deal with empty non-topk obj in topk image
Browse files- box_utils.py +7 -4
box_utils.py
CHANGED
@@ -106,7 +106,7 @@ def postprocess(matches, prompt_labels, img_matches=None):
|
|
106 |
m['logit'], [1] *
|
107 |
len(m['box_id']),
|
108 |
list(np.array(m['cls_emb'])))))
|
109 |
-
if img_matches is not None and k in
|
110 |
img_m = img_matches_[k]
|
111 |
# and also those non-TopK hits and those non-topk are not anticipating training
|
112 |
boxes += [i for i in map(list, zip(img_m['box_id'], img_m['cx'], img_m['cy'], img_m['w'], img_m['h'],
|
@@ -114,6 +114,8 @@ def postprocess(matches, prompt_labels, img_matches=None):
|
|
114 |
l)] for l in img_m['label']], img_m['logit'],
|
115 |
[0] * len(img_m['box_id']), list(np.array(img_m['cls_emb']))))
|
116 |
if i[0] not in [b[0] for b in boxes]]
|
|
|
|
|
117 |
# update record metadata after query
|
118 |
for b in boxes:
|
119 |
meta.append(b[0])
|
@@ -127,7 +129,8 @@ def postprocess(matches, prompt_labels, img_matches=None):
|
|
127 |
list(zip(*[(*b[1:5], b[6]) for b in boxes]))))
|
128 |
ind = nms(cx, cy, w, h, s, 0.3)
|
129 |
boxes = [boxes[i] for i in ind]
|
130 |
-
|
131 |
-
|
132 |
-
(
|
|
|
133 |
return boxes_w_img, meta
|
|
|
106 |
m['logit'], [1] *
|
107 |
len(m['box_id']),
|
108 |
list(np.array(m['cls_emb'])))))
|
109 |
+
if img_matches is not None and k in img_matches_:
|
110 |
img_m = img_matches_[k]
|
111 |
# and also those non-TopK hits and those non-topk are not anticipating training
|
112 |
boxes += [i for i in map(list, zip(img_m['box_id'], img_m['cx'], img_m['cy'], img_m['w'], img_m['h'],
|
|
|
114 |
l)] for l in img_m['label']], img_m['logit'],
|
115 |
[0] * len(img_m['box_id']), list(np.array(img_m['cls_emb']))))
|
116 |
if i[0] not in [b[0] for b in boxes]]
|
117 |
+
else:
|
118 |
+
img_m = None
|
119 |
# update record metadata after query
|
120 |
for b in boxes:
|
121 |
meta.append(b[0])
|
|
|
129 |
list(zip(*[(*b[1:5], b[6]) for b in boxes]))))
|
130 |
ind = nms(cx, cy, w, h, s, 0.3)
|
131 |
boxes = [boxes[i] for i in ind]
|
132 |
+
if img_m is not None:
|
133 |
+
img_score = img_m['img_score'] if img_matches is not None else m['img_score']
|
134 |
+
boxes_w_img.append(
|
135 |
+
(m["img_id"], m["img_url"], m["img_w"], m["img_h"], img_score, boxes))
|
136 |
return boxes_w_img, meta
|