Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Repository demonstrating how to train a custom CNN model based on yolo-v4-tiny architecture. This can be utilized for image classification, image localization or object detection applications.

Notifications You must be signed in to change notification settings

MGTheTrain/python-yolo-training-with-jupyter-notebooks

Repository files navigation

python-yolo-training-with-jupyter-notebooks

Table of Contents

Summary

Repository demonstrating how to train a custom CNN model based on yolo-v4-tiny architecture. This can be utilized for image classification, image localization or object detection applications.

Open custom-yolov4-tiny-training.ipynb in Colab

References

How to use

Labeling images

Add your images (e.g. .JPG files) to the img folder and label your images. For labeling images utilize for example one of the following:

Modify train.txt to encompass all JPG files for training purposes, and adjust test.txt to incorporate all JPG files for validation. Also update the obj.names file to list your classes.

Updating the yolov4-tiny-custom.cfg file

Adjust in the yolov4-tiny-custom.cfg the width, height, batch, subdivision, max_batches, steps, classes and filters hyperparameter values. Refer to section 3(a) Create and upload the labeled custom dataset “obj.zip” file to the “yolov4-tiny” folder on your drive here or copy the original file which can be found here yolov4-tiny-custom.cfg and replace this yolov4-tiny-custom.cfg.

Uploading the custom-data folder to Google Drive

Upload the data-custom folder to Google Drive.

Running code blocks of the custom Jupyter notebook in Google Colab

Open custom-yolov4-tiny-training.ipynb in Colab and run each code block

Init and update git submodules

Execute the following steps in order to initialize the git submodule containing the object detector app:

# On Unix terminals
git submodule init --update
# or on Windows OS
git submodule init
git submodule update

Utilize your trained weights in the sample object detector app

Copy custom .weights, .cfg and .names files to appropriate destination pathes:

# On Unix terminals
cp <your download folder path>/yolov4-tiny-custom_best.weights python-object-detection-with-yolo-and-opencv/weights
cp data-custom/yolov4-tiny-custom.cfg python-object-detection-with-yolo-and-opencv/cfg
cp data-custom/obj.names python-object-detection-with-yolo-and-opencv/object-names
# On Powershell (Windows OS)
Copy-Item "<your download folder path>\yolov4-tiny-custom_best.weights" -Destination "python-object-detection-with-yolo-and-opencv\weights"
Copy-Item "data-custom\yolov4-tiny-custom.cfg" -Destination "python-object-detection-with-yolo-and-opencv\cfg"
Copy-Item "data-custom\obj.names" -Destination "python-object-detection-with-yolo-and-opencv\object-names"

In python-object-detection-with-yolo-and-opencv install the pip package requirements if not yet done and launch the object detector app via

cd python-object-detection-with-yolo-and-opencv
python object_detector_app.py --model custom-yolov4-tiny

About

Repository demonstrating how to train a custom CNN model based on yolo-v4-tiny architecture. This can be utilized for image classification, image localization or object detection applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published