Deci-AI / super-gradients

Easily train or fine-tune SOTA computer vision models with one open source training library. The home of Yolo-NAS.
https://www.supergradients.com
Apache License 2.0
4.52k stars 489 forks source link

Bad support on some medical images with non RGB format #1920

Open james-imi opened 5 months ago

james-imi commented 5 months ago

🐛 Describe the bug

Using this code with the latest version

for image in tqdm(images):
    images_predictions = model.predict(image, iou=0.5, conf=0.4, class_agnostic_nms=True)
    class_names = images_predictions.class_names
    labels = images_predictions.prediction.labels
    confidence = images_predictions.prediction.confidence
    bboxes = images_predictions.prediction.bboxes_xyxy

    basefile = os.path.basename(image)

    for i, (label, conf, bbox) in enumerate(zip(labels, confidence, bboxes)):
        predictions.append({
            'xmin': int(bbox[0]),
            'ymin': int(bbox[1]),
            'xmax': int(bbox[2]),
            'ymax': int(bbox[3]),
            'confidence': float(conf),
            'class': int(label),
            'name': class_names[int(label)],
            'filename': basefile
        })

and noticed that my metrics are way off. Turns out, it reads the images that are mode I when using Pillow on image.mode weirdly and has poor support on this. Image gets loaded like this

image

Versions

Latest

BloodAxe commented 5 months ago

What is the original image format and channel number and depth?

james-imi commented 5 months ago

If you open it via Image.open, the mode is I instead of RGB

BloodAxe commented 5 months ago

What is the original image format and channel number and depth? Can you attach a file?

james-imi commented 4 months ago

alerady mentioned it before but in case its not clear image