Skip to content

Commit 20cf975

Browse files
committed
Add num classes for SSD models
1 parent d0da121 commit 20cf975

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

fastmot/detector.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __init__(self, size,
8686
self.max_area = max_area
8787

8888
class_ids = [] if class_ids is None else list(class_ids)
89-
self.label_mask = np.zeros(len(models.LABEL_MAP), dtype=np.bool_)
89+
self.label_mask = np.zeros(self.model.NUM_CLASSES, dtype=np.bool_)
9090
self.label_mask[class_ids] = True
9191

9292
self.batch_size = int(np.prod(self.tiling_grid))

fastmot/models/ssd.py

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class SSD:
1212
PLUGIN_PATH = None
1313
ENGINE_PATH = None
1414
MODEL_PATH = None
15+
NUM_CLASSES = None
1516
INPUT_SHAPE = None
1617
OUTPUT_NAME = None
1718

@@ -70,6 +71,7 @@ def build_engine(cls, trt_logger, batch_size, calib_dataset=Path.home() / 'VOCde
7071
class SSDMobileNetV1(SSD):
7172
ENGINE_PATH = Path(__file__).parent / 'ssd_mobilenet_v1_coco.trt'
7273
MODEL_PATH = Path(__file__).parent / 'ssd_mobilenet_v1_coco.pb'
74+
NUM_CLASSES = 90
7375
INPUT_SHAPE = (3, 300, 300)
7476
OUTPUT_NAME = 'NMS'
7577
NMS_THRESH = 0.5
@@ -167,6 +169,7 @@ def add_plugin(cls, graph):
167169
class SSDMobileNetV2(SSD):
168170
ENGINE_PATH = Path(__file__).parent / 'ssd_mobilenet_v2_coco.trt'
169171
MODEL_PATH = Path(__file__).parent / 'ssd_mobilenet_v2_coco.pb'
172+
NUM_CLASSES = 90
170173
INPUT_SHAPE = (3, 300, 300)
171174
OUTPUT_NAME = 'NMS'
172175
NMS_THRESH = 0.5
@@ -263,6 +266,7 @@ def add_plugin(cls, graph):
263266
class SSDInceptionV2(SSD):
264267
ENGINE_PATH = Path(__file__).parent / 'ssd_inception_v2_coco.trt'
265268
MODEL_PATH = Path(__file__).parent / 'ssd_inception_v2_coco.pb'
269+
NUM_CLASSES = 90
266270
INPUT_SHAPE = (3, 300, 300)
267271
OUTPUT_NAME = 'NMS'
268272
NMS_THRESH = 0.5

0 commit comments

Comments
 (0)