Open Ahelsamahy opened 1 month ago
Removing classes hardly speeds up the model and usually makes the accuracy worse.
@Y-T-G how does not detecting other classes makes the detected classes worse?
@Ahelsamahy Because the models learn better when you force them to distinguish between classes which is the case when you have more classes.
@Y-T-G and this cannot be solved when you train the model with a larger database and apply different augmentation parameters to the training process?
@Ahelsamahy You won't beat the original score. Training a hunan detection model is harder than it looks. Not excluding any classes also means the model gets to learn what are NOT humans from that extra data which reduces false positives.
You also some augmentations that shouldn't be used here like flipud
and probably even degrees
.
@Y-T-G so you are saying that if I added more classes to my model, it should be able to detect humans better? I don't think this is how it works. Have you tested it before?
You won't beat the original score
If the original model is trained on COCO
and I test it with another dataset, that my custom model is trained on, then my model will outperform the original model. It is just a matter of what the model is trained on and the test split that is used later.
I don't think this is how it works. Have you tested it before?
Yeah, I have tested training a model for person detection without any other classes before, and it was always worse than pretrained model. It makes sense to me. Model's have been shown to perform better when they are trained to perform more tasks because the extra tasks introduce regularization that prevents overfitting. It's the premise behind multi-task learning https://en.m.wikipedia.org/wiki/Multi-task_learning
And what's your goal anyway? Because none of this will increase your model's speed noticeably.
If you want to test the performance, you should try running it on a video and compare them.
I'm trying to acheive a speed of 25fps on Jetson nano. I made a discussion about it before and managed to get to a _blank
model but I had to train it myself from the beginning. Glenn said it would which can streamline the computation
and reduce the inference time.
I have tried other options, like setting the imgsz
parameter and floating precision, which did help in the speed.
Can you explain more on the results you got from your training sessions?
I had a use case where I had to improve the person detection on CCTV views, which are different from images in COCO dataset. I tried retraining the model on COCO images and the added images but the results were always worse. In the end, I just used two models, the pretrained and custom trained model.
If I were given that task now, I would use this to add an extra head for the new images: https://y-t-g.github.io/tutorials/yolov8n-add-classes/
Have you tried converting to TensorRT with int8 quantization?
Thanks for sharing the resources. I actually came across your blog when i was preparing for the project before. I think my use case is different from yours. I'm only trying to detect humans with high precision, and you were trying to add more classes?
I think it comes back to your idea Model's have been shown to perform better when they are trained to perform more tasks
but I don't want to end with a 50mb .pt
model if it will reduce the speed of the model while increasing the detection for a little (correct me if i'm wrong)
I have indeed exported my model to a .engine
but couldn't make it to int8=True
due do limitation on the hardware of Nano
self.pt_model = YOLO("yolov8n.pt")
# Export the model to TensorRT format with FB16 quantization and (640,480) resolution
self.pt_model.export(format="engine", device="cuda", imgsz=(self.img_size[1], self.img_size[0]), half=True)
Is this the old Nano or Orin Nano? Can you upgrade JetPack?
What's the FLOPs of your one class model vs. the FLOPs of the original YOLOv8n (model.info()
? The reduction will be really insignificant in terms of speed.
To put it into perspective, you're only changing the size of the last few layers by reducing the nc.
Search before asking
Question
Hi, I'm trying to create a stipped-down yolov8n model that would only detect humans and run it on Jetson Nano. It will be used to keep track of a human in front of a small vehicle. I managed to create the model with detection for one class only using the provided
.yaml
file.I want to train the model to have good detection as much as the default
yolov8n
model (or even better on different weather conditions). On a previous answer it was mentioned what parameters it was trained on.I trained my
.yaml
with them and got different score than the one from yolov8n.ptHere is the test result between my model,
yolov8n
andyolov10n
from runningmodel.val(data="coco.yaml")
. The test is done on RTX3090Additional
I trained my model initially for 500 epochs on COCO dataset with lots of augmentation parameters as here