From e866579830dcf6a1d418ce3f1ca7943f8db1349b Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Wed, 17 Jul 2024 17:26:00 +0200 Subject: [PATCH] Warn on `save_hybrid=True` (#14484) Signed-off-by: Glenn Jocher Co-authored-by: UltralyticsAssistant --- ultralytics/models/yolo/detect/val.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ultralytics/models/yolo/detect/val.py b/ultralytics/models/yolo/detect/val.py index 99cdab7c2f..133037c605 100644 --- a/ultralytics/models/yolo/detect/val.py +++ b/ultralytics/models/yolo/detect/val.py @@ -41,6 +41,11 @@ class DetectionValidator(BaseValidator): self.iouv = torch.linspace(0.5, 0.95, 10) # IoU vector for mAP@0.5:0.95 self.niou = self.iouv.numel() self.lb = [] # for autolabelling + if self.args.save_hybrid: + LOGGER.warning( + "WARNING ⚠️ 'save_hybrid=True' will append ground truth to predictions for autolabelling.\n" + "WARNING ⚠️ 'save_hybrid=True' will cause incorrect mAP.\n" + ) def preprocess(self, batch): """Preprocesses batch of images for YOLO training.""" @@ -53,14 +58,10 @@ class DetectionValidator(BaseValidator): height, width = batch["img"].shape[2:] nb = len(batch["img"]) bboxes = batch["bboxes"] * torch.tensor((width, height, width, height), device=self.device) - self.lb = ( - [ - torch.cat([batch["cls"][batch["batch_idx"] == i], bboxes[batch["batch_idx"] == i]], dim=-1) - for i in range(nb) - ] - if self.args.save_hybrid - else [] - ) # for autolabelling + self.lb = [ + torch.cat([batch["cls"][batch["batch_idx"] == i], bboxes[batch["batch_idx"] == i]], dim=-1) + for i in range(nb) + ] return batch