Giter Club home page Giter Club logo

s2anet's Introduction

Align Deep Features for Oriented Object Detection

Align Deep Features for Oriented Object Detection,
Jiaming Han*, Jian Ding*, Jie Li, Gui-Song Xia,
arXiv preprint (arXiv:2008.09397) / TGRS (IEEE Xplore).

The repo is based on mmdetection.

Two versions are provided here: Original version and v20210104. We recommend to use v20210104 (i.e. the master branch).

Introduction

The past decade has witnessed significant progress on detecting objects in aerial images that are often distributed with large scale variations and arbitrary orientations. However most of existing methods rely on heuristically defined anchors with different scales, angles and aspect ratios and usually suffer from severe misalignment between anchor boxes and axis-aligned convolutional features, which leads to the common inconsistency between the classification score and localization accuracy. To address this issue, we propose a Single-shot Alignment Network (S2A-Net) consisting of two modules: a Feature Alignment Module (FAM) and an Oriented Detection Module (ODM). The FAM can generate high-quality anchors with an Anchor Refinement Network and adaptively align the convolutional features according to the corresponding anchor boxes with a novel Alignment Convolution. The ODM first adopts active rotating filters to encode the orientation information and then produces orientation-sensitive and orientation-invariant features to alleviate the inconsistency between classification score and localization accuracy. Besides, we further explore the approach to detect objects in large-size images, which leads to a better speed-accuracy trade-off. Extensive experiments demonstrate that our method can achieve state-of-the-art performance on two commonly used aerial objects datasets (i.e., DOTA and HRSC2016) while keeping high efficiency.

Changelog

  • 2021-09019. @khiemauto updates S2A-Net with Pytorch1.9 support! See the pytorch1.9 branch for more details.

  • 2021-08-04. Another third-party implementation with Jittor and JDet.

  • 2021-06-03. Docker support. See install.md.

  • 2021-04-29. Third-party implementation with PaddleDetection.

  • 2021-04-10. Rotated IoU Loss is added that further boosts the performance.

  • 2021-03-13. Our paper is available at IEEE Xplore.

  • 2021-02-06. Accepted to IEEE Transactions on Geoscience and Remote Sensing (TGRS).

  • 2021-01-01. Big changes! Following mmdetection v2, we made a lot of changes to our code. Our original code contains many unnecessary functions and inappropriate modifications. So we modified related codes, e.g, dataset preprocessing and loading, unified function names, iou calculator between OBBs, and evaluation. Besides, we also implement a Cascade S2A-Net. Compared with previous versions, the updated version is more straightforward and easy to understand.

Benchmark and model zoo

Model Backbone MS Rotate Lr schd Inf time (fps) box AP (ori./now) Download
RetinaNet R-50-FPN - - 1x 16.0 68.05/68.40 model
S2A-Net R-50-FPN - - 1x 16.0 74.12/73.99 model
S2A-Net R-50-FPN 1x 16.0 79.42 model
S2A-Net R-101-FPN 1x 12.7 79.15 model

*Note that the mAP reported here is a little different from the original paper. All results are reported on DOTA-v1.0 test set. All checkpoints here are trained with the Original version, and not compatible with the updated version.

  • 20210104 updated version
Model Data Backbone MS Rotate Lr schd box AP Download
RetinaNet HRSC2016 R-50-FPN - 6x 81.63 cfg model log
CS2A-Net-1s HRSC2016 R-50-FPN - 4x 84.58 cfg model log
CS2A-Net-2s HRSC2016 R-50-FPN - 3x 89.96 cfg model log
S2A-Net HRSC2016 R-101-FPN - 3x 90.00 cfg model
CS2A-Net-1s DOTA R-50-FPN - - 1x 69.06 cfg model log
CS2A-Net-2s DOTA R-50-FPN - - 1x 73.67 cfg model log
S2A-Net DOTA R-50-FPN - - 1x 74.04 cfg model
CS2A-Net-2s-IoU DOTA R-50-FPN - - 1x 74.58 cfg model log

Note:

  1. All models are trained on 4 GPUs with a initial learning rate 0.01. If you train the model with fewer/more GPUs, remember to change the lr, e.g., 0.01lr=0.0025lr*4GPU, 0.0025lr=0.0025lr*1GPU, 0.02lr=0.0025lr*8GPU

  2. CS2A-Net-ns indicates Cascade S2A-Net with n stages. For more information, please refer to CASCADE_S2ANET.md

  3. IoU means IoU Loss for bbox regression.

  4. The checkpoints of S2A-Net are converted from the original version.

  5. If you cannot get access to Google Drive, BaiduYun download link can be found here with extracting code ABCD.

Installation

Please refer to install.md for installation and dataset preparation.

Getting Started

Please see getting_started.md for the basic usage of MMDetection.

Citation

@article{han2021align,  
  author={J. {Han} and J. {Ding} and J. {Li} and G. -S. {Xia}},  
  journal={IEEE Transactions on Geoscience and Remote Sensing},   
  title={Align Deep Features for Oriented Object Detection},   
  year={2021}, 
  pages={1-11},  
  doi={10.1109/TGRS.2021.3062048}}

@inproceedings{xia2018dota,
  title={DOTA: A large-scale dataset for object detection in aerial images},
  author={Xia, Gui-Song and Bai, Xiang and Ding, Jian and Zhu, Zhen and Belongie, Serge and Luo, Jiebo and Datcu, Mihai and Pelillo, Marcello and Zhang, Liangpei},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
  pages={3974--3983},
  year={2018}
}

@InProceedings{Ding_2019_CVPR,
  author = {Ding, Jian and Xue, Nan and Long, Yang and Xia, Gui-Song and Lu, Qikai},
  title = {Learning RoI Transformer for Oriented Object Detection in Aerial Images},
  booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
  month = {June},
  year = {2019}
}

@article{chen2019mmdetection,
  title={MMDetection: Open mmlab detection toolbox and benchmark},
  author={Chen, Kai and Wang, Jiaqi and Pang, Jiangmiao and Cao, Yuhang and Xiong, Yu and Li, Xiaoxiao and Sun, Shuyang and Feng, Wansen and Liu, Ziwei and Xu, Jiarui and others},
  journal={arXiv preprint arXiv:1906.07155},
  year={2019}
}

s2anet's People

Contributors

csuhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

s2anet's Issues

AP计算

您好,关于mAP的计算,是使用旋转框的iou计算的吗?可以告知一下是哪个文件吗?我只您的文件中找到了适用于用(K ,4)这种形式的ap计算。

AssertionError

when I run python tools/test.py configs/dota/s2anet_r50_fpn_1x.py /home/lichenglong/s2anet/configs/dota/s2anet_r50_fpn_1x_ms_rotate_epoch_12_20200815.pth --out /home/lichenglong/s2anet/work_dirs/s2anet_r50_fpn_1x/res.pkl --show
there is an AssertionError : assert bboxes.shape[1] == 4 or bboxes.shape[1] == 5
the details are as follows:
image
Is there anyone who has also encountered the same problem?I need for your help,tanks!

--show problem

dear author:
can you help me to solve this prolem? whether i can directly get the visiual result by this command?
CUDA_VISIBLE_DEVICES=1 python tools/test.py configs/dota/s2anet_r101_fpn_1x_ms_rotate.py yzk_work_dirs/s2anet_r101_fpn_1x_ms_rotate/epoch_12.pth --show

when i run it ,it occurs error.
image
hope for your reply.i want to apply this detection project on real-time detection,if i can do it?thanks for your reply and directions.

undefined symbol: _ZN3c1011CPUTensorIdEv

您好,请问这个问题怎么解决阿, 谢谢:
Traceback (most recent call last):
File "tools/test.py", line 15, in
from mmdet.apis import init_dist
File "/home/wen/Documents/HJJ/s2anet/mmdet/apis/init.py", line 2, in
from .inference import (inference_detector, init_detector, show_result,
File "/home/wen/Documents/HJJ/s2anet/mmdet/apis/inference.py", line 11, in
from mmdet.core import get_classes
File "/home/wen/Documents/HJJ/s2anet/mmdet/core/init.py", line 1, in
from .anchor import * # noqa: F401, F403
File "/home/wen/Documents/HJJ/s2anet/mmdet/core/anchor/init.py", line 2, in
from .anchor_target import anchor_inside_flags, anchor_target, unmap, images_to_levels
File "/home/wen/Documents/HJJ/s2anet/mmdet/core/anchor/anchor_target.py", line 3, in
from ..bbox import PseudoSampler, assign_and_sample, bbox2delta, build_assigner
File "/home/wen/Documents/HJJ/s2anet/mmdet/core/bbox/init.py", line 1, in
from .assigners import AssignResult, BaseAssigner, MaxIoUAssigner
File "/home/wen/Documents/HJJ/s2anet/mmdet/core/bbox/assigners/init.py", line 1, in
from .approx_max_iou_assigner import ApproxMaxIoUAssigner
File "/home/wen/Documents/HJJ/s2anet/mmdet/core/bbox/assigners/approx_max_iou_assigner.py", line 3, in
from ..geometry import bbox_overlaps
File "/home/wen/Documents/HJJ/s2anet/mmdet/core/bbox/geometry.py", line 3, in
from mmdet.ops.box_iou_rotated import box_iou_rotated
File "/home/wen/Documents/HJJ/s2anet/mmdet/ops/init.py", line 2, in
from .dcn import (DeformConv, DeformConvPack, DeformRoIPooling,
File "/home/wen/Documents/HJJ/s2anet/mmdet/ops/dcn/init.py", line 1, in
from .deform_conv import (DeformConv, DeformConvPack, ModulatedDeformConv,
File "/home/wen/Documents/HJJ/s2anet/mmdet/ops/dcn/deform_conv.py", line 10, in
from . import deform_conv_cuda
ImportError: /home/wen/Documents/HJJ/s2anet/mmdet/ops/dcn/deform_conv_cuda.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN3c1011CPUTensorIdEv

Something went wrong when I was training my own dataset.

Traceback (most recent call last):
  File "./train.py", line 108, in <module>
    main()
  File "./train.py", line 104, in main
    logger=logger)
  File "/home/spsv/Codes/lph/hjj/s2anet/mmdet/apis/train.py", line 58, in train_detector
    _dist_train(model, dataset, cfg, validate=validate)
  File "/home/spsv/Codes/lph/hjj/s2anet/mmdet/apis/train.py", line 192, in _dist_train
    runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
  File "/home/spsv/miniconda3/envs/s2anet/lib/python3.7/site-packages/mmcv/runner/runner.py", line 358, in run
    epoch_runner(data_loaders[i], **kwargs)
  File "/home/spsv/miniconda3/envs/s2anet/lib/python3.7/site-packages/mmcv/runner/runner.py", line 274, in train
    self.call_hook('after_train_epoch')
  File "/home/spsv/miniconda3/envs/s2anet/lib/python3.7/site-packages/mmcv/runner/runner.py", line 229, in call_hook
    getattr(hook, fn_name)(self)
  File "/home/spsv/Codes/lph/hjj/s2anet/mmdet/core/evaluation/eval_hooks.py", line 64, in after_train_epoch
    self.evaluate(runner, results)
  File "/home/spsv/Codes/lph/hjj/s2anet/mmdet/core/evaluation/eval_hooks.py", line 92, in evaluate
    bboxes = np.vstack([bboxes, ann['bboxes_ignore']])
  File "<__array_function__ internals>", line 6, in vstack
  File "/home/spsv/miniconda3/envs/s2anet/lib/python3.7/site-packages/numpy/core/shape_base.py", line 283, in vstack
    return _nx.concatenate(arrs, 0)
  File "<__array_function__ internals>", line 6, in concatenate
ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 5 and the array at index 1 has size 0
Traceback (most recent call last):
  File "/home/spsv/miniconda3/envs/s2anet/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/spsv/miniconda3/envs/s2anet/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/spsv/miniconda3/envs/s2anet/lib/python3.7/site-packages/torch/distributed/launch.py", line 253, in <module>
    main()
  File "/home/spsv/miniconda3/envs/s2anet/lib/python3.7/site-packages/torch/distributed/launch.py", line 249, in main
    cmd=cmd)
subprocess.CalledProcessError: Command '['/home/spsv/miniconda3/envs/s2anet/bin/python', '-u', './train.py', '--local_rank=3', '/home/spsv/Codes/lph/hjj/s2anet/configs/dota/hjj.py', '--launcher', 'pytorch', '--validate']' returned non-zero exit status 1.

What should I do to fix this problem?

question request

python tools/test.py configs/dota/s2anet_r50_fpn_1x.py
work_dirs/s2anet_r50_fpn_1x/epoch_12.pth \
--out work_dirs/ s2anet_r50_fpn_1x/res.pkl
how to make res.pkl?

MultiScale config in config file

Hi! this is a nice work. the best result in your paper is trained and tested by multiscale, but in your DOTA config file all the train and test pipeline is simple scale. So what is your multiscale train and test config? Thank you
image
image

Some questions about s2anet in other dataset

S2anet has good performance in DOTA and HRSC, but when I use s2anet in other data sets, such as DIOR, it has many Fasle Positives. The loss is about 0.3-0.4 and cannot be reduced. Do you have any suggestions?
The config file

`
model = dict(
type='S2ANetDetector',
pretrained='torchvision://resnet101',
backbone=dict(
type='ResNet',
depth=101,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
style='pytorch'),
neck=dict(
type='FPN',
in_channels=[256, 512, 1024, 2048],
out_channels=256,
start_level=1,
add_extra_convs=True,
num_outs=5),
rbox_head=dict(
type='S2ANetHead',
num_classes=6,
in_channels=256,
feat_channels=256,
stacked_convs=2,
align_conv_type='AlignConv',#[AlignConv,DCN,GA_DCN]
align_conv_size=3,
with_orconv=True,
anchor_ratios=[1.0],
anchor_strides=[8, 16, 32, 64, 128],
anchor_scales=[4],
target_means=[.0, .0, .0, .0, .0],
target_stds=[1.0, 1.0, 1.0, 1.0, 1.0],
loss_fam_cls=dict(
type='FocalLoss',
use_sigmoid=True,
gamma=2.0,
alpha=0.25,
loss_weight=1.0),
loss_fam_bbox=dict(
type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0),
loss_odm_cls=dict(
type='FocalLoss',
use_sigmoid=True,
gamma=2.0,
alpha=0.25,
loss_weight=1.0),
loss_odm_bbox=dict(
type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0)))

train_cfg = dict(
fam_cfg=dict(
anchor_target_type='hbb_obb_rbox_overlap',
assigner=dict(
type='MaxIoUAssignerRbox',
pos_iou_thr=0.5,
neg_iou_thr=0.4,
min_pos_iou=0,
ignore_iof_thr=-1),
allowed_border=-1,
pos_weight=-1,
debug=False),
odm_cfg=dict(
anchor_target_type='obb_obb_rbox_overlap',
anchor_inside_type='center',
assigner=dict(
type='MaxIoUAssignerRbox',
pos_iou_thr=0.5,
neg_iou_thr=0.4,
min_pos_iou=0,
ignore_iof_thr=-1),
allowed_border=-1,
pos_weight=-1,
debug=False))
test_cfg = dict(nms_pre=2000, min_bbox_size=0, score_thr=0.1, nms=dict(type='nms_rotated', iou_thr=0.1), max_per_img=2000)
dataset_type = 'DIORDataset'
data_root = 'data/contest/'
img_norm_cfg = dict(
mean=[65.288, 76.517, 74.574], std=[54.247, 48.163, 46.390], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True),
dict(type='RotatedResize', img_scale=(1024, 1024), keep_ratio=True),
dict(type='RotatedRandomFlip', flip_ratio=0.5),
dict(type='RandomRotate', rate=0.5, angles=[30, 60, 90, 120, 150], auto_bound=False),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(1024, 1024),
flip=False,
transforms=[
dict(type='RotatedResize', img_scale=(1024, 1024), keep_ratio=True),
dict(type='RotatedRandomFlip'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img']),
])
]
data = dict(
imgs_per_gpu=4,
workers_per_gpu=2,
train=dict(
type=dataset_type,
ann_file=data_root + 'trainval_patch_s2a.json',
img_prefix=data_root + '/images',
pipeline=train_pipeline),
val=dict(
type=dataset_type,
ann_file=data_root + 'trainval_patch_s2a.json',
img_prefix=data_root + '/images',
pipeline=test_pipeline),
test=dict(
type=dataset_type,
ann_file=data_root + 'test.json',
img_prefix=data_root + '/images',
pipeline=test_pipeline))

optimizer

optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001)
optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2))

learning policy

lr_config = dict(
policy='step',
warmup='linear',
warmup_iters=500,
warmup_ratio=1.0 / 3,
step=[40, 45])
checkpoint_config = dict(interval=1)

yapf:disable

log_config = dict(
interval=50,
hooks=[
dict(type='TextLoggerHook'),
# dict(type='TensorboardLoggerHook')
])

yapf:enable

runtime settings

total_epochs = 50
dist_params = dict(backend='nccl')
log_level = 'INFO'
work_dir = './works_dirs/s2anet_r101_dota/'
load_from = '.cache/torch/checkpoints/s2anet_r101_fpn_1x_ms_rotate_epoch_12_20200815.pth'
resume_from = None
workflow = [('train', 1)]
It trained in 50 epoch
{"mode": "train", "epoch": 50, "iter": 50, "lr": 0.0001, "time": 0.86242, "data_time": 0.02099, "memory": 8990, "loss_fam_cls": 0.15524, "loss_fam_bbox": 0.07553, "loss_odm_cls": 0.04947, "loss_odm_bbox": 0.0558, "loss": 0.33603}
{"mode": "train", "epoch": 50, "iter": 100, "lr": 0.0001, "time": 0.8468, "data_time": 0.01285, "memory": 8990, "loss_fam_cls": 0.15316, "loss_fam_bbox": 0.06564, "loss_odm_cls": 0.04806, "loss_odm_bbox": 0.05529, "loss": 0.32216}
{"mode": "train", "epoch": 50, "iter": 150, "lr": 0.0001, "time": 0.85156, "data_time": 0.0137, "memory": 8990, "loss_fam_cls": 0.15407, "loss_fam_bbox": 0.07925, "loss_odm_cls": 0.04821, "loss_odm_bbox": 0.05632, "loss": 0.33786}
{"mode": "train", "epoch": 50, "iter": 200, "lr": 0.0001, "time": 0.85856, "data_time": 0.01323, "memory": 8990, "loss_fam_cls": 0.14702, "loss_fam_bbox": 0.07098, "loss_odm_cls": 0.04571, "loss_odm_bbox": 0.05816, "loss": 0.32187}
{"mode": "train", "epoch": 50, "iter": 250, "lr": 0.0001, "time": 0.84088, "data_time": 0.01274, "memory": 8990, "loss_fam_cls": 0.16415, "loss_fam_bbox": 0.06529, "loss_odm_cls": 0.05354, "loss_odm_bbox": 0.05491, "loss": 0.33789}
{"mode": "train", "epoch": 50, "iter": 300, "lr": 0.0001, "time": 0.83431, "data_time": 0.01131, "memory": 8990, "loss_fam_cls": 0.16803, "loss_fam_bbox": 0.09001, "loss_odm_cls": 0.05105, "loss_odm_bbox": 0.05975, "loss": 0.36885}
{"mode": "train", "epoch": 50, "iter": 350, "lr": 0.0001, "time": 0.84979, "data_time": 0.01281, "memory": 8990, "loss_fam_cls": 0.14657, "loss_fam_bbox": 0.07459, "loss_odm_cls": 0.04058, "loss_odm_bbox": 0.05461, "loss": 0.31635}
{"mode": "train", "epoch": 50, "iter": 400, "lr": 0.0001, "time": 0.85282, "data_time": 0.01256, "memory": 8990, "loss_fam_cls": 0.14932, "loss_fam_bbox": 0.08008, "loss_odm_cls": 0.04741, "loss_odm_bbox": 0.06068, "loss": 0.33749}
{"mode": "train", "epoch": 50, "iter": 450, "lr": 0.0001, "time": 0.84619, "data_time": 0.01359, "memory": 8990, "loss_fam_cls": 0.14492, "loss_fam_bbox": 0.06747, "loss_odm_cls": 0.05152, "loss_odm_bbox": 0.056, "loss": 0.3199}
{"mode": "train", "epoch": 50, "iter": 500, "lr": 0.0001, "time": 0.84169, "data_time": 0.01221, "memory": 8990, "loss_fam_cls": 0.14924, "loss_fam_bbox": 0.06251, "loss_odm_cls": 0.04694, "loss_odm_bbox": 0.04926, "loss": 0.30795}
{"mode": "train", "epoch": 50, "iter": 550, "lr": 0.0001, "time": 0.84714, "data_time": 0.01283, "memory": 8990, "loss_fam_cls": 0.16291, "loss_fam_bbox": 0.08238, "loss_odm_cls": 0.05405, "loss_odm_bbox": 0.05899, "loss": 0.35833}
{"mode": "train", "epoch": 50, "iter": 600, "lr": 0.0001, "time": 0.84862, "data_time": 0.01286, "memory": 8990, "loss_fam_cls": 0.15531, "loss_fam_bbox": 0.06335, "loss_odm_cls": 0.05805, "loss_odm_bbox": 0.05274, "loss": 0.32945}
{"mode": "train", "epoch": 50, "iter": 650, "lr": 0.0001, "time": 0.84977, "data_time": 0.01135, "memory": 8990, "loss_fam_cls": 0.14908, "loss_fam_bbox": 0.07171, "loss_odm_cls": 0.04623, "loss_odm_bbox": 0.05798, "loss": 0.325}

`

Is there any problem with the rotated rectangle representation?

Hello, thank you for your excellent work.
I have achieved good performance on HRSC2016 with your implementation by adding an extra anchor refinement module(Refined-RetinaNet), but there are many redundant boxes in the detection results. I don't know whether it is caused by your rbox representation. And this may be the reason for the poor performance achieved by RetinaNet here?
In addition, I implemented a retinanet for polygon prediction, and there are still many redundant rotated boxes with high-confidence . Does the problem come from the data loader?
100001048
100001410
100000763
100001180

Question about how ARF works

Hello,
In the arxiv manuscript, I do not understand how ARF works

  1. EQ 5 the Y is calculated as the ARF output, but in EQ 6 the x\hat is the pooled output. Is this x\hat supposed to be y\hat or I misunderstood it?

  2. It seems like the ARF is trying to rotate a kernel and compute how the feature map matching different orientation of this filter. If one filter response is high it means the local feature is highly possible aligned in this direction. Am I getting this correctly? Then why should we sum up the output like eq5, rather than keep them in different channels and find the maximum?

  3. For EQ.5 when the F rotates, it is misaligned with X. How to compute eq5. By interpolation?

4.I don't understand why 256 channel feature map will become 32 channel feature map after pooling. Could you explain it?

I think my problems are somewhat related. Maybe I missed some fundamental knowledge in NN.

Thanks for your time and contribution!

the size of the gt_bboxes and the gt_labels is inconsistent

hey,
when I try to modify some code ,and print the shape of two tensors as following in the anchor_target_single_obb_obb_rbox.py file and find that they are inconsistent:

gt_bboxes: torch.Size([324, 5])
gt_labels: torch.Size([343])

is this right?

loss became to nan

I kept your settings completely unchanged, and experimented on the DOTA dataset, and found that the loss became nan.
When I reduced the lr, I found that the loss did not converge very well, and after training for several epochs, it will become very large until nan

dataset_prepare

使用 prepare_dota1_ms.py在data/dota_1024_s2anet下生成了文件夹 都是空的 要怎么进行裁剪呢?并没有看到生成1024*1024的图像生成在images文件夹里。请问是不是还要执行别的py文件?我的dota训练集的路径是/home/yzk/s2anet-master/data/dota/trainval。麻烦指教,谢谢。
image

odm anchor

anchors refined by FAM are transformed to the ODM to regresssion to get the anchors with higher accuracy?

Heading irrelevant bounding box

Hi, thanks for the great contribution!
I would like to ask whether it's possible to make the bbox loss heading irrelevant. I.e., different orders of four corners points are equivalent. I.e., the degree of prediction is -pi to pi?

Thank you!

梯度爆炸问题

训练hrsc2016出现梯度爆炸问题,请问是怎么解决的呢?

mAP计算

你好,我想问一下关于mAP的计算,在训练阶段的时候,看代码里显示的是DOTA数据集的train和val set都用了,请问在DOTA_devkit中的dota_evaluation_task1.py中的标注文件是什么,也是用val 数据集进行验证的吗?已经参与训练的数据再测试会不会使得结果不准确?
还有想知道作者这里的test的标注文件是什么?DOTA数据集test是没有标注的啊?
image

ImportError: cannot import name 'nms_rotated_cuda' from 'mmdet.ops.nms_rotated'

hi, it's odd that this error occured when training DOTA for I check the code and seems no problem :

Traceback (most recent call last): File "tools/train.py", line 9, in <module> from mmdet.apis import (get_root_logger, init_dist, set_random_seed, File "/dat01/zhangshuhao/dy/s2anet-dal/mmdet/apis/__init__.py", line 2, in <module> from .inference import (inference_detector, init_detector, show_result, File "/dat01/zhangshuhao/dy/s2anet-dal/mmdet/apis/inference.py", line 11, in <module> from mmdet.core import get_classes File "/dat01/zhangshuhao/dy/s2anet-dal/mmdet/core/__init__.py", line 1, in <module> from .anchor import * # noqa: F401, F403 File "/dat01/zhangshuhao/dy/s2anet-dal/mmdet/core/anchor/__init__.py", line 2, in <module> from .anchor_target import anchor_inside_flags, anchor_target, unmap, images_to_levels File "/dat01/zhangshuhao/dy/s2anet-dal/mmdet/core/anchor/anchor_target.py", line 3, in <module> from ..bbox import PseudoSampler, assign_and_sample, bbox2delta, build_assigner File "/dat01/zhangshuhao/dy/s2anet-dal/mmdet/core/bbox/__init__.py", line 1, in <module> from .assigners import AssignResult, BaseAssigner, MaxIoUAssigner File "/dat01/zhangshuhao/dy/s2anet-dal/mmdet/core/bbox/assigners/__init__.py", line 1, in <module> from .approx_max_iou_assigner import ApproxMaxIoUAssigner File "/dat01/zhangshuhao/dy/s2anet-dal/mmdet/core/bbox/assigners/approx_max_iou_assigner.py", line 3, in <module> from ..geometry import bbox_overlaps File "/dat01/zhangshuhao/dy/s2anet-dal/mmdet/core/bbox/geometry.py", line 3, in <module> from mmdet.ops.box_iou_rotated import box_iou_rotated File "/dat01/zhangshuhao/dy/s2anet-dal/mmdet/ops/__init__.py", line 8, in <module> from .nms_rotated import nms_rotated File "/dat01/zhangshuhao/dy/s2anet-dal/mmdet/ops/nms_rotated/__init__.py", line 1, in <module> from . import nms_rotated_cuda ImportError: cannot import name 'nms_rotated_cuda' from 'mmdet.ops.nms_rotated' (/dat01/zhangshuhao/dy/s2anet-dal/mmdet/ops/nms_rotated/__init__.py) ~

loss became NaN when traning with multi-scale dataset

Hello, I configured the multi-scale dataset, used the DOTA1.5 tag, and modified the num_classes configuration, but the other configurations were not modified. When I was training, loss dropped at the beginning, but suddenly became NaN. I want to know if this is due to a code problem or my wrong dataset configuration.
Using the dota1.0 dataset, I can train well.Thanks for your attention and reply!
ss

Hi,does s2anet support multi anchor_ratios?

Hi,when i set "anchor_ratios=[0.5, 2/3, 1.0, 3/2, 2]", there is some error, so how can i set multi anchor_ratios in s2anet?
The error log is:
2020-10-15 14:54:19,828 - INFO - Distributed training: False
2020-10-15 14:54:20,415 - INFO - load model from: torchvision://resnet101
2020-10-15 14:54:20,778 - WARNING - The model and loaded state dict do not match exactly

unexpected key in source state_dict: fc.weight, fc.bias

2020-10-15 14:54:25,094 - INFO - Start running, host: root@c382926e5c92, work_dir: /user/lsc/workspace/s2anet/work_dirs/match_1015_3
2020-10-15 14:54:25,094 - INFO - workflow: [('train', 1)], max: 36 epochs
Traceback (most recent call last):
File "tools/train.py", line 109, in
main()
File "tools/train.py", line 105, in main
logger=logger)
File "/user/lsc/workspace/s2anet/mmdet/apis/train.py", line 60, in train_detector
_non_dist_train(model, dataset, cfg, validate=validate)
File "/user/lsc/workspace/s2anet/mmdet/apis/train.py", line 232, in _non_dist_train
runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
File "/root/anaconda3/envs/s2net/lib/python3.6/site-packages/mmcv/runner/runner.py", line 358, in run
epoch_runner(data_loaders[i], **kwargs)
File "/root/anaconda3/envs/s2net/lib/python3.6/site-packages/mmcv/runner/runner.py", line 264, in train
self.model, data_batch, train_mode=True, **kwargs)
File "/user/lsc/workspace/s2anet/mmdet/apis/train.py", line 38, in batch_processor
losses = model(**data)
File "/root/anaconda3/envs/s2net/lib/python3.6/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
result = self.forward(*input, **kwargs)
File "/root/anaconda3/envs/s2net/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 153, in forward
return self.module(*inputs[0], **kwargs[0])
File "/root/anaconda3/envs/s2net/lib/python3.6/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
result = self.forward(*input, **kwargs)
File "/user/lsc/workspace/s2anet/mmdet/core/fp16/decorators.py", line 49, in new_func
return old_func(*args, **kwargs)
File "/user/lsc/workspace/s2anet/mmdet/models/detectors/base.py", line 100, in forward
return self.forward_train(img, img_meta, **kwargs)
File "/user/lsc/workspace/s2anet/mmdet/models/detectors/s2anet.py", line 66, in forward_train
outs = self.rbox_head(x)
File "/root/anaconda3/envs/s2net/lib/python3.6/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
result = self.forward(*input, **kwargs)
File "/user/lsc/workspace/s2anet/mmdet/models/anchor_heads/s2anet_head.py", line 369, in forward
return multi_apply(self.forward_single, feats, self.anchor_strides)
File "/user/lsc/workspace/s2anet/mmdet/core/utils/misc.py", line 24, in multi_apply
return tuple(map(list, zip(*map_results)))
File "/user/lsc/workspace/s2anet/mmdet/models/anchor_heads/s2anet_head.py", line 339, in forward_single
self.target_stds)
File "/user/lsc/workspace/s2anet/mmdet/models/anchor_heads/s2anet_head.py", line 45, in bbox_decode
wh_ratio_clip=1e-6)
File "/user/lsc/workspace/s2anet/mmdet/core/bbox/transforms_rbox.py", line 70, in delta2rbox
Rroi_x = (Rrois[:, 0]).unsqueeze(1).expand_as(dx)
RuntimeError: The expanded size of the tensor (16384) must match the existing size (81920) at non-singleton dimension 0. Target sizes: [16384, 1]. Tensor sizes: [81920, 1]

compile error when installing with 'python setup.py develop'

building 'mmdet.ops.box_iou_rotated.box_iou_rotated_C' extension
gcc -pthread -B /opt/conda/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/opt/conda/lib/python3.6/site-packages/torch/include -I/opt/conda/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/opt/conda/lib/python3.6/site-packages/torch/include/TH -I/opt/conda/lib/python3.6/site-packages/torch/include/THC -I'/usr/local/cuda'/include -I/opt/conda/include/python3.6m -c mmdet/ops/box_iou_rotated/src/box_iou_rotated_cpu.cpp -o build/temp.linux-x86_64-3.6/mmdet/ops/box_iou_rotated/src/box_iou_rotated_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=box_iou_rotated_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
mmdet/ops/box_iou_rotated/src/box_iou_rotated_cpu.cpp: In function ‘void box_iou_rotated_cpu_kernel(const at::Tensor&, const at::Tensor&, at::Tensor&)’:
mmdet/ops/box_iou_rotated/src/box_iou_rotated_cpu.cpp:25:31: error: expected primary-expression before ‘>’ token
boxes1[i].data_ptr(), boxes2[j].data_ptr());
^
mmdet/ops/box_iou_rotated/src/box_iou_rotated_cpu.cpp:25:33: error: expected primary-expression before ‘)’ token
boxes1[i].data_ptr(), boxes2[j].data_ptr());
^
mmdet/ops/box_iou_rotated/src/box_iou_rotated_cpu.cpp:25:56: error: expected primary-expression before ‘>’ token
boxes1[i].data_ptr(), boxes2[j].data_ptr());
^
mmdet/ops/box_iou_rotated/src/box_iou_rotated_cpu.cpp:25:58: error: expected primary-expression before ‘)’ token
boxes1[i].data_ptr(), boxes2[j].data_ptr());
^
error: command 'gcc' failed with exit status 1

Training with custom dataset

Hi, I am training s2anet with my custom dataset for which I need to estimate oriented bounding boxes. I have modified input resolution and anchor scales as per my requirement along with support for new dataset, following is logs for one of the epoch. Could you let me know if something else needs to be modified for experimenting with custom dataset?

loss_fam_cls: nan, loss_fam_bbox: nan, loss_odm_cls: 0.3204, loss_odm_bbox: nan

trained model

Could you please provide with trained RetinaNet model? Thanks!

about the ImportError: cannot import name 'get_best_rbox'

when I try to train the dota dataset with the config file "s2anet_r101_fpn_1x_ms_rotate.py", the error description is as follows:
from .transforms_rbox import (delta2rbox, get_best_begin_point,
ImportError: cannot import name 'get_best_rbox' from 'mmdet.core.bbox.transforms_rbox'
Could you please solve this?

Model Loss in Test Stage

First, thx for this excellent repo.
How could I print loss in test stage.
I changed result = model(return_loss = False, xxxxx) toresult = model(return_loss =True, xxxxx) in line 31 of test.py. But run error.
looking forward to your reply.

mmdet

version `libcudart.so.10.1' not found

python setup.py develop

when I run "python setup.py develop" , I meet the error. How I can do to solve the problem!

(s2anet) dl@dl-System-Product-Name:/media/dl/本地磁盘/s2anet$ python setup.py develop
running develop
running egg_info
writing mmdet.egg-info/PKG-INFO
writing dependency_links to mmdet.egg-info/dependency_links.txt
writing requirements to mmdet.egg-info/requires.txt
writing top-level names to mmdet.egg-info/top_level.txt
reading manifest file 'mmdet.egg-info/SOURCES.txt'
writing manifest file 'mmdet.egg-info/SOURCES.txt'
running build_ext
building 'mmdet.ops.nms.soft_nms_cpu' extension
Emitting ninja build file /media/dl/本地磁盘/s2anet/build/temp.linux-x86_64-3.7/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: no work to do.
g++ -pthread -shared -B /home/dl/anaconda3/envs/s2anet/compiler_compat -L/home/dl/anaconda3/envs/s2anet/lib -Wl,-rpath=/home/dl/anaconda3/envs/s2anet/lib -Wl,--no-as-needed -Wl,--sysroot=/ /media/dl/本地磁盘/s2anet/build/temp.linux-x86_64-3.7/mmdet/ops/nms/src/soft_nms_cpu.o -o build/lib.linux-x86_64-3.7/mmdet/ops/nms/soft_nms_cpu.cpython-37m-x86_64-linux-gnu.so
building 'mmdet.ops.nms.nms_cpu' extension
Emitting ninja build file /media/dl/本地磁盘/s2anet/build/temp.linux-x86_64-3.7/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: no work to do.
g++ -pthread -shared -B /home/dl/anaconda3/envs/s2anet/compiler_compat -L/home/dl/anaconda3/envs/s2anet/lib -Wl,-rpath=/home/dl/anaconda3/envs/s2anet/lib -Wl,--no-as-needed -Wl,--sysroot=/ /media/dl/本地磁盘/s2anet/build/temp.linux-x86_64-3.7/mmdet/ops/nms/src/nms_cpu.o -L/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/lib -L/usr/local/cuda-10.2/lib64 - -ltorch -ltorch_cpu -ltorch_python -lcudart -lc10_cuda -ltorch_cuda -o build/lib.linux-x86_64-3.7/mmdet/ops/nms/nms_cpu.cpython-37m-x86_64-linux-gnu.so
building 'mmdet.ops.nms.nms_cuda' extension
Emitting ninja build file /media/dl/本地磁盘/s2anet/build/temp.linux-x86_64-3.7/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
[1/1] c++ -MMD -MF '/media/dl/本地磁盘/s2anet/build/temp.linux-x86_64-3.7/mmdet/ops/nms/src/nms_cuda.o'.d -pthread -B /home/dl/anaconda3/envs/s2anet/compiler_compat -Wl,--sysroot=/ -Wsigmpare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include -I/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/TH -I/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda-10.2/include -I/home/dl/anaconda3/envs/s2anet/include/python3.7m -c -c '/media/dl/本地磁盘/s2anet/mmdet/ops/nms/src/nms_cuda.cpp' -o '/m/dl/本地磁盘/s2anet/build/temp.linux-x86_64-3.7/mmdet/ops/nms/src/nms_cuda.o' -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=nms_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
FAILED: /media/dl/本地磁盘/s2anet/build/temp.linux-x86_64-3.7/mmdet/ops/nms/src/nms_cuda.o
c++ -MMD -MF '/media/dl/本地磁盘/s2anet/build/temp.linux-x86_64-3.7/mmdet/ops/nms/src/nms_cuda.o'.d -pthread -B /home/dl/anaconda3/envs/s2anet/compiler_compat -Wl,--sysroot=/ -Wsign-comp-DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include -I/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/TH -I/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda-10.2/include -I/home/dl/anaconda3/envs/s2anet/include/python3.7m -c -c '/media/dl/本地磁盘/s2anet/mmdet/ops/nms/src/nms_cuda.cpp' -o '/media/d磁盘/s2anet/build/temp.linux-x86_64-3.7/mmdet/ops/nms/src/nms_cuda.o' -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=nms_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/ATen/Parallel.h:149:0,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/utils.h:3,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/nn/cloneable.h:5,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/nn.h:3,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/all.h:7,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/extension.h:4,
from /media/dl/本地磁盘/s2anet/mmdet/ops/nms/src/nms_cuda.cpp:2:
/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/ATen/ParallelOpenMP.h:84:0: warning: ignoring #pragma omp parallel [-Wunknown-pragmas]
#pragma omp parallel for if ((end - begin) >= grain_size)

/media/dl/本地磁盘/s2anet/mmdet/ops/nms/src/nms_cuda.cpp: In function ‘at::Tensor nms(const at::Tensor&, float)’:
/media/dl/本地磁盘/s2anet/mmdet/ops/nms/src/nms_cuda.cpp:4:39: warning: ‘at::DeprecatedTypeProperties& at::Tensor::type() const’ is deprecated: Tensor.type() is deprecated. Instead use Tr.options(), which in many cases (e.g. in a constructor) is a drop-in replacement. If you were using data from type(), that is now available from Tensor itself, so instead of tensor.type().scalar_type(), use tensor.scalar_type() instead and instead of tensor.type().backend() use tensor.device(). [-Wdeprecated-declarations]
#define CHECK_CUDA(x) AT_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ")
^
/media/dl/本地磁盘/s2anet/mmdet/ops/nms/src/nms_cuda.cpp:9:3: note: in expansion of macro ‘CHECK_CUDA’
CHECK_CUDA(dets);
^~~~~~~~~~
In file included from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/ATen/Tensor.h:3:0,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/ATen/Context.h:4,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/ATen/ATen.h:5,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/all.h:4,
from /home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/torch/extension.h:4,
from /media/dl/本地磁盘/s2anet/mmdet/ops/nms/src/nms_cuda.cpp:2:
/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/include/ATen/core/TensorBody.h:268:30: note: declared here
DeprecatedTypeProperties & type() const {
^~~~
/media/dl/本地磁盘/s2anet/mmdet/ops/nms/src/nms_cuda.cpp:4:23: error: ‘AT_CHECK’ was not declared in this scope
#define CHECK_CUDA(x) AT_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ")
^
/media/dl/本地磁盘/s2anet/mmdet/ops/nms/src/nms_cuda.cpp:9:3: note: in expansion of macro ‘CHECK_CUDA’
CHECK_CUDA(dets);
^~~~~~~~~~
/media/dl/本地磁盘/s2anet/mmdet/ops/nms/src/nms_cuda.cpp:4:23: note: suggested alternative: ‘DCHECK’
#define CHECK_CUDA(x) AT_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ")
^
/media/dl/本地磁盘/s2anet/mmdet/ops/nms/src/nms_cuda.cpp:9:3: note: in expansion of macro ‘CHECK_CUDA’
CHECK_CUDA(dets);
^~~~~~~~~~
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1515, in _run_ninja_build
env=env)
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/subprocess.py", line 512, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "setup.py", line 228, in
zip_safe=False)
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/setuptools/init.py", line 163, in setup
return distutils.core.setup(**attrs)
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/setuptools/command/develop.py", line 38, in run
self.install_for_development()
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/setuptools/command/develop.py", line 140, in install_for_development
self.run_command('build_ext')
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 87, in run
_build_ext.run(self)
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 649, in build_extensions
build_ext.build_extensions(self)
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions
_build_ext.build_ext.build_extensions(self)
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/distutils/command/build_ext.py", line 449, in build_extensions
self._build_extensions_serial()
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/distutils/command/build_ext.py", line 474, in _build_extensions_serial
self.build_extension(ext)
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 208, in build_extension
_build_ext.build_extension(self, ext)
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/distutils/command/build_ext.py", line 534, in build_extension
depends=ext.depends)
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 478, in unix_wrap_ninja_compile
with_cuda=with_cuda)
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1233, in _write_ninja_file_and_compile_objects
error_prefix='Error compiling objects for extension')
File "/home/dl/anaconda3/envs/s2anet/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1529, in _run_ninja_build
raise RuntimeError(message)
RuntimeError: Error compiling objects for extension

compile error

when install with python setup.py develop, an error occurred as follow:

building 'mmdet.ops.box_iou_rotated.box_iou_rotated_C' extension
gcc -pthread -B /opt/conda/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/opt/conda/lib/python3.6/site-packages/torch/include -I/opt/conda/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/opt/conda/lib/python3.6/site-packages/torch/include/TH -I/opt/conda/lib/python3.6/site-packages/torch/include/THC -I'/usr/local/cuda'/include -I/opt/conda/include/python3.6m -c mmdet/ops/box_iou_rotated/src/box_iou_rotated_cpu.cpp -o build/temp.linux-x86_64-3.6/mmdet/ops/box_iou_rotated/src/box_iou_rotated_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=box_iou_rotated_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
mmdet/ops/box_iou_rotated/src/box_iou_rotated_cpu.cpp: In function ‘void box_iou_rotated_cpu_kernel(const at::Tensor&, const at::Tensor&, at::Tensor&)’:
mmdet/ops/box_iou_rotated/src/box_iou_rotated_cpu.cpp:25:31: error: expected primary-expression before ‘>’ token
           boxes1[i].data_ptr<T>(), boxes2[j].data_ptr<T>());
                               ^
mmdet/ops/box_iou_rotated/src/box_iou_rotated_cpu.cpp:25:33: error: expected primary-expression before ‘)’ token
           boxes1[i].data_ptr<T>(), boxes2[j].data_ptr<T>());
                                 ^
mmdet/ops/box_iou_rotated/src/box_iou_rotated_cpu.cpp:25:56: error: expected primary-expression before ‘>’ token
           boxes1[i].data_ptr<T>(), boxes2[j].data_ptr<T>());
                                                        ^
mmdet/ops/box_iou_rotated/src/box_iou_rotated_cpu.cpp:25:58: error: expected primary-expression before ‘)’ token
           boxes1[i].data_ptr<T>(), boxes2[j].data_ptr<T>());
                                                          ^
error: command 'gcc' failed with exit status 1

Result on HRSC2016

Hi, I've obtained the same results reported in paper on hrsc2016 with s2anet.
But detection results with RetinaNet are not good enough, what's wong with my configs:

# model settings
model = dict(
    type='RBoxRetinaNet',
    pretrained='torchvision://resnet50',
    backbone=dict(
        type='ResNet',
        depth=50,
        num_stages=4,
        out_indices=(0, 1, 2, 3),
        frozen_stages=1,
        style='pytorch'),
    neck=dict(
        type='FPN',
        in_channels=[256, 512, 1024, 2048],
        out_channels=256,
        start_level=1,
        add_extra_convs=True,
        num_outs=5),
    rbox_head=dict(
        type='RBoxRetinaHead',
        num_classes=2,
        in_channels=256,
        stacked_convs=4,
        feat_channels=256,
        octave_base_scale=4,
        scales_per_octave=3,
        anchor_ratios=[0.5, 1.0, 2.0],
        anchor_strides=[8, 16, 32, 64, 128],
        target_means=[.0, .0, .0, .0, .0],
        target_stds=[1.0, 1.0, 1.0, 1.0, 1.0],
        loss_cls=dict(
            type='FocalLoss',
            use_sigmoid=True,
            gamma=2.0,
            alpha=0.25,
            loss_weight=1.0),
        loss_bbox=dict(type='SmoothL1Loss', beta=0.11, loss_weight=1.0)))
# training and testing settings
train_cfg = dict(
#     anchor_target_type='hbb_obb_rbox_overlap',
    assigner=dict(
        type='MaxIoUAssigner',
#         type='MaxIoUAssignerRbox',
        pos_iou_thr=0.5,
        neg_iou_thr=0.4,
        min_pos_iou=0,
        ignore_iof_thr=-1),
    allowed_border=-1,
    pos_weight=-1,
    debug=False)
test_cfg = dict(
    nms_pre=2000,
    min_bbox_size=0,
    score_thr=0.05,
    nms=dict(type='nms_rotated', iou_thr=0.1),#15fps
    max_per_img=2000)
# dataset settings
dataset_type = 'HRSC2016Dataset'
data_root = 'data/HRSC2016/'
img_norm_cfg = dict(
    mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
    dict(type='LoadImageFromFile'),
    dict(type='LoadAnnotations', with_bbox=True),
    dict(type='RotatedResize', img_scale=(800, 800), keep_ratio=True),
    dict(type='RotatedRandomFlip', flip_ratio=0.5),
    dict(type='RandomRotate', rate=0.5, angles=[30, 60, 90, 120, 150], auto_bound=False),
    dict(type='Normalize', **img_norm_cfg),
    dict(type='Pad', size_divisor=32),
    dict(type='DefaultFormatBundle'),
    dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
]
test_pipeline = [
    dict(type='LoadImageFromFile'),
    dict(
        type='MultiScaleFlipAug',
        img_scale=(800, 800),
        flip=False,
        transforms=[
            dict(type='RotatedResize',img_scale=(800, 800), keep_ratio=True),
            dict(type='RotatedRandomFlip'),
            dict(type='Normalize', **img_norm_cfg),
            dict(type='Pad', size_divisor=32),
            dict(type='ImageToTensor', keys=['img']),
            dict(type='Collect', keys=['img']),
        ])
]
data = dict(
    imgs_per_gpu=2,
    workers_per_gpu=2,
    train=dict(
        type=dataset_type,
        ann_file=data_root + 'ImageSets/train.json',
        img_prefix=data_root + 'Train/images/',
        pipeline=train_pipeline),
    val=dict(
        type=dataset_type,
        ann_file=data_root + 'ImageSets/val.json',
        img_prefix=data_root + 'Val/images/',
        pipeline=test_pipeline),
    test=dict(
        type=dataset_type,
        ann_file=data_root + 'ImageSets/test.json',
        img_prefix=data_root + 'Test/images/',
        pipeline=test_pipeline))
# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001)
# optimizer = dict(type='Adam', lr=1e-4)
optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2))
# learning policy
lr_config = dict(
    policy='step',
    warmup='linear',
    warmup_iters=500,
    warmup_ratio=1.0 / 3,
    step=[24, 33])
checkpoint_config = dict(interval=12)
# yapf:disable
log_config = dict(
    interval=50,
    hooks=[
        dict(type='TextLoggerHook'),
        # dict(type='TensorboardLoggerHook')
    ])
# yapf:enable
# runtime settings
total_epochs = 36
dist_params = dict(backend='nccl')
log_level = 'INFO'
work_dir = './work_dirs/retinanet_obb_r50_fpn_1x_hrsc2016/'
load_from = None
resume_from = None
workflow = [('train', 1)]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.