Skip to content

An object detection system powered by the YOLOv5s pretrained model πŸš€, trained on 2,086 images (1,461 training, 417 validation, 208 testing). Data annotation was done using Roboflow πŸ–ŒοΈ, and training took place on Google Colab for 250 epochs.πŸ”₯πŸ’₯ The model achieved high accuracy on both validation and test datasets! 🎯πŸ”₯πŸ’₯

License

Notifications You must be signed in to change notification settings

shaheennabi/Object_detection-End-to-End-project

Repository files navigation

πŸŽ†πŸŽ‰ Object_detection-End-to-End-project πŸŽ‰πŸŽ†

Project Overview

  • Objective: Develop an object detection system using the YOLOv5s pretrained model.

  • Dataset:

    • Total Images: 2,086 images
    • Training Images: 1,461
    • Validation Images: 417
    • Testing Images: 208
    • Annotation Tool: Data was annotated using Roboflow for efficient labeling.
  • Model Training:

    • Framework: Utilized the YOLOv5s model, known for its speed and accuracy.
    • Environment: Training conducted on Google Colab with GPU support.
    • Epochs: The model was trained for 250 epochs, resulting in significant improvements in detection accuracy.
    • Performance: The trained model demonstrated great accuracy on the validation and testing datasets.
  • Additional Information: Further details, including setup instructions and usage, can be found in the project repository.

πŸŽ‹ Project Tree Structure πŸŽ‹

Object_Detection-End-to-End-project/
  β”œβ”€β”€ .github/
  β”‚   └── workflows/
  β”‚       └── main.yaml
  β”œβ”€β”€ .jenkins/
  β”‚   └── Jenkinsfile
  β”œβ”€β”€ artifact/
  β”‚   └── 10_05_2024_03_23_14 (or time Stamp)/
  β”‚       β”œβ”€β”€ data_ingestion/
  β”‚       β”‚   β”œβ”€β”€ feature_store/
  β”‚       β”‚   β”‚   β”œβ”€β”€ test
  β”‚       β”‚   β”‚   β”œβ”€β”€ train
  β”‚       β”‚   β”‚   β”œβ”€β”€ valid
  β”‚       β”‚   β”‚   └── data.yaml
  β”‚       └── SignLangData.Zip
  β”‚       β”œβ”€β”€ data_validation/
  β”‚       β”‚   └── status.txt           
  β”‚       └── model_trainer/
  β”‚           └── best.pt
  β”œβ”€β”€ data/
  β”‚   β”œβ”€β”€ .gitkeep
  β”‚   └── inputImage.jpg
  β”œβ”€β”€ flowchart/
  β”œβ”€β”€ logs/
  β”œβ”€β”€ notebook/
  β”‚   β”œβ”€β”€ Object_Detection_with_Yolov5.ipynb
  β”‚   └── test.ipynb
  β”œβ”€β”€ scripts/
  β”‚   β”œβ”€β”€ ec2_setup.sh
  β”‚   └── jenkins.sh
  β”œβ”€β”€ SignLanguage or src/
  β”‚   β”œβ”€β”€ components/
  β”‚   β”‚   β”œβ”€β”€ __pycache__/
  β”‚   β”‚   β”œβ”€β”€ __init__.py
  β”‚   β”‚   β”œβ”€β”€ data_ingestion.py
  β”‚   β”‚   β”œβ”€β”€ data_validation.py
  β”‚   β”‚   β”œβ”€β”€ model_pusher.py
  β”‚   β”‚   └── model_trainer.py
  β”‚   β”œβ”€β”€ configuration/
  β”‚   β”‚   β”œβ”€β”€ __pycache__/
  β”‚   β”‚   β”œβ”€β”€ logs/
  β”‚   β”‚   β”œβ”€β”€ __init__.py
  β”‚   β”‚   β”œβ”€β”€ gdown_connection.py
  β”‚   β”‚   └── s3_operations.py
  β”‚   β”œβ”€β”€ constants/
  β”‚   β”‚   β”œβ”€β”€ __pycache__/
  β”‚   β”‚   β”œβ”€β”€ __init__.py
  β”‚   β”‚   └── training_pipeline/
  β”‚   └── entity/
  β”‚       β”œβ”€β”€ __pycache__/
  β”‚       β”œβ”€β”€ __init__.py
  β”‚       β”œβ”€β”€ artifact_entity.py
  β”‚       └── config_entity.py
  β”œβ”€β”€ templates/
  β”‚   └── index.html
  β”œβ”€β”€ yolov5/
  β”œβ”€β”€ app.py
  β”œβ”€β”€ data_collector.py
  β”œβ”€β”€ docker_compose.yml
  β”œβ”€β”€ Dockerfile
  β”œβ”€β”€ README.md
  β”œβ”€β”€ requirements.txt
  β”œβ”€β”€ setup.py
  └── template.py

Installation Instructions

  1. Clone the repository:
    git clone https://github.com/shaheennabi/Object_detection-End-to-End-project.git
    cd Object_detection-End-to-End-project
  • Create a new conda environment and activate it:
conda create -n signLanguage python=3.10 -y
conda activate signlanguage
  • Install the required dependencies:
pip install -r requirements.txt

Export the environment variable(anaconda prompt)

set DATA_DOWNLOAD_URL=https://drive.google.com/uc?/export=download&id=  your file_id goes here"

Export the environment variable(git bash)

export DATA_DOWNLOAD_URL="https://drive.google.com/file/d/ your file_id goes here"

πŸŽ‰ Workflow πŸŽ‰

After creating the project template:

  • πŸŽ‡ Update constants πŸŽ†
  • πŸŽ‡ Update Entity modules πŸŽ†
  • πŸŽ‡ Update respective component πŸŽ†
  • πŸŽ‡ Update pipeline πŸŽ†
  • πŸŽ‰ Endpoint - (app.py) πŸŽ‰

πŸŽ† Model Training πŸŽ†

  1. Ensure the dataset is properly loaded in the data/ folder.

  2. Run the training script:

    python  cd yolov5/ && python train.py --img 416 --batch 16 --epochs 300 --data '../data.yaml' --cfg ./models/custom_yolov5s.yaml --weights 'yolov5s.pt' --name yolov5s_results  --cache

To use the trained model for inference on new images, run:

python cd yolov5/ && python detect.py --weights /content/runs/train/yolov5s_results/weights/best.pt --img 416 --conf 0.5 --source /content/test/images

Deployment

To deploy the application locally:

  1. Install the dependencies in requirements.txt.
  2. Run the Flask app:
    python app.py
    
    

Deployment (CI/CD)

Run these commands on EC2 Machine

  • Update package lists
sudo apt update
  • Update package lists (alternate command)
sudo apt-get update
  • Upgrade the system
sudo apt upgrade -y
  • Download Docker installation script
curl -fsSL https://get.docker.com -o get-docker.sh
  • Run the Docker installation script
sudo sh get-docker.sh
  • Add current user to the Docker group (run both lines)
sudo usermod -aG docker $USER
sudo usermod -aG docker $USER
  • Install AWS CLI
sudo apt install awscli -y  (if not worked- install with curl -check doc)
  • AWS Configuration
aws configure

Run these commands to install Jenkins on EC2

  • Update package lists
sudo apt update
  • Install OpenJDK 8
sudo apt install openjdk-8-jdk -y
# Jenkins repository (links for reference)
# https://pkg.jenkins.io/
# https://pkg.jenkins.io/debian-stable/
  • Start Jenkins service
sudo systemctl start jenkins
  • Enable Jenkins to start on boot
sudo systemctl enable jenkins
  • Check the status of Jenkins service
sudo systemctl status jenkins
  • Download Docker installation script
curl -fsSL https://get.docker.com -o get-docker.sh
  • Run the Docker installation script
sudo sh get-docker.sh
  • Add current user to Docker group
sudo usermod -aG docker $USER
  • Add Jenkins user to Docker group
sudo usermod -aG docker jenkins
  • Activate Docker group changes
newgrp docker
  • Install AWS CLI
sudo apt install awscli -y
  • Add Jenkins to Docker group again to ensure it has access
sudo usermod -a -G docker jenkins
  • Download Docker installation script
curl -fsSL https://get.docker.com -o get-docker.sh
  • Run the Docker installation script
sudo sh get-docker.sh
  • Add current user to Docker group
sudo usermod -aG docker $USER
  • Add Jenkins user to Docker group
sudo usermod -aG docker jenkins
  • Activate Docker group changes
newgrp docker
  • Install AWS CLI
sudo apt install awscli -y
  • Add Jenkins to Docker group again to ensure it has access
sudo usermod -a -G docker jenkins
  • Retrieve the initial Jenkins admin passwo
sudo cat /var/lib/jenkins/secrets/initialAdminPassword

About

An object detection system powered by the YOLOv5s pretrained model πŸš€, trained on 2,086 images (1,461 training, 417 validation, 208 testing). Data annotation was done using Roboflow πŸ–ŒοΈ, and training took place on Google Colab for 250 epochs.πŸ”₯πŸ’₯ The model achieved high accuracy on both validation and test datasets! 🎯πŸ”₯πŸ’₯

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages