diff --git a/.circleci/test.yml b/.circleci/test.yml index e171e8e87..bc194ae68 100644 --- a/.circleci/test.yml +++ b/.circleci/test.yml @@ -70,7 +70,6 @@ jobs: - run: name: Build and install command: | - pip install 'numpy < 1.24.0' pip install -e . - run: name: Run unittests @@ -98,11 +97,13 @@ jobs: command: | git clone -b main --depth 1 https://github.com/open-mmlab/mmengine.git /home/circleci/mmengine git clone -b dev-3.x --depth 1 https://github.com/open-mmlab/mmdetection.git /home/circleci/mmdetection + git clone --depth 1 https://github.com/QUVA-Lab/e2cnn.git /home/circleci/e2cnn - run: name: Build Docker image command: | docker build .circleci/docker -t mmrotate:gpu --build-arg PYTORCH=<< parameters.torch >> --build-arg CUDA=<< parameters.cuda >> --build-arg CUDNN=<< parameters.cudnn >> docker run --gpus all -t -d -v /home/circleci/project:/mmrotate -v /home/circleci/mmengine:/mmengine -v /home/circleci/mmdetection:/mmdetection -w /mmrotate --name mmrotate mmrotate:gpu + docker exec mmrotate apt-get install -y git - run: name: Install mmrotate dependencies command: | @@ -114,7 +115,6 @@ jobs: - run: name: Build and install command: | - docker exec mmrotate pip install 'numpy < 1.24.0' docker exec mmrotate pip install -e . - run: name: Run unittests diff --git a/.github/workflows/merge_stage_test.yml b/.github/workflows/merge_stage_test.yml index b75860652..290192adb 100644 --- a/.github/workflows/merge_stage_test.yml +++ b/.github/workflows/merge_stage_test.yml @@ -48,7 +48,7 @@ jobs: - name: Install other dependencies run: pip install -r requirements/tests.txt - name: Build and install - run: rm -rf .eggs && pip install 'numpy < 1.24.0' && pip install -e . + run: rm -rf .eggs && pip install -e . - name: Run unittests and generate coverage report run: | coverage run --branch --source mmrotate -m pytest tests/ diff --git a/README.md b/README.md index 12f429a1e..c5f9f5f9f 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,20 @@ English | [简体中文](README_zh-CN.md) +
+ ## Introduction MMRotate is an open-source toolbox for rotated object detection based on PyTorch. @@ -148,8 +162,9 @@ A summary can be found in the [Model Zoo](docs/en/model_zoo.md) page. - [x] [KLD](configs/kld/README.md) (NeurIPS'2021) - [x] [SASM](configs/sasm_reppoints/README.md) (AAAI'2022) - [x] [Oriented RepPoints](configs/oriented_reppoints/README.md) (CVPR'2022) -- [x] [KFIoU](configs/kfiou/README.md) (arXiv) -- [x] [H2RBox](configs/h2rbox/README.md) (arXiv) +- [x] [KFIoU](configs/kfiou/README.md) (ICLR'2023) +- [x] [H2RBox](configs/h2rbox/README.md) (ICLR'2023) +- [x] [RTMDet](configs/rotated_rtmdet/README.md) (arXiv) diff --git a/README_zh-CN.md b/README_zh-CN.md index 110bfb7cc..6afe8b694 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -144,8 +144,9 @@ https://user-images.githubusercontent.com/10410257/154433305-416d129b-60c8-44c7- - [x] [KLD](configs/kld/README.md) (NeurIPS'2021) - [x] [SASM](configs/sasm_reppoints/README.md) (AAAI'2022) - [x] [Oriented RepPoints](configs/oriented_reppoints/README.md) (CVPR'2022) -- [x] [KFIoU](configs/kfiou/README.md) (arXiv) -- [x] [H2RBox](configs/h2rbox/README.md) (arXiv) +- [x] [KFIoU](configs/kfiou/README.md) (ICLR'2023) +- [x] [H2RBox](configs/h2rbox/README.md) (ICLR'2023) +- [x] [RTMDet](configs/rotated_rtmdet/README.md) (arXiv) diff --git a/configs/convnext/metafile.yml b/configs/convnext/metafile.yml index 2235a9d9a..4b657b807 100644 --- a/configs/convnext/metafile.yml +++ b/configs/convnext/metafile.yml @@ -1,5 +1,5 @@ Collections: -- Name: ConvNeXt +- Name: convnext Metadata: Training Data: DOTAv1.0 Training Techniques: diff --git a/configs/h2rbox/README.md b/configs/h2rbox/README.md index a22e92f00..68af43b0f 100644 --- a/configs/h2rbox/README.md +++ b/configs/h2rbox/README.md @@ -54,11 +54,11 @@ DIOR ## Citation ``` -@article{yang2022h2rbox, +@article{yang2023h2rbox, title={H2RBox: Horizontal Box Annotation is All You Need for Oriented Object Detection}, author={Yang, Xue and Zhang, Gefan and Li, Wentong and Wang, Xuehui and Zhou, Yue and Yan, Junchi}, - journal={arXiv preprint arXiv:2210.06742}, - year={2022} + booktitle={International Conference on Learning Representations}, + year={2023} } ``` diff --git a/configs/h2rbox/metafile.yml b/configs/h2rbox/metafile.yml index 4b9811d30..a29101454 100644 --- a/configs/h2rbox/metafile.yml +++ b/configs/h2rbox/metafile.yml @@ -1,5 +1,5 @@ Collections: -- Name: psc +- Name: h2rbox Metadata: Training Data: DOTAv1.0, DOTAv1.5, DOTAv2.0, DIOR Training Techniques: diff --git a/configs/kfiou/README.md b/configs/kfiou/README.md index 2ce5d2add..9f18c86a1 100644 --- a/configs/kfiou/README.md +++ b/configs/kfiou/README.md @@ -42,12 +42,10 @@ DOTA1.0 ## Citation ``` -@misc{yang2022kfiou, +@misc{yang2023kfiou, title={The KFIoU Loss for Rotated Object Detection}, author={Xue Yang and Yue Zhou and Gefan Zhang and Jirui Yang and Wentao Wang and Junchi Yan and Xiaopeng Zhang and Qi Tian}, - year={2022}, - eprint={2201.12558}, - archivePrefix={arXiv}, - primaryClass={cs.CV} + booktitle={International Conference on Learning Representations}, + year={2023} } ``` diff --git a/configs/redet/README.md b/configs/redet/README.md index 0c5d56e5c..397cfc811 100644 --- a/configs/redet/README.md +++ b/configs/redet/README.md @@ -33,8 +33,13 @@ Notes: - `MS` means multiple scale image split. - `RR` means random rotation. +- ReDet needs to install [e2cnn](https://github.com/QUVA-Lab/e2cnn) first. + +```shell +pip install -e git+https://github.com/QUVA-Lab/e2cnn.git#egg=e2cnn +``` + - Please download pretrained weight of ReResNet from [ReDet](https://github.com/csuhan/ReDet), and put it on `work_dirs/pretrain`. BTW, it is normal for `missing keys in source state_dict: xxx.filter ` to appear in the log. Don't worry! -- Please use distributed training, there are some bugs when using `train.py`. ## Citation diff --git a/docs/zh_cn/get_started.md b/docs/zh_cn/get_started.md index e18e25dcd..b9a59d67e 100644 --- a/docs/zh_cn/get_started.md +++ b/docs/zh_cn/get_started.md @@ -1,37 +1,37 @@ -# 开始你的第一步(待翻译) +# 开始你的第一步 -## Prerequisites +## 需要准备的依赖环境 -In this section we demonstrate how to prepare an environment with PyTorch. +在本小节中将会演示如何准备一个Pytorch的环境。 -MMRotate works on Linux and Windows. It requires Python 3.7+, CUDA 9.2+ and PyTorch 1.6+. +MMRotate可以在Linux和Windows系统工作,需要以下环境版本:Python 3.7+, CUDA 9.2+ and PyTorch 1.6+。 ```{note} -If you are experienced with PyTorch and have already installed it, just skip this part and jump to the [next section](#installation). Otherwise, you can follow these steps for the preparation. +如果您对于Pytorch很熟悉并且已经完成了其安装步骤,您可以跳过本部分内容直接查阅[安装](#安装)的部分。当然,如果您没有准备好这部分的安装,请按照以下流程进行准备。 ``` -**Step 0.** Download and install Miniconda from the [official website](https://docs.conda.io/en/latest/miniconda.html). +**第一步:** 从 [Miniconda](https://docs.conda.io/en/latest/miniconda.html) 下载并且安装Miniconda。 -**Step 1.** Create a conda environment and activate it. +**第二步:** 创建一个虚拟环境并且切换至该虚拟环境中。 ```shell conda create --name openmmlab python=3.8 -y conda activate openmmlab ``` -**Step 2.** Install PyTorch following [official instructions](https://pytorch.org/get-started/locally/), e.g. +**第三步:** 根据 [Pytorch的官方说明](https://pytorch.org/get-started/locally/) 安装Pytorch, 例如: ```shell conda install pytorch==1.8.0 torchvision==0.9.0 cudatoolkit=10.2 -c pytorch ``` -## Installation +## 安装 -We recommend that users follow our best practices to install MMRotate. However, the whole process is highly customizable. See [Customize Installation](#customize-installation) section for more information. +我们强烈建议用户使用以下方式安装MMRotate,这是最方便的。当然,还有多种自定义的安装方式可供经验丰富者选择,您可以查阅 [自定义安装](#customize-installation) 来获取更多相关的帮助。 -### Best Practices +### 最佳的安装方式 -**Step 0.** Install [MMEngine](https://github.com/open-mmlab/mmengine) and [MMCV](https://github.com/open-mmlab/mmcv) using [MIM](https://github.com/open-mmlab/mim). +**第一步:** 安装 [MMEngine](https://github.com/open-mmlab/mmengine) 和 [MMCV](https://github.com/open-mmlab/mmcv) ,并且我们建议使用 [MIM](https://github.com/open-mmlab/mim) 来完成安装。 ```shell pip install -U openmim @@ -39,13 +39,13 @@ mim install mmengine mim install "mmcv>=2.0.0rc2" ``` -**Step 1.** Install [MMDetection](https://github.com/open-mmlab/mmdetection) as a dependency. +**第二步:** 安装 [MMDetection](https://github.com/open-mmlab/mmdetection) 。 ```shell mim install 'mmdet>=3.0.0rc2' ``` -Optionally, you could also build MMDetection from source in case you want to modify the code: +注意:如果您需要进行部分代码的修改与开发,请从源码获取MMDetection并且进行以下示例的安装: ```shell git clone https://github.com/open-mmlab/mmdetection.git -b dev-3.x @@ -57,9 +57,9 @@ pip install -v -e . # thus any local modifications made to the code will take effect without reinstallation. ``` -**Step 2.** Install MMRotate. +**第三步:** 安装 MMRotate。 -Case a: If you develop and run mmrotate directly, install it from source: +情形a:如果您需要对于MMRotate进行代码上的开发与修改,请从源码进行以下示例的安装: ```shell git clone https://github.com/open-mmlab/mmrotate.git -b dev-1.x @@ -71,35 +71,35 @@ pip install -v -e . # thus any local modifications made to the code will take effect without reinstallation. ``` -Case b: If you use mmrotate as a dependency or third-party package, install it with pip: +情形b:如果您只是使用MMRotate作为依赖项或者是第三方软件包,则直接使用pip进行以下示例的安装即可: ```shell pip install mmrotate ``` -### Verify the installation +### 验证安装是否正确 -To verify whether MMRotate is installed correctly, we provide some sample codes to run an inference demo. +为了验证MMRotate是否正确地被安装到了您的环境中,我们提供了一些demo以供测试。 -**Step 1.** We need to download config and checkpoint files. +**第一步:** 为了进行测试的验证,我们需要下载config文件与checkpoint文件。 ```shell mim download mmrotate --config oriented-rcnn-le90_r50_fpn_1x_dota --dest . ``` -The downloading will take several seconds or more, depending on your network environment. When it is done, you will find two files `oriented-rcnn-le90_r50_fpn_1x_dota.py` and `oriented_rcnn_r50_fpn_1x_dota_le90-6d2b2ce0.pth` in your current folder. +下载过程可能会依据您的网络状况花费数秒或者更多的时间。当下载完成之后,您可以在您的当前目录下找到 `oriented-rcnn-le90_r50_fpn_1x_dota.py` 和 `oriented_rcnn_r50_fpn_1x_dota_le90-6d2b2ce0.pth` 两个文件。 -**Step 2.** Verify the inference demo. +**第二步:** 使用推理demo完成验证 -Option (a). If you install mmrotate from source, just run the following command. +情形 (a):如果您是通过源码方式安装的MMRotate,直接在命令行中运行以下代码即可: ```shell python demo/image_demo.py demo/demo.jpg oriented-rcnn-le90_r50_fpn_1x_dota.py oriented_rcnn_r50_fpn_1x_dota_le90-6d2b2ce0.pth --out-file result.jpg ``` -You will see a new image `result.jpg` on your current folder, where rotated bounding boxes are plotted on cars, buses, etc. +您将会在您的当前文件夹下看到一张 `result.jpg` 为文件名的图片,在该图片中完成了对于小轿车和公交车等物体的旋转锚定框的绘制。 -Option (b). If you install mmrotate with pip, open you python interpreter and copy&paste the following codes. +情形 (b): 如果您是使用pip的方式安装的MMRotate,打开您的python控制台并使用代码: ```python from mmdet.apis import init_detector, inference_detector @@ -111,41 +111,41 @@ model = init_detector(config_file, checkpoint_file, device='cuda:0') inference_detector(model, 'demo/demo.jpg') ``` -You will see a list of arrays printed, indicating the detected rotated bounding boxes. +您将会看到一系列数组列表被打印出来,这代表着被检测到的旋转锚定框。 -### Customize Installation +### 自定义安装 -#### CUDA versions +#### CUDA 版本 -When installing PyTorch, you need to specify the version of CUDA. If you are not clear on which to choose, follow our recommendations: +安装Pytorch之前,您需要指定安装的CUDA版本。如果您不清楚您的CUDA版本的安装选择,我们建议: -- For Ampere-based NVIDIA GPUs, such as GeForce 30 series and NVIDIA A100, CUDA 11 is a must. -- For older NVIDIA GPUs, CUDA 11 is backward compatible, but CUDA 10.2 offers better compatibility and is more lightweight. +- 对于基于安培架构的NVIDIA GPU,例如GeForce 30系列和NVIDIA A100,请使用CUDA 11。 +- 对于其他的NVIDIA GPU,CUDA 11同样可以兼容,但是CUDA 10.2更加轻量并且更好被兼容。 -Please make sure the GPU driver satisfies the minimum version requirements. See [this table](https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#cuda-major-component-versions__table-cuda-toolkit-driver-versions) for more information. +请确保GPU的驱动程序满足最低的版本需求,您可以查阅 [表格](https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#cuda-major-component-versions__table-cuda-toolkit-driver-versions) 以了解更多信息。 ```{note} -Installing CUDA runtime libraries is enough if you follow our best practices, because no CUDA code will be compiled locally. However if you hope to compile MMCV from source or develop other CUDA operators, you need to install the complete CUDA toolkit from NVIDIA's [website](https://developer.nvidia.com/cuda-downloads), and its version should match the CUDA version of PyTorch. i.e., the specified version of cudatoolkit in `conda install` command. +如果您按照我们推荐的最佳的安装方式进行安装流程,安装CUDA的运行库就已经足够了,因为这不需要在本地进行CUDA代码的编译工作。但是如果您想从源码对于MMCV进行编译或者开发其他的CUDA算子,您需要从NVIDIA官网完整地安装CUDA工具包 [官网](https://developer.nvidia.com/cuda-downloads) 并且CUDA工具包的版本应该和您使用的Pytorch版本对应。例如您可以使用 'conda install' 命令来安装指定版本的CUDA工具包。 ``` -#### Install MMCV without MIM +#### 不使用MIM安装MMCV -MMCV contains C++ and CUDA extensions, thus depending on PyTorch in a complex way. MIM solves such dependencies automatically and makes the installation easier. However, it is not a must. +MMCV有一些C++和CUDA扩展的使用,因此MMCV与Pytorch有着复杂的依赖关系。MIM会自动处理这些依赖关系使整个安装过程更加简便,但是您也可以选择不使用MIM这个工具。 -To install MMCV with pip instead of MIM, please follow [MMCV installation guides](https://mmcv.readthedocs.io/en/latest/get_started/installation.html). This requires manually specifying a find-url based on PyTorch version and its CUDA version. +如果您想使用pip进行MMCV的安装,而不是MIM,请按照 [MMCV安装指南](https://mmcv.readthedocs.io/en/latest/get_started/installation.html) 。您需要根据Pytorch版本和CUDA版本手动指定 find-url。 -For example, the following command install mmcv built for PyTorch 1.9.x and CUDA 10.2. +举个例子,以下代码示例是在PyTorch 1.9.x于CUDA 10.2的环境下进行MMCV的安装: ```shell pip install mmcv -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.8/index.html ``` -#### Install on Google Colab +#### 在Google Colab上安装 -[Google Colab](https://research.google.com/) usually has PyTorch installed, -thus we only need to install MMCV and MMDetection with the following commands. +[Google Colab](https://research.google.com/) 通常已经完成了Pytorch的安装, +因此我们只需要按照以下步骤完成MMCV和MMDetection的安装即可。 -**Step 1.** Install [MMCV](https://github.com/open-mmlab/mmcv) and [MMDetection](https://github.com/open-mmlab/mmdetection) using [MIM](https://github.com/open-mmlab/mim). +**第一步:** 使用 [MIM](https://github.com/open-mmlab/mim) 安装 [MMCV](https://github.com/open-mmlab/mmcv) 和 [MMDetection](https://github.com/open-mmlab/mmdetection) : ```shell !pip3 install -U openmim @@ -153,7 +153,7 @@ thus we only need to install MMCV and MMDetection with the following commands. !mim install 'mmdet>=3.0.0rc2' ``` -**Step 2.** Install MMRotate from the source. +**第二步:** 从源码安装MMRotate: ```shell !git clone https://github.com/open-mmlab/mmrotate.git -b dev-1.x @@ -161,7 +161,7 @@ thus we only need to install MMCV and MMDetection with the following commands. !pip install -e . ``` -**Step 3.** Verification. +**第三步:** 验证安装是否正确 ```python import mmrotate @@ -170,12 +170,12 @@ print(mmrotate.__version__) ``` ```{note} -Within Jupyter, the exclamation mark `!` is used to call external executables and `%cd` is a [magic command](https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-cd) to change the current working directory of Python. +在Jupyter中,感叹号 `!` 用于调用外部可执行文件,而符号 `%cd` 是一个用于更改Python当前工作目录的 [魔术指令](https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-cd) 。 ``` -#### Using MMRotate with Docker +#### 使用Docker安装MMRotate -We provide a [Dockerfile](https://github.com/open-mmlab/mmrotate/tree/main/docker/Dockerfile) to build an image. Ensure that your [docker version](https://docs.docker.com/engine/install/) >=19.03. +我们同样提供了 [Dockerfile](https://github.com/open-mmlab/mmrotate/tree/main/docker/Dockerfile) 用于创建镜像。请确认您的 [docker version](https://docs.docker.com/engine/install/) >=19.03。 ```shell # build an image with PyTorch 1.6, CUDA 10.1 @@ -183,13 +183,12 @@ We provide a [Dockerfile](https://github.com/open-mmlab/mmrotate/tree/main/docke docker build -t mmrotate docker/ ``` -Run it with +然后运行以下指令: ```shell docker run --gpus all --shm-size=8g -it -v {DATA_DIR}:/mmrotate/data mmrotate ``` -### Trouble shooting +### 常见问题 -If you have some issues during the installation, please first view the [FAQ](faq.md) page. -You may [open an issue](https://github.com/open-mmlab/mmrotate/issues/new/choose) on GitHub if no solution is found. +如果您在安装的过程中遇到了一些困难,可以查询 [FAQ](faq.md) 页面。如果还是不能解决您的问题,您可以在github中 [提交Issue](https://github.com/open-mmlab/mmrotate/issues/new/choose) 。 diff --git a/mmrotate/datasets/transforms/transforms.py b/mmrotate/datasets/transforms/transforms.py index bde0ae819..141c42569 100644 --- a/mmrotate/datasets/transforms/transforms.py +++ b/mmrotate/datasets/transforms/transforms.py @@ -151,7 +151,8 @@ def _transform_bboxes(self, results: dict) -> None: def _filter_invalid(self, results: dict) -> None: """Filter invalid data w.r.t `gt_bboxes`""" - height, width = results['img_shape'] + # results['img_shape'] maybe (h,w,c) or (h,w) + height, width = results['img_shape'][:2] if 'gt_bboxes' in results: if len(results['gt_bboxes']) == 0: return diff --git a/mmrotate/models/backbones/re_resnet.py b/mmrotate/models/backbones/re_resnet.py index 083253fae..9208babbf 100644 --- a/mmrotate/models/backbones/re_resnet.py +++ b/mmrotate/models/backbones/re_resnet.py @@ -2,7 +2,6 @@ # Modified from csuhan: https://github.com/csuhan/ReDet from typing import Optional, Sequence, Tuple -import e2cnn.nn as enn import torch.nn as nn import torch.utils.checkpoint as cp from mmdet.utils import ConfigType, OptConfigType, OptMultiConfig @@ -11,12 +10,27 @@ from torch.nn.modules.batchnorm import _BatchNorm from mmrotate.registry import MODELS -from ..utils import (build_enn_divide_feature, build_enn_norm_layer, - build_enn_trivial_feature, ennAvgPool, ennConv, - ennMaxPool, ennReLU, ennTrivialConv) - -class BasicBlock(enn.EquivariantModule): +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) +except ImportError: + enn = None + build_enn_divide_feature = None + build_enn_norm_layer = None + build_enn_trivial_feature = None + ennAvgPool = None + ennConv = None + ennMaxPool = None + ennReLU = None + ennTrivialConv = None + EquivariantModule = BaseModule + + +class BasicBlock(EquivariantModule): """BasicBlock for ReResNet. Args: @@ -139,7 +153,7 @@ def evaluate_output_shape(self, input_shape: Sequence) -> Sequence: return input_shape -class Bottleneck(enn.EquivariantModule): +class Bottleneck(EquivariantModule): """Bottleneck block for ReResNet. Args: @@ -490,8 +504,14 @@ def __init__(self, zero_init_residual: bool = True, init_cfg: OptMultiConfig = None) -> None: super().__init__(init_cfg=init_cfg) - self.in_type = build_enn_trivial_feature(in_channels) + try: + import e2cnn # noqa: F401 + except ImportError: + raise ImportError( + 'Please install e2cnn by "pip install -e ' + 'git+https://github.com/QUVA-Lab/e2cnn.git#egg=e2cnn"') + self.in_type = build_enn_trivial_feature(in_channels) if depth not in self.arch_settings: raise KeyError(f'invalid depth {depth} for resnet') self.depth = depth diff --git a/mmrotate/models/necks/re_fpn.py b/mmrotate/models/necks/re_fpn.py index dfde8f871..d72e84e8b 100644 --- a/mmrotate/models/necks/re_fpn.py +++ b/mmrotate/models/necks/re_fpn.py @@ -3,18 +3,29 @@ import warnings from typing import List, Optional, Sequence, Tuple, Union -import e2cnn.nn as enn import torch.nn as nn from mmdet.utils import MultiConfig, OptConfigType from mmengine.model import BaseModule from torch import Tensor from mmrotate.registry import MODELS -from ..utils import (build_enn_feature, build_enn_norm_layer, ennConv, - ennInterpolate, ennMaxPool, ennReLU) - -class ConvModule(enn.EquivariantModule): +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: + build_enn_feature = None + build_enn_norm_layer = None + ennConv = None + ennInterpolate = None + ennMaxPool = None + ennReLU = None + EquivariantModule = BaseModule + + +class ConvModule(EquivariantModule): """ConvModule. Args: @@ -202,7 +213,12 @@ def __init__( init_cfg: MultiConfig = dict( type='Xavier', layer='Conv2d', distribution='uniform') ) -> None: - + try: + import e2cnn # noqa: F401 + except ImportError: + raise ImportError( + 'Please install e2cnn by "pip install -e ' + 'git+https://github.com/QUVA-Lab/e2cnn.git#egg=e2cnn"') super().__init__(init_cfg=init_cfg) assert isinstance(in_channels, list) self.in_channels = in_channels diff --git a/mmrotate/models/utils/__init__.py b/mmrotate/models/utils/__init__.py index 38d6ca85c..c5c8188d7 100644 --- a/mmrotate/models/utils/__init__.py +++ b/mmrotate/models/utils/__init__.py @@ -1,16 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -from .enn import (build_enn_divide_feature, build_enn_feature, - build_enn_norm_layer, build_enn_trivial_feature, ennAvgPool, - ennConv, ennInterpolate, ennMaxPool, ennReLU, ennTrivialConv) from .misc import (convex_overlaps, get_num_level_anchors_inside, levels_to_images, points_center_pts) from .orconv import ORConv2d from .ripool import RotationInvariantPooling __all__ = [ - 'ORConv2d', 'RotationInvariantPooling', 'ennConv', 'ennReLU', 'ennAvgPool', - 'ennMaxPool', 'ennInterpolate', 'build_enn_divide_feature', - 'build_enn_feature', 'build_enn_norm_layer', 'build_enn_trivial_feature', - 'ennTrivialConv', 'get_num_level_anchors_inside', 'points_center_pts', - 'levels_to_images', 'convex_overlaps' + 'ORConv2d', 'RotationInvariantPooling', 'get_num_level_anchors_inside', + 'points_center_pts', 'levels_to_images', 'convex_overlaps' ] diff --git a/mmrotate/models/utils/enn.py b/mmrotate/models/utils/enn.py index ddacbc04f..6726f19aa 100644 --- a/mmrotate/models/utils/enn.py +++ b/mmrotate/models/utils/enn.py @@ -1,5 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. -import e2cnn.nn as enn +try: + import e2cnn.nn as enn +except ImportError: + raise ImportError( + 'Please install e2cnn by ' + '"pip install -e git+https://github.com/QUVA-Lab/e2cnn.git#egg=e2cnn"') from e2cnn import gspaces N = 8 diff --git a/model-index.yml b/model-index.yml index d43633066..fea6a72f8 100644 --- a/model-index.yml +++ b/model-index.yml @@ -1,11 +1,15 @@ Import: - configs/cfa/metafile.yml + - configs/convnext/metafile.yml - configs/csl/metafile.yml - configs/gliding_vertex/metafile.yml - configs/gwd/metafile.yml + - configs/h2rbox/metafile.yml - configs/kfiou/metafile.yml - configs/kld/metafile.yml - configs/oriented_rcnn/metafile.yml + - configs/oriented_reppoints/metafile.yml + - configs/psc/metafile.yml - configs/r3det/metafile.yml - configs/redet/metafile.yml - configs/roi_trans/metafile.yml @@ -14,6 +18,6 @@ Import: - configs/rotated_fcos/metafile.yml - configs/rotated_reppoints/metafile.yml - configs/rotated_retinanet/metafile.yml + - configs/rotated_rtmdet/metafile.yml - configs/s2anet/metafile.yml - configs/sasm_reppoints/metafile.yml - - configs/psc/metafile.yml diff --git a/requirements/build.txt b/requirements/build.txt index ff8f1ae42..05c9412e0 100644 --- a/requirements/build.txt +++ b/requirements/build.txt @@ -1,3 +1,3 @@ # These must be installed before building mmrotate cython -numpy<1.24.0 +numpy diff --git a/requirements/runtime.txt b/requirements/runtime.txt index 40f9d586c..b0b1a7073 100644 --- a/requirements/runtime.txt +++ b/requirements/runtime.txt @@ -1,4 +1,3 @@ -e2cnn matplotlib numpy pycocotools diff --git a/requirements/tests.txt b/requirements/tests.txt index bc0badd52..e2f3ec935 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -2,7 +2,7 @@ asynctest codecov coverage cython -e2cnn +-e git+https://github.com/QUVA-Lab/e2cnn.git#egg=e2cnn flake8 interrogate isort==4.3.21 diff --git a/tests/test_models/test_backbones/test_re_resnet.py b/tests/test_models/test_backbones/test_re_resnet.py index ed2c6cc5c..e2948afd2 100644 --- a/tests/test_models/test_backbones/test_re_resnet.py +++ b/tests/test_models/test_backbones/test_re_resnet.py @@ -8,7 +8,7 @@ from mmrotate.models.backbones.re_resnet import (BasicBlock, Bottleneck, ReResNet, ResLayer) -from mmrotate.models.utils import build_enn_divide_feature +from mmrotate.models.utils.enn import build_enn_divide_feature def is_block(modules): diff --git a/tests/test_models/test_necks/test_re_fpn.py b/tests/test_models/test_necks/test_re_fpn.py index 8b6761069..324b42dc4 100644 --- a/tests/test_models/test_necks/test_re_fpn.py +++ b/tests/test_models/test_necks/test_re_fpn.py @@ -6,7 +6,7 @@ from torch.nn.modules.batchnorm import _BatchNorm from mmrotate.models.necks import ReFPN -from mmrotate.models.utils import build_enn_divide_feature +from mmrotate.models.utils.enn import build_enn_divide_feature class TestReFPN(TestCase):