-
-
Notifications
You must be signed in to change notification settings - Fork 16.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
Change images produced by segment/predict.py #12908
Comments
@osamamer hello! 👋 It sounds like you're working on a custom output for your segmentation tasks using YOLOv5. To achieve a black-and-white image where detections are white and the rest is black, you indeed need to modify how the mask is applied and how the final image is constructed. Here's a simplified approach:
Here is a conceptual snippet: import numpy as np
# Assuming 'results' is your detection output from model
img_bw = np.zeros((results.imgs[0].shape[0], results.imgs[0].shape[1]), dtype=np.uint8) # Creating BW base
for det in results.xyxy[0]: # Loop through detections
bbox = [int(x) for x in det[:4]] # Convert to int
img_bw[bbox[1]:bbox[3], bbox[0]:bbox[2]] = 255 # Fill detected areas with white
# 'img_bw' now is your black-white image as desired This code snippet assumes that your model's detections are stored in Feel free to tweak this further based on your project's specific requirements. Happy coding! 🚀 |
👋 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 ⭐ |
Search before asking
Question
Hello,
I'm trying to change the segment/predict,py file in order to make it produce a black-and-white image, the white portion of which is the detections, and everything else is black. This requires me to change the opacity of the image to be fully opaque, which I'm having trouble figuring out. I tried changing the alpha parameter in the Annotator's masks function, but that raises a tensor dimension mismatch error. What changes do I need to make to the predict file to get the required output?
Additional
No response
The text was updated successfully, but these errors were encountered: