Skip to content

Commit 5d85c22

Browse files
authored
Merge pull request #12923 from velconia/015_for_flowers_local
Fix flowers dataset download problem
2 parents 198ee1a + 40f23b3 commit 5d85c22

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

python/paddle/dataset/common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import os
2020
import errno
2121
import shutil
22+
import six
2223
import sys
2324
import importlib
2425
import paddle.dataset
@@ -94,6 +95,8 @@ def download(url, module_name, md5sum, save_name=None):
9495
dl = 0
9596
total_length = int(total_length)
9697
for data in r.iter_content(chunk_size=4096):
98+
if six.PY2:
99+
data = six.b(data)
97100
dl += len(data)
98101
f.write(data)
99102
done = int(50 * dl / total_length)

python/paddle/dataset/flowers.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import functools
3636
from .common import download
3737
import tarfile
38+
import six
3839
import scipy.io as scio
3940
from paddle.dataset.image import *
4041
from paddle.reader import *
@@ -45,10 +46,10 @@
4546
from six.moves import zip
4647
__all__ = ['train', 'test', 'valid']
4748

48-
DATA_URL = 'http://www.robots.ox.ac.uk/~vgg/data/flowers/102/102flowers.tgz'
49-
LABEL_URL = 'http://www.robots.ox.ac.uk/~vgg/data/flowers/102/imagelabels.mat'
50-
SETID_URL = 'http://www.robots.ox.ac.uk/~vgg/data/flowers/102/setid.mat'
51-
DATA_MD5 = '33bfc11892f1e405ca193ae9a9f2a118'
49+
DATA_URL = 'http://paddlemodels.cdn.bcebos.com/flowers/102flowers.tgz'
50+
LABEL_URL = 'http://paddlemodels.cdn.bcebos.com/flowers/imagelabels.mat'
51+
SETID_URL = 'http://paddlemodels.cdn.bcebos.com/flowers/setid.mat'
52+
DATA_MD5 = '52808999861908f626f3c1f4e79d11fa'
5253
LABEL_MD5 = 'e0620be6f572b9609742df49c70aed4d'
5354
SETID_MD5 = 'a5357ecc9cb78c4bef273ce3793fc85c'
5455
# In official 'readme', tstid is the flag of test data
@@ -120,7 +121,10 @@ def reader():
120121
file = file.strip()
121122
batch = None
122123
with open(file, 'rb') as f:
123-
batch = pickle.load(f)
124+
if six.PY2:
125+
batch = pickle.load(f)
126+
else:
127+
batch = pickle.load(f, encoding='bytes')
124128
data = batch['data']
125129
labels = batch['label']
126130
for sample, label in zip(data, batch['label']):

0 commit comments

Comments
 (0)