-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
is there a way to make masks not to overlap? #12732
Comments
Hello, Thank you for reaching out! To prevent instance masks from overlapping in YOLOv8, you can set the yolo predict model=path/to/your_model.pt source=path/to/your_image.jpg overlap_mask=False This will ensure that each mask is exclusive to its respective detected object. Let us know if you need further assistance! |
@glenn-jocher
as well as during prediction:
but it still shows me overlapping masks. |
@polinamalova0 hello, Thanks for the detailed information! It seems like the If updating doesn't resolve the issue, it could be helpful to check if there's any custom modification in your model or data processing pipeline that might be influencing the mask behavior. Please let us know if the problem persists after checking these points! |
Unfortunately, i updated the libraries as well as re-checked all my annotations to make sure that none overlap, and the newly trained model still gives off overlapped masks as a result... is there another way that can help me with the problem? |
Hello @polinamalova0, Thank you for the update and for checking those aspects. It's puzzling that the issue persists despite these efforts. Here are a couple more steps we can try:
We're here to help you through this, so keep us posted on your progress! 🚀 |
@glenn-jocher thank you for the answer. if i got right what you meant by "output logs", this is what i got before training info:
as you might understand, the problem with overlap is persistent. I am using a small dataset, and i checked myself the annotation, there's also no overlap in the annotated images. I don't know where it might come from. |
Hello @polinamalova0, Thank you for providing the detailed logs and for your efforts in troubleshooting this issue. It's clear you've taken the necessary steps to ensure your setup and data are correctly configured. Given that the problem persists despite these measures, there might be an underlying issue with how the At this point, I recommend the following steps:
We appreciate your patience and are here to assist you further as needed. Your detailed feedback is invaluable in improving YOLOv8 and helping us identify areas that may require attention. |
@glenn-jocher i am not sure it is a source code issue, since my code for training and predicting is like that:
|
Hello @polinamalova0, Thank you for sharing your code snippet and providing detailed context. Let's work together to resolve this issue. First, let's ensure that the bug occurs with the most recent versions of pip install -U torch ultralytics If the issue persists after updating, we need to verify that the problem can be reproduced. Could you provide a minimum reproducible example? This will help us investigate the issue more effectively. You can find guidelines on creating a minimum reproducible example here. Here's a simplified version of your code to ensure we are on the same page: from ultralytics import YOLO
import torch
device = 'cuda' if torch.cuda.is_available() else 'cpu'
print(f'Using device: {device}')
model = YOLO('yolov8s-seg.pt').to(device)
# Training
results = model.train(data='path/to/dataset.yaml', epochs=100, imgsz=428, device=device, overlap_mask=False, verbose=True, workers=1)
# Prediction
path = 'path/to/last.pt'
img = 'path/to/img.png'
model = YOLO(path)
prediction = model(img, save=True, overlap_mask=False, verbose=True) If you have already ensured that your annotations are correct and there are no overlaps, and the issue still persists, it might be helpful to check if there are any specific conditions or edge cases in your dataset that could be causing this behavior. Additionally, you can try visualizing the masks during training to see if the overlap issue starts there or only appears during prediction. This might give us more clues about where the problem lies. If you continue to face issues, please consider raising an issue on our GitHub repository with the minimum reproducible example. This will allow the development team to investigate further and provide a solution. Thank you for your patience and cooperation. We're here to help you get this resolved! 😊 |
Search before asking
Question
Dear Ultralytics team,
After training my instance segmentation model, i tried to predict the objects and obtained the masks. However, the cases where they overlay one on another are very common. Therefore my question is: is there a way to set the prediction so that the masks are not overlapping (exclusive for each object)?
Additional
No response
The text was updated successfully, but these errors were encountered: