From ae1b479c75a36d8a7dff1039c139d4e38d78e7d6 Mon Sep 17 00:00:00 2001 From: Feng Ni Date: Fri, 2 Apr 2021 17:52:25 +0800 Subject: [PATCH] comments for architectures post_process and data source (#2473) --- configs/cascade_rcnn/README.md | 4 +- configs/dcn/README.md | 22 ++++---- configs/faster_rcnn/README.md | 28 +++++----- configs/hrnet/README.md | 4 +- configs/mask_rcnn/README.md | 20 +++---- ppdet/data/source/category.py | 2 + ppdet/data/source/coco.py | 11 ++++ ppdet/data/source/dataset.py | 12 +++++ ppdet/data/source/voc.py | 1 + ppdet/data/source/widerface.py | 6 ++- ppdet/metrics/coco_utils.py | 16 +++--- ppdet/metrics/map_utils.py | 11 ++-- ppdet/modeling/architectures/cascade_rcnn.py | 12 +++++ ppdet/modeling/architectures/faster_rcnn.py | 17 +++--- ppdet/modeling/architectures/mask_rcnn.py | 19 ++++--- ppdet/modeling/backbones/hrnet.py | 48 ++++++++++++++++- ppdet/modeling/necks/hrfpn.py | 2 +- ppdet/modeling/post_process.py | 57 +++++++++++++++----- 18 files changed, 207 insertions(+), 85 deletions(-) diff --git a/configs/cascade_rcnn/README.md b/configs/cascade_rcnn/README.md index 887f706fd..fe2a2a7ad 100644 --- a/configs/cascade_rcnn/README.md +++ b/configs/cascade_rcnn/README.md @@ -4,8 +4,8 @@ | 骨架网络 | 网络类型 | 每张GPU图片个数 | 学习率策略 |推理时间(fps) | Box AP | Mask AP | 下载 | 配置文件 | | :------------------- | :------------- | :-----: | :-----: | :------------: | :-----: | :-----: | :-----------------------------------------------------: | :-----: | -| ResNet50-FPN | Cascade Faster | 1 | 1x | ---- | 41.1 | - | [下载链接](https://paddledet.bj.bcebos.com/models/cascade_rcnn_r50_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/cascade_rcnn/cascade_rcnn_r50_fpn_1x_coco.yml) | -| ResNet50-FPN | Cascade Mask | 1 | 1x | ---- | 41.8 | 36.3 | [下载链接](https://paddledet.bj.bcebos.com/models/cascade_mask_rcnn_r50_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/cascade_rcnn/cascade_mask_rcnn_r50_fpn_1x_coco.yml) | +| ResNet50-FPN | Cascade Faster | 1 | 1x | ---- | 41.1 | - | [下载链接](https://paddledet.bj.bcebos.com/models/cascade_rcnn_r50_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/cascade_rcnn/cascade_rcnn_r50_fpn_1x_coco.yml) | +| ResNet50-FPN | Cascade Mask | 1 | 1x | ---- | 41.8 | 36.3 | [下载链接](https://paddledet.bj.bcebos.com/models/cascade_mask_rcnn_r50_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/cascade_rcnn/cascade_mask_rcnn_r50_fpn_1x_coco.yml) | **注意:** Cascade R-CNN模型精度依赖Paddle develop分支修改,精度复现须使用[每日版本](https://www.paddlepaddle.org.cn/documentation/docs/zh/install/Tables.html#whl-dev)或2.0.1版本(将于2021.03发布),使用Paddle 2.0.0版本会有少量精度损失。 diff --git a/configs/dcn/README.md b/configs/dcn/README.md index 499b9cc0a..3248a387c 100644 --- a/configs/dcn/README.md +++ b/configs/dcn/README.md @@ -2,17 +2,17 @@ | 骨架网络 | 网络类型 | 卷积 | 每张GPU图片个数 | 学习率策略 |推理时间(fps)| Box AP | Mask AP | 下载 | 配置文件 | | :------------------- | :------------- | :-----: |:--------: | :-----: | :-----------: |:----: | :-----: | :----------------------------------------------------------: | :----: | -| ResNet50-FPN | Faster | c3-c5 | 1 | 1x | - | 42.1 | - | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_dcn_r50_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/dcn/faster_rcnn_dcn_r50_fpn_1x_coco.yml) | -| ResNet50-vd-FPN | Faster | c3-c5 | 1 | 1x | - | 42.7 | - | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_dcn_r50_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/dcn/faster_rcnn_dcn_r50_vd_fpn_1x_coco.yml) | -| ResNet50-vd-FPN | Faster | c3-c5 | 1 | 2x | - | 43.7 | - | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_dcn_r50_vd_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/dcn/faster_rcnn_dcn_r50_vd_fpn_2x_coco.yml) | -| ResNet101-vd-FPN | Faster | c3-c5 | 1 | 1x | - | 45.1 | - | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_dcn_r101_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/dcn/faster_rcnn_dcn_r101_vd_fpn_1x_coco.yml) | -| ResNeXt101-vd-FPN | Faster | c3-c5 | 1 | 1x | - | 46.5 | - | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_dcn_x101_vd_64x4d_fpn_1x_coco.pdparams) |[配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/dcn/faster_rcnn_dcn_x101_vd_64x4d_fpn_1x_coco.yml) | -| ResNet50-FPN | Mask | c3-c5 | 1 | 1x | - | 42.7 | 38.4 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_dcn_r50_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/dcn/mask_rcnn_dcn_r50_fpn_1x_coco.yml) | -| ResNet50-vd-FPN | Mask | c3-c5 | 1 | 2x | - | 44.6 | 39.8 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_dcn_r50_vd_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/dcn/mask_rcnn_dcn_r50_vd_fpn_2x_coco.yml) | -| ResNet101-vd-FPN | Mask | c3-c5 | 1 | 1x | - | 45.6 | 40.6 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_dcn_r101_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/dcn/mask_rcnn_dcn_r101_vd_fpn_1x_coco.yml) | -| ResNeXt101-vd-FPN | Mask | c3-c5 | 1 | 1x | - | 47.3 | 42.0 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_dcn_x101_vd_64x4d_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/dcn/mask_rcnn_dcn_x101_vd_64x4d_fpn_1x_coco.yml) | -| ResNet50-FPN | Cascade Faster | c3-c5 | 1 | 1x | - | 42.1 | - | [下载链接](https://paddledet.bj.bcebos.com/models/cascade_rcnn_dcn_r50_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/dcn/cascade_rcnn_dcn_r50_fpn_1x_coco.yml) | -| ResNeXt101-vd-FPN | Cascade Faster | c3-c5 | 1 | 1x | - | 48.8 | - | [下载链接](https://paddledet.bj.bcebos.com/models/cascade_rcnn_dcn_x101_vd_64x4d_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/dcn/cascade_rcnn_dcn_x101_vd_64x4d_fpn_1x_coco.yml) | +| ResNet50-FPN | Faster | c3-c5 | 1 | 1x | - | 42.1 | - | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_dcn_r50_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/dcn/faster_rcnn_dcn_r50_fpn_1x_coco.yml) | +| ResNet50-vd-FPN | Faster | c3-c5 | 1 | 1x | - | 42.7 | - | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_dcn_r50_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/dcn/faster_rcnn_dcn_r50_vd_fpn_1x_coco.yml) | +| ResNet50-vd-FPN | Faster | c3-c5 | 1 | 2x | - | 43.7 | - | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_dcn_r50_vd_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/dcn/faster_rcnn_dcn_r50_vd_fpn_2x_coco.yml) | +| ResNet101-vd-FPN | Faster | c3-c5 | 1 | 1x | - | 45.1 | - | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_dcn_r101_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/dcn/faster_rcnn_dcn_r101_vd_fpn_1x_coco.yml) | +| ResNeXt101-vd-FPN | Faster | c3-c5 | 1 | 1x | - | 46.5 | - | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_dcn_x101_vd_64x4d_fpn_1x_coco.pdparams) |[配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/dcn/faster_rcnn_dcn_x101_vd_64x4d_fpn_1x_coco.yml) | +| ResNet50-FPN | Mask | c3-c5 | 1 | 1x | - | 42.7 | 38.4 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_dcn_r50_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/dcn/mask_rcnn_dcn_r50_fpn_1x_coco.yml) | +| ResNet50-vd-FPN | Mask | c3-c5 | 1 | 2x | - | 44.6 | 39.8 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_dcn_r50_vd_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/dcn/mask_rcnn_dcn_r50_vd_fpn_2x_coco.yml) | +| ResNet101-vd-FPN | Mask | c3-c5 | 1 | 1x | - | 45.6 | 40.6 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_dcn_r101_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/dcn/mask_rcnn_dcn_r101_vd_fpn_1x_coco.yml) | +| ResNeXt101-vd-FPN | Mask | c3-c5 | 1 | 1x | - | 47.3 | 42.0 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_dcn_x101_vd_64x4d_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/dcn/mask_rcnn_dcn_x101_vd_64x4d_fpn_1x_coco.yml) | +| ResNet50-FPN | Cascade Faster | c3-c5 | 1 | 1x | - | 42.1 | - | [下载链接](https://paddledet.bj.bcebos.com/models/cascade_rcnn_dcn_r50_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/dcn/cascade_rcnn_dcn_r50_fpn_1x_coco.yml) | +| ResNeXt101-vd-FPN | Cascade Faster | c3-c5 | 1 | 1x | - | 48.8 | - | [下载链接](https://paddledet.bj.bcebos.com/models/cascade_rcnn_dcn_x101_vd_64x4d_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/dcn/cascade_rcnn_dcn_x101_vd_64x4d_fpn_1x_coco.yml) | **注意事项:** diff --git a/configs/faster_rcnn/README.md b/configs/faster_rcnn/README.md index 826b1a154..e3b5987c5 100644 --- a/configs/faster_rcnn/README.md +++ b/configs/faster_rcnn/README.md @@ -4,20 +4,20 @@ | 骨架网络 | 网络类型 | 每张GPU图片个数 | 学习率策略 |推理时间(fps) | Box AP | 下载 | 配置文件 | | :------------------- | :------------- | :-----: | :-----: | :------------: | :-----: | :-----------------------------------------------------: | :-----: | -| ResNet50 | Faster | 1 | 1x | ---- | 36.7 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r50_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/faster_rcnn/faster_rcnn_r50_1x_coco.yml) | -| ResNet50-vd | Faster | 1 | 1x | ---- | 37.6 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r50_vd_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/faster_rcnn/faster_rcnn_r50_vd_1x_coco.yml) | -| ResNet101 | Faster | 1 | 1x | ---- | 39.0 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r101_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/faster_rcnn/faster_rcnn_r101_1x_coco.yml) | -| ResNet34-FPN | Faster | 1 | 1x | ---- | 37.8 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r34_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/faster_rcnn/faster_rcnn_r34_fpn_1x_coco.yml) | -| ResNet34-vd-FPN | Faster | 1 | 1x | ---- | 38.5 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r34_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/faster_rcnn/faster_rcnn_r34_vd_fpn_1x_coco.yml) | -| ResNet50-FPN | Faster | 1 | 1x | ---- | 38.4 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r50_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.yml) | -| ResNet50-FPN | Faster | 1 | 2x | ---- | 40.0 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r50_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/faster_rcnn/faster_rcnn_r50_fpn_2x_coco.yml) | -| ResNet50-vd-FPN | Faster | 1 | 1x | ---- | 39.5 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r50_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/faster_rcnn/faster_rcnn_r50_vd_fpn_1x_coco.yml) | -| ResNet50-vd-FPN | Faster | 1 | 2x | ---- | 40.8 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r50_vd_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/faster_rcnn/faster_rcnn_r50_vd_fpn_2x_coco.yml) | -| ResNet101-FPN | Faster | 1 | 2x | ---- | 41.4 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r101_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/faster_rcnn/faster_rcnn_r101_fpn_2x_coco.yml) | -| ResNet101-vd-FPN | Faster | 1 | 1x | ---- | 42.0 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r101_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/faster_rcnn/faster_rcnn_r101_vd_fpn_1x_coco.yml) | -| ResNet101-vd-FPN | Faster | 1 | 2x | ---- | 43.0 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r101_vd_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/faster_rcnn/faster_rcnn_r101_vd_fpn_2x_coco.yml) | -| ResNeXt101-vd-FPN | Faster | 1 | 1x | ---- | 43.4 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_x101_vd_64x4d_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/faster_rcnn/faster_rcnn_x101_vd_64x4d_fpn_1x_coco.yml) | -| ResNeXt101-vd-FPN | Faster | 1 | 2x | ---- | 44.0 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_x101_vd_64x4d_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/faster_rcnn/faster_rcnn_x101_vd_64x4d_fpn_2x_coco.yml) | +| ResNet50 | Faster | 1 | 1x | ---- | 36.7 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r50_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/faster_rcnn/faster_rcnn_r50_1x_coco.yml) | +| ResNet50-vd | Faster | 1 | 1x | ---- | 37.6 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r50_vd_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/faster_rcnn/faster_rcnn_r50_vd_1x_coco.yml) | +| ResNet101 | Faster | 1 | 1x | ---- | 39.0 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r101_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/faster_rcnn/faster_rcnn_r101_1x_coco.yml) | +| ResNet34-FPN | Faster | 1 | 1x | ---- | 37.8 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r34_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/faster_rcnn/faster_rcnn_r34_fpn_1x_coco.yml) | +| ResNet34-vd-FPN | Faster | 1 | 1x | ---- | 38.5 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r34_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/faster_rcnn/faster_rcnn_r34_vd_fpn_1x_coco.yml) | +| ResNet50-FPN | Faster | 1 | 1x | ---- | 38.4 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r50_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.yml) | +| ResNet50-FPN | Faster | 1 | 2x | ---- | 40.0 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r50_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/faster_rcnn/faster_rcnn_r50_fpn_2x_coco.yml) | +| ResNet50-vd-FPN | Faster | 1 | 1x | ---- | 39.5 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r50_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/faster_rcnn/faster_rcnn_r50_vd_fpn_1x_coco.yml) | +| ResNet50-vd-FPN | Faster | 1 | 2x | ---- | 40.8 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r50_vd_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/faster_rcnn/faster_rcnn_r50_vd_fpn_2x_coco.yml) | +| ResNet101-FPN | Faster | 1 | 2x | ---- | 41.4 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r101_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/faster_rcnn/faster_rcnn_r101_fpn_2x_coco.yml) | +| ResNet101-vd-FPN | Faster | 1 | 1x | ---- | 42.0 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r101_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/faster_rcnn/faster_rcnn_r101_vd_fpn_1x_coco.yml) | +| ResNet101-vd-FPN | Faster | 1 | 2x | ---- | 43.0 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_r101_vd_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/faster_rcnn/faster_rcnn_r101_vd_fpn_2x_coco.yml) | +| ResNeXt101-vd-FPN | Faster | 1 | 1x | ---- | 43.4 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_x101_vd_64x4d_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/faster_rcnn/faster_rcnn_x101_vd_64x4d_fpn_1x_coco.yml) | +| ResNeXt101-vd-FPN | Faster | 1 | 2x | ---- | 44.0 | [下载链接](https://paddledet.bj.bcebos.com/models/faster_rcnn_x101_vd_64x4d_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/faster_rcnn/faster_rcnn_x101_vd_64x4d_fpn_2x_coco.yml) | **注意:** Faster R-CNN模型精度依赖Paddle develop分支修改,精度复现须使用[每日版本](https://www.paddlepaddle.org.cn/documentation/docs/zh/install/Tables.html#whl-dev)或2.0.1版本(将于2021.03发布),使用Paddle 2.0.0版本会有少量精度损失。 diff --git a/configs/hrnet/README.md b/configs/hrnet/README.md index 4e1807a39..1c6fec7bd 100644 --- a/configs/hrnet/README.md +++ b/configs/hrnet/README.md @@ -30,5 +30,5 @@ | Backbone | Type | Image/gpu | Lr schd | Inf time (fps) | Box AP | Mask AP | Download | Configs | | :---------------------- | :------------- | :-------: | :-----: | :------------: | :----: | :-----: | :----------------------------------------------------------: | :-----: | -| HRNetV2p_W18 | Faster | 1 | 1x | - | 36.8 | - | [model](https://paddledet.bj.bcebos.com/models/faster_rcnn_hrnetv2p_w18_1x_coco.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/hrnet/faster_rcnn_hrnetv2p_w18_1x_coco.yml) | -| HRNetV2p_W18 | Faster | 1 | 2x | - | 39.0 | - | [model](https://paddledet.bj.bcebos.com/models/faster_rcnn_hrnetv2p_w18_2x_coco.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/hrnet/faster_rcnn_hrnetv2p_w18_2x_coco.yml) | +| HRNetV2p_W18 | Faster | 1 | 1x | - | 36.8 | - | [model](https://paddledet.bj.bcebos.com/models/faster_rcnn_hrnetv2p_w18_1x_coco.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/hrnet/faster_rcnn_hrnetv2p_w18_1x_coco.yml) | +| HRNetV2p_W18 | Faster | 1 | 2x | - | 39.0 | - | [model](https://paddledet.bj.bcebos.com/models/faster_rcnn_hrnetv2p_w18_2x_coco.pdparams) | [config](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/hrnet/faster_rcnn_hrnetv2p_w18_2x_coco.yml) | diff --git a/configs/mask_rcnn/README.md b/configs/mask_rcnn/README.md index 4b98ada65..39d15322f 100644 --- a/configs/mask_rcnn/README.md +++ b/configs/mask_rcnn/README.md @@ -4,16 +4,16 @@ | 骨架网络 | 网络类型 | 每张GPU图片个数 | 学习率策略 |推理时间(fps) | Box AP | Mask AP | 下载 | 配置文件 | | :------------------- | :------------| :-----: | :-----: | :------------: | :-----: | :-----: | :-----------------------------------------------------: | :-----: | -| ResNet50 | Mask | 1 | 1x | ---- | 37.4 | 32.8 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r50_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/mask_rcnn/mask_rcnn_r50_1x_coco.yml) | -| ResNet50 | Mask | 1 | 2x | ---- | 39.7 | 34.5 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r50_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/mask_rcnn/mask_rcnn_r50_2x_coco.yml) | -| ResNet50-FPN | Mask | 1 | 1x | ---- | 39.2 | 35.6 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r50_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/mask_rcnn/mask_rcnn_r50_fpn_1x_coco.yml) | -| ResNet50-FPN | Mask | 1 | 2x | ---- | 40.5 | 36.7 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r50_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/mask_rcnn/mask_rcnn_r50_fpn_2x_coco.yml) | -| ResNet50-vd-FPN | Mask | 1 | 1x | ---- | 40.3 | 36.4 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r50_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/mask_rcnn/mask_rcnn_r50_vd_fpn_1x_coco.yml) | -| ResNet50-vd-FPN | Mask | 1 | 2x | ---- | 41.4 | 37.5 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r50_vd_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/mask_rcnn/mask_rcnn_r50_vd_fpn_2x_coco.yml) | -| ResNet101-FPN | Mask | 1 | 1x | ---- | 40.6 | 36.6 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r101_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/mask_rcnn/mask_rcnn_r101_fpn_1x_coco.yml) | -| ResNet101-vd-FPN | Mask | 1 | 1x | ---- | 42.4 | 38.1 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r101_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/mask_rcnn/mask_rcnn_r101_vd_fpn_1x_coco.yml) | -| ResNeXt101-vd-FPN | Mask | 1 | 1x | ---- | 44.0 | 39.5 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_x101_vd_64x4d_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/mask_rcnn/mask_rcnn_x101_vd_64x4d_fpn_1x_coco.yml) | -| ResNeXt101-vd-FPN | Mask | 1 | 2x | ---- | 44.6 | 39.8 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_x101_vd_64x4d_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/master/dygraph/configs/mask_rcnn/mask_rcnn_x101_vd_64x4d_fpn_2x_coco.yml) | +| ResNet50 | Mask | 1 | 1x | ---- | 37.4 | 32.8 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r50_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/mask_rcnn/mask_rcnn_r50_1x_coco.yml) | +| ResNet50 | Mask | 1 | 2x | ---- | 39.7 | 34.5 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r50_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/mask_rcnn/mask_rcnn_r50_2x_coco.yml) | +| ResNet50-FPN | Mask | 1 | 1x | ---- | 39.2 | 35.6 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r50_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/mask_rcnn/mask_rcnn_r50_fpn_1x_coco.yml) | +| ResNet50-FPN | Mask | 1 | 2x | ---- | 40.5 | 36.7 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r50_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/mask_rcnn/mask_rcnn_r50_fpn_2x_coco.yml) | +| ResNet50-vd-FPN | Mask | 1 | 1x | ---- | 40.3 | 36.4 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r50_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/mask_rcnn/mask_rcnn_r50_vd_fpn_1x_coco.yml) | +| ResNet50-vd-FPN | Mask | 1 | 2x | ---- | 41.4 | 37.5 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r50_vd_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/mask_rcnn/mask_rcnn_r50_vd_fpn_2x_coco.yml) | +| ResNet101-FPN | Mask | 1 | 1x | ---- | 40.6 | 36.6 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r101_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/mask_rcnn/mask_rcnn_r101_fpn_1x_coco.yml) | +| ResNet101-vd-FPN | Mask | 1 | 1x | ---- | 42.4 | 38.1 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_r101_vd_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/mask_rcnn/mask_rcnn_r101_vd_fpn_1x_coco.yml) | +| ResNeXt101-vd-FPN | Mask | 1 | 1x | ---- | 44.0 | 39.5 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_x101_vd_64x4d_fpn_1x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/mask_rcnn/mask_rcnn_x101_vd_64x4d_fpn_1x_coco.yml) | +| ResNeXt101-vd-FPN | Mask | 1 | 2x | ---- | 44.6 | 39.8 | [下载链接](https://paddledet.bj.bcebos.com/models/mask_rcnn_x101_vd_64x4d_fpn_2x_coco.pdparams) | [配置文件](https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/mask_rcnn/mask_rcnn_x101_vd_64x4d_fpn_2x_coco.yml) | **注意:** Mask R-CNN模型精度依赖Paddle develop分支修改,精度复现须使用[每日版本](https://www.paddlepaddle.org.cn/documentation/docs/zh/install/Tables.html#whl-dev)或2.0.1版本(将于2021.03发布),使用Paddle 2.0.0版本会有少量精度损失。 diff --git a/ppdet/data/source/category.py b/ppdet/data/source/category.py index fe73af7a4..06fbcccbb 100644 --- a/ppdet/data/source/category.py +++ b/ppdet/data/source/category.py @@ -32,6 +32,8 @@ def get_categories(metric_type, anno_file=None): to category name map from annotation file. Args: + metric_type (str): metric type, currently support 'coco', 'voc', 'oid' + and 'widerface'. anno_file (str): annotation file path """ if metric_type.lower() == 'coco': diff --git a/ppdet/data/source/coco.py b/ppdet/data/source/coco.py index 18625cfb5..d5691c7be 100644 --- a/ppdet/data/source/coco.py +++ b/ppdet/data/source/coco.py @@ -24,6 +24,17 @@ logger = setup_logger(__name__) @register @serializable class COCODataSet(DetDataset): + """ + Load dataset with COCO format. + + Args: + dataset_dir (str): root directory for dataset. + image_dir (str): directory for images. + anno_path (str): coco annotation file path. + data_fields (list): key name of data dictionary, at least have 'image'. + sample_num (int): number of samples to load, -1 means all. + """ + def __init__(self, dataset_dir=None, image_dir=None, diff --git a/ppdet/data/source/dataset.py b/ppdet/data/source/dataset.py index 14d1b5400..07330a6b2 100644 --- a/ppdet/data/source/dataset.py +++ b/ppdet/data/source/dataset.py @@ -27,6 +27,18 @@ import copy @serializable class DetDataset(Dataset): + """ + Load detection dataset. + + Args: + dataset_dir (str): root directory for dataset. + image_dir (str): directory for images. + anno_path (str): annotation file path. + data_fields (list): key name of data dictionary, at least have 'image'. + sample_num (int): number of samples to load, -1 means all. + use_default_label (bool): whether to load default label list. + """ + def __init__(self, dataset_dir=None, image_dir=None, diff --git a/ppdet/data/source/voc.py b/ppdet/data/source/voc.py index 00d976ce0..562366ae8 100644 --- a/ppdet/data/source/voc.py +++ b/ppdet/data/source/voc.py @@ -38,6 +38,7 @@ class VOCDataSet(DetDataset): dataset_dir (str): root directory for dataset. image_dir (str): directory for images. anno_path (str): voc annotation file path. + data_fields (list): key name of data dictionary, at least have 'image'. sample_num (int): number of samples to load, -1 means all. label_list (str): if use_default_label is False, will load mapping between category and class index. diff --git a/ppdet/data/source/widerface.py b/ppdet/data/source/widerface.py index db2b74326..b1813b0e0 100644 --- a/ppdet/data/source/widerface.py +++ b/ppdet/data/source/widerface.py @@ -31,8 +31,10 @@ class WIDERFaceDataSet(DetDataset): Args: dataset_dir (str): root directory for dataset. image_dir (str): directory for images. - anno_path (str): root directory for voc annotation data - sample_num (int): number of samples to load, -1 means all + anno_path (str): WiderFace annotation data. + data_fields (list): key name of data dictionary, at least have 'image'. + sample_num (int): number of samples to load, -1 means all. + with_lmk (bool): whether to load face landmark keypoint labels. """ def __init__(self, diff --git a/ppdet/metrics/coco_utils.py b/ppdet/metrics/coco_utils.py index 984abfbf7..9e45b1c2a 100644 --- a/ppdet/metrics/coco_utils.py +++ b/ppdet/metrics/coco_utils.py @@ -67,13 +67,13 @@ def cocoapi_eval(jsonfile, classwise=False): """ Args: - jsonfile: Evaluation json file, eg: bbox.json, mask.json. - style: COCOeval style, can be `bbox` , `segm` and `proposal`. - coco_gt: Whether to load COCOAPI through anno_file, + jsonfile (str): Evaluation json file, eg: bbox.json, mask.json. + style (str): COCOeval style, can be `bbox` , `segm` and `proposal`. + coco_gt (str): Whether to load COCOAPI through anno_file, eg: coco_gt = COCO(anno_file) - anno_file: COCO annotations file. - max_dets: COCO evaluation maxDets. - classwise: whether per-category AP and draw P-R Curve or not. + anno_file (str): COCO annotations file. + max_dets (tuple): COCO evaluation maxDets. + classwise (bool): Whether per-category AP and draw P-R Curve or not. """ assert coco_gt != None or anno_file != None from pycocotools.coco import COCO @@ -142,9 +142,7 @@ def cocoapi_eval(jsonfile, return coco_eval.stats -def json_eval_results(metric: object, - json_directory: object=None, - dataset: object=None) -> object: +def json_eval_results(metric, json_directory, dataset): """ cocoapi eval with already exists proposal.json, bbox.json or mask.json """ diff --git a/ppdet/metrics/map_utils.py b/ppdet/metrics/map_utils.py index 21c0e3922..17730bcdf 100644 --- a/ppdet/metrics/map_utils.py +++ b/ppdet/metrics/map_utils.py @@ -101,19 +101,20 @@ class DetectionMAP(object): Currently support two types: 11point and integral Args: - class_num (int): the class number. + class_num (int): The class number. overlap_thresh (float): The threshold of overlap ratio between prediction bounding box and ground truth bounding box for deciding true/false positive. Default 0.5. - map_type (str): calculation method of mean average + map_type (str): Calculation method of mean average precision, currently support '11point' and 'integral'. Default '11point'. - is_bbox_normalized (bool): whther bounding boxes + is_bbox_normalized (bool): Whether bounding boxes is normalized to range[0, 1]. Default False. - evaluate_difficult (bool): whether to evaluate + evaluate_difficult (bool): Whether to evaluate difficult bounding boxes. Default False. - classwise (bool): whether per-category AP and draw + catid2name (dict): Mapping between category id and category name. + classwise (bool): Whether per-category AP and draw P-R Curve or not. """ diff --git a/ppdet/modeling/architectures/cascade_rcnn.py b/ppdet/modeling/architectures/cascade_rcnn.py index 987d7a77a..ac29b775d 100644 --- a/ppdet/modeling/architectures/cascade_rcnn.py +++ b/ppdet/modeling/architectures/cascade_rcnn.py @@ -25,6 +25,18 @@ __all__ = ['CascadeRCNN'] @register class CascadeRCNN(BaseArch): + """ + Cascade R-CNN network, see https://arxiv.org/abs/1712.00726 + + Args: + backbone (object): backbone instance + rpn_head (object): `RPNHead` instance + bbox_head (object): `BBoxHead` instance + bbox_post_process (object): `BBoxPostProcess` instance + neck (object): 'FPN' instance + mask_head (object): `MaskHead` instance + mask_post_process (object): `MaskPostProcess` instance + """ __category__ = 'architecture' __inject__ = [ 'bbox_post_process', diff --git a/ppdet/modeling/architectures/faster_rcnn.py b/ppdet/modeling/architectures/faster_rcnn.py index b7cd9308f..26a2672d6 100644 --- a/ppdet/modeling/architectures/faster_rcnn.py +++ b/ppdet/modeling/architectures/faster_rcnn.py @@ -25,6 +25,16 @@ __all__ = ['FasterRCNN'] @register class FasterRCNN(BaseArch): + """ + Faster R-CNN network, see https://arxiv.org/abs/1506.01497 + + Args: + backbone (object): backbone instance + rpn_head (object): `RPNHead` instance + bbox_head (object): `BBoxHead` instance + bbox_post_process (object): `BBoxPostProcess` instance + neck (object): 'FPN' instance + """ __category__ = 'architecture' __inject__ = ['bbox_post_process'] @@ -34,13 +44,6 @@ class FasterRCNN(BaseArch): bbox_head, bbox_post_process, neck=None): - """ - backbone (nn.Layer): backbone instance. - rpn_head (nn.Layer): generates proposals using backbone features. - bbox_head (nn.Layer): a head that performs per-region computation. - mask_head (nn.Layer): generates mask from bbox and backbone features. - """ - super(FasterRCNN, self).__init__() self.backbone = backbone self.neck = neck diff --git a/ppdet/modeling/architectures/mask_rcnn.py b/ppdet/modeling/architectures/mask_rcnn.py index 3b5618655..071a326f4 100644 --- a/ppdet/modeling/architectures/mask_rcnn.py +++ b/ppdet/modeling/architectures/mask_rcnn.py @@ -25,6 +25,19 @@ __all__ = ['MaskRCNN'] @register class MaskRCNN(BaseArch): + """ + Mask R-CNN network, see https://arxiv.org/abs/1703.06870 + + Args: + backbone (object): backbone instance + rpn_head (object): `RPNHead` instance + bbox_head (object): `BBoxHead` instance + mask_head (object): `MaskHead` instance + bbox_post_process (object): `BBoxPostProcess` instance + mask_post_process (object): `MaskPostProcess` instance + neck (object): 'FPN' instance + """ + __category__ = 'architecture' __inject__ = [ 'bbox_post_process', @@ -39,12 +52,6 @@ class MaskRCNN(BaseArch): bbox_post_process, mask_post_process, neck=None): - """ - backbone (nn.Layer): backbone instance. - rpn_head (nn.Layer): generates proposals using backbone features. - bbox_head (nn.Layer): a head that performs per-region computation. - mask_head (nn.Layer): generates mask from bbox and backbone features. - """ super(MaskRCNN, self).__init__() self.backbone = backbone self.neck = neck diff --git a/ppdet/modeling/backbones/hrnet.py b/ppdet/modeling/backbones/hrnet.py index 4450bd9a5..f93f5fd9c 100644 --- a/ppdet/modeling/backbones/hrnet.py +++ b/ppdet/modeling/backbones/hrnet.py @@ -97,7 +97,12 @@ class ConvNormLayer(nn.Layer): class Layer1(nn.Layer): - def __init__(self, num_channels, has_se=False, freeze_norm=True, name=None): + def __init__(self, + num_channels, + has_se=False, + norm_decay=0., + freeze_norm=True, + name=None): super(Layer1, self).__init__() self.bottleneck_block_list = [] @@ -111,6 +116,7 @@ class Layer1(nn.Layer): has_se=has_se, stride=1, downsample=True if i == 0 else False, + norm_decay=norm_decay, freeze_norm=freeze_norm, name=name + '_' + str(i + 1))) self.bottleneck_block_list.append(bottleneck_block) @@ -123,7 +129,12 @@ class Layer1(nn.Layer): class TransitionLayer(nn.Layer): - def __init__(self, in_channels, out_channels, freeze_norm=True, name=None): + def __init__(self, + in_channels, + out_channels, + norm_decay=0., + freeze_norm=True, + name=None): super(TransitionLayer, self).__init__() num_in = len(in_channels) @@ -140,6 +151,7 @@ class TransitionLayer(nn.Layer): ch_in=in_channels[i], ch_out=out_channels[i], filter_size=3, + norm_decay=norm_decay, freeze_norm=freeze_norm, act='relu', name=name + '_layer_' + str(i + 1))) @@ -151,6 +163,7 @@ class TransitionLayer(nn.Layer): ch_out=out_channels[i], filter_size=3, stride=2, + norm_decay=norm_decay, freeze_norm=freeze_norm, act='relu', name=name + '_layer_' + str(i + 1))) @@ -175,6 +188,7 @@ class Branches(nn.Layer): in_channels, out_channels, has_se=False, + norm_decay=0., freeze_norm=True, name=None): super(Branches, self).__init__() @@ -190,6 +204,7 @@ class Branches(nn.Layer): num_channels=in_ch, num_filters=out_channels[i], has_se=has_se, + norm_decay=norm_decay, freeze_norm=freeze_norm, name=name + '_branch_layer_' + str(i + 1) + '_' + str(j + 1))) @@ -213,6 +228,7 @@ class BottleneckBlock(nn.Layer): has_se, stride=1, downsample=False, + norm_decay=0., freeze_norm=True, name=None): super(BottleneckBlock, self).__init__() @@ -224,6 +240,7 @@ class BottleneckBlock(nn.Layer): ch_in=num_channels, ch_out=num_filters, filter_size=1, + norm_decay=norm_decay, freeze_norm=freeze_norm, act="relu", name=name + "_conv1") @@ -232,6 +249,7 @@ class BottleneckBlock(nn.Layer): ch_out=num_filters, filter_size=3, stride=stride, + norm_decay=norm_decay, freeze_norm=freeze_norm, act="relu", name=name + "_conv2") @@ -239,6 +257,7 @@ class BottleneckBlock(nn.Layer): ch_in=num_filters, ch_out=num_filters * 4, filter_size=1, + norm_decay=norm_decay, freeze_norm=freeze_norm, act=None, name=name + "_conv3") @@ -248,6 +267,7 @@ class BottleneckBlock(nn.Layer): ch_in=num_channels, ch_out=num_filters * 4, filter_size=1, + norm_decay=norm_decay, freeze_norm=freeze_norm, act=None, name=name + "_downsample") @@ -283,6 +303,7 @@ class BasicBlock(nn.Layer): stride=1, has_se=False, downsample=False, + norm_decay=0., freeze_norm=True, name=None): super(BasicBlock, self).__init__() @@ -293,6 +314,7 @@ class BasicBlock(nn.Layer): ch_in=num_channels, ch_out=num_filters, filter_size=3, + norm_decay=norm_decay, freeze_norm=freeze_norm, stride=stride, act="relu", @@ -301,6 +323,7 @@ class BasicBlock(nn.Layer): ch_in=num_filters, ch_out=num_filters, filter_size=3, + norm_decay=norm_decay, freeze_norm=freeze_norm, stride=1, act=None, @@ -311,6 +334,7 @@ class BasicBlock(nn.Layer): ch_in=num_channels, ch_out=num_filters * 4, filter_size=1, + norm_decay=norm_decay, freeze_norm=freeze_norm, act=None, name=name + "_downsample") @@ -381,6 +405,7 @@ class Stage(nn.Layer): num_modules, num_filters, has_se=False, + norm_decay=0., freeze_norm=True, multi_scale_output=True, name=None): @@ -396,6 +421,7 @@ class Stage(nn.Layer): num_channels=num_channels, num_filters=num_filters, has_se=has_se, + norm_decay=norm_decay, freeze_norm=freeze_norm, multi_scale_output=False, name=name + '_' + str(i + 1))) @@ -406,6 +432,7 @@ class Stage(nn.Layer): num_channels=num_channels, num_filters=num_filters, has_se=has_se, + norm_decay=norm_decay, freeze_norm=freeze_norm, name=name + '_' + str(i + 1))) @@ -424,6 +451,7 @@ class HighResolutionModule(nn.Layer): num_filters, has_se=False, multi_scale_output=True, + norm_decay=0., freeze_norm=True, name=None): super(HighResolutionModule, self).__init__() @@ -432,6 +460,7 @@ class HighResolutionModule(nn.Layer): in_channels=num_channels, out_channels=num_filters, has_se=has_se, + norm_decay=norm_decay, freeze_norm=freeze_norm, name=name) @@ -439,6 +468,7 @@ class HighResolutionModule(nn.Layer): in_channels=num_filters, out_channels=num_filters, multi_scale_output=multi_scale_output, + norm_decay=norm_decay, freeze_norm=freeze_norm, name=name) @@ -453,6 +483,7 @@ class FuseLayers(nn.Layer): in_channels, out_channels, multi_scale_output=True, + norm_decay=0., freeze_norm=True, name=None): super(FuseLayers, self).__init__() @@ -473,6 +504,7 @@ class FuseLayers(nn.Layer): filter_size=1, stride=1, act=None, + norm_decay=norm_decay, freeze_norm=freeze_norm, name=name + '_layer_' + str(i + 1) + '_' + str(j + 1))) @@ -489,6 +521,7 @@ class FuseLayers(nn.Layer): ch_out=out_channels[i], filter_size=3, stride=2, + norm_decay=norm_decay, freeze_norm=freeze_norm, act=None, name=name + '_layer_' + str(i + 1) + '_' + @@ -503,6 +536,7 @@ class FuseLayers(nn.Layer): ch_out=out_channels[j], filter_size=3, stride=2, + norm_decay=norm_decay, freeze_norm=freeze_norm, act="relu", name=name + '_layer_' + str(i + 1) + '_' + @@ -544,6 +578,7 @@ class HRNet(nn.Layer): has_se (bool): whether to add SE block for each stage freeze_at (int): the stage to freeze freeze_norm (bool): whether to freeze norm in HRNet + norm_decay (float): weight decay for normalization layer weights return_idx (List): the stage to return """ @@ -586,6 +621,7 @@ class HRNet(nn.Layer): ch_out=64, filter_size=3, stride=2, + norm_decay=norm_decay, freeze_norm=freeze_norm, act='relu', name="layer1_1") @@ -595,6 +631,7 @@ class HRNet(nn.Layer): ch_out=64, filter_size=3, stride=2, + norm_decay=norm_decay, freeze_norm=freeze_norm, act='relu', name="layer1_2") @@ -602,12 +639,14 @@ class HRNet(nn.Layer): self.la1 = Layer1( num_channels=64, has_se=has_se, + norm_decay=norm_decay, freeze_norm=freeze_norm, name="layer2") self.tr1 = TransitionLayer( in_channels=[256], out_channels=channels_2, + norm_decay=norm_decay, freeze_norm=freeze_norm, name="tr1") @@ -616,12 +655,14 @@ class HRNet(nn.Layer): num_modules=num_modules_2, num_filters=channels_2, has_se=self.has_se, + norm_decay=norm_decay, freeze_norm=freeze_norm, name="st2") self.tr2 = TransitionLayer( in_channels=channels_2, out_channels=channels_3, + norm_decay=norm_decay, freeze_norm=freeze_norm, name="tr2") @@ -630,12 +671,14 @@ class HRNet(nn.Layer): num_modules=num_modules_3, num_filters=channels_3, has_se=self.has_se, + norm_decay=norm_decay, freeze_norm=freeze_norm, name="st3") self.tr3 = TransitionLayer( in_channels=channels_3, out_channels=channels_4, + norm_decay=norm_decay, freeze_norm=freeze_norm, name="tr3") self.st4 = Stage( @@ -643,6 +686,7 @@ class HRNet(nn.Layer): num_modules=num_modules_4, num_filters=channels_4, has_se=self.has_se, + norm_decay=norm_decay, freeze_norm=freeze_norm, name="st4") diff --git a/ppdet/modeling/necks/hrfpn.py b/ppdet/modeling/necks/hrfpn.py index 7afbbc0ea..4b737c9fb 100644 --- a/ppdet/modeling/necks/hrfpn.py +++ b/ppdet/modeling/necks/hrfpn.py @@ -30,8 +30,8 @@ class HRFPN(nn.Layer): in_channels (list): number of input feature channels from backbone out_channel (int): number of output feature channels share_conv (bool): whether to share conv for different layers' reduction - spatial_scales (list): feature map scaling factor extra_stage (int): add extra stage for returning HRFPN fpn_feats + spatial_scales (list): feature map scaling factor """ def __init__(self, diff --git a/ppdet/modeling/post_process.py b/ppdet/modeling/post_process.py index 2b2fc4483..bfebe98b4 100644 --- a/ppdet/modeling/post_process.py +++ b/ppdet/modeling/post_process.py @@ -24,6 +24,8 @@ try: except Exception: from collections import Sequence +__all__ = ['BBoxPostProcess', 'MaskPostProcess', 'FCOSPostProcess'] + @register class BBoxPostProcess(object): @@ -40,13 +42,17 @@ class BBoxPostProcess(object): """ Decode the bbox and do NMS if needed. + Args: + head_out (tuple): bbox_pred and cls_prob of bbox_head output. + rois (tuple): roi and rois_num of rpn_head output. + im_shape (Tensor): The shape of the input image. + scale_factor (Tensor): The scale factor of the input image. Returns: - bbox_pred(Tensor): The output is the prediction with shape [N, 6] - including labels, scores and bboxes. The size of - bboxes are corresponding to the input image and - the bboxes may be used in other brunch. - bbox_num(Tensor): The number of prediction of each batch with shape - [N, 6]. + bbox_pred (Tensor): The output prediction with shape [N, 6], including + labels, scores and bboxes. The size of bboxes are corresponding + to the input image, the bboxes may be used in other branch. + bbox_num (Tensor): The number of prediction boxes of each batch with + shape [1], and is N. """ if self.nms is not None: bboxes, score = self.decode(head_out, rois, im_shape, scale_factor) @@ -54,6 +60,9 @@ class BBoxPostProcess(object): else: bbox_pred, bbox_num = self.decode(head_out, rois, im_shape, scale_factor) + + # Prevent empty bbox_pred from decode or NMS. + # Bboxes and score before NMS may be empty due to the score threshold. if bbox_pred.shape[0] == 0: bbox_pred = paddle.to_tensor( np.array( @@ -64,16 +73,22 @@ class BBoxPostProcess(object): def get_pred(self, bboxes, bbox_num, im_shape, scale_factor): """ Rescale, clip and filter the bbox from the output of NMS to - get final prediction. + get final prediction. + + Notes: + Currently only support bs = 1. Args: - bboxes(Tensor): The output of __call__ with shape [N, 6] + bbox_pred (Tensor): The output bboxes with shape [N, 6] after decode + and NMS, including labels, scores and bboxes. + bbox_num (Tensor): The number of prediction boxes of each batch with + shape [1], and is N. + im_shape (Tensor): The shape of the input image. + scale_factor (Tensor): The scale factor of the input image. Returns: - bbox_pred(Tensor): The output is the prediction with shape [N, 6] - including labels, scores and bboxes. The size of - bboxes are corresponding to the original image. + pred_result (Tensor): The final prediction results with shape [N, 6] + including labels, scores and bboxes. """ - origin_shape = paddle.floor(im_shape / scale_factor + 0.5) origin_shape_list = [] @@ -125,7 +140,9 @@ class MaskPostProcess(object): self.binary_thresh = binary_thresh def paste_mask(self, masks, boxes, im_h, im_w): - # paste each mask on image + """ + Paste the mask prediction to the original image. + """ x0, y0, x1, y1 = paddle.split(boxes, 4, axis=1) masks = paddle.unsqueeze(masks, [0, 1]) img_y = paddle.arange(0, im_h, dtype='float32') + 0.5 @@ -148,7 +165,19 @@ class MaskPostProcess(object): def __call__(self, mask_out, bboxes, bbox_num, origin_shape): """ - Paste the mask prediction to the original image. + Decode the mask_out and paste the mask to the origin image. + + Args: + mask_out (Tensor): mask_head output with shape [N, 28, 28]. + bbox_pred (Tensor): The output bboxes with shape [N, 6] after decode + and NMS, including labels, scores and bboxes. + bbox_num (Tensor): The number of prediction boxes of each batch with + shape [1], and is N. + origin_shape (Tensor): The origin shape of the input image, the tensor + shape is [N, 2], and each row is [h, w]. + Returns: + pred_result (Tensor): The final prediction mask results with shape + [N, h, w] in binary mask style. """ num_mask = mask_out.shape[0] origin_shape = paddle.cast(origin_shape, 'int32') -- GitLab