This python class is used for loading data for machine-learning projects. Main points:
- Contains generators, which are useful for batch-processing
- Able to shufftle data for each epoch
- Can learn labels of images from foldernames, csv-files, or from a image/label file pair like in VOC-dataset
- Can return labels as numerical labels (0,1,2,...), as text-labels (dog, cat, house,...), as one-hot decoded (0,0,1,0,0,0,...), as file paths (data/train/1.txt), and as decoded images.
#Create object for holding test set
il_test = imageLoader()
#Set the input
il_test.inputsFromFilePath(filepath='data/Test')
# Iterate over data and labels with a batch size of 13, return images an array of decoded images, return labels as
for data, labels in il_test.iterate_minibatches(batchsize=13, datastyle='image', shuffle=True, labelstyle = 'label'):
pass
#Create object for holding test set
il_test = imageLoader()
#Set the input
il_test.inputsFromFilePath(filepath='./data/images/test', targetpath='./data/targets/test')
for data, labels in il_test.iterate_minibatches(batchsize=3, datastyle='path', shuffle=True, labelstyle = 'path'):
pass
#Create object for holding test set
il_test = imageLoader()
#Set the input
il_test.inputsFromFilePath(filepath='./data/images/test', targetpath='./data/targets/test')
for data, labels in il_test.iterate_minibatches(batchsize=3, datastyle='image', shuffle=True, labelstyle = 'image'):
pass
trainpath = './data/images/train'
testpath = './data/images/test'
imagesize=256
il_train, il_test = imageLoader.setupTrainValAndTest(trainpath=trainpath, testpath=testpath, valpath=None, imagesize=(imagesize, imagesize, 3))
il_test.exportCSV('./test.csv')
il_test.inputs
il_test.targets
il_test.targetsOneHot
il_test.labelsDict