From 2623031fe4a5f6ff8c72caf7913499ef40721c27 Mon Sep 17 00:00:00 2001 From: Tzu-Wei Huang Date: Tue, 31 Oct 2017 17:01:10 +0800 Subject: [PATCH 1/3] Fix dataset url There is "HTTP Error 500" for http. change url to https fixes this. --- torchvision/datasets/cifar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/torchvision/datasets/cifar.py b/torchvision/datasets/cifar.py index c6139ee4ef8..67f15fbdc6d 100644 --- a/torchvision/datasets/cifar.py +++ b/torchvision/datasets/cifar.py @@ -32,7 +32,7 @@ class CIFAR10(data.Dataset): """ base_folder = 'cifar-10-batches-py' - url = "http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz" + url = "https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz" filename = "cifar-10-python.tar.gz" tgz_md5 = 'c58f30108f718f92721af3b95e74349a' train_list = [ @@ -162,7 +162,7 @@ def download(self): class CIFAR100(CIFAR10): base_folder = 'cifar-100-python' - url = "http://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz" + url = "https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz" filename = "cifar-100-python.tar.gz" tgz_md5 = 'eb9058c3a382ffc7106e4002c42a8d85' train_list = [ From 30a0c05d05574fc1ca5cb57e30602e1d3159178b Mon Sep 17 00:00:00 2001 From: Tzu-Wei Huang Date: Tue, 31 Oct 2017 21:07:05 +0800 Subject: [PATCH 2/3] try http or https if one of them failed --- torchvision/datasets/utils.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/torchvision/datasets/utils.py b/torchvision/datasets/utils.py index 346149ec73d..f954980eb5a 100644 --- a/torchvision/datasets/utils.py +++ b/torchvision/datasets/utils.py @@ -36,5 +36,13 @@ def download_url(url, root, filename, md5): if os.path.isfile(fpath) and check_integrity(fpath, md5): print('Using downloaded and verified file: ' + fpath) else: - print('Downloading ' + url + ' to ' + fpath) - urllib.request.urlretrieve(url, fpath) + try: + print('Downloading ' + url + ' to ' + fpath) + urllib.request.urlretrieve(url, fpath) + except: + if url[:5] == 'https': + url = url.replace('https:', 'http:') + else: + url = url.replace('http:', 'https:') + print('Downloading ' + url + ' to ' + fpath) + urllib.request.urlretrieve(url, fpath) From c5c6ac189eeef837e2a625ecfcf31fa1b9c55740 Mon Sep 17 00:00:00 2001 From: Soumith Chintala Date: Tue, 31 Oct 2017 09:43:12 -0400 Subject: [PATCH 3/3] Update utils.py --- torchvision/datasets/utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/torchvision/datasets/utils.py b/torchvision/datasets/utils.py index f954980eb5a..466be647252 100644 --- a/torchvision/datasets/utils.py +++ b/torchvision/datasets/utils.py @@ -42,7 +42,6 @@ def download_url(url, root, filename, md5): except: if url[:5] == 'https': url = url.replace('https:', 'http:') - else: - url = url.replace('http:', 'https:') - print('Downloading ' + url + ' to ' + fpath) - urllib.request.urlretrieve(url, fpath) + print('Failed download. Trying https -> http instead.' + ' Downloading ' + url + ' to ' + fpath) + urllib.request.urlretrieve(url, fpath)