From e93a5fbff648836a054f56a97c0afd523eb1795c Mon Sep 17 00:00:00 2001 From: Laughing <61612323+Laughing-q@users.noreply.github.com> Date: Mon, 26 Jun 2023 19:37:33 +0800 Subject: [PATCH] Fix RTDETR val_batch_pred (#3392) --- ultralytics/vit/rtdetr/val.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ultralytics/vit/rtdetr/val.py b/ultralytics/vit/rtdetr/val.py index 682296e..cfee292 100644 --- a/ultralytics/vit/rtdetr/val.py +++ b/ultralytics/vit/rtdetr/val.py @@ -91,6 +91,7 @@ class RTDETRValidator(DetectionValidator): """Apply Non-maximum suppression to prediction outputs.""" bs, _, nd = preds[0].shape bboxes, scores = preds[0].split((4, nd - 4), dim=-1) + bboxes *= self.args.imgsz outputs = [torch.zeros((0, 6), device=bboxes.device)] * bs for i, bbox in enumerate(bboxes): # (300, 4) bbox = ops.xywh2xyxy(bbox) @@ -126,8 +127,8 @@ class RTDETRValidator(DetectionValidator): if self.args.single_cls: pred[:, 5] = 0 predn = pred.clone() - predn[..., [0, 2]] *= shape[1] # native-space pred - predn[..., [1, 3]] *= shape[0] # native-space pred + predn[..., [0, 2]] *= shape[1] / self.args.imgsz # native-space pred + predn[..., [1, 3]] *= shape[0] / self.args.imgsz # native-space pred # Evaluate if nl: