Cleanup Detector labelmap (#4932)

* Add missing labels to default labelmap.  Fill any holes with "unknown".  Remove unique labelmap for tensorrt.

* Replace "truck" with "car" on Openvino labelmap
This commit is contained in:
Nate Meyer 2023-01-06 08:03:16 -05:00 committed by GitHub
parent 740d932848
commit 8ac3114f9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 8 deletions

View File

@ -91,7 +91,8 @@ RUN wget -qO cpu_model.tflite https://github.com/google-coral/test_data/raw/rele
COPY labelmap.txt . COPY labelmap.txt .
# Copy OpenVino model # Copy OpenVino model
COPY --from=ov-converter /models/public/ssdlite_mobilenet_v2/FP16 openvino-model COPY --from=ov-converter /models/public/ssdlite_mobilenet_v2/FP16 openvino-model
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 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 && \
sed -i 's/truck/car/g' openvino-model/coco_91cl_bkgr.txt

View File

@ -32,6 +32,3 @@ do
python3 onnx_to_tensorrt.py -m ${model} python3 onnx_to_tensorrt.py -m ${model}
cp /tensorrt_demos/yolo/${model}.trt ${OUTPUT_FOLDER}/${model}.trt; cp /tensorrt_demos/yolo/${model}.trt ${OUTPUT_FOLDER}/${model}.trt;
done done
# Download Labelmap
wget -q https://github.com/openvinotoolkit/open_model_zoo/raw/master/data/dataset_classes/coco_91cl.txt -O ${OUTPUT_FOLDER}/coco_91cl.txt

View File

@ -228,7 +228,6 @@ detectors:
model: model:
path: /trt-models/yolov7-tiny-416.trt path: /trt-models/yolov7-tiny-416.trt
labelmap_path: /trt-models/coco_91cl.txt
input_tensor: nchw input_tensor: nchw
input_pixel_format: rgb input_pixel_format: rgb
width: 416 width: 416

View File

@ -706,15 +706,17 @@ def load_labels(path, encoding="utf-8"):
Dictionary mapping indices to labels. Dictionary mapping indices to labels.
""" """
with open(path, "r", encoding=encoding) as f: with open(path, "r", encoding=encoding) as f:
labels = {index: "unknown" for index in range(91)}
lines = f.readlines() lines = f.readlines()
if not lines: if not lines:
return {} return {}
if lines[0].split(" ", maxsplit=1)[0].isdigit(): if lines[0].split(" ", maxsplit=1)[0].isdigit():
pairs = [line.split(" ", maxsplit=1) for line in lines] pairs = [line.split(" ", maxsplit=1) for line in lines]
return {int(index): label.strip() for index, label in pairs} labels.update({int(index): label.strip() for index, label in pairs})
else: else:
return {index: line.strip() for index, line in enumerate(lines)} labels.update({index: line.strip() for index, line in enumerate(lines)})
return labels
def clean_camera_user_pass(line: str) -> str: def clean_camera_user_pass(line: str) -> str:

View File

@ -9,6 +9,7 @@
8 boat 8 boat
9 traffic light 9 traffic light
10 fire hydrant 10 fire hydrant
11 street sign
12 stop sign 12 stop sign
13 parking meter 13 parking meter
14 bench 14 bench
@ -22,8 +23,11 @@
22 bear 22 bear
23 zebra 23 zebra
24 giraffe 24 giraffe
25 hat
26 backpack 26 backpack
27 umbrella 27 umbrella
28 shoe
29 eye glasses
30 handbag 30 handbag
31 tie 31 tie
32 suitcase 32 suitcase
@ -38,6 +42,7 @@
41 surfboard 41 surfboard
42 tennis racket 42 tennis racket
43 bottle 43 bottle
44 plate
45 wine glass 45 wine glass
46 cup 46 cup
47 fork 47 fork
@ -58,8 +63,12 @@
62 couch 62 couch
63 potted plant 63 potted plant
64 bed 64 bed
65 mirror
66 dining table 66 dining table
67 window
68 desk
69 toilet 69 toilet
70 door
71 tv 71 tv
72 laptop 72 laptop
73 mouse 73 mouse
@ -71,6 +80,7 @@
79 toaster 79 toaster
80 sink 80 sink
81 refrigerator 81 refrigerator
82 blender
83 book 83 book
84 clock 84 clock
85 vase 85 vase
@ -78,3 +88,4 @@
87 teddy bear 87 teddy bear
88 hair drier 88 hair drier
89 toothbrush 89 toothbrush
90 hair brush