Skip to content

Commit f9df932

Browse files
lanpasoumith
authored andcommitted
Fix dataset url (#314)
1 parent 7be960f commit f9df932

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

torchvision/datasets/cifar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CIFAR10(data.Dataset):
3232
3333
"""
3434
base_folder = 'cifar-10-batches-py'
35-
url = "http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz"
35+
url = "https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz"
3636
filename = "cifar-10-python.tar.gz"
3737
tgz_md5 = 'c58f30108f718f92721af3b95e74349a'
3838
train_list = [
@@ -162,7 +162,7 @@ def download(self):
162162

163163
class CIFAR100(CIFAR10):
164164
base_folder = 'cifar-100-python'
165-
url = "http://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz"
165+
url = "https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz"
166166
filename = "cifar-100-python.tar.gz"
167167
tgz_md5 = 'eb9058c3a382ffc7106e4002c42a8d85'
168168
train_list = [

torchvision/datasets/utils.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,12 @@ def download_url(url, root, filename, md5):
3636
if os.path.isfile(fpath) and check_integrity(fpath, md5):
3737
print('Using downloaded and verified file: ' + fpath)
3838
else:
39-
print('Downloading ' + url + ' to ' + fpath)
40-
urllib.request.urlretrieve(url, fpath)
39+
try:
40+
print('Downloading ' + url + ' to ' + fpath)
41+
urllib.request.urlretrieve(url, fpath)
42+
except:
43+
if url[:5] == 'https':
44+
url = url.replace('https:', 'http:')
45+
print('Failed download. Trying https -> http instead.'
46+
' Downloading ' + url + ' to ' + fpath)
47+
urllib.request.urlretrieve(url, fpath)

0 commit comments

Comments
 (0)