Created
August 8, 2018 14:20
-
-
Save rcgalbo/103a1fb3e5ecac7d47d99c6e13e7860a to your computer and use it in GitHub Desktop.
move images into sub directories for keras ImageDataGenerator
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 | |
with open('../data/labels.csv','r') as labels: | |
lines = [line.split(',') for line in labels.readlines()][1:] | |
for line in lines: | |
image = line[0] | |
label = line[1].split('/')[-1].replace('\n','') | |
if not os.path.exists('../data/train/'+label): | |
os.mkdir('../data/train/'+label) | |
os.rename('../data/train/'+image+'.jpg', '../data/train/'+label+'/'+image+'.jpg') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment