Skip to content

Commit

Permalink
corrected calculation of xc parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianfis committed Mar 24, 2024
1 parent 2a91ca2 commit e389e3d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions nms.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ def non_max_suppresion_v8(prediction, conf_thres=0.25, iou_thres=0.45, classes=N

nc = prediction.shape[2] - 4 # number of classes
# xc = prediction[..., 4] > conf_thres # candidates
xc = []
for xi, x in enumerate(prediction): # image index, image inference
conf = np.amax(x[:, 4:], axis=1, keepdims=True)
if np.any(conf > conf_thres):
xc.append(True)
else:
xc.append(False)
# xc = np.amax(prediction[..., 4:], axis=2, keepdims=True) > conf_thres
# xc = []
# for xi, x in enumerate(prediction): # image index, image inference
# conf = np.amax(x[:, 4:], axis=1, keepdims=True)
# if np.any(conf > conf_thres):
# xc.append(True)
# else:
# xc.append(False)
xc = np.amax(prediction[..., 4:], axis=2) > conf_thres

# Checks
assert 0 <= conf_thres <= 1, f'Invalid Confidence threshold {conf_thres}, valid values are between 0.0 and 1.0'
Expand Down

0 comments on commit e389e3d

Please sign in to comment.