def download_fashion_mnist_and_get_file_paths() -> Dict[str, str]: """ Downloads pytorch_networks from the Zalando Research AWS :return: paths to the different files """ base_url = "http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/" filenames = [["train_images", "train-images-idx3-ubyte.gz"], ["test_images", "t10k-images-idx3-ubyte.gz"], ["train_labels", "train-labels-idx1-ubyte.gz"], ["test_labels", "t10k-labels-idx1-ubyte.gz"]] sub_folder = '/fashion_mnist' local_files = real_download(base_url, filenames, sub_folder) return local_files
def download_mnist_and_get_file_paths() -> Dict[str, str]: """ Downloads pytorch_networks from Yann Lecun's website :return: paths to the different files """ base_url = "http://yann.lecun.com/exdb/mnist/" filenames = [["train_images", "train-images-idx3-ubyte.gz"], ["test_images", "t10k-images-idx3-ubyte.gz"], ["train_labels", "train-labels-idx1-ubyte.gz"], ["test_labels", "t10k-labels-idx1-ubyte.gz"]] sub_folder = '/mnist' local_files = real_download(base_url, filenames, sub_folder) return local_files
def download_ucf101_and_get_file_paths(folder='', split='01'): """ Download ucf101 from University of Central Florida The archive contains the videos of different action classes :return: paths to different files """ base_url = "https://www.crcv.ucf.edu/data/UCF101/" filenames = [('ucf101', 'UCF101.rar'), ('ucf101_split', 'UCF101TrainTestSplits-RecognitionTask.zip')] sub_folder = '/ucf101' local_files = real_download(base_url, filenames, sub_folder, output_dir=folder) files = unrar(local_files['ucf101']) zip = zipfile.ZipFile(local_files['ucf101_split']) path = os.path.dirname(os.path.abspath( local_files['ucf101'])) + '/UCF-101/' train_files = [] with zip.open( 'ucfTrainTestlist/trainlist{}.txt'.format(split)) as file_split: for line in file_split: file = path + bytes.decode(line.split()[0]) if file in files: train_files.append(file) test_files = [] with zip.open( 'ucfTrainTestlist/testlist{}.txt'.format(split)) as file_split: for line in file_split: file = path + bytes.decode(line.strip()) if file in files: test_files.append(file) label_list = {} with zip.open('ucfTrainTestlist/classInd.txt') as labels: for line in labels: line = bytes.decode(line.strip()) label = line.split()[1] idx = int(line.split()[0]) - 1 label_list[label] = idx return train_files, test_files, label_list
def download_cifar10_and_get_file_paths(folder=''): """ Download cifar10 from University of Toronto The archive contains the files data_batch_1, data_batch_2, ..., data_batch_5, as well as test_batch :return: paths to different files """ base_url = "https://www.cs.toronto.edu/~kriz/" filenames = [('cifar10', 'cifar-10-binary.tar.gz')] sub_folder = '/cifar10' local_files = real_download(base_url, filenames, sub_folder, output_dir=folder) files = unzip(local_files['cifar10']) data_files = [file for file in files if '_batch_' in file] test_data = [file for file in files if 'test_batch' in file] return data_files, test_data