ultralytics/yolov5

About detect.py

Closed this issue · 10 comments

Search before asking

Question

When I run detect.py ,how can I get this result?This result have bus and truck.

Additional

No response

![Uploading }A]IOII5U4MSO`0Z8~7MK.png…]()

}A IOII5U4MSO`0Z8~7MK

@Bonjourzwh hey there! It looks like there was an issue with uploading your image. Could you please try re-uploading it, or describe in detail what result you're expecting with detect.py? Looking forward to assisting you further! 😊

@Bonjourzwh嘿!上传您的图片时似乎出现了问题。您能否尝试重新上传它,或者详细描述您期望的结果detect.py?期待为您提供进一步帮助! 😊

Uploading Screenshot_2024-04-24-00-33-02-647_com.miui.gallery-edit.jpg…

}一个IOII5U4MSO`0Z8~7MK

}一个IOII5U4MSO`0Z8~7MK

justlike this

It appears there's an interest in understanding how to achieve specific detection results with YOLOv5 using detect.py. If you're aiming to detect specific classes such as buses and trucks, ensure your YOLOv5 model is trained on a dataset that includes these classes.

For a straightforward detection command, use:

python detect.py --source your_image_or_video_path --weights your_trained_weights_path --conf 0.25 --classes 5 7

Here, --classes 5 7 specifies class IDs for buses and trucks, assuming these are the correct class IDs in your model's dataset. The --conf option sets the confidence threshold.

Please, adjust the paths and class IDs according to your specific setup and dataset. If these aren't the results you're looking for, could you provide more details about your expected outcome? Happy to help further! 😊

}A IOII5U4MSO'0Z8~7MK

this result have two classes,how can i get the result like this?

Hey there! To achieve detection focusing on specific classes, such as the two classes shown in your example, you would use the --classes flag with detect.py. This flag allows you to specify which class IDs you're interested in. You'll need to know the class IDs for the objects you're detecting (e.g., if 0 and 2 are your class IDs for the desired objects):

python detect.py --source your_image_or_video_path --weights your_trained_weights_path --classes 0 2

Just replace your_image_or_video_path with the path to your image or video, and your_trained_weights_path with the path to your model weights. This command filters the detection output to only include your specified classes. 😊

Make sure to adjust the class IDs (0 2 in this example) according to your model's trained classes!

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐