sujanshresstha/YOLOv9_DeepSORT

class_id is Incompatible with class_name

Closed this issue · 2 comments

Hello!Thanks for your code!But I have a problem.The code class_id = track.get_det_class() seemly work not good.
I use your code file named coco.names ,including 80 classes.But class_id has 875 classes. By the way, I use yolov9-c.pt downloading from your readme.I just change the source.Please give me an answer.Thanks!

bugpy-2024.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 38893 -- /mnt/bb/zt/torch_yolov9/detect_tracking.py
I0424 20:57:07.730828 139915310851904 embedder_pytorch.py:69] MobileNetV2 Embedder for Deep Sort initialised
I0424 20:57:07.731621 139915310851904 embedder_pytorch.py:70] - gpu enabled: True
I0424 20:57:07.731755 139915310851904 embedder_pytorch.py:71] - half precision: True
I0424 20:57:07.731870 139915310851904 embedder_pytorch.py:72] - max batch size: 16
I0424 20:57:07.731981 139915310851904 embedder_pytorch.py:73] - expects BGR: True
I0424 20:57:08.492943 139915310851904 deepsort_tracker.py:142] DeepSort Tracker initialised
I0424 20:57:08.493184 139915310851904 deepsort_tracker.py:143] - max age: 50
I0424 20:57:08.493317 139915310851904 deepsort_tracker.py:144] - appearance threshold: 0.2
I0424 20:57:08.493435 139915310851904 deepsort_tracker.py:145] - nms threshold: OFF
I0424 20:57:08.493539 139915310851904 deepsort_tracker.py:148] - max num of appearance features: None
I0424 20:57:08.493642 139915310851904 deepsort_tracker.py:149] - overriding track class : No
I0424 20:57:08.493743 139915310851904 deepsort_tracker.py:152] - today given : No
I0424 20:57:08.493844 139915310851904 deepsort_tracker.py:153] - in-build embedder : Yes
I0424 20:57:08.493944 139915310851904 deepsort_tracker.py:154] - polygon detections : No
Fusing layers...
Model summary: 724 layers, 51141120 parameters, 0 gradients, 238.7 GFLOPs
Adding AutoShape...
Traceback (most recent call last):
File "/mnt/zz/anaconda3/envs/torch1.9/lib/python3.8/runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/mnt/zz/anaconda3/envs/torch1.9/lib/python3.8/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/zz/.vscode-server/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/main.py", line 39, in
cli.main()
File "/home/zz/.vscode-server/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/home/zz/.vscode-server/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
runpy.run_path(target, run_name="main")
File "/home/zz/.vscode-server/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
File "/home/zz/.vscode-server/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/home/zz/.vscode-server/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "/mnt/bb/zt/torch_yolov9/detect_tracking.py", line 108, in
app.run(main)
File "/mnt/zz/anaconda3/envs/torch1.9/lib/python3.8/site-packages/absl/app.py", line 312, in run
_run_main(main, args)
File "/mnt/zz/anaconda3/envs/torch1.9/lib/python3.8/site-packages/absl/app.py", line 258, in _run_main
sys.exit(main(argv))
File "/mnt/bb/zt/torch_yolov9/detect_tracking.py", line 84, in main
color = colors[80]
IndexError: index 80 is out of bounds for axis 0 with size 80

Hey there, @isserendipity !

Could you please double-check the model you've downloaded? The provided weights are trained for the COCO object detection dataset, so it's not possible for the class_id to be 875. It appears to be functioning correctly on my end.

For

File "/mnt/bb/zt/torch_yolov9/detect_tracking.py", line 84, in main
color = colors[80]
IndexError: index 80 is out of bounds for axis 0 with size 80

If you're attempting to hard code the last object from coco.names in line 84, you should update it to "color = colors[79]" since there are only 80 objects listed there.

Thank for you answer! I solve this problem by your way! Hope you be happy everyday!