Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support RR360 (Rotated Rectangle 360) Detection in TRR360D #731

Merged
merged 92 commits into from
Mar 13, 2023

Conversation

vansin
Copy link
Collaborator

@vansin vansin commented Feb 15, 2023

1. Motivation

传统的 mmrotate的 oc le90 le135 定义的算法和数据集检测范围不支持 360的旋转模板检测,不能区分矩形的ABCD点的语义,所以本工作,定义了 r360 角度定义法,同时制作了DOTA格式的TRR360D 数据集,在此数据集上验证改造算法的有效性。

image

2. Modification

  • A new generated dataset (TRR360D )
  • R360 angle define, q2rbox r2qbox funcition
  • RR360LocalVisualizer
  • DOTAR360Metric

3. 快速上手

mkdir RR360
cd RR360
export WORK_HOME=$(pwd)

安装前置依赖

conda create -n RR360 python=3.8 -y
conda activate RR360

pip install torch==1.10.0+cu111 torchvision==0.11.0+cu111 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html

pip install -U openmim
mim install mmengine
mim install "mmcv>=2.0.0rc1"

cd $WORK_HOME
git clone https://github.com/open-mmlab/mmdetection -b dev-3.x
cd mmdetection 
pip install -v -e .
# 假设已经安装mmengine、mmcv 2.x、mmdetection
cd $WORK_HOME
git clone https://github.com/vansin/mmrotate -b RR360
cd mmrotate 
export MMROTATE_HOME=$(pwd)
pip install -v -e .

数据集下载

cd $MMROTATE_HOME
mkdir -p data/TRR360D
# git clone https://github.com/vansin/TRR360D.git data/TRR360D
wget https://openmmlab.vansin.top/datasets/ICDAR2019_MTD_HOQ.zip -O data/TRR360D/TRR360D.zip
cd $MMROTATE_HOME/data/TRR360D
unzip TRR360D.zip

600 个训练图片,240个测试图片

通过 browse_dataset.py 检测数据集的正确性

cd $MMROTATE_HOME
 python projects/RR360/tools/browse_dataset.py \
 projects/RR360/configs360/rotated_retinanet/rotated-retinanet-rbox-r360_r50_fpn_6x_ic19.py \
    --output-dir show_ann \
    # --show

数据集有由语义信息的,ABCD点是表格左上角开始,依次顺时钟的四个点。
image

configs360

推理已训练好的模型

cd $MMROTATE_HOME

wget https://openmmlab.vansin.top/work_dirs/RR360/configs360/rotated_rtmdet_x3_r/rotated_rtmdet_s_l1-3x-ic19_pt/epoch_36.pth

python projects/RR360/tools/test.py \
    projects/RR360/configs360/rotated_rtmdet_x3_r/rotated_rtmdet_s_l1-3x-ic19_pt.py \
    epoch_36.pth \
    --show-dir predict_result
    # --show

在 work_dirs/rotated_rtmdet_s_l1-3x-ic19_pt/{时间戳}/predict_result 可以看到训练好的模型推理结果
image

训练

cd $MMROTATE_HOME
python projects/RR360/tools/train.py \
    projects/RR360/configs360/rotated_rtmdet_x3_r/rotated_rtmdet_s_l1-3x-ic19_pt.py \
    --d

测试自行训练的

cd $MMROTATE_HOME
python projects/RR360/tools/test.py \
    work_dirs/RR360/configs360/rotated_rtmdet_x3_r/rotated_rtmdet_s_l1-3x-ic19_pt/rotated_rtmdet_s_l1-3x-ic19_pt.py \
    work_dirs/RR360/configs360/rotated_rtmdet_x3_r/rotated_rtmdet_s_l1-3x-ic19_pt/epoch_36.pth

5. Checklist

zytx121
zytx121 previously approved these changes Mar 12, 2023
Copy link
Collaborator

@zytx121 zytx121 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zytx121 zytx121 requested a review from RangiLyu March 12, 2023 14:46
@zytx121
Copy link
Collaborator

zytx121 commented Mar 12, 2023

@RangiLyu hope merge as soon as possible

@zytx121 zytx121 closed this Mar 12, 2023
@zytx121 zytx121 reopened this Mar 12, 2023
@codecov
Copy link

codecov bot commented Mar 12, 2023

Codecov Report

❗ No coverage uploaded for pull request base (dev-1.x@35c766e). Click here to learn what that means.
Patch has no changes to coverable lines.

❗ Current head b7088b6 differs from pull request most recent head f2e43c3. Consider uploading reports for the commit f2e43c3 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             dev-1.x     #731   +/-   ##
==========================================
  Coverage           ?   79.35%           
==========================================
  Files              ?      100           
  Lines              ?     7274           
  Branches           ?     1040           
==========================================
  Hits               ?     5772           
  Misses             ?     1164           
  Partials           ?      338           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

projects/RR360/readme.md Outdated Show resolved Hide resolved
@vansin
Copy link
Collaborator Author

vansin commented Mar 13, 2023

@RangiLyu 加TODO 的意思是要readme 写一下吗?

@RangiLyu
Copy link
Member

@RangiLyu 加TODO 的意思是要readme 写一下吗?

代码里加上 TODO:xxxxx 的注释说明一下这么做是暂时的,之后会修改

@RangiLyu
Copy link
Member

@RangiLyu 加TODO 的意思是要readme 写一下吗?

Readme最好也说明一下情况

@vansin
Copy link
Collaborator Author

vansin commented Mar 13, 2023

@RangiLyu 加TODO 的意思是要readme 写一下吗?

Readme最好也说明一下情况

ok

@RangiLyu RangiLyu merged commit 607db84 into open-mmlab:dev-1.x Mar 13, 2023
@vansin vansin changed the title [WIP] Support RR360 (Rotated Rectangle 360) Detection in TRR360D Support RR360 (Rotated Rectangle 360) Detection in TRR360D Mar 13, 2023
@lzh420202
Copy link

Does this coding directly apply to existing models to improve or degrade performance? I am also concerned about how to accurately evaluate this method, since the actual orientation information is not effectively represented in the mAP.

@vansin
Copy link
Collaborator Author

vansin commented May 4, 2023

Does this coding directly apply to existing models to improve or degrade performance? I am also concerned about how to accurately evaluate this method, since the actual orientation information is not effectively represented in the mAP.

please see~

i] >= iou_thr and distance_gt_pred_angle < angle_thr * np.pi / 180: # noqa: E501

https://github.com/open-mmlab/mmrotate/blob/dev-1.x/projects/RR360/evaluation/metrics/dota_r360_metric.py

dota_r360_metric

@lzh420202
Copy link

Does this coding directly apply to existing models to improve or degrade performance? I am also concerned about how to accurately evaluate this method, since the actual orientation information is not effectively represented in the mAP.

please see~

i] >= iou_thr and distance_gt_pred_angle < angle_thr * np.pi / 180: # noqa: E501

https://github.com/open-mmlab/mmrotate/blob/dev-1.x/projects/RR360/evaluation/metrics/dota_r360_metric.py

dota_r360_metric

Thanks, I understand the evaluation method, but did you test it on DOTA1.0? I just want to know if it has any advantages over the le90, le135, and oc on RS.
Thanks for your attention.

@vansin
Copy link
Collaborator Author

vansin commented May 4, 2023

Does this coding directly apply to existing models to improve or degrade performance? I am also concerned about how to accurately evaluate this method, since the actual orientation information is not effectively represented in the mAP.

please see~

i] >= iou_thr and distance_gt_pred_angle < angle_thr * np.pi / 180: # noqa: E501

https://github.com/open-mmlab/mmrotate/blob/dev-1.x/projects/RR360/evaluation/metrics/dota_r360_metric.py
dota_r360_metric

Thanks, I understand the evaluation method, but did you test it on DOTA1.0? I just want to know if it has any advantages over the le90, le135, and oc on RS. Thanks for your attention.

not test in DOTA 1.0, define a new metric named r360, the dataset satisfy follow condition can use this method

https://arxiv.org/pdf/2303.01894.pdf

image

welcome add my wechat van-sin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants