first commit

This commit is contained in:
CownowAn
2024-03-15 14:38:51 +00:00
commit bc2ed1304f
321 changed files with 44802 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
"""
@author: Hayeon Lee
2020/02/19
Script for downloading, and reorganizing aircraft
for few shot classification
Run this file as follows:
python get_data.py
"""
import pickle
import os
import numpy as np
from tqdm import tqdm
import requests
import tarfile
from PIL import Image
import glob
import shutil
import pickle
import collections
import sys
sys.path.append(os.path.join(os.getcwd(), 'main_exp'))
from all_path import RAW_DATA_PATH
def download_file(url, filename):
"""
Helper method handling downloading large files from `url`
to `filename`. Returns a pointer to `filename`.
"""
chunkSize = 1024
r = requests.get(url, stream=True)
with open(filename, 'wb') as f:
pbar = tqdm( unit="B", total=int( r.headers['Content-Length'] ) )
for chunk in r.iter_content(chunk_size=chunkSize):
if chunk: # filter out keep-alive new chunks
pbar.update (len(chunk))
f.write(chunk)
return filename
dir_path = RAW_DATA_PATH
if not os.path.exists(dir_path):
os.makedirs(dir_path)
file_name = os.path.join(dir_path, 'fgvc-aircraft-2013b.tar.gz')
if not os.path.exists(file_name):
print(f"Downloading {file_name}\n")
download_file(
'http://www.robots.ox.ac.uk/~vgg/data/fgvc-aircraft/archives/fgvc-aircraft-2013b.tar.gz',
file_name)
print("\nDownloading done.\n")
else:
print("fgvc-aircraft-2013b.tar.gz has already been downloaded. Did not download twice.\n")
untar_file_name = os.path.join(dir_path, 'aircraft')
if not os.path.exists(untar_file_name):
tarname = file_name
print("Untarring: {}".format(tarname))
tar = tarfile.open(tarname)
tar.extractall(untar_file_name)
tar.close()
else:
print(f"{untar_file_name} folder already exists. Did not untarring twice\n")
os.remove(file_name)

View File

@@ -0,0 +1,50 @@
###########################################################################################
# Copyright (c) Hayeon Lee, Eunyoung Hyung [GitHub MetaD2A], 2021
# Rapid Neural Architecture Search by Learning to Generate Graphs from Datasets, ICLR 2021
###########################################################################################
import os
from tqdm import tqdm
import requests
import zipfile
import sys
sys.path.append(os.path.join(os.getcwd(), 'main_exp'))
from all_path import RAW_DATA_PATH
def download_file(url, filename):
"""
Helper method handling downloading large files from `url`
to `filename`. Returns a pointer to `filename`.
"""
chunkSize = 1024
r = requests.get(url, stream=True)
with open(filename, 'wb') as f:
pbar = tqdm(unit="B", total=int(r.headers['Content-Length']))
for chunk in r.iter_content(chunk_size=chunkSize):
if chunk: # filter out keep-alive new chunks
pbar.update(len(chunk))
f.write(chunk)
return filename
dir_path = os.path.join(RAW_DATA_PATH, 'pets')
if not os.path.exists(dir_path):
os.makedirs(dir_path)
full_name = os.path.join(dir_path, 'test15.pth')
if not os.path.exists(full_name):
print(f"Downloading {full_name}\n")
download_file(
'https://www.dropbox.com/s/kzmrwyyk5iaugv0/test15.pth?dl=1', full_name)
print("Downloading done.\n")
else:
print(f"{full_name} has already been downloaded. Did not download twice.\n")
full_name = os.path.join(dir_path, 'train85.pth')
if not os.path.exists(full_name):
print(f"Downloading {full_name}\n")
download_file(
'https://www.dropbox.com/s/w7mikpztkamnw9s/train85.pth?dl=1', full_name)
print("Downloading done.\n")
else:
print(f"{full_name} has already been downloaded. Did not download twice.\n")

View File

@@ -0,0 +1,46 @@
###########################################################################################
# Copyright (c) Hayeon Lee, Eunyoung Hyung [GitHub MetaD2A], 2021
# Rapid Neural Architecture Search by Learning to Generate Graphs from Datasets, ICLR 2021
###########################################################################################
import os
from tqdm import tqdm
import requests
from all_path import PROCESSED_DATA_PATH
dir_path = PROCESSED_DATA_PATH
if not os.path.exists(dir_path):
os.makedirs(dir_path)
def download_file(url, filename):
"""
Helper method handling downloading large files from `url`
to `filename`. Returns a pointer to `filename`.
"""
chunkSize = 1024
r = requests.get(url, stream=True)
with open(filename, 'wb') as f:
pbar = tqdm( unit="B", total=int( r.headers['Content-Length'] ) )
for chunk in r.iter_content(chunk_size=chunkSize):
if chunk: # filter out keep-alive new chunks
pbar.update (len(chunk))
f.write(chunk)
return filename
def get_preprocessed_data(file_name, url):
print(f"Downloading {file_name} datasets\n")
full_name = os.path.join(dir_path, file_name)
download_file(url, full_name)
print("Downloading done.\n")
for file_name, url in [
('aircraftbylabel.pt', 'https://www.dropbox.com/s/nn6mlrk1jijg108/aircraft100bylabel.pt?dl=1'),
('cifar100bylabel.pt', 'https://www.dropbox.com/s/nn6mlrk1jijg108/aircraft100bylabel.pt?dl=1'),
('cifar10bylabel.pt', 'https://www.dropbox.com/s/wt1pcwi991xyhwr/cifar10bylabel.pt?dl=1'),
('imgnet32bylabel.pt', 'https://www.dropbox.com/s/7r3hpugql8qgi9d/imgnet32bylabel.pt?dl=1'),
('petsbylabel.pt', 'https://www.dropbox.com/s/mxh6qz3grhy7wcn/petsbylabel.pt?dl=1'),
]:
get_preprocessed_data(file_name, url)

View File

@@ -0,0 +1,44 @@
###########################################################################################
# Copyright (c) Hayeon Lee, Eunyoung Hyung [GitHub MetaD2A], 2021
# Rapid Neural Architecture Search by Learning to Generate Graphs from Datasets, ICLR 2021
###########################################################################################
import os
from tqdm import tqdm
import requests
DATA_PATH = "./data/ofa/data_score_model"
dir_path = DATA_PATH
if not os.path.exists(dir_path):
os.makedirs(dir_path)
def download_file(url, filename):
"""
Helper method handling downloading large files from `url`
to `filename`. Returns a pointer to `filename`.
"""
chunkSize = 1024
r = requests.get(url, stream=True)
with open(filename, 'wb') as f:
pbar = tqdm( unit="B", total=int( r.headers['Content-Length'] ) )
for chunk in r.iter_content(chunk_size=chunkSize):
if chunk: # filter out keep-alive new chunks
pbar.update (len(chunk))
f.write(chunk)
return filename
def get_preprocessed_data(file_name, url):
print(f"Downloading {file_name} datasets\n")
full_name = os.path.join(dir_path, file_name)
download_file(url, full_name)
print("Downloading done.\n")
for file_name, url in [
('ofa_database_500000.pt', 'https://www.dropbox.com/scl/fi/0asz5qnvakf6ggucuynkk/ofa_database_500000.pt?rlkey=lqa1y4d6mikgzznevtanl2ybx&dl=1'),
('ridx-500000.pt', 'https://www.dropbox.com/scl/fi/ambrm9n5efdkyydmsli0h/ridx-500000.pt?rlkey=b6iliyuiaxya4ropms8chsa7c&dl=1'),
]:
get_preprocessed_data(file_name, url)