|
|
|
@ -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')
|
|
|
|
|