Site icon Machine Learning Projects

Easiest way to Train yolov7 on the custom dataset – 2022

Machine Learning Projects

Hey guys in this blog we will see how we can Train yolov7 on the custom dataset and create a Number Plate Detector.

Sneak Peek at our Output…

Yolov7 is the new state-of-the-art real-time object detection model.

You can use it for different industrial applications. Also, you can optimize the model, that is, converting the model to ONNX, TensorRT, etc, which will increase the throughput and run the edge devices.

In this blog, we will see the step-by-step guide to Train yolov7 on the custom dataset.

So without any further due, let’s do it…

Step 1 – Clone YOLOv7 Repo

Clone the yolov7 repository from GitHub by running the following command in the terminal.

git clone

Step 2 – Install requirements


Step 3 – Let’s Prepare the data

Step 4 – Editing Config Files

Step 5 – Download pre-trained yolov7 weights

Step 6 – Let’s Train yolov7 on the custom dataset

from google.colab import drive

!pip install -r drive/MyDrive/yolov7/requirements.txt
!pip install -r drive/MyDrive/yolov7/requirements_gpu.txt

%cd drive/MyDrive/yolov7/
!python --workers 1 --device 0 --batch-size 16 --epochs 100 --img 640 640 --hyp data/hyp.scratch.custom.yaml --name yolov7-custom --weights

Step 7 -Testing our custom Model

!python --weights --conf 0.5 --img-size 640 --source img.jpg --view-img --no-trace

For Colab Environment run the following command, because e can’t view image in Colab.

!python --weights --conf 0.5 --img-size 640 --source 1.mp4 --no-trace


NOTE – If you ever need to change data in the ‘yolov7/data’ folder, make sure to delete cache files.

So in this way you can Train yolov7 on the custom dataset in the easiest way possible.

Read my last post on – Best Data Science Resources

Check out my other machine learning projectsdeep learning projectscomputer vision projectsNLP projects, and Flask projects at

Exit mobile version