Unverified 提交 b564c1f3 authored 作者: Yonghye Kwon's avatar Yonghye Kwon 提交者: GitHub

Check `conf_thres` and `iou_thres` prior to use (#10515)

* Checks conf_thres and iou_thres at beign Why checks conf_thres after operation with it? Signed-off-by: 's avatarYonghye Kwon <developer.0hye@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update general.py Signed-off-by: 's avatarYonghye Kwon <developer.0hye@gmail.com> Co-authored-by: 's avatarpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com>
上级 1ae91940
...@@ -898,6 +898,9 @@ def non_max_suppression( ...@@ -898,6 +898,9 @@ def non_max_suppression(
list of detections, on (n,6) tensor per image [xyxy, conf, cls] list of detections, on (n,6) tensor per image [xyxy, conf, cls]
""" """
# Checks
assert 0 <= conf_thres <= 1, f'Invalid Confidence threshold {conf_thres}, valid values are between 0.0 and 1.0'
assert 0 <= iou_thres <= 1, f'Invalid IoU {iou_thres}, valid values are between 0.0 and 1.0'
if isinstance(prediction, (list, tuple)): # YOLOv5 model in validation model, output = (inference_out, loss_out) if isinstance(prediction, (list, tuple)): # YOLOv5 model in validation model, output = (inference_out, loss_out)
prediction = prediction[0] # select only inference output prediction = prediction[0] # select only inference output
...@@ -909,10 +912,6 @@ def non_max_suppression( ...@@ -909,10 +912,6 @@ def non_max_suppression(
nc = prediction.shape[2] - nm - 5 # number of classes nc = prediction.shape[2] - nm - 5 # number of classes
xc = prediction[..., 4] > conf_thres # candidates xc = prediction[..., 4] > conf_thres # candidates
# Checks
assert 0 <= conf_thres <= 1, f'Invalid Confidence threshold {conf_thres}, valid values are between 0.0 and 1.0'
assert 0 <= iou_thres <= 1, f'Invalid IoU {iou_thres}, valid values are between 0.0 and 1.0'
# Settings # Settings
# min_wh = 2 # (pixels) minimum box width and height # min_wh = 2 # (pixels) minimum box width and height
max_wh = 7680 # (pixels) maximum box width and height max_wh = 7680 # (pixels) maximum box width and height
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论