Skip to content

Commit

Permalink
Merge pull request #1 from PaddlePaddle/master
Browse files Browse the repository at this point in the history
track official update
  • Loading branch information
LielinJiang committed Sep 4, 2019
2 parents 0ed1863 + aa03cba commit 8ec2454
Show file tree
Hide file tree
Showing 65 changed files with 1,467 additions and 727 deletions.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: python

python:
- '2.7'
- '3.5'
- '3.6'

script:
- /bin/bash ./test/ci/test_download_dataset.sh

notifications:
email:
on_success: change
on_failure: always
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# PaddleSeg 语义分割库

[![Build Status](https://travis-ci.org/PaddlePaddle/PaddleSeg.svg?branch=master)](https://travis-ci.org/PaddlePaddle/PaddleSeg)
[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE)

## 简介
Expand All @@ -19,7 +20,7 @@ PaddleSeg是基于[PaddlePaddle](https://www.paddlepaddle.org.cn)开发的语义

- **高性能**

- PaddleSeg支持多进程IO、多卡并行、多卡Batch Norm同步等训练加速策略,通过飞桨核心框架的显存优化算法,可以大幅度节约分割模型的显存开销,更快完成分割模型训练。
- PaddleSeg支持多进程IO、多卡并行、多卡Batch Norm同步等训练加速策略,结合飞桨核心框架的显存优化算法,可以大幅度减少分割模型的显存开销,更快完成分割模型训练。

- **工业级部署**

Expand Down Expand Up @@ -76,7 +77,7 @@ A: 降低Batch size,使用Group Norm策略等。

* PaddleSeg分割库初始版本发布,包含DeepLabv3+, U-Net, ICNet三类分割模型, 其中DeepLabv3+支持Xception, MobileNet两种可调节的骨干网络。
* CVPR 19' LIP人体部件分割比赛冠军预测模型发布[ACE2P](./contrib/ACE2P)
* 预置基于DeepLabv3+网络的[人像分割](./contrib/HumanSeg/)[车道线分割](./contrib/RoadLine)预测模型发布
* 预置基于DeepLabv3+网络的人像分割和车道线分割预测模型发布

## 如何贡献代码

Expand Down
5 changes: 0 additions & 5 deletions contrib/ACE2P/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Augmented Context Embedding with Edge Perceiving(ACE2P)


- 类别: 图像-语义分割
- 网络: ACE2P
- 数据集: LIP

## 模型概述
人体解析(Human Parsing)是细粒度的语义分割任务,旨在识别像素级别的人类图像的组成部分(例如,身体部位和服装)。ACE2P通过融合底层特征、全局上下文信息和边缘细节,
端到端训练学习人体解析任务。以ACE2P单人人体解析网络为基础的解决方案在CVPR2019第三届LIP挑战赛中赢得了全部三个人体解析任务的第一名
Expand Down
2 changes: 1 addition & 1 deletion contrib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CVPR 19 Look into Person (LIP) 单人人像分割比赛冠军模型,详见[ACE

### 4. 运行

**NOTE:** 运行该模型需要需至少2.5G显存
**NOTE:** 运行该模型需要2G左右显存

使用GPU预测
```
Expand Down
6 changes: 3 additions & 3 deletions contrib/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ def infer():
output_im.putpalette(palette)
output_im.save(result_path)

if idx % 100 == 0:
print('%d processd' % (idx))
if (idx + 1) % 100 == 0:
print('%d processd' % (idx + 1))

print('%d processd done' % (idx))
print('%d processd done' % (idx + 1))

return 0

Expand Down
33 changes: 33 additions & 0 deletions dataset/download_cityscapes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import os

LOCAL_PATH = os.path.dirname(os.path.abspath(__file__))
TEST_PATH = os.path.join(LOCAL_PATH, "..", "test")
sys.path.append(TEST_PATH)

from test_utils import download_file_and_uncompress


def download_cityscapes_dataset(savepath, extrapath):
url = "https://paddleseg.bj.bcebos.com/dataset/cityscapes.tar"
download_file_and_uncompress(
url=url, savepath=savepath, extrapath=extrapath)


if __name__ == "__main__":
download_cityscapes_dataset(LOCAL_PATH, LOCAL_PATH)
print("Dataset download finish!")
33 changes: 33 additions & 0 deletions dataset/download_pet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import os

LOCAL_PATH = os.path.dirname(os.path.abspath(__file__))
TEST_PATH = os.path.join(LOCAL_PATH, "..", "test")
sys.path.append(TEST_PATH)

from test_utils import download_file_and_uncompress


def download_pet_dataset(savepath, extrapath):
url = "https://paddleseg.bj.bcebos.com/dataset/mini_pet.zip"
download_file_and_uncompress(
url=url, savepath=savepath, extrapath=extrapath)


if __name__ == "__main__":
download_pet_dataset(LOCAL_PATH, LOCAL_PATH)
print("Dataset download finish!")
16 changes: 8 additions & 8 deletions docs/annotation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
打开终端输入`labelme`会出现LableMe的交互界面,可以先预览`LabelMe`给出的已标注好的图片,再开始标注自定义数据集。

<div align="center">
<img src="./docs/imgs/annotation/image-1.png" width="600px"/>
<img src="../imgs/annotation/image-1.png" width="600px"/>
<p>图1 LableMe交互界面的示意图</p>
</div>

Expand All @@ -24,7 +24,7 @@ git clone https://github.com/wkentaro/labelme
终端输入`labelme`会出现LableMe的交互界面,点击`OpenDir`打开`<path/to/labelme>/examples/semantic_segmentation/data_annotated`,其中`<path/to/labelme>`为克隆下来的`labelme`的路径,打开后示意的是语义分割的真值标注。

<div align="center">
<img src="./docs/imgs/annotation/image-2.png" width="600px"/>
<img src="../imgs/annotation/image-2.png" width="600px"/>
<p>图2 已标注图片的示意图</p>
</div>

Expand All @@ -35,15 +35,15 @@ git clone https://github.com/wkentaro/labelme
​ (1) 点击`OpenDir`打开待标注图片所在目录,点击`Create Polygons`,沿着目标的边缘画多边形,完成后输入目标的类别。在标注过程中,如果某个点画错了,可以按撤销快捷键可撤销该点。Mac下的撤销快捷键为`command+Z`

<div align="center">
<img src="./docs/imgs/annotation/image-3.png" width="600px"/>
<img src="../imgs/annotation/image-3.png" width="600px"/>
<p>图3 标注单个目标的示意图</p>
</div>

​ (2) 右击选择`Edit Polygons`可以整体移动多边形的位置,也可以移动某个点的位置;右击选择`Edit Label`可以修改每个目标的类别。请根据自己的需要执行这一步骤,若不需要修改,可跳过。

<div align="center">
<img src="./docs/imgs/annotation/image-4-1.png" width="00px" />
<img src="./docs/imgs/annotation/image-4-2.png" width="600px"/>
<img src="../imgs/annotation/image-4-1.png" width="00px" />
<img src="../imgs/annotation/image-4-2.png" width="600px"/>
<p>图4 修改标注的示意图</p>
</div>

Expand All @@ -52,7 +52,7 @@ git clone https://github.com/wkentaro/labelme
LableMe产出的真值文件可参考我们给出的文件夹`data_annotated`

<div align="center">
<img src="./docs/imgs/annotation/image-5.png" width="600px"/>
<img src="../imgs/annotation/image-5.png" width="600px"/>
<p>图5 LableMe产出的真值文件的示意图</p>
</div>

Expand All @@ -71,7 +71,7 @@ LableMe产出的真值文件可参考我们给出的文件夹`data_annotated`。
```

<div align="center">
<img src="./docs/imgs/annotation/image-6.png" width="600px"/>
<img src="../imgs/annotation/image-6.png" width="600px"/>
<p>图6 训练所需的数据集目录的结构示意图</p>
</div>

Expand All @@ -92,6 +92,6 @@ pip install pillow
转换得到的数据集可参考我们给出的文件夹`my_dataset`。其中,文件`class_names.txt`是数据集中所有标注类别的名称,包含背景类;文件夹`JPEGImages`保存的是数据集的图片;文件夹`SegmentationClassPNG`保存的是各图片的像素级别的真值信息,背景类`_background_`对应为0,其它目标类别从1开始递增,至多为255。

<div align="center">
<img src="./docs/imgs/annotation/image-7.png" width="600px"/>
<img src="../imgs/annotation/image-7.png" width="600px"/>
<p>图7 训练所需的数据集各目录的内容示意图</p>
</div>
4 changes: 2 additions & 2 deletions docs/configs/dataloader_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ DATALOADER Group存放所有与数据加载相关的配置
### 注意事项

* 该选项只在`pdseg/train.py``pdseg/eval.py`中使用到
* 当使用多线程时,该字段表示线程适量,使用多进程时,该字段表示进程数量。一般该字段使用默认值即可
* 该字段表示数据预处理时的进程数量,只有在`pdseg/train.py`或者`pdseg/eval.py`中打开了`--use_mpio`开关有效。一般该字段使用默认值即可

<br/>
<br/>
Expand All @@ -27,4 +27,4 @@ DATALOADER Group存放所有与数据加载相关的配置
256

<br/>
<br/>
<br/>
2 changes: 1 addition & 1 deletion docs/data_aug.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ rich crop是指对图像进行多种变换,保证在训练过程中数据的

- 输入图片格式
- 原图
- 图片格式:rgb三通道图片和rgba四通道图片两种类型的图片进行训练,但是在一次训练过程只能存在一种格式。
- 图片格式:RGB三通道图片和RGBA四通道图片两种类型的图片进行训练,但是在一次训练过程只能存在一种格式。
- 图片转换:灰度图片经过预处理后之后会转变成三通道图片
- 图片参数设置:当图片为三通道图片时IMAGE_TYPE设置为rgb, 对应MEAN和STD也必须是一个长度为3的list,当图片为四通道图片时IMAGE_TYPE设置为rgba,对应的MEAN和STD必须是一个长度为4的list。
- 标注图
Expand Down
41 changes: 26 additions & 15 deletions docs/data_prepare.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ PaddleSeg采用通用的文件列表方式组织训练集、验证集和测试
```


其中`[SEP]`是文件路径分割符,可以在`DATASET.SEPRATOR`配置项中修改, 默认为空格。
其中`[SEP]`是文件路径分割符,可以在`DATASET.SEPARATOR`配置项中修改, 默认为空格。

**注意事项**

Expand All @@ -60,42 +60,50 @@ PaddleSeg采用通用的文件列表方式组织训练集、验证集和测试
完整的配置信息可以参考[`./dataset/cityscapes_demo`](../dataset/cityscapes_demo/)目录下的yaml和文件列表。

## 数据校验
从7方面对用户自定义的数据集和yaml配置进行校验,帮助用户排查基本的数据和配置问题。
对用户自定义的数据集和yaml配置进行校验,帮助用户排查基本的数据和配置问题。

数据校验脚本如下,支持通过`YAML_FILE_PATH`来指定配置文件。
```
# YAML_FILE_PATH为yaml配置文件路径
python pdseg/check.py --cfg ${YAML_FILE_PATH}
```
### 1 数据集基本校验
* 数据集路径检查,包括`DATASET.TRAIN_FILE_LIST``DATASET.VAL_FILE_LIST``DATASET.TEST_FILE_LIST`设置是否正确。
* 列表分割符检查,判断在`TRAIN_FILE_LIST``VAL_FILE_LIST``TEST_FILE_LIST`列表文件中的分隔符`DATASET.SEPARATOR`设置是否正确。
运行后,命令行将显示校验结果的概览信息,详细信息可到detail.log文件中查看。

### 2 标注类别校验
### 1 列表分割符校验
判断在`TRAIN_FILE_LIST``VAL_FILE_LIST``TEST_FILE_LIST`列表文件中的分隔符`DATASET.SEPARATOR`设置是否正确。
### 2 数据集读取校验
通过是否能成功读取`DATASET.TRAIN_FILE_LIST``DATASET.VAL_FILE_LIST``DATASET.TEST_FILE_LIST`中所有图片,判断这3项设置是否正确。

若不正确返回错误信息。错误可能有多种情况,如数据集路径设置错误、图片损坏等。

### 3 标注格式校验
检查标注图像是否为PNG格式。

**NOTE:** 标注图像请使用PNG无损压缩格式的图片,若使用其他格式则可能影响精度。

### 4 标注通道数校验
检查标注图的通道数。正确的标注图应该为单通道图像。

### 5 标注类别校验
检查实际标注类别是否和配置参数`DATASET.NUM_CLASSES``DATASET.IGNORE_INDEX`匹配。

**NOTE:**
标注图像类别数值必须在[0~(`DATASET.NUM_CLASSES`-1)]范围内或者为`DATASET.IGNORE_INDEX`
标注类别最好从0开始,否则可能影响精度。

### 3 标注像素统计
### 6 标注像素统计
统计每种类别像素数量,显示以供参考。

### 4 标注格式校验
检查标注图像是否为PNG格式。

**NOTE:** 标注图像请使用PNG无损压缩格式的图片,若使用其他格式则可能影响精度。

### 5 图像格式校验
### 7 图像格式校验
检查图片类型`DATASET.IMAGE_TYPE`是否设置正确。

**NOTE:** 当数据集包含三通道图片时`DATASET.IMAGE_TYPE`设置为rgb;
当数据集全部为四通道图片时`DATASET.IMAGE_TYPE`设置为rgba;

### 6 图像与标注图尺寸一致性校验
### 8 图像与标注图尺寸一致性校验
验证图像尺寸和对应标注图尺寸是否一致。

### 7 模型验证参数`EVAL_CROP_SIZE`校验
### 9 模型验证参数`EVAL_CROP_SIZE`校验
验证`EVAL_CROP_SIZE`是否设置正确,共有3种情形:

-`AUG.AUG_METHOD`为unpadding时,`EVAL_CROP_SIZE`的宽高应不小于`AUG.FIX_RESIZE_SIZE`的宽高。
Expand All @@ -105,3 +113,6 @@ python pdseg/check.py --cfg ${YAML_FILE_PATH}
-`AUG.AUG_METHOD`为rangscaling时,`EVAL_CROP_SIZE`的宽高应不小于缩放后图像中最大的宽高。

我们将计算并给出`EVAL_CROP_SIZE`的建议值。

### 10 数据增强参数`AUG.INF_RESIZE_VALUE`校验
验证`AUG.INF_RESIZE_VALUE`是否在[`AUG.MIN_RESIZE_VALUE`~`AUG.MAX_RESIZE_VALUE`]范围内。若在范围内,则通过校验。
15 changes: 4 additions & 11 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* Python2.7 or 3.5+
* CUDA 9.2
* cudnn v7.1

* paddlepaddle >= 1.5.2
* nccl >= 2.4.7


## 1. 安装PaddlePaddle
Expand All @@ -26,7 +27,7 @@ PaddlePaddle最新版本1.5支持Conda安装,可以减少相关依赖安装成
conda install -c paddle paddlepaddle-gpu cudatoolkit=9.0
```

更多安装方式详情可以查看 [PaddlePaddle快速开始](https://www.paddlepaddle.org.cn/start)
更多安装方式详情可以查看 [PaddlePaddle安装说明](https://www.paddlepaddle.org.cn/documentation/docs/zh/beginners_guide/install/index_cn.html)


## 2. 下载PaddleSeg代码
Expand All @@ -39,14 +40,6 @@ git clone https://github.com/PaddlePaddle/PaddleSeg
## 3. 安装PaddleSeg依赖

```
cd PaddleSeg
pip install -r requirements.txt
```


## 4. 本地流程测试

通过执行以下命令,会完整执行数据下载,训练,可视化,预测模型导出四个环节,用于验证PaddleSeg安装和依赖是否正常。

```
python test/local_test_cityscapes.py
```
6 changes: 3 additions & 3 deletions docs/model_zoo.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ train数据集为coco instance分割数据集合转换成的语义分割数据
|---|---|---|---|---|---|---|
| DeepLabv3+/MobileNetv2/bn | COCO | MODEL.MODEL_NAME: deeplabv3p <br> MODEL.DEEPLAB.BACKBONE: mobilenet <br> MODEL.DEEPLAB.DEPTH_MULTIPLIER: 1.0 <br> MODEL.DEFAULT_NORM_TYPE: bn|[deeplabv3plus_coco_bn_init.tgz](https://bj.bcebos.com/v1/paddleseg/deeplabv3plus_coco_bn_init.tgz) | 16 | --| -- |
| DeeplabV3+/Xception65/bn | COCO | MODEL.MODEL_NAME: deeplabv3p <br> MODEL.DEEPLAB.BACKBONE: xception_65 <br> MODEL.DEFAULT_NORM_TYPE: bn | [xception65_coco.tgz](https://paddleseg.bj.bcebos.com/models/xception65_coco.tgz)| 16 | -- | -- |
| UNet/bn | COCO | MODEL.MODEL_NEME: unet <br> MODEL.DEFAULT_NORM_TYPE: bn | [unet](https://paddleseg.bj.bcebos.com/models/unet_coco_v2.tgz) | 16 | -- | -- |
| UNet/bn | COCO | MODEL.MODEL_NEME: unet <br> MODEL.DEFAULT_NORM_TYPE: bn | [unet](https://paddleseg.bj.bcebos.com/models/unet_coco_v3.tgz) | 16 | -- | -- |

## Cityscapes预训练模型

Expand All @@ -40,5 +40,5 @@ train数据集合为Cityscapes 训练集合,测试为Cityscapes的验证集合
|---|---|---|---|---|---|---|
| DeepLabv3+/MobileNetv2/bn | Cityscapes |MODEL.MODEL_NAME: deeplabv3p <br> MODEL.DEEPLAB.BACKBONE: mobilenet <br> MODEL.DEEPLAB.DEPTH_MULTIPLIER: 1.0 <br> MODEL.DEEPLAB.ENCODER_WITH_ASPP: False <br> MODEL.DEEPLAB.ENABLE_DECODER: False <br> MODEL.DEFAULT_NORM_TYPE: bn|[mobilenet_cityscapes.tgz](https://paddleseg.bj.bcebos.com/models/mobilenet_cityscapes.tgz) |16|false| 0.698|
| DeepLabv3+/Xception65/gn | Cityscapes |MODEL.MODEL_NAME: deeplabv3p <br> MODEL.DEEPLAB.BACKBONE: xception_65 <br> MODEL.DEFAULT_NORM_TYPE: gn | [deeplabv3p_xception65_cityscapes.tgz](https://paddleseg.bj.bcebos.com/models/deeplabv3p_xception65_cityscapes.tgz) |16|false| 0.7804 |
| DeepLabv3+/Xception65/bn | Cityscapes | MODEL.MODEL_NAME: deeplabv3p <br> MODEL.DEEPLAB.BACKBONE: xception_65 <br> MODEL.DEFAULT_NORM_TYPE: bn| [Xception65_deeplab_cityscapes.tgz](https://paddleseg.bj.bcebos.com/models/Xception65_deeplab_cityscapes.tgz) | 16 | false | 0.7715 |
| ICNet/bn | Cityscapes | MODEL.MODEL_NAME: icnet <br> MODEL.DEFAULT_NORM_TYPE: bn | [icnet_cityscapes.tgz](https://paddleseg.bj.bcebos.com/models/icnet_cityscapes.tgz) |16|false| 0.6854 |
| DeepLabv3+/Xception65/bn | Cityscapes | MODEL.MODEL_NAME: deeplabv3p <br> MODEL.DEEPLAB.BACKBONE: xception_65 <br> MODEL.DEFAULT_NORM_TYPE: bn| [Xception65_deeplab_cityscapes.tgz](https://paddleseg.bj.bcebos.com/models/xception65_bn_cityscapes.tgz) | 16 | false | 0.7715 |
| ICNet/bn | Cityscapes | MODEL.MODEL_NAME: icnet <br> MODEL.DEFAULT_NORM_TYPE: bn | [icnet_cityscapes.tgz](https://paddleseg.bj.bcebos.com/models/icnet6831.tar.gz) |16|false| 0.6831 |
Loading

0 comments on commit 8ec2454

Please sign in to comment.