Skip to content

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

Merged
glenn-jocher merged 1 commit intoultralytics:masterfrom
paulguerrie:patch-2
Oct 6, 2022
Merged

Error in utils/segment/general masks2segments()#9724
glenn-jocher merged 1 commit intoultralytics:masterfrom
paulguerrie:patch-2

Conversation

@paulguerrie
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants