Skip to content

Commit f37b452

Browse files
author
yixu.cui
committed
1 parent 17f77d9 commit f37b452

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

utils/general.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ def segments2boxes(segments):
310310
def resample_segments(segments, n=1000):
311311
# Up-sample an (n,2) segment
312312
for i, s in enumerate(segments):
313+
s = np.concatenate((s, s[0:1, :]), axis=0)
313314
x = np.linspace(0, len(s) - 1, n)
314315
xp = np.arange(len(s))
315316
segments[i] = np.concatenate([np.interp(x, xp, s[:, i]) for i in range(2)]).reshape(2, -1).T # segment xy
@@ -646,7 +647,11 @@ def non_max_suppression(prediction, conf_thres=0.25, iou_thres=0.45, classes=Non
646647
continue
647648

648649
# Compute conf
649-
x[:, 5:] *= x[:, 4:5] # conf = obj_conf * cls_conf
650+
if nc == 1:
651+
x[:, 5:] = x[:, 4:5] # for models with one class, cls_loss is 0 and cls_conf is always 0.5,
652+
# so there is no need to multiplicate.
653+
else:
654+
x[:, 5:] *= x[:, 4:5] # conf = obj_conf * cls_conf
650655

651656
# Box (center x, center y, width, height) to (x1, y1, x2, y2)
652657
box = xywh2xyxy(x[:, :4])

0 commit comments

Comments
 (0)