/yolov3

YOLOv3 object detection Training in Google Colab | AI Machine learning Examples and tutorials on using computer vision models and techniques. Learn everything through YOLO and object-detection

Primary LanguageJupyter NotebookGNU General Public License v2.0GPL-2.0

YOLOv3 Object Detection Training In Google Colab

Stars Issues Forks

๐Ÿš€ Train your own custom YOLOv3 object detection model with ease! ๐ŸŒŸ

Demo Animation

Table of Contents

About

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.

Getting Started

Get your project up and running in no time! Follow these simple steps:

Prerequisites

Make sure you have the following prerequisites installed:

  • Python 3.x
  • CUDA (for GPU acceleration)
  1. Cheack Gpu :
!nvidia-smi
  1. Mount Google drive :
from google.colab import drive
drive.mount('/content/gdrive')
  1. 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
  1. 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
  1. 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
  1. 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
  1. Create a folder and unzip image dataset:
!mkdir data/obj
!unzip /content/gdrive/MyDrive/ocr_ds.zip -d data/obj
  1. 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))
  1. Download pre-trained weights for the convolutional layers file:
!wget https://pjreddie.com/media/files/darknet53.conv.74
  1. 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