更换文档检测模型

This commit is contained in:
2024-08-27 14:42:45 +08:00
parent aea6f19951
commit 1514e09c40
2072 changed files with 254336 additions and 4967 deletions

View File

@@ -0,0 +1,48 @@
简体中文 | [English](README_en.md)
# Ambiguity-Resistant Semi-Supervised Learning for Dense Object Detection (ARSL)
## ARSL-FCOS 模型库
| 模型 | COCO监督数据比例 | Semi mAP<sup>val<br>0.5:0.95 | Semi Epochs (Iters) | 模型下载 | 配置文件 |
| :------------: | :---------:|:----------------------------: | :------------------: |:--------: |:----------: |
| ARSL-FCOS | 1% | **22.8** | 240 (87120) | [download](https://paddledet.bj.bcebos.com/models/arsl_fcos_r50_fpn_coco_semi001.pdparams) | [config](./arsl_fcos_r50_fpn_coco_semi001.yml) |
| ARSL-FCOS | 5% | **33.1** | 240 (174240) | [download](https://paddledet.bj.bcebos.com/models/arsl_fcos_r50_fpn_coco_semi005.pdparams) | [config](./arsl_fcos_r50_fpn_coco_semi005.yml ) |
| ARSL-FCOS | 10% | **36.9** | 240 (174240) | [download](https://paddledet.bj.bcebos.com/models/arsl_fcos_r50_fpn_coco_semi010.pdparams) | [config](./arsl_fcos_r50_fpn_coco_semi010.yml ) |
| ARSL-FCOS | 10% | **38.5(LSJ)** | 240 (174240) | [download](https://paddledet.bj.bcebos.com/models/arsl_fcos_r50_fpn_coco_semi010_lsj.pdparams) | [config](./arsl_fcos_r50_fpn_coco_semi010_lsj.yml ) |
| ARSL-FCOS | full(100%) | **45.1** | 240 (174240) | [download](https://paddledet.bj.bcebos.com/models/arsl_fcos_r50_fpn_coco_full.pdparams) | [config](./arsl_fcos_r50_fpn_coco_full.yml ) |
## 使用说明
仅训练时必须使用半监督检测的配置文件去训练,评估、预测、部署也可以按基础检测器的配置文件去执行。
### 训练
```bash
# 单卡训练 (不推荐,需按线性比例相应地调整学习率)
CUDA_VISIBLE_DEVICES=0 python tools/train.py -c configs/semi_det/arsl/arsl_fcos_r50_fpn_coco_semi010.yml --eval
# 多卡训练
python -m paddle.distributed.launch --log_dir=arsl_fcos_r50_fpn_coco_semi010/ --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/semi_det/arsl/arsl_fcos_r50_fpn_coco_semi010.yml --eval
```
### 评估
```bash
CUDA_VISIBLE_DEVICES=0 python tools/eval.py -c configs/semi_det/arsl/arsl_fcos_r50_fpn_coco_semi010.yml -o weights=output/arsl_fcos_r50_fpn_coco_semi010/model_final.pdparams
```
### 预测
```bash
CUDA_VISIBLE_DEVICES=0 python tools/infer.py -c configs/semi_det/arsl/arsl_fcos_r50_fpn_coco_semi010.yml -o weights=output/arsl_fcos_r50_fpn_coco_semi010/model_final.pdparams --infer_img=demo/000000014439.jpg
```
## 引用
```
```

View File

@@ -0,0 +1,56 @@
architecture: ARSL_FCOS
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_cos_pretrained.pdparams
ARSL_FCOS:
backbone: ResNet
neck: FPN
fcos_head: FCOSHead_ARSL
fcos_cr_loss: FCOSLossCR
ResNet:
depth: 50
norm_type: bn
freeze_at: 0
return_idx: [1,2,3]
num_stages: 4
FPN:
out_channel: 256
spatial_scales: [0.125, 0.0625, 0.03125]
extra_stage: 2
has_extra_convs: true
use_c5: false
FCOSHead_ARSL:
fcos_feat:
name: FCOSFeat
feat_in: 256
feat_out: 256
num_convs: 4
norm_type: "gn"
use_dcn: false
fpn_stride: [8, 16, 32, 64, 128]
prior_prob: 0.01
norm_reg_targets: True
centerness_on_reg: True
fcos_loss:
name: FCOSLossMILC
loss_alpha: 0.25
loss_gamma: 2.0
iou_loss_type: "giou"
reg_weights: 1.0
nms:
name: MultiClassNMS
nms_top_k: 1000
keep_top_k: 100
score_threshold: 0.025
nms_threshold: 0.6
FCOSLossCR:
iou_loss_type: "giou"
cls_weight: 2.0
reg_weight: 2.0
iou_weight: 0.5
hard_neg_mining_flag: true

View File

@@ -0,0 +1,55 @@
worker_num: 2
SemiTrainReader:
sample_transforms:
- Decode: {}
- RandomResize: {target_size: [[640, 1333], [672, 1333], [704, 1333], [736, 1333], [768, 1333], [800, 1333]], keep_ratio: True, interp: 1}
- RandomFlip: {}
weak_aug:
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: true}
strong_aug:
- StrongAugImage: {transforms: [
RandomColorJitter: {prob: 0.8, brightness: 0.4, contrast: 0.4, saturation: 0.4, hue: 0.1},
RandomErasingCrop: {},
RandomGaussianBlur: {prob: 0.5, sigma: [0.1, 2.0]},
RandomGrayscale: {prob: 0.2},
]}
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: true}
sup_batch_transforms:
- Permute: {}
- PadBatch: {pad_to_stride: 32}
- Gt2FCOSTarget:
object_sizes_boundary: [64, 128, 256, 512]
center_sampling_radius: 1.5
downsample_ratios: [8, 16, 32, 64, 128]
num_shift: 0. # default 0.5
multiply_strides_reg_targets: False
norm_reg_targets: True
unsup_batch_transforms:
- Permute: {}
- PadBatch: {pad_to_stride: 32}
sup_batch_size: 2
unsup_batch_size: 2
shuffle: True
drop_last: True
EvalReader:
sample_transforms:
- Decode: {}
- Resize: {interp: 2, target_size: [800, 1333], keep_ratio: True}
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: true}
- Permute: {}
batch_transforms:
- PadBatch: {pad_to_stride: 32}
batch_size: 1
TestReader:
sample_transforms:
- Decode: {}
- Resize: {interp: 2, target_size: [800, 1333], keep_ratio: True}
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: true}
- Permute: {}
batch_transforms:
- PadBatch: {pad_to_stride: 32}
batch_size: 1

View File

@@ -0,0 +1,29 @@
epoch: 120 # employ iter to control shedule
LearningRate:
base_lr: 0.02 # 0.02 for 8*(4+4) batch
schedulers:
- !PiecewiseDecay
gamma: 0.1
milestones: [3000] # do not decay lr
- !LinearWarmup
start_factor: 0.3333333333333333
steps: 1000
max_iter: 360000 # 360k for 32 batch, 720k for 16 batch
epoch_iter: 1000 # set epoch_iter for saving checkpoint and eval
optimize_rate: 1
SEMISUPNET:
BBOX_THRESHOLD: 0.5 # # not used
TEACHER_UPDATE_ITER: 1
BURN_UP_STEP: 30000
EMA_KEEP_RATE: 0.9996
UNSUP_LOSS_WEIGHT: 1.0 # detailed weights for cls and loc task can be seen in cr_loss
PSEUDO_WARM_UP_STEPS: 2000
OptimizerBuilder:
optimizer:
momentum: 0.9
type: Momentum
regularizer:
factor: 0.0001
type: L2

View File

@@ -0,0 +1,30 @@
epoch: 30 # employ iter to control shedule
LearningRate:
base_lr: 0.02 # 0.02 for 8*(4+4) batch
schedulers:
- !PiecewiseDecay
gamma: 0.1
milestones: [300] # do not decay lr
- !LinearWarmup
start_factor: 0.3333333333333333
steps: 1000
max_iter: 90000 # 90k for 32 batch, 180k for 16 batch
epoch_iter: 1000 # set epoch_iter for saving checkpoint and eval
# update student params according to loss_grad every X iter.
optimize_rate: 1
SEMISUPNET:
BBOX_THRESHOLD: 0.5 # not used
TEACHER_UPDATE_ITER: 1
BURN_UP_STEP: 9000
EMA_KEEP_RATE: 0.9996
UNSUP_LOSS_WEIGHT: 1.0 # detailed weights for cls and loc task can be seen in cr_loss
PSEUDO_WARM_UP_STEPS: 2000
OptimizerBuilder:
optimizer:
momentum: 0.9
type: Momentum
regularizer:
factor: 0.0001
type: L2

View File

@@ -0,0 +1,12 @@
_BASE_: [
'../_base_/coco_detection_full.yml',
'../../runtime.yml',
'_base_/arsl_fcos_r50_fpn.yml',
'_base_/optimizer_360k.yml',
'_base_/arsl_fcos_reader.yml',
]
weights: output/fcos_r50_fpn_arsl_360k_coco_full/model_final
#semi detector type
ssod_method: ARSL

View File

@@ -0,0 +1,12 @@
_BASE_: [
'../_base_/coco_detection_percent_1.yml',
'../../runtime.yml',
'_base_/arsl_fcos_r50_fpn.yml',
'_base_/optimizer_90k.yml',
'_base_/arsl_fcos_reader.yml',
]
weights: output/arsl_fcos_r50_fpn_coco_semi001/model_final
#semi detector type
ssod_method: ARSL

View File

@@ -0,0 +1,12 @@
_BASE_: [
'../_base_/coco_detection_percent_5.yml',
'../../runtime.yml',
'_base_/arsl_fcos_r50_fpn.yml',
'_base_/optimizer_90k.yml',
'_base_/arsl_fcos_reader.yml',
]
weights: output/arsl_fcos_r50_fpn_coco_semi005/model_final
#semi detector type
ssod_method: ARSL

View File

@@ -0,0 +1,12 @@
_BASE_: [
'../_base_/coco_detection_percent_10.yml',
'../../runtime.yml',
'_base_/arsl_fcos_r50_fpn.yml',
'_base_/optimizer_360k.yml',
'_base_/arsl_fcos_reader.yml',
]
weights: output/arsl_fcos_r50_fpn_coco_semi010/model_final
#semi detector type
ssod_method: ARSL

View File

@@ -0,0 +1,47 @@
_BASE_: [
'../_base_/coco_detection_percent_10.yml',
'../../runtime.yml',
'_base_/arsl_fcos_r50_fpn.yml',
'_base_/optimizer_360k.yml',
'_base_/arsl_fcos_reader.yml',
]
weights: output/arsl_fcos_r50_fpn_coco_semi010/model_final
#semi detector type
ssod_method: ARSL
worker_num: 2
SemiTrainReader:
sample_transforms:
- Decode: {}
# large-scale jittering
- RandomResize: {target_size: [[400, 1333], [1200, 1333]], keep_ratio: True, interp: 1, random_range: True}
- RandomFlip: {}
weak_aug:
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: true}
strong_aug:
- StrongAugImage: {transforms: [
RandomColorJitter: {prob: 0.8, brightness: 0.4, contrast: 0.4, saturation: 0.4, hue: 0.1},
RandomErasingCrop: {},
RandomGaussianBlur: {prob: 0.5, sigma: [0.1, 2.0]},
RandomGrayscale: {prob: 0.2},
]}
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: true}
sup_batch_transforms:
- Permute: {}
- PadBatch: {pad_to_stride: 32}
- Gt2FCOSTarget:
object_sizes_boundary: [64, 128, 256, 512]
center_sampling_radius: 1.5
downsample_ratios: [8, 16, 32, 64, 128]
num_shift: 0. # default 0.5
multiply_strides_reg_targets: False
norm_reg_targets: True
unsup_batch_transforms:
- Permute: {}
- PadBatch: {pad_to_stride: 32}
sup_batch_size: 2
unsup_batch_size: 2
shuffle: True
drop_last: True