diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d1591bf95d..90f7ebab85 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,13 +3,8 @@ repos: rev: 3.8.3 hooks: - id: flake8 - - repo: https://github.com/asottile/seed-isort-config - rev: v2.2.0 - hooks: - - id: seed-isort-config - args: ["--exclude", ".dev"] - - 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/mmseg/datasets/builder.py b/mmseg/datasets/builder.py index 4a12ec8adb..3529ab9228 100644 --- a/mmseg/datasets/builder.py +++ b/mmseg/datasets/builder.py @@ -64,8 +64,8 @@ def _concat_dataset(cfg, default_args=None): def build_dataset(cfg, default_args=None): """Build datasets.""" - from .dataset_wrappers import (ConcatDataset, RepeatDataset, - MultiImageMixDataset) + from .dataset_wrappers import (ConcatDataset, MultiImageMixDataset, + RepeatDataset) if isinstance(cfg, (list, tuple)): dataset = ConcatDataset([build_dataset(c, default_args) for c in cfg]) elif cfg['type'] == 'RepeatDataset': diff --git a/setup.cfg b/setup.cfg index 1045a9a85f..4839120ab6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ split_before_expression_after_opening_paren = true [isort] line_length = 79 multi_line_output = 0 -known_standard_library = setuptools +extra_standard_library = setuptools known_first_party = mmseg known_third_party = PIL,cityscapesscripts,cv2,detail,matplotlib,mmcv,numpy,onnxruntime,packaging,prettytable,pytest,pytorch_sphinx_theme,requests,scipy,seaborn,torch,ts no_lines_before = STDLIB,LOCALFOLDER diff --git a/tests/test_config.py b/tests/test_config.py index e6cec409d6..2482144439 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -66,9 +66,10 @@ def test_config_data_pipeline(): CommandLine: xdoctest -m tests/test_config.py test_config_build_data_pipeline """ + import numpy as np from mmcv import Config + from mmseg.datasets.pipelines import Compose - import numpy as np config_dpath = _get_config_directory() print('Found config_dpath = {!r}'.format(config_dpath)) diff --git a/tests/test_metrics.py b/tests/test_metrics.py index a8db8025df..51ad1f349c 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -308,9 +308,10 @@ def test_mean_fscore(): def test_filename_inputs(): - import cv2 import tempfile + import cv2 + def save_arr(input_arrays: list, title: str, is_image: bool, dir: str): filenames = [] SUFFIX = '.png' if is_image else '.npy' diff --git a/tests/test_models/test_losses/test_ce_loss.py b/tests/test_models/test_losses/test_ce_loss.py index 03bc3beef9..2fe5c2eb49 100644 --- a/tests/test_models/test_losses/test_ce_loss.py +++ b/tests/test_models/test_losses/test_ce_loss.py @@ -30,6 +30,7 @@ def test_ce_loss(): # test loss with class weights from file import os import tempfile + import mmcv import numpy as np tmp_file = tempfile.NamedTemporaryFile() diff --git a/tests/test_models/test_losses/test_dice_loss.py b/tests/test_models/test_losses/test_dice_loss.py index d6f10439d8..3936f5d741 100644 --- a/tests/test_models/test_losses/test_dice_loss.py +++ b/tests/test_models/test_losses/test_dice_loss.py @@ -21,6 +21,7 @@ def test_dice_lose(): # test loss with class weights from file import os import tempfile + import mmcv import numpy as np tmp_file = tempfile.NamedTemporaryFile() diff --git a/tests/test_models/test_losses/test_lovasz_loss.py b/tests/test_models/test_losses/test_lovasz_loss.py index 74ddb48d8e..bea3f4b77f 100644 --- a/tests/test_models/test_losses/test_lovasz_loss.py +++ b/tests/test_models/test_losses/test_lovasz_loss.py @@ -51,6 +51,7 @@ def test_lovasz_loss(): # test loss with class weights from file import os import tempfile + import mmcv import numpy as np tmp_file = tempfile.NamedTemporaryFile() diff --git a/tools/pytorch2onnx.py b/tools/pytorch2onnx.py index 1751a7b750..9de34048fa 100644 --- a/tools/pytorch2onnx.py +++ b/tools/pytorch2onnx.py @@ -242,8 +242,9 @@ def pytorch2onnx(model, None, {net_feed_input[0]: img_list[0].detach().numpy()})[0][0] # show segmentation results if show: - import cv2 import os.path as osp + + import cv2 img = img_meta_list[0][0]['filename'] if not osp.exists(img): img = imgs[0][:3, ...].permute(1, 2, 0) * 255