提交 e74303b6 编写于 作者: W wangguanzhong 提交者: GitHub

Update doc in PaddleDetection (#3074)

* update doc in PaddleDetection
上级 77001119
# Introduction
# Config Pipline
## Introduction
PaddleDetection takes a rather principled approach to configuration management. We aim to automate the configuration workflow and to reduce configuration errors.
# Rationale
## Rationale
Presently, configuration in mainstream frameworks are usually dictionary based: the global config is simply a giant, loosely defined Python dictionary.
......@@ -12,7 +14,7 @@ This approach is error prone, e.g., misspelled or displaced keys may lead to ser
To avoid the common pitfalls, with automation and static analysis in mind, we propose a configuration design that is user friendly, easy to maintain and extensible.
# Design
## Design
The design utilizes some of Python's reflection mechanism to extract configuration schematics from Python class definitions.
......@@ -21,7 +23,7 @@ To be specific, it extracts information from class constructor arguments, includ
This approach advocates modular and testable design, leading to a unified and extensible code base.
## API
### API
Most of the functionality is exposed in `ppdet.core.workspace` module.
......@@ -34,7 +36,7 @@ Most of the functionality is exposed in `ppdet.core.workspace` module.
- `load_config` and `merge_config`: Loading yaml file and merge config settings from command line.
## Example
### Example
Take the `RPNHead` module for example, it is composed of several PaddlePaddle operators. We first wrap those operators into classes, then pass in instances of these classes when instantiating the `RPNHead` module.
......@@ -156,7 +158,7 @@ LearningRate:
```
# Requirements
## Requirements
Two Python packages are used, both are optional.
......@@ -170,7 +172,7 @@ pip install typeguard http://github.com/willthefrog/docstring_parser/tarball/mas
```
# Tooling
## Tooling
A small utility (`tools/configure.py`) is included to simplify the configuration process, it provides 4 commands to walk users through the configuration process:
......@@ -190,7 +192,7 @@ A small utility (`tools/configure.py`) is included to simplify the configuration
```
# FAQ
## FAQ
**Q:** There are some configuration options that are used by multiple modules (e.g., `num_classes`), how do I avoid duplication in config files?
......
# 简介
# 配置模块
## 简介
为了使配置过程更加自动化并减少配置错误,PaddleDetection的配置管理采取了较为严谨的设计。
# 设计思想
## 设计思想
目前主流框架全局配置基本是一个Python dict,这种设计对配置的检查并不严格,拼写错误或者遗漏的配置项往往会造成训练过程中的严重错误,进而造成时间及资源的浪费。为了避免这些陷阱,从自动化和静态分析的原则出发,PaddleDetection采用了一种用户友好、 易于维护和扩展的配置设计。
# 基本设计
## 基本设计
利用Python的反射机制,PaddleDection的配置系统从Python类的构造函数抽取多种信息 - 如参数名、初始值、参数注释、数据类型(如果给出type hint)- 来作为配置规则。 这种设计便于设计的模块化,提升可测试性及扩展性。
## API
### API
配置系统的大多数功能由 `ppdet.core.workspace` 模块提供
......@@ -26,7 +28,7 @@
- `load_config` and `merge_config`: 加载yaml文件,合并命令行提供的配置项。
## 示例
### 示例
`RPNHead` 模块为例,该模块包含多个PaddlePaddle OP,先将这些OP封装成类,并将其实例在构造 `RPNHead` 时注入。
......@@ -148,7 +150,7 @@ LearningRate:
```
# 安装依赖
## 安装依赖
配置系统用到两个Python包,均为可选安装。
......@@ -162,7 +164,7 @@ pip install typeguard http://github.com/willthefrog/docstring_parser/tarball/mas
```
# 相关工具
## 相关工具
为了方便用户配置,PaddleDection提供了一个工具 (`tools/configure.py`), 共支持四个子命令:
......@@ -182,7 +184,7 @@ pip install typeguard http://github.com/willthefrog/docstring_parser/tarball/mas
```
# FAQ
## FAQ
**Q:** 某些配置项会在多个模块中用到(如 `num_classes`),如何避免在配置文件中多次重复设置?
......
# Data Pipline
## Introduction
The data pipeline is responsible for loading and converting data. Each
......
# 数据模块
## 介绍
本模块是一个Python模块,用于加载数据并将其转换成适用于检测模型的训练、验证、测试所需要的格式——由多个np.ndarray组成的tuple数组,例如用于Faster R-CNN模型的训练数据格式为:`[(im, im_info, im_id, gt_bbox, gt_class, is_crowd), (...)]`
......
......@@ -51,7 +51,7 @@ python -u tools/train.py -c configs/faster_rcnn_r50_1x.yml --eval
Alternating between training epoch and evaluation run is possible, simply pass
in `--eval` to do so and evaluate at each snapshot_iter. It can be modified at `snapshot_iter` of the configuration file. If evaluation dataset is large and
causes time-consuming in training, we suggest decreasing evaluation times or evaluating after training. When perform evaluation in training,
causes time-consuming in training, we suggest decreasing evaluation times or evaluating after training. When perform evaluation in training,
the best model with highest MAP is saved at each `snapshot_iter`. `best_model` has the same path as `model_final`.
......@@ -162,11 +162,12 @@ export CUDA_VISIBLE_DEVICES=0
python tools/infer.py -c configs/faster_rcnn_r50_1x.yml \
--infer_img=demo/000000570688.jpg \
--output_dir=infer_output/ \
--draw_threshold=0.5
--draw_threshold=0.5 \
-o weights=output/faster_rcnn_r50_1x/model_final
```
The visualization files are saved in `output` by default, to specify a different
path, simply add a `--output_dir=` flag.
`--draw_threshold` is an optional argument. Default is 0.5. Different thresholds will produce different results depending on the calculation of [NMS](https://ieeexplore.ieee.org/document/1699659)
`--draw_threshold` is an optional argument. Default is 0.5. Different thresholds will produce different results depending on the calculation of [NMS](https://ieeexplore.ieee.org/document/1699659). If users want to infer according to customized model path, `-o weights` can be set for specified path.
- Save inference model
......
......@@ -156,12 +156,13 @@ export PYTHONPATH=$PYTHONPATH:.
python tools/infer.py -c configs/faster_rcnn_r50_1x.yml \
--infer_img=demo/000000570688.jpg \
--output_dir=infer_output/ \
--draw_threshold=0.5
--draw_threshold=0.5 \
-o weights=output/faster_rcnn_r50_1x/model_final
```
可视化文件默认保存在`output`中,可通过`--output_dir=`指定不同的输出路径。
`--draw_threshold` 是个可选参数. 根据 [NMS](https://ieeexplore.ieee.org/document/1699659) 的计算,不同阈值会产生不同的结果。
`--draw_threshold` 是个可选参数. 根据 [NMS](https://ieeexplore.ieee.org/document/1699659) 的计算,不同阈值会产生不同的结果。如果用户需要对自定义路径的模型进行推断,可以设置`-o weights`指定模型路径。
- 保存推断模型
......
# 模型库和基线
## 测试环境
- Python 2.7.1
- PaddlePaddle 1.5
- CUDA 9.0
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册