Skip to content

Commit 466a10d

Browse files
committed
refine code, test=develop
1 parent 9eb2d7b commit 466a10d

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

paddle/fluid/operators/detection/multiclass_nms_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ independently for each class. The outputs is a 2-D LoDTenosr, for each
520520
image, the offsets in first dimension of LoDTensor are called LoD, the number
521521
of offset is N + 1, where N is the batch size. If LoD[i + 1] - LoD[i] == 0,
522522
means there is no detected bbox for this image. If there is no detected boxes
523-
for all images, all the elements in LoD are set to {0,1}, and the Out only
523+
for all images, all the elements in LoD are set to {1}, and the Out only
524524
contains one value which is -1.
525525
)DOC");
526526
}

python/paddle/fluid/layers/detection.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,10 @@ class number, M is number of bounding boxes. For each category
263263
number is N + 1, N is the batch size. The i-th image has
264264
`LoD[i + 1] - LoD[i]` detected results, if it is 0, the i-th image
265265
has no detected results. If all images have not detected results,
266-
all the elements in LoD are 0, and output tensor only contains one
266+
LoD will be set to {1}, and output tensor only contains one
267267
value, which is -1.
268+
(After version 1.3, when no boxes detected, the lod is changed
269+
from {0} to {1}.)
268270
269271
Examples:
270272
.. code-block:: python
@@ -1967,8 +1969,8 @@ def multiclass_nms(bboxes,
19671969
scores,
19681970
score_threshold,
19691971
nms_top_k,
1970-
nms_threshold,
19711972
keep_top_k,
1973+
nms_threshold=0.3,
19721974
normalized=True,
19731975
nms_eta=1.,
19741976
background_label=0,
@@ -2035,8 +2037,10 @@ class number
20352037
Each row has 10 values:
20362038
[label, confidence, x1, y1, x2, y2, x3, y3, x4, y4]. No is the
20372039
total number of detections. If there is no detected boxes for all
2038-
images, lod will be set to {0, 1} and Out only contains one value
2039-
which is -1.
2040+
images, lod will be set to {1} and Out only contains one value
2041+
which is -1.
2042+
(After version 1.3, when no boxes detected, the lod is changed
2043+
from {0} to {1})
20402044
20412045
Examples:
20422046
.. code-block:: python

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from op_test import OpTest
2020

2121

22-
def iou(box_a, box_b, normalized):
22+
def iou(box_a, box_b, norm):
2323
"""Apply intersection-over-union overlap between box_a and box_b
2424
"""
2525
xmin_a = min(box_a[0], box_a[2])
@@ -32,10 +32,10 @@ def iou(box_a, box_b, normalized):
3232
xmax_b = max(box_b[0], box_b[2])
3333
ymax_b = max(box_b[1], box_b[3])
3434

35-
area_a = (ymax_a - ymin_a + (normalized == False)) * \
36-
(xmax_a - xmin_a + (normalized == False))
37-
area_b = (ymax_b - ymin_b + (normalized == False)) * \
38-
(xmax_b - xmin_b + (normalized == False))
35+
area_a = (ymax_a - ymin_a + (norm == False)) * (xmax_a - xmin_a +
36+
(norm == False))
37+
area_b = (ymax_b - ymin_b + (norm == False)) * (xmax_b - xmin_b +
38+
(norm == False))
3939
if area_a <= 0 and area_b <= 0:
4040
return 0.0
4141

@@ -44,8 +44,8 @@ def iou(box_a, box_b, normalized):
4444
xb = min(xmax_a, xmax_b)
4545
yb = min(ymax_a, ymax_b)
4646

47-
inter_area = max(xb - xa + (normalized == False), 0.0) * \
48-
max(yb - ya + (normalized == False), 0.0)
47+
inter_area = max(xb - xa + (norm == False),
48+
0.0) * max(yb - ya + (norm == False), 0.0)
4949

5050
iou_ratio = inter_area / (area_a + area_b - inter_area)
5151

@@ -210,7 +210,6 @@ def batched_multiclass_nms(boxes,
210210
normalized,
211211
shared=True)
212212
if nmsed_num == 0:
213-
# lod.append(1)
214213
continue
215214

216215
lod.append(nmsed_num)

0 commit comments

Comments
 (0)