Here, We are targeting complete automation of the garbage collection system which includes identification of garbage. This is the critical task where knowledge of image processing and machine learning will be applied.
-
Create Virtual Environment.(Optional)
python -m venv yolov7_custom
source yolov7_custom/bin/activate
-
Annonate dataset using labelImg in YOLO format.
To install labelImg use command "pip install labelImg" in your command prompt and after installation type "labelImg" in command prompt and annonate your data.
-
Split the dataset in train and val folder and save images and labels in data folder as shown below.
-
Install pre-reuirements for YOLOv7 by running "pip install -r requirements.txt" and "pip install -r requirements_gpu.txt".
-
Modify "data/custom_data.yaml" and "cfg/training/yolov7-custom.yaml" files.
-
Install YOLOv7 model using this link : "https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt".
-
Train YOLOv7 on custom dataset.
code : "python train.py --workers 1 --device 0 --batch-size 8 --epochs 100 --img 640 640 --data data/custom_data.yaml --hyp data/hyp.scratch.custom.yaml --cfg cfg/training/yolov7-custom.yaml --name yolov7_custom --weights yolov7.pt"
After running the above code it will create runs folder and store te training information in runs/train/yolov7-custom.
-
Testing on images
code : "python detect.py --weights runs/train/yolov7-custom/weights/best.pt --img-size 640 --source image_test.jpg --view-img --no-trace"
Working Video: