Skip to content

Commit 9dad45c

Browse files
authored
Merge pull request #14560 from velconia/fix_nms_op_ut_in_py36
Fix multiclass_nms_op unit test fail in python3.6
2 parents e90afec + 3d0f6df commit 9dad45c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

python/paddle/fluid/tests/unittests/test_multiclass_nms_op.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,15 @@ def batched_multiclass_nms(boxes, scores, background, score_threshold,
145145
lod.append(nmsed_num)
146146
if nmsed_num == 0: continue
147147

148+
tmp_det_out = []
148149
for c, indices in nmsed_outs.items():
149150
for idx in indices:
150151
xmin, ymin, xmax, ymax = boxes[n][idx][:]
151-
det_outs.append([c, scores[n][c][idx], xmin, ymin, xmax, ymax])
152+
tmp_det_out.append(
153+
[c, scores[n][c][idx], xmin, ymin, xmax, ymax])
154+
sorted_det_out = sorted(
155+
tmp_det_out, key=lambda tup: tup[0], reverse=False)
156+
det_outs.extend(sorted_det_out)
152157

153158
return det_outs, lod
154159

@@ -210,7 +215,7 @@ def test_check_output(self):
210215
class TestMulticlassNMSOpNoOutput(TestMulticlassNMSOp):
211216
def set_argument(self):
212217
# Here set 2.0 to test the case there is no outputs.
213-
# In practical use, 0.0 < score_threshold < 1.0
218+
# In practical use, 0.0 < score_threshold < 1.0
214219
self.score_threshold = 2.0
215220

216221

0 commit comments

Comments
 (0)