diff --git a/mmdeploy/codebase/mmcls/deploy/classification_model.py b/mmdeploy/codebase/mmcls/deploy/classification_model.py index 458c66ef8a..f7f3bbfe73 100644 --- a/mmdeploy/codebase/mmcls/deploy/classification_model.py +++ b/mmdeploy/codebase/mmcls/deploy/classification_model.py @@ -98,7 +98,7 @@ def forward_test(self, imgs: torch.Tensor, *args, **kwargs) -> \ def show_result(self, img: np.ndarray, result: list, - win_name: str, + win_name: str = '', show: bool = True, out_file: str = None): """Show predictions of classification. diff --git a/mmdeploy/codebase/mmocr/deploy/mmocr.py b/mmdeploy/codebase/mmocr/deploy/mmocr.py index 5bc95bf2c6..c97d2958a4 100644 --- a/mmdeploy/codebase/mmocr/deploy/mmocr.py +++ b/mmdeploy/codebase/mmocr/deploy/mmocr.py @@ -4,6 +4,7 @@ import mmcv import torch from mmcv.utils import Registry +from packaging import version from torch.utils.data import DataLoader, Dataset from mmdeploy.codebase.base import CODEBASE, BaseTask, MMCodebase @@ -137,6 +138,11 @@ def single_gpu_test(model: torch.nn.Module, Returns: list: The prediction results. """ - from mmdet.apis import single_gpu_test + import mmocr + # fixed the bug when using `--show-dir` after mocr v0.4.1 + if version.parse(mmocr.__version__) < version.parse('0.4.1'): + from mmdet.apis import single_gpu_test + else: + from mmocr.apis import single_gpu_test outputs = single_gpu_test(model, data_loader, show, out_dir, **kwargs) return outputs diff --git a/mmdeploy/codebase/mmocr/deploy/text_detection_model.py b/mmdeploy/codebase/mmocr/deploy/text_detection_model.py index 4b9b4ec99b..31861b66e4 100644 --- a/mmdeploy/codebase/mmocr/deploy/text_detection_model.py +++ b/mmdeploy/codebase/mmocr/deploy/text_detection_model.py @@ -118,7 +118,7 @@ def forward_test(self, imgs: torch.Tensor, *args, **kwargs) -> \ def show_result(self, img: np.ndarray, result: dict, - win_name: str, + win_name: str = '', show: bool = True, score_thr: float = 0.3, out_file: str = None): diff --git a/mmdeploy/codebase/mmocr/deploy/text_recognition_model.py b/mmdeploy/codebase/mmocr/deploy/text_recognition_model.py index 42e88f2235..7f07dbba63 100644 --- a/mmdeploy/codebase/mmocr/deploy/text_recognition_model.py +++ b/mmdeploy/codebase/mmocr/deploy/text_recognition_model.py @@ -125,7 +125,7 @@ def forward_test(self, imgs: torch.Tensor, def show_result(self, img: np.ndarray, result: list, - win_name: str, + win_name: str = '', show: bool = True, score_thr: float = 0.3, out_file: str = None):