From c985eaba0d928d96f2bcc7374dd830d6c885f16f Mon Sep 17 00:00:00 2001 From: Laughing <61612323+Laughing-q@users.noreply.github.com> Date: Sun, 8 Jan 2023 20:51:10 +0800 Subject: [PATCH] Fix segment coco val (#156) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- ultralytics/yolo/v8/segment/val.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ultralytics/yolo/v8/segment/val.py b/ultralytics/yolo/v8/segment/val.py index 288d378..019da2f 100644 --- a/ultralytics/yolo/v8/segment/val.py +++ b/ultralytics/yolo/v8/segment/val.py @@ -90,12 +90,14 @@ class SegmentationValidator(DetectionValidator): if self.args.single_cls: pred[:, 5] = 0 predn = pred.clone() - ops.scale_boxes(batch["img"][si].shape[1:], predn[:, :4], shape) # native-space pred + ops.scale_boxes(batch["img"][si].shape[1:], predn[:, :4], shape, + ratio_pad=batch["ratio_pad"][si]) # native-space pred # Evaluate if nl: tbox = ops.xywh2xyxy(bbox) # target boxes - ops.scale_boxes(batch["img"][si].shape[1:], tbox, shape) # native-space labels + ops.scale_boxes(batch["img"][si].shape[1:], tbox, shape, + ratio_pad=batch["ratio_pad"][si]) # native-space labels labelsn = torch.cat((cls, tbox), 1) # native-space labels correct_bboxes = self._process_batch(predn, labelsn) # TODO: maybe remove these `self.` arguments as they already are member variable @@ -117,7 +119,9 @@ class SegmentationValidator(DetectionValidator): # Save if self.args.save_json: pred_masks = ops.scale_image(batch["img"][si].shape[1:], - pred_masks.permute(1, 2, 0).contiguous().cpu().numpy(), shape) + pred_masks.permute(1, 2, 0).contiguous().cpu().numpy(), + shape, + ratio_pad=batch["ratio_pad"][si]) self.pred_to_json(predn, batch["im_file"][si], pred_masks) # if self.args.save_txt: # save_one_txt(predn, save_conf, shape, file=save_dir / 'labels' / f'{path.stem}.txt')