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

Retina mask is shifted #11908

Closed
1 of 2 tasks
stephencheung16 opened this issue Jul 26, 2023 · 9 comments
Closed
1 of 2 tasks

Retina mask is shifted #11908

stephencheung16 opened this issue Jul 26, 2023 · 9 comments
Labels
bug Something isn't working Stale

Comments

@stephencheung16
Copy link

stephencheung16 commented Jul 26, 2023

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

No response

Bug

Install Yolov5 & Roboflow. Download weight of pre-trained Yolov5x segmentation model.
p1

Run prediction on skis with --retina-masks option. Retina mask is shifted to bottom-right.
p2

Run prediction on skis without --retina-masks option. The mask is not shifted.
p3

Would you please help?

Environment

  • Kaggle notebook

Minimal Reproducible Example

Install Yolov5

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

import torch
import utils
display = utils.notebook_init() # checks

Test if retina mask is shifted on skis

image_path = '/kaggle/input/test-images/skis_600x396.jpg'
!python segment/predict.py --img 320 --weights yolov5x-seg.pt --source {image_path}
--save-txt --save-conf --device cpu
--retina-masks

display.Image(filename=f'runs/predict-seg/exp/skis_600x396.jpg', width=600)

Test if mask is shifted if --retina-mask option is deleted

image_path = '/kaggle/input/test-images/skis_600x396.jpg'
!python segment/predict.py --img 320 --weights yolov5x-seg.pt --source {image_path}
--save-txt --save-conf --device cpu

display.Image(filename=f'runs/predict-seg/exp2/skis_600x396.jpg', width=600)

The test image

skis_600x396

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@stephencheung16 stephencheung16 added the bug Something isn't working label Jul 26, 2023
@github-actions
Copy link
Contributor

👋 Hello @stephencheung16, 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
Copy link
Member

@stephencheung16 hi there! Thank you for bringing this issue to our attention. I understand that the retina mask is shifted when using the --retina-masks option in YOLOv5 segmentation prediction.

To better assist you, could you please confirm if you have followed the steps in the YOLOv5 tutorial correctly, specifically the instructions for setting up the environment and installing the requirements?

Additionally, it would be helpful if you could provide the following information:

  • Versions of Python, PyTorch, and the YOLOv5 codebase you are using.
  • Any modifications made to the YOLOv5 codebase or custom configurations.

Please ensure that you are using the latest version of YOLOv5 and its dependencies. If the issue persists, please provide a minimum reproducible example that we can use to debug the problem.

Thank you for your collaboration, and we look forward to resolving this issue with you.

@stephencheung16
Copy link
Author

@glenn-jocher

Hi Glenn,

I follow the steps in the Roboflow tutorial 'How to Train YOLOv5 Instance Segmentation on a Custom Dataset' for setting up the environment and installing the requirements

In Kaggle, the Python version is 3.10.12. Pytorch version is 2.0.0. YOLOv5 is v7.0-196-gacdf73b.

I did not modify any of the YOLOv5 codebase or custom configurations.

The 'minimum reproducible example' is attached above, in my first message. Both code and test image are attached.

Just modify the path to the test image. The code can be run. There are only 12 lines.

Please try the 'minimum reproducible example'. Thanks.

@glenn-jocher
Copy link
Member

Hi @stephencheung16!

Thank you for providing the details and the minimum reproducible example. I apologize for any confusion caused.

I understand that you followed the steps in the Roboflow tutorial for setting up the environment and installing the requirements. I also see that you are using Python version 3.10.12, PyTorch version 2.0.0, and YOLOv5 version v7.0-196-gacdf73b.

I will try the minimum reproducible example you provided with the test image you attached. I will investigate the issue and get back to you with a solution or further information as soon as possible.

Thank you for your patience, and I appreciate your cooperation in resolving this issue.

Best regards,
Glenn

@stephencheung16
Copy link
Author

stephencheung16 commented Jul 28, 2023

Hi @glenn-jocher,

By making the skis thinner, the shift is more obvious.

With --retina-masks,
skis_600x396_further_narrowed

Without --retina-masks,
skis_600x396_further_narrowed

Attached is the test image,
skis_600x396_further_narrowed

Would you please help? Thanks.

@glenn-jocher
Copy link
Member

Hi @stephencheung16,

Thank you for providing the details and additional images.

I understand that when using the --retina-masks option in YOLOv5 for segmentation predictions, the shift becomes more obvious, particularly when the skis are thinner. In comparison, without the --retina-masks option, the shift is less apparent.

To investigate and address this issue, I will analyze the provided test image and run additional tests with the --retina-masks option enabled.

I appreciate your patience, and I will get back to you with further information or a solution as soon as possible.

Thank you for your understanding.

Best regards,
Glenn

@github-actions
Copy link
Contributor

👋 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 Aug 28, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 8, 2023
@Boatsure
Copy link

Boatsure commented May 8, 2024

Interesting, now is 2024 and I use yolov8.1-seg to do instance segmentation inference, the visualization masks will be shifted to bottom-right with retina_masks True and imgsz not 640. I mean the masks won't be shifted when imgsz=640, with retina_masks on or not.

@glenn-jocher
Copy link
Member

Hi there!

Thank you for sharing your findings with YOLOv8.1-seg regarding the mask shifting issue related to the imgsz parameter and retina_masks option. It seems like resizing the images to sizes other than 640 pixels might be affecting the alignment of the masks.

A potential workaround could be to ensure all image inputs are resized to 640 pixels before running segmentation, as this size seems to prevent the shifting issue. You might also check for any discrepancies in the resizing or coordinate transformation logic in the code if adjusting imgsz is not feasible for your application.

Your input is valuable, and we'll look into this for potential improvements in future updates! 🌟

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

3 participants