diff --git a/ultralytics/models/yolo/detect/val.py b/ultralytics/models/yolo/detect/val.py index 8226cd694..5550ec3ec 100644 --- a/ultralytics/models/yolo/detect/val.py +++ b/ultralytics/models/yolo/detect/val.py @@ -67,7 +67,7 @@ def init_metrics(self, model): val = self.data.get(self.args.split, "") # validation path self.is_coco = isinstance(val, str) and "coco" in val and val.endswith(f"{os.sep}val2017.txt") # is COCO self.class_map = converter.coco80_to_coco91_class() if self.is_coco else list(range(1000)) - self.args.save_json |= self.is_coco and not self.training # run on final val if training COCO + self.args.save_json |= self.is_coco # run on final val if training COCO self.names = model.names self.nc = len(model.names) self.metrics.names = self.names diff --git a/ultralytics/models/yolov10/predict.py b/ultralytics/models/yolov10/predict.py index 7310db3d0..00de85377 100644 --- a/ultralytics/models/yolov10/predict.py +++ b/ultralytics/models/yolov10/predict.py @@ -6,6 +6,9 @@ class YOLOv10DetectionPredictor(DetectionPredictor): def postprocess(self, preds, img, orig_imgs): + if isinstance(preds, dict): + preds = preds["one2one"] + if isinstance(preds, (list, tuple)): preds = preds[0] diff --git a/ultralytics/models/yolov10/val.py b/ultralytics/models/yolov10/val.py index 92419b2d9..bbe119922 100644 --- a/ultralytics/models/yolov10/val.py +++ b/ultralytics/models/yolov10/val.py @@ -8,7 +8,7 @@ def __init__(self, *args, **kwargs): self.args.save_json |= self.is_coco def postprocess(self, preds): - if self.training: + if isinstance(preds, dict): preds = preds["one2one"] if isinstance(preds, (list, tuple)): diff --git a/ultralytics/nn/modules/head.py b/ultralytics/nn/modules/head.py index ba9d2d218..54b59d6cb 100644 --- a/ultralytics/nn/modules/head.py +++ b/ultralytics/nn/modules/head.py @@ -516,7 +516,7 @@ def forward(self, x): if not self.training: one2one = self.inference(one2one) if not self.export: - return one2one + return {"one2many": one2many, "one2one": one2one} else: assert(self.max_det != -1) boxes, scores, labels = ops.v10postprocess(one2one.permute(0, 2, 1), self.max_det)