From 2588abc10d9426f56d3f677cd6d9a3669cd41ab8 Mon Sep 17 00:00:00 2001 From: xiexinch Date: Wed, 23 Nov 2022 16:54:01 +0800 Subject: [PATCH 1/3] fix assertion --- mmcv/transforms/processing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mmcv/transforms/processing.py b/mmcv/transforms/processing.py index fef4e608ce..f4019c881b 100644 --- a/mmcv/transforms/processing.py +++ b/mmcv/transforms/processing.py @@ -1063,7 +1063,7 @@ def __init__( self.scales = scales else: self.scales = [scales] - assert mmengine.is_list_of(self.scales, tuple) + assert mmengine.is_list_of(self.scales, (tuple, int)) self.resize_cfg = dict(type=resize_type, **resize_kwargs) # create a empty Resize object @@ -1079,7 +1079,7 @@ def _random_select(self) -> Tuple[int, int]: ``scale_idx`` is the selected index in the given candidates. """ - assert mmengine.is_list_of(self.scales, tuple) + assert mmengine.is_list_of(self.scales, (tuple, int)) scale_idx = np.random.randint(len(self.scales)) scale = self.scales[scale_idx] return scale, scale_idx From 338f072d16222616089088547c1c86b7de42e3d9 Mon Sep 17 00:00:00 2001 From: xiexinch Date: Wed, 23 Nov 2022 17:10:47 +0800 Subject: [PATCH 2/3] remove assert --- mmcv/transforms/processing.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mmcv/transforms/processing.py b/mmcv/transforms/processing.py index f4019c881b..5d11ab7050 100644 --- a/mmcv/transforms/processing.py +++ b/mmcv/transforms/processing.py @@ -1079,7 +1079,6 @@ def _random_select(self) -> Tuple[int, int]: ``scale_idx`` is the selected index in the given candidates. """ - assert mmengine.is_list_of(self.scales, (tuple, int)) scale_idx = np.random.randint(len(self.scales)) scale = self.scales[scale_idx] return scale, scale_idx From ccce90a60f203ddf89c72cdf528ca542c3a72704 Mon Sep 17 00:00:00 2001 From: xiexinch Date: Wed, 23 Nov 2022 17:29:43 +0800 Subject: [PATCH 3/3] use is_seq_of --- mmcv/transforms/processing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmcv/transforms/processing.py b/mmcv/transforms/processing.py index 5d11ab7050..09098f1990 100644 --- a/mmcv/transforms/processing.py +++ b/mmcv/transforms/processing.py @@ -1063,7 +1063,7 @@ def __init__( self.scales = scales else: self.scales = [scales] - assert mmengine.is_list_of(self.scales, (tuple, int)) + assert mmengine.is_seq_of(self.scales, (tuple, int)) self.resize_cfg = dict(type=resize_type, **resize_kwargs) # create a empty Resize object