roboflow-python
roboflow-python copied to clipboard
`model.predict` fails when running segmentation model on numpy images
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!
Hi @LinasKo, I would like to contribute to this. Can you assign it to me?
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.