roboflow-python icon indicating copy to clipboard operation
roboflow-python copied to clipboard

`model.predict` fails when running segmentation model on numpy images

Open LinasKo opened this issue 1 year ago • 2 comments

import cv2

version = rf.workspace("model-examples").project("car-parts-instance-segmentation").version(3)
dataset = version.download("yolov8")
seg_model = version.model

first_image_path = os.listdir(f"{dataset.location}/train/images")[0]
first_image_path = f"{dataset.location}/train/images/{first_image_path}"
seg_image = cv2.imread(first_image_path)
assert seg_image is not None
# Path
result = seg_model.predict(first_image_path).json()
detections = sv.Detections.from_inference(result)
assert len(detections) > 0
# Succeeds

# Np img
result = seg_model.predict(seg_image).json()
detections = sv.Detections.from_inference(result)
assert len(detections) > 0
# Fails!

# Empty np img
result = seg_model.predict(black_image).json()
detections = sv.Detections.from_inference(result)
assert len(detections) == 0
# Fails!

LinasKo avatar Dec 02 '24 16:12 LinasKo

Hi @LinasKo, I would like to contribute to this. Can you assign it to me?

Anirudh2112 avatar Dec 18 '24 21:12 Anirudh2112

Good afternoon @LinasKo. I have created a pull request for this issue. Could you please go through it and let me know if everything is working as needed or if any changes are required? Thank you.

Anirudh2112 avatar Jan 02 '25 20:01 Anirudh2112