Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
b46e467a
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b46e467a
编写于
3月 28, 2019
作者:
L
lidanqing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add wget and unzip part and change data_dir
test=develop
上级
894aa9b2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
49 addition
and
5 deletion
+49
-5
paddle/fluid/inference/tests/api/full_ILSVRC2012_val_preprocess.py
...uid/inference/tests/api/full_ILSVRC2012_val_preprocess.py
+49
-5
未找到文件。
paddle/fluid/inference/tests/api/full_ILSVRC2012_val_preprocess.py
浏览文件 @
b46e467a
...
...
@@ -21,6 +21,7 @@ import functools
import
contextlib
from
PIL
import
Image
,
ImageEnhance
import
math
from
paddle.dataset.common
import
download
random
.
seed
(
0
)
np
.
random
.
seed
(
0
)
...
...
@@ -30,8 +31,6 @@ DATA_DIM = 224
SIZE_FLOAT32
=
4
SIZE_INT64
=
8
DATA_DIR
=
'./data/ILSVRC2012/data.bin'
img_mean
=
np
.
array
([
0.485
,
0.456
,
0.406
]).
reshape
((
3
,
1
,
1
))
img_std
=
np
.
array
([
0.229
,
0.224
,
0.225
]).
reshape
((
3
,
1
,
1
))
...
...
@@ -71,15 +70,60 @@ def process_image(img_path, mode, color_jitter, rotate):
return
img
def
download_unzip
():
tmp_folder
=
'int8/download'
cache_folder
=
os
.
path
.
expanduser
(
'~/.cache/'
+
tmp_folder
)
data_urls
=
[]
data_md5s
=
[]
data_urls
.
append
(
'https://paddle-inference-dist.bj.bcebos.com/int8/ILSVRC2012_img_val.tar.gz.partaa'
)
data_md5s
.
append
(
'60f6525b0e1d127f345641d75d41f0a8'
)
data_urls
.
append
(
'https://paddle-inference-dist.bj.bcebos.com/int8/ILSVRC2012_img_val.tar.gz.partab'
)
data_md5s
.
append
(
'1e9f15f64e015e58d6f9ec3210ed18b5'
)
file_names
=
[]
for
i
in
range
(
0
,
len
(
data_urls
)):
download
(
data_urls
[
i
],
tmp_folder
,
data_md5s
[
i
])
file_names
.
append
(
data_urls
[
i
].
split
(
'/'
)[
-
1
])
zip_path
=
os
.
path
.
join
(
cache_folder
,
'full_imagenet_val.tar.gz'
)
if
not
os
.
path
.
exists
(
zip_path
):
cat_command
=
'cat'
for
file_name
in
file_names
:
cat_command
+=
' '
+
os
.
path
.
join
(
cache_folder
,
file_name
)
cat_command
+=
' > '
+
zip_path
os
.
system
(
cat_command
)
if
not
os
.
path
.
exists
(
cache_folder
):
cmd
=
'mkdir {0} && tar xf {1} -C {0}'
.
format
(
cache_folder
,
zip_path
)
cmd
=
'rm -rf {3} && ln -s {1} {0}'
.
format
(
"data"
,
cache_folder
,
zip_path
)
os
.
system
(
cmd
)
data_dir
=
os
.
path
.
expanduser
(
cache_folder
+
'data'
)
return
data_dir
def
reader
():
data_dir
=
DATA_DIR
data_dir
=
download_unzip
()
file_list
=
os
.
path
.
join
(
data_dir
,
'val_list.txt'
)
bin_file
=
os
.
path
.
join
(
data_dir
,
'data
.bin'
)
output_file
=
os
.
path
.
join
(
data_dir
,
'int8_full_val
.bin'
)
with
open
(
file_list
)
as
flist
:
lines
=
[
line
.
strip
()
for
line
in
flist
]
num_images
=
len
(
lines
)
with
open
(
bin_file
,
"w+b"
)
as
of
:
with
open
(
output_file
,
"w+b"
)
as
of
:
#save num_images(int64_t) to file
of
.
seek
(
0
)
num
=
np
.
array
(
int
(
num_images
)).
astype
(
'int64'
)
of
.
write
(
num
.
tobytes
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录