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
# Creating dirs train, valid and test and organize data into them | |
os.chdir('D:\SACHIN\Jupyter\Hand Sign Language\Hand_Sign_Language_DL_Project\American-Sign-Language-Digits-Dataset') | |
# If dir doesn't exist then make specified dirs | |
if os.path.isdir('train/0/') is False: | |
os.mkdir('train') | |
os.mkdir('valid') | |
os.mkdir('test') | |
for i in range(0, 10): | |
# Moving 0-9 dirs into train dir | |
shutil.move(f'{i}', 'train') | |
os.mkdir(f'valid/{i}') | |
os.mkdir(f'test/{i}') | |
# Take 90 sample imgs for valid dir | |
valid_samples = random.sample(os.listdir(f'train/{i}'), 90) | |
for j in valid_samples: | |
# Moving the sample imgs from train dir to valid sub-dirs | |
shutil.move(f'train/{i}/{j}', f'valid/{i}') | |
# Take 10 sample imgs for test dir | |
test_samples = random.sample(os.listdir(f'train/{i}'), 10) | |
for k in test_samples: | |
# Moving the sample imgs from train dir to test sub-dirs | |
shutil.move(f'train/{i}/{k}', f'test/{i}') | |
os.chdir('../..') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment