Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensembling of yolov5 and yolov8 #12732

Closed
1 task done
humairaneha opened this issue Feb 14, 2024 · 6 comments
Closed
1 task done

Ensembling of yolov5 and yolov8 #12732

humairaneha opened this issue Feb 14, 2024 · 6 comments
Labels
question Further information is requested Stale

Comments

@humairaneha
Copy link

Search before asking

Question

Can i ensemble yolov5 model with a yolov8 model. both are trained on custom dataset?

Additional

No response

@humairaneha humairaneha added the question Further information is requested label Feb 14, 2024
@glenn-jocher
Copy link
Member

@humairaneha hi there! 👋

Yes, you can ensemble YOLOv5 with YOLOv8 models. Ensembling different models involves running each model separately on the same input and then combining their predictions. The combination can be done by averaging the bounding box coordinates and confidence scores or by using more sophisticated methods like Non-Maximum Suppression (NMS).

For the best results, ensure that both models are well-calibrated and that their confidence scores are comparable. You might need to experiment with different ensembling techniques to find what works best for your specific use case.

For more details on how to implement this, you can refer to our documentation on custom inference scripts and post-processing steps. Good luck with your ensembling! 😊

@humairaneha
Copy link
Author

humairaneha commented Feb 14, 2024

Thank you so much. One thing I am confused about. Can I use the custom yolov8.pt the same way I used custom yolov5.pt in your ultralytics yolov5 repo?

Load YOLOv8 model

yolov8_weights = "path_to_yolov8_weights.pt"
yolov8_model = DetectMultiBackend(yolov8_weights, device=device, dnn=dnn, data=data, fp16=half)

Run inference with both models

pred_yolov5 = model(im, augment=augment, visualize=visualize)
pred_yolov8 = yolov8_model(im, augment=augment, visualize=visualize)

Combine predictions

pred_combined = combine_predictions(pred_yolov5, pred_yolov8)

Perform non-maximum suppression on combined predictions

pred_combined = non_max_suppression(pred_combined, conf_thres, iou_thres, classes, agnostic_nms, max_det=max_det) like this?

@glenn-jocher
Copy link
Member

@humairaneha, the code snippet you've provided is conceptually correct for ensembling models. However, YOLOv8 is not part of the Ultralytics YOLOv5 repository, and the YOLOv5 codebase is specifically tailored for YOLOv5 models. If YOLOv8 has a different architecture or requires different preprocessing, the code may not be directly compatible.

You would need to ensure that the YOLOv8 model can be loaded and used in a similar manner to YOLOv5, which may require adjustments to the code or the use of a separate inference script that is compatible with YOLOv8. Additionally, you would need to handle the outputs of both models in a way that they can be combined effectively, considering any differences in output format.

If YOLOv8 follows a similar implementation and output format as YOLOv5, you might be able to use the same functions with minor modifications. Otherwise, you'll need to adapt the code to accommodate the differences between the two models.

Remember to test the combined inference thoroughly to ensure that the models are correctly ensembled and the predictions are as expected. Good luck with your implementation! 😄

@KAKAROT12419
Copy link

@humairaneha have you got success with implementation of ensemble of yolov5 and yolov8?

Copy link
Contributor

github-actions bot commented Apr 6, 2024

👋 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 ⭐

@github-actions github-actions bot added the Stale label Apr 6, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 16, 2024
@glenn-jocher
Copy link
Member

Hi @KAKAROT12419! 😊

If you've successfully implemented the ensemble of YOLOv5 and YOLOv8, that's great! If you're encountering any issues or have specific questions about the process, feel free to share them here. We're here to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

3 participants