🚀 Train your own custom YOLOv3 object detection model with ease! 🌟
Welcome to the YOLOv3 Object Detection Training repository! This project provides a comprehensive guide and tools to train your own custom YOLOv3 model for object detection tasks. Whether you're working on surveillance, autonomous vehicles, or any other computer vision project, our project simplifies the process.
🔥 Key Features:
- 🖼️ Custom Dataset Support: Easily train on your own dataset.
- 🚁 State-of-the-Art Accuracy: Utilize the power of YOLOv3 architecture.
- 🧪 Fine-Tuning Options: Customize and fine-tune pre-trained models.
- 📈 Monitoring and Visualization: Track your training progress with rich visualizations.
- 🤝 Community-Driven: Active contributors and open to collaborations.
Get your project up and running in no time! Follow these simple steps:
Make sure you have the following prerequisites installed:
- Python 3.x
- CUDA (for GPU acceleration)
- Cheack Gpu :
!nvidia-smi
- Mount Google drive :
from google.colab import drive
drive.mount('/content/gdrive')
- Clone, configure & compile Darknet:
!git clone https://github.com/AlexeyAB/darknet
%cd darknet
!sed -i 's/OPENCV=0/OPENCV=1/' Makefile
!sed -i 's/GPU=0/GPU=1/' Makefile
!sed -i 's/CUDNN=0/CUDNN=1/' Makefile
!make
- Configure yolov3.cfg file:
!cp cfg/yolov3.cfg cfg/yolov3_training.cfg
!sed -i 's/batch=1/batch=64/' cfg/yolov3_training.cfg
!sed -i 's/subdivisions=1/subdivisions=16/' cfg/yolov3_training.cfg
!sed -i 's/max_batches = 500200/max_batches = 4000/' cfg/yolov3_training.cfg
!sed -i '610 s@classes=80@classes=2@' cfg/yolov3_training.cfg
!sed -i '696 s@classes=80@classes=2@' cfg/yolov3_training.cfg
!sed -i '783 s@classes=80@classes=2@' cfg/yolov3_training.cfg
!sed -i '603 s@filters=255@filters=21@' cfg/yolov3_training.cfg
!sed -i '689 s@filters=255@filters=21@' cfg/yolov3_training.cfg
!sed -i '776 s@filters=255@filters=21@' cfg/yolov3_training.cfg
- Create .names and .data files:
!echo -e 'job\nbeam_number' > data/obj.names
!echo -e 'classes= 2\ntrain = data/train.txt\nvalid = data/test.txt\nnames = data/obj.names\nbackup = /content/weight' > data/obj.data
- Save yolov3_training.cfg and obj.names files in Google drive:
!mkdir /content/gdrive/MyDrive/Yolo_v3/yolov3_testing.cfg
!mkdir /content/gdrive/MyDrive/Yolo_v3/classes.txt
!cp cfg/yolov3_training.cfg /content/gdrive/MyDrive/Yolo_v3/yolov3_testing.cfg
!cp data/obj.names /content/gdrive/MyDrive/Yolo_v3/classes.txt
- Create a folder and unzip image dataset:
!mkdir data/obj
!unzip /content/gdrive/MyDrive/ocr_ds.zip -d data/obj
- Create train.txt file:
import glob
images_list = glob.glob("data/obj/ocr_ds/*.jpg")
with open("data/train.txt", "w") as f:
f.write("\n".join(images_list))
- Download pre-trained weights for the convolutional layers file:
!wget https://pjreddie.com/media/files/darknet53.conv.74
- Start training:
!./darknet detector train data/obj.data cfg/yolov3_training.cfg darknet53.conv.74 -dont_show
# Uncomment below and comment above to re-start your training from last saved weights
#!./darknet detector train data/obj.data cfg/yolov3_training.cfg /mydrive/yolov3/yolov3_training_last.weights -dont_show