How to train a custom YOLOv5 model using CodeProject.AI Training for YoloV5 6.2 module

MikeLud1

IPCT Contributor
Joined
Apr 5, 2017
Messages
2,214
Reaction score
4,253
Location
Brooklyn, NY
Below are some recommendations for training a custom model
  • Stop using all other CodeProject.AI modules (Training a model needs all the resources it can get)
  • Nvidia GPU with as much VRAM is recommended (You can train with a CPU but it will be extremely slow and can take days to have well performing model)
  • Use over 1,000 images when training. (My custom models were trained with over 70,000 images)
First step is to install Training for YoloV5 6.2 module
1703732308344.png

After the Training for YoloV5 6.2 module is installed start the module
1703732455351.png

Next open CodeProject.AI Explorer
1703732641393.png

When on the Explorer page click on Train.
1703732733626.png

To train a custom model you need to create a dataset of image. The Training for YoloV5 6.2 module can create the dataset using images from Open Images Dataset V7 (see the below link for details on Open Images Dataset V7)

To see a list of the available classes in the Open Images Dataset V7 click on the exclamation point (there are 600 object classes to choose from)
1703733595686.png

Lets create a dataset named Pets with 10,000 image and the classes in this dataset will be Cat and Dog. To start creating the dataset click on Create Dataset. (creating the dataset will take some time to build, for me it took about 10 minutes)
1703734057777.png

The dataset will be saved in the below folder.
1703735122787.png

Now you have the dataset named Pets ready for training. Below are my typical training settings, to start the training click on Train Model. (I will add more details on each of the settings tomorrow)
1703735844960.png
 

BORIStheBLADE

Getting comfortable
Joined
Feb 14, 2016
Messages
740
Reaction score
2,070
Location
North Texas
MikeLud,

Is the this model we end up training something we can maintain ourselves? Basically is it stored on our PC and we can back it up?
 

mailseth

Getting the hang of it
Joined
Dec 22, 2023
Messages
124
Reaction score
87
Location
California
If we are running two models on my video feeds, does that mean that each model has half of the resources to run? Does it makes more sense to train a single model with all of the classes than several custom models? If I want to add a fire class to one of your custom ipcam models does that mean it would take several days of compute? (Would I also need to label a thousand images?)

Or what about combining the classes of several ipcam models? I want everything: animals, plates, people, fire, night, day on one model.

Part of the motivation here is that the TPU really only accepts a single model efficiently. Otherwise it would need to load a new model each time. It makes sense to have the TPU do the heavy lifting and the GPU does the more custom burst-y models like faces and plate reading.
 
Last edited:

MikeLud1

IPCT Contributor
Joined
Apr 5, 2017
Messages
2,214
Reaction score
4,253
Location
Brooklyn, NY
MikeLud,

Is the this model we end up training something we can maintain ourselves? Basically is it stored on our PC and we can back it up?
Once the dataset is downloaded you can add additional images and retrain the model. The dataset and model is stored on your PC.
 

MikeLud1

IPCT Contributor
Joined
Apr 5, 2017
Messages
2,214
Reaction score
4,253
Location
Brooklyn, NY
If we are running two models on my video feeds, does that mean that each model has half of the resources to run? Does it makes more sense to train a single model with all of the classes than several custom models? If I want to add a fire class to one of your custom ipcam models does that mean it would take several days of compute? (Would I also need to label a thousand images?)

Or what about combining the classes of several ipcam models? I want everything: animals, plates, people, fire, night, day on one model.

Part of the motivation here is that the TPU really only accepts a single model efficiently. Otherwise it would need to load a new model each time. It makes sense to have the TPU do the heavy lifting and the GPU does the more custom burst-y models like faces and plate reading.
You can have as many classes in one model. The only downside is as you add more classes the accuracy for each class will be reduced by a small amount.
 

MikeLud1

IPCT Contributor
Joined
Apr 5, 2017
Messages
2,214
Reaction score
4,253
Location
Brooklyn, NY
Below are some recommendations for training a custom model
  • Stop using all other CodeProject.AI modules (Training a model needs all the resources it can get)
Last night as I was training the Pets model I ran into an issue where it crashed because I did not follow my first recommendation. I was viewing my cameras using UI3 and it overused my GPU VRAM and caused the training to crash. I will try retraining the model over the weekend and update the thread with more details on training.
 

Nunofya

Getting comfortable
Joined
Nov 8, 2021
Messages
356
Reaction score
274
Location
USA
Last night as I was training the Pets model I ran into an issue where it crashed because I did not follow my first recommendation. I was viewing my cameras using UI3 and it overused my GPU VRAM and caused the training to crash. I will try retraining the model over the weekend and update the thread with more details on training.
Wow, crashed a 4090:oops:
 

prsmith777

Getting comfortable
Joined
Dec 23, 2019
Messages
268
Reaction score
382
Location
Colorado
How would I do this to add a vehicle to your delivery.pt? The Amazon people are always delivering in these white vans with "fluid" logo. I'd like to add those images somehow
 

MikeLud1

IPCT Contributor
Joined
Apr 5, 2017
Messages
2,214
Reaction score
4,253
Location
Brooklyn, NY
How would I do this to add a vehicle to your delivery.pt? The Amazon people are always delivering in these white vans with "fluid" logo. I'd like to add those images somehow
I did not create the delivery.pt model @VideoDad did. You would need the images he used plus your images to retain the model.
 

Dixit

Getting the hang of it
Joined
Dec 14, 2015
Messages
75
Reaction score
36
@MikeLud1
Question on this. On the "Open Images Dataset V7" what portion should we download? This Dataset seems huge and semi confusing to me being totally new at this on what to get, im assuming it has to be the ones that are already annotated.

Is it possible to use the COCO dataset? I only ask because I use the default object detection model and I find that the medium or large seems to be the best for me accuracy wise vs the ipcam-general. I wanted to basically cut down the default mode where instead of that model having 80 classes just have it for say just maybe 3-5 tops like car, truck, person, maybe bicycle. But Im assuming Id have to download that dataset that is also annotated to get this to work right?

Dixit
 

MikeLud1

IPCT Contributor
Joined
Apr 5, 2017
Messages
2,214
Reaction score
4,253
Location
Brooklyn, NY
@MikeLud1
Question on this. On the "Open Images Dataset V7" what portion should we download? This Dataset seems huge and semi confusing to me being totally new at this on what to get, im assuming it has to be the ones that are already annotated.

Is it possible to use the COCO dataset? I only ask because I use the default object detection model and I find that the medium or large seems to be the best for me accuracy wise vs the ipcam-general. I wanted to basically cut down the default mode where instead of that model having 80 classes just have it for say just maybe 3-5 tops like car, truck, person, maybe bicycle. But Im assuming Id have to download that dataset that is also annotated to get this to work right?

Dixit
When I made all my custom models I use FiftyOne to export the images with the object I wanted to use for the models.

 

Mluck0315

n3wb
Joined
Sep 3, 2019
Messages
9
Reaction score
1
Location
Chicago
Just so I’m clear, does the pets custom model allow us to train to identify a specific pet (loosely, facial—err, body—recognition applied to dogs and cats, or just differentiate among species?

@MikeLud1, any POV?
 
Last edited:

gmprpl

n3wb
Joined
Mar 11, 2024
Messages
4
Reaction score
1
Location
Poland
Couple of months ago, I started reading about image classification and object recognition. I was trying to learn how to do transfer learning on pre-trained models. I set up the environment, struggled to configure Tensorflow, CUDA, etc.
I prepared a collection of images (more than 1000) for just one class, I labelled them manually, but when it came to actual training, I got some weird numbers on some parameters, and after a couple of attempts to fix the issue, I abandonem the project.

Is there a way for me to re-use my dataset, collection of labelled images, in the train section in CodeProject AI? (Training for YoloV5 6.2 )
The class I want to add is not on the list from Open Images Dataset, so I can't exactly follow this guide.
If it can't be done through the user interface, I'm ok with tweaking the source files, with some guidance.

Thanks for any advice.
 

MikeLud1

IPCT Contributor
Joined
Apr 5, 2017
Messages
2,214
Reaction score
4,253
Location
Brooklyn, NY
Couple of months ago, I started reading about image classification and object recognition. I was trying to learn how to do transfer learning on pre-trained models. I set up the environment, struggled to configure Tensorflow, CUDA, etc.
I prepared a collection of images (more than 1000) for just one class, I labelled them manually, but when it came to actual training, I got some weird numbers on some parameters, and after a couple of attempts to fix the issue, I abandonem the project.

Is there a way for me to re-use my dataset, collection of labelled images, in the train section in CodeProject AI? (Training for YoloV5 6.2 )
The class I want to add is not on the list from Open Images Dataset, so I can't exactly follow this guide.
If it can't be done through the user interface, I'm ok with tweaking the source files, with some guidance.

Thanks for any advice.
You need to format the dataset as shown in the below link

 

gmprpl

n3wb
Joined
Mar 11, 2024
Messages
4
Reaction score
1
Location
Poland
You need to format the dataset as shown in the below link

Can I then use the web UI to initialize and monitor the training? Will it let me use class names that are not on the list under the "i" tooltip?
 

MikeLud1

IPCT Contributor
Joined
Apr 5, 2017
Messages
2,214
Reaction score
4,253
Location
Brooklyn, NY
Can I then use the web UI to initialize and monitor the training? Will it let me use class names that are not on the list under the "i" tooltip?
You can, to use your dataset all you need to do is put the full path for your dataset in the Dataset box

1710177311788.png
 

Mluck0315

n3wb
Joined
Sep 3, 2019
Messages
9
Reaction score
1
Location
Chicago
Can anybody help answer the above question regarding training YOLO on pets? Can you train it (with sufficient pics) to identify an individual domestic animal (e.g., Spot), or just identify where it is a dog or cat, etc.?
Sorry for the noob question, just getting into training custom models.
 
Top