jkjung-avt / tensorrt_demos

TensorRT MODNet, YOLOv4, YOLOv3, SSD, MTCNN, and GoogLeNet
https://jkjung-avt.github.io/
MIT License
1.74k stars 545 forks source link

IndexError: list index out of range #518

Closed fatfishlin closed 2 years ago

fatfishlin commented 2 years ago

hi,I do "Demo #5: YOLOv4" as you said,using: $python3 trt_yolo.py --usb 6 --width 1920 --height 1080 -m yolov4-416 it is ok(I have one camera in /dev/video6),detection is ok ,but I using: $python3 trt_yolo.py --usb 6 --width 1920 --height 1080 -m yolov4-416 -c 2 have error: [ WARN:0] global /home/nvidia/opencv/opencv-4.4.0/modules/videoio/src/cap_gstreamer.cpp (935) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1 Traceback (most recent call last): File "trt_yolo.py", line 110, in main() File "trt_yolo.py", line 103, in main loop_and_detect(cam, trt_yolo, conf_th=0.3, vis=vis) File "trt_yolo.py", line 68, in loop_and_detect img = vis.draw_bboxes(img, boxes, confs, clss) File "/home/nvidia/dev_ws/src/tensorrt_demos-master/utils/visualization.py", line 96, in draw_bboxes color = self.colors[cl] IndexError: list index out of range

please help me. thanks.

jkjung-avt commented 2 years ago

The "-c" (or "--category_num") option is for specifying number of object classes for your custom model.

The error messages basically told you that you called "trt_yolo.py" with "-c 2" but the model outputs a class ID larger than or equal to 2 (while only 0 and 1 are valid class IDs).