Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
e102e5dd
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e102e5dd
编写于
8月 08, 2018
作者:
M
minqiyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix cifar10 decompress problem
上级
3ec6d60c
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
23 addition
and
29 deletion
+23
-29
python/paddle/dataset/cifar.py
python/paddle/dataset/cifar.py
+9
-12
python/paddle/dataset/common.py
python/paddle/dataset/common.py
+2
-8
python/paddle/fluid/compat.py
python/paddle/fluid/compat.py
+2
-2
python/paddle/fluid/tests/book/high-level-api/image_classification/cifar10_small_test_set.py
...-level-api/image_classification/cifar10_small_test_set.py
+10
-7
未找到文件。
python/paddle/dataset/cifar.py
浏览文件 @
e102e5dd
...
...
@@ -32,7 +32,7 @@ import itertools
import
numpy
import
paddle.dataset.common
import
tarfile
from
six.moves
import
zip
import
six
from
six.moves
import
cPickle
as
pickle
__all__
=
[
'train100'
,
'test100'
,
'train10'
,
'test10'
,
'convert'
]
...
...
@@ -46,25 +46,22 @@ CIFAR100_MD5 = 'eb9058c3a382ffc7106e4002c42a8d85'
def
reader_creator
(
filename
,
sub_name
,
cycle
=
False
):
def
read_batch
(
batch
):
data
=
batch
[
'data'
]
labels
=
batch
.
get
(
'labels'
,
batch
.
get
(
'fine_labels'
,
None
))
data
=
batch
[
six
.
b
(
'data'
)
]
labels
=
batch
.
get
(
six
.
b
(
'labels'
),
batch
.
get
(
six
.
b
(
'fine_labels'
)
,
None
))
assert
labels
is
not
None
for
sample
,
label
in
zip
(
data
,
labels
):
for
sample
,
label
in
six
.
moves
.
zip
(
data
,
labels
):
yield
(
sample
/
255.0
).
astype
(
numpy
.
float32
),
int
(
label
)
def
reader
():
with
tarfile
.
open
(
filename
,
mode
=
'r'
)
as
f
:
names
=
(
each_item
.
name
for
each_item
in
f
if
sub_name
in
each_item
.
name
)
names
=
[
each_item
.
name
for
each_item
in
f
if
sub_name
in
each_item
.
name
]
while
True
:
for
name
in
names
:
import
sys
print
(
name
)
sys
.
stdout
.
flush
()
print
(
f
.
extractfile
(
name
))
sys
.
stdout
.
flush
()
if
six
.
PY2
:
batch
=
pickle
.
load
(
f
.
extractfile
(
name
))
else
:
batch
=
pickle
.
load
(
f
.
extractfile
(
name
),
encoding
=
'bytes'
)
for
item
in
read_batch
(
batch
):
yield
item
if
not
cycle
:
...
...
python/paddle/dataset/common.py
浏览文件 @
e102e5dd
...
...
@@ -87,20 +87,14 @@ def download(url, module_name, md5sum, save_name=None):
if
total_length
is
None
:
with
open
(
filename
,
'wb'
)
as
f
:
import
sys
print
(
"write follow block"
)
sys
.
stdout
.
flush
()
shutil
.
copyfileobj
(
cpt
.
to_bytes
(
r
.
raw
),
f
)
shutil
.
copyfileobj
(
r
.
raw
,
f
)
else
:
with
open
(
filename
,
'wb'
)
as
f
:
import
sys
print
(
"write follow length"
)
sys
.
stdout
.
flush
()
dl
=
0
total_length
=
int
(
total_length
)
for
data
in
r
.
iter_content
(
chunk_size
=
4096
):
dl
+=
len
(
data
)
f
.
write
(
cpt
.
to_bytes
(
data
)
)
f
.
write
(
data
)
done
=
int
(
50
*
dl
/
total_length
)
sys
.
stdout
.
write
(
"
\r
[%s%s]"
%
(
'='
*
done
,
' '
*
(
50
-
done
)))
...
...
python/paddle/fluid/compat.py
浏览文件 @
e102e5dd
...
...
@@ -27,7 +27,7 @@ def to_literal_str(obj):
def
_to_literal_str
(
obj
):
if
isinstance
(
obj
,
six
.
binary_type
):
return
obj
.
decode
(
'
latin-1
'
)
return
obj
.
decode
(
'
utf-8
'
)
elif
isinstance
(
obj
,
six
.
text_type
):
return
obj
else
:
...
...
@@ -45,7 +45,7 @@ def to_bytes(obj):
def
_to_bytes
(
obj
):
if
isinstance
(
obj
,
six
.
text_type
):
return
obj
.
encode
(
'
latin-1
'
)
return
obj
.
encode
(
'
utf-8
'
)
elif
isinstance
(
obj
,
six
.
binary_type
):
return
obj
else
:
...
...
python/paddle/fluid/tests/book/high-level-api/image_classification/cifar10_small_test_set.py
浏览文件 @
e102e5dd
...
...
@@ -32,8 +32,8 @@ import itertools
import
numpy
import
paddle.dataset.common
import
tarfile
import
six
from
six.moves
import
cPickle
as
pickle
from
six.moves
import
zip
__all__
=
[
'train10'
]
...
...
@@ -44,20 +44,23 @@ CIFAR10_MD5 = 'c58f30108f718f92721af3b95e74349a'
def
reader_creator
(
filename
,
sub_name
,
batch_size
=
None
):
def
read_batch
(
batch
):
data
=
batch
[
'data'
]
labels
=
batch
.
get
(
'labels'
,
batch
.
get
(
'fine_labels'
,
None
))
data
=
batch
[
six
.
b
(
'data'
)
]
labels
=
batch
.
get
(
six
.
b
(
'labels'
),
batch
.
get
(
six
.
b
(
'fine_labels'
)
,
None
))
assert
labels
is
not
None
for
sample
,
label
in
zip
(
data
,
labels
):
for
sample
,
label
in
six
.
moves
.
zip
(
data
,
labels
):
yield
(
sample
/
255.0
).
astype
(
numpy
.
float32
),
int
(
label
)
def
reader
():
with
tarfile
.
open
(
filename
,
mode
=
'r'
)
as
f
:
names
=
(
each_item
.
name
for
each_item
in
f
if
sub_name
in
each_item
.
name
)
names
=
[
each_item
.
name
for
each_item
in
f
if
sub_name
in
each_item
.
name
]
batch_count
=
0
for
name
in
names
:
if
six
.
PY2
:
batch
=
pickle
.
load
(
f
.
extractfile
(
name
))
else
:
batch
=
pickle
.
load
(
f
.
extractfile
(
name
),
encoding
=
'bytes'
)
for
item
in
read_batch
(
batch
):
if
isinstance
(
batch_size
,
int
)
and
batch_count
>
batch_size
:
break
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录