diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5bc29280..61795ddd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,12 +4,8 @@ repos: rev: 4.0.1 hooks: - id: flake8 - - repo: https://github.com/asottile/seed-isort-config - rev: v2.2.0 - hooks: - - id: seed-isort-config - - repo: https://github.com/timothycrosley/isort - rev: 4.3.21 + - repo: https://github.com/PyCQA/isort + rev: 5.10.1 hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-yapf diff --git a/demo/ner_demo.py b/demo/ner_demo.py index 0fdcd86f..113d4e31 100755 --- a/demo/ner_demo.py +++ b/demo/ner_demo.py @@ -3,7 +3,6 @@ from argparse import ArgumentParser from mmocr.apis import init_detector from mmocr.apis.inference import text_model_inference - from mmocr.datasets import build_dataset # NOQA from mmocr.models import build_detector # NOQA diff --git a/mmocr/core/__init__.py b/mmocr/core/__init__.py index c126512d..beae1ba4 100644 --- a/mmocr/core/__init__.py +++ b/mmocr/core/__init__.py @@ -1,13 +1,12 @@ # Copyright (c) OpenMMLab. All rights reserved. from . import evaluation +from .evaluation import * # NOQA from .mask import extract_boundary, points2boundary, seg2boundary from .visualize import (det_recog_show_result, imshow_edge, imshow_node, imshow_pred_boundary, imshow_text_char_boundary, imshow_text_label, overlay_mask_img, show_feature, show_img_boundary, show_pred_gt) -from .evaluation import * # NOQA - __all__ = [ 'points2boundary', 'seg2boundary', 'extract_boundary', 'overlay_mask_img', 'show_feature', 'show_img_boundary', 'show_pred_gt', diff --git a/mmocr/core/deployment/deploy_utils.py b/mmocr/core/deployment/deploy_utils.py index a82a324c..9f5b31bb 100644 --- a/mmocr/core/deployment/deploy_utils.py +++ b/mmocr/core/deployment/deploy_utils.py @@ -48,6 +48,7 @@ class ONNXRuntimeDetector(TextDetectorMixin, SingleStageTextDetector): SingleStageTextDetector.__init__(self, **(cfg.model)) TextDetectorMixin.__init__(self, show_score) import onnxruntime as ort + # get the custom op path ort_custom_op_path = '' try: @@ -122,6 +123,7 @@ class ONNXRuntimeRecognizer(EncodeDecodeRecognizer): cfg.model.pop('type') EncodeDecodeRecognizer.__init__(self, **(cfg.model)) import onnxruntime as ort + # get the custom op path ort_custom_op_path = '' try: diff --git a/mmocr/datasets/__init__.py b/mmocr/datasets/__init__.py index b37068b2..c16565b1 100644 --- a/mmocr/datasets/__init__.py +++ b/mmocr/datasets/__init__.py @@ -12,7 +12,6 @@ from .openset_kie_dataset import OpensetKIEDataset from .pipelines import CustomFormatBundle, DBNetTargets, FCENetTargets from .text_det_dataset import TextDetDataset from .uniform_concat_dataset import UniformConcatDataset - from .utils import * # NOQA __all__ = [ diff --git a/mmocr/models/__init__.py b/mmocr/models/__init__.py index cd2f0d5e..e0c7bb89 100644 --- a/mmocr/models/__init__.py +++ b/mmocr/models/__init__.py @@ -4,7 +4,6 @@ from .builder import (BACKBONES, CONVERTORS, DECODERS, DETECTORS, ENCODERS, HEADS, LOSSES, NECKS, PREPROCESSOR, build_backbone, build_convertor, build_decoder, build_detector, build_encoder, build_loss, build_preprocessor) - from .common import * # NOQA from .kie import * # NOQA from .ner import * # NOQA diff --git a/mmocr/models/common/__init__.py b/mmocr/models/common/__init__.py index f9a578f1..94464711 100644 --- a/mmocr/models/common/__init__.py +++ b/mmocr/models/common/__init__.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. from . import backbones, layers, losses, modules - from .backbones import * # NOQA -from .losses import * # NOQA from .layers import * # NOQA +from .losses import * # NOQA from .modules import * # NOQA __all__ = backbones.__all__ + losses.__all__ + layers.__all__ + modules.__all__ diff --git a/mmocr/models/kie/__init__.py b/mmocr/models/kie/__init__.py index 9fd5d2de..b8e8c2c0 100644 --- a/mmocr/models/kie/__init__.py +++ b/mmocr/models/kie/__init__.py @@ -1,6 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. from . import extractors, heads, losses - from .extractors import * # NOQA from .heads import * # NOQA from .losses import * # NOQA diff --git a/mmocr/models/ner/__init__.py b/mmocr/models/ner/__init__.py index 1f8245c9..2d9866e7 100644 --- a/mmocr/models/ner/__init__.py +++ b/mmocr/models/ner/__init__.py @@ -1,6 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. from . import classifiers, convertors, decoders, encoders, losses - from .classifiers import * # NOQA from .convertors import * # NOQA from .decoders import * # NOQA diff --git a/mmocr/models/textdet/__init__.py b/mmocr/models/textdet/__init__.py index b644d103..027e812f 100644 --- a/mmocr/models/textdet/__init__.py +++ b/mmocr/models/textdet/__init__.py @@ -1,6 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. from . import dense_heads, detectors, losses, necks, postprocess - from .dense_heads import * # NOQA from .detectors import * # NOQA from .losses import * # NOQA diff --git a/mmocr/models/textrecog/__init__.py b/mmocr/models/textrecog/__init__.py index c3b2e1ec..b24be2da 100644 --- a/mmocr/models/textrecog/__init__.py +++ b/mmocr/models/textrecog/__init__.py @@ -1,17 +1,16 @@ # Copyright (c) OpenMMLab. All rights reserved. from . import (backbones, convertors, decoders, encoders, fusers, heads, losses, necks, preprocessor, recognizer) - from .backbones import * # NOQA from .convertors import * # NOQA from .decoders import * # NOQA from .encoders import * # NOQA +from .fusers import * # NOQA from .heads import * # NOQA from .losses import * # NOQA from .necks import * # NOQA from .preprocessor import * # NOQA from .recognizer import * # NOQA -from .fusers import * # NOQA __all__ = ( backbones.__all__ + convertors.__all__ + decoders.__all__ + diff --git a/setup.cfg b/setup.cfg index a74ef41e..01acd45e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,7 +18,7 @@ SPLIT_PENALTY_AFTER_OPENING_BRACKET=800 [isort] line_length = 79 multi_line_output = 0 -known_standard_library = setuptools +extra_standard_library = setuptools known_first_party = mmocr known_third_party = PIL,cv2,imgaug,lanms,lmdb,matplotlib,mmcv,mmdet,numpy,packaging,pyclipper,pytest,pytorch_sphinx_theme,rapidfuzz,requests,scipy,shapely,skimage,titlecase,torch,torchvision,ts,yaml no_lines_before = STDLIB,LOCALFOLDER diff --git a/setup.py b/setup.py index 4441e61c..09a88c3e 100644 --- a/setup.py +++ b/setup.py @@ -80,6 +80,7 @@ def get_version(): with open(version_file, 'r') as f: exec(compile(f.read(), version_file, 'exec')) import sys + # return short version for sdist if 'sdist' in sys.argv or 'bdist_wheel' in sys.argv: return locals()['short_version'] @@ -99,9 +100,9 @@ def parse_requirements(fname='requirements.txt', with_version=True): CommandLine: python -c "import setup; print(setup.parse_requirements())" """ + import re import sys from os.path import exists - import re require_fpath = fname def parse_line(line): diff --git a/tests/test_core/test_deploy_utils.py b/tests/test_core/test_deploy_utils.py index 88a63469..10541ca8 100644 --- a/tests/test_core/test_deploy_utils.py +++ b/tests/test_core/test_deploy_utils.py @@ -23,7 +23,7 @@ def test_detector_wrapper(): try: import onnxruntime as ort # noqa: F401 import tensorrt as trt - from mmcv.tensorrt import (onnx2trt, save_trt_engine) + from mmcv.tensorrt import onnx2trt, save_trt_engine except ImportError: pytest.skip('ONNXRuntime or TensorRT is not available.') @@ -129,7 +129,7 @@ def test_recognizer_wrapper(): try: import onnxruntime as ort # noqa: F401 import tensorrt as trt - from mmcv.tensorrt import (onnx2trt, save_trt_engine) + from mmcv.tensorrt import onnx2trt, save_trt_engine except ImportError: pytest.skip('ONNXRuntime or TensorRT is not available.') diff --git a/tools/deployment/mmocr_handler.py b/tools/deployment/mmocr_handler.py index beaed6f0..a667f039 100644 --- a/tools/deployment/mmocr_handler.py +++ b/tools/deployment/mmocr_handler.py @@ -7,7 +7,6 @@ import torch from ts.torch_handler.base_handler import BaseHandler from mmocr.apis import init_detector, model_inference - from mmocr.datasets.pipelines import * # NOQA