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

If you had thousands of pictures of Spot, you could definitely train a model on those pictures and it would be able to find Spot in other pictures you gave it.

But the big problem is it may not necessarily know enough to distinguish Spot from a similarly shaped animal. If you want to get a model that can definitely recognize only Spot, you'll need lots of images that are not Spot, so it can learn the difference.
 
If you had thousands of pictures of Spot, you could definitely train a model on those pictures and it would be able to find Spot in other pictures you gave it.

But the big problem is it may not necessarily know enough to distinguish Spot from a similarly shaped animal. If you want to get a model that can definitely recognize only Spot, you'll need lots of images that are not Spot, so it can learn the difference.

So how important is it to include negative examples?
Creating a dataset from Open Images V7 will not have any, right?
If I have my collection of images for just a single class, do I need to throw in random images without any labels?
 
So how important is it to include negative examples?
Creating a dataset from Open Images V7 will not have any, right?
If I have my collection of images for just a single class, do I need to throw in random images without any labels?
If your chosen object looks similar to another, then consider including images that could generate false positives. For example, if you are training a model to recognize horses, you might want include pictures of zebras without labels.

That's probably not the best example, but you get the idea. They should be images chosen for their potential to be false positives, not just random images.
 
If your chosen object looks similar to another, then consider including images that could generate false positives. For example, if you are training a model to recognize horses, you might want include pictures of zebras without labels.

That's probably not the best example, but you get the idea. They should be images chosen for their potential to be false positives, not just random images.
Thanks a lot for your help so far! I was able to initialize my first training.

I've got a few other questions now.
Should I expect a significant difference in perfromance between a model with 2000 images of just one class vs the same set of images with 5 different classes (additional objects, more bounding boxes)?
Are there any easy to follow guidelines regarding training parameters - number of epochs, number of workers, tuning, model size? Or.. should I treat settings from your example as the best default settings for most applications?
 
Last edited:
  • Like
Reactions: Pentagano
2 questions:

1. What are the minimum hardware requirements for training custom models?

I know that's a loaded question but to elaborate, I have no need for a GPU (e.g. gaming, video editing, etc.) so all my computers are using integrated graphics. If I needed to get a graphics card for the sole purpose of creating a model or two what could I get by with? Is it possible to get something for $100 ($200-250 max) without the the training running almost an entire month or even an entire week?

Can a high end CPU work just as well? If so, would it need a lot of memory as well or would 16 or 32 GB be enough? At least with the CPU I can repurpose it (e.g.: new Proxmox server).

2. What is the difference between training a model for a GPU versus training the model for a Coral TPU? Or is there a difference?

I'm still learning about Models and YOLO. I thought I had it but with the new versions of everything I don't think I was right, or maybe I was partially correct. I thought YOLO was the algorithm (engine) and Models were what the algorithm used for processing. I guess where I am confused is in the Install Modules list there are many options for ObjectDetection with different YOLO versions. But then when I look in the model options (for Object Detection Coral) I see YOLOv5, YOLOv8, MobileNet SSD, etc. Sorry for my lack of knowledge.
 
Most models can be used on a Coral TPU but require some extra steps to get them exported as the appropriate .tflite file and then more steps to get them segmented across multiple TPUs. YOLOv8 is relatively easy to export since they have the settings built into their export feature, but it’s not a simple model and is not completely compatible with the TPU.
 
Most models can be used on a Coral TPU but require some extra steps to get them exported as the appropriate .tflite file and then more steps to get them segmented across multiple TPUs. YOLOv8 is relatively easy to export since they have the settings built into their export feature, but it’s not a simple model and is not completely compatible with the TPU.
If I find another model .tflite file on git how do I program cpai to use that specific custom model? I'm at the bottom of the learning curve..
 
If you’re starting from ‘scratch’ with an existing .tflite file, the first step would be to instal the TPU compiler and converting to that format:

I think the YOLOv8 export takes care of that for you, but it may still be needed if you find your own .tflite file. Segmenting so it runs well across more than one TPU would require installing the profiling compiler, which requires Ubuntu 20.04 and a particular package installed with Bezel. I don’t know if how to get it installed in CPAI, but I’m sure it can be supported if someone wants the functionality.
 
  • Like
Reactions: Pentagano
So the models that come with CPAI (e.g.: "EfficientDet-Lite" and "MobileNet SSD") are there multiple "versions"? One for a single TPU versus one for Dual TPU?

I'm a complete newb as well and was reading the Coral documentation but that is obviously different than using the module that comes with CPAI. The module that comes with CPAI seems WAY easier but wasn't sure if we can use it directly with a TPU. Sounds like it needs extra steps?
 
For the original models:

There are really two models (MobileNet & EfficentDet) in your comment in different sizes and variations. Mainly think of the different sizes. Then, for models that don't fit well on one TPU, I've been playing with segmenting them with different strategies. For example, see my file here here:

Different layers of the model run on different TPUs and some layers run on the CPU. So different files for each model / size / TPU count combination. This isn't really something to worry about when building the model, however. It seems to be pretty random exactly what the best strategy is and when the YOLO models work well on a single TPU and when they don't. Smaller models and smaller tensor sizes tend to work better, but it's not always very predictable.

For training I'd personally just use the CLI here:

But I’ve never trained a deep learning model myself, and would trust Mike to know better than I. And I know that it exports models to a single TPU (generally) well and easily with a single command. Getting them to run on multiple TPUs is more tricky to do well, but if there's interest I can discuss my learnings.
 
Last edited:
Hello friends, I am trying to train codeProject.Ai with the indications that they are giving me in some tutorial that I have seen but I understand that one of the options that indicates that we can download from Open images V7 which is quite confusing but if I want to train my own model there will be some option to do so, example I would like to see the possibility of training it for the stop of weapons or for any specific thing. Is there a way to do it manually in CodeProject.AI? Note: I don't know much about programming or not in this language, so if there is any intuitive instruction that can direct me to be able to train Yolo5.6 in CodeProject.AI.
 
This is very confusing at some point I assumed that just uploading a tagged image to the CodeProject.AI server was enough to train it but now I see that all this training is very confusing. Now, is there anything that I can do easily maybe manually from codeProyect.AI? No Python domain. on Windows maybe.
 
Hello all, been having issues with trying to get training for yolov5 6.2 to train model, i can create the dataset just fine, but when i go to train it, it comes back with Model Path: not yet completed
 
Hello!
This is my first time solving the problem of detecting vehicle registration plates in "CodeProject.AI". I am a beginner.
I installed the modules "Object Detection (YOLOv5 .NET)", "Object Detection (YOLOv5 6.2)", "License Plate Reader" and "Training for YoloV5 6.2".
In my case, vehicle registration plates are not detected in a 3840x2160 photo.
cam18_00_20250320125602.jpg
But if I select a fragment with a vehicle in such a photo and place it in a separate file without changing the fragment size

Безымянный5.png
, then the vehicle registration plates are detected correctly.

I assumed that I needed to enable Model Size Tiny or Large in "Object Detection (YOLOv5 .NET)". Switching modes did not help.
Then I looked at examples in "Open Images Dataset V7". There are large photos there where the vehicle registration plates are detected correctly. Example:

Is it possible to somehow change the module settings so that they would detect numbers on a 3840 x 2160 photo?
If not, what do I need to download from "Open Images Dataset V7" to train "Object Detection (YOLOv5 .NET)"? I don't yet understand what needs to be written in the "Dataset" field.

Thanks in advance for your help!
 
Are you trying to train your own model? Or just use the existing ALPR model? And are you trying to detect the presence of a license plate in the frame, or actually read the letters/numbers on the plate?

The YOLO models generally work by turning the input image into a 640 × 640 square then looking for patterns that match the desired object(s). In the case of a license plate, that's expected to be an rectangular area of high contrast.

The first image is way too big for a plate to be detected unless cropped as shown.

If a plate is detected, then those pixels in the rectangle are sent to the OCR module for assigning what it detects as the most likely set of letters and numbers.

In practical terms, you need to get a camera that can get a tighter, optically zoomed-in view of the vehicle with a plate.
 
I am currently using the existing ALPR model. I do not have another camera, I cannot reconfigure the camera. I have thousands of photos from one camera. I'm trying to identify the license plates in these photos.
 
I am currently using the existing ALPR model. I do not have another camera, I cannot reconfigure the camera. I have thousands of photos from one camera. I'm trying to identify the license plates in these photos.
Then the best I can suggest is to crop the larger images down to just the car.
 
Is the vehicle always in a certain region of the picture? If so there are programs that will do a batch crop to a predefined rectangle.

Alternatively, if you are handy with programming, you could have each photo run through AI detection for a vehicle, that returns a rectangle for the vehicle, then do your own crop to that specific rectangle.