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 = [ diff --git a/torchvision/datasets/utils.py b/torchvision/datasets/utils.py index 346149ec73d..466be647252 100644 --- a/torchvision/datasets/utils.py +++ b/torchvision/datasets/utils.py @@ -36,5 +36,12 @@ 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:') + print('Failed download. Trying https -> http instead.' + ' Downloading ' + url + ' to ' + fpath) + urllib.request.urlretrieve(url, fpath)