ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.48k stars 16.29k forks source link

Model modification #11383

Closed Batman-97 closed 1 year ago

Batman-97 commented 1 year ago

Search before asking

Question

Hello Yolo community!,

I have question about modifying yolov5 or v8 head architecture to predict custom prediction and classification, conventional yolo, class_prob, x, y, h, w I want to change it to, class_prob, x, y, h, w, p (where p is another regression annotation for particular bounding box)

can I do that? if yes, could you please guide me through this.

thank you in advance.

Additional

No response

github-actions[bot] commented 1 year ago

👋 Hello @Batman-97, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

Introducing YOLOv8 🚀

We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀!

Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.

Check out our YOLOv8 Docs for details and get started with:

pip install ultralytics
glenn-jocher commented 1 year ago

Hello @Batman-97, sure you can modify YOLOv5's head architecture to predict custom outputs. You can make changes in the models/yolo.py file, specifically in the Detect's forward or Forward methods. Please note that you will also need to update the config files located in the yaml folder to reflect the changes in the number and names of the outputs, and make changes in functions that accept or use predictions.

Also, we would recommend you study the PyTorch library and previous versions of YOLO object detector architecture before making any changes. Good luck!

Batman-97 commented 1 year ago

Thank you @glenn-jocher for replying.

thank you once again @glenn-jocher

glenn-jocher commented 1 year ago

You're welcome, @Batman-97. Yes, you can modify the YOLOv8 head architecture in a similar way to YOLOv5 as they share similar architectures. However, YOLOv8 uses Scaled-YOLOv4 as the base architecture, whose structure and components are different from previous YOLO versions. So, you may need to familiarize yourself with Scaled-YOLOv4 and PyTorch library before making any modifications.

Regarding adding an extra regression output alongside the bounding box, you will need to modify the loss function to include this additional output, especially if you're using supervised learning. This will require you to update the loss calculation to include the new output, similarly to how the current loss calculation updates the class, objectness, and regression losses.

I hope this helps! Let me know if you have any more questions.

Batman-97 commented 1 year ago

thank you so much @glenn-jocher that was so helpful. If I have any questions I will write again in this thread!

glenn-jocher commented 1 year ago

You're welcome, @Batman-97! I'm glad I could help. Feel free to ask any questions you may have, and I'll be happy to assist you. Good luck with your modifications to YOLOv5 or YOLOv8!

github-actions[bot] commented 1 year ago

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