7 def __init__(self, modelPath, inputSize=[320, 240], confThreshold=0.8, nmsThreshold=0.3, topK=5000, keepTopK=750, backendId=0, targetId=0):
18 self.
min_sizes = [[10, 16, 24], [32, 48], [64, 96], [128, 192, 256]]
19 self.
steps = [8, 16, 32, 64]
83 feature_map_2th = [int(int((h + 1) / 2) / 2),
84 int(int((w + 1) / 2) / 2)]
85 feature_map_3th = [int(feature_map_2th[0] / 2),
86 int(feature_map_2th[1] / 2)]
87 feature_map_4th = [int(feature_map_3th[0] / 2),
88 int(feature_map_3th[1] / 2)]
89 feature_map_5th = [int(feature_map_4th[0] / 2),
90 int(feature_map_4th[1] / 2)]
91 feature_map_6th = [int(feature_map_5th[0] / 2),
92 int(feature_map_5th[1] / 2)]
94 feature_maps = [feature_map_3th, feature_map_4th,
95 feature_map_5th, feature_map_6th]
98 for k, f
in enumerate(feature_maps):
100 for i, j
in product(range(f[0]), range(f[1])):
101 for min_size
in min_sizes:
105 cx = (j + 0.5) * self.
steps[k] / w
106 cy = (i + 0.5) * self.
steps[k] / h
108 priors.append([cx, cy, s_kx, s_ky])
109 self.
priors = np.array(priors, dtype=np.float32)
112 loc, conf, iou = blob
114 cls_scores = conf[:, 1]
115 iou_scores = iou[:, 0]
117 _idx = np.where(iou_scores < 0.)
118 iou_scores[_idx] = 0.
119 _idx = np.where(iou_scores > 1.)
120 iou_scores[_idx] = 1.
121 scores = np.sqrt(cls_scores * iou_scores)
122 scores = scores[:, np.newaxis]
134 dets = np.hstack((bboxes, scores))
__init__(self, modelPath, inputSize=[320, 240], confThreshold=0.8, nmsThreshold=0.3, topK=5000, keepTopK=750, backendId=0, targetId=0)