ibaiGorordo / ONNX-YOLOv8-Instance-Segmentation

Python scripts performing Instance Segmentation using the YOLOv8 model in ONNX.
MIT License
142 stars 30 forks source link

ValueError: zero-size array to reduction operation maximum which has no identity #2

Closed Abdiflame closed 1 year ago

Abdiflame commented 1 year ago

Hello @ibaiGorordo !

Thanks for your ONNX-YOLOv8-Instance-Segmentation module, it is very well-made and useful :)

Meanwhile, I found one small error that could be fixed as soon as you have time.

If our segmentation model has < 4 classes, we may have the "zero-size array to reduction error".

On file: YOLOSeg.py

instead of:

# Filter out object confidence scores below threshold
        scores = np.max(predictions[:, 4:num_classes], axis=1)

change to:

# Filter out object confidence scores below threshold
        scores = np.max(predictions[:, 4:4+num_classes], axis=1)

This made the algorithm work smoothly 👍

Thanks and feel free to comment or ask any questions :)

ibaiGorordo commented 1 year ago

Thanks! You are absolutely right, I missed that :facepalm:

Can you submit a quick PR for it. If not, I can change it, but since you found the bug I would prefer if you submit the PR