[Bug] GUI Image Detection inference fails with IndexError when loading native YOLO .pt models
Maintainers usually reply within 6 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- computer-vision, frontend, testing-qa
Research direction
Start with gui/tasks/image_detection/sidebar.py to inspect the model-format selection and its default for .pt files, then read perceptionmetrics/models/utils/torchvision.py to locate the raw-tensor postprocessing path. Run streamlit run app.py and reproduce the error by loading yolov8n.pt in the Image Detection Model sidebar and running inference in Tab 2. Done means native YOLO models are auto-selected when appropriate, raw tensors are routed to YOLO postprocessing, and inference no longer raises the IndexError.
Written by the indexing model from the issue text.
Description
Problem Description
When loading a native YOLO model (such as yolov8n.pt) in the Streamlit GUI, running inference in Tab 2 fails with:
Failed to run inference: too many indices for tensor of dimension 2
Steps to reproduce:
- Run
streamlit run app.py - In sidebar → Image Detection Model: upload
yolov8n.ptand valid ontology JSON. - Leave
Model Formatas default (torchvision) and click Load Model. - Tab 2 (Inference): upload any test image.
Root Cause:
In gui/tasks/image_detection/sidebar.py, the Model Format dropdown defaults to torchvision. Native YOLO models output a raw 2D tensor [84, 8400]. When passed to torchvision.postprocess_detection, executing output["scores"] on a 2D tensor raises IndexError.
Proposed Approach
- In
gui/tasks/image_detection/sidebar.py: Auto-selectYOLOin the dropdown if the model filename containsyoloor is a.ptfile (while still allowing manual selection). - In
perceptionmetrics/models/utils/torchvision.py: Add a type check so if a raw tensor is passed, it routes to YOLO postprocessing rather than crashing with an unhandled exception.
Environment
- OS: macOS (Apple Silicon M4)
- Python: 3.11
- Model:
yolov8n.pt
I've reproduced and tested this locally. I would like to submit a PR for this if the approach looks good to the maintainers!
- Dominant language
- Python
- Stars
- 117
- Forks
- 121
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JdeRobot/PerceptionMetrics
-
COCO loader drops images that have the same file name in different subfoldersPossibly taken @Vivaan-Atharva claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JdeRobot/PerceptionMetrics#702 ·
Maintainers usually reply within 6 days
-
YOLO loader only handles one image extension: other images are dropped or fail in read_annotationPossibly taken @soujasK claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
JdeRobot/PerceptionMetrics#700 ·
Maintainers usually reply within 6 days
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
JdeRobot/PerceptionMetrics#698 ·
Maintainers usually reply within 6 days
-
COCO-style mAP@[0.5:0.95] doesn't match pycocotools (uses 11-point interpolation)May be free again @clarkf19 claimed this 16 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JdeRobot/PerceptionMetrics#685 · 3 comments ·
Maintainers usually reply within 6 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
JdeRobot/PerceptionMetrics#684 · 1 comment ·
Maintainers usually reply within 6 days
All issues in JdeRobot/PerceptionMetrics
Similar issues
-
essreduce
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
Maintainers usually reply within 1 day
-
[PORT] A2A: map audio file parts to audio content and ignore MIME parameters (TS→Py)Possibly taken A pull request linked to this issue is open or already merged. Openarea-a2a bug port python
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
strands-agents/harness-sdk#6697 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TigreGotico/orthography2ipa#2950 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
TigreGotico/text2spoken#929 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100