From 314da263c7a53affd70a6aadb00aadaa2f9c966e Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Thu, 5 Jan 2023 15:56:52 +0100 Subject: [PATCH] Default confidences predict 0.25, val 0.001 (#149) --- ultralytics/yolo/configs/default.yaml | 2 +- ultralytics/yolo/engine/predictor.py | 3 ++- ultralytics/yolo/engine/validator.py | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ultralytics/yolo/configs/default.yaml b/ultralytics/yolo/configs/default.yaml index fe8b820..896c197 100644 --- a/ultralytics/yolo/configs/default.yaml +++ b/ultralytics/yolo/configs/default.yaml @@ -39,7 +39,7 @@ dropout: False # use dropout regularization val: True # validate/test during training save_json: False # save results to JSON file save_hybrid: False # save hybrid version of labels (labels + additional predictions) -conf: 0.001 # object confidence threshold for detection +conf: null # object confidence threshold for detection (default 0.25 predict, 0.001 val) iou: 0.7 # intersection over union (IoU) threshold for NMS max_det: 300 # maximum number of detections per image half: False # use half precision (FP16) diff --git a/ultralytics/yolo/engine/predictor.py b/ultralytics/yolo/engine/predictor.py index cd8537c..d654257 100644 --- a/ultralytics/yolo/engine/predictor.py +++ b/ultralytics/yolo/engine/predictor.py @@ -77,7 +77,8 @@ class BasePredictor: name = self.args.name or f"{self.args.mode}" self.save_dir = increment_path(Path(project) / name, exist_ok=self.args.exist_ok) (self.save_dir / 'labels' if self.args.save_txt else self.save_dir).mkdir(parents=True, exist_ok=True) - + if self.args.conf is None: + self.args.conf = 0.25 # default conf=0.25 self.done_setup = False # Usable if setup is done diff --git a/ultralytics/yolo/engine/validator.py b/ultralytics/yolo/engine/validator.py index 8ca8d04..8e5210b 100644 --- a/ultralytics/yolo/engine/validator.py +++ b/ultralytics/yolo/engine/validator.py @@ -65,6 +65,9 @@ class BaseValidator: exist_ok=self.args.exist_ok if RANK in {-1, 0} else True) (self.save_dir / 'labels' if self.args.save_txt else self.save_dir).mkdir(parents=True, exist_ok=True) + if self.args.conf is None: + self.args.conf = 0.001 # default conf=0.001 + self.callbacks = defaultdict(list, {k: [v] for k, v in callbacks.default_callbacks.items()}) # add callbacks @smart_inference_mode()