Home

Awesome

AlphaRotate: A Rotation Detection Benchmark using TensorFlow

Documentation Status PyPI Downloads License Average time to resolve an issue Percentage of issues still open

<!-- Documentation: [https://rotationdetection.readthedocs.io/](https://rotationdetection.readthedocs.io/) --> <!-- :rocket::rocket::rocket: **News:** The MMDetection version cooperating with MMLab will be released soon, stay tuned.:rocket::rocket::rocket: -->

:rocket::rocket::rocket: News: MMRotate has been released at https://github.com/open-mmlab/mmrotate <img src="https://img.shields.io/github/stars/open-mmlab/mmrotate?style=social" /> :rocket::rocket::rocket:

Abstract

AlphaRotate is mainly maintained by Xue Yang with Shanghai Jiao Tong University supervised by Prof. Junchi Yan.

Papers and codes related to remote sensing/aerial image detection: DOTA-DOAI <img src="https://img.shields.io/github/stars/SJTU-Thinklab-Det/DOTA-DOAI?style=social" />.

Techniques:

The above-mentioned rotation detectors are all modified based on the following horizontal detectors:

3

Projects

0

Latest Performance

<!-- More results and trained models are available in the [MODEL_ZOO.md](MODEL_ZOO.md). -->

DOTA (Task1)

Baseline

BackboneNeckTraining/test datasetData AugmentationEpochNMS
ResNet50_v1d 600->800FPNtrainval/test×13 (AP50) or 17 (AP50:95) is enough for baseline (default is 13)gpu nms (slightly worse <1% than cpu nms but faster)
MethodBaselineDOTA1.0DOTA1.5DOTA2.0ModelAnchorAngle Pred.Reg. LossAngle RangeConfigs
-RetinaNet-R67.2556.5042.04Baidu Drive (bi8b)RReg. (∆⍬)smooth L1[-90,0)dota1.0, dota1.5, dota2.0
-RetinaNet-H64.1756.1043.06Baidu Drive (bi8b)HReg. (∆⍬)smooth L1[-90,90)dota1.0, dota1.5, dota2.0
-RetinaNet-H65.3357.2144.58Baidu Drive (bi8b)HReg. (sin⍬, cos⍬)smooth L1[-90,90)dota1.0, dota1.5, dota2.0
-RetinaNet-H65.7358.8744.16Baidu Drive (bi8b)HReg. (∆⍬)smooth L1[-90,0)dota1.0, dota1.5, dota2.0
IoU-Smooth L1RetinaNet-H66.9959.1746.31Baidu Drive (qcvc)HReg. (∆⍬)iou-smooth L1[-90,0)dota1.0, dota1.5, dota2.0
RIDetRetinaNet-H66.0658.9145.35Baidu Drive (njjv)HQuad.hungarian loss-dota1.0, dota1.5, dota2.0
RSDetRetinaNet-H67.2761.4246.71Baidu Drive (2a1f)HQuad.modulated loss-dota1.0, dota1.5, dota2.0
CSLRetinaNet-H67.3858.5543.34Baidu Drive (sdbb)HCls.: Gaussian (r=1, w=10)smooth L1[-90,90)dota1.0, dota1.5, dota2.0
DCLRetinaNet-H67.3959.3845.46Baidu Drive (m7pq)HCls.: BCL (w=180/256)smooth L1[-90,90)dota1.0, dota1.5, dota2.0
-FCOS67.6961.0548.10Baidu Drive (pic4)-Quadsmooth L1-dota1.0, dota1.5, dota2.0
RSDet++FCOS67.9162.1848.81Baidu Drive (8ww5)-Quadmodulated loss-dota1.0, dota1.5 dota2.0
GWDRetinaNet-H68.9360.0346.65Baidu Drive (7g5a)HReg. (∆⍬)gwd[-90,0)dota1.0, dota1.5, dota2.0
GWD + SWARetinaNet-H69.9260.6047.63Baidu Drive (qcn0)HReg. (∆⍬)gwd[-90,0)dota1.0, dota1.5, dota2.0
BCDRetinaNet-H71.2360.7847.48Baidu Drive (0puk)HReg. (∆⍬)bcd[-90,0)dota1.0, dota1.5, dota2.0
KLDRetinaNet-H71.2862.5047.69Baidu Drive (o6rv)HReg. (∆⍬)kld[-90,0)dota1.0, dota1.5, dota2.0
KFIoURetinaNet-H70.6462.7148.04Baidu Drive (o72o)HReg. (∆⍬)kfiou[-90,0)dota1.0, dota1.5, dota2.0
KFIoU<sup>*</sup>RetinaNet-H71.60-48.94Baidu Drive (o72o)HReg. (∆⍬)kfiou[-90,0)dota1.0, dota2.0
R<sup>3</sup>DetRetinaNet-H70.6662.9148.43Baidu Drive (n9mv)H->RReg. (∆⍬)smooth L1[-90,0)dota1.0, dota1.5, dota2.0
DCLR<sup>3</sup>Det71.2161.9848.71Baidu Drive (eg2s)H->RCls.: BCL (w=180/256)iou-smooth L1[-90,0)->[-90,90)dota1.0, dota1.5, dota2.0
GWDR<sup>3</sup>Det71.5663.2249.25Baidu Drive (jb6e)H->RReg. (∆⍬)smooth L1->gwd[-90,0)dota1.0, dota1.5, dota2.0
BCDR<sup>3</sup>Det72.2263.5349.71Baidu Drive (v60g)H->RReg. (∆⍬)bcd[-90,0)dota1.0, dota1.5, dota2.0
KLDR<sup>3</sup>Det71.7365.1850.90Baidu Drive (tq7f)H->RReg. (∆⍬)kld[-90,0)dota1.0, dota1.5, dota2.0
KFIoUR<sup>3</sup>Det72.2864.6950.41Baidu Drive (u77v)H->RReg. (∆⍬)kfiou[-90,0)dota1.0, dota1.5, dota2.0
-R<sup>2</sup>CNN (Faster-RCNN)72.2766.4552.35Baidu Drive (02s5)H->RReg. (∆⍬)smooth L1[-90,0)dota1.0, dota1.5 dota2.0

SOTA

MethodBackboneDOTA1.0ModelMSData AugmentationEpochConfigs
R<sup>2</sup>CNN-BCDResNet152_v1d-FPN79.54Baidu Drive (h2u1)34dota1.0
RetinaNet-BCDResNet152_v1d-FPN78.52Baidu Drive (0puk)51dota1.0
R<sup>3</sup>Det-BCDResNet50_v1d-FPN79.08Baidu Drive (v60g)51dota1.0
R<sup>3</sup>Det-BCDResNet152_v1d-FPN79.95Baidu Drive (v60g)51dota1.0

Note:

My Development Environment

Installation

Manual configuration (cuda version < 11)

pip install -r requirements.txt
pip install -v -e .  # or "python setup.py develop"

Or, you can simply install AlphaRotate with the following command:

pip install alpharotate  # Not suitable for dev.

Docker (cuda version < 11)

docker images: yangxue2docker/yx-tf-det:tensorflow1.13.1-cuda10-gpu-py3

Note: For 30xx series graphics cards (cuda version >= 11), I recommend this blog to install tf1.xx, or download image from tensorflow-release-notes according to your development environment, e.g. nvcr.io/nvidia/tensorflow:20.11-tf1-py3

cd alpharotate/libs/utils/cython_utils
rm *.so
rm *.c
rm *.cpp
python setup.py build_ext --inplace (or make)

cd alpharotate/libs/utils/
rm *.so
rm *.c
rm *.cpp
python setup.py build_ext --inplace

Download Model

Pretrain weights

Download a pretrain weight you need from the following three options, and then put it to $PATH_ROOT/dataloader/pretrained_weights.

  1. MxNet pretrain weights (recommend in this repo, default in NET_NAME): resnet_v1d, resnet_v1b, refer to gluon2TF.
  1. Tensorflow pretrain weights: resnet50_v1, resnet101_v1, resnet152_v1, efficientnet, mobilenet_v2, darknet53 (Baidu Drive (1jg2), Google Drive).
  2. PyTorch pretrain weights, refer to pretrain_zoo.py and Others.

Trained weights

  1. Please download trained models by this project, then put them to $PATH_ROOT/output/pretained_weights.

Train

  1. If you want to train your own dataset, please note:

    (1) Select the detector and dataset you want to use, and mark them as #DETECTOR and #DATASET (such as #DETECTOR=retinanet and #DATASET=DOTA)
    (2) Modify parameters (such as CLASS_NUM, DATASET_NAME, VERSION, etc.) in $PATH_ROO./configs/#DATASET/#DETECTOR/cfgs_xxx.py
    (3) Copy $PATH_ROO./configs/#DATASET/#DETECTOR/cfgs_xxx.py to $PATH_ROO./configs/cfgs.py
    (4) Add category information in $PATH_ROOT/libs/label_name_dict/label_dict.py     
    (5) Add data_name to $PATH_ROOT/dataloader/dataset/read_tfrecord.py  
    
  2. Make tfrecord
    If image is very large (such as DOTA dataset), the image needs to be cropped. Take DOTA dataset as a example:

    cd $PATH_ROOT/dataloader/dataset/DOTA
    python data_crop.py
    

    If image does not need to be cropped, just convert the annotation file into xml format, refer to example.xml.

    cd $PATH_ROOT/dataloader/dataset/  
    python convert_data_to_tfrecord.py --root_dir='/PATH/TO/DOTA/' 
                                       --xml_dir='labeltxt'
                                       --image_dir='images'
                                       --save_name='train' 
                                       --img_format='.png' 
                                       --dataset='DOTA'
    
  3. Start training

    cd $PATH_ROOT/tools/#DETECTOR
    python train.py
    

Test

  1. For large-scale image, take DOTA dataset as a example (the output file or visualization is in $PATH_ROOT/tools/#DETECTOR/test_dota/VERSION):

    cd $PATH_ROOT/tools/#DETECTOR
    python test_dota.py --test_dir='/PATH/TO/IMAGES/'  
                        --gpus=0,1,2,3,4,5,6,7  
                        -ms (multi-scale testing, optional)
                        -s (visualization, optional)
    
    or (recommend in this repo, better than multi-scale testing)
    
    python test_dota_sota.py --test_dir='/PATH/TO/IMAGES/'  
                             --gpus=0,1,2,3,4,5,6,7  
                             -s (visualization, optional)
    

    Notice: In order to set the breakpoint conveniently, the read and write mode of the file is' a+'. If the model of the same #VERSION needs to be tested again, the original test results need to be deleted.

  2. For small-scale image, take HRSC2016 dataset as a example:

    cd $PATH_ROOT/tools/#DETECTOR
    python test_hrsc2016.py --test_dir='/PATH/TO/IMAGES/'  
                            --gpu=0
                            --image_ext='bmp'
                            --test_annotation_path='/PATH/TO/ANNOTATIONS'
                            -s (visualization, optional)
    

Tensorboard

cd $PATH_ROOT/output/summary
tensorboard --logdir=.

1

2

Citation

If you find our code useful for your research, please consider cite.

@article{yang2021alpharotate,
    author  = {Yang, Xue and Zhou, Yue and Yan, Junchi},
    title   = {AlphaRotate: A Rotation Detection Benchmark using TensorFlow},
    journal = {arXiv preprint arXiv:2111.06677},
    year    = {2021},
}

Reference

1、https://github.com/endernewton/tf-faster-rcnn
2、https://github.com/zengarden/light_head_rcnn
3、https://github.com/tensorflow/models/tree/master/research/object_detection
4、https://github.com/fizyr/keras-retinanet