import os
from random import randrange
directory = 'C:\\GitHub\\TensorFlow\\workspace\\traininig_demo\\images'
traindir = 'C:\\GitHub\\TensorFlow\\workspace\\traininig_demo\\images\\train'
testdir = 'C:\\GitHub\\TensorFlow\\workspace\\traininig_demo\\images\\test'
for filename in os.listdir(directory):
if filename.endswith(".xml"):
print(os.path.join(directory, filename))
if os.path.isfile(os.path.join(directory, filename[0:-4]+'.jpg')):
x = randrange(100)
if x <= 75:
os.replace(os.path.join(directory, filename), os.path.join(traindir, filename))
os.replace(os.path.join(directory, filename[0:-4]+'.jpg'), os.path.join(traindir, filename[0:-4]+'.jpg'))
else:
os.replace(os.path.join(directory, filename), os.path.join(testdir, filename))
os.replace(os.path.join(directory, filename[0:-4]+'.jpg'), os.path.join(testdir, filename[0:-4]+'.jpg'))
else:
continue
Till Next Time
Geen opmerkingen:
Een reactie posten