From 95934acade5e5aaf736efa2fc28e4756ffec7948 Mon Sep 17 00:00:00 2001 From: qingqing01 Date: Wed, 13 May 2020 02:21:12 -0500 Subject: [PATCH] Update docs (#653) * Update docs * Update README.md --- README.md | 24 ++++++++++++------ README_en.md | 21 +++++++++++----- .../TRANSFER_LEARNING_cn.md | 7 +++--- docs/tutorials/GETTING_STARTED.md | 2 ++ docs/tutorials/GETTING_STARTED_cn.md | 2 ++ slim/distillation/distill.py | 9 +++++-- .../distill_pruned_model.py | 8 +++++- slim/nas/train_nas.py | 22 +++++----------- slim/prune/eval.py | 18 ++++--------- slim/prune/export_model.py | 6 ++++- slim/prune/prune.py | 9 ++++++- slim/quantization/eval.py | 8 ++++-- slim/quantization/export_model.py | 8 ++++-- slim/quantization/infer.py | 10 +++++--- slim/quantization/train.py | 9 ++++--- slim/sensitive/sensitive.py | 20 +++++---------- tools/eval.py | 16 +----------- tools/infer.py | 18 ++----------- tools/train.py | 25 +++++-------------- 19 files changed, 116 insertions(+), 126 deletions(-) diff --git a/README.md b/README.md index ede5f15a4..f23075d84 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,14 @@ | BlazeFace | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | | Faceboxes | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | -[1] [ResNet-vd](https://arxiv.org/pdf/1812.01187) 模型提供了较大的精度提高和较少的性能损失。 +[1] [ResNet-vd](https://arxiv.org/pdf/1812.01187) 模型预测速度基本不变的情况下提高了精度。 + +更多的模型: + +- EfficientDet +- FCOS +- CornerNet-Squeeze +- YOLOv4 更多的Backone: @@ -52,10 +59,11 @@ - VGG - GCNet - CBNet +- Hourglass 扩展特性: -- [x] **Synchronized Batch Norm**: 目前在YOLOv3中使用。 +- [x] **Synchronized Batch Norm** - [x] **Group Norm** - [x] **Modulated Deformable Convolution** - [x] **Deformable PSRoI Pooling** @@ -107,12 +115,14 @@ ## 模型库 - [模型库](docs/MODEL_ZOO_cn.md) -- [人脸检测模型](docs/featured_model/FACE_DETECTION.md) 开源BlazeFace系列模型,Wider-Face数据集上最高精度达到91.5%,同时具备了较高的预测性能 -- [行人检测和车辆检测预训练模型](docs/featured_model/CONTRIB_cn.md) 针对不同场景的检测模型 -- [YOLOv3增强模型](docs/featured_model/YOLOv3_ENHANCEMENT.md) 改进原始YOLOv3,精度达到43.6%,原论文精度为33.0%,同时预测速度也得到提升 -- [Objects365 2019 Challenge夺冠模型](docs/featured_model/CACascadeRCNN.md) Objects365 Full Track任务中最好的单模型之一,精度达到31.7% -- [Open Images V5和Objects365数据集模型](docs/featured_model/OIDV5_BASELINE_MODEL.md) - [移动端模型](configs/mobile/README.md) +- [Anchor free模型](configs/anchor_free/README.md) +- [人脸检测模型](docs/featured_model/FACE_DETECTION.md) +- [YOLOv3增强模型](docs/featured_model/YOLOv3_ENHANCEMENT.md): COCO mAP高达43.6%,原论文精度为33.0% +- [行人检测预训练模型](docs/featured_model/CONTRIB_cn.md) +- [车辆检测预训练模型](docs/featured_model/CONTRIB_cn.md) +- [Objects365 2019 Challenge夺冠模型](docs/featured_model/CACascadeRCNN.md) +- [Open Images 2019-Object Detction比赛最佳单模型](docs/featured_model/OIDV5_BASELINE_MODEL.md) ## 许可证书 diff --git a/README_en.md b/README_en.md index 9a3d4697c..9b7f12c68 100644 --- a/README_en.md +++ b/README_en.md @@ -59,6 +59,13 @@ Supported Architectures: [1] [ResNet-vd](https://arxiv.org/pdf/1812.01187) models offer much improved accuracy with negligible performance cost. +More models: + +- EfficientDet +- FCOS +- CornerNet-Squeeze +- YOLOv4 + More Backbones: - DarkNet @@ -68,7 +75,7 @@ More Backbones: Advanced Features: -- [x] **Synchronized Batch Norm**: currently used by YOLOv3. +- [x] **Synchronized Batch Norm** - [x] **Group Norm** - [x] **Modulated Deformable Convolution** - [x] **Deformable PSRoI Pooling** @@ -121,12 +128,14 @@ The following is the relationship between COCO mAP and FPS on Tesla V100 of repr ## Model Zoo - Pretrained models are available in the [PaddleDetection model zoo](docs/MODEL_ZOO.md). -- [Face detection models](docs/featured_model/FACE_DETECTION_en.md) BlazeFace series model with the highest precision of 91.5% on Wider-Face dataset and outstanding inference performance. -- [Pretrained models for pedestrian and vehicle detection](docs/featured_model/CONTRIB.md) Models for object detection in specific scenarios. -- [YOLOv3 enhanced model](docs/featured_model/YOLOv3_ENHANCEMENT.md) Compared to MAP of 33.0% in paper, enhanced YOLOv3 reaches the MAP of 43.6% and inference speed is improved as well -- [Objects365 2019 Challenge champion model](docs/featured_model/CACascadeRCNN.md) One of the best single models in Objects365 Full Track of which MAP reaches 31.7%. -- [Open Images Dataset V5 and Objects365 Dataset models](docs/featured_model/OIDV5_BASELINE_MODEL.md) - [Mobile models](configs/mobile/README.md) +- [Anchor free models](configs/anchor_free/README.md) +- [Face detection models](docs/featured_model/FACE_DETECTION_en.md) +- [Pretrained models for pedestrian detection](docs/featured_model/CONTRIB.md) +- [Pretrained models for vehicle detection](docs/featured_model/CONTRIB.md) +- [YOLOv3 enhanced model](docs/featured_model/YOLOv3_ENHANCEMENT.md): Compared to MAP of 33.0% in paper, enhanced YOLOv3 reaches the MAP of 43.6%, and inference speed is improved as well +- [Objects365 2019 Challenge champion model](docs/featured_model/CACascadeRCNN.md) +- [Best single model of Open Images 2019-Object Detction](docs/featured_model/OIDV5_BASELINE_MODEL.md) ## License diff --git a/docs/advanced_tutorials/TRANSFER_LEARNING_cn.md b/docs/advanced_tutorials/TRANSFER_LEARNING_cn.md index 7db411ac4..dd5e525f1 100644 --- a/docs/advanced_tutorials/TRANSFER_LEARNING_cn.md +++ b/docs/advanced_tutorials/TRANSFER_LEARNING_cn.md @@ -2,11 +2,10 @@ 迁移学习为利用已有知识,对新知识进行学习。例如利用ImageNet分类预训练模型做初始化来训练检测模型,利用在COCO数据集上的检测模型做初始化来训练基于PascalVOC数据集的检测模型。 -在进行迁移学习时,由于会使用不同的数据集,数据类别数与COCO/VOC数据类别不同,导致在加载PaddlePaddle开源模型时,与类别数相关的权重(例如分类模块的fc层)会出现维度不匹配的问题;另外,如果需要结构更加复杂的模型,需要对已有开源模型结构进行调整,对应权重也需要选择性加载。因此,需要检测库能够指定参数字段,在加载模型时不加载匹配的权重。 +在进行迁移学习时,由于会使用不同的数据集,数据类别数与COCO/VOC数据类别不同,导致在加载开源模型(如COCO预训练模型)时,与类别数相关的权重(例如分类模块的fc层)会出现维度不匹配的问题;另外,如果需要结构更加复杂的模型,需要对已有开源模型结构进行调整,对应权重也需要选择性加载。因此,需要检测库能够指定参数字段,在加载模型时不加载匹配的权重。 -## PaddleDetection进行迁移学习 -在迁移学习中,对预训练模型进行选择性加载,PaddleDetection支持如下两种迁移学习方式: +在迁移学习中,对预训练模型进行选择性加载,支持如下两种迁移学习方式: #### 直接加载预训练权重(**推荐方式**) @@ -38,7 +37,7 @@ python -u tools/train.py -c configs/faster_rcnn_r50_1x.yml \ 1. pretrain\_weights的路径为COCO数据集上开源的faster RCNN模型链接,完整模型链接可参考[MODEL_ZOO](../MODEL_ZOO_cn.md) 2. finetune\_exclude\_pretrained\_params中设置参数字段,如果参数名能够匹配以上参数字段(通配符匹配方式),则在模型加载时忽略该参数。 -如果用户需要利用自己的数据进行finetune,模型结构不变,只需要忽略与类别数相关的参数。PaddleDetection给出了不同模型类型所对应的忽略参数字段。如下表所示:
+如果用户需要利用自己的数据进行finetune,模型结构不变,只需要忽略与类别数相关的参数,不同模型类型所对应的忽略参数字段如下表所示:
| 模型类型 | 忽略参数字段 | | :----------------: | :---------------------------------------: | diff --git a/docs/tutorials/GETTING_STARTED.md b/docs/tutorials/GETTING_STARTED.md index fb3105079..405f1eb0e 100644 --- a/docs/tutorials/GETTING_STARTED.md +++ b/docs/tutorials/GETTING_STARTED.md @@ -11,6 +11,8 @@ instructions](INSTALL.md). PaddleDetection provides scripots for training, evalution and inference with various features according to different configure. ```bash +# set PYTHONPATH +export PYTHONPATH=$PYTHONPATH:. # training in single-GPU and multi-GPU. specify different GPU numbers by CUDA_VISIBLE_DEVICES export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python tools/train.py -c configs/faster_rcnn_r50_1x.yml diff --git a/docs/tutorials/GETTING_STARTED_cn.md b/docs/tutorials/GETTING_STARTED_cn.md index 6b44b0fcd..47751bb49 100644 --- a/docs/tutorials/GETTING_STARTED_cn.md +++ b/docs/tutorials/GETTING_STARTED_cn.md @@ -8,6 +8,8 @@ PaddleDetection提供了训练/评估/推断三个功能的使用脚本,支持通过不同可选参数实现特定功能 ```bash +# 设置PYTHONPATH路径 +export PYTHONPATH=$PYTHONPATH:. # GPU训练 支持单卡,多卡训练,通过CUDA_VISIBLE_DEVICES指定卡号 export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python tools/train.py -c configs/faster_rcnn_r50_1x.yml diff --git a/slim/distillation/distill.py b/slim/distillation/distill.py index 68003757d..59e5593ec 100644 --- a/slim/distillation/distill.py +++ b/slim/distillation/distill.py @@ -16,11 +16,16 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os +import os, sys +# add python path of PadleDetection to sys.path +parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) +if parent_path not in sys.path: + sys.path.append(parent_path) + import numpy as np from collections import OrderedDict -from paddleslim.dist.single_distiller import merge, l2_loss +from paddleslim.dist.single_distiller import merge, l2_loss from paddle import fluid from ppdet.core.workspace import load_config, merge_config, create from ppdet.data.reader import create_reader diff --git a/slim/extensions/distill_pruned_model/distill_pruned_model.py b/slim/extensions/distill_pruned_model/distill_pruned_model.py index c154bafb4..3302f278c 100644 --- a/slim/extensions/distill_pruned_model/distill_pruned_model.py +++ b/slim/extensions/distill_pruned_model/distill_pruned_model.py @@ -16,7 +16,13 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os +import os, sys + +# add python path of PadleDetection to sys.path +parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 4))) +if parent_path not in sys.path: + sys.path.append(parent_path) + import numpy as np from collections import OrderedDict from paddleslim.dist.single_distiller import merge, l2_loss diff --git a/slim/nas/train_nas.py b/slim/nas/train_nas.py index d025cd950..f4eca0e31 100644 --- a/slim/nas/train_nas.py +++ b/slim/nas/train_nas.py @@ -16,29 +16,19 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os +import os, sys +# add python path of PadleDetection to sys.path +parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) +if parent_path not in sys.path: + sys.path.append(parent_path) + import time import numpy as np import datetime from collections import deque - -def set_paddle_flags(**kwargs): - for key, value in kwargs.items(): - if os.environ.get(key, None) is None: - os.environ[key] = str(value) - - -# NOTE(paddle-dev): All of these flags should be set before -# `import paddle`. Otherwise, it would not take any effect. -set_paddle_flags( - FLAGS_eager_delete_tensor_gb=0, # enable GC to save memory -) - from paddle import fluid -import sys -sys.path.append("../../") from ppdet.experimental import mixed_precision_context from ppdet.core.workspace import load_config, merge_config, create, register from ppdet.data.reader import create_reader diff --git a/slim/prune/eval.py b/slim/prune/eval.py index b5d685c1d..4607f208d 100644 --- a/slim/prune/eval.py +++ b/slim/prune/eval.py @@ -16,20 +16,12 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os +import os, sys - -def set_paddle_flags(**kwargs): - for key, value in kwargs.items(): - if os.environ.get(key, None) is None: - os.environ[key] = str(value) - - -# NOTE(paddle-dev): All of these flags should be set before -# `import paddle`. Otherwise, it would not take any effect. -set_paddle_flags( - FLAGS_eager_delete_tensor_gb=0, # enable GC to save memory -) +# add python path of PadleDetection to sys.path +parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) +if parent_path not in sys.path: + sys.path.append(parent_path) import paddle.fluid as fluid from paddleslim.prune import Pruner diff --git a/slim/prune/export_model.py b/slim/prune/export_model.py index 1d986b48d..808af9f3b 100644 --- a/slim/prune/export_model.py +++ b/slim/prune/export_model.py @@ -16,7 +16,11 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os +import os, sys +# add python path of PadleDetection to sys.path +parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) +if parent_path not in sys.path: + sys.path.append(parent_path) from paddle import fluid diff --git a/slim/prune/prune.py b/slim/prune/prune.py index cdfa255ee..c907df9cd 100644 --- a/slim/prune/prune.py +++ b/slim/prune/prune.py @@ -16,7 +16,13 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os +import os, sys + +# add python path of PadleDetection to sys.path +parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) +if parent_path not in sys.path: + sys.path.append(parent_path) + import time import numpy as np import datetime @@ -24,6 +30,7 @@ from collections import deque from paddleslim.prune import Pruner from paddleslim.analysis import flops from paddle import fluid + from ppdet.experimental import mixed_precision_context from ppdet.core.workspace import load_config, merge_config, create from ppdet.data.reader import create_reader diff --git a/slim/quantization/eval.py b/slim/quantization/eval.py index d95c17f9d..037bbcfd3 100644 --- a/slim/quantization/eval.py +++ b/slim/quantization/eval.py @@ -16,8 +16,12 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os -import sys +import os, sys + +# add python path of PadleDetection to sys.path +parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) +if parent_path not in sys.path: + sys.path.append(parent_path) import paddle.fluid as fluid diff --git a/slim/quantization/export_model.py b/slim/quantization/export_model.py index 07f618ba3..ab219fa3c 100644 --- a/slim/quantization/export_model.py +++ b/slim/quantization/export_model.py @@ -16,8 +16,12 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os -import sys +import os, sys +# add python path of PadleDetection to sys.path +parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) +if parent_path not in sys.path: + sys.path.append(parent_path) + from paddle import fluid from ppdet.core.workspace import load_config, merge_config, create diff --git a/slim/quantization/infer.py b/slim/quantization/infer.py index e126029e8..cb16d3b95 100644 --- a/slim/quantization/infer.py +++ b/slim/quantization/infer.py @@ -16,17 +16,19 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os -import glob -import sys +import os, sys +# add python path of PadleDetection to sys.path +parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) +if parent_path not in sys.path: + sys.path.append(parent_path) +import glob import numpy as np from PIL import Image from paddle import fluid from ppdet.core.workspace import load_config, merge_config, create - from ppdet.utils.eval_utils import parse_fetches from ppdet.utils.cli import ArgsParser from ppdet.utils.check import check_gpu, check_version, check_config diff --git a/slim/quantization/train.py b/slim/quantization/train.py index f0a84e7c2..2e89dc09a 100644 --- a/slim/quantization/train.py +++ b/slim/quantization/train.py @@ -16,8 +16,12 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os -import sys +import os, sys +# add python path of PadleDetection to sys.path +parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) +if parent_path not in sys.path: + sys.path.append(parent_path) + import time import numpy as np import datetime @@ -28,7 +32,6 @@ from paddle import fluid from ppdet.core.workspace import load_config, merge_config, create from ppdet.data.reader import create_reader - from ppdet.utils import dist_utils from ppdet.utils.eval_utils import parse_fetches, eval_run, eval_results from ppdet.utils.stats import TrainingStats diff --git a/slim/sensitive/sensitive.py b/slim/sensitive/sensitive.py index c04c38e1c..d57699ad3 100644 --- a/slim/sensitive/sensitive.py +++ b/slim/sensitive/sensitive.py @@ -16,25 +16,17 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os +import os, sys +# add python path of PadleDetection to sys.path +parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3))) +if parent_path not in sys.path: + sys.path.append(parent_path) + import time import numpy as np import datetime from collections import deque - -def set_paddle_flags(**kwargs): - for key, value in kwargs.items(): - if os.environ.get(key, None) is None: - os.environ[key] = str(value) - - -# NOTE(paddle-dev): All of these flags should be set before -# `import paddle`. Otherwise, it would not take any effect. -set_paddle_flags( - FLAGS_eager_delete_tensor_gb=0, # enable GC to save memory -) - from paddle import fluid from ppdet.experimental import mixed_precision_context from ppdet.core.workspace import load_config, merge_config, create diff --git a/tools/eval.py b/tools/eval.py index bdf93180e..40840503f 100644 --- a/tools/eval.py +++ b/tools/eval.py @@ -16,26 +16,12 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os -import sys +import os, sys # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: sys.path.append(parent_path) - -def set_paddle_flags(**kwargs): - for key, value in kwargs.items(): - if os.environ.get(key, None) is None: - os.environ[key] = str(value) - - -# NOTE(paddle-dev): All of these flags should be set before -# `import paddle`. Otherwise, it would not take any effect. -set_paddle_flags( - FLAGS_eager_delete_tensor_gb=0, # enable GC to save memory -) - import paddle.fluid as fluid from ppdet.utils.eval_utils import parse_fetches, eval_run, eval_results, json_eval_results diff --git a/tools/infer.py b/tools/infer.py index 699c48bcd..f889eff81 100644 --- a/tools/infer.py +++ b/tools/infer.py @@ -16,30 +16,16 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os -import glob -import sys +import os, sys # add python path of PadleDetection to sys.path parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) if parent_path not in sys.path: sys.path.append(parent_path) +import glob import numpy as np from PIL import Image - -def set_paddle_flags(**kwargs): - for key, value in kwargs.items(): - if os.environ.get(key, None) is None: - os.environ[key] = str(value) - - -# NOTE(paddle-dev): All of these flags should be set before -# `import paddle`. Otherwise, it would not take any effect. -set_paddle_flags( - FLAGS_eager_delete_tensor_gb=0, # enable GC to save memory -) - from paddle import fluid from ppdet.core.workspace import load_config, merge_config, create diff --git a/tools/train.py b/tools/train.py index 7fc8b4b87..c6464abb9 100644 --- a/tools/train.py +++ b/tools/train.py @@ -16,31 +16,18 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os +import os, sys +# add python path of PadleDetection to sys.path +parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) +if parent_path not in sys.path: + sys.path.append(parent_path) + import time import numpy as np import random import datetime from collections import deque from paddle.fluid import profiler -import sys -# add python path of PadleDetection to sys.path -parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2))) -if parent_path not in sys.path: - sys.path.append(parent_path) - - -def set_paddle_flags(**kwargs): - for key, value in kwargs.items(): - if os.environ.get(key, None) is None: - os.environ[key] = str(value) - - -# NOTE(paddle-dev): All of these flags should be set before -# `import paddle`. Otherwise, it would not take any effect. -set_paddle_flags( - FLAGS_eager_delete_tensor_gb=0, # enable GC to save memory -) from paddle import fluid from paddle.fluid.layers.learning_rate_scheduler import _decay_step_counter -- GitLab