Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Support mmocr v0.4+ #115

Merged
merged 2 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mmdeploy/codebase/mmcls/deploy/classification_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion mmdeploy/codebase/mmocr/deploy/mmocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion mmdeploy/codebase/mmocr/deploy/text_detection_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion mmdeploy/codebase/mmocr/deploy/text_recognition_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down