Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
ee2be095
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
282
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
ee2be095
编写于
10月 28, 2020
作者:
H
haoyuying
提交者:
GitHub
10月 28, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add download datast
上级
73e06533
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
8 deletion
+33
-8
demo/colorization/train.py
demo/colorization/train.py
+2
-2
demo/style_transfer/train.py
demo/style_transfer/train.py
+2
-2
paddlehub/datasets/Canvas.py
paddlehub/datasets/Canvas.py
+6
-2
paddlehub/datasets/MiniCOCO.py
paddlehub/datasets/MiniCOCO.py
+6
-2
paddlehub/utils/download.py
paddlehub/utils/download.py
+17
-0
未找到文件。
demo/colorization/train.py
浏览文件 @
ee2be095
...
...
@@ -2,7 +2,7 @@ import paddle
import
paddlehub
as
hub
import
paddlehub.process.transforms
as
T
from
paddlehub.finetune.trainer
import
Trainer
from
paddlehub.datasets.
colorizedataset
import
Colorizedataset
from
paddlehub.datasets.
Canvas
import
Canvas
if
__name__
==
'__main__'
:
...
...
@@ -13,7 +13,7 @@ if __name__ == '__main__':
stay_rgb
=
True
,
is_permute
=
False
)
color_set
=
C
olorizedataset
(
transform
=
transform
,
mode
=
'train'
)
color_set
=
C
anvas
(
transform
=
transform
,
mode
=
'train'
)
optimizer
=
paddle
.
optimizer
.
Adam
(
learning_rate
=
0.0001
,
parameters
=
model
.
parameters
())
trainer
=
Trainer
(
model
,
optimizer
,
checkpoint_dir
=
'img_colorization_ckpt'
)
trainer
.
train
(
color_set
,
epochs
=
101
,
batch_size
=
2
,
eval_dataset
=
color_set
,
log_interval
=
10
,
save_interval
=
10
)
demo/style_transfer/train.py
浏览文件 @
ee2be095
...
...
@@ -2,14 +2,14 @@ import paddle
import
paddlehub
as
hub
import
paddlehub.process.transforms
as
T
from
paddlehub.finetune.trainer
import
Trainer
from
paddlehub.datasets.
styletransfer
import
StyleTransferData
from
paddlehub.datasets.
MiniCOCO
import
MiniCOCO
if
__name__
==
"__main__"
:
model
=
hub
.
Module
(
name
=
'msgnet'
)
transform
=
T
.
Compose
([
T
.
Resize
(
(
256
,
256
),
interp
=
'LINEAR'
),
T
.
CenterCrop
(
crop_size
=
256
)],
T
.
SetType
(
datatype
=
'float32'
))
styledata
=
StyleTransferData
(
transform
)
styledata
=
MiniCOCO
(
transform
)
optimizer
=
paddle
.
optimizer
.
Adam
(
learning_rate
=
0.0001
,
parameters
=
model
.
parameters
())
trainer
=
Trainer
(
model
,
optimizer
,
checkpoint_dir
=
'img_style_transfer_ckpt'
)
trainer
.
train
(
styledata
,
epochs
=
5
,
batch_size
=
16
,
eval_dataset
=
styledata
,
log_interval
=
1
,
save_interval
=
1
)
paddlehub/datasets/
colorizedataset
.py
→
paddlehub/datasets/
Canvas
.py
浏览文件 @
ee2be095
...
...
@@ -21,11 +21,14 @@ import paddle
from
paddlehub.process.functional
import
get_img_file
from
paddlehub.env
import
DATA_HOME
from
typing
import
Callable
from
paddlehub.utils.download
import
download_data
class
Colorizedataset
(
paddle
.
io
.
Dataset
):
@
download_data
(
url
=
'https://paddlehub.bj.bcebos.com/dygraph/datasets/canvas.tar.gz'
)
class
Canvas
(
paddle
.
io
.
Dataset
):
"""
Dataset for colorization.
Dataset for colorization. It contains 1193 and 400 pictures for Monet and Vango paintings style, respectively.
We collected data from https://people.eecs.berkeley.edu/~taesung_park/CycleGAN/datasets/.
Args:
transform(callmethod) : The method of preprocess images.
...
...
@@ -34,6 +37,7 @@ class Colorizedataset(paddle.io.Dataset):
Returns:
DataSet: An iterable object for data iterating
"""
def
__init__
(
self
,
transform
:
Callable
,
mode
:
str
=
'train'
):
self
.
mode
=
mode
self
.
transform
=
transform
...
...
paddlehub/datasets/
styletransfer
.py
→
paddlehub/datasets/
MiniCOCO
.py
浏览文件 @
ee2be095
...
...
@@ -19,11 +19,14 @@ from typing import Callable
import
paddle
from
paddlehub.process.functional
import
get_img_file
from
paddlehub.env
import
DATA_HOME
from
paddlehub.utils.download
import
download_data
class
StyleTransferData
(
paddle
.
io
.
Dataset
):
@
download_data
(
url
=
'https://paddlehub.bj.bcebos.com/dygraph/datasets/minicoco.tar.gz'
)
class
MiniCOCO
(
paddle
.
io
.
Dataset
):
"""
Dataset for Style transfer.
Dataset for Style transfer. The dataset contains 2001 images for training set and 200 images for testing set.
They are derived form COCO2014. Meanwhile, it contains 21 different style pictures in file "21styles".
Args:
transform(callmethod) : The method of preprocess images.
...
...
@@ -32,6 +35,7 @@ class StyleTransferData(paddle.io.Dataset):
Returns:
DataSet: An iterable object for data iterating
"""
def
__init__
(
self
,
transform
:
Callable
,
mode
:
str
=
'train'
):
self
.
mode
=
mode
self
.
transform
=
transform
...
...
paddlehub/utils/download.py
0 → 100644
浏览文件 @
ee2be095
import
os
from
paddlehub.env
import
DATA_HOME
from
paddle.utils.download
import
get_path_from_url
def
download_data
(
url
):
save_name
=
os
.
path
.
basename
(
url
).
split
(
'.'
)[
0
]
output_path
=
os
.
path
.
join
(
DATA_HOME
,
save_name
)
if
not
os
.
path
.
exists
(
output_path
):
get_path_from_url
(
url
,
DATA_HOME
)
def
_wrapper
(
Dataset
):
return
Dataset
return
_wrapper
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录