From 447549a58f76d1f351079507a43399f0afd12802 Mon Sep 17 00:00:00 2001
From: juncaipeng <13006307475@163.com>
Date: Mon, 28 Nov 2022 20:56:50 +0800
Subject: [PATCH 01/10] [Doc][Fix]Refine train, predict, evaluate docs for
release 2.7
---
docs/evaluation/evaluate_cn.md | 38 ++++++++++-----
docs/predict/predict_cn.md | 77 ++++++++++++++++--------------
docs/train/train_cn.md | 86 +++++++++++++++++++++++++---------
docs/whole_process_cn.md | 41 +++++++++++-----
4 files changed, 159 insertions(+), 83 deletions(-)
diff --git a/docs/evaluation/evaluate_cn.md b/docs/evaluation/evaluate_cn.md
index e6e7e5afd2..a2bdbfae4a 100644
--- a/docs/evaluation/evaluate_cn.md
+++ b/docs/evaluation/evaluate_cn.md
@@ -1,11 +1,25 @@
简体中文|[English](evaluate.md)
## 模型评估
-### 1.**配置化驱动**方式下评估和预测
+### 1.**配置化驱动**方式下评估
-#### 评估
+训练完成后,大家可以使用评估脚本`tools/val.py`来评估模型的精度,即对配置文件中的验证数据集进行测试。
-训练完成后,用户可以使用评估脚本val.py来评估模型效果。假设训练过程中迭代次数(iters)为1000,保存模型的间隔为500,即每迭代1000次数据集保存2次训练模型。因此一共会产生2个定期保存的模型,加上保存的最佳模型`best_model`,一共有3个模型,可以通过`model_path`指定期望评估的模型文件。
+假设训练过程中迭代次数(iters)为1000,保存模型的间隔为500,即每迭代1000次数据集保存2次训练模型。因此一共会产生2个定期保存的模型,加上保存的最佳模型`best_model`,一共有3个模型。
+
+```
+output
+ ├── iter_500 #表示在500步保存一次模型
+ ├── model.pdparams #模型参数
+ └── model.pdopt #训练阶段的优化器参数
+ ├── iter_1000 #表示在1000步保存一次模型
+ ├── model.pdparams #模型参数
+ └── model.pdopt #训练阶段的优化器参数
+ └── best_model #精度最高的模型权重
+ └── model.pdparams
+```
+
+在PP-LiteSeg示例中,执行如下命令进行模型评估。其中,通过`--model_path`输入参数来指定评估的模型权重。
```
!python tools/val.py \
@@ -47,18 +61,16 @@ python tools/val.py \
```
...
-2021-01-13 16:41:29 [INFO] Start evaluating (total_samples=76, total_iters=76)...
-76/76 [==============================] - 2s 30ms/step - batch_cost: 0.0268 - reader cost: 1.7656e-
-2021-01-13 16:41:31 [INFO] [EVAL] #Images=76 mIoU=0.8526 Acc=0.9942 Kappa=0.8283
-2021-01-13 16:41:31 [INFO] [EVAL] Class IoU:
-[0.9941 0.7112]
-2021-01-13 16:41:31 [INFO] [EVAL] Class Acc:
-[0.9959 0.8886]
+2022-06-22 11:05:55 [INFO] [EVAL] #Images: 76 mIoU: 0.9232 Acc: 0.9970 Kappa: 0.9171 Dice: 0.9585
+2022-06-22 11:05:55 [INFO] [EVAL] Class IoU:
+[0.997 0.8494]
+2022-06-22 11:05:55 [INFO] [EVAL] Class Precision:
+[0.9984 0.9237]
+2022-06-22 11:05:55 [INFO] [EVAL] Class Recall:
+[0.9986 0.9135]
```
-### 2.**API**方式下评估和预测
-
-#### 评估
+### 2.**API**方式下评估
构建模型
```
diff --git a/docs/predict/predict_cn.md b/docs/predict/predict_cn.md
index d99dca513e..f5b855070c 100644
--- a/docs/predict/predict_cn.md
+++ b/docs/predict/predict_cn.md
@@ -3,7 +3,9 @@
除了分析模型的IOU、ACC和Kappa指标之外,我们还可以查阅一些具体样本的切割样本效果,从Bad Case启发进一步优化的思路。
-predict.py脚本是专门用来可视化预测案例的,命令格式如下所示:
+## 预测用法
+
+`tools/predict.py`脚本是专门用来可视化预测的,命令格式如下所示。
```
python tools/predict.py \
@@ -18,24 +20,23 @@ python tools/predict.py \
同样的,可以通过`--aug_pred`开启多尺度翻转预测, `--is_slide`开启滑窗预测。
-## 1.准备预测数据
+在执行预测时,如果只有原始图像,`tools/predict.py`脚本的输入参数`--image_path`可以设置为保存所有原始图像的目录,也可以设置为txt文件的路径(符合如下格式,只有原始图像)。
+```
+images/image1.jpg
+images/image2.jpg
+...
+```
-- 在执行预测时,仅需要原始图像。你应该准备好 `test.txt` 的内容,如下所示:
- ```
- images/image1.jpg
- images/image2.jpg
- ...
- ```
+如果`tools/predict.py`脚本的输入参数`--image_path`设置为txt文件的路径(如下格式,包含原始图像和标注图像),测试脚本将自动忽略文件列表中给出的标注图像。
+```
+images/image1.jpg labels/label1.png
+images/image2.jpg labels/label2.png
+...
+```
-- 在调用`predict.py`进行可视化展示时,文件列表中可以包含标注图像。在预测时,模型将自动忽略文件列表中给出的标注图像。因此,你也可以直接使用训练、验证数据集进行预测。也就是说,如果你的`train.txt`的内容如下:
- ```
- images/image1.jpg labels/label1.png
- images/image2.jpg labels/label2.png
- ...
- ```
+## 预测函数解析
-## 2.预测函数API
预测API的参数解析
```
@@ -57,7 +58,7 @@ paddleseg.core.predict(
)
```
-- 参数说明如下
+**参数说明如下**
| 参数名 | 数据类型 | 用途 | 是否必选项 | 默认值 |
| --------------- | ----------------- | ---------------------------------------------------- | ---------- | -------- |
@@ -76,7 +77,7 @@ paddleseg.core.predict(
| crop_size | tuple/list | 设置滑动窗口的裁剪的宽度和高度,`is_slide`为True时生效 | 否 | None |
| custom_color | list | 设置自定义分割预测颜色,len(custom_color) = 3 * 像素种类 | 否 | 预设color map |
-导入API接口,开始预测
+导入API接口,开始预测。
```
from paddleseg.core import predict
@@ -90,27 +91,32 @@ predict(
)
```
-## 3.输出文件说明
+## 输出文件说明
+
如果你不指定输出位置,在默认文件夹`output/results`下将生成两个文件夹`added_prediction`与`pseudo_color_prediction`, 分别存放叠加效果图与预测mask的结果。
- output/result
- |
- |--added_prediction
- | |--image1.jpg
- | |--image2.jpg
- | |--...
- |
- |--pseudo_color_prediction
- | |--image1.jpg
- | |--image2.jpg
- | |--...
-
-
-## 4.自定义color map
-经过预测后,我们得到的是默认color map配色的预测分割结果。以视盘分割为例:
+```
+output/result
+|
+|--added_prediction
+| |--image1.jpg
+| |--image2.jpg
+| |--...
+|
+|--pseudo_color_prediction
+| |--image1.jpg
+| |--image2.jpg
+| |--...
+```
+
+
+## 自定义color map
+
+经过预测后,我们得到的是默认color map配色的预测分割结果。
+
+以视盘分割为例,伪彩色标注图/叠加图如下:

- 伪彩色标注图/叠加图
在该分割结果中,前景以红色标明,背景以黑色标明。如果你想要使用其他颜色,可以参考如下命令:
```python
@@ -124,9 +130,8 @@ python tools/predict.py \
分割预测结果如下:

- 伪彩色标注图/叠加图
-- 参数解析
+参数解析:
- 可以看到我们在最后添加了 `--custom_color 0 0 0 255 255 255`,这是什么意思呢?在RGB图像中,每个像素最终呈现出来的颜色是由RGB三个通道的分量共同决定的,因此该命令行参数后每三位代表一种像素的颜色,位置与`label.txt`中各类像素点一一对应。
- 如果使用自定义color map,输入的`color值`的个数应该等于`3 * 像素种类`(取决于你所使用的数据集)。比如,你的数据集有 3 种像素,则可考虑执行:
```python
diff --git a/docs/train/train_cn.md b/docs/train/train_cn.md
index fb0769fa7b..3428a9bb86 100644
--- a/docs/train/train_cn.md
+++ b/docs/train/train_cn.md
@@ -1,13 +1,16 @@
简体中文|[English](train.md)
# 模型训练
-## 1、开启训练
-我们可以通过PaddleSeg提供的脚本对模型进行训练,在本文档中我们使用`PP-LiteSeg`模型与`optic_disc`数据集展示训练过程。 请确保已经完成了PaddleSeg的安装工作,并且位于PaddleSeg目录下,执行以下脚本:
+## 1、单卡训练
+
+准备好配置文件后,我们使用`tools/train.py`脚本进行模型训练。
+
+在本文档中我们使用`PP-LiteSeg`模型与`optic_disc`数据集展示训练过程。请确保已经完成了PaddleSeg的安装工作,并且位于PaddleSeg目录下,执行以下脚本:
```shell
-export CUDA_VISIBLE_DEVICES=0 # 设置1张可用的卡
-# windows下请执行以下命令
-# set CUDA_VISIBLE_DEVICES=0
+export CUDA_VISIBLE_DEVICES=0 # Linux上设置1张可用的卡
+# set CUDA_VISIBLE_DEVICES=0 # Windows上设置1张可用的卡
+
python tools/train.py \
--config configs/quick_start/pp_liteseg_optic_disc_512x512_1k.yml \
--do_eval \
@@ -16,7 +19,28 @@ python tools/train.py \
--save_dir output
```
-### 训练参数解释
+上述训练命令解释:
+* `--config`指定配置文件。
+* `--save_interval`指定每训练特定轮数后,就进行一次模型保存或者评估(如果开启模型评估)。
+* `--do_eval`开启模型评估。具体而言,在训练save_interval指定的轮数后,会进行模型评估。
+* `--use_vdl`开启写入VisualDL日志信息,用于VisualDL可视化训练过程。
+* `--save_dir`指定模型和visualdl日志文件的保存根路径。
+
+在PP-LiteSeg示例中,训练的模型权重保存在output目录下,如下所示。总共训练1000轮,每500轮评估一次并保存模型信息,所以有`iter_500`和`iter_1000`文件夹。评估精度最高的模型权重,保存在`best_model`文件夹。后续模型的评估、测试和导出,都是使用保存在`best_model`文件夹下精度最高的模型权重。
+
+```
+output
+ ├── iter_500 #表示在500步保存一次模型
+ ├── model.pdparams #模型参数
+ └── model.pdopt #训练阶段的优化器参数
+ ├── iter_1000 #表示在1000步保存一次模型
+ ├── model.pdparams #模型参数
+ └── model.pdopt #训练阶段的优化器参数
+ └── best_model #精度最高的模型权重
+ └── model.pdparams
+```
+
+`train.py`脚本输入参数的详细说明如下。
| 参数名 | 用途 | 是否必选项 | 默认值 |
| :------------------ | :----------------------------------------------------------- | :--------- | :--------------- |
@@ -33,10 +57,18 @@ python tools/train.py \
| resume_model | 恢复训练模型路径,如:`output/iter_1000` | 否 | None |
| keep_checkpoint_max | 最新模型保存个数 | 否 | 5 |
+
## 2、多卡训练
-如果想要使用多卡训练的话,需要将环境变量CUDA_VISIBLE_DEVICES指定为多卡(不指定时默认使用所有的gpu),并使用paddle.distributed.launch启动训练脚本(windows下由于不支持nccl,无法使用多卡训练):
-```shell
+使用多卡训练:首先通过环境变量`CUDA_VISIBLE_DEVICES`指定使用的多张显卡,如果不设置`CUDA_VISIBLE_DEVICES`,默认使用所有显卡进行训练;然后使用`paddle.distributed.launch`启动`train.py`脚本进行训练。
+
+多卡训练的`train.py`支持的输入参数和单卡训练相同。
+
+由于Windows环境下不支持nccl,所以无法使用多卡训练。
+
+举例如下,在PaddleSeg根目录下执行如下命令,进行多卡训练。
+
+```
export CUDA_VISIBLE_DEVICES=0,1,2,3 # 设置4张可用的卡
python -m paddle.distributed.launch tools/train.py \
--config configs/quick_start/pp_liteseg_optic_disc_512x512_1k.yml \
@@ -47,7 +79,14 @@ python -m paddle.distributed.launch tools/train.py \
```
## 3、恢复训练:
-```shell
+
+如果训练中断,我们可以恢复训练,避免从头开始训练。
+
+具体而言,通过给`train.py`脚本设置`resume_model`输入参数,加载中断前最近一次保存的模型信息,恢复训练。
+
+在PP-LiteSeg示例中,总共需要训练1000轮。假如训练到750轮中断了,我们在`output`目录下,可以看到在`iter_500`文件夹中保存了第500轮的训练信息。执行如下命令,加载第500轮的训练信息恢复训练。
+
+```
python tools/train.py \
--config configs/quick_start/pp_liteseg_optic_disc_512x512_1k.yml \
--resume_model output/iter_500 \
@@ -57,21 +96,26 @@ python tools/train.py \
--save_dir output
```
+单卡和多卡训练都采用相同的方法设置`resume_model`输入参数,即可恢复训练。
+
## 4、训练可视化
-PaddleSeg会将训练过程中的数据写入VisualDL文件,并实时的查看训练过程中的日志,记录的数据包括:
-1. loss变化趋势
-2. 学习率变化趋势
-3. 训练时间
-4. 数据读取时间
-5. mean IoU变化趋势(当打开了`do_eval`开关后生效)
-6. mean pixel Accuracy变化趋势(当打开了`do_eval`开关后生效)
+为了直观显示模型的训练过程,对训练过程进行分析从而快速的得到更好的模型,飞桨提供了可视化分析工具:VisualDL。
-使用如下命令启动VisualDL查看日志
-```shell
-# 下述命令会在127.0.0.1上启动一个服务,支持通过前端web页面查看,可以通过--host这个参数指定实际ip地址
+当`train.py`脚本设置`use_vdl`输入参数后,PaddleSeg会将训练过程中的日志信息写入VisualDL文件,写入的日志信息包括:
+* loss
+* 学习率lr
+* 训练时间
+* 数据读取时间
+* 验证集上mIoU(当打开了`do_eval`开关后生效)
+* 验证集上mean Accuracy(当打开了`do_eval`开关后生效)
+
+在PP-LiteSeg示例中,在训练过程中或者训练结束后,我们都可以通过VisualDL来查看日志信息。
+
+首先执行如下命令,启动VisualDL;然后在浏览器输入提示的网址,效果如下图。
+
+```
visualdl --logdir output/
```
-在浏览器输入提示的网址,效果如下:
-
+
diff --git a/docs/whole_process_cn.md b/docs/whole_process_cn.md
index ca01a0d590..2db36f9f34 100644
--- a/docs/whole_process_cn.md
+++ b/docs/whole_process_cn.md
@@ -63,14 +63,23 @@ PaddleSeg中,配置文件包括超参、训练数据集、验证数据集、
大家可以灵活修改配置文件的内容,如自定义模型使用的骨干网络、模型使用的损失函数以及关于网络结构等配置,自定义配置数据处理的策略,如改变尺寸、归一化和翻转等数据增强的策略,这些修改可以参考对应模块的代码,传入相应参数即可。
-以`PaddleSeg/configs/quick_start/pp_liteseg_optic_disc_512x512_1k.yml`为例,详细解读配置文件如下。
+以`PaddleSeg/configs/quick_start/pp_liteseg_optic_disc_512x512_1k.yml`为例,详细解读配置文件如下:
+* yml文件定义了超参、训练数据集、测试数据集、优化器、学习率、损失函数、模型的配置信息,PaddleSeg基于配置信息构建对应的模块,进行模型训练、评估和导出。
+* 超参主要包括batch_size和iters,前者是单卡的batch_size,后者表示训练迭代的轮数(单个batch进行一次前向和反向表示一轮)。
+* 配置信息模块中,`type`字段对应到PaddleSeg代码中的类名(Python Class Name),其他字段对应类(Python Class)中`__init__`函数的初始化参数。
+* 数据集dataset模块,支持的类在`PaddleSeg/paddleseg/datasets`目录下(使用@manager.DATASETS.add_component进行注册)。
+* 数据预处理方式transforms模块,支持的类在`PaddleSeg/paddleseg/transforms/transforms.py`文件中(使用@manager.TRANSFORMS.add_component进行注册)。
+* 优化器optimizer模块,支持Paddle提供的所有优化器类,具体参考:https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/Overview_cn.html#api
+* 学习率衰减lr_scheduler模块,支持Paddle提供的所有lr_scheduler类,具体参考:https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/Overview_cn.html#about-lr
+* 损失函数Loss模块,在`types`字段下分别定义使用的损失函数类,`coef`字段定义每个损失函数的权重。`types`字段下损失函数个数,应该等于`coef`字段数组的长度。如果所有损失函数相同,可以只定义一个损失函数。支持的损失函数类在`PaddleSeg/paddleseg/models/losses/`目录下(使用@manager.LOSSES.add_component注册)。
+* 模型Model模块,支持的model类在`PaddleSeg/paddleseg/models/`目录下(使用@manager.MODELS.add_component注册),支持的backbone类在`PaddleSeg/paddleseg/models/backbones`目录下(使用@manager.BACKBONES.add_component注册)。
```
batch_size: 4 #设定batch_size的值即为迭代一次送入网络的图片数量,一般显卡显存越大,batch_size的值可以越大。如果使用多卡训练,总得batch size等于该batch size乘以卡数。
iters: 1000 #模型训练迭代的轮数
train_dataset: #训练数据设置
- type: Dataset #指定加载数据集的类
+ type: Dataset #指定加载数据集的类。数据集类的代码在`PaddleSeg/paddleseg/datasets`目录下。
dataset_root: data/optic_disc_seg #数据集路径
train_path: data/optic_disc_seg/train_list.txt #数据集中用于训练的标识文件
num_classes: 2 #指定类别个数(背景也算为一类)
@@ -90,7 +99,7 @@ train_dataset: #训练数据设置
- type: Normalize #对原始图像进行归一化,标注图像保持不变
val_dataset: #验证数据设置
- type: Dataset #指定加载数据集的类
+ type: Dataset #指定加载数据集的类。数据集类的代码在`PaddleSeg/paddleseg/datasets`目录下。
dataset_root: data/optic_disc_seg #数据集路径
val_path: data/optic_disc_seg/val_list.txt #数据集中用于验证的标识文件
num_classes: 2 #指定类别个数(背景也算为一类)
@@ -140,15 +149,14 @@ model: #模型说明
### 4.1 单卡训练
-准备好配置文件后,在PaddleSeg根目录下执行如下命令,使用`train.py`脚本进行单卡模型训练。
+准备好配置文件后,在PaddleSeg根目录下执行如下命令,使用`tools/train.py`脚本进行单卡模型训练。
> 注意:PaddleSeg中模型训练、评估、预测、导出等命令,都要求在PaddleSeg根目录下执行。
```
-export CUDA_VISIBLE_DEVICES=0 # 设置1张可用的卡
+export CUDA_VISIBLE_DEVICES=0 # Linux上设置1张可用的卡
+# set CUDA_VISIBLE_DEVICES=0 # Windows上设置1张可用的卡
-**windows下请执行以下命令**
-**set CUDA_VISIBLE_DEVICES=0**
python tools/train.py \
--config configs/quick_start/pp_liteseg_optic_disc_512x512_1k.yml \
--save_interval 500 \
@@ -199,7 +207,7 @@ output
使用多卡训练:首先通过环境变量`CUDA_VISIBLE_DEVICES`指定使用的多张显卡,如果不设置`CUDA_VISIBLE_DEVICES`,默认使用所有显卡进行训练;然后使用`paddle.distributed.launch`启动`train.py`脚本进行训练。
-多卡训练的`train.py`支持的输入参数和单卡训练相同。
+多卡训练的`tools/train.py`支持的输入参数和单卡训练相同。
由于Windows环境下不支持nccl,所以无法使用多卡训练。
@@ -219,7 +227,7 @@ python -m paddle.distributed.launch tools/train.py \
如果训练中断,我们可以恢复训练,避免从头开始训练。
-具体而言,通过给`train.py`脚本设置`resume_model`输入参数,加载中断前最近一次保存的模型信息,恢复训练。
+具体而言,通过给`tools/train.py`脚本设置`resume_model`输入参数,加载中断前最近一次保存的模型信息,恢复训练。
在PP-LiteSeg示例中,总共需要训练1000轮。假如训练到750轮中断了,我们在`output`目录下,可以看到在`iter_500`文件夹中保存了第500轮的训练信息。执行如下命令,加载第500轮的训练信息恢复训练。
@@ -239,7 +247,7 @@ python tools/train.py \
为了直观显示模型的训练过程,对训练过程进行分析从而快速的得到更好的模型,飞桨提供了可视化分析工具:VisualDL。
-当`train.py`脚本设置`use_vdl`输入参数后,PaddleSeg会将训练过程中的日志信息写入VisualDL文件,写入的日志信息包括:
+当`tools/train.py`脚本设置`use_vdl`输入参数后,PaddleSeg会将训练过程中的日志信息写入VisualDL文件,写入的日志信息包括:
* loss
* 学习率lr
* 训练时间
@@ -259,7 +267,7 @@ visualdl --logdir output/
## 5. 模型评估
-训练完成后,大家可以使用评估脚本`val.py`来评估模型的精度,即对配置文件中的验证数据集进行测试。
+训练完成后,大家可以使用评估脚本`tools/val.py`来评估模型的精度,即对配置文件中的验证数据集进行测试。
在PP-LiteSeg示例中,执行如下命令进行模型评估。其中,通过`--model_path`输入参数来指定评估的模型权重。
@@ -269,6 +277,15 @@ python tools/val.py \
--model_path output/best_model/model.pdparams
```
+如果想使用多卡进行评估,可以使用`paddle.distributed.launch`启动`tools/val.py`脚本。
+
+```
+export CUDA_VISIBLE_DEVICES=0,1
+python -m paddle.distributed.launch tools/val.py \
+ --config configs/quick_start/pp_liteseg_optic_disc_512x512_1k.yml \
+ --model_path output/best_model/model.pdparams
+```
+
如果想进行多尺度翻转评估,可以通过传入`--aug_eval`进行开启,然后通过`--scales`传入尺度信息, `--flip_horizontal`开启水平翻转,`--flip_vertical`开启垂直翻转。使用示例如下:
```
@@ -303,8 +320,6 @@ python tools/val.py \
```
...
-2022-06-22 11:05:51 [INFO] Start evaluating (total_samples: 76, total_iters: 76)...
-76/76 [==============================] - 3s 45ms/step - batch_cost: 0.0444 - reader cost: 5.4260e-04
2022-06-22 11:05:55 [INFO] [EVAL] #Images: 76 mIoU: 0.9232 Acc: 0.9970 Kappa: 0.9171 Dice: 0.9585
2022-06-22 11:05:55 [INFO] [EVAL] Class IoU:
[0.997 0.8494]
From 737a86943b5268628638f20a614e2801d573c446 Mon Sep 17 00:00:00 2001
From: juncaipeng <13006307475@163.com>
Date: Tue, 29 Nov 2022 14:14:27 +0800
Subject: [PATCH 02/10] add config preparation doc
---
README_CN.md | 4 +-
README_EN.md | 4 +-
docs/config/pre_config.md | 83 ++++++++++++++++++++++++++++++++++
docs/config/pre_config_cn.md | 86 ++++++++++++++++++++++++++++++++++++
docs/whole_process_cn.md | 2 +-
5 files changed, 174 insertions(+), 5 deletions(-)
create mode 100644 docs/config/pre_config.md
create mode 100644 docs/config/pre_config_cn.md
diff --git a/README_CN.md b/README_CN.md
index a2a18bd1f2..7588bf7479 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -374,8 +374,8 @@
* [准备公开数据集](./docs/data/pre_data_cn.md)
* [准备自定义数据集](./docs/data/marker/marker_cn.md)
* [EISeg 数据标注](./EISeg)
-
-* [模型训练](/docs/train/train_cn.md)
+* [准备配置文件](./docs/config/pre_config_cn.md)
+* [模型训练](./docs/train/train_cn.md)
* [模型评估](./docs/evaluation/evaluate_cn.md)
* [模型预测](./docs/predict/predict_cn.md)
diff --git a/README_EN.md b/README_EN.md
index 58b908d8b1..1b615e88e6 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -377,10 +377,10 @@ Note that:
* [Prepare Public Dataset](./docs/data/pre_data.md)
* [Prepare Customized Dataset](./docs/data/marker/marker.md)
* [Label Data with EISeg](./EISeg)
-
+* [Config Preparation](./docs/config/pre_config.md)
* [Model Training](/docs/train/train.md)
* [Model Evaluation](./docs/evaluation/evaluate.md)
-* [Prediction](./docs/predict/predict.md)
+* [Model Prediction](./docs/predict/predict.md)
* Model Export
* [Export Inference Model](./docs/model_export.md)
diff --git a/docs/config/pre_config.md b/docs/config/pre_config.md
new file mode 100644
index 0000000000..71b9949a48
--- /dev/null
+++ b/docs/config/pre_config.md
@@ -0,0 +1,83 @@
+English | [简体中文 ](pre_config_cn.md)
+
+The config file contains the information of train dataset, val dataset, optimizer, loss and model in PaddleSeg.
+All config files of SOTA models are saved in `PaddleSeg/configs`.
+Based on these config files, we can modify the content at will and then conduct model training.
+
+The config file of `PaddleSeg/configs/quick_start/pp_liteseg_optic_disc_512x512_1k.yml` are as following. The details are explained:
+* PaddleSeg employes the config file to build dataset, optimizer, model, etc, and then it conducts model training, evaluation and exporting.
+* Hyperparameters have batch_size and iters.
+* In each config module, `type` is the class name of corresponding component, and other values are the input params of `__init__` function.
+* For dataset config module, the supported classes in `PaddleSeg/paddleseg/datasets` are registered by `@manager.DATASETS.add_component`.
+* For data transforms config module, the supported classes in `PaddleSeg/paddleseg/transforms/transforms.py` are registered by `@manager.TRANSFORMS.add_component`.
+* For optimizer config module, it supports all optimizer provided by PaddlePaddle. Please refer to the [document](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/Overview_cn.html#api).
+* For lr_scheduler config module, it supports all lr_scheduler provided by PaddlePaddle. Please refer to the [document](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/Overview_cn.html#about-lr).
+* For loss config module, `types` containes several loss name, `coef` defines the weights of each loss. The number of losses and weights must be equal. If all losses are the same, we can only add one loss name. All supported classes in `PaddleSeg/paddleseg/models/losses/` are registered by `@manager.LOSSES.add_component`.
+* For model config module, the supported classes in `PaddleSeg/paddleseg/models/` are registered by `@manager.MODELS.add_component`, and the supported backbone in `PaddleSeg/paddleseg/models/backbones` are registered by `@manager.BACKBONES.add_component`.
+
+```
+batch_size: 4 # batch size on single GPU
+iters: 1000
+
+train_dataset:
+ type: Dataset
+ dataset_root: data/optic_disc_seg
+ train_path: data/optic_disc_seg/train_list.txt
+ num_classes: 2 # background is also a class
+ mode: train
+ transforms:
+ - type: ResizeStepScaling
+ min_scale_factor: 0.5
+ max_scale_factor: 2.0
+ scale_step_size: 0.25
+ - type: RandomPaddingCrop
+ crop_size: [512, 512]
+ - type: RandomHorizontalFlip
+ - type: RandomDistort
+ brightness_range: 0.5
+ contrast_range: 0.5
+ saturation_range: 0.5
+ - type: Normalize
+
+val_dataset:
+ type: Dataset
+ dataset_root: data/optic_disc_seg
+ val_path: data/optic_disc_seg/val_list.txt
+ num_classes: 2
+ mode: val
+ transforms:
+ - type: Normalize
+
+optimizer:
+ type: sgd
+ momentum: 0.9
+ weight_decay: 4.0e-5
+
+lr_scheduler:
+ type: PolynomialDecay
+ learning_rate: 0.01
+ power: 0.9
+ end_lr: 0
+
+loss:
+ types:
+ - type: CrossEntropyLoss
+ coef: [1, 1, 1] # total_loss = coef_1 * loss_1 + .... + coef_n * loss_n
+
+model:
+ type: PPLiteSeg
+ backbone:
+ type: STDC2
+ pretrained: https://bj.bcebos.com/paddleseg/dygraph/PP_STDCNet2.tar.gz
+
+```
+
+
+Note that:
+* In the data transforms of train and val dataset, PaddleSeg will add read image operation in the beginning, add HWC->CHW transform operation in the end.
+* For the config files in `PaddleSeg/configs/quick_start`, the learning_rate is corresponding to single GPU training. For other config files, the learning_rate is corresponding to 4 GPU training.
+
+Besides, one config file can include another config file. For example, the right `deeplabv3p_resnet50_os8_cityscapes_1024x512_80k.yml` uses `_base_` to include the left `../_base_/cityscapes.yml`.
+If config value `X` in both config files (`A` includes `B`), the `X` value in `B` will be hidden.
+
+
diff --git a/docs/config/pre_config_cn.md b/docs/config/pre_config_cn.md
new file mode 100644
index 0000000000..0cf12f0b8b
--- /dev/null
+++ b/docs/config/pre_config_cn.md
@@ -0,0 +1,86 @@
+简体中文 | [English](pre_config.md)
+
+PaddleSeg中,配置文件包括超参、训练数据集、验证数据集、优化器、损失函数、模型等信息。**所有模型在公开数据集上训练的配置文件在PaddleSeg/configs文件夹下面**。
+
+大家可以灵活修改配置文件的内容,如自定义模型使用的骨干网络、模型使用的损失函数以及关于网络结构等配置,自定义配置数据处理的策略,如改变尺寸、归一化和翻转等数据增强的策略,这些修改可以参考对应模块的代码,传入相应参数即可。
+
+下面是`PaddleSeg/configs/quick_start/pp_liteseg_optic_disc_512x512_1k.yml`配置文件,我们进行详细解读:
+* yml文件定义了超参、训练数据集、测试数据集、优化器、学习率、损失函数、模型的配置信息,PaddleSeg基于配置信息构建对应的模块,进行模型训练、评估和导出。
+* 超参主要包括batch_size和iters,前者是单卡的batch_size,后者表示训练迭代的轮数(单个batch进行一次前向和反向表示一轮)。
+* 每个配置信息模块中,`type`字段对应到PaddleSeg代码中的类名(Python Class Name),其他字段对应类(Python Class)中`__init__`函数的初始化参数。
+* 数据集dataset模块,支持的类在`PaddleSeg/paddleseg/datasets`目录下(使用@manager.DATASETS.add_component进行注册)。
+* 数据预处理方式transforms模块,支持的类在`PaddleSeg/paddleseg/transforms/transforms.py`文件中(使用@manager.TRANSFORMS.add_component进行注册)。
+* 优化器optimizer模块,支持Paddle提供的所有优化器类,具体参考:https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/Overview_cn.html#api
+* 学习率衰减lr_scheduler模块,支持Paddle提供的所有lr_scheduler类,具体参考:https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/Overview_cn.html#about-lr
+* 损失函数Loss模块,在`types`字段下分别定义使用的损失函数类,`coef`字段定义每个损失函数的权重。`types`字段下损失函数个数,应该等于`coef`字段数组的长度。如果所有损失函数相同,可以只定义一个损失函数。支持的损失函数类在`PaddleSeg/paddleseg/models/losses/`目录下(使用@manager.LOSSES.add_component注册)。
+* 模型Model模块,支持的model类在`PaddleSeg/paddleseg/models/`目录下(使用@manager.MODELS.add_component注册),支持的backbone类在`PaddleSeg/paddleseg/models/backbones`目录下(使用@manager.BACKBONES.add_component注册)。
+
+```
+batch_size: 4 #设定batch_size的值即为迭代一次送入网络的图片数量,一般显卡显存越大,batch_size的值可以越大。如果使用多卡训练,总得batch size等于该batch size乘以卡数。
+iters: 1000 #模型训练迭代的轮数
+
+train_dataset: #训练数据设置
+ type: Dataset #指定加载数据集的类。数据集类的代码在`PaddleSeg/paddleseg/datasets`目录下。
+ dataset_root: data/optic_disc_seg #数据集路径
+ train_path: data/optic_disc_seg/train_list.txt #数据集中用于训练的标识文件
+ num_classes: 2 #指定类别个数(背景也算为一类)
+ mode: train #表示用于训练
+ transforms: #模型训练的数据预处理方式。
+ - type: ResizeStepScaling #将原始图像和标注图像随机缩放为0.5~2.0倍
+ min_scale_factor: 0.5
+ max_scale_factor: 2.0
+ scale_step_size: 0.25
+ - type: RandomPaddingCrop #从原始图像和标注图像中随机裁剪512x512大小
+ crop_size: [512, 512]
+ - type: RandomHorizontalFlip #对原始图像和标注图像随机进行水平反转
+ - type: RandomDistort #对原始图像进行亮度、对比度、饱和度随机变动,标注图像不变
+ brightness_range: 0.5
+ contrast_range: 0.5
+ saturation_range: 0.5
+ - type: Normalize #对原始图像进行归一化,标注图像保持不变
+
+val_dataset: #验证数据设置
+ type: Dataset #指定加载数据集的类。数据集类的代码在`PaddleSeg/paddleseg/datasets`目录下。
+ dataset_root: data/optic_disc_seg #数据集路径
+ val_path: data/optic_disc_seg/val_list.txt #数据集中用于验证的标识文件
+ num_classes: 2 #指定类别个数(背景也算为一类)
+ mode: val #表示用于验证
+ transforms: #模型验证的数据预处理的方式
+ - type: Normalize #对原始图像进行归一化,标注图像保持不变
+
+optimizer: #设定优化器的类型
+ type: sgd #采用SGD(Stochastic Gradient Descent)随机梯度下降方法为优化器
+ momentum: 0.9 #设置SGD的动量
+ weight_decay: 4.0e-5 #权值衰减,使用的目的是防止过拟合
+
+lr_scheduler: # 学习率的相关设置
+ type: PolynomialDecay # 一种学习率类型。共支持12种策略
+ learning_rate: 0.01 # 初始学习率
+ power: 0.9
+ end_lr: 0
+
+loss: #设定损失函数的类型
+ types:
+ - type: CrossEntropyLoss #CE损失
+ coef: [1, 1, 1] # PP-LiteSeg有一个主loss和两个辅助loss,coef表示权重,所以 total_loss = coef_1 * loss_1 + .... + coef_n * loss_n
+
+model: #模型说明
+ type: PPLiteSeg #设定模型类别
+ backbone: # 设定模型的backbone,包括名字和预训练权重
+ type: STDC2
+ pretrained: https://bj.bcebos.com/paddleseg/dygraph/PP_STDCNet2.tar.gz
+
+```
+
+注意:
+- 对于训练和测试数据集的预处理,PaddleSeg默认会添加读取图像操作、HWC转CHW的操作,所以这两个操作不用添加到transform配置字段中。
+- 只有"PaddleSeg/configs/quick_start"下面配置文件中的学习率为单卡学习率,其他配置文件中均为4卡的学习率。如果大家单卡训练来复现公开数据集上的指标,学习率设置应变成原来的1/4。
+
+
+上面我们介绍的PP-LiteSeg配置文件,所有的配置信息都放置在同一个yml文件中。为了具有更好的复用性,PaddleSeg的配置文件采用了更加耦合的设计,配置文件支持包含复用。
+
+如下图,右侧`deeplabv3p_resnet50_os8_cityscapes_1024x512_80k.yml`配置文件通过`_base_: '../_base_/cityscapes.yml'`来包含左侧`cityscapes.yml`配置文件,其中`_base_: `设置的是被包含配置文件相对于该配置文件的路径。
+
+如果两个配置文件具有相同的字段信息,被包含的配置文件中的字段信息会被覆盖。如下图,1号配置文件可以覆盖2号配置文件的字段信息。
+
+
diff --git a/docs/whole_process_cn.md b/docs/whole_process_cn.md
index 2db36f9f34..9d6c552a15 100644
--- a/docs/whole_process_cn.md
+++ b/docs/whole_process_cn.md
@@ -59,7 +59,7 @@ PP-LiteSeg模型的结构如下图。更多详细介绍,请参考[链接](../c
### 3.2 配置文件详细解读
-PaddleSeg中,配置文件包括超参、训练数据集、验证数据集、优化器、损失函数、模型等信息。**所有的配置文件在PaddleSeg/configs文件夹下面**。
+PaddleSeg中,配置文件包括超参、训练数据集、验证数据集、优化器、损失函数、模型等信息。**所有模型在公开数据集上训练的配置文件在PaddleSeg/configs文件夹下面**。
大家可以灵活修改配置文件的内容,如自定义模型使用的骨干网络、模型使用的损失函数以及关于网络结构等配置,自定义配置数据处理的策略,如改变尺寸、归一化和翻转等数据增强的策略,这些修改可以参考对应模块的代码,传入相应参数即可。
From 998ab74ea150f9c351978dcd0e85eb2fcb42dda3 Mon Sep 17 00:00:00 2001
From: juncaipeng <13006307475@163.com>
Date: Tue, 29 Nov 2022 14:40:20 +0800
Subject: [PATCH 03/10] up
---
docs/config/pre_config.md | 1 +
docs/config/pre_config_cn.md | 25 ++++++++++++++-----------
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/docs/config/pre_config.md b/docs/config/pre_config.md
index 71b9949a48..7c6b418a7c 100644
--- a/docs/config/pre_config.md
+++ b/docs/config/pre_config.md
@@ -1,4 +1,5 @@
English | [简体中文 ](pre_config_cn.md)
+# Config Preparation
The config file contains the information of train dataset, val dataset, optimizer, loss and model in PaddleSeg.
All config files of SOTA models are saved in `PaddleSeg/configs`.
diff --git a/docs/config/pre_config_cn.md b/docs/config/pre_config_cn.md
index 0cf12f0b8b..a3b86610a0 100644
--- a/docs/config/pre_config_cn.md
+++ b/docs/config/pre_config_cn.md
@@ -1,19 +1,22 @@
简体中文 | [English](pre_config.md)
-PaddleSeg中,配置文件包括超参、训练数据集、验证数据集、优化器、损失函数、模型等信息。**所有模型在公开数据集上训练的配置文件在PaddleSeg/configs文件夹下面**。
+# 准备配置文件
-大家可以灵活修改配置文件的内容,如自定义模型使用的骨干网络、模型使用的损失函数以及关于网络结构等配置,自定义配置数据处理的策略,如改变尺寸、归一化和翻转等数据增强的策略,这些修改可以参考对应模块的代码,传入相应参数即可。
+PaddleSeg的配置文件按照模块化进行定义,包括超参、训练数据集、验证数据集、优化器、损失函数、模型等模块信息。
+不同模块信息都对应PaddleSeg中定义的模块类,所以PaddleSeg基于配置文件构建对应的模块,进行模型训练、评估和导出。
+
+PaddleSeg中所有语义分割模型都针对公开数据集,提供了对应的配置文件,都保存在`PaddleSeg/configs`目录下。
+
+下面是`PaddleSeg/configs/quick_start/pp_liteseg_optic_disc_512x512_1k.yml`配置文件,我们以此为例进行详细解读,让大家熟悉修改配置文件的方法。
-下面是`PaddleSeg/configs/quick_start/pp_liteseg_optic_disc_512x512_1k.yml`配置文件,我们进行详细解读:
-* yml文件定义了超参、训练数据集、测试数据集、优化器、学习率、损失函数、模型的配置信息,PaddleSeg基于配置信息构建对应的模块,进行模型训练、评估和导出。
* 超参主要包括batch_size和iters,前者是单卡的batch_size,后者表示训练迭代的轮数(单个batch进行一次前向和反向表示一轮)。
-* 每个配置信息模块中,`type`字段对应到PaddleSeg代码中的类名(Python Class Name),其他字段对应类(Python Class)中`__init__`函数的初始化参数。
-* 数据集dataset模块,支持的类在`PaddleSeg/paddleseg/datasets`目录下(使用@manager.DATASETS.add_component进行注册)。
-* 数据预处理方式transforms模块,支持的类在`PaddleSeg/paddleseg/transforms/transforms.py`文件中(使用@manager.TRANSFORMS.add_component进行注册)。
-* 优化器optimizer模块,支持Paddle提供的所有优化器类,具体参考:https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/Overview_cn.html#api
-* 学习率衰减lr_scheduler模块,支持Paddle提供的所有lr_scheduler类,具体参考:https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/Overview_cn.html#about-lr
-* 损失函数Loss模块,在`types`字段下分别定义使用的损失函数类,`coef`字段定义每个损失函数的权重。`types`字段下损失函数个数,应该等于`coef`字段数组的长度。如果所有损失函数相同,可以只定义一个损失函数。支持的损失函数类在`PaddleSeg/paddleseg/models/losses/`目录下(使用@manager.LOSSES.add_component注册)。
-* 模型Model模块,支持的model类在`PaddleSeg/paddleseg/models/`目录下(使用@manager.MODELS.add_component注册),支持的backbone类在`PaddleSeg/paddleseg/models/backbones`目录下(使用@manager.BACKBONES.add_component注册)。
+* 每个模块信息中,`type`字段对应到PaddleSeg代码中的类名(Python Class Name),其他字段对应类(Python Class)中`__init__`函数的初始化参数。所以大家需要参考PaddleSeg代码中的模块类来修改模块信息。
+* 数据集dataset模块,支持的类在`PaddleSeg/paddleseg/datasets`[目录](../../paddleseg/datasets/)下,使用`@manager.DATASETS.add_component`进行注册。
+* 数据预处理方式transforms模块,支持的类在`PaddleSeg/paddleseg/transforms/transforms.py`[文件](../../paddleseg/transforms/transforms.py)中,使用`@manager.TRANSFORMS.add_component`进行注册。
+* 优化器optimizer模块,支持Paddle提供的所有优化器类,具体参考[文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/Overview_cn.html#api)。
+* 学习率衰减lr_scheduler模块,支持Paddle提供的所有lr_scheduler类,具体参考[文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/Overview_cn.html#about-lr)。
+* 损失函数Loss模块,在`types`字段下分别定义使用的损失函数类,`coef`字段定义每个损失函数的权重。`types`字段下损失函数个数,应该等于`coef`字段数组的长度。如果所有损失函数相同,可以只定义一个损失函数。支持的损失函数类在`PaddleSeg/paddleseg/models/losses/`[目录](../../paddleseg/models/losses/)下,使用`@manager.LOSSES.add_component注册`。
+* 模型Model模块,支持的model类在`PaddleSeg/paddleseg/models/`[目录](../../paddleseg/models)下,使用`@manager.MODELS.add_component`注册;支持的backbone类在`PaddleSeg/paddleseg/models/backbones`[目录](../../paddleseg/models/backbones/)下,使用`@manager.BACKBONES.add_component`注册。
```
batch_size: 4 #设定batch_size的值即为迭代一次送入网络的图片数量,一般显卡显存越大,batch_size的值可以越大。如果使用多卡训练,总得batch size等于该batch size乘以卡数。
From 6a4680607e8e6729ddcaf5722aac64d88a88e1c1 Mon Sep 17 00:00:00 2001
From: juncaipeng <13006307475@163.com>
Date: Tue, 29 Nov 2022 14:46:02 +0800
Subject: [PATCH 04/10] up
---
docs/config/pre_config_cn.md | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/docs/config/pre_config_cn.md b/docs/config/pre_config_cn.md
index a3b86610a0..70970c88f3 100644
--- a/docs/config/pre_config_cn.md
+++ b/docs/config/pre_config_cn.md
@@ -3,20 +3,22 @@
# 准备配置文件
PaddleSeg的配置文件按照模块化进行定义,包括超参、训练数据集、验证数据集、优化器、损失函数、模型等模块信息。
+
不同模块信息都对应PaddleSeg中定义的模块类,所以PaddleSeg基于配置文件构建对应的模块,进行模型训练、评估和导出。
-PaddleSeg中所有语义分割模型都针对公开数据集,提供了对应的配置文件,都保存在`PaddleSeg/configs`目录下。
+PaddleSeg中所有语义分割模型都针对公开数据集,提供了对应的配置文件,保存在`PaddleSeg/configs`目录下。
-下面是`PaddleSeg/configs/quick_start/pp_liteseg_optic_disc_512x512_1k.yml`配置文件,我们以此为例进行详细解读,让大家熟悉修改配置文件的方法。
+下面是`PaddleSeg/configs/quick_start/pp_liteseg_optic_disc_512x512_1k.yml`配置文件。我们以这个配置文件为例进行详细解读,让大家熟悉修改配置文件的方法。
* 超参主要包括batch_size和iters,前者是单卡的batch_size,后者表示训练迭代的轮数(单个batch进行一次前向和反向表示一轮)。
-* 每个模块信息中,`type`字段对应到PaddleSeg代码中的类名(Python Class Name),其他字段对应类(Python Class)中`__init__`函数的初始化参数。所以大家需要参考PaddleSeg代码中的模块类来修改模块信息。
-* 数据集dataset模块,支持的类在`PaddleSeg/paddleseg/datasets`[目录](../../paddleseg/datasets/)下,使用`@manager.DATASETS.add_component`进行注册。
-* 数据预处理方式transforms模块,支持的类在`PaddleSeg/paddleseg/transforms/transforms.py`[文件](../../paddleseg/transforms/transforms.py)中,使用`@manager.TRANSFORMS.add_component`进行注册。
+* 每个模块信息中,`type`字段对应到PaddleSeg代码中的模块类名(python class name),其他字段对应模块类`__init__`函数的初始化参数。所以大家需要参考PaddleSeg代码中的模块类来修改模块信息。
+* 数据集dataset模块,支持的dataset类在`PaddleSeg/paddleseg/datasets`[目录](../../paddleseg/datasets/)下,使用`@manager.DATASETS.add_component`进行注册。
+* 数据预处理方式transforms模块,支持的transform类在`PaddleSeg/paddleseg/transforms/transforms.py`[文件](../../paddleseg/transforms/transforms.py)中,使用`@manager.TRANSFORMS.add_component`进行注册。
* 优化器optimizer模块,支持Paddle提供的所有优化器类,具体参考[文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/Overview_cn.html#api)。
* 学习率衰减lr_scheduler模块,支持Paddle提供的所有lr_scheduler类,具体参考[文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/Overview_cn.html#about-lr)。
* 损失函数Loss模块,在`types`字段下分别定义使用的损失函数类,`coef`字段定义每个损失函数的权重。`types`字段下损失函数个数,应该等于`coef`字段数组的长度。如果所有损失函数相同,可以只定义一个损失函数。支持的损失函数类在`PaddleSeg/paddleseg/models/losses/`[目录](../../paddleseg/models/losses/)下,使用`@manager.LOSSES.add_component注册`。
-* 模型Model模块,支持的model类在`PaddleSeg/paddleseg/models/`[目录](../../paddleseg/models)下,使用`@manager.MODELS.add_component`注册;支持的backbone类在`PaddleSeg/paddleseg/models/backbones`[目录](../../paddleseg/models/backbones/)下,使用`@manager.BACKBONES.add_component`注册。
+* 模型Model模块,支持的model类在`PaddleSeg/paddleseg/models/`[目录](../../paddleseg/models)下,使用`@manager.MODELS.add_component`注册。
+* 模型Model模块,支持的backbone类在`PaddleSeg/paddleseg/models/backbones`[目录](../../paddleseg/models/backbones/)下,使用`@manager.BACKBONES.add_component`注册。
```
batch_size: 4 #设定batch_size的值即为迭代一次送入网络的图片数量,一般显卡显存越大,batch_size的值可以越大。如果使用多卡训练,总得batch size等于该batch size乘以卡数。
From 69ed7e8cf31b6ad06f830171241c6ee73cabe14e Mon Sep 17 00:00:00 2001
From: juncaipeng <13006307475@163.com>
Date: Tue, 29 Nov 2022 16:33:00 +0800
Subject: [PATCH 05/10] up
---
README_CN.md | 6 +++---
README_EN.md | 2 +-
docs/data/custom/data_prepare.md | 2 +-
docs/data/custom/data_prepare_cn.md | 2 +-
docs/data/marker/LabelMe.md | 2 +-
docs/data/marker/LabelMe_cn.md | 2 +-
docs/deployment/inference/infer_benchmark.md | 2 +-
docs/deployment/inference/infer_benchmark_cn.md | 2 +-
docs/deployment/inference/python_inference.md | 2 +-
docs/deployment/inference/python_inference_cn.md | 2 +-
docs/deployment/lite/lite.md | 1 +
docs/deployment/lite/lite_cn.md | 8 +++++---
docs/deployment/serving/serving.md | 2 +-
docs/deployment/serving/serving_cn.md | 2 +-
docs/deployment/slim/distill/distill.md | 2 ++
docs/deployment/slim/distill/distill_cn.md | 2 ++
docs/deployment/slim/quant/quant.md | 2 ++
docs/deployment/slim/quant/quant_cn.md | 2 ++
docs/evaluation/evaluate.md | 2 +-
docs/evaluation/evaluate_cn.md | 2 +-
docs/install_cn.md | 2 +-
docs/model_export_onnx.md | 2 +-
docs/model_export_onnx_cn.md | 2 +-
docs/model_zoo_overview_cn.md | 2 +-
docs/predict/predict.md | 2 +-
docs/predict/predict_cn.md | 2 +-
docs/quick_start_cn.md | 2 +-
docs/train/train.md | 2 +-
docs/train/train_cn.md | 2 +-
docs/train/train_tricks.md | 2 +-
docs/train/train_tricks_cn.md | 2 +-
31 files changed, 41 insertions(+), 30 deletions(-)
diff --git a/README_CN.md b/README_CN.md
index 7588bf7479..f69a1a1555 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -44,7 +44,7 @@
## 特性
-* **高精度**:跟踪学术界的前沿分割技术,结合半监督标签知识蒸馏方案([SSLD](https://paddleclas.readthedocs.io/zh_CN/latest/advanced_tutorials/distillation/distillation.html#ssld))训练的骨干网络,提供40+主流分割网络、140+的高质量预训练模型,效果优于其他开源实现。
+* **高精度**:跟踪学术界的前沿分割技术,结合高精度训练的骨干网络,提供40+主流分割网络、140+的高质量预训练模型,效果优于其他开源实现。
* **高性能**:使用多进程异步I/O、多卡并行训练、评估等加速策略,结合飞桨核心框架的显存优化功能,大幅度减少分割模型的训练开销,让开发者更低成本、更高效地完成图像分割训练。
@@ -370,7 +370,7 @@
**基础教程**
-* 准备数据
+* 准备数据集
* [准备公开数据集](./docs/data/pre_data_cn.md)
* [准备自定义数据集](./docs/data/marker/marker_cn.md)
* [EISeg 数据标注](./EISeg)
@@ -387,7 +387,7 @@
* [Paddle Inference部署(Python)](./docs/deployment/inference/python_inference_cn.md)
* [Paddle Inference部署(C++)](./docs/deployment/inference/cpp_inference_cn.md)
* [Paddle Lite部署](./docs/deployment/lite/lite_cn.md)
- * [Paddle Serving部署](./docs/deployment/serving/serving.md)
+ * [Paddle Serving部署](./docs/deployment/serving/serving_cn.md)
* [Paddle JS部署](./docs/deployment/web/web_cn.md)
* [推理Benchmark](./docs/deployment/inference/infer_benchmark_cn.md)
diff --git a/README_EN.md b/README_EN.md
index 1b615e88e6..cc61710763 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -49,7 +49,7 @@ PaddleSeg is an end-to-end high-efficent development toolkit for image segmentat
##
Features
-* **High-Performance Model**: Following the state of the art segmentation methods and use the high-performance backbone trained by semi-supervised label knowledge distillation scheme ([SSLD]((https://paddleclas.readthedocs.io/zh_CN/latest/advanced_tutorials/distillation/distillation.html#ssld))), we provide 40+ models and 140+ high-quality pre-training models, which are better than other open-source implementations.
+* **High-Performance Model**: Following the state of the art segmentation methods and use the high-performance backbone, we provide 40+ models and 140+ high-quality pre-training models, which are better than other open-source implementations.
* **High Efficiency**: PaddleSeg provides multi-process asynchronous I/O, multi-card parallel training, evaluation, and other acceleration strategies, combined with the memory optimization function of the PaddlePaddle, which can greatly reduce the training overhead of the segmentation model, all this allowing developers to lower cost and more efficiently train image segmentation model.
diff --git a/docs/data/custom/data_prepare.md b/docs/data/custom/data_prepare.md
index 1217898934..c6e4919ebe 100644
--- a/docs/data/custom/data_prepare.md
+++ b/docs/data/custom/data_prepare.md
@@ -1,4 +1,4 @@
-English|[简体中文](data_prepare_cn.md)
+English | [简体中文](data_prepare_cn.md)
# Prepare Custom Dataset Data
If you want to train on custom dataset, please prepare the dataset using following steps.
diff --git a/docs/data/custom/data_prepare_cn.md b/docs/data/custom/data_prepare_cn.md
index e69ef77cd5..050a2ed712 100644
--- a/docs/data/custom/data_prepare_cn.md
+++ b/docs/data/custom/data_prepare_cn.md
@@ -1,4 +1,4 @@
-简体中文|[English](data_prepare.md)
+简体中文 | [English](data_prepare.md)
# 准备自定义数据集
如果您需要使用自定义数据集进行训练,请按照以下步骤准备数据。
diff --git a/docs/data/marker/LabelMe.md b/docs/data/marker/LabelMe.md
index 0c8d2de225..5c414aaf48 100644
--- a/docs/data/marker/LabelMe.md
+++ b/docs/data/marker/LabelMe.md
@@ -1,4 +1,4 @@
-English|[简体中文](LabelMe_cn.md)
+English | [简体中文](LabelMe_cn.md)
# LabelMe
If you have not installed it before, please refer to [LabelMe installation](https://paddlex.readthedocs.io/zh_CN/develop/data/annotation/labelme.html)
diff --git a/docs/data/marker/LabelMe_cn.md b/docs/data/marker/LabelMe_cn.md
index a8d917da22..8ce95d3d09 100644
--- a/docs/data/marker/LabelMe_cn.md
+++ b/docs/data/marker/LabelMe_cn.md
@@ -1,4 +1,4 @@
-简体中文|[English](LabelMe.md)
+简体中文 | [English](LabelMe.md)
# LabelMe
如您先前并无安装,那么LabelMe的安装可参考[LabelMe安装和启动](https://paddlex.readthedocs.io/zh_CN/develop/data/annotation/labelme.html)
diff --git a/docs/deployment/inference/infer_benchmark.md b/docs/deployment/inference/infer_benchmark.md
index a3337a2a71..f7dc2baf68 100644
--- a/docs/deployment/inference/infer_benchmark.md
+++ b/docs/deployment/inference/infer_benchmark.md
@@ -1,4 +1,4 @@
-English|[简体中文](infer_benchmark_cn.md)
+English | [简体中文](infer_benchmark_cn.md)
# Inference Benchmark
Test Environment:
diff --git a/docs/deployment/inference/infer_benchmark_cn.md b/docs/deployment/inference/infer_benchmark_cn.md
index 9faa424005..11a8d17a97 100644
--- a/docs/deployment/inference/infer_benchmark_cn.md
+++ b/docs/deployment/inference/infer_benchmark_cn.md
@@ -1,4 +1,4 @@
-简体中文|[English](infer_benchmark.md)
+简体中文 | [English](infer_benchmark.md)
# 推理 Benchmark
测试环境:
diff --git a/docs/deployment/inference/python_inference.md b/docs/deployment/inference/python_inference.md
index 43723e7b3b..e347523126 100644
--- a/docs/deployment/inference/python_inference.md
+++ b/docs/deployment/inference/python_inference.md
@@ -1,4 +1,4 @@
-English|[简体中文](python_inference_cn.md)
+English | [简体中文](python_inference_cn.md)
# Paddle Inference Deployment(Python)
## 1. Description
diff --git a/docs/deployment/inference/python_inference_cn.md b/docs/deployment/inference/python_inference_cn.md
index fe89186766..9862611f3a 100644
--- a/docs/deployment/inference/python_inference_cn.md
+++ b/docs/deployment/inference/python_inference_cn.md
@@ -1,4 +1,4 @@
-简体中文|[English](python_inference.md)
+简体中文 | [English](python_inference.md)
# Paddle Inference部署(Python)
## 1. 说明
diff --git a/docs/deployment/lite/lite.md b/docs/deployment/lite/lite.md
index 045f9ae878..822798b3e0 100644
--- a/docs/deployment/lite/lite.md
+++ b/docs/deployment/lite/lite.md
@@ -1,3 +1,4 @@
+English | [简体中文](lite_cn.md)
# Deployment by PaddleLite
## 1. Introduction
diff --git a/docs/deployment/lite/lite_cn.md b/docs/deployment/lite/lite_cn.md
index 117ad3f512..284a9b2baf 100644
--- a/docs/deployment/lite/lite_cn.md
+++ b/docs/deployment/lite/lite_cn.md
@@ -1,3 +1,5 @@
+简体中文 | [English](lite.md)
+
# 移动端Lite部署
## 1.介绍
@@ -45,11 +47,11 @@ Paddle-Lite的编译目前支持Docker,Linux和Mac OS开发环境,建议使
* 使用预编译版本的预测库,最新的预编译文件参考:[release](https://github.com/PaddlePaddle/Paddle-Lite/releases/),此demo使用的[版本](https://paddlelite-demo.bj.bcebos.com/libs/android/paddle_lite_libs_v2_8_0.tar.gz)
- 解压上面文件,PaddlePredictor.jar位于:java/PaddlePredictor.jar;
+ 解压上面文件,PaddlePredictor.jar位于:java/PaddlePredictor.jar;
- arm64-v8a相关so位于:java/libs/arm64-v8a;
+ arm64-v8a相关so位于:java/libs/arm64-v8a;
- armeabi-v7a相关so位于:java/libs/armeabi-v7a;
+ armeabi-v7a相关so位于:java/libs/armeabi-v7a;
* 手动编译Paddle-Lite预测库
开发环境的准备和编译方法参考:[Paddle-Lite源码编译](https://paddle-lite.readthedocs.io/zh/release-v2.8/source_compile/compile_env.html)。
diff --git a/docs/deployment/serving/serving.md b/docs/deployment/serving/serving.md
index 81eba6defa..6d4d37bcf7 100644
--- a/docs/deployment/serving/serving.md
+++ b/docs/deployment/serving/serving.md
@@ -1,4 +1,4 @@
-English|[简体中文](serving_cn.md)
+English | [简体中文](serving_cn.md)
# Paddle Serving deployment
## Overview
diff --git a/docs/deployment/serving/serving_cn.md b/docs/deployment/serving/serving_cn.md
index 8139c2c18f..5427e2c8b3 100644
--- a/docs/deployment/serving/serving_cn.md
+++ b/docs/deployment/serving/serving_cn.md
@@ -1,4 +1,4 @@
-简体中文|[English](serving.md)
+简体中文 | [English](serving.md)
# Paddle Serving部署
## 概述
diff --git a/docs/deployment/slim/distill/distill.md b/docs/deployment/slim/distill/distill.md
index 7d06c30df7..f0559c16dc 100644
--- a/docs/deployment/slim/distill/distill.md
+++ b/docs/deployment/slim/distill/distill.md
@@ -1,3 +1,5 @@
+English | [简体中文](distill_cn.md)
+
# Model Distillation Tutorial
# 1. Introduction
diff --git a/docs/deployment/slim/distill/distill_cn.md b/docs/deployment/slim/distill/distill_cn.md
index 191f1bf3e5..1e3d133b93 100644
--- a/docs/deployment/slim/distill/distill_cn.md
+++ b/docs/deployment/slim/distill/distill_cn.md
@@ -1,3 +1,5 @@
+简体中文 | [English](distill.md)
+
# 模型蒸馏教程
## 1 简介
diff --git a/docs/deployment/slim/quant/quant.md b/docs/deployment/slim/quant/quant.md
index 31f78107b5..1785204774 100644
--- a/docs/deployment/slim/quant/quant.md
+++ b/docs/deployment/slim/quant/quant.md
@@ -1,3 +1,5 @@
+English | [简体中文](quant_cn.md)
+
# Model Quantization Tutorial
diff --git a/docs/deployment/slim/quant/quant_cn.md b/docs/deployment/slim/quant/quant_cn.md
index a51fd40da1..745bd8f21f 100644
--- a/docs/deployment/slim/quant/quant_cn.md
+++ b/docs/deployment/slim/quant/quant_cn.md
@@ -1,3 +1,5 @@
+简体中文 | [English](quant.md)
+
# 模型量化教程
## 1 概述
diff --git a/docs/evaluation/evaluate.md b/docs/evaluation/evaluate.md
index cb92282479..c5af589731 100644
--- a/docs/evaluation/evaluate.md
+++ b/docs/evaluation/evaluate.md
@@ -1,4 +1,4 @@
-English|[简体中文](evaluate_cn.md)
+English | [简体中文](evaluate_cn.md)
## Model Evaluating
### 1. Evaluation and Prediction under **Configuration-Driven** Approach
diff --git a/docs/evaluation/evaluate_cn.md b/docs/evaluation/evaluate_cn.md
index a2bdbfae4a..fd1606ee75 100644
--- a/docs/evaluation/evaluate_cn.md
+++ b/docs/evaluation/evaluate_cn.md
@@ -1,4 +1,4 @@
-简体中文|[English](evaluate.md)
+简体中文 | [English](evaluate.md)
## 模型评估
### 1.**配置化驱动**方式下评估
diff --git a/docs/install_cn.md b/docs/install_cn.md
index 9f688fd857..202762d9de 100644
--- a/docs/install_cn.md
+++ b/docs/install_cn.md
@@ -1,4 +1,4 @@
-简体中文|[English](install.md)
+简体中文 | [English](install.md)
# 安装文档
diff --git a/docs/model_export_onnx.md b/docs/model_export_onnx.md
index d631070171..adf15f0cb2 100644
--- a/docs/model_export_onnx.md
+++ b/docs/model_export_onnx.md
@@ -1,4 +1,4 @@
-English|[简体中文](model_export_onnx_cn.md)
+English | [简体中文](model_export_onnx_cn.md)
# Export model with ONNX format
After training the model by PaddleSeg, we also support exporting model with ONNX format. This tutorial provides an example to introduce it.
diff --git a/docs/model_export_onnx_cn.md b/docs/model_export_onnx_cn.md
index 48156c8c00..55e49773ef 100644
--- a/docs/model_export_onnx_cn.md
+++ b/docs/model_export_onnx_cn.md
@@ -1,4 +1,4 @@
-简体中文|[English](model_export_onnx.md)
+简体中文 | [English](model_export_onnx.md)
# 导出ONNX格式模型
PaddleSeg训练好模型后,也支持导出ONNX格式模型,本教程提供一个示例介绍使用方法。
diff --git a/docs/model_zoo_overview_cn.md b/docs/model_zoo_overview_cn.md
index 6edd59f471..355ff57984 100644
--- a/docs/model_zoo_overview_cn.md
+++ b/docs/model_zoo_overview_cn.md
@@ -1,6 +1,6 @@
简体中文 | [English](model_zoo_overview.md)
-# PaddleSeg模型库总览
+# 模型库
## 模型库
### CNN系列
diff --git a/docs/predict/predict.md b/docs/predict/predict.md
index c7b6deb0c3..4ddffbed81 100644
--- a/docs/predict/predict.md
+++ b/docs/predict/predict.md
@@ -1,4 +1,4 @@
-English|[简体中文](predict_cn.md)
+English | [简体中文](predict_cn.md)
# Prediction
diff --git a/docs/predict/predict_cn.md b/docs/predict/predict_cn.md
index f5b855070c..f91176f0a3 100644
--- a/docs/predict/predict_cn.md
+++ b/docs/predict/predict_cn.md
@@ -1,4 +1,4 @@
-简体中文|[English](predict.md)
+简体中文 | [English](predict.md)
# 预测
除了分析模型的IOU、ACC和Kappa指标之外,我们还可以查阅一些具体样本的切割样本效果,从Bad Case启发进一步优化的思路。
diff --git a/docs/quick_start_cn.md b/docs/quick_start_cn.md
index fb36ac8b57..2c7e3b625e 100644
--- a/docs/quick_start_cn.md
+++ b/docs/quick_start_cn.md
@@ -1,4 +1,4 @@
-[English](./quick_start.md) | 简体中文
+简体中文 | [English](./quick_start.md)
# 快速开始
diff --git a/docs/train/train.md b/docs/train/train.md
index 913d45c18c..199e9cd949 100644
--- a/docs/train/train.md
+++ b/docs/train/train.md
@@ -1,4 +1,4 @@
-English|[简体中文](train_cn.md)
+English | [简体中文](train_cn.md)
# Model Training
## 1、Start Training
diff --git a/docs/train/train_cn.md b/docs/train/train_cn.md
index 3428a9bb86..fe1c1e9cef 100644
--- a/docs/train/train_cn.md
+++ b/docs/train/train_cn.md
@@ -1,4 +1,4 @@
-简体中文|[English](train.md)
+简体中文 | [English](train.md)
# 模型训练
## 1、单卡训练
diff --git a/docs/train/train_tricks.md b/docs/train/train_tricks.md
index 0420b1509b..3c88038363 100644
--- a/docs/train/train_tricks.md
+++ b/docs/train/train_tricks.md
@@ -1,4 +1,4 @@
-English|[简体中文](train_tricks_cn.md)
+English | [简体中文](train_tricks_cn.md)
# Training Tricks
diff --git a/docs/train/train_tricks_cn.md b/docs/train/train_tricks_cn.md
index adf874e30f..f4f7b2a2c7 100644
--- a/docs/train/train_tricks_cn.md
+++ b/docs/train/train_tricks_cn.md
@@ -1,4 +1,4 @@
-简体中文|[English](train_tricks.md)
+简体中文 | [English](train_tricks.md)
# 模型训练技巧
From 22292e0d4309981cdd00f6102b293d12be3070c3 Mon Sep 17 00:00:00 2001
From: juncaipeng <13006307475@163.com>
Date: Tue, 29 Nov 2022 17:07:02 +0800
Subject: [PATCH 06/10] add model zoo
---
README_CN.md | 1 +
README_EN.md | 7 ++-
docs/model_zoo_overview.md | 107 ++++++----------------------------
docs/model_zoo_overview_cn.md | 98 ++++---------------------------
4 files changed, 35 insertions(+), 178 deletions(-)
diff --git a/README_CN.md b/README_CN.md
index f69a1a1555..772e6b73b9 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -367,6 +367,7 @@
* [安装说明](./docs/install_cn.md)
* [快速体验](./docs/quick_start_cn.md)
* [20分钟快速上手PaddleSeg](./docs/whole_process_cn.md)
+* [模型库](./docs/model_zoo_overview_cn.md)
**基础教程**
diff --git a/README_EN.md b/README_EN.md
index cc61710763..343129511c 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -369,11 +369,12 @@ Note that:
* [Installation](./docs/install.md)
* [Quick Start](./docs/quick_start.md)
-* [A 20 minutes Blitz to learn PaddleSeg](./docs/whole_process.md)
+* [A 20 minutes Blitz to Learn PaddleSeg](./docs/whole_process.md)
+* [Model Zoo](./docs/model_zoo_overview.md)
**Basic Tutorials**
-* Data Preparation
+* Data Preparation
* [Prepare Public Dataset](./docs/data/pre_data.md)
* [Prepare Customized Dataset](./docs/data/marker/marker.md)
* [Label Data with EISeg](./EISeg)
@@ -386,7 +387,7 @@ Note that:
* [Export Inference Model](./docs/model_export.md)
* [Export ONNX Model](./docs/model_export_onnx.md)
-* Model Deploy
+* Model Deploy
* [Paddle Inference (Python)](./docs/deployment/inference/python_inference.md)
* [Paddle Inference (C++)](./docs/deployment/inference/cpp_inference.md)
* [Paddle Lite](./docs/deployment/lite/lite.md)
diff --git a/docs/model_zoo_overview.md b/docs/model_zoo_overview.md
index 24527e052c..e463f80577 100644
--- a/docs/model_zoo_overview.md
+++ b/docs/model_zoo_overview.md
@@ -1,9 +1,24 @@
English | [简体中文](model_zoo_overview_cn.md)
-# PaddleSeg model zoo overview
+# Model Zoo
-## Model zoo
-### CNN Series
+## Semantic Segmentation Model Zoo
+
+目前,PaddleSeg提供了40+语义分割模型、150+预训练模型、10+骨干网络。
+
+在`PaddleSeg/configs`目录下,我们给出了所有模型在公开数据集上的配置文件和README文件,比如[PP-LiteSeg模型](../configs/pp_liteseg/)。
+其中,README文件介绍了模型论文和训练精度,而且给出了公开数据集上训练的权重,可以直接下载进行测试。
+
+如下我们列出了部分模型。
+
+PaddleSeg provides 40+ semantic segmentation models, 150+ well-trained models, 10+ backbones.
+
+In `PaddleSeg/configs`, we provide the config files and readme.md for all models on common dataset, e.g., [PP-LiteSeg](../configs/pp_liteseg/).
+Besides, the readme.md file introduces the origin paper, the performance and the trained weights.
+
+Some common models are as follows.
+
+**CNN Series**
|Model\Backbone Network|ResNet50|ResNet101|HRNetw18|HRNetw48|
|-|-|-|-|-|
@@ -49,92 +64,8 @@ English | [简体中文](model_zoo_overview_cn.md)
|[GloRe](../configs/glore)|✔|-|-|-|
|[PP-LiteSeg](../configs/pp_liteseg)|-|-|-|-|
-### Transformer series
+**Transformer series**
* [SETR](../configs/setr)
* [MLATransformer](../contrib/AutoNUE/configs)
* [SegFormer](../configs/segformer)
* [SegMenter](../configs/segmenter)
-
-# Model zoo benchmark
-Based on the Cityscapes dataset, PaddleSeg supports 22+ series of segmentation algorithms and corresponding 30+ image segmentation pre-training models. The performance is evaluated as follows.
-
-**Test environment:**
-
-- GPU: Tesla V100 16GB
-- CPU: Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
-- CUDA: 10.2
-- cuDNN: 7.6
-- Paddle: 2.1.3
-- PaddleSeg: 2.3
-
-**Test method:**
-
-- Single GPU, Batch size is 1, the running time is pure model prediction time, and the predicted image size is 1024x512.
-- Use Paddle Inference's Python API to test the model after export.
-- Inference time is the result of averaging predictions using 100 images in the CityScapes dataset.
-- Some algorithms have only tested performance under the configuration that achieves the highest segmentation accuracy.
-
-## Accuracy vs Speed
-