Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleGAN
提交
4760af1c
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看板
提交
4760af1c
编写于
9月 29, 2020
作者:
L
LielinJiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean code
上级
c1bd1a2a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
2 addition
and
36 deletion
+2
-36
ppgan/datasets/paired_dataset.py
ppgan/datasets/paired_dataset.py
+1
-10
ppgan/datasets/transforms/builder.py
ppgan/datasets/transforms/builder.py
+0
-9
ppgan/datasets/transforms/transforms.py
ppgan/datasets/transforms/transforms.py
+0
-15
ppgan/datasets/unpaired_dataset.py
ppgan/datasets/unpaired_dataset.py
+1
-2
未找到文件。
ppgan/datasets/paired_dataset.py
浏览文件 @
4760af1c
...
...
@@ -23,7 +23,7 @@ class PairedDataset(BaseDataset):
cfg
.
phase
)
# get the image directory
self
.
AB_paths
=
sorted
(
make_dataset
(
self
.
dir_AB
,
cfg
.
max_dataset_size
))
# get image paths
# assert(self.cfg.transform.load_size >= self.cfg.transform.crop_size) # crop_size should be smaller than the size of loaded image
self
.
input_nc
=
self
.
cfg
.
output_nc
if
self
.
cfg
.
direction
==
'BtoA'
else
self
.
cfg
.
input_nc
self
.
output_nc
=
self
.
cfg
.
input_nc
if
self
.
cfg
.
direction
==
'BtoA'
else
self
.
cfg
.
output_nc
self
.
transforms
=
build_transforms
(
cfg
.
transforms
)
...
...
@@ -53,15 +53,6 @@ class PairedDataset(BaseDataset):
B
=
AB
[:
h
,
w2
:,
:]
# apply the same transform to both A and B
# transform_params = get_params(self.opt, A.size)
# transform_params = get_params(self.cfg.transform, (w2, h))
# A_transform = get_transform(self.cfg.transform, transform_params, grayscale=(self.input_nc == 1))
# B_transform = get_transform(self.cfg.transform, transform_params, grayscale=(self.output_nc == 1))
# A = A_transform(A)
# B = B_transform(B)
# A, B = self.transforms((A, B))
A
,
B
=
self
.
transforms
((
A
,
B
))
return
{
'A'
:
A
,
'B'
:
B
,
'A_paths'
:
AB_path
,
'B_paths'
:
AB_path
}
...
...
ppgan/datasets/transforms/builder.py
浏览文件 @
4760af1c
...
...
@@ -25,11 +25,6 @@ class Compose(object):
def
__call__
(
self
,
data
):
for
f
in
self
.
transforms
:
try
:
# multi-fileds in a sample
# if isinstance(data, Sequence):
# data = f(*data)
# # single field in a sample, call transform directly
# else:
data
=
f
(
data
)
except
Exception
as
e
:
stack_info
=
traceback
.
format_exc
()
...
...
@@ -39,10 +34,6 @@ class Compose(object):
return
data
def
build_transform
(
cfg
):
pass
def
build_transforms
(
cfg
):
transforms
=
[]
...
...
ppgan/datasets/transforms/transforms.py
浏览文件 @
4760af1c
import
sys
import
types
import
random
import
numbers
import
warnings
import
traceback
import
collections
import
numpy
as
np
from
paddle.utils
import
try_import
import
paddle.vision.transforms.functional
as
F
import
paddle.vision.transforms.transforms
as
T
from
.builder
import
TRANSFORMS
...
...
@@ -31,7 +27,6 @@ class Transform():
"""
if
args
:
for
k
,
v
in
args
.
items
():
# print(k, v)
if
k
!=
"self"
and
not
k
.
startswith
(
"_"
):
setattr
(
self
,
k
,
v
)
...
...
@@ -39,7 +34,6 @@ class Transform():
raise
NotImplementedError
def
__call__
(
self
,
inputs
):
# print('debug:', type(inputs), type(inputs[0]))
if
isinstance
(
inputs
,
tuple
):
inputs
=
list
(
inputs
)
if
self
.
keys
is
not
None
:
...
...
@@ -177,10 +171,6 @@ class RandomHorizontalFlip(Transform):
return
img
# import paddle
# paddle.vision.transforms.RandomHorizontalFlip
@
TRANSFORMS
.
register
()
class
PairedRandomHorizontalFlip
(
RandomHorizontalFlip
):
def
__init__
(
self
,
prob
=
0.5
,
keys
=
None
):
...
...
@@ -271,11 +261,6 @@ class Permute(Transform):
return
img
# import paddle
# paddle.vision.transforms.Normalize
# TRANSFORMS.register(T.Normalize)
class
Crop
():
def
__init__
(
self
,
pos
,
size
):
self
.
pos
=
pos
...
...
ppgan/datasets/unpaired_dataset.py
浏览文件 @
4760af1c
...
...
@@ -35,8 +35,7 @@ class UnpairedDataset(BaseDataset):
btoA
=
self
.
cfg
.
direction
==
'BtoA'
input_nc
=
self
.
cfg
.
output_nc
if
btoA
else
self
.
cfg
.
input_nc
# get the number of channels of input image
output_nc
=
self
.
cfg
.
input_nc
if
btoA
else
self
.
cfg
.
output_nc
# get the number of channels of output image
# self.transform_A = get_transform(self.cfg.transform, grayscale=(input_nc == 1))
# self.transform_B = get_transform(self.cfg.transform, grayscale=(output_nc == 1))
self
.
transform_A
=
build_transforms
(
self
.
cfg
.
transforms
)
self
.
transform_B
=
build_transforms
(
self
.
cfg
.
transforms
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录