Skip to content

Commit b0635ff

Browse files
LHamnettxiexinch
andauthored
[Enhancement] Change assertion logic inference cfg.model.test_cfg (open-mmlab#3012)
## Motivation In encode_decoder.py , assertion logic is not working correctly if user modifes cfg.test_cfg and defines it in a dictionary format. See: open-mmlab#3011 ## Modification Slight change to assertion behaviour to change assertion depending on if received test_cfg object is a dict or not. ## BC-breaking (Optional) Unsure - I believe this will not break any downstream tasks as the previous logic is still included ## Use cases (Optional) n/a --------- Co-authored-by: xiexinch <[email protected]>
1 parent 20adcfa commit b0635ff

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mmseg/models/segmentors/encoder_decoder.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class EncoderDecoder(BaseSegmentor):
3333
2. The ``predict`` method is used to predict segmentation results,
3434
which includes two steps: (1) Run inference function to obtain the list of
3535
seg_logits (2) Call post-processing function to obtain list of
36-
``SegDataSampel`` including ``pred_sem_seg`` and ``seg_logits``.
36+
``SegDataSample`` including ``pred_sem_seg`` and ``seg_logits``.
3737
3838
.. code:: text
3939
@@ -326,8 +326,9 @@ def inference(self, inputs: Tensor, batch_img_metas: List[dict]) -> Tensor:
326326
Tensor: The segmentation results, seg_logits from model of each
327327
input image.
328328
"""
329-
330-
assert self.test_cfg.mode in ['slide', 'whole']
329+
assert self.test_cfg.get('mode', 'whole') in ['slide', 'whole'], \
330+
f'Only "slide" or "whole" test mode are supported, but got ' \
331+
f'{self.test_cfg.mode}'
331332
ori_shape = batch_img_metas[0]['ori_shape']
332333
assert all(_['ori_shape'] == ori_shape for _ in batch_img_metas)
333334
if self.test_cfg.mode == 'slide':

0 commit comments

Comments
 (0)