Last active
January 18, 2020 07:27
-
-
Save ayooshkathuria/ef84d955e301fe9f1e4828f9e4c8ecd4 to your computer and use it in GitHub Desktop.
Partition CamVid Data for GauGAN
This file contains 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
import os | |
from shutil import copy | |
import random | |
from tqdm import tqdm | |
partition_percentage = 90 | |
annotations_dir = 'GauGAN_Annotations' | |
annotations_files = os.listdir(annotations_dir) | |
annotations_files = [os.path.join(os.path.realpath("."), annotations_dir, x) for x in annotations_files] | |
train_labels = random.sample(annotations_files, int(partition_percentage / 100 * len(annotations_files))) | |
test_labels = [x for x in annotations_files if x not in train_labels] | |
train_images = [x.replace(annotations_dir, '701_StillsRaw_full').replace("_L", "") for x in train_labels] | |
test_images = [x.replace(annotations_dir, '701_StillsRaw_full').replace("_L", "") for x in test_labels] | |
for file in tqdm(train_labels): | |
src = file | |
dst = file.replace(annotations_dir, 'train_label').replace("_L", "") | |
copy(src, dst) | |
for file in tqdm(test_labels): | |
src = file | |
dst = file.replace(annotations_dir, 'test_label').replace("_L", "") | |
copy(src, dst) | |
for file in tqdm(train_images): | |
src = file | |
dst = file.replace('701_StillsRaw_full', 'train_img') | |
copy(src, dst) | |
for file in tqdm(test_images): | |
src = file | |
dst = file.replace('701_StillsRaw_full', 'test_img') | |
copy(src, dst) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment