Warn on `save_hybrid=True` (#14484)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
pull/14498/head^2
Glenn Jocher 4 months ago committed by GitHub
parent 23720db369
commit e866579830
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 17
      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

Loading…
Cancel
Save