Replies: 1 comment 2 replies
-
Hi Tim 👋, Great to hear you're using YOLOv8 for segmentation! To get a black and white mask for your segmented items, you'll primarily work with the Here's a quick way to generate a black and white mask from your predictions and save it as an image, which you can then load into MATLAB: from ultralytics import YOLO
import numpy as np
import cv2
# Load your trained model
model = YOLO('path/to/your/model.pt')
# Run prediction
results = model('path/to/your/image.jpg')
# Assuming you have at least one mask, generate a black and white mask
# Note: Adjust the index [0] if you're interested in masks for other detected objects
mask = results.masks[0].numpy() * 255 # Convert boolean mask to uint8
# Save the mask as an image
cv2.imwrite('mask.jpg', mask) You can then easily load Hope this helps! Let us know if you have any more questions. |
Beta Was this translation helpful? Give feedback.
-
Hi I’ve trained yolov8 on some new items I’m looking to get the segmented masks into matlab so I can compare with some other data I’m working with. I can’t seam to find in the documentation the properties of the .txt file that is created when I predict an image I’m only really after a black and white mask.
thanks
Tim
Beta Was this translation helpful? Give feedback.
All reactions