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

Error in utils/segment/general masks2segments() #9724

Merged
merged 1 commit into from
Oct 6, 2022

Conversation

paulguerrie
Copy link
Contributor

@paulguerrie paulguerrie commented Oct 6, 2022

When running segmentation predict on gpu, the conversion from tensor to numpy fails. Calling .cpu() before calling .numpy() solves this problem.

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Enhanced compatibility for YOLOv5 segmentation mask processing.

πŸ“Š Key Changes

  • Modified the data handling in segment conversion to ensure tensor operations are CPU compatible.

🎯 Purpose & Impact

  • Purpose: The change ensures that the segmentation mask conversion process can be executed on systems without GPU support by explicitly moving the mask tensor to the CPU.
  • Impact: This improves the flexibility of the code, allowing it to run on a wider range of hardware, particularly benefiting users who may be working with CPU-only environments. It could potentially increase the accessibility of YOLOv5 for users with less powerful machines. πŸ–₯οΈπŸš€

When running segmentation predict on gpu, the conversion from tensor to numpy fails. Calling `.cpu()` solves this problem. 

Signed-off-by: Paul Guerrie <97041392+paulguerrie@users.noreply.github.com>
@glenn-jocher
Copy link
Member

@paulguerrie thanks for the PR! I'm not able to reproduce any issues with GPU segmentation inference. Can you help us by providing the commands you are using that produce the error for you? Thanks!

Screenshot 2022-10-06 at 22 34 13

@paulguerrie
Copy link
Contributor Author

Of course! Sorry, should have included steps to reproduce in the PR. Here's what I ran in a google colab and the resulting error:

Screen Shot 2022-10-06 at 2 40 08 PM

Also, noticing that other runs of segment/predict.py do not fail in the same colab. (Using the Roboflow tutorial colab: https://colab.research.google.com/drive/1JTz7kpmHsg-5qwVz2d2IH3AaenI1tv0N?usp=sharing)

@glenn-jocher glenn-jocher merged commit 5ef69ef into ultralytics:master Oct 6, 2022
@glenn-jocher
Copy link
Member

@paulguerrie ah yes, I'm able to reproduce now!

PR is merged. Thank you for your contributions to YOLOv5 πŸš€ and Vision AI ⭐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants