Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleGAN
提交
9c673e6b
P
PaddleGAN
项目概览
PaddlePaddle
/
PaddleGAN
大约 1 年 前同步成功
通知
97
Star
7254
Fork
1210
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleGAN
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9c673e6b
编写于
11月 11, 2020
作者:
L
lijianshe02
提交者:
GitHub
11月 11, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine duplicate frames and fix some bugs (#81)
* refine duplicate frames and fix some bugs
上级
358279b7
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
30 addition
and
19 deletion
+30
-19
docs/en_US/tutorials/psgan.md
docs/en_US/tutorials/psgan.md
+2
-2
docs/zh_CN/tutorials/psgan.md
docs/zh_CN/tutorials/psgan.md
+2
-2
ppgan/apps/dain_predictor.py
ppgan/apps/dain_predictor.py
+11
-1
ppgan/apps/psgan_predictor.py
ppgan/apps/psgan_predictor.py
+7
-14
ppgan/models/makeup_model.py
ppgan/models/makeup_model.py
+1
-0
tools/psgan_infer.py
tools/psgan_infer.py
+7
-0
未找到文件。
docs/en_US/tutorials/psgan.md
浏览文件 @
9c673e6b
...
...
@@ -33,8 +33,8 @@ python tools/psgan_infer.py \
2.
Downloading the landmarks
[
data
](
https://paddlegan.bj.bcebos.com/landmarks.tar
)
, and uncompress it
3.
Runnint the following command to substitute files:
```
mv landmarks/makeup MT-Dataset/landmarks/makeup
mv landmarks/non-makeup MT-Dataset/landmarks/non-makeup
rm -rf MT-Dataset/landmarks/makeup && mv landmarks/makeup MT-Dataset/landmarks/
rm -rf MT-Dataset/landmarks/non-makeup && mv landmarks/non-makeup MT-Dataset/landmarks/
cp landmarks/train_makeup.txt MT-Dataset/train_makeup.txt
cp landmarks/train_non-makeup.txt MT-Dataset/train_non-makeup.txt
```
...
...
docs/zh_CN/tutorials/psgan.md
浏览文件 @
9c673e6b
...
...
@@ -33,8 +33,8 @@ python tools/psgan_infer.py \
2.
下载landmarks数据
[
lmks
](
https://paddlegan.bj.bcebos.com/landmarks.tar
)
,并解压
3.
运行如下命令进行文件夹及文件替换:
```
mv landmarks/makeup MT-Dataset/landmarks/makeup
mv landmarks/non-makeup MT-Dataset/landmarks/non-makeup
rm -rf MT-Dataset/landmarks/makeup && mv landmarks/makeup MT-Dataset/landmarks/
rm -rf MT-Dataset/landmarks/non-makeup && mv landmarks/non-makeup MT-Dataset/landmarks/
cp landmarks/train_makeup.txt MT-Dataset/train_makeup.txt
cp landmarks/train_non-makeup.txt MT-Dataset/train_non-makeup.txt
```
...
...
ppgan/apps/dain_predictor.py
浏览文件 @
9c673e6b
...
...
@@ -269,6 +269,7 @@ class DAINPredictor(BasePredictor):
return
sum
([
2
**
i
for
(
i
,
v
)
in
enumerate
(
diff
.
flatten
())
if
v
])
hashes
=
{}
max_interp
=
9
image_paths
=
sorted
(
glob
.
glob
(
os
.
path
.
join
(
paths
,
'*.png'
)))
for
image_path
in
image_paths
:
image
=
cv2
.
imread
(
image_path
)
...
...
@@ -283,7 +284,16 @@ class DAINPredictor(BasePredictor):
last_index
=
int
(
hashed_paths
[
-
1
].
split
(
'/'
)[
-
1
].
split
(
'.'
)[
-
2
])
+
1
gap
=
2
*
(
last_index
-
first_index
)
-
1
if
gap
>
9
:
if
gap
>
2
*
max_interp
:
cut1
=
len
(
hashed_paths
)
//
3
cut2
=
cut1
*
2
for
p
in
hashed_paths
[
1
:
cut1
-
1
]:
os
.
remove
(
p
)
for
p
in
hashed_paths
[
cut1
+
1
:
cut2
]:
os
.
remove
(
p
)
for
p
in
hashed_paths
[
cut2
+
1
:]:
os
.
remove
(
p
)
if
gap
>
max_interp
:
mid
=
len
(
hashed_paths
)
//
2
for
p
in
hashed_paths
[
1
:
mid
-
1
]:
os
.
remove
(
p
)
...
...
ppgan/apps/psgan_predictor.py
浏览文件 @
9c673e6b
...
...
@@ -43,16 +43,6 @@ def toImage(net_output):
return
img
def
mask2image
(
mask
:
np
.
array
,
format
=
"HWC"
):
H
,
W
=
mask
.
shape
canvas
=
np
.
zeros
((
H
,
W
,
3
),
dtype
=
np
.
uint8
)
for
i
in
range
(
int
(
mask
.
max
())):
color
=
np
.
random
.
rand
(
1
,
1
,
3
)
*
255
canvas
+=
(
mask
==
i
)[:,
:,
None
]
*
color
.
astype
(
np
.
uint8
)
return
canvas
PS_WEIGHT_URL
=
"https://paddlegan.bj.bcebos.com/models/psgan_weight.pdparams"
...
...
@@ -81,6 +71,7 @@ class PreProcess:
self
.
down_ratio
,
self
.
width_ratio
)
np_image
=
np
.
array
(
image
)
image_trans
=
self
.
transform
(
np_image
)
mask
=
self
.
face_parser
.
parse
(
np
.
float32
(
cv2
.
resize
(
np_image
,
(
512
,
512
))))
mask
=
cv2
.
resize
(
mask
.
numpy
(),
(
self
.
img_size
,
self
.
img_size
),
...
...
@@ -88,7 +79,8 @@ class PreProcess:
mask
=
mask
.
astype
(
np
.
uint8
)
mask_tensor
=
paddle
.
to_tensor
(
mask
)
lms
=
futils
.
dlib
.
landmarks
(
image
,
face
)
*
self
.
img_size
/
image
.
width
lms
=
futils
.
dlib
.
landmarks
(
image
,
face
)
/
image_trans
.
shape
[:
2
]
*
self
.
img_size
lms
=
lms
.
round
()
P_np
=
generate_P_from_lmks
(
lms
,
self
.
img_size
,
self
.
img_size
,
...
...
@@ -96,10 +88,8 @@ class PreProcess:
mask_aug
=
generate_mask_aug
(
mask
,
lms
)
image
=
self
.
transform
(
np_image
)
return
[
self
.
norm
(
image
).
unsqueeze
(
0
),
self
.
norm
(
image
_trans
).
unsqueeze
(
0
),
np
.
float32
(
mask_aug
),
np
.
float32
(
P_np
),
np
.
float32
(
mask
)
...
...
@@ -212,6 +202,9 @@ class PSGANPredictor(BasePredictor):
image
=
postprocess
(
source_crop
,
image
)
ref_img_name
=
os
.
path
.
split
(
reference_path
)[
1
]
if
not
os
.
path
.
exists
(
self
.
output_path
):
os
.
makedirs
(
sefl
.
output_path
)
save_path
=
os
.
path
.
join
(
self
.
output_path
,
'transfered_ref_'
+
ref_img_name
)
image
.
save
(
save_path
)
ppgan/models/makeup_model.py
浏览文件 @
9c673e6b
...
...
@@ -11,6 +11,7 @@
# 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
os
import
numpy
as
np
import
paddle
...
...
tools/psgan_infer.py
浏览文件 @
9c673e6b
...
...
@@ -12,7 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
os
import
sys
import
argparse
cur_path
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
root_path
=
os
.
path
.
split
(
cur_path
)[
0
]
sys
.
path
.
append
(
root_path
)
from
ppgan.utils.options
import
parse_args
from
ppgan.utils.config
import
get_config
from
ppgan.apps.psgan_predictor
import
PSGANPredictor
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录