IDEA-Research / Grounded-Segment-Anything

Grounded SAM: Marrying Grounding DINO with Segment Anything & Stable Diffusion & Recognize Anything - Automatically Detect , Segment and Generate Anything
https://arxiv.org/abs/2401.14159
Apache License 2.0
14.23k stars 1.31k forks source link

ValueError in Labels issues? #452

Closed JohanHuynh0130 closed 4 months ago

JohanHuynh0130 commented 5 months ago

has anyone ever come into the issue below when trying to test other SAM models: Traceback (most recent call last): File "E:\PythonProjects\Grounded-Segment-Anything\EfficientSAM\grounded_mobile_sam.py", line 145, in main(args) File "E:\PythonProjects\Grounded-Segment-Anything\EfficientSAM\grounded_mobile_sam.py", line 83, in main labels = [ File "E:\PythonProjects\Grounded-Segment-Anything\EfficientSAM\grounded_mobile_sam.py", line 83, in labels = [ ValueError: too many values to unpack (expected 5)

Let me know how to fix this please. Thank you!

haviduck commented 5 months ago

detections returns 6 values, while the labels list takes into account 5. fixed by changing:

labels = [ f"{CLASSES[class_id]} {confidence:0.2f}" for _, _, confidence, class_id, _ in detections]

to:

labels = [ f"{CLASSES[class_id]} {confidence:0.2f}" for _, _, confidence, class_id, _, _ in detections]

JohanHuynh0130 commented 4 months ago

thanks a lot :) @haviduck