Skip to content

Commit

Permalink
Merge pull request #78 from LielinJiang/dianbiao_contrib
Browse files Browse the repository at this point in the history
Add mechanical meter to contrib
  • Loading branch information
LielinJiang authored Nov 1, 2019
2 parents 6e99158 + 7bc19a1 commit 43f56a5
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 6 deletions.
52 changes: 52 additions & 0 deletions configs/unet_mechanical_meter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
EVAL_CROP_SIZE: (2049, 1537) # (width, height), for unpadding rangescaling and stepscaling
TRAIN_CROP_SIZE: (769, 769) # (width, height), for unpadding rangescaling and stepscaling
AUG:
AUG_METHOD: u"stepscaling" # choice unpadding rangescaling and stepscaling
FIX_RESIZE_SIZE: (640, 640) # (width, height), for unpadding
INF_RESIZE_VALUE: 500 # for rangescaling
MAX_RESIZE_VALUE: 600 # for rangescaling
MIN_RESIZE_VALUE: 400 # for rangescaling
MAX_SCALE_FACTOR: 2.0 # for stepscaling
MIN_SCALE_FACTOR: 0.5 # for stepscaling
SCALE_STEP_SIZE: 0.25 # for stepscaling
MIRROR: True
RICH_CROP:
ENABLE: False

BATCH_SIZE: 2
MEAN: [0.5, 0.5, 0.5]
STD: [0.5, 0.5, 0.5]

DATALOADER:
BUF_SIZE: 256
NUM_WORKERS: 4
DATASET:
DATA_DIR: "./dataset/mini_mechanical_industry_meter_data/"
IMAGE_TYPE: "rgb" # choice rgb or rgba
NUM_CLASSES: 5
TEST_FILE_LIST: "./dataset/mini_mechanical_industry_meter_data/val_mini.txt"
TEST_TOTAL_IMAGES: 8
TRAIN_FILE_LIST: "./dataset/mini_mechanical_industry_meter_data/train_mini.txt"
TRAIN_TOTAL_IMAGES: 64
VAL_FILE_LIST: "./dataset/mini_mechanical_industry_meter_data/val_mini.txt"
VAL_TOTAL_IMAGES: 8
SEPARATOR: "|"
IGNORE_INDEX: 255

FREEZE:
MODEL_FILENAME: "__model__"
PARAMS_FILENAME: "__params__"
MODEL:
MODEL_NAME: "unet"
DEFAULT_NORM_TYPE: "bn"
TEST:
TEST_MODEL: "./saved_model/unet_mechanical_meter/final/"
TRAIN:
MODEL_SAVE_DIR: "./saved_model/unet_mechanical_meter/"
PRETRAINED_MODEL_DIR: "./pretrained_model/unet_bn_coco/"
SNAPSHOT_EPOCH: 10
SOLVER:
NUM_EPOCHS: 100
LR: 0.001
LR_POLICY: "poly"
OPTIMIZER: "sgd"
31 changes: 31 additions & 0 deletions contrib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,37 @@ python -u infer.py --example RoadLine

预测结果:![](imgs/RoadLine.png)

## 工业用表分割

### 1. 模型结构

unet

### 2. 数据准备

cd到PaddleSeg/dataset文件夹下,执行download_mini_mechanical_industry_meter.py


### 3. 训练与评估

```
CUDA_VISIBLE_DEVICES=0 python ./pdseg/train.py --log_steps 10 --cfg configs/unet_mechanical_meter.yaml --use_gpu --do_eval --use_mpio
```

### 4. 可视化
我们提供了一个训练好的模型,点击[链接](https://paddleseg.bj.bcebos.com/models/unet_mechanical_industry_meter.tar),下载后放在PaddleSeg/pretrained_model下
```
CUDA_VISIBLE_DEVICES=0 python ./pdseg/vis.py --cfg configs/unet_mechanical_meter.yaml --use_gpu --vis_dir vis_meter \
TEST.TEST_MODEL "./pretrained_model/unet_gongyeyongbiao/"
```
可视化结果会保存在vis_meter文件夹下

### 5. 可视化结果示例:

原图:![](imgs/1560143028.5_IMG_3091.JPG)

预测结果:![](imgs/1560143028.5_IMG_3091.png)

# 备注

1. 数据及模型路径等详细配置见ACE2P/HumanSeg/RoadLine下的config.py文件
Expand Down
Binary file added contrib/imgs/1560143028.5_IMG_3091.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contrib/imgs/1560143028.5_IMG_3091.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions dataset/download_mini_mechanical_industry_meter.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_deepglobe_road_dataset(savepath, extrapath):
url = "https://paddleseg.bj.bcebos.com/dataset/mini_mechanical_industry_meter_data.zip"
download_file_and_uncompress(
url=url, savepath=savepath, extrapath=extrapath)


if __name__ == "__main__":
download_deepglobe_road_dataset(LOCAL_PATH, LOCAL_PATH)
print("Dataset download finish!")
13 changes: 7 additions & 6 deletions docs/multiple_gpus_train_and_mixed_precision_train.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### 环境要求
* PaddlePaddle >= 1.6.0
* NVIDIA NCCL >= 2.4.7,并在Linux环境下运行
* NVIDIA NCCL >= 2.4.7

环境配置,数据,预训练模型准备等工作请参考[安装说明](./installation.md)[PaddleSeg使用说明](./usage.md)

Expand Down Expand Up @@ -49,12 +49,13 @@ python -m paddle.distributed.launch pdseg/train.py --use_gpu \

### benchmark

| 模型 | 数据集合 | batch size | number gpu cards | 多进程训练 | 混合精度训练 | 显存占用 | 速度(image/s) | mIoU on val |
|---|---|---|---|---|---|---|---|---|
| DeepLabv3+/Xception65/bn | Cityscapes | 16 | 4 | False | False | 15988 MiB | 17.27 | 79.20 |
| DeepLabv3+/Xception65/bn | Cityscapes | 16 | 4 | True | False | 15814 MiB | 19.80 | 78.90 |
| DeepLabv3+/Xception65/bn | Cityscapes | 16 | 4 | True | True | 14922 MiB | 25.84 |79.06|
| 模型 | 数据集合 | batch size | number gpu cards | 多进程训练 | 混合精度训练 | 速度(image/s) | mIoU on val |
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| DeepLabv3+/Xception65/bn | Cityscapes | 16 | 4 | False | False | 17.27 | 79.20 |
| DeepLabv3+/Xception65/bn | Cityscapes | 16 | 4 | True | False | 19.80 | 78.90 |
| DeepLabv3+/Xception65/bn | Cityscapes | 16 | 4 | True | True | 25.84 |79.06|

测试环境:python3.7.3,paddle1.6.0,cuda10,cudnn7.6.2,v100。

### 参考

Expand Down
3 changes: 3 additions & 0 deletions turtorial/finetune_icnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

* 本教程的所有命令都基于PaddleSeg主目录进行执行

* 注意 ***`ICNet`*** 不支持在cpu环境上训练和评估


## 一. 准备待训练数据

我们提前准备好了一份数据集,通过以下代码进行下载
Expand Down

0 comments on commit 43f56a5

Please sign in to comment.