-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Joint training on images with bounding boxes and labels, and images with only labels (YOLO9000 style) #13312
Comments
👋 Hello @sidharthanup, thank you for your interest in Ultralytics YOLOv8 🚀! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered. 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. Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users. InstallPip install the pip install ultralytics EnvironmentsYOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit. |
Hello! Great question! To train a model on a mixed dataset with both bounding boxes and class labels only (YOLO9000 style), you'll need to modify the training process to handle each type of data appropriately. For YOLOv8, you can implement a custom training loop that:
This approach requires modifying the loss computation part of your model's training script. You might need to dive into the model's codebase to implement these conditional checks and loss adjustments. If you're comfortable editing the model's training code, this could be a feasible approach. Otherwise, consulting with a developer familiar with the YOLO architecture and its implementation might be necessary. Let us know if you need further assistance or specific guidance on the code changes! |
Thank you @glenn-jocher! That makes sense. And yes I'm new to the codebase and I'll really appreciate it if you guys can help me get started on the code and a general sense of where I should be changing stuff. |
Hello! We're glad to hear the information was helpful! 🚀 To get started with modifying the codebase for your needs, I recommend first familiarizing yourself with the structure of the YOLOv8 model, particularly focusing on the files where the loss functions are defined and handled. A good starting point would be to look into the If you encounter any specific issues or have questions as you go through the code, feel free to reach out. We're here to help! Happy coding! |
Thank you! Can you help me with pointing out where the loss calculations (dfs, vfs etc) are? I see backward being called in the trainer code : https://github.com/ultralytics/ultralytics/blob/main/ultralytics/engine/trainer.py . Is that where I should be focusing on? |
@sidharthanup hello! Absolutely, I'd be happy to help you navigate the codebase! 😊 You're on the right track by looking into the Here are the key areas to focus on:
Here's a general outline of what you might need to do:
Here's a small snippet to give you an idea: # In loss.py
def compute_loss(predictions, targets, has_bboxes):
if has_bboxes:
# Compute full loss (classification + localization)
loss = full_loss(predictions, targets)
else:
# Compute classification loss and scaled IoU loss
loss = classification_loss(predictions, targets) + 0.3 * iou_loss(predictions, targets)
return loss
# In trainer.py
for batch in dataloader:
images, targets, has_bboxes = batch
predictions = model(images)
loss = compute_loss(predictions, targets, has_bboxes)
loss.backward()
optimizer.step() This is a simplified example, but it should give you a starting point. Make sure to test thoroughly to ensure the new logic integrates well with the existing training process. If you encounter any specific issues or need further guidance, feel free to ask. We're here to help! 🚀 Happy coding! |
Thank you so much! I'll let you know how it goes! |
@sidharthanup you're very welcome! 😊 We're excited to see how your implementation progresses. Before you dive in, here are a couple of quick checks to ensure everything runs smoothly:
If you need further assistance or run into any issues, don't hesitate to reach out. We're here to help! Happy coding, and best of luck with your project! 🚀 |
Search before asking
Question
Hello!
Assuming I have a dataset with images that have bounding boxes (+ superclass labels) and images with only class labels, I needed some help with how I can train this in a YOLO9000 manner. For YOLO9000, When the training
Can I adapt something similar to allow for joint training of detection and classification images and if so how do I proceed?
Awaiting your response. Thanks in advance!
Additional
No response
The text was updated successfully, but these errors were encountered: