Skip to content

Commit 8ac3114

Browse files
authored
Cleanup Detector labelmap (blakeblackshear#4932)
* Add missing labels to default labelmap. Fill any holes with "unknown". Remove unique labelmap for tensorrt. * Replace "truck" with "car" on Openvino labelmap
1 parent 740d932 commit 8ac3114

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ RUN wget -qO cpu_model.tflite https://github.com/google-coral/test_data/raw/rele
9191
COPY labelmap.txt .
9292
# Copy OpenVino model
9393
COPY --from=ov-converter /models/public/ssdlite_mobilenet_v2/FP16 openvino-model
94-
RUN wget -q https://github.com/openvinotoolkit/open_model_zoo/raw/master/data/dataset_classes/coco_91cl_bkgr.txt -O openvino-model/coco_91cl_bkgr.txt
94+
RUN wget -q https://github.com/openvinotoolkit/open_model_zoo/raw/master/data/dataset_classes/coco_91cl_bkgr.txt -O openvino-model/coco_91cl_bkgr.txt && \
95+
sed -i 's/truck/car/g' openvino-model/coco_91cl_bkgr.txt
9596

9697

9798

docker/tensorrt_models.sh

-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,3 @@ do
3232
python3 onnx_to_tensorrt.py -m ${model}
3333
cp /tensorrt_demos/yolo/${model}.trt ${OUTPUT_FOLDER}/${model}.trt;
3434
done
35-
36-
# Download Labelmap
37-
wget -q https://github.com/openvinotoolkit/open_model_zoo/raw/master/data/dataset_classes/coco_91cl.txt -O ${OUTPUT_FOLDER}/coco_91cl.txt

docs/docs/configuration/detectors.md

-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ detectors:
228228

229229
model:
230230
path: /trt-models/yolov7-tiny-416.trt
231-
labelmap_path: /trt-models/coco_91cl.txt
232231
input_tensor: nchw
233232
input_pixel_format: rgb
234233
width: 416

frigate/util.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -706,15 +706,17 @@ def load_labels(path, encoding="utf-8"):
706706
Dictionary mapping indices to labels.
707707
"""
708708
with open(path, "r", encoding=encoding) as f:
709+
labels = {index: "unknown" for index in range(91)}
709710
lines = f.readlines()
710711
if not lines:
711712
return {}
712713

713714
if lines[0].split(" ", maxsplit=1)[0].isdigit():
714715
pairs = [line.split(" ", maxsplit=1) for line in lines]
715-
return {int(index): label.strip() for index, label in pairs}
716+
labels.update({int(index): label.strip() for index, label in pairs})
716717
else:
717-
return {index: line.strip() for index, line in enumerate(lines)}
718+
labels.update({index: line.strip() for index, line in enumerate(lines)})
719+
return labels
718720

719721

720722
def clean_camera_user_pass(line: str) -> str:

labelmap.txt

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
8 boat
1010
9 traffic light
1111
10 fire hydrant
12+
11 street sign
1213
12 stop sign
1314
13 parking meter
1415
14 bench
@@ -22,8 +23,11 @@
2223
22 bear
2324
23 zebra
2425
24 giraffe
26+
25 hat
2527
26 backpack
2628
27 umbrella
29+
28 shoe
30+
29 eye glasses
2731
30 handbag
2832
31 tie
2933
32 suitcase
@@ -38,6 +42,7 @@
3842
41 surfboard
3943
42 tennis racket
4044
43 bottle
45+
44 plate
4146
45 wine glass
4247
46 cup
4348
47 fork
@@ -58,8 +63,12 @@
5863
62 couch
5964
63 potted plant
6065
64 bed
66+
65 mirror
6167
66 dining table
68+
67 window
69+
68 desk
6270
69 toilet
71+
70 door
6372
71 tv
6473
72 laptop
6574
73 mouse
@@ -71,10 +80,12 @@
7180
79 toaster
7281
80 sink
7382
81 refrigerator
83+
82 blender
7484
83 book
7585
84 clock
7686
85 vase
7787
86 scissors
7888
87 teddy bear
7989
88 hair drier
80-
89 toothbrush
90+
89 toothbrush
91+
90 hair brush

0 commit comments

Comments
 (0)