-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo_testImageLoader.py
executable file
·108 lines (53 loc) · 3.05 KB
/
demo_testImageLoader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
from ImageLoader.imageLoader import imageLoader
#from imageLoader import imageLoader
import scipy
#Test generator that starts over
il_test = imageLoader()
il_test.inputsFromFilePath(filepath='/media/mads/Data/TrainTestValDataset/GeneratedDatasetImages299x299_2018-01-11_SIMPLIFIED/Test')
ix=0
batchsize=10
for data, labels in il_test.iterate_minibatches(batchsize=batchsize, datastyle='image', shuffle=True, resize=True, labelstyle = 'label', startOverAfterFinished=True):
ix+=1
print(batchsize*ix,il_test.nSamples)
#Export list of labels and load them from other instance
il_train = imageLoader()
il_train.inputsFromFilePath(filepath='/media/mads/Data/TrainTestValDataset/GeneratedDatasetImages299x299_2018-01-11_SIMPLIFIED/Train')
il_train.exportDict(labelpath='labels.txt')
il_test = imageLoader()
il_test.inputsFromFilePath(filepath='/media/mads/Data/TrainTestValDataset/GeneratedDatasetImages299x299_2018-01-11_SIMPLIFIED/Test',labelspath='labels.txt')
img,lbl = il_test.getImagesAndLabels(returnstyle='numerical', shuffle=True)
for i in range(10):
scipy.misc.imshow(img[i])
print(lbl[i])
pass
#########################
#Load images for semantic segmentation
il_test = imageLoader()
il_test.inputsFromFilePath(filepath='./SamplessemanticSegmentaiontrain/images', targetpath='./SamplessemanticSegmentaiontrain/targets')
for data, labels in il_test.iterate_minibatches(batchsize=3, datastyle='image', shuffle=True, labelstyle = 'path', resize=False):
pass
#########################
#Load images for semantic segmentation, but return only the paths
il_test = imageLoader()
il_test.inputsFromFilePath(filepath='./SamplessemanticSegmentaiontrain/images', targetpath='./SamplessemanticSegmentaiontrain/targets')
for data, labels in il_test.iterate_minibatches(batchsize=3, datastyle='path', shuffle=True, labelstyle = 'path'):
pass
##########################
#Load images and use their foldernames as labels
il_test = imageLoader()
il_test.inputsFromFilePath(filepath='/mnt/AU_BrugerDrev/Database/TrainTestValDataset/GeneratedDatasetImages256x256_2016-12-16_SIMPLIFIED/Test')
for data, labels in il_test.iterate_minibatches(batchsize=13, datastyle='image', shuffle=True, labelstyle = 'label'):
pass
##########################
il_test = imageLoader()
il_test.inputsFromFilePath(filepath='/mnt/AU_BrugerDrev/Database/TrainTestValDataset/GeneratedDatasetImages256x256_2016-12-16_SIMPLIFIED/Test')
# Get all images
data, labels = il_test.getImagesAndLabels(returnstyle='numerical', zeromean=False, normalize=False, resize=True, preprocessor=None)
#########################
trainpath = '/home/mads/AU_BrugerDrev/Database/TrainTestValDataset/GeneratedDatasetImages256x256_2016-12-16_SIMPLIFIED/Train'
testpath = '/home/mads/AU_BrugerDrev/Database/TrainTestValDataset/GeneratedDatasetImages256x256_2016-12-16_SIMPLIFIED/Test'
# Read in data
#imagesize=256
#il_train, il_test = imageLoader.setupTrainValAndTest(trainpath=trainpath, testpath=testpath, valpath=None, imagesize=(imagesize, imagesize, 3))
#Export csv
#il_test.exportCSV('./test.csv')