Skip to content

Commit ad48e14

Browse files
committed
add iou-fcos and ssod baseline
1 parent 314019c commit ad48e14

13 files changed

+563
-38
lines changed

configs/fcos/README.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
# FCOS for Object Detection
1+
# FCOS (Fully Convolutional One-Stage Object Detection)
22

3-
## Introduction
3+
## Model Zoo on COCO
44

5-
FCOS (Fully Convolutional One-Stage Object Detection) is a fast anchor-free object detection framework with strong performance. We reproduced the model of the paper, and improved and optimized the accuracy of the FCOS.
5+
| 骨架网络 | 网络类型 | 每张GPU图片个数 | 学习率策略 |推理时间(fps) | Box AP | 下载 | 配置文件 |
6+
| :------------------- | :------------- | :-----: | :-----: | :------------: | :-----: | :-----------------------------------------------------: | :-----: |
7+
| ResNet50-FPN | FCOS | 2 | 1x | ---- | 39.6 | [download](https://paddledet.bj.bcebos.com/models/fcos_r50_fpn_1x_coco.pdparams) | [config](./fcos_r50_fpn_1x_coco.yml) |
8+
| ResNet50-FPN | FCOS + iou | 2 | 1x | ---- | 40.0 | [download](https://paddledet.bj.bcebos.com/models/fcos_r50_fpn_iou_1x_coco.pdparams) | [config](./fcos_r50_fpn_iou_1x_coco.yml) |
9+
| ResNet50-FPN | FCOS + DCN | 2 | 1x | ---- | 44.3 | [download](https://paddledet.bj.bcebos.com/models/fcos_dcn_r50_fpn_1x_coco.pdparams) | [config](./fcos_dcn_r50_fpn_1x_coco.yml) |
10+
| ResNet50-FPN | FCOS + multiscale_train | 2 | 2x | ---- | 41.8 | [download](https://paddledet.bj.bcebos.com/models/fcos_r50_fpn_multiscale_2x_coco.pdparams) | [config](./fcos_r50_fpn_multiscale_2x_coco.yml) |
11+
| ResNet50-FPN | FCOS + multiscale_train + iou | 2 | 2x | ---- | 42.6 | [download](https://paddledet.bj.bcebos.com/models/fcos_r50_fpn_iou_multiscale_2x_coco.pdparams) | [config](./fcos_r50_fpn_iou_multiscale_2x_coco.yml) |
612

7-
**Highlights:**
13+
**注意:**
14+
- `+ iou` 表示与原版 FCOS 相比,不使用 `centerness` 而是使用 `iou` 来参与计算loss。
815

9-
- Training Time: The training time of the model of `fcos_r50_fpn_1x` on Tesla v100 with 8 GPU is only 8.5 hours.
10-
11-
## Model Zoo
12-
13-
| Backbone | Model | images/GPU | lr schedule |FPS | Box AP | download | config |
14-
| :-------------- | :------------- | :-----: | :-----: | :------------: | :-----: | :-----------------------------------------------------: | :-----: |
15-
| ResNet50-FPN | FCOS | 2 | 1x | ---- | 39.6 | [download](https://paddledet.bj.bcebos.com/models/fcos_r50_fpn_1x_coco.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/fcos/fcos_r50_fpn_1x_coco.yml) |
16-
| ResNet50-FPN | FCOS+DCN | 2 | 1x | ---- | 44.3 | [download](https://paddledet.bj.bcebos.com/models/fcos_dcn_r50_fpn_1x_coco.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/fcos/fcos_dcn_r50_fpn_1x_coco.yml) |
17-
| ResNet50-FPN | FCOS+multiscale_train | 2 | 2x | ---- | 41.8 | [download](https://paddledet.bj.bcebos.com/models/fcos_r50_fpn_multiscale_2x_coco.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/fcos/fcos_r50_fpn_multiscale_2x_coco.yml) |
18-
19-
**Notes:**
20-
21-
- FCOS is trained on COCO train2017 dataset and evaluated on val2017 results of `mAP(IoU=0.5:0.95)`.
2216

2317
## Citations
2418
```
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
_BASE_: [
2+
'../datasets/coco_detection.yml',
3+
'../runtime.yml',
4+
'_base_/fcos_r50_fpn.yml',
5+
'_base_/optimizer_1x.yml',
6+
'_base_/fcos_reader.yml',
7+
]
8+
9+
weights: output/fcos_r50_fpn_iou_1x_coco/model_final
10+
11+
12+
TrainReader:
13+
sample_transforms:
14+
- Decode: {}
15+
- RandomResize: {target_size: [[640, 1333], [672, 1333], [704, 1333], [736, 1333], [768, 1333], [800, 1333]], keep_ratio: True, interp: 1}
16+
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
17+
- RandomFlip: {}
18+
batch_transforms:
19+
- Permute: {}
20+
- PadBatch: {pad_to_stride: 32}
21+
- Gt2FCOSTarget:
22+
object_sizes_boundary: [64, 128, 256, 512]
23+
center_sampling_radius: 1.5
24+
downsample_ratios: [8, 16, 32, 64, 128]
25+
norm_reg_targets: True
26+
batch_size: 2
27+
shuffle: True
28+
drop_last: True
29+
30+
31+
EvalReader:
32+
sample_transforms:
33+
- Decode: {}
34+
- Resize: {target_size: [800, 1333], keep_ratio: True, interp: 1}
35+
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
36+
- Permute: {}
37+
batch_transforms:
38+
- PadBatch: {pad_to_stride: 32}
39+
batch_size: 1
40+
41+
42+
TestReader:
43+
sample_transforms:
44+
- Decode: {}
45+
- Resize: {target_size: [800, 1333], keep_ratio: True, interp: 1}
46+
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
47+
- Permute: {}
48+
batch_transforms:
49+
- PadBatch: {pad_to_stride: 32}
50+
batch_size: 1
51+
fuse_normalize: True
52+
53+
54+
FCOSHead:
55+
fcos_feat:
56+
name: FCOSFeat
57+
feat_in: 256
58+
feat_out: 256
59+
num_convs: 4
60+
norm_type: "gn"
61+
use_dcn: False
62+
fpn_stride: [8, 16, 32, 64, 128]
63+
prior_prob: 0.01
64+
norm_reg_targets: True
65+
centerness_on_reg: True
66+
fcos_loss:
67+
name: FCOSLoss
68+
loss_alpha: 0.25
69+
loss_gamma: 2.0
70+
iou_loss_type: "giou"
71+
reg_weights: 1.0
72+
quality: "iou" # default 'centerness'
73+
nms:
74+
name: MultiClassNMS
75+
nms_top_k: 1000
76+
keep_top_k: 100
77+
score_threshold: 0.025
78+
nms_threshold: 0.6
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
_BASE_: [
2+
'../datasets/coco_detection.yml',
3+
'../runtime.yml',
4+
'_base_/fcos_r50_fpn.yml',
5+
'_base_/optimizer_1x.yml',
6+
'_base_/fcos_reader.yml',
7+
]
8+
9+
weights: output/fcos_r50_fpn_iou_multiscale_2x_coco_010/model_final
10+
11+
TrainReader:
12+
sample_transforms:
13+
- Decode: {}
14+
- RandomResize: {target_size: [[640, 1333], [672, 1333], [704, 1333], [736, 1333], [768, 1333], [800, 1333]], keep_ratio: True, interp: 1}
15+
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
16+
- RandomFlip: {}
17+
batch_transforms:
18+
- Permute: {}
19+
- PadBatch: {pad_to_stride: 32}
20+
- Gt2FCOSTarget:
21+
object_sizes_boundary: [64, 128, 256, 512]
22+
center_sampling_radius: 1.5
23+
downsample_ratios: [8, 16, 32, 64, 128]
24+
norm_reg_targets: True
25+
batch_size: 2
26+
shuffle: True
27+
drop_last: True
28+
29+
30+
EvalReader:
31+
sample_transforms:
32+
- Decode: {}
33+
- Resize: {target_size: [800, 1333], keep_ratio: True, interp: 1}
34+
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
35+
- Permute: {}
36+
batch_transforms:
37+
- PadBatch: {pad_to_stride: 32}
38+
batch_size: 1
39+
40+
41+
TestReader:
42+
sample_transforms:
43+
- Decode: {}
44+
- Resize: {target_size: [800, 1333], keep_ratio: True, interp: 1}
45+
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
46+
- Permute: {}
47+
batch_transforms:
48+
- PadBatch: {pad_to_stride: 32}
49+
batch_size: 1
50+
fuse_normalize: True
51+
52+
53+
epoch: 24
54+
55+
LearningRate:
56+
base_lr: 0.01
57+
schedulers:
58+
- !PiecewiseDecay
59+
gamma: 0.1
60+
milestones: [16, 22]
61+
- !LinearWarmup
62+
start_factor: 0.001
63+
steps: 1000
64+
65+
66+
FCOSHead:
67+
fcos_feat:
68+
name: FCOSFeat
69+
feat_in: 256
70+
feat_out: 256
71+
num_convs: 4
72+
norm_type: "gn"
73+
use_dcn: False
74+
fpn_stride: [8, 16, 32, 64, 128]
75+
prior_prob: 0.01
76+
norm_reg_targets: True
77+
centerness_on_reg: True
78+
fcos_loss:
79+
name: FCOSLoss
80+
loss_alpha: 0.25
81+
loss_gamma: 2.0
82+
iou_loss_type: "giou"
83+
reg_weights: 1.0
84+
quality: "iou" # default 'centerness'
85+
nms:
86+
name: MultiClassNMS
87+
nms_top_k: 1000
88+
keep_top_k: 100
89+
score_threshold: 0.025
90+
nms_threshold: 0.6

configs/ssod/README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
简体中文 | [English](README_en.md)
2+
3+
# Semi-Supervised Object Detection (SSOD) 半监督目标检测
4+
5+
## 内容
6+
- [简介](#简介)
7+
- [模型库](#模型库)
8+
- [数据集准备](#数据集准备)
9+
- [引用](#引用)
10+
11+
## 简介
12+
半监督目标检测(SSOD)是**同时使用有标注数据和无标注数据**进行训练的目标检测,既可以极大地节省标注成本,也可以充分利用无标注数据进一步提高检测精度。
13+
14+
15+
## 模型库
16+
17+
### [Baseline](baseline)
18+
19+
**纯监督数据**模型的训练和模型库,请参照[Baseline](baseline)
20+
21+
22+
23+
## 数据集准备
24+
25+
半监督目标检测**同时需要有标注数据和无标注数据**,且无标注数据量一般**远多于有标注数据量**
26+
对于COCO数据集一般有两种常规设置:
27+
28+
(1)抽取部分比例的原始训练集`train2017`作为标注数据和无标注数据;
29+
30+
`train2017`中按固定百分比(1%、2%、5%、10%等)抽取,由于抽取方法会对半监督训练的结果影响较大,所以采用五折交叉验证来评估。运行数据集划分制作的脚本如下:
31+
```bash
32+
python tools/gen_semi_coco.py
33+
```
34+
会按照 1%、2%、5%、10% 的监督数据比例来划分`train2017`全集,为了交叉验证每一种划分会随机重复5次,生成的半监督标注文件如下:
35+
- 标注数据集标注:`instances_train2017.{fold}@{percent}.json`
36+
- 无标注数据集标注:`instances_train2017.{fold}@{percent}-unlabeled.json`
37+
其中,`fold` 表示交叉验证,`percent` 表示有标注数据的百分比。
38+
39+
(2)使用全量原始训练集`train2017`作为有标注数据 和 全量原始无标签图片集`unlabeled2017`作为无标注数据;
40+
41+
42+
### 下载链接
43+
44+
PaddleDetection团队提供了COCO数据集全部的标注文件,请下载并解压存放至对应目录:
45+
46+
```shell
47+
# 下载COCO全量数据集图片和标注
48+
# 包括 train2017, val2017, annotations
49+
wget https://bj.bcebos.com/v1/paddledet/data/coco.tar
50+
51+
# 下载PaddleDetection团队整理的COCO部分比例数据的标注文件
52+
wget https://bj.bcebos.com/v1/paddledet/data/coco/semi_annotations.zip
53+
54+
# unlabeled2017是可选,如果不需要训‘full’则无需下载
55+
# 下载COCO全量 unlabeled 无标注数据集
56+
wget https://bj.bcebos.com/v1/paddledet/data/coco/unlabeled2017.zip
57+
wget https://bj.bcebos.com/v1/paddledet/data/coco/image_info_unlabeled2017.zip
58+
# 下载转换完的 unlabeled2017 无标注json文件
59+
wget https://bj.bcebos.com/v1/paddledet/data/coco/instances_unlabeled2017.zip
60+
```
61+
62+
如果需要用到COCO全量unlabeled无标注数据集,需要将原版的`image_info_unlabeled2017.json`进行格式转换,运行以下代码:
63+
64+
<details>
65+
<summary> COCO unlabeled 标注转换代码:</summary>
66+
67+
```python
68+
import json
69+
anns_train = json.load(open('annotations/instances_train2017.json', 'r'))
70+
anns_unlabeled = json.load(open('annotations/image_info_unlabeled2017.json', 'r'))
71+
unlabeled_json = {
72+
'images': anns_unlabeled['images'],
73+
'annotations': [],
74+
'categories': anns_train['categories'],
75+
}
76+
path = 'annotations/instances_unlabeled2017.json'
77+
with open(path, 'w') as f:
78+
json.dump(unlabeled_json, f)
79+
```
80+
81+
</details>
82+
83+
84+
<details>
85+
<summary> 解压后的数据集目录如下:</summary>
86+
87+
```
88+
PaddleDetection
89+
├── dataset
90+
│ ├── coco
91+
│ │ ├── annotations
92+
│ │ │ ├── instances_train2017.json
93+
│ │ │ ├── instances_unlabeled2017.json
94+
│ │ │ ├── instances_val2017.json
95+
│ │ ├── semi_annotations
96+
│ │ │ ├── instances_train2017.1@1.json
97+
│ │ │ ├── instances_train2017.1@1-unlabeled.json
98+
│ │ │ ├── instances_train2017.1@2.json
99+
│ │ │ ├── instances_train2017.1@2-unlabeled.json
100+
│ │ │ ├── instances_train2017.1@5.json
101+
│ │ │ ├── instances_train2017.1@5-unlabeled.json
102+
│ │ │ ├── instances_train2017.1@10.json
103+
│ │ │ ├── instances_train2017.1@10-unlabeled.json
104+
│ │ ├── train2017
105+
│ │ ├── unlabeled2017
106+
│ │ ├── val2017
107+
```
108+
109+
</details>

configs/ssod/baseline/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Supervised Baseline 纯监督模型基线
2+
3+
## COCO数据集模型库
4+
5+
### [FCOS](../../fcos)
6+
7+
| 基础模型 | 监督数据比例 | mAP<sup>val<br>0.5:0.95 | 模型下载 | 配置文件 |
8+
| :---------------: | :-------------: | :---------------------: |:--------: | :---------: |
9+
| FCOS ResNet50-FPN | 5% | 21.3 | [download](https://paddledet.bj.bcebos.com/models/ssod/fcos_r50_fpn_2x_coco_sup005.pdparams) | [config](fcos_r50_fpn_2x_coco_sup005.yml) |
10+
| FCOS ResNet50-FPN | 10% | 26.3 | [download](https://paddledet.bj.bcebos.com/models/ssod/fcos_r50_fpn_2x_coco_sup010.pdparams) | [config](fcos_r50_fpn_2x_coco_sup010.yml) |
11+
| FCOS ResNet50-FPN | full | 42.6 | [download](https://paddledet.bj.bcebos.com/models/fcos_r50_fpn_iou_multiscale_2x_coco.pdparams) | [config](../../fcos/fcos_r50_fpn_iou_multiscale_2x_coco.yml) |
12+
13+
14+
### [PP-YOLOE+](../../ppyoloe)
15+
16+
| 基础模型 | 监督数据比例 | mAP<sup>val<br>0.5:0.95 | 模型下载 | 配置文件 |
17+
| :---------------: | :-------------: | :---------------------: |:--------: | :---------: |
18+
| PP-YOLOE+_s | 5% | 32.8 | [download](https://paddledet.bj.bcebos.com/models/ssod/ppyoloe_plus_crn_s_80e_coco_sup005.pdparams) | [config](ppyoloe_plus_crn_s_80e_coco_sup005.yml) |
19+
| PP-YOLOE+_s | 10% | 35.3 | [download](https://paddledet.bj.bcebos.com/models/ssod/ppyoloe_plus_crn_s_80e_coco_sup010.pdparams) | [config](ppyoloe_plus_crn_s_80e_coco_sup010.yml) |
20+
| PP-YOLOE+_s | full | 43.7 | [download](https://paddledet.bj.bcebos.com/models/ppyoloe_plus_crn_s_80e_coco.pdparams) | [config](../../ppyoloe/ppyoloe_plus_crn_s_80e_coco.yml) |
21+
22+
23+
### [Faster R-CNN](../../faster_rcnn)
24+
25+
| 基础模型 | 监督数据比例 | mAP<sup>val<br>0.5:0.95 | 模型下载 | 配置文件 |
26+
| :---------------: | :-------------: | :---------------------: |:--------: | :---------: |
27+
| Faster R-CNN ResNet50-FPN | 10% | 25.6 | [download](https://paddledet.bj.bcebos.com/models/ssod/faster_rcnn_r50_fpn_2x_coco_sup010.pdparams) | [config](faster_rcnn_r50_fpn_2x_coco_sup010.yml) |
28+
| Faster R-CNN ResNet50-FPN | full | 40.0 | [download](https://paddledet.bj.bcebos.com/models/faster_rcnn_r50_fpn_2x_coco.pdparams) | [config](../../configs/faster_rcnn/faster_rcnn_r50_fpn_2x_coco.yml) |
29+
30+
31+
### [RetinaNet](../../retinanet)
32+
33+
| 基础模型 | 监督数据比例 | mAP<sup>val<br>0.5:0.95 | 模型下载 | 配置文件 |
34+
| :---------------: | :-------------: | :---------------------: |:--------: | :---------: |
35+
| RetinaNet ResNet50-FPN | 10% | 23.6 | [download](https://paddledet.bj.bcebos.com/models/ssod/retinanet_r50_fpn_2x_coco_sup010.pdparams) | [config](retinanet_r50_fpn_2x_coco_sup010.yml) |
36+
| RetinaNet ResNet50-FPN | full | 37.5(1x) | [download](https://paddledet.bj.bcebos.com/models/retinanet_r50_fpn_1x_coco.pdparams) | [config](../../configs/retinanet/retinanet_r50_fpn_1x_coco.yml) |
37+
38+
39+
**注意:**
40+
- COCO部分监督数据集请参照 [数据集准备](../README.md) 去下载和准备,各个比例的训练集均为**从train2017中抽取部分百分比的子集**,默认使用`fold`号为1的划分子集,`sup010`表示抽取10%的监督数据训练,`sup005`表示抽取5%,`full`表示全部train2017,验证集均为val2017全量;
41+
- 抽取部分百分比的监督数据的抽法不同,或使用的`fold`号不同,精度都会因此而有约0.5 mAP之多的差异;
42+
- PP-YOLOE+ 使用Objects365预训练,其余模型均使用ImageNet预训练;
43+
- PP-YOLOE+ 训练80 epoch,其余模型均训练24 epoch,;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
_BASE_: [
2+
'../../faster_rcnn/faster_rcnn_r50_fpn_2x_coco.yml',
3+
]
4+
log_iter: 50
5+
snapshot_epoch: 2
6+
weights: output/faster_rcnn_r50_fpn_2x_coco_sup010/model_final
7+
8+
9+
TrainDataset:
10+
!COCODataSet
11+
image_dir: train2017
12+
anno_path: semi_annotations/instances_train2017.1@10.json
13+
dataset_dir: dataset/coco
14+
data_fields: ['image', 'gt_bbox', 'gt_class']
15+
16+
17+
epoch: 24
18+
LearningRate:
19+
base_lr: 0.01
20+
schedulers:
21+
- !PiecewiseDecay
22+
gamma: 0.1
23+
milestones: [16, 22]
24+
- !LinearWarmup
25+
start_factor: 0.1
26+
steps: 500

0 commit comments

Comments
 (0)