nathanrooy / rpi-urban-mobility-tracker

The easiest way to count pedestrians, cyclists, and vehicles on edge computing devices or live video feeds.
GNU General Public License v3.0
121 stars 37 forks source link

Error when -labelmap labels.txt is added #28

Open geeuk opened 2 years ago

geeuk commented 2 years ago

(venv) root@raspberrypi:/home/pi/ped-net/model# umt -video highway_01.mp4 -modelpath pednet_20200517.tflite -labelmap labels.txt

INITIALIZING UMT... THRESHOLD: 0.5 CUSTOM LABEL MAP = TRUE (labels.txt) TPU = FALSE CUSTOM DETECTOR = TRUE DETECTOR PATH = pednet_20200517.tflite

TRACKING... FRAME: 0 Traceback (most recent call last): File "/home/pi/venv/bin/umt", line 8, in sys.exit(main()) File "/home/pi/venv/lib/python3.7/site-packages/umt/umt_main.py", line 106, in main class_name = labels[track.class_name] KeyError: 3

without it:

(venv) root@raspberrypi:/home/pi/ped-net/model# umt -video highway_01.mp4 -modelpath pednet_20200517.tflite -labelmap labels.txt

INITIALIZING UMT... THRESHOLD: 0.5 CUSTOM LABEL MAP = TRUE (labels.txt) TPU = FALSE CUSTOM DETECTOR = TRUE DETECTOR PATH = pednet_20200517.tflite

TRACKING... FRAME: 0 Traceback (most recent call last): File "/home/pi/venv/bin/umt", line 8, in sys.exit(main()) File "/home/pi/venv/lib/python3.7/site-packages/umt/umt_main.py", line 106, in main class_name = labels[track.class_name] KeyError: 3 (venv) root@raspberrypi:/home/pi/ped-net/model# umt -video highway_01.mp4 -modelpath pednet_20200517.tflite INITIALIZING UMT... THRESHOLD: 0.5 CUSTOM LABEL MAP = FALSE TPU = FALSE CUSTOM DETECTOR = TRUE DETECTOR PATH = pednet_20200517.tflite

TRACKING... FRAME: 0 FRAME: 1 FRAME: 2 FRAME: 3 FRAME: 4 FRAME: 5 FRAME: 6 FRAME: 7 FRAME: 8 FRAME: 9 (venv) root@raspberrypi:/home/pi/ped-net/model#

jcothran commented 2 years ago

I believe the model file has 4 classes (0-3) but the label text file only has 3 classes. I got around this error by adding 'scooter' as the 4th class in the label file. This labeled all the cars as scooters so labels list maybe should be as below with vehicle as 4th class:

1 bike 2 pedestrian 3 scooter 4 vehicle