From 0a7d86cd26ddef5a37a02a4293ae10a5216a7a8a Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 10 Jan 2023 12:18:39 +0100 Subject: [PATCH] Detection training zero-mAP fix (#192) --- ultralytics/yolo/engine/exporter.py | 2 +- ultralytics/yolo/engine/model.py | 1 + ultralytics/yolo/v8/detect/train.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ultralytics/yolo/engine/exporter.py b/ultralytics/yolo/engine/exporter.py index a5bca5e..76f3b3e 100644 --- a/ultralytics/yolo/engine/exporter.py +++ b/ultralytics/yolo/engine/exporter.py @@ -168,7 +168,7 @@ class Exporter: # Input im = torch.zeros(self.args.batch, 3, *self.imgsz).to(self.device) - file = Path(getattr(model, 'pt_path', None) or model.yaml['yaml_file']) + file = Path(getattr(model, 'pt_path', None) or getattr(model, 'yaml_file', None) or model.yaml['yaml_file']) if file.suffix == '.yaml': file = Path(file.name) diff --git a/ultralytics/yolo/engine/model.py b/ultralytics/yolo/engine/model.py index 72df1a7..3e6e9a5 100644 --- a/ultralytics/yolo/engine/model.py +++ b/ultralytics/yolo/engine/model.py @@ -218,3 +218,4 @@ class YOLO: args.pop("batch", None) args.pop("epochs", None) args.pop("cache", None) + args.pop("save_json", None) diff --git a/ultralytics/yolo/v8/detect/train.py b/ultralytics/yolo/v8/detect/train.py index 3d0a115..9b0322c 100644 --- a/ultralytics/yolo/v8/detect/train.py +++ b/ultralytics/yolo/v8/detect/train.py @@ -60,7 +60,7 @@ class DetectionTrainer(BaseTrainer): def get_model(self, cfg=None, weights=None, verbose=True): model = DetectionModel(cfg, ch=3, nc=self.data["nc"], verbose=verbose) if weights: - model.load(model) + model.load(weights) return model