MCPcopy Index your code
hub / github.com/SJTU-Thinklab-Det/r3det-pytorch

github.com/SJTU-Thinklab-Det/r3det-pytorch @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
345 symbols 968 edges 98 files 173 documented · 50%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

R3Det: Refined Single-Stage Detector with Feature Refinement for Rotating Object

License arXiv

News

2022.02.18 MMRotate: OpenMMLab Rotated Object Detection Benchmark was released!

Installation

# install mmdetection first if you haven't installed it yet. (Refer to mmdetection for details.)
pip install mmdet==2.19.0

# install r3det (Compiling rotated ops is a little time-consuming.)
pip install -r requirements.txt
pip install -v -e .

  • It is best to use opencv-python greater than 4.5.1 because its angle representation has been changed in 4.5.1. The following experiments are all run with 4.5.3.

Quick Start

Please change path in configs to your data path.

# train
CUDA_VISIBLE_DEVICES=0 PORT=29500 \
./tools/dist_train.sh configs/rretinanet/rretinanet_obb_r50_fpn_1x_dota_v3.py 1

# submission
CUDA_VISIBLE_DEVICES=0 PORT=29500 \
./tools/dist_test.sh configs/rretinanet/rretinanet_obb_r50_fpn_1x_dota_v3.py \
        work_dirs/rretinanet_obb_r50_fpn_1x_dota_v3/epoch_12.pth 1 --format-only\
        --eval-options submission_dir=work_dirs/rretinanet_obb_r50_fpn_1x_dota_v3/Task1_results

For DOTA dataset, please crop the original images into 1024×1024 patches with an overlap of 200 by run

python tools/split/img_split.py --base_json \
       tools/split/split_configs/dota1_0/ss_trainval.json

python tools/split/img_split.py --base_json \
       tools/split/split_configs/dota1_0/ss_test.json

Please change path in ss_trainval.json, ss_test.json to your path. (Forked from BboxToolkit, which is faster then DOTA_Devkit.)

Angle Representations

Three angle representations are built-in, which can freely switch in the config.

  • v1 (from R3Det): [-PI/2, 0)
  • v2 (from S2ANet): [-Pi/4, 3PI/4)
  • v3 (from OBBDetection): [-PI/2, PI/2)

The differences of the three angle representations are reflected in poly2obb, obb2poly, obb2xyxy, obb2hbb, hbb2obb, etc. [More], And according to the above three papers, the coders of them are different.

  • DeltaXYWHAOBBoxCoder
  • v1:None
  • v2:Constrained angle + Projection of dx and dy + Normalized with PI
  • v3:Constrained angle and length&width + Projection of dx and dy
  • DeltaXYWHAHBBoxCoder
  • v1:None
  • v2:Constrained angle + Normalized with PI
  • v3:Constrained angle and length&width + Normalized with 2PI

We believe that different coders are the key reason for the different baselines in different papers. The good news is that all the above coders can be freely switched in R3Det. In addition, R3Det also provide 4 NMS ops and 3 IoU_Calculators for rotation detection as follows:

  • nms.type
  • v1:v1
  • v2:v2
  • v3:v3
  • mmcv: mmcv
  • iou_calculator
  • v1:RBboxOverlaps2D_v1
  • v2:RBboxOverlaps2D_v2
  • v3:RBboxOverlaps2D_v3

Performance

DOTA1.0 (Task1)

Model Backbone Lr schd MS RR Angle box AP Official Download
RRetinaNet HBB R50-FPN 1x - - v1 65.19 65.73 Baidu:0518/Google
RRetinaNet OBB R50-FPN 1x - - v3 68.20 69.40 Baidu:0518/Google
RRetinaNet OBB R50-FPN 1x - - v2 68.64 68.40 Baidu:0518/Google
R3Det R50-FPN 1x - - v1 70.41 70.66 Baidu:0518/Google
R3Det* R50-FPN 1x - - v1 70.86 - Baidu:0518/Google
  • MS means multiple scale image split.
  • RR means random rotation.

Citation

@inproceedings{yang2021r3det,
    title={R3Det: Refined Single-Stage Detector with Feature Refinement for Rotating Object},
    author={Yang, Xue and Yan, Junchi and Feng, Ziming and He, Tao},
    booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
    volume={35},
    number={4},
    pages={3163--3171},
    year={2021}
}

Core symbols most depended-on inside this repo

dot
called by 9
r3det/ops/rnms/src/rcpu/rnms_cpu.cpp
make_cuda_ext
called by 8
setup.py
parse_requirements
called by 7
setup.py
cross
called by 6
r3det/ops/rnms/src/rcpu/rnms_cpu.cpp
cross
called by 6
r3det/ops/polygon_geo/src/polygon_geo_cpu.cpp
decode
called by 6
r3det/core/bbox/coder/delta_xywha_rbbox_coder.py
dot
called by 4
r3det/ops/polygon_geo/src/polygon_geo_cpu.cpp
obb2poly_np
called by 4
r3det/core/bbox/rtransforms.py

Shape

Function 194
Method 119
Class 32

Languages

Python70%
C++30%

Modules by API surface

r3det/core/bbox/rtransforms.py36 symbols
r3det/ops/polygon_geo/src/polygon_geo_cpu.cpp20 symbols
r3det/ops/rnms/src/rcpu/rnms_cpu.cpp19 symbols
r3det/datasets/dota1.py16 symbols
r3det/datasets/pipelines/rtransforms.py15 symbols
tools/split/img_split.py14 symbols
r3det/ops/nms_rotated/src/box_iou_rotated_utils.h13 symbols
r3det/ops/ml_nms_rotated/src/box_iou_rotated_utils.h13 symbols
r3det/ops/box_iou_rotated/src/box_iou_rotated_utils.h13 symbols
r3det/models/dense_heads/rotate_anchor_head.py13 symbols
r3det/ops/fr/feature_refine_module.py12 symbols
r3det/core/bbox/iou_calculators/rotate_iou2d_calculator.py12 symbols

For agents

$ claude mcp add r3det-pytorch \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page