Created
October 22, 2019 04:42
-
-
Save bkj/11b4bfacc1898b69dfaa8f32281536c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
prep-CUB200.py | |
""" | |
import os | |
import shutil | |
import pandas as pd | |
from tqdm import tqdm | |
images = pd.read_csv('CUB_200_2011/images.txt', sep=' ', header=None) | |
train_test_split = pd.read_csv('CUB_200_2011/train_test_split.txt', sep=' ', header=None) | |
train_images = images[train_test_split[1] == 1] | |
test_images = images[train_test_split[1] == 0] | |
train_images = list(train_images[1]) | |
test_images = list(test_images[1]) | |
for t in tqdm(train_images): | |
src = os.path.join('CUB_200_2011/images/', t) | |
dst = os.path.join('CUB_200_2011/prepped/train', t) | |
_ = os.makedirs(os.path.dirname(dst), exist_ok=True) | |
_ = shutil.copy(src, dst) | |
for t in tqdm(test_images): | |
src = os.path.join('CUB_200_2011/images/', t) | |
dst = os.path.join('CUB_200_2011/prepped/test', t) | |
_ = os.makedirs(os.path.dirname(dst), exist_ok=True) | |
_ = shutil.copy(src, dst) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment