Skip to content

Commit 030a685

Browse files
committed
first commit
0 parents  commit 030a685

46 files changed

Lines changed: 63975 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# project specific
2+
data/
3+
saves/
4+
logs/
5+
6+
# Byte-compiled / optimized / DLL files
7+
__pycache__/
8+
*.py[cod]
9+
*$py.class
10+
11+
# C extensions
12+
*.so
13+
14+
# Distribution / packaging
15+
.Python
16+
build/
17+
develop-eggs/
18+
dist/
19+
downloads/
20+
eggs/
21+
.eggs/
22+
lib/
23+
lib64/
24+
parts/
25+
sdist/
26+
var/
27+
wheels/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
MANIFEST
32+
33+
# PyInstaller
34+
# Usually these files are written by a python script from a template
35+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36+
*.manifest
37+
*.spec
38+
39+
# Installer logs
40+
pip-log.txt
41+
pip-delete-this-directory.txt
42+
43+
# Unit test / coverage reports
44+
htmlcov/
45+
.tox/
46+
.coverage
47+
.coverage.*
48+
.cache
49+
nosetests.xml
50+
coverage.xml
51+
*.cover
52+
.hypothesis/
53+
.pytest_cache/
54+
55+
# Translations
56+
*.mo
57+
*.pot
58+
59+
# Django stuff:
60+
*.log
61+
local_settings.py
62+
db.sqlite3
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# pyenv
81+
.python-version
82+
83+
# celery beat schedule file
84+
celerybeat-schedule
85+
86+
# SageMath parsed files
87+
*.sage.py
88+
89+
# Environments
90+
.env
91+
.venv
92+
env/
93+
venv/
94+
ENV/
95+
env.bak/
96+
venv.bak/
97+
98+
# Spyder project settings
99+
.spyderproject
100+
.spyproject
101+
102+
# Rope project settings
103+
.ropeproject
104+
105+
# mkdocs documentation
106+
/site
107+
108+
# mypy
109+
.mypy_cache/
110+
111+
*.txt
112+
*.sw[opn]
113+
*.pt
114+
*.hdf5
115+
train_dir/
116+
*tgz
117+
*tar.gz

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Tristan Deleu
4+
Copyright (c) 2018 Risto Vuorio
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

README.md

Lines changed: 188 additions & 0 deletions
Large diffs are not rendered by default.

asset/classification_summary.png

1.42 MB
Loading

asset/model.png

139 KB
Loading

asset/tb.png

383 KB
Loading

download.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import subprocess
2+
import argparse
3+
4+
5+
parser = argparse.ArgumentParser(description='Download datasets for MMAML.')
6+
parser.add_argument('--dataset', metavar='N', type=str, nargs='+',
7+
choices=['aircraft', 'bird', 'cifar', 'miniimagenet'])
8+
9+
10+
def download(dataset):
11+
cmd = ['python', 'get_dataset_script/get_{}.py'.format(dataset)]
12+
print(' '.join(cmd))
13+
subprocess.call(cmd)
14+
return
15+
16+
17+
if __name__ == '__main__':
18+
args = parser.parse_args()
19+
if len(args.dataset) > 0:
20+
for dataset in args.dataset:
21+
download(dataset)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# https://drive.google.com/drive/folders/0B-r7apOz1BHAWXYwT1lGb3J1Yjg
2+
# Download files on Google Drive
3+
import requests
4+
5+
def download_file_from_google_drive(id, destination):
6+
URL = "https://drive.google.com/uc?export=download"
7+
8+
session = requests.Session()
9+
10+
response = session.get(URL, params = { 'id' : id }, stream = True)
11+
token = get_confirm_token(response)
12+
13+
if token:
14+
params = { 'id' : id, 'confirm' : token }
15+
response = session.get(URL, params = params, stream = True)
16+
17+
save_response_content(response, destination)
18+
19+
def get_confirm_token(response):
20+
for key, value in response.cookies.items():
21+
if key.startswith('download_warning'):
22+
return value
23+
24+
return None
25+
26+
def save_response_content(response, destination):
27+
CHUNK_SIZE = 32768
28+
29+
with open(destination, "wb") as f:
30+
for chunk in response.iter_content(CHUNK_SIZE):
31+
if chunk: # filter out keep-alive new chunks
32+
f.write(chunk)
33+
34+
if __name__ == "__main__":
35+
file_id = "1HkgrkAwukzEZA0TpO7010PkAOREb2Nuk"
36+
destination = './mini-imagenet.zip'
37+
download_file_from_google_drive(file_id, destination)

get_dataset_script/get_aircraft.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import subprocess
2+
3+
4+
cmds = []
5+
cmds.append(['wget', 'http://www.robots.ox.ac.uk/~vgg/data/fgvc-aircraft/archives/fgvc-aircraft-2013b.tar.gz'])
6+
cmds.append(['tar', 'xvzf', 'fgvc-aircraft-2013b.tar.gz'])
7+
cmds.append(['python', 'get_dataset_script/proc_aircraft.py'])
8+
cmds.append(['rm', '-rf', 'fgvc-aircraft-2013b.tar.gz', 'fgvc-aircraft-2013b'])
9+
10+
for cmd in cmds:
11+
print(' '.join(cmd))
12+
subprocess.call(cmd)

get_dataset_script/get_bird.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import subprocess
2+
import os
3+
4+
5+
cmds = []
6+
cmds.append(['wget', 'http://www.vision.caltech.edu/visipedia-data/CUB-200-2011/CUB_200_2011.tgz'])
7+
cmds.append(['tar', 'xvzf', 'CUB_200_2011.tgz'])
8+
cmds.append(['python', 'get_dataset_script/proc_bird.py'])
9+
cmds.append(['rm', '-rf', 'CUB_200_2011', 'CUB_200_2011.tgz'])
10+
11+
for cmd in cmds:
12+
print(' '.join(cmd))
13+
subprocess.call(cmd)

0 commit comments

Comments
 (0)