From d65f9c01f638cfad0e7412b5ed5085e19e712c2e Mon Sep 17 00:00:00 2001 From: zytx121 <592267829@qq.com> Date: Thu, 13 Apr 2023 07:55:26 +0800 Subject: [PATCH 1/2] update lnt --- .dev_scripts/gather_models.py | 5 ++--- .pre-commit-config-zh-cn.yaml | 2 +- .pre-commit-config.yaml | 4 ++-- demo/huge_image_demo.py | 3 +-- demo/image_demo.py | 3 +-- docs/en/conf.py | 3 +-- docs/zh_cn/conf.py | 3 +-- mmrotate/apis/inference.py | 3 +-- mmrotate/datasets/dior.py | 7 +++---- mmrotate/datasets/dota.py | 3 +-- mmrotate/datasets/hrsc.py | 7 +++---- mmrotate/datasets/transforms/loading.py | 3 +-- mmrotate/datasets/transforms/transforms.py | 5 ++--- mmrotate/evaluation/functional/mean_ap.py | 3 +-- mmrotate/evaluation/metrics/dota_metric.py | 7 +++---- mmrotate/evaluation/metrics/rotated_coco_metric.py | 9 ++++----- mmrotate/models/backbones/re_resnet.py | 4 ++-- mmrotate/models/dense_heads/angle_branch_retina_head.py | 3 +-- mmrotate/models/dense_heads/cfa_head.py | 3 +-- mmrotate/models/dense_heads/h2rbox_head.py | 3 +-- mmrotate/models/dense_heads/oriented_reppoints_head.py | 3 +-- mmrotate/models/dense_heads/oriented_rpn_head.py | 3 +-- mmrotate/models/dense_heads/r3_head.py | 3 +-- mmrotate/models/dense_heads/rotated_atss_head.py | 3 +-- mmrotate/models/dense_heads/rotated_fcos_head.py | 3 +-- mmrotate/models/dense_heads/rotated_reppoints_head.py | 3 +-- mmrotate/models/dense_heads/rotated_rtmdet_head.py | 3 +-- mmrotate/models/dense_heads/s2a_head.py | 3 +-- mmrotate/models/dense_heads/sam_reppoints_head.py | 3 +-- mmrotate/models/detectors/h2rbox.py | 3 +-- mmrotate/models/detectors/refine_single_stage.py | 3 +-- mmrotate/models/layers/align.py | 3 +-- mmrotate/models/losses/gaussian_dist_loss.py | 3 +-- mmrotate/models/losses/gaussian_dist_loss_v1.py | 3 +-- mmrotate/models/losses/h2rbox_consistency_loss.py | 3 +-- mmrotate/models/losses/rotated_iou_loss.py | 3 +-- mmrotate/models/necks/re_fpn.py | 6 +++--- .../models/roi_heads/bbox_heads/convfc_rbbox_head.py | 3 +-- mmrotate/models/roi_heads/bbox_heads/gv_bbox_head.py | 3 +-- mmrotate/models/roi_heads/gv_ratio_roi_head.py | 3 +-- .../models/task_modules/assigners/convex_assigner.py | 3 +-- .../task_modules/assigners/max_convex_iou_assigner.py | 3 +-- .../task_modules/assigners/rotated_atss_assigner.py | 5 ++--- mmrotate/models/task_modules/assigners/sas_assigner.py | 3 +-- mmrotate/models/task_modules/coders/angle_coder.py | 1 - .../coders/delta_midpointoffset_rbbox_coder.py | 3 +-- .../models/task_modules/coders/delta_xywh_hbbox_coder.py | 3 +-- .../models/task_modules/coders/delta_xywh_qbbox_coder.py | 3 +-- .../task_modules/coders/delta_xywht_hbbox_coder.py | 3 +-- .../task_modules/coders/delta_xywht_rbbox_coder.py | 3 +-- .../models/task_modules/coders/gliding_vertex_coder.py | 3 +-- .../task_modules/prior_generators/anchor_generator.py | 3 +-- mmrotate/models/utils/orconv.py | 2 +- mmrotate/structures/bbox/quadri_boxes.py | 5 ++--- mmrotate/structures/bbox/rotated_boxes.py | 5 ++--- mmrotate/testing/_utils.py | 3 +-- mmrotate/utils/misc.py | 3 +-- mmrotate/utils/patch/merge_results.py | 3 +-- mmrotate/utils/patch/split.py | 3 +-- mmrotate/utils/setup_env.py | 1 - mmrotate/visualization/local_visualizer.py | 3 +-- mmrotate/visualization/palette.py | 3 +-- projects/LSKNet/lsknet/lsknet.py | 5 ++--- projects/RR360/datasets/transforms/transforms.py | 3 +-- projects/RR360/evaluation/functional/mean_ap.py | 3 +-- projects/RR360/evaluation/metrics/dota_r360_metric.py | 9 ++++----- projects/RR360/structures/bbox/rotated_boxes.py | 5 ++--- projects/RR360/tools/browse_dataset.py | 1 - projects/RR360/tools/test.py | 3 +-- projects/RR360/tools/train.py | 3 +-- projects/RR360/visualization/local_visualizer.py | 5 ++--- setup.py | 5 +++-- tests/test_apis/test_inference.py | 5 ++--- tests/test_datasets/test_dota.py | 1 - tests/test_datasets/test_transforms/test_transforms.py | 3 +-- tests/test_evaluation/test_metrics/test_dota_metric.py | 5 ++--- .../test_metrics/test_rotated_coco_metric.py | 7 +++---- tests/test_models/test_backbones/test_re_resnet.py | 3 +-- .../test_dense_heads/test_angle_branch_retina_head.py | 3 +-- tests/test_models/test_dense_heads/test_cfa_head.py | 3 +-- tests/test_models/test_dense_heads/test_h2rbox_head.py | 3 +-- .../test_dense_heads/test_oriented_reppoints.py | 3 +-- tests/test_models/test_dense_heads/test_r3_head.py | 3 +-- .../test_dense_heads/test_rotated_atss_head.py | 3 +-- .../test_dense_heads/test_rotated_fcos_head.py | 3 +-- .../test_dense_heads/test_rotated_reppoints.py | 3 +-- .../test_dense_heads/test_rotated_retina_head.py | 3 +-- .../test_dense_heads/test_rotated_rtmdet_head.py | 3 +-- tests/test_models/test_dense_heads/test_s2a_head.py | 3 +-- .../test_dense_heads/test_sam_reppoints_head.py | 3 +-- tests/test_models/test_detectors/test_h2rbox.py | 5 ++--- .../test_detectors/test_refine_single_stage.py | 5 ++--- tests/test_models/test_detectors/test_single_stage.py | 5 ++--- tests/test_models/test_detectors/test_two_stage.py | 5 ++--- tests/test_models/test_losses/test_loss.py | 3 +-- tests/test_models/test_necks/test_re_fpn.py | 3 +-- .../test_bbox_head/test_convfc_rbbox_head.py | 5 ++--- .../test_roi_heads/test_bbox_head/test_gv_bbox_head.py | 5 ++--- .../test_models/test_roi_heads/test_gv_ratio_roi_head.py | 5 ++--- .../test_assigners/test_convex_assigner.py | 3 +-- .../test_assigners/test_max_convex_iou_assigner.py | 3 +-- .../test_assigners/test_rotated_atss_assigner.py | 3 +-- .../test_assigners/test_sas_assigner.py | 3 +-- .../test_task_modules/test_coder/test_angle_coder.py | 3 +-- .../test_coder/test_delta_midpointoffset_rbbox_coder.py | 3 +-- .../test_coder/test_delta_xywh_hbbox_coder.py | 3 +-- .../test_coder/test_delta_xywh_qbbox_coder.py | 3 +-- .../test_coder/test_delta_xywht_hbbox_coder.py | 3 +-- .../test_coder/test_delta_xywht_rbbox_coder.py | 3 +-- .../test_coder/test_gliding_vertex_coder.py | 3 +-- .../test_prior_generators/test_anchor_generator.py | 3 +-- .../test_task_modules/test_rotated_iou2d_calculator.py | 3 +-- tests/test_structures/test_bbox/test_box_converters.py | 5 ++--- tests/test_structures/test_bbox/test_quadri_boxes.py | 7 +++---- tests/test_structures/test_bbox/test_rotated_boxes.py | 7 +++---- tests/test_visualization/test_local_visualizer.py | 5 ++--- tools/analysis_tools/analyze_logs.py | 3 +-- tools/analysis_tools/benchmark.py | 1 - tools/analysis_tools/browse_dataset.py | 1 - tools/analysis_tools/confusion_matrix.py | 3 +-- tools/analysis_tools/get_flops.py | 1 - tools/data/dota/dota2coco.py | 3 +-- tools/data/dota/split/img_split.py | 5 ++--- tools/deployment/mmrotate2torchserve.py | 5 ++--- tools/deployment/mmrotate_handler.py | 3 +-- tools/misc/print_config.py | 1 - tools/model_converters/publish_model.py | 1 - tools/test.py | 1 - tools/train.py | 1 - 129 files changed, 163 insertions(+), 285 deletions(-) diff --git a/.dev_scripts/gather_models.py b/.dev_scripts/gather_models.py index 84e9a3de4..46d549d21 100644 --- a/.dev_scripts/gather_models.py +++ b/.dev_scripts/gather_models.py @@ -2,14 +2,13 @@ import argparse import glob import json +import mmcv import os.path as osp import shutil import subprocess -from collections import OrderedDict - -import mmcv import torch import yaml +from collections import OrderedDict def ordered_yaml_dump(data, stream=None, Dumper=yaml.SafeDumper, **kwds): diff --git a/.pre-commit-config-zh-cn.yaml b/.pre-commit-config-zh-cn.yaml index 9b98d009c..52bb607e8 100644 --- a/.pre-commit-config-zh-cn.yaml +++ b/.pre-commit-config-zh-cn.yaml @@ -5,7 +5,7 @@ repos: hooks: - id: flake8 - repo: https://gitee.com/openmmlab/mirrors-isort - rev: 5.10.1 + rev: 5.11.5 hooks: - id: isort - repo: https://gitee.com/openmmlab/mirrors-yapf diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a6571b5ed..823a06fb5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,8 +7,8 @@ repos: 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.11.5 hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-yapf diff --git a/demo/huge_image_demo.py b/demo/huge_image_demo.py index 26a4ab1d1..33af95949 100644 --- a/demo/huge_image_demo.py +++ b/demo/huge_image_demo.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. -from argparse import ArgumentParser - import mmcv +from argparse import ArgumentParser from mmdet.apis import init_detector from mmrotate.apis import inference_detector_by_patches diff --git a/demo/image_demo.py b/demo/image_demo.py index 3ad1f6852..50b47d9d1 100644 --- a/demo/image_demo.py +++ b/demo/image_demo.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. -from argparse import ArgumentParser - import mmcv +from argparse import ArgumentParser from mmdet.apis import inference_detector, init_detector from mmrotate.registry import VISUALIZERS diff --git a/docs/en/conf.py b/docs/en/conf.py index a74461261..e3c10672e 100644 --- a/docs/en/conf.py +++ b/docs/en/conf.py @@ -11,9 +11,8 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. # import os -import sys - import pytorch_sphinx_theme +import sys sys.path.insert(0, os.path.abspath('../..')) diff --git a/docs/zh_cn/conf.py b/docs/zh_cn/conf.py index f49e59c89..a1e6653a1 100644 --- a/docs/zh_cn/conf.py +++ b/docs/zh_cn/conf.py @@ -11,9 +11,8 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. # import os -import sys - import pytorch_sphinx_theme +import sys sys.path.insert(0, os.path.abspath('../..')) diff --git a/mmrotate/apis/inference.py b/mmrotate/apis/inference.py index 03a4db1fe..f2a542e7f 100644 --- a/mmrotate/apis/inference.py +++ b/mmrotate/apis/inference.py @@ -1,6 +1,4 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import List, Optional, Sequence, Union - import mmcv import numpy as np import torch @@ -8,6 +6,7 @@ from mmcv.transforms import Compose from mmdet.structures import DetDataSample, SampleList from torch import nn +from typing import List, Optional, Sequence, Union from mmrotate.utils import (get_multiscale_patch, get_test_pipeline_cfg, merge_results_by_nms, slide_window) diff --git a/mmrotate/datasets/dior.py b/mmrotate/datasets/dior.py index dd4afb1d2..b2fb22d46 100755 --- a/mmrotate/datasets/dior.py +++ b/mmrotate/datasets/dior.py @@ -1,12 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. -import os.path as osp -import xml.etree.ElementTree as ET -from typing import List, Optional, Union - import mmcv import numpy as np +import os.path as osp +import xml.etree.ElementTree as ET from mmengine.dataset import BaseDataset from mmengine.fileio import get, get_local_path, list_from_file +from typing import List, Optional, Union from mmrotate.registry import DATASETS diff --git a/mmrotate/datasets/dota.py b/mmrotate/datasets/dota.py index cc38b2697..bc2c7727e 100644 --- a/mmrotate/datasets/dota.py +++ b/mmrotate/datasets/dota.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. import glob import os.path as osp -from typing import List - from mmengine.dataset import BaseDataset +from typing import List from mmrotate.registry import DATASETS diff --git a/mmrotate/datasets/hrsc.py b/mmrotate/datasets/hrsc.py index 26344744a..ad42e38a3 100644 --- a/mmrotate/datasets/hrsc.py +++ b/mmrotate/datasets/hrsc.py @@ -1,13 +1,12 @@ # Copyright (c) OpenMMLab. All rights reserved. -import os.path as osp -import xml.etree.ElementTree as ET -from typing import List, Optional, Union - import mmcv import numpy as np +import os.path as osp import torch +import xml.etree.ElementTree as ET from mmengine.dataset import BaseDataset from mmengine.fileio import get, get_local_path, list_from_file +from typing import List, Optional, Union from mmrotate.registry import DATASETS from mmrotate.structures.bbox import rbox2qbox diff --git a/mmrotate/datasets/transforms/loading.py b/mmrotate/datasets/transforms/loading.py index ea8bcc067..3cce5d575 100644 --- a/mmrotate/datasets/transforms/loading.py +++ b/mmrotate/datasets/transforms/loading.py @@ -1,8 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Sequence, Union - import mmcv from mmcv.transforms import BaseTransform +from typing import Sequence, Union from mmrotate.registry import TRANSFORMS diff --git a/mmrotate/datasets/transforms/transforms.py b/mmrotate/datasets/transforms/transforms.py index 141c42569..96c685eed 100644 --- a/mmrotate/datasets/transforms/transforms.py +++ b/mmrotate/datasets/transforms/transforms.py @@ -1,7 +1,4 @@ # Copyright (c) OpenMMLab. All rights reserved. -from numbers import Number -from typing import List, Optional, Union - import cv2 import mmcv import numpy as np @@ -10,6 +7,8 @@ from mmdet.structures.bbox import BaseBoxes, get_box_type from mmdet.structures.mask import PolygonMasks from mmengine.utils import is_list_of +from numbers import Number +from typing import List, Optional, Union from mmrotate.registry import TRANSFORMS diff --git a/mmrotate/evaluation/functional/mean_ap.py b/mmrotate/evaluation/functional/mean_ap.py index e4baf1e3b..bb01709b4 100644 --- a/mmrotate/evaluation/functional/mean_ap.py +++ b/mmrotate/evaluation/functional/mean_ap.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -from multiprocessing import get_context - import numpy as np import torch from mmcv.ops import box_iou_quadri, box_iou_rotated from mmdet.evaluation.functional import average_precision from mmengine.logging import print_log +from multiprocessing import get_context from terminaltables import AsciiTable diff --git a/mmrotate/evaluation/metrics/dota_metric.py b/mmrotate/evaluation/metrics/dota_metric.py index bd4564a4d..94ef58e0f 100644 --- a/mmrotate/evaluation/metrics/dota_metric.py +++ b/mmrotate/evaluation/metrics/dota_metric.py @@ -1,19 +1,18 @@ # Copyright (c) OpenMMLab. All rights reserved. import copy +import numpy as np import os import os.path as osp import re import tempfile +import torch import zipfile from collections import OrderedDict, defaultdict -from typing import List, Optional, Sequence, Union - -import numpy as np -import torch from mmcv.ops import nms_quadri, nms_rotated from mmengine.evaluator import BaseMetric from mmengine.fileio import dump from mmengine.logging import MMLogger +from typing import List, Optional, Sequence, Union from mmrotate.evaluation import eval_rbbox_map from mmrotate.registry import METRICS diff --git a/mmrotate/evaluation/metrics/rotated_coco_metric.py b/mmrotate/evaluation/metrics/rotated_coco_metric.py index 71597d3ee..4c7801821 100644 --- a/mmrotate/evaluation/metrics/rotated_coco_metric.py +++ b/mmrotate/evaluation/metrics/rotated_coco_metric.py @@ -1,14 +1,12 @@ # Copyright (c) OpenMMLab. All rights reserved. +import cv2 import datetime import itertools +import numpy as np import os.path as osp +import pycocotools.mask as maskUtils import tempfile from collections import OrderedDict -from typing import Dict, Optional, Sequence - -import cv2 -import numpy as np -import pycocotools.mask as maskUtils from mmcv.ops import box_iou_rotated from mmdet.datasets.api_wrappers import COCO from mmdet.evaluation import CocoMetric @@ -16,6 +14,7 @@ from mmengine.fileio import dump, load from pycocotools.cocoeval import COCOeval from terminaltables import AsciiTable +from typing import Dict, Optional, Sequence from mmrotate.registry import METRICS from mmrotate.structures.bbox import RotatedBoxes diff --git a/mmrotate/models/backbones/re_resnet.py b/mmrotate/models/backbones/re_resnet.py index 9208babbf..12cf87bcb 100644 --- a/mmrotate/models/backbones/re_resnet.py +++ b/mmrotate/models/backbones/re_resnet.py @@ -1,19 +1,19 @@ # Copyright (c) OpenMMLab. All rights reserved. # Modified from csuhan: https://github.com/csuhan/ReDet -from typing import Optional, Sequence, Tuple - import torch.nn as nn import torch.utils.checkpoint as cp from mmdet.utils import ConfigType, OptConfigType, OptMultiConfig from mmengine.model import BaseModule from torch import Tensor from torch.nn.modules.batchnorm import _BatchNorm +from typing import Optional, Sequence, Tuple from mmrotate.registry import MODELS try: import e2cnn.nn as enn from e2cnn.nn import EquivariantModule + from ..utils.enn import (build_enn_divide_feature, build_enn_norm_layer, build_enn_trivial_feature, ennAvgPool, ennConv, ennMaxPool, ennReLU, ennTrivialConv) diff --git a/mmrotate/models/dense_heads/angle_branch_retina_head.py b/mmrotate/models/dense_heads/angle_branch_retina_head.py index 4d72c163e..1f39adeb6 100644 --- a/mmrotate/models/dense_heads/angle_branch_retina_head.py +++ b/mmrotate/models/dense_heads/angle_branch_retina_head.py @@ -1,7 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. import copy -from typing import List, Optional, Tuple, Union - import torch import torch.nn as nn from mmdet.models.dense_heads.retina_head import RetinaHead @@ -13,6 +11,7 @@ from mmengine.config import ConfigDict from mmengine.structures import InstanceData from torch import Tensor +from typing import List, Optional, Tuple, Union from mmrotate.registry import MODELS, TASK_UTILS diff --git a/mmrotate/models/dense_heads/cfa_head.py b/mmrotate/models/dense_heads/cfa_head.py index 69cf953c3..446a049b5 100644 --- a/mmrotate/models/dense_heads/cfa_head.py +++ b/mmrotate/models/dense_heads/cfa_head.py @@ -1,12 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Dict, List, Optional, Tuple - import numpy as np import torch from mmdet.models.utils import multi_apply from mmdet.utils import InstanceList, OptInstanceList from mmengine.structures import InstanceData from torch import Tensor +from typing import Dict, List, Optional, Tuple from mmrotate.models.dense_heads.rotated_reppoints_head import \ RotatedRepPointsHead diff --git a/mmrotate/models/dense_heads/h2rbox_head.py b/mmrotate/models/dense_heads/h2rbox_head.py index c66f6b29b..57b0bfc71 100644 --- a/mmrotate/models/dense_heads/h2rbox_head.py +++ b/mmrotate/models/dense_heads/h2rbox_head.py @@ -1,8 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. import copy import math -from typing import Dict, List, Optional, Tuple - import torch from mmcv.cnn import Scale from mmdet.models.utils import (filter_scores_and_topk, multi_apply, @@ -13,6 +11,7 @@ from mmengine import ConfigDict from mmengine.structures import InstanceData from torch import Tensor +from typing import Dict, List, Optional, Tuple from mmrotate.models.dense_heads.rotated_fcos_head import RotatedFCOSHead from mmrotate.registry import MODELS diff --git a/mmrotate/models/dense_heads/oriented_reppoints_head.py b/mmrotate/models/dense_heads/oriented_reppoints_head.py index cd5301d01..9ca8f52c3 100644 --- a/mmrotate/models/dense_heads/oriented_reppoints_head.py +++ b/mmrotate/models/dense_heads/oriented_reppoints_head.py @@ -1,7 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. import math -from typing import Dict, List, Optional, Tuple - import numpy as np import torch import torch.nn as nn @@ -11,6 +9,7 @@ from mmdet.utils import ConfigType, InstanceList, OptInstanceList from mmengine.structures import InstanceData from torch import Tensor +from typing import Dict, List, Optional, Tuple from mmrotate.models.dense_heads.rotated_reppoints_head import \ RotatedRepPointsHead diff --git a/mmrotate/models/dense_heads/oriented_rpn_head.py b/mmrotate/models/dense_heads/oriented_rpn_head.py index 136b6ea4e..1b8ded8bf 100644 --- a/mmrotate/models/dense_heads/oriented_rpn_head.py +++ b/mmrotate/models/dense_heads/oriented_rpn_head.py @@ -1,6 +1,4 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Optional - import torch from mmcv.ops import batched_nms from mmdet.models.dense_heads import RPNHead @@ -8,6 +6,7 @@ scale_boxes) from mmengine.config import ConfigDict from mmengine.structures import InstanceData +from typing import Optional from mmrotate.registry import MODELS from mmrotate.structures.bbox import rbox2hbox diff --git a/mmrotate/models/dense_heads/r3_head.py b/mmrotate/models/dense_heads/r3_head.py index 04250209f..a0e43cf79 100644 --- a/mmrotate/models/dense_heads/r3_head.py +++ b/mmrotate/models/dense_heads/r3_head.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import List, Optional, Tuple, Union - import torch from mmdet.models.utils import select_single_mlvl from mmdet.utils import InstanceList, OptInstanceList from mmengine.config import ConfigDict from torch import Tensor +from typing import List, Optional, Tuple, Union from mmrotate.registry import MODELS from mmrotate.structures.bbox import RotatedBoxes diff --git a/mmrotate/models/dense_heads/rotated_atss_head.py b/mmrotate/models/dense_heads/rotated_atss_head.py index 7f9dde8bd..7be2a2987 100644 --- a/mmrotate/models/dense_heads/rotated_atss_head.py +++ b/mmrotate/models/dense_heads/rotated_atss_head.py @@ -1,6 +1,4 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import List, Optional - import torch import torch.nn as nn from mmcv.cnn import ConvModule, Scale @@ -11,6 +9,7 @@ from mmdet.utils import InstanceList, OptInstanceList from mmengine.structures import InstanceData from torch import Tensor +from typing import List, Optional from mmrotate.registry import MODELS from mmrotate.structures.bbox import RotatedBoxes diff --git a/mmrotate/models/dense_heads/rotated_fcos_head.py b/mmrotate/models/dense_heads/rotated_fcos_head.py index b8fce7cb5..662af013a 100644 --- a/mmrotate/models/dense_heads/rotated_fcos_head.py +++ b/mmrotate/models/dense_heads/rotated_fcos_head.py @@ -1,7 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. import copy -from typing import Dict, List, Optional, Tuple - import torch import torch.nn as nn from mmcv.cnn import Scale @@ -14,6 +12,7 @@ from mmengine import ConfigDict from mmengine.structures import InstanceData from torch import Tensor +from typing import Dict, List, Optional, Tuple from mmrotate.registry import MODELS, TASK_UTILS from mmrotate.structures import RotatedBoxes diff --git a/mmrotate/models/dense_heads/rotated_reppoints_head.py b/mmrotate/models/dense_heads/rotated_reppoints_head.py index b70039219..db9f95468 100644 --- a/mmrotate/models/dense_heads/rotated_reppoints_head.py +++ b/mmrotate/models/dense_heads/rotated_reppoints_head.py @@ -1,6 +1,4 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Dict, List, Tuple - import torch from mmcv.ops import min_area_polygons from mmdet.models.dense_heads.reppoints_head import RepPointsHead @@ -9,6 +7,7 @@ from mmengine.config import ConfigDict from mmengine.structures import InstanceData from torch import Tensor +from typing import Dict, List, Tuple from mmrotate.registry import MODELS from mmrotate.structures.bbox import RotatedBoxes, qbox2rbox diff --git a/mmrotate/models/dense_heads/rotated_rtmdet_head.py b/mmrotate/models/dense_heads/rotated_rtmdet_head.py index 6ee13b941..6134094ff 100644 --- a/mmrotate/models/dense_heads/rotated_rtmdet_head.py +++ b/mmrotate/models/dense_heads/rotated_rtmdet_head.py @@ -1,7 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. import copy -from typing import List, Optional, Tuple - import torch from mmcv.cnn import ConvModule, Scale, is_norm from mmdet.models import inverse_sigmoid @@ -17,6 +15,7 @@ from mmengine.model import bias_init_with_prob, constant_init, normal_init from mmengine.structures import InstanceData from torch import Tensor, nn +from typing import List, Optional, Tuple from mmrotate.registry import MODELS, TASK_UTILS from mmrotate.structures import RotatedBoxes, distance2obb diff --git a/mmrotate/models/dense_heads/s2a_head.py b/mmrotate/models/dense_heads/s2a_head.py index 0b351ef26..955da4341 100644 --- a/mmrotate/models/dense_heads/s2a_head.py +++ b/mmrotate/models/dense_heads/s2a_head.py @@ -1,6 +1,4 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import List, Optional, Tuple, Union - import torch import torch.nn as nn from mmcv.cnn import ConvModule @@ -8,6 +6,7 @@ from mmdet.utils import InstanceList, OptInstanceList from mmengine.config import ConfigDict from torch import Tensor +from typing import List, Optional, Tuple, Union from mmrotate.registry import MODELS from mmrotate.structures.bbox import RotatedBoxes diff --git a/mmrotate/models/dense_heads/sam_reppoints_head.py b/mmrotate/models/dense_heads/sam_reppoints_head.py index da58113a2..15e6f899b 100644 --- a/mmrotate/models/dense_heads/sam_reppoints_head.py +++ b/mmrotate/models/dense_heads/sam_reppoints_head.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Dict, List, Tuple - import torch from mmdet.models.utils import images_to_levels, multi_apply, unmap from mmdet.utils import InstanceList, OptInstanceList from mmengine.structures import InstanceData from torch import Tensor +from typing import Dict, List, Tuple from mmrotate.models.dense_heads.rotated_reppoints_head import \ RotatedRepPointsHead diff --git a/mmrotate/models/detectors/h2rbox.py b/mmrotate/models/detectors/h2rbox.py index 4362c5be2..0a922e97f 100644 --- a/mmrotate/models/detectors/h2rbox.py +++ b/mmrotate/models/detectors/h2rbox.py @@ -1,7 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. import math -from typing import Tuple, Union - import torch from mmdet.models.detectors.single_stage import SingleStageDetector from mmdet.models.utils import unpack_gt_instances @@ -10,6 +8,7 @@ from mmdet.utils import ConfigType, InstanceList, OptConfigType, OptMultiConfig from torch import Tensor from torch.nn.functional import grid_sample +from typing import Tuple, Union from mmrotate.registry import MODELS from mmrotate.structures.bbox import RotatedBoxes diff --git a/mmrotate/models/detectors/refine_single_stage.py b/mmrotate/models/detectors/refine_single_stage.py index 636b6eabd..68a7d30ab 100644 --- a/mmrotate/models/detectors/refine_single_stage.py +++ b/mmrotate/models/detectors/refine_single_stage.py @@ -1,12 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import List, Sequence, Tuple, Union - from mmdet.models.detectors.base import BaseDetector from mmdet.models.utils import unpack_gt_instances from mmdet.structures import OptSampleList, SampleList from mmdet.utils import ConfigType, OptConfigType, OptMultiConfig from mmengine.model import ModuleList from torch import Tensor +from typing import List, Sequence, Tuple, Union from mmrotate.registry import MODELS diff --git a/mmrotate/models/layers/align.py b/mmrotate/models/layers/align.py index 0a0e7ed36..848e73d22 100644 --- a/mmrotate/models/layers/align.py +++ b/mmrotate/models/layers/align.py @@ -1,10 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import List - import torch from mmcv.ops import DeformConv2d, DeformConv2dPack, rotated_feature_align from mmengine.model import BaseModule, normal_init from torch import Tensor, nn +from typing import List from mmrotate.registry import MODELS diff --git a/mmrotate/models/losses/gaussian_dist_loss.py b/mmrotate/models/losses/gaussian_dist_loss.py index 91889bb05..5730a27ea 100644 --- a/mmrotate/models/losses/gaussian_dist_loss.py +++ b/mmrotate/models/losses/gaussian_dist_loss.py @@ -1,7 +1,6 @@ # Copyright (c) SJTU. All rights reserved. -from copy import deepcopy - import torch +from copy import deepcopy from mmdet.models.losses.utils import weighted_loss from torch import nn diff --git a/mmrotate/models/losses/gaussian_dist_loss_v1.py b/mmrotate/models/losses/gaussian_dist_loss_v1.py index 4a9f10601..e3719c6f8 100644 --- a/mmrotate/models/losses/gaussian_dist_loss_v1.py +++ b/mmrotate/models/losses/gaussian_dist_loss_v1.py @@ -1,7 +1,6 @@ # Copyright (c) SJTU. All rights reserved. -from copy import deepcopy - import torch +from copy import deepcopy from torch import nn from mmrotate.registry import MODELS diff --git a/mmrotate/models/losses/h2rbox_consistency_loss.py b/mmrotate/models/losses/h2rbox_consistency_loss.py index cad51c984..209c338cb 100644 --- a/mmrotate/models/losses/h2rbox_consistency_loss.py +++ b/mmrotate/models/losses/h2rbox_consistency_loss.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Optional - import torch from mmdet.utils import ConfigType from torch import Tensor +from typing import Optional from mmrotate.registry import MODELS diff --git a/mmrotate/models/losses/rotated_iou_loss.py b/mmrotate/models/losses/rotated_iou_loss.py index 198b87116..07e8122fd 100644 --- a/mmrotate/models/losses/rotated_iou_loss.py +++ b/mmrotate/models/losses/rotated_iou_loss.py @@ -1,8 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. -import warnings - import torch import torch.nn as nn +import warnings from mmdet.models.losses.utils import weighted_loss from mmrotate.registry import MODELS diff --git a/mmrotate/models/necks/re_fpn.py b/mmrotate/models/necks/re_fpn.py index d72e84e8b..2ab2f6570 100644 --- a/mmrotate/models/necks/re_fpn.py +++ b/mmrotate/models/necks/re_fpn.py @@ -1,18 +1,18 @@ # Copyright (c) OpenMMLab. All rights reserved. # Modified from csuhan: https://github.com/csuhan/ReDet -import warnings -from typing import List, Optional, Sequence, Tuple, Union - import torch.nn as nn +import warnings from mmdet.utils import MultiConfig, OptConfigType from mmengine.model import BaseModule from torch import Tensor +from typing import List, Optional, Sequence, Tuple, Union from mmrotate.registry import MODELS try: import e2cnn.nn as enn # noqa: F401 from e2cnn.nn import EquivariantModule + from ..utils.enn import (build_enn_feature, build_enn_norm_layer, ennConv, ennInterpolate, ennMaxPool, ennReLU) except ImportError: diff --git a/mmrotate/models/roi_heads/bbox_heads/convfc_rbbox_head.py b/mmrotate/models/roi_heads/bbox_heads/convfc_rbbox_head.py index 7d733dd7e..716c1752b 100644 --- a/mmrotate/models/roi_heads/bbox_heads/convfc_rbbox_head.py +++ b/mmrotate/models/roi_heads/bbox_heads/convfc_rbbox_head.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Optional - import torch from mmdet.models.losses import accuracy from mmdet.models.roi_heads.bbox_heads import Shared2FCBBoxHead from mmdet.structures.bbox import get_box_tensor from torch import Tensor +from typing import Optional from mmrotate.registry import MODELS diff --git a/mmrotate/models/roi_heads/bbox_heads/gv_bbox_head.py b/mmrotate/models/roi_heads/bbox_heads/gv_bbox_head.py index d10823648..b6939089c 100644 --- a/mmrotate/models/roi_heads/bbox_heads/gv_bbox_head.py +++ b/mmrotate/models/roi_heads/bbox_heads/gv_bbox_head.py @@ -1,6 +1,4 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import List, Optional, Tuple - import torch import torch.nn as nn import torch.nn.functional as F @@ -15,6 +13,7 @@ from mmengine.structures import InstanceData from torch import Tensor from torch.nn.modules.utils import _pair +from typing import List, Optional, Tuple from mmrotate.registry import MODELS, TASK_UTILS from mmrotate.structures.bbox import QuadriBoxes, hbox2qbox diff --git a/mmrotate/models/roi_heads/gv_ratio_roi_head.py b/mmrotate/models/roi_heads/gv_ratio_roi_head.py index 15c497985..c9e3eaeb9 100644 --- a/mmrotate/models/roi_heads/gv_ratio_roi_head.py +++ b/mmrotate/models/roi_heads/gv_ratio_roi_head.py @@ -1,6 +1,4 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import List, Tuple - import torch from mmdet.models.roi_heads.standard_roi_head import StandardRoIHead from mmdet.models.task_modules.samplers import SamplingResult @@ -8,6 +6,7 @@ from mmdet.structures.bbox import bbox2roi from mmdet.utils import ConfigType, InstanceList from torch import Tensor +from typing import List, Tuple from mmrotate.registry import MODELS diff --git a/mmrotate/models/task_modules/assigners/convex_assigner.py b/mmrotate/models/task_modules/assigners/convex_assigner.py index e806d7ec6..d8447a192 100644 --- a/mmrotate/models/task_modules/assigners/convex_assigner.py +++ b/mmrotate/models/task_modules/assigners/convex_assigner.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Optional - import torch from mmdet.models.task_modules.assigners.assign_result import AssignResult from mmdet.models.task_modules.assigners.base_assigner import BaseAssigner from mmengine.structures import InstanceData from torch import Tensor +from typing import Optional from mmrotate.registry import TASK_UTILS diff --git a/mmrotate/models/task_modules/assigners/max_convex_iou_assigner.py b/mmrotate/models/task_modules/assigners/max_convex_iou_assigner.py index 04e31a021..865747e85 100644 --- a/mmrotate/models/task_modules/assigners/max_convex_iou_assigner.py +++ b/mmrotate/models/task_modules/assigners/max_convex_iou_assigner.py @@ -1,12 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Optional, Union - import torch from mmcv.ops import convex_iou from mmdet.models.task_modules.assigners.assign_result import AssignResult from mmdet.models.task_modules.assigners.base_assigner import BaseAssigner from mmengine.structures import InstanceData from torch import Tensor +from typing import Optional, Union from mmrotate.registry import TASK_UTILS diff --git a/mmrotate/models/task_modules/assigners/rotated_atss_assigner.py b/mmrotate/models/task_modules/assigners/rotated_atss_assigner.py index 097bd70e9..3b1b90a21 100644 --- a/mmrotate/models/task_modules/assigners/rotated_atss_assigner.py +++ b/mmrotate/models/task_modules/assigners/rotated_atss_assigner.py @@ -1,13 +1,12 @@ # Copyright (c) OpenMMLab. All rights reserved. -import warnings -from typing import List, Optional - import torch +import warnings from mmdet.models.task_modules.assigners.assign_result import AssignResult from mmdet.models.task_modules.assigners.base_assigner import BaseAssigner from mmdet.utils import ConfigType from mmengine.structures import InstanceData from torch import Tensor +from typing import List, Optional from mmrotate.registry import TASK_UTILS diff --git a/mmrotate/models/task_modules/assigners/sas_assigner.py b/mmrotate/models/task_modules/assigners/sas_assigner.py index ecf771544..7a0043efe 100644 --- a/mmrotate/models/task_modules/assigners/sas_assigner.py +++ b/mmrotate/models/task_modules/assigners/sas_assigner.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import List, Optional - import torch from mmcv.ops import convex_iou, points_in_polygons from mmdet.models.task_modules.assigners.assign_result import AssignResult from mmdet.models.task_modules.assigners.base_assigner import BaseAssigner from mmengine.structures import InstanceData +from typing import List, Optional from mmrotate.registry import TASK_UTILS from mmrotate.structures.bbox import qbox2hbox diff --git a/mmrotate/models/task_modules/coders/angle_coder.py b/mmrotate/models/task_modules/coders/angle_coder.py index 4ac9f3b40..a14567ed1 100644 --- a/mmrotate/models/task_modules/coders/angle_coder.py +++ b/mmrotate/models/task_modules/coders/angle_coder.py @@ -1,6 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. import math - import torch from mmdet.models.task_modules.coders.base_bbox_coder import BaseBBoxCoder from torch import Tensor diff --git a/mmrotate/models/task_modules/coders/delta_midpointoffset_rbbox_coder.py b/mmrotate/models/task_modules/coders/delta_midpointoffset_rbbox_coder.py index e522f56af..d0cd1d1bf 100644 --- a/mmrotate/models/task_modules/coders/delta_midpointoffset_rbbox_coder.py +++ b/mmrotate/models/task_modules/coders/delta_midpointoffset_rbbox_coder.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Optional, Sequence, Union - import numpy as np import torch from mmdet.models.task_modules.coders.base_bbox_coder import BaseBBoxCoder from mmdet.structures.bbox import HorizontalBoxes, get_box_tensor from torch import Tensor +from typing import Optional, Sequence, Union from mmrotate.registry import TASK_UTILS from mmrotate.structures.bbox import (RotatedBoxes, qbox2rbox, rbox2hbox, diff --git a/mmrotate/models/task_modules/coders/delta_xywh_hbbox_coder.py b/mmrotate/models/task_modules/coders/delta_xywh_hbbox_coder.py index d6203964a..3fdd08e49 100644 --- a/mmrotate/models/task_modules/coders/delta_xywh_hbbox_coder.py +++ b/mmrotate/models/task_modules/coders/delta_xywh_hbbox_coder.py @@ -1,10 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Union - from mmdet.models.task_modules.coders import DeltaXYWHBBoxCoder from mmdet.models.task_modules.coders.delta_xywh_bbox_coder import bbox2delta from mmdet.structures.bbox import HorizontalBoxes, get_box_tensor from torch import Tensor +from typing import Union from mmrotate.registry import TASK_UTILS from mmrotate.structures.bbox import RotatedBoxes diff --git a/mmrotate/models/task_modules/coders/delta_xywh_qbbox_coder.py b/mmrotate/models/task_modules/coders/delta_xywh_qbbox_coder.py index d617e5138..cdae97f0d 100644 --- a/mmrotate/models/task_modules/coders/delta_xywh_qbbox_coder.py +++ b/mmrotate/models/task_modules/coders/delta_xywh_qbbox_coder.py @@ -1,10 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Union - from mmdet.models.task_modules.coders import DeltaXYWHBBoxCoder from mmdet.models.task_modules.coders.delta_xywh_bbox_coder import bbox2delta from mmdet.structures.bbox import HorizontalBoxes, get_box_tensor from torch import Tensor +from typing import Union from mmrotate.registry import TASK_UTILS from mmrotate.structures.bbox import QuadriBoxes diff --git a/mmrotate/models/task_modules/coders/delta_xywht_hbbox_coder.py b/mmrotate/models/task_modules/coders/delta_xywht_hbbox_coder.py index 95f8b8a40..236768dbc 100644 --- a/mmrotate/models/task_modules/coders/delta_xywht_hbbox_coder.py +++ b/mmrotate/models/task_modules/coders/delta_xywht_hbbox_coder.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Optional, Sequence, Union - import numpy as np import torch from mmdet.models.task_modules.coders.base_bbox_coder import BaseBBoxCoder from mmdet.structures.bbox import HorizontalBoxes, get_box_tensor from torch import Tensor +from typing import Optional, Sequence, Union from mmrotate.registry import TASK_UTILS from mmrotate.structures.bbox import RotatedBoxes diff --git a/mmrotate/models/task_modules/coders/delta_xywht_rbbox_coder.py b/mmrotate/models/task_modules/coders/delta_xywht_rbbox_coder.py index 8ee059882..bb2a363ba 100644 --- a/mmrotate/models/task_modules/coders/delta_xywht_rbbox_coder.py +++ b/mmrotate/models/task_modules/coders/delta_xywht_rbbox_coder.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Optional, Sequence, Union - import numpy as np import torch from mmdet.models.task_modules.coders.base_bbox_coder import BaseBBoxCoder from mmdet.structures.bbox import get_box_tensor from torch import Tensor +from typing import Optional, Sequence, Union from mmrotate.registry import TASK_UTILS from mmrotate.structures.bbox import RotatedBoxes diff --git a/mmrotate/models/task_modules/coders/gliding_vertex_coder.py b/mmrotate/models/task_modules/coders/gliding_vertex_coder.py index 026e7f1a9..4af459f63 100644 --- a/mmrotate/models/task_modules/coders/gliding_vertex_coder.py +++ b/mmrotate/models/task_modules/coders/gliding_vertex_coder.py @@ -1,10 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Union - import torch from mmdet.models.task_modules.coders.base_bbox_coder import BaseBBoxCoder from mmdet.structures.bbox import HorizontalBoxes, get_box_tensor from torch import Tensor +from typing import Union from mmrotate.registry import TASK_UTILS from mmrotate.structures.bbox import QuadriBoxes diff --git a/mmrotate/models/task_modules/prior_generators/anchor_generator.py b/mmrotate/models/task_modules/prior_generators/anchor_generator.py index 79d196aef..448be7772 100644 --- a/mmrotate/models/task_modules/prior_generators/anchor_generator.py +++ b/mmrotate/models/task_modules/prior_generators/anchor_generator.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import List, Tuple - import torch from mmdet.models.task_modules import AnchorGenerator from mmdet.structures.bbox import HorizontalBoxes from torch import Tensor from torch.nn.modules.utils import _pair +from typing import List, Tuple from mmrotate.registry import TASK_UTILS from mmrotate.structures.bbox import RotatedBoxes diff --git a/mmrotate/models/utils/orconv.py b/mmrotate/models/utils/orconv.py index 1b5bc17b9..cca932de2 100644 --- a/mmrotate/models/utils/orconv.py +++ b/mmrotate/models/utils/orconv.py @@ -1,7 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. from __future__ import absolute_import -import math +import math import torch import torch.nn.functional as F from mmcv.ops import active_rotated_filter diff --git a/mmrotate/structures/bbox/quadri_boxes.py b/mmrotate/structures/bbox/quadri_boxes.py index d78880b69..42848d33f 100644 --- a/mmrotate/structures/bbox/quadri_boxes.py +++ b/mmrotate/structures/bbox/quadri_boxes.py @@ -1,13 +1,12 @@ # Copyright (c) OpenMMLab. All rights reserved. -import warnings -from typing import Tuple, TypeVar, Union - import cv2 import numpy as np import torch +import warnings from mmdet.structures.bbox import BaseBoxes, register_box from mmdet.structures.mask import BitmapMasks, PolygonMasks from torch import BoolTensor, Tensor +from typing import Tuple, TypeVar, Union T = TypeVar('T') DeviceType = Union[str, torch.device] diff --git a/mmrotate/structures/bbox/rotated_boxes.py b/mmrotate/structures/bbox/rotated_boxes.py index 8280684f1..e356580cc 100644 --- a/mmrotate/structures/bbox/rotated_boxes.py +++ b/mmrotate/structures/bbox/rotated_boxes.py @@ -1,13 +1,12 @@ # Copyright (c) OpenMMLab. All rights reserved. -import warnings -from typing import Optional, Tuple, TypeVar, Union - import cv2 import numpy as np import torch +import warnings from mmdet.structures.bbox import BaseBoxes, register_box from mmdet.structures.mask import BitmapMasks, PolygonMasks from torch import BoolTensor, Tensor +from typing import Optional, Tuple, TypeVar, Union T = TypeVar('T') DeviceType = Union[str, torch.device] diff --git a/mmrotate/testing/_utils.py b/mmrotate/testing/_utils.py index 7801d9b81..e203b1c78 100644 --- a/mmrotate/testing/_utils.py +++ b/mmrotate/testing/_utils.py @@ -1,13 +1,12 @@ # Copyright (c) OpenMMLab. All rights reserved. import copy -from os.path import dirname, exists, join - import numpy as np import torch from mmdet.structures import DetDataSample from mmdet.structures.bbox import HorizontalBoxes from mmengine.dataset import pseudo_collate from mmengine.structures import InstanceData, PixelData +from os.path import dirname, exists, join from mmrotate.structures.bbox import RotatedBoxes, rbox2qbox diff --git a/mmrotate/utils/misc.py b/mmrotate/utils/misc.py index de0bcf0cf..be01472aa 100644 --- a/mmrotate/utils/misc.py +++ b/mmrotate/utils/misc.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Union - from mmengine.config import Config, ConfigDict +from typing import Union def get_test_pipeline_cfg(cfg: Union[str, ConfigDict]) -> ConfigDict: diff --git a/mmrotate/utils/patch/merge_results.py b/mmrotate/utils/patch/merge_results.py index 842aef881..2aaf3dd1d 100644 --- a/mmrotate/utils/patch/merge_results.py +++ b/mmrotate/utils/patch/merge_results.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Sequence, Tuple - import numpy as np from mmcv.ops import batched_nms from mmdet.structures import DetDataSample, SampleList from mmengine.structures import InstanceData from torch import Tensor +from typing import Sequence, Tuple def translate_bboxes(bboxes: Tensor, offset: Sequence[int]): diff --git a/mmrotate/utils/patch/split.py b/mmrotate/utils/patch/split.py index 41b3d6457..ff39cca64 100644 --- a/mmrotate/utils/patch/split.py +++ b/mmrotate/utils/patch/split.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. +import numpy as np from itertools import product from math import ceil -import numpy as np - def get_multiscale_patch(sizes, steps, ratios): """Get multiscale patch sizes and steps. diff --git a/mmrotate/utils/setup_env.py b/mmrotate/utils/setup_env.py index 75ddb5307..0b0d92f4e 100644 --- a/mmrotate/utils/setup_env.py +++ b/mmrotate/utils/setup_env.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. import datetime import warnings - from mmengine import DefaultScope diff --git a/mmrotate/visualization/local_visualizer.py b/mmrotate/visualization/local_visualizer.py index adc5ec1e7..428bdb6cf 100644 --- a/mmrotate/visualization/local_visualizer.py +++ b/mmrotate/visualization/local_visualizer.py @@ -1,6 +1,4 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import List, Optional - import numpy as np import torch from mmdet.structures.mask import BitmapMasks, PolygonMasks, bitmap_to_polygon @@ -8,6 +6,7 @@ from mmdet.visualization.palette import _get_adaptive_scales from mmengine.structures import InstanceData from torch import Tensor +from typing import List, Optional from mmrotate.registry import VISUALIZERS from mmrotate.structures.bbox import QuadriBoxes, RotatedBoxes diff --git a/mmrotate/visualization/palette.py b/mmrotate/visualization/palette.py index 59e5aa864..c97b33408 100644 --- a/mmrotate/visualization/palette.py +++ b/mmrotate/visualization/palette.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import List, Tuple, Union - import mmcv import numpy as np from mmengine.utils import is_str +from typing import List, Tuple, Union def get_palette(palette: Union[List[tuple], str, tuple], diff --git a/projects/LSKNet/lsknet/lsknet.py b/projects/LSKNet/lsknet/lsknet.py index 655b98b28..590b1cd42 100644 --- a/projects/LSKNet/lsknet/lsknet.py +++ b/projects/LSKNet/lsknet/lsknet.py @@ -1,9 +1,8 @@ import math -import warnings -from functools import partial - import torch import torch.nn as nn +import warnings +from functools import partial from mmcv.cnn import build_norm_layer from mmcv.cnn.bricks import DropPath from mmcv.cnn.utils.weight_init import (constant_init, normal_init, diff --git a/projects/RR360/datasets/transforms/transforms.py b/projects/RR360/datasets/transforms/transforms.py index f2f9e1b8e..0e77916db 100644 --- a/projects/RR360/datasets/transforms/transforms.py +++ b/projects/RR360/datasets/transforms/transforms.py @@ -1,8 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Union - # import cv2 import mmcv +from typing import Union from mmrotate.datasets.transforms import Rotate from mmrotate.registry import TRANSFORMS diff --git a/projects/RR360/evaluation/functional/mean_ap.py b/projects/RR360/evaluation/functional/mean_ap.py index c66f4c0d3..03e743eaa 100644 --- a/projects/RR360/evaluation/functional/mean_ap.py +++ b/projects/RR360/evaluation/functional/mean_ap.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -from multiprocessing import get_context - import numpy as np import torch from mmcv.ops import box_iou_quadri, box_iou_rotated from mmdet.evaluation.functional import average_precision from mmengine.logging import print_log +from multiprocessing import get_context from terminaltables import AsciiTable diff --git a/projects/RR360/evaluation/metrics/dota_r360_metric.py b/projects/RR360/evaluation/metrics/dota_r360_metric.py index 71c5a674a..b1eab6d72 100644 --- a/projects/RR360/evaluation/metrics/dota_r360_metric.py +++ b/projects/RR360/evaluation/metrics/dota_r360_metric.py @@ -1,23 +1,22 @@ # Copyright (c) OpenMMLab. All rights reserved. import copy +import numpy as np import os import os.path as osp import re import tempfile +import torch import zipfile from collections import OrderedDict, defaultdict -from typing import List, Optional, Sequence, Union - -import numpy as np -import torch from mmcv.ops import nms_quadri, nms_rotated from mmengine.evaluator import BaseMetric from mmengine.fileio import dump from mmengine.logging import MMLogger -from projects.RR360.evaluation import eval_rbbox_head_map +from typing import List, Optional, Sequence, Union from mmrotate.registry import METRICS from mmrotate.structures.bbox import rbox2qbox +from projects.RR360.evaluation import eval_rbbox_head_map @METRICS.register_module() diff --git a/projects/RR360/structures/bbox/rotated_boxes.py b/projects/RR360/structures/bbox/rotated_boxes.py index a3d943fac..97108c1a0 100644 --- a/projects/RR360/structures/bbox/rotated_boxes.py +++ b/projects/RR360/structures/bbox/rotated_boxes.py @@ -1,13 +1,12 @@ """copy from /mmrotate/structures/bbox/rotated_boxes.py and redefine 'r360'.""" -import math -from typing import Optional, Tuple, TypeVar, Union - import cv2 +import math import numpy as np import torch from mmdet.structures.bbox import register_box, register_box_converter from mmdet.structures.mask import BitmapMasks, PolygonMasks from torch import Tensor +from typing import Optional, Tuple, TypeVar, Union from mmrotate.structures.bbox import QuadriBoxes from mmrotate.structures.bbox import RotatedBoxes as mmrotate_RotatedBoxes diff --git a/projects/RR360/tools/browse_dataset.py b/projects/RR360/tools/browse_dataset.py index cc283759c..d45a30e74 100644 --- a/projects/RR360/tools/browse_dataset.py +++ b/projects/RR360/tools/browse_dataset.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. import argparse import os.path as osp - from mmdet.models.utils import mask2ndarray from mmdet.registry import DATASETS, VISUALIZERS from mmdet.structures.bbox import BaseBoxes diff --git a/projects/RR360/tools/test.py b/projects/RR360/tools/test.py index 3974a2f2d..d78469f8b 100644 --- a/projects/RR360/tools/test.py +++ b/projects/RR360/tools/test.py @@ -2,16 +2,15 @@ import argparse import os import os.path as osp - from mmdet.utils import register_all_modules as register_all_modules_mmdet from mmengine.config import Config, DictAction from mmengine.evaluator import DumpResults from mmengine.registry import RUNNERS from mmengine.runner import Runner -from projects.RR360.structures.bbox import RotatedBoxes import mmrotate.structures from mmrotate.utils import register_all_modules +from projects.RR360.structures.bbox import RotatedBoxes # TODO : Refactoring with registry build mmrotate.structures.bbox.RotatedBoxes = RotatedBoxes diff --git a/projects/RR360/tools/train.py b/projects/RR360/tools/train.py index cdbdc2304..fd96b5be1 100644 --- a/projects/RR360/tools/train.py +++ b/projects/RR360/tools/train.py @@ -3,16 +3,15 @@ import logging import os import os.path as osp - from mmdet.utils import register_all_modules as register_all_modules_mmdet from mmengine.config import Config, DictAction from mmengine.logging import print_log from mmengine.registry import RUNNERS from mmengine.runner import Runner -from projects.RR360.structures.bbox import RotatedBoxes import mmrotate.structures from mmrotate.utils import register_all_modules +from projects.RR360.structures.bbox import RotatedBoxes # TODO : Refactoring with registry build mmrotate.structures.bbox.RotatedBoxes = RotatedBoxes diff --git a/projects/RR360/visualization/local_visualizer.py b/projects/RR360/visualization/local_visualizer.py index 366393ef5..9f02099ad 100644 --- a/projects/RR360/visualization/local_visualizer.py +++ b/projects/RR360/visualization/local_visualizer.py @@ -1,19 +1,18 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import List, Optional - import numpy as np import torch from mmdet.structures.mask import BitmapMasks, PolygonMasks, bitmap_to_polygon from mmdet.visualization import DetLocalVisualizer, jitter_color from mmdet.visualization.palette import _get_adaptive_scales from mmengine.structures import InstanceData -from projects.RR360.structures.bbox import RotatedBoxes from torch import Tensor +from typing import List, Optional from mmrotate.registry import VISUALIZERS # from mmrotate.structures.bbox import QuadriBoxes, RotatedBoxes from mmrotate.structures.bbox import QuadriBoxes from mmrotate.visualization.palette import get_palette +from projects.RR360.structures.bbox import RotatedBoxes @VISUALIZERS.register_module() diff --git a/setup.py b/setup.py index 5421d0d39..9c544cc3a 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,10 @@ +from setuptools import find_packages, setup + import os import os.path as osp import shutil import sys import warnings -from setuptools import find_packages, setup def readme(): @@ -35,9 +36,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_apis/test_inference.py b/tests/test_apis/test_inference.py index 4f63588f7..c2f875fc5 100644 --- a/tests/test_apis/test_inference.py +++ b/tests/test_apis/test_inference.py @@ -1,13 +1,12 @@ # Copyright (c) OpenMMLab. All rights reserved. -import os.path as osp -from unittest import TestCase - import numpy as np +import os.path as osp import pytest import torch from mmdet.apis import init_detector from mmdet.structures import DetDataSample from parameterized import parameterized +from unittest import TestCase from mmrotate.apis import inference_detector_by_patches from mmrotate.utils import register_all_modules diff --git a/tests/test_datasets/test_dota.py b/tests/test_datasets/test_dota.py index 54308efd4..fb3456104 100644 --- a/tests/test_datasets/test_dota.py +++ b/tests/test_datasets/test_dota.py @@ -1,6 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. import unittest - from parameterized import parameterized from mmrotate.datasets import DOTADataset, DOTAv2Dataset, DOTAv15Dataset diff --git a/tests/test_datasets/test_transforms/test_transforms.py b/tests/test_datasets/test_transforms/test_transforms.py index cce1cd7d2..4a19c649d 100644 --- a/tests/test_datasets/test_transforms/test_transforms.py +++ b/tests/test_datasets/test_transforms/test_transforms.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. import copy -import unittest - import numpy as np import torch +import unittest from mmdet.structures.bbox import BaseBoxes from mmdet.structures.mask import BitmapMasks, PolygonMasks from mmengine.testing import assert_allclose diff --git a/tests/test_evaluation/test_metrics/test_dota_metric.py b/tests/test_evaluation/test_metrics/test_dota_metric.py index 87ef050e1..861575dd4 100644 --- a/tests/test_evaluation/test_metrics/test_dota_metric.py +++ b/tests/test_evaluation/test_metrics/test_dota_metric.py @@ -1,10 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. +import numpy as np import os.path as osp import tempfile -import unittest - -import numpy as np import torch +import unittest from mmrotate.evaluation import DOTAMetric diff --git a/tests/test_evaluation/test_metrics/test_rotated_coco_metric.py b/tests/test_evaluation/test_metrics/test_rotated_coco_metric.py index eac8977c5..1e53acad6 100644 --- a/tests/test_evaluation/test_metrics/test_rotated_coco_metric.py +++ b/tests/test_evaluation/test_metrics/test_rotated_coco_metric.py @@ -1,12 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. -import os.path as osp -import tempfile -from unittest import TestCase - import numpy as np +import os.path as osp import pycocotools.mask as mask_util +import tempfile import torch from mmengine.fileio import dump +from unittest import TestCase from mmrotate.evaluation import RotatedCocoMetric diff --git a/tests/test_models/test_backbones/test_re_resnet.py b/tests/test_models/test_backbones/test_re_resnet.py index e2948afd2..4d3eda015 100644 --- a/tests/test_models/test_backbones/test_re_resnet.py +++ b/tests/test_models/test_backbones/test_re_resnet.py @@ -1,10 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import e2cnn.nn as enn import torch from torch.nn.modules import GroupNorm from torch.nn.modules.batchnorm import _BatchNorm +from unittest import TestCase from mmrotate.models.backbones.re_resnet import (BasicBlock, Bottleneck, ReResNet, ResLayer) diff --git a/tests/test_models/test_dense_heads/test_angle_branch_retina_head.py b/tests/test_models/test_dense_heads/test_angle_branch_retina_head.py index 80787494e..74a74ed13 100644 --- a/tests/test_models/test_dense_heads/test_angle_branch_retina_head.py +++ b/tests/test_models/test_dense_heads/test_angle_branch_retina_head.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import torch from mmengine import Config from mmengine.structures import InstanceData +from unittest import TestCase from mmrotate.models.dense_heads import AngleBranchRetinaHead from mmrotate.structures.bbox import RotatedBoxes diff --git a/tests/test_models/test_dense_heads/test_cfa_head.py b/tests/test_models/test_dense_heads/test_cfa_head.py index a491e9a45..51d0f1b3e 100644 --- a/tests/test_models/test_dense_heads/test_cfa_head.py +++ b/tests/test_models/test_dense_heads/test_cfa_head.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest - import torch +import unittest from mmdet.structures import DetDataSample from mmengine.config import ConfigDict from mmengine.structures import InstanceData diff --git a/tests/test_models/test_dense_heads/test_h2rbox_head.py b/tests/test_models/test_dense_heads/test_h2rbox_head.py index 41f9fb027..e4ae3461c 100644 --- a/tests/test_models/test_dense_heads/test_h2rbox_head.py +++ b/tests/test_models/test_dense_heads/test_h2rbox_head.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. import math -import unittest - import pytest import torch +import unittest from mmengine.structures import InstanceData from mmrotate.models.dense_heads import H2RBoxHead diff --git a/tests/test_models/test_dense_heads/test_oriented_reppoints.py b/tests/test_models/test_dense_heads/test_oriented_reppoints.py index 2a5e18227..ba0511c3a 100644 --- a/tests/test_models/test_dense_heads/test_oriented_reppoints.py +++ b/tests/test_models/test_dense_heads/test_oriented_reppoints.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest - import torch +import unittest from mmdet.structures import DetDataSample from mmengine.config import ConfigDict from mmengine.structures import InstanceData diff --git a/tests/test_models/test_dense_heads/test_r3_head.py b/tests/test_models/test_dense_heads/test_r3_head.py index 8b417f0bf..dd8f2c61a 100644 --- a/tests/test_models/test_dense_heads/test_r3_head.py +++ b/tests/test_models/test_dense_heads/test_r3_head.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import torch from mmengine import Config from mmengine.structures import InstanceData +from unittest import TestCase from mmrotate.models.dense_heads import R3Head, R3RefineHead from mmrotate.structures.bbox import RotatedBoxes diff --git a/tests/test_models/test_dense_heads/test_rotated_atss_head.py b/tests/test_models/test_dense_heads/test_rotated_atss_head.py index ac0690adb..c956e8852 100644 --- a/tests/test_models/test_dense_heads/test_rotated_atss_head.py +++ b/tests/test_models/test_dense_heads/test_rotated_atss_head.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest - import torch +import unittest from mmengine import Config from mmengine.structures import InstanceData diff --git a/tests/test_models/test_dense_heads/test_rotated_fcos_head.py b/tests/test_models/test_dense_heads/test_rotated_fcos_head.py index eb8caa52b..5f0e4f237 100644 --- a/tests/test_models/test_dense_heads/test_rotated_fcos_head.py +++ b/tests/test_models/test_dense_heads/test_rotated_fcos_head.py @@ -1,8 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest - import pytest import torch +import unittest from mmdet.models import L1Loss from mmengine.structures import InstanceData diff --git a/tests/test_models/test_dense_heads/test_rotated_reppoints.py b/tests/test_models/test_dense_heads/test_rotated_reppoints.py index 5fe476341..bc63f7ca1 100644 --- a/tests/test_models/test_dense_heads/test_rotated_reppoints.py +++ b/tests/test_models/test_dense_heads/test_rotated_reppoints.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest - import torch +import unittest from mmdet.structures import DetDataSample from mmengine.config import ConfigDict from mmengine.structures import InstanceData diff --git a/tests/test_models/test_dense_heads/test_rotated_retina_head.py b/tests/test_models/test_dense_heads/test_rotated_retina_head.py index bcfaaa60e..06ba79459 100644 --- a/tests/test_models/test_dense_heads/test_rotated_retina_head.py +++ b/tests/test_models/test_dense_heads/test_rotated_retina_head.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import torch from mmengine import Config from mmengine.structures import InstanceData +from unittest import TestCase from mmrotate.models.dense_heads import RotatedRetinaHead from mmrotate.structures.bbox import RotatedBoxes diff --git a/tests/test_models/test_dense_heads/test_rotated_rtmdet_head.py b/tests/test_models/test_dense_heads/test_rotated_rtmdet_head.py index 76a69270c..35604f884 100644 --- a/tests/test_models/test_dense_heads/test_rotated_rtmdet_head.py +++ b/tests/test_models/test_dense_heads/test_rotated_rtmdet_head.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest - import torch +import unittest from mmdet.models import L1Loss from mmengine.structures import InstanceData from parameterized import parameterized diff --git a/tests/test_models/test_dense_heads/test_s2a_head.py b/tests/test_models/test_dense_heads/test_s2a_head.py index c3e2cb3a7..b90a376dd 100644 --- a/tests/test_models/test_dense_heads/test_s2a_head.py +++ b/tests/test_models/test_dense_heads/test_s2a_head.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import torch from mmengine import Config from mmengine.structures import InstanceData +from unittest import TestCase from mmrotate.models.dense_heads import S2AHead, S2ARefineHead from mmrotate.structures.bbox import RotatedBoxes diff --git a/tests/test_models/test_dense_heads/test_sam_reppoints_head.py b/tests/test_models/test_dense_heads/test_sam_reppoints_head.py index 489ce4f7b..243e91821 100644 --- a/tests/test_models/test_dense_heads/test_sam_reppoints_head.py +++ b/tests/test_models/test_dense_heads/test_sam_reppoints_head.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest - import torch +import unittest from mmdet.structures import DetDataSample from mmengine.config import ConfigDict from mmengine.structures import InstanceData diff --git a/tests/test_models/test_detectors/test_h2rbox.py b/tests/test_models/test_detectors/test_h2rbox.py index a0d471b21..80c61e179 100644 --- a/tests/test_models/test_detectors/test_h2rbox.py +++ b/tests/test_models/test_detectors/test_h2rbox.py @@ -1,12 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. import time -import unittest -from unittest import TestCase - import torch +import unittest from mmdet.structures import DetDataSample from mmengine.logging import MessageHub from parameterized import parameterized +from unittest import TestCase from mmrotate.testing import demo_mm_inputs, get_detector_cfg from mmrotate.utils import register_all_modules diff --git a/tests/test_models/test_detectors/test_refine_single_stage.py b/tests/test_models/test_detectors/test_refine_single_stage.py index 2487dee10..14882b0b1 100644 --- a/tests/test_models/test_detectors/test_refine_single_stage.py +++ b/tests/test_models/test_detectors/test_refine_single_stage.py @@ -1,12 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. import time -import unittest -from unittest import TestCase - import torch +import unittest from mmdet.structures import DetDataSample from mmengine.logging import MessageHub from parameterized import parameterized +from unittest import TestCase from mmrotate.testing import demo_mm_inputs, get_detector_cfg from mmrotate.utils import register_all_modules diff --git a/tests/test_models/test_detectors/test_single_stage.py b/tests/test_models/test_detectors/test_single_stage.py index defbbf5c3..ab6c6b0d7 100644 --- a/tests/test_models/test_detectors/test_single_stage.py +++ b/tests/test_models/test_detectors/test_single_stage.py @@ -1,12 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. import time -import unittest -from unittest import TestCase - import torch +import unittest from mmdet.structures import DetDataSample from mmengine.logging import MessageHub from parameterized import parameterized +from unittest import TestCase from mmrotate.testing import demo_mm_inputs, get_detector_cfg from mmrotate.utils import register_all_modules diff --git a/tests/test_models/test_detectors/test_two_stage.py b/tests/test_models/test_detectors/test_two_stage.py index b5ffda2be..2545c4ea0 100644 --- a/tests/test_models/test_detectors/test_two_stage.py +++ b/tests/test_models/test_detectors/test_two_stage.py @@ -1,10 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest -from unittest import TestCase - import torch +import unittest from mmdet.structures import DetDataSample from parameterized import parameterized +from unittest import TestCase from mmrotate.testing import demo_mm_inputs, get_detector_cfg from mmrotate.utils import register_all_modules diff --git a/tests/test_models/test_losses/test_loss.py b/tests/test_models/test_losses/test_loss.py index 6b414c2bd..7392c1f1c 100644 --- a/tests/test_models/test_losses/test_loss.py +++ b/tests/test_models/test_losses/test_loss.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest - import torch +import unittest from parameterized import parameterized from mmrotate.models.losses import (BCConvexGIoULoss, ConvexGIoULoss, GDLoss, diff --git a/tests/test_models/test_necks/test_re_fpn.py b/tests/test_models/test_necks/test_re_fpn.py index 324b42dc4..e6815e527 100644 --- a/tests/test_models/test_necks/test_re_fpn.py +++ b/tests/test_models/test_necks/test_re_fpn.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import e2cnn.nn as enn import torch from torch.nn.modules.batchnorm import _BatchNorm +from unittest import TestCase from mmrotate.models.necks import ReFPN from mmrotate.models.utils.enn import build_enn_divide_feature diff --git a/tests/test_models/test_roi_heads/test_bbox_head/test_convfc_rbbox_head.py b/tests/test_models/test_roi_heads/test_bbox_head/test_convfc_rbbox_head.py index 6c52a844c..d15091310 100644 --- a/tests/test_models/test_roi_heads/test_bbox_head/test_convfc_rbbox_head.py +++ b/tests/test_models/test_roi_heads/test_bbox_head/test_convfc_rbbox_head.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest -from unittest import TestCase - import torch +import unittest from parameterized import parameterized +from unittest import TestCase from mmrotate.models.roi_heads.bbox_heads import RotatedShared2FCBBoxHead from mmrotate.utils import register_all_modules diff --git a/tests/test_models/test_roi_heads/test_bbox_head/test_gv_bbox_head.py b/tests/test_models/test_roi_heads/test_bbox_head/test_gv_bbox_head.py index 037adc32c..5931c031f 100644 --- a/tests/test_models/test_roi_heads/test_bbox_head/test_gv_bbox_head.py +++ b/tests/test_models/test_roi_heads/test_bbox_head/test_gv_bbox_head.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest -from unittest import TestCase - import torch +import unittest from parameterized import parameterized +from unittest import TestCase from mmrotate.models.roi_heads.bbox_heads import GVBBoxHead from mmrotate.utils import register_all_modules diff --git a/tests/test_models/test_roi_heads/test_gv_ratio_roi_head.py b/tests/test_models/test_roi_heads/test_gv_ratio_roi_head.py index bf07d3616..8f2466e82 100644 --- a/tests/test_models/test_roi_heads/test_gv_ratio_roi_head.py +++ b/tests/test_models/test_roi_heads/test_gv_ratio_roi_head.py @@ -1,10 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest -from unittest import TestCase - import torch +import unittest from mmengine.config import Config from parameterized import parameterized +from unittest import TestCase from mmrotate.registry import MODELS from mmrotate.testing import demo_mm_inputs, demo_mm_proposals diff --git a/tests/test_models/test_task_modules/test_assigners/test_convex_assigner.py b/tests/test_models/test_task_modules/test_assigners/test_convex_assigner.py index d6bc43d20..3996a2ed5 100644 --- a/tests/test_models/test_task_modules/test_assigners/test_convex_assigner.py +++ b/tests/test_models/test_task_modules/test_assigners/test_convex_assigner.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest - import torch +import unittest from mmengine.structures import InstanceData from mmengine.testing import assert_allclose diff --git a/tests/test_models/test_task_modules/test_assigners/test_max_convex_iou_assigner.py b/tests/test_models/test_task_modules/test_assigners/test_max_convex_iou_assigner.py index 75d696b18..a2a7292c6 100644 --- a/tests/test_models/test_task_modules/test_assigners/test_max_convex_iou_assigner.py +++ b/tests/test_models/test_task_modules/test_assigners/test_max_convex_iou_assigner.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest - import torch +import unittest from mmengine.structures import InstanceData from parameterized import parameterized diff --git a/tests/test_models/test_task_modules/test_assigners/test_rotated_atss_assigner.py b/tests/test_models/test_task_modules/test_assigners/test_rotated_atss_assigner.py index 1f0ec2cfd..46fad2312 100644 --- a/tests/test_models/test_task_modules/test_assigners/test_rotated_atss_assigner.py +++ b/tests/test_models/test_task_modules/test_assigners/test_rotated_atss_assigner.py @@ -1,8 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import torch from mmengine.structures import InstanceData +from unittest import TestCase from mmrotate.models.task_modules.assigners import RotatedATSSAssigner from mmrotate.structures.bbox import RotatedBoxes diff --git a/tests/test_models/test_task_modules/test_assigners/test_sas_assigner.py b/tests/test_models/test_task_modules/test_assigners/test_sas_assigner.py index fbbeb52a2..89b0369ca 100644 --- a/tests/test_models/test_task_modules/test_assigners/test_sas_assigner.py +++ b/tests/test_models/test_task_modules/test_assigners/test_sas_assigner.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. -import unittest - import torch +import unittest from mmengine.structures import InstanceData from mmengine.testing import assert_allclose diff --git a/tests/test_models/test_task_modules/test_coder/test_angle_coder.py b/tests/test_models/test_task_modules/test_coder/test_angle_coder.py index 22c41aac3..ba7a8abbc 100644 --- a/tests/test_models/test_task_modules/test_coder/test_angle_coder.py +++ b/tests/test_models/test_task_modules/test_coder/test_angle_coder.py @@ -1,8 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import torch from mmengine.testing import assert_allclose +from unittest import TestCase from mmrotate.models.task_modules.coders import CSLCoder diff --git a/tests/test_models/test_task_modules/test_coder/test_delta_midpointoffset_rbbox_coder.py b/tests/test_models/test_task_modules/test_coder/test_delta_midpointoffset_rbbox_coder.py index e8e1d0eeb..e61f98a99 100644 --- a/tests/test_models/test_task_modules/test_coder/test_delta_midpointoffset_rbbox_coder.py +++ b/tests/test_models/test_task_modules/test_coder/test_delta_midpointoffset_rbbox_coder.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import torch from mmdet.structures.bbox import HorizontalBoxes from mmengine.testing import assert_allclose +from unittest import TestCase from mmrotate.models.task_modules.coders import MidpointOffsetCoder from mmrotate.structures.bbox import RotatedBoxes diff --git a/tests/test_models/test_task_modules/test_coder/test_delta_xywh_hbbox_coder.py b/tests/test_models/test_task_modules/test_coder/test_delta_xywh_hbbox_coder.py index c3a1b7275..54968489c 100644 --- a/tests/test_models/test_task_modules/test_coder/test_delta_xywh_hbbox_coder.py +++ b/tests/test_models/test_task_modules/test_coder/test_delta_xywh_hbbox_coder.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import torch from mmdet.structures.bbox import HorizontalBoxes from mmengine.testing import assert_allclose +from unittest import TestCase from mmrotate.models.task_modules.coders import DeltaXYWHHBBoxCoder from mmrotate.structures.bbox import RotatedBoxes diff --git a/tests/test_models/test_task_modules/test_coder/test_delta_xywh_qbbox_coder.py b/tests/test_models/test_task_modules/test_coder/test_delta_xywh_qbbox_coder.py index 1662d81bd..dfc9a759b 100644 --- a/tests/test_models/test_task_modules/test_coder/test_delta_xywh_qbbox_coder.py +++ b/tests/test_models/test_task_modules/test_coder/test_delta_xywh_qbbox_coder.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import torch from mmdet.structures.bbox import HorizontalBoxes from mmengine.testing import assert_allclose +from unittest import TestCase from mmrotate.models.task_modules.coders import DeltaXYWHQBBoxCoder from mmrotate.structures.bbox import QuadriBoxes diff --git a/tests/test_models/test_task_modules/test_coder/test_delta_xywht_hbbox_coder.py b/tests/test_models/test_task_modules/test_coder/test_delta_xywht_hbbox_coder.py index 42b1aa722..cb34cf705 100644 --- a/tests/test_models/test_task_modules/test_coder/test_delta_xywht_hbbox_coder.py +++ b/tests/test_models/test_task_modules/test_coder/test_delta_xywht_hbbox_coder.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import torch from mmdet.structures.bbox import HorizontalBoxes from mmengine.testing import assert_allclose +from unittest import TestCase from mmrotate.models.task_modules.coders import DeltaXYWHTHBBoxCoder from mmrotate.structures.bbox import RotatedBoxes diff --git a/tests/test_models/test_task_modules/test_coder/test_delta_xywht_rbbox_coder.py b/tests/test_models/test_task_modules/test_coder/test_delta_xywht_rbbox_coder.py index cc7a9c014..ab0ce7e91 100644 --- a/tests/test_models/test_task_modules/test_coder/test_delta_xywht_rbbox_coder.py +++ b/tests/test_models/test_task_modules/test_coder/test_delta_xywht_rbbox_coder.py @@ -1,8 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import torch from mmengine.testing import assert_allclose +from unittest import TestCase from mmrotate.models.task_modules.coders import DeltaXYWHTRBBoxCoder from mmrotate.structures.bbox import RotatedBoxes diff --git a/tests/test_models/test_task_modules/test_coder/test_gliding_vertex_coder.py b/tests/test_models/test_task_modules/test_coder/test_gliding_vertex_coder.py index ffd9acd07..7c1a9d648 100644 --- a/tests/test_models/test_task_modules/test_coder/test_gliding_vertex_coder.py +++ b/tests/test_models/test_task_modules/test_coder/test_gliding_vertex_coder.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import torch from mmdet.structures.bbox import HorizontalBoxes from mmengine.testing import assert_allclose +from unittest import TestCase from mmrotate.models.task_modules.coders import GVFixCoder, GVRatioCoder from mmrotate.structures.bbox import QuadriBoxes diff --git a/tests/test_models/test_task_modules/test_prior_generators/test_anchor_generator.py b/tests/test_models/test_task_modules/test_prior_generators/test_anchor_generator.py index 20a6de8b3..8e2606e6b 100644 --- a/tests/test_models/test_task_modules/test_prior_generators/test_anchor_generator.py +++ b/tests/test_models/test_task_modules/test_prior_generators/test_anchor_generator.py @@ -1,8 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import torch from mmengine.testing import assert_allclose +from unittest import TestCase from mmrotate.registry import TASK_UTILS from mmrotate.structures.bbox import RotatedBoxes diff --git a/tests/test_models/test_task_modules/test_rotated_iou2d_calculator.py b/tests/test_models/test_task_modules/test_rotated_iou2d_calculator.py index ee1b13f3d..f6a2486a4 100644 --- a/tests/test_models/test_task_modules/test_rotated_iou2d_calculator.py +++ b/tests/test_models/test_task_modules/test_rotated_iou2d_calculator.py @@ -1,10 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. -from unittest import TestCase - import numpy as np import torch from mmdet.structures.bbox import HorizontalBoxes from mmengine.testing import assert_allclose +from unittest import TestCase from mmrotate.models.task_modules import (FakeRBboxOverlaps2D, QBbox2HBboxOverlaps2D, diff --git a/tests/test_structures/test_bbox/test_box_converters.py b/tests/test_structures/test_bbox/test_box_converters.py index 3ab865426..fcb66d9da 100644 --- a/tests/test_structures/test_bbox/test_box_converters.py +++ b/tests/test_structures/test_bbox/test_box_converters.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -from math import sqrt -from unittest import TestCase - import numpy as np import torch +from math import sqrt from mmdet.structures.bbox import HorizontalBoxes from mmengine.testing import assert_allclose +from unittest import TestCase from mmrotate.structures.bbox import QuadriBoxes, RotatedBoxes diff --git a/tests/test_structures/test_bbox/test_quadri_boxes.py b/tests/test_structures/test_bbox/test_quadri_boxes.py index 2f10118c4..28504f9e9 100644 --- a/tests/test_structures/test_bbox/test_quadri_boxes.py +++ b/tests/test_structures/test_bbox/test_quadri_boxes.py @@ -1,13 +1,12 @@ # Copyright (c) OpenMMLab. All rights reserved. -import random -from math import sqrt -from unittest import TestCase - import cv2 import numpy as np +import random import torch +from math import sqrt from mmdet.structures.mask import BitmapMasks, PolygonMasks from mmengine.testing import assert_allclose +from unittest import TestCase from mmrotate.structures.bbox import QuadriBoxes diff --git a/tests/test_structures/test_bbox/test_rotated_boxes.py b/tests/test_structures/test_bbox/test_rotated_boxes.py index 4fc0f557a..fbc99e010 100644 --- a/tests/test_structures/test_bbox/test_rotated_boxes.py +++ b/tests/test_structures/test_bbox/test_rotated_boxes.py @@ -1,13 +1,12 @@ # Copyright (c) OpenMMLab. All rights reserved. -import random -from math import sqrt -from unittest import TestCase - import cv2 import numpy as np +import random import torch +from math import sqrt from mmdet.structures.mask import BitmapMasks, PolygonMasks from mmengine.testing import assert_allclose +from unittest import TestCase from mmrotate.structures.bbox import RotatedBoxes diff --git a/tests/test_visualization/test_local_visualizer.py b/tests/test_visualization/test_local_visualizer.py index 15667bdd1..a1c1dc59a 100644 --- a/tests/test_visualization/test_local_visualizer.py +++ b/tests/test_visualization/test_local_visualizer.py @@ -1,13 +1,12 @@ # Copyright (c) OpenMMLab. All rights reserved. -import os -from unittest import TestCase - import cv2 import numpy as np +import os import torch from mmdet.structures import DetDataSample from mmdet.structures.mask import BitmapMasks from mmengine.structures import InstanceData +from unittest import TestCase from mmrotate.structures.bbox import RotatedBoxes from mmrotate.visualization import RotLocalVisualizer diff --git a/tools/analysis_tools/analyze_logs.py b/tools/analysis_tools/analyze_logs.py index d5410daf8..9c5dc59a8 100644 --- a/tools/analysis_tools/analyze_logs.py +++ b/tools/analysis_tools/analyze_logs.py @@ -1,10 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. import argparse import json -from collections import defaultdict - import matplotlib.pyplot as plt import numpy as np +from collections import defaultdict try: import seaborn as sns diff --git a/tools/analysis_tools/benchmark.py b/tools/analysis_tools/benchmark.py index fbd0de5f9..dddbab592 100644 --- a/tools/analysis_tools/benchmark.py +++ b/tools/analysis_tools/benchmark.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. import argparse import os - from mmdet.utils.benchmark import (DataLoaderBenchmark, DatasetBenchmark, InferenceBenchmark) from mmengine import MMLogger diff --git a/tools/analysis_tools/browse_dataset.py b/tools/analysis_tools/browse_dataset.py index 56129c209..b8eeb2e17 100644 --- a/tools/analysis_tools/browse_dataset.py +++ b/tools/analysis_tools/browse_dataset.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. import argparse import os.path as osp - from mmdet.models.utils import mask2ndarray from mmdet.registry import DATASETS, VISUALIZERS from mmdet.structures.bbox import BaseBoxes diff --git a/tools/analysis_tools/confusion_matrix.py b/tools/analysis_tools/confusion_matrix.py index 7c71bd906..60c9dc7c7 100644 --- a/tools/analysis_tools/confusion_matrix.py +++ b/tools/analysis_tools/confusion_matrix.py @@ -1,9 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. import argparse -import os - import matplotlib.pyplot as plt import numpy as np +import os from matplotlib.ticker import MultipleLocator from mmcv.ops import nms_rotated from mmdet.registry import DATASETS diff --git a/tools/analysis_tools/get_flops.py b/tools/analysis_tools/get_flops.py index f745cd294..441a8004d 100644 --- a/tools/analysis_tools/get_flops.py +++ b/tools/analysis_tools/get_flops.py @@ -1,6 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. import argparse - import numpy as np import torch from mmengine.config import Config, DictAction diff --git a/tools/data/dota/dota2coco.py b/tools/data/dota/dota2coco.py index 423bb70d7..c6d9153ee 100644 --- a/tools/data/dota/dota2coco.py +++ b/tools/data/dota/dota2coco.py @@ -1,11 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. # Written by dingjiansw101 # Reference: https://github.com/CAPTAIN-WHU/DOTA_devkit +import cv2 import json import os from argparse import ArgumentParser - -import cv2 from mmengine.utils import ProgressBar try: diff --git a/tools/data/dota/split/img_split.py b/tools/data/dota/split/img_split.py index 63279d3c4..15739fbfc 100644 --- a/tools/data/dota/split/img_split.py +++ b/tools/data/dota/split/img_split.py @@ -4,19 +4,18 @@ import argparse import codecs +import cv2 import datetime import itertools import json import logging +import numpy as np import os import os.path as osp import time from functools import partial, reduce from math import ceil from multiprocessing import Manager, Pool - -import cv2 -import numpy as np from PIL import Image Image.MAX_IMAGE_PIXELS = None diff --git a/tools/deployment/mmrotate2torchserve.py b/tools/deployment/mmrotate2torchserve.py index 4691b01b8..a33bc6246 100644 --- a/tools/deployment/mmrotate2torchserve.py +++ b/tools/deployment/mmrotate2torchserve.py @@ -1,10 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. from argparse import ArgumentParser, Namespace -from pathlib import Path -from tempfile import TemporaryDirectory - from mmengine.config import Config from mmengine.utils import mkdir_or_exist +from pathlib import Path +from tempfile import TemporaryDirectory try: from model_archiver.model_packaging import package_model diff --git a/tools/deployment/mmrotate_handler.py b/tools/deployment/mmrotate_handler.py index 5991f1766..09d103ce7 100644 --- a/tools/deployment/mmrotate_handler.py +++ b/tools/deployment/mmrotate_handler.py @@ -1,8 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. import base64 -import os - import mmcv +import os import torch from mmdet.apis import inference_detector, init_detector from ts.torch_handler.base_handler import BaseHandler diff --git a/tools/misc/print_config.py b/tools/misc/print_config.py index d43c8c532..50d661d71 100644 --- a/tools/misc/print_config.py +++ b/tools/misc/print_config.py @@ -1,6 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. import argparse - from mmengine import Config, DictAction diff --git a/tools/model_converters/publish_model.py b/tools/model_converters/publish_model.py index 0fa9b8457..3c2ac48f8 100644 --- a/tools/model_converters/publish_model.py +++ b/tools/model_converters/publish_model.py @@ -1,7 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. import argparse import subprocess - import torch diff --git a/tools/test.py b/tools/test.py index 4d416112d..766d246c7 100644 --- a/tools/test.py +++ b/tools/test.py @@ -2,7 +2,6 @@ import argparse import os import os.path as osp - from mmdet.utils import register_all_modules as register_all_modules_mmdet from mmengine.config import Config, DictAction from mmengine.evaluator import DumpResults diff --git a/tools/train.py b/tools/train.py index 5b4fac437..136fcc859 100644 --- a/tools/train.py +++ b/tools/train.py @@ -3,7 +3,6 @@ import logging import os import os.path as osp - from mmdet.utils import register_all_modules as register_all_modules_mmdet from mmengine.config import Config, DictAction from mmengine.logging import print_log From 8489436ac89a3e846ca47783d5c19b49f2fc5b1e Mon Sep 17 00:00:00 2001 From: zytx121 <592267829@qq.com> Date: Thu, 13 Apr 2023 08:03:13 +0800 Subject: [PATCH 2/2] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 823a06fb5..c63a68a2b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,10 +3,6 @@ repos: rev: 5.0.4 hooks: - id: flake8 - - repo: https://github.com/asottile/seed-isort-config - rev: v2.2.0 - hooks: - - id: seed-isort-config - repo: https://github.com/PyCQA/isort rev: 5.11.5 hooks: