Vehicle detection and classification project (2024)
In this project, the aim is to train machine learning models for detection and classification of vehicles and run them in a web application for real-time inference. The project focuses on utilizing computer vision techniques to automatically identify vehicles in a road and classify vehicles based on their make and model.
- Data Collection: Download the Roboflow-100 Vehicles Collection for detection tasks and Stanford Car Dataset for classification tasks.
- Data Preprocessing: Clean and preprocess the dataset to prepare it for training the models.
- Model Training: Train computer vision models using state-of-the-art techniques and frameworks such as PyTorch.
- Evaluation: Evaluate the trained models on test datasets to measure their accuracy, precision, and other measures.
- Integration: Integrate the trained models into an application for real-time vehicle detection and classification.
- Prior to installing WSL in Windows
- Search in Windows: Control Panel > Programs > Activate or deactive Windows features.
- Enable "Virtual Machine Platform", "Windows Hypervisor Platform" and "Windows Subsytem for Linux".
- Restart your PC after making those changes.
- Steps to install WSL in Windows
-
Go to Microsoft Store and install "Windows Subsystem for Linux".
-
Open Windows Powershell as Administrator and check if WSL is installed:
wsl --status
-
Go back to Microsoft Store and install "Debian" or "Ubuntu".
-
Open the chosen OS terminal and create a UNIX user and password. Then install git:
sudo apt update && sudo apt install git -
Open VS Code and select the blue button in the bottom left corner to create a Remote Connection with WSL option.
- Clone the repository:
-
Open a new terminal in VS Code and execute:
git clone https://github.com/carvarsou/Vehicle-Classification
- Install Miniconda:
-
Execute these commands to install Miniconda:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh bash Miniconda3-latest-Linux-x86_64.sh
-
Check if Miniconda is added to the PATH:
nano ~/.bashrc export PATH="$HOME/miniconda3/bin:$PATH"
-
Reload the Shell Configuration:
source ~/.bashrc
-
Verify installation:
conda --version
- Create a Conda Environment:
-
Install a new environment:
conda create --name env python=3.10
If you already have an environment to use, downgrade the version as so:
conda activate <your_env> conda install python=3.10
-
Activate the Environment:
conda init conda activate env
To deactivate:
conda deactivate env
-
Install the requirements:
-
Make sure Conda Environment is now activated. Then install Torch and other packages:
pip install -r requirements.txt
-
Install npm and node.js:
# installs nvm (Node Version Manager) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash # download and install Node.js (you may need to restart the terminal) cd ~/.nvm && nvm install 22 npm install -g pnpm
- Run the train file of each model in the core folder.
python -m core.detect_vehicles.yolov5.train python -m core.detect_vehicles.yolov8.train python -m core.classify_vehicles.efficientnet_b1.train python -m core.classify_vehicles.yolov8.train ...
- The app uses Swagger as the API framework.
cd <path_to>/Vehicle-Classification # Generates .env file for local settings echo -e "DJANGO_KEY='$(python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())')'\nDEBUG=True" > .env # Runs SQLite server ./webapp/vc_backend/manage.py makemigrations ./webapp/vc_backend/manage.py migrate ./webapp/vc_backend/manage.py runserver
-
The app uses Vue.js 3 + Vite as the frontend framework.
Open another terminal:
cd <path_to>/Vehicle_Classification/webapp/vc_frontend/perseidai pnpm up pnpm dev
This project is released under the Apache 2.0 License. For more information, check: https://www.apache.org/licenses/LICENSE-2.0.
Carlos Varela Soult (carvarsou)