Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

104 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vehicle-Classification

Vehicle detection and classification project (2024)

Introduction

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.

Project Components

  1. Data Collection: Download the Roboflow-100 Vehicles Collection for detection tasks and Stanford Car Dataset for classification tasks.
  2. Data Preprocessing: Clean and preprocess the dataset to prepare it for training the models.
  3. Model Training: Train computer vision models using state-of-the-art techniques and frameworks such as PyTorch.
  4. Evaluation: Evaluate the trained models on test datasets to measure their accuracy, precision, and other measures.
  5. Integration: Integrate the trained models into an application for real-time vehicle detection and classification.

Installation in Windows/Linux

Prerequisites (only in Windows)

  1. 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.
  1. 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.

Steps to Install the Environment

  1. Clone the repository:
  • Open a new terminal in VS Code and execute:

    git clone https://github.com/carvarsou/Vehicle-Classification
  1. 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
  1. 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
  1. Activate the Environment:

    conda init
    conda activate env

    To deactivate:

    conda deactivate env
  2. 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

Usage

Training the models (optional)

  • 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
    ...

Running the webapp API locally

  • 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

Running the application UI locally

  • 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

License

This project is released under the Apache 2.0 License. For more information, check: https://www.apache.org/licenses/LICENSE-2.0.

Contributors

Carlos Varela Soult (carvarsou)

Acknowledgements

Roboflow 100 Project

Stanford Car Dataset by J. Utrera

About

🚗 Vehicle detection and classification project (2024)

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages