Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleX
提交
96764865
P
PaddleX
项目概览
PaddlePaddle
/
PaddleX
通知
138
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
43
列表
看板
标记
里程碑
合并请求
5
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleX
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
43
Issue
43
列表
看板
标记
里程碑
合并请求
5
合并请求
5
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
96764865
编写于
6月 18, 2020
作者:
F
FlyingQianMM
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Applications -> examples
上级
829431c5
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
11 addition
and
32 deletion
+11
-32
Applications/HumanSeg/data/background.jpg
Applications/HumanSeg/data/background.jpg
+0
-0
Applications/HumanSeg/data/human_image.jpg
Applications/HumanSeg/data/human_image.jpg
+0
-0
Applications/HumanSeg/utils/__init__.py
Applications/HumanSeg/utils/__init__.py
+0
-15
examples/human_segmentation/README.md
examples/human_segmentation/README.md
+4
-6
examples/human_segmentation/bg_replace.py
examples/human_segmentation/bg_replace.py
+0
-0
examples/human_segmentation/data/download_data.py
examples/human_segmentation/data/download_data.py
+0
-0
examples/human_segmentation/eval.py
examples/human_segmentation/eval.py
+0
-0
examples/human_segmentation/postprocess.py
examples/human_segmentation/postprocess.py
+6
-5
examples/human_segmentation/pretrain_weights/download_pretrain_weights.py
...egmentation/pretrain_weights/download_pretrain_weights.py
+0
-0
examples/human_segmentation/quant_offline.py
examples/human_segmentation/quant_offline.py
+0
-0
examples/human_segmentation/train.py
examples/human_segmentation/train.py
+0
-5
examples/human_segmentation/video_infer.py
examples/human_segmentation/video_infer.py
+1
-1
未找到文件。
Applications/HumanSeg/data/background.jpg
已删除
100644 → 0
浏览文件 @
829431c5
339.0 KB
Applications/HumanSeg/data/human_image.jpg
已删除
100644 → 0
浏览文件 @
829431c5
78.3 KB
Applications/HumanSeg/utils/__init__.py
已删除
100644 → 0
浏览文件 @
829431c5
# Copyright (c) 2020 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.
from
.
import
humanseg_postprocess
Applications/HumanSeg
/README.md
→
examples/human_segmentation
/README.md
浏览文件 @
96764865
...
...
@@ -7,8 +7,6 @@
**前置依赖**
*
paddlepaddle >= 1.8.0
*
python >= 3.5
*
cython
*
pycocotools
```
pip install paddlex -i https://mirror.baidu.com/pypi/simple
...
...
@@ -95,6 +93,10 @@ python bg_replace.py --model_dir pretrain_weights/humanseg_mobile_inference --im
## 训练
使用下述命令基于与训练模型进行Fine-tuning,请确保选用的模型结构
`model_type`
与模型参数
`pretrain_weights`
匹配。
```
bash
# 指定GPU卡号(以0号卡为例)
export
CUDA_VISIBLE_DEVICES
=
0
# 若不使用GPU,则将CUDA_VISIBLE_DEVICES指定为空
# export CUDA_VISIBLE_DEVICES=
python train.py
--model_type
HumanSegMobile
\
--save_dir
output/
\
--data_dir
data/mini_supervisely
\
...
...
@@ -177,7 +179,3 @@ python quant_offline.py --model_dir output/best_model \
*
`--quant_list`
: 量化数据集列表路径,一般直接选择训练集或验证集
*
`--save_dir`
: 量化模型保存路径
*
`--image_shape`
: 网络输入图像大小(w, h)
## AIStudio在线教程
我们在AI Studio平台上提供了人像分割在线体验的教程,
[
点击体验
](
https://aistudio.baidu.com/aistudio/projectdetail/475345
)
Applications/HumanSeg
/bg_replace.py
→
examples/human_segmentation
/bg_replace.py
浏览文件 @
96764865
文件已移动
Applications/HumanSeg
/data/download_data.py
→
examples/human_segmentation
/data/download_data.py
浏览文件 @
96764865
文件已移动
Applications/HumanSeg
/eval.py
→
examples/human_segmentation
/eval.py
浏览文件 @
96764865
文件已移动
Applications/HumanSeg/utils/humanseg_
postprocess.py
→
examples/human_segmentation/
postprocess.py
浏览文件 @
96764865
...
...
@@ -16,7 +16,8 @@
import
numpy
as
np
def
human_seg_tracking
(
pre_gray
,
cur_gray
,
prev_cfd
,
dl_weights
,
disflow
):
def
cal_optical_flow_tracking
(
pre_gray
,
cur_gray
,
prev_cfd
,
dl_weights
,
disflow
):
"""计算光流跟踪匹配点和光流图
输入参数:
pre_gray: 上一帧灰度图
...
...
@@ -59,7 +60,7 @@ def human_seg_tracking(pre_gray, cur_gray, prev_cfd, dl_weights, disflow):
return
track_cfd
,
is_track
,
dl_weights
def
human_seg_track_fuse
(
track_cfd
,
dl_cfd
,
dl_weights
,
is_track
):
def
fuse_optical_flow_tracking
(
track_cfd
,
dl_cfd
,
dl_weights
,
is_track
):
"""光流追踪图和人像分割结构融合
输入参数:
track_cfd: 光流追踪图
...
...
@@ -116,9 +117,9 @@ def postprocess(cur_gray, scoremap, prev_gray, pre_cfd, disflow, is_init):
fusion_cfd
=
cur_cfd
else
:
weights
=
np
.
ones
((
h
,
w
),
np
.
float32
)
*
0.3
track_cfd
,
is_track
,
weights
=
human_seg
_tracking
(
track_cfd
,
is_track
,
weights
=
cal_optical_flow
_tracking
(
prev_gray
,
cur_gray
,
pre_cfd
,
weights
,
disflow
)
fusion_cfd
=
human_seg_track_fuse
(
track_cfd
,
cur_cfd
,
weights
,
is_track
)
fusion_cfd
=
fuse_optical_flow_tracking
(
track_cfd
,
cur_cfd
,
weights
,
is_track
)
return
fusion_cfd
Applications/HumanSeg
/pretrain_weights/download_pretrain_weights.py
→
examples/human_segmentation
/pretrain_weights/download_pretrain_weights.py
浏览文件 @
96764865
文件已移动
Applications/HumanSeg
/quant_offline.py
→
examples/human_segmentation
/quant_offline.py
浏览文件 @
96764865
文件已移动
Applications/HumanSeg
/train.py
→
examples/human_segmentation
/train.py
浏览文件 @
96764865
...
...
@@ -13,11 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
os
# 选择使用0号卡
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
'0'
# 使用CPU
#os.environ['CUDA_VISIBLE_DEVICES'] = ''
import
argparse
import
paddlex
as
pdx
...
...
Applications/HumanSeg
/video_infer.py
→
examples/human_segmentation
/video_infer.py
浏览文件 @
96764865
...
...
@@ -19,7 +19,7 @@ import os.path as osp
import
cv2
import
numpy
as
np
from
utils.humanseg_
postprocess
import
postprocess
,
threshold_mask
from
postprocess
import
postprocess
,
threshold_mask
import
paddlex
as
pdx
import
paddlex.utils.logging
as
logging
from
paddlex.seg
import
transforms
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录