[Fix] Fix bug cannot use both '--tta' and '--out' while testing. (#3067)

## Motivation

Fix bug cannot use both '--tta' and '--out' while testing.
For details, please refer to #3064 .

## Modification

Add 'img_path' in TTA predictions.

---------

Co-authored-by: xiexinch <xiexinch@outlook.com>
pull/3089/head
nightrain01 2023-06-06 16:39:41 +08:00 committed by GitHub
parent e8c8b94e8c
commit 13e42cc2ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -44,5 +44,6 @@ class SegTTAModel(BaseTTAModel):
'pred_sem_seg': PixelData(data=seg_pred),
'gt_sem_seg': data_samples[0].gt_sem_seg
})
data_sample.set_metainfo({'img_path': data_samples[0].img_path})
predictions.append(data_sample)
return predictions

View File

@ -1,4 +1,6 @@
# Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import torch
from mmengine import ConfigDict
from mmengine.model import BaseTTAModel
@ -37,7 +39,8 @@ def test_encoder_decoder_tta():
ori_shape=(10, 10),
img_shape=(10 + i, 10 + i),
flip=(i % 2 == 0),
flip_direction=flip_direction),
flip_direction=flip_direction,
img_path=tempfile.mktemp()),
gt_sem_seg=PixelData(data=torch.randint(0, 19, (1, 10, 10))))
])