Skip to content

Instantly share code, notes, and snippets.

@mercutiodesign
Created September 30, 2019 12:43
Show Gist options
  • Save mercutiodesign/267719ae4d7febb40a952fcdfb519ae1 to your computer and use it in GitHub Desktop.
Save mercutiodesign/267719ae4d7febb40a952fcdfb519ae1 to your computer and use it in GitHub Desktop.
import torch
import torchvision
from pathlib import Path
import zipfile
path = Path('./data/tiny-imagenet-200.zip')
extracted_path = path.parent / path.stem
if extracted_path.exists():
print("path already exists")
else:
url = "http://cs231n.stanford.edu/tiny-imagenet-200.zip"
md5 = "90528d7ca1a48142e341f4ef8d21d0de" # set to None if you don't know the correct md5
torchvision.datasets.utils.download_url(url, path.parent, md5=md5)
if md5 is None:
print("md5", torchvision.datasets.utils.calculate_md5(path))
with zipfile.ZipFile(path) as z:
z.extractall(path.parent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment