I have trained a model based on YOLOv5 on a custom dataset which has two classes (for example human and car)
I am using detect.py
with the following command:
> python detect.py --weights best.pt --source video.mp4
I want only car class to be detected without detecting humans, how it could be done?
CodePudding user response:
I think you can use the argument --classes of detect.py. Just use the index of the classes.
CodePudding user response:
You can specify classes, which you want to detect [--classes] arguments will be used.
Example
python detect.py --weights "your weights.pt" --source "video/image/stream" --classes 0,1,2
In above command, 0,1,2 are classId, so when you will run it, only mentioned classes will be detect.