Site icon Machine Learning Projects

Easiest way to Train yolov7 on the custom dataset – 2023

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…

https://machinelearningprojects.net/wp-content/uploads/2022/10/Train-yolov7-on-the-custom-dataset.mp4

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 https://github.com/WongKinYiu/yolov7.git

Step 2 – Install requirements

-i https://download.pytorch.org/whl/cu113
torch==1.11.0+cu113
torchvision==0.12.0+cu113

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
drive.mount('/content/drive')

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

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

Step 7 -Testing our custom Model

!python detect.py --weights best.pt --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 detect.py --weights best.pt --conf 0.5 --img-size 640 --source 1.mp4 --no-trace

Output

https://machinelearningprojects.net/wp-content/uploads/2022/10/Train-yolov7-on-the-custom-dataset.mp4

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 machinelearningprojects.net

Exit mobile version