Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
hapi
提交
9764c13c
H
hapi
项目概览
PaddlePaddle
/
hapi
通知
11
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hapi
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9764c13c
编写于
3月 31, 2020
作者:
L
LielinJiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove unused code
上级
c0894c2e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
6 addition
and
24 deletion
+6
-24
image_classification/imagenet_dataset.py
image_classification/imagenet_dataset.py
+2
-21
image_classification/main.py
image_classification/main.py
+4
-3
未找到文件。
image_classification/imagenet_dataset.py
浏览文件 @
9764c13c
...
...
@@ -3,7 +3,6 @@ import cv2
import
math
import
random
import
numpy
as
np
from
paddle.fluid.io
import
Dataset
from
datasets.folder
import
DatasetFolder
...
...
@@ -65,24 +64,6 @@ def compose(functions):
return
process
def
image_folder
(
path
):
valid_ext
=
(
'.jpg'
,
'.jpeg'
,
'.png'
,
'.ppm'
,
'.bmp'
,
'.webp'
)
classes
=
[
d
for
d
in
os
.
listdir
(
path
)
if
os
.
path
.
isdir
(
os
.
path
.
join
(
path
,
d
))
]
classes
.
sort
()
class_map
=
{
cls
:
idx
for
idx
,
cls
in
enumerate
(
classes
)}
samples
=
[]
for
dir
in
sorted
(
class_map
.
keys
()):
d
=
os
.
path
.
join
(
path
,
dir
)
for
root
,
_
,
fnames
in
sorted
(
os
.
walk
(
d
)):
for
fname
in
sorted
(
fnames
):
p
=
os
.
path
.
join
(
root
,
fname
)
if
os
.
path
.
splitext
(
p
)[
1
].
lower
()
in
valid_ext
:
samples
.
append
((
p
,
[
class_map
[
dir
]]))
return
samples
class
ImageNetDataset
(
DatasetFolder
):
def
__init__
(
self
,
path
,
mode
=
'train'
):
super
(
ImageNetDataset
,
self
).
__init__
(
path
)
...
...
@@ -96,8 +77,8 @@ class ImageNetDataset(DatasetFolder):
[
cv2
.
imread
,
center_crop_resize
,
normalize_permute
])
def
__getitem__
(
self
,
idx
):
return
self
.
transform
(
self
.
samples
[
idx
]
)
img
,
label
=
self
.
samples
[
idx
]
return
self
.
transform
(
(
img
,
[
label
])
)
def
__len__
(
self
):
return
len
(
self
.
samples
)
image_classification/main.py
浏览文件 @
9764c13c
...
...
@@ -40,7 +40,7 @@ def make_optimizer(step_per_epoch, parameter_list=None):
momentum
=
0.9
weight_decay
=
1e-4
boundaries
=
[
step_per_epoch
*
e
for
e
in
[
30
,
60
,
9
0
]]
boundaries
=
[
step_per_epoch
*
e
for
e
in
[
30
,
60
,
8
0
]]
values
=
[
base_lr
*
(
0.1
**
i
)
for
i
in
range
(
len
(
boundaries
)
+
1
)]
learning_rate
=
fluid
.
layers
.
piecewise_decay
(
boundaries
=
boundaries
,
values
=
values
)
...
...
@@ -61,7 +61,8 @@ def main():
device
=
set_device
(
FLAGS
.
device
)
fluid
.
enable_dygraph
(
device
)
if
FLAGS
.
dynamic
else
None
model
=
models
.
__dict__
[
FLAGS
.
arch
](
pretrained
=
FLAGS
.
eval_only
)
model
=
models
.
__dict__
[
FLAGS
.
arch
](
pretrained
=
FLAGS
.
eval_only
and
not
FLAGS
.
resume
)
if
FLAGS
.
resume
is
not
None
:
model
.
load
(
FLAGS
.
resume
)
...
...
@@ -115,7 +116,7 @@ if __name__ == '__main__':
parser
.
add_argument
(
"-d"
,
"--dynamic"
,
action
=
'store_true'
,
help
=
"enable dygraph mode"
)
parser
.
add_argument
(
"-e"
,
"--epoch"
,
default
=
12
0
,
type
=
int
,
help
=
"number of epoch"
)
"-e"
,
"--epoch"
,
default
=
9
0
,
type
=
int
,
help
=
"number of epoch"
)
parser
.
add_argument
(
'--lr'
,
'--learning-rate'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录