In the earlier video explaining the dataset structure, you mentioned to put the [train, test, val] folder in the images and labels folder respectively. However, in this examples at 9:15, there are train, test and val folders containing images and labels. which one to use?
This function is added to download the dataset from the provided URL and duplication check. Once the dataset is downloaded the for loop iterate the whole folder and displays the images and labels name. So it means that the directory is created successfully and the files are added. This code is added to show that files are extracted and we can see the image's names and label names. The inner loop (j%==2) is showing that if the image is repetitive then remove them.
7:40 We use that code block to go into each directory (train, valid, test) and remove images and labels at the even number places. The reason is to remove all duplicated files from the dataset.
I'm running this notebook through VSCode and I'm on the section where the model trains. I'm on the first epoch and around 11 minutes in. Is this the expected behavior? You said in your video that training 25 epochs took 0.096 hours (which equals around 6 minutes). I'm using an m1 macbook, so performance shouldn't be an issue. Do you know what the issue may be?
The bottleneck could depend on the dataset, the device, or the training configuration. In this case the issue could be due to M1 MacBook, because it does not have a dedicated GPU.
I think the code section after where you download the zip file, is there to make sure that only one image exists, actually, there are two images of a sample, so we remove one image and the label as well.
Hey, drawing bounding boxes is an object detection problem, while colouring the objects is a segmentation problem. Please check out our segmentation playlist to know more: th-cam.com/play/PLfYPZalDvZDI9jLmgXgUgBOz7YCNlT8DP.html
Very good explanation. Hi Sir. I have been following your tutorial on how to train a custom Yolov5 object detector as I am doing a school project on vehicle detection. I am having an error on training my model. Is it ok if you can help on this please.
Hi! YOLOv5 itself is a single stage object detector. In case you want to go for two stage detectors, Faster RCNN models are some of the best ones. Further, if you want to use any component of YOLOv5 in two stage detection, you can take the YOLOv5 CSP backbone and attach it two the Faster RCNN head. That will also work as a two stage detector.
Get expert guidance, insider tips n tricks and Create stunning images, learn to fine tune diffusion models, advanced Image Editing techniques like In-Painting, Instruct Pix2Pix and many more. Join our Kickstarter campaign now! bit.ly/3JYh7A6
📚 LINK TO BLOGPOST: learnopencv.com/custom-object-detection-training-using-yolov5/ ▶ LINK TO YOLO MASTERCLASS PLAYLIST: th-cam.com/play/PLfYPZalDvZDLALsG9o-cjwNelh-oW9Xc4.html
#each folder has duplicate images and labels dirs = ['train', 'valid', 'test'] #loop through 'train', 'valid', and 'test' for i, dir_name in enumerate(dirs): #store all images name in from each folder and store it temp variable all_image_names all_image_names = sorted(os.listdir(f"{dir_name}/images/")) #loop through all_image_names for j, image_name in enumerate(all_image_names): #because we have duplicate images and lavel so delete only even number image or you can say store first one delete second one if (j % 2) == 0: #because label file extenstion is .txt not job so grab the file name file_name = image_name.split('.jpg')[0] #direct remove the every images 2'nd duplicate os.remove(f"{dir_name}/images/{image_name}") # using the file name delete the 2'nd label file os.remove(f"{dir_name}/labels/{file_name}.txt")
Hey nice video, but I am not able to understand how to run train.py file successfully on my colab. Below is the error i am getting again and again. even after pasting the correct path of yaml file. This is the code i have written in my colab. ! python train.py --img 640 --batch 16 --epochs 3 --data '/content/drive/MyDrive/DL_unzipdata_files/Vehicle_object_detection/data.yaml' --weights yolov5s.pt This is the msg I am getting Dataset not found ⚠, missing paths ['/content/yolov5/valid/images'] Traceback (most recent call last): File "train.py", line 634, in main(opt) File "train.py", line 528, in main train(opt.hyp, opt, device, callbacks) File "train.py", line 111, in train data_dict = data_dict or check_dataset(data) # check if None File "/content/yolov5/utils/general.py", line 542, in check_dataset raise Exception('Dataset not found ❌') Exception: Dataset not found ❌
@sovitrath4735 Hey, thanks for replying, as i am new to object detection, i had no idea that we could edit the yaml file. So i have sorted the issue. Just a suggestion please make videos as the users are entirely beginners, not just read out the code. As the person from the video has not mentioned many things which i have to take help through other coders and took me 5 days to implement the code from scratch.
I meant. You are absolutely fantastic at explaining. Very instructive. Big fan already
Thank you! 😃 Glad you enjoyed it!
Glad to get this from you directly. Closing in on the expert bundle, CV has me.
Time Stamps:
0:00-00:20: Introduction
00:20-00:29: YOLOv5n (Nano)
00:29-00:38: YOLOv5s (Small)
00:38-00:52: YOLOv5m (Medium)
00:52-01:02: YOLOv5l (Large)
01:02-01:50: YOLOv5x (Extra Large)
1:50-02:45: Code Explanation
02:45-04:19: Imports
04:19-05:39: Epochs
05:39-08:39: Download and Prepare Dataset
08:39-09:55: Dataset Structure of YOLOv5
09:55-13:59: Helper Function for Logging results
13:59-17:57: Clone YOLOv5 Repo
17:57-26:24: Train the model
26:24-33:20: Training Process
33:20-36:06: Training Summary and results
36:06-48:09: Inference
Clearly explained the concepts practically
Hey! I'm glad you liked the video. Checkout other videos in the YOLO playlist, and do subscribe for more!
In the earlier video explaining the dataset structure, you mentioned to put the [train, test, val] folder in the images and labels folder respectively. However, in this examples at 9:15, there are train, test and val folders containing images and labels. which one to use?
Thanks, consistently high quality advice and guidance
Thank you for your kind words.
lutely fantastic at explaining. Very educational. Big fan already
🎉❤🎉❤❤ 0:00 😮
@babalukumar6381
😅😅😊
[Q&A-8:00] Because the dataset contains duplicate files of the images and labels, the referred code removes the doubles (images and labels)
This function is added to download the dataset from the provided URL and duplication check.
Once the dataset is downloaded the for loop iterate the whole folder and displays the images and labels name.
So it means that the directory is created successfully and the files are added. This code is added to show that files are extracted and we can see the image's names and label names. The inner loop (j%==2) is showing that if the image is repetitive then remove them.
Just great, thank you!
It was really helpful thank you
Glad we could be of help! Please subscribe to our channel to never miss out on the YOLO series!
Thank you so much teacher
Very informative…
Thank you
Glad it was helpful! :)
7:40 We use that code block to go into each directory (train, valid, test) and remove images and labels at the even number places. The reason is to remove all duplicated files from the dataset.
Hi there, you deserved your like for the introduction alone. Good overview and detailed explanation. Liked and subbed
I'm running this notebook through VSCode and I'm on the section where the model trains. I'm on the first epoch and around 11 minutes in. Is this the expected behavior? You said in your video that training 25 epochs took 0.096 hours (which equals around 6 minutes). I'm using an m1 macbook, so performance shouldn't be an issue. Do you know what the issue may be?
The bottleneck could depend on the dataset, the device, or the training configuration. In this case the issue could be due to M1 MacBook, because it does not have a dedicated GPU.
I think the code section after where you download the zip file, is there to make sure that only one image exists, actually, there are two images of a sample, so we remove one image and the label as well.
For transfer learning, how many layers are there in total , so if the you froze the first 15, how many are being trained ?
Hey, how can we use live video from webcam to test the model?
can YOLO detect smal objects? like taken from the plane or something like google earth? Or is there a model that id better suited for this role?
Same que did you get the answer
Is there any way to make the model color the objects detected instead of putting them in a box?
Hey, drawing bounding boxes is an object detection problem, while colouring the objects is a segmentation problem. Please check out our segmentation playlist to know more: th-cam.com/play/PLfYPZalDvZDI9jLmgXgUgBOz7YCNlT8DP.html
Very good explanation. Hi Sir. I have been following your tutorial on how to train a custom Yolov5 object detector as I am doing a school project on vehicle detection. I am having an error on training my model. Is it ok if you can help on this please.
Hi sir, the yolov5 confusion matrix does not match the precision rate and recall rate
well how to recognize yolov5 training when overfits? is that from Precission when it reach values : 1 ?
Thanks for the video. How is the best way to prepare dataset of multiple classes passing conveyor belt ? static Ip camera
this is a great video, how can we use this model on a pythone or rasberi machine without internet
No, we cannot train YOLOv5 on Raspberry Pi. However, we can run inference using an optimized YOLOv5 model on the device.
Dear how i could use yolov5 in two phases object detection ?
Hi! YOLOv5 itself is a single stage object detector. In case you want to go for two stage detectors, Faster RCNN models are some of the best ones. Further, if you want to use any component of YOLOv5 in two stage detection, you can take the YOLOv5 CSP backbone and attach it two the Faster RCNN head. That will also work as a two stage detector.
How i can use the model to run yolov5 for real time inject detection
Yes, you can! You'll have to train the model using custom insect dataset.
I have to integrate the trained model in my project
The code Added after downloading the data is there to check for duplicates and remove them.
Hi excellent explanation. Love your videos. Can I use this video to prepare a research paper? please confirm
Thank you and you may go ahead! Please give us credit for the same. :)
is it possible to count the objects after the detection
Hi, yes. You can checkout this code: github.com/ultralytics/yolov5/issues/2696#issuecomment-815061140 and update it as per your liking.
Hi I want to export the trained model and use it in my local machine
Get expert guidance, insider tips n tricks and Create stunning images, learn to fine tune diffusion models, advanced Image Editing techniques like In-Painting, Instruct Pix2Pix and many more.
Join our Kickstarter campaign now! bit.ly/3JYh7A6
The code block (mentioned in "Imports") is to delete every second image and label correspondingly, because they occur twice in their folders.
Love your content .I guess you are from revenshaw.My gf sister everybody from their
📚 LINK TO BLOGPOST: learnopencv.com/custom-object-detection-training-using-yolov5/
▶ LINK TO YOLO MASTERCLASS PLAYLIST: th-cam.com/play/PLfYPZalDvZDLALsG9o-cjwNelh-oW9Xc4.html
Hello thank you for this good video , but the code is does not work for me , If you can help me and thank you again
where is ipynb ?
Hi, you can find the notebook here: github.com/spmallick/learnopencv/tree/master/Custom-Object-Detection-Training-using-YOLOv5
pake model jangan pretrained
#each folder has duplicate images and labels
dirs = ['train', 'valid', 'test']
#loop through 'train', 'valid', and 'test'
for i, dir_name in enumerate(dirs):
#store all images name in from each folder and store it temp variable all_image_names
all_image_names = sorted(os.listdir(f"{dir_name}/images/"))
#loop through all_image_names
for j, image_name in enumerate(all_image_names):
#because we have duplicate images and lavel so delete only even number image or you can say store first one delete second one
if (j % 2) == 0:
#because label file extenstion is .txt not job so grab the file name
file_name = image_name.split('.jpg')[0]
#direct remove the every images 2'nd duplicate
os.remove(f"{dir_name}/images/{image_name}")
# using the file name delete the 2'nd label file
os.remove(f"{dir_name}/labels/{file_name}.txt")
Hey nice video, but I am not able to understand how to run train.py file successfully on my colab.
Below is the error i am getting again and again. even after pasting the correct path of yaml file.
This is the code i have written in my colab.
! python train.py --img 640 --batch 16 --epochs 3 --data '/content/drive/MyDrive/DL_unzipdata_files/Vehicle_object_detection/data.yaml' --weights yolov5s.pt
This is the msg I am getting
Dataset not found ⚠, missing paths ['/content/yolov5/valid/images']
Traceback (most recent call last):
File "train.py", line 634, in
main(opt)
File "train.py", line 528, in main
train(opt.hyp, opt, device, callbacks)
File "train.py", line 111, in train
data_dict = data_dict or check_dataset(data) # check if None
File "/content/yolov5/utils/general.py", line 542, in check_dataset
raise Exception('Dataset not found ❌')
Exception: Dataset not found ❌
Can you please check that the dataset has been downloaded and extacted correctly?
@sovitrath4735 Hey, thanks for replying, as i am new to object detection, i had no idea that we could edit the yaml file.
So i have sorted the issue.
Just a suggestion please make videos as the users are entirely beginners, not just read out the code.
As the person from the video has not mentioned many things which i have to take help through other coders and took me 5 days to implement the code from scratch.