forked from previtus/ChangeDetectionBaseline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprebake_entire_dataset.py
63 lines (46 loc) · 1.96 KB
/
prebake_entire_dataset.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
# === Initialize sets - Unlabeled, Train and Test
import keras
from ActiveLearning.LargeDatasetHandler_AL import get_balanced_dataset, get_unbalanced_dataset
from timeit import default_timer as timer
from datetime import *
import os
months = ["unk", "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
month = (months[datetime.now().month])
day = str(datetime.now().day)
def main():
import matplotlib.pyplot as plt
import numpy as np
RemainingUnlabeledSet = get_unbalanced_dataset()
"""
PER_BATCH = 2048 # How big files would we like ? test with smaller and if we can move that comfortably to a server ...
for batch in RemainingUnlabeledSet.generator_for_all_images(PER_BATCH,mode='SAVEBATCHFILES', skip_i_batches=40):
print(">>>>>>>>>>>>>>>>>>>>>>>>> processed batch " + batch)
#break
"""
k = 0
PER_BATCH = 2048 # How big files would we like ? test with smaller and if we can move that comfortably to a server ...
for batch in RemainingUnlabeledSet.generator_for_all_images(PER_BATCH, mode='dataonly_LOADBATCHFILES'):
# batch < corresponding_indices, [lefts,rights]
remaining_indices = batch[0]
remaining_data = batch[1] # lefts and rights, no labels!
print("MegaBatch (", RemainingUnlabeledSet.N_of_data,") of size", len(remaining_indices), " = indices from id", remaining_indices[0], "to id", remaining_indices[-1])
L, R = remaining_data
L = np.asarray(L).astype('float32')
R = np.asarray(R).astype('float32')
print("L", L.shape, "R", R.shape)
del L
del R
del remaining_data
del remaining_indices
del batch
#k += 1
#if k > 10:
# break
if __name__ == '__main__':
start = timer()
main()
end = timer()
time = (end - start)
print("This run took " + str(time) + "s (" + str(time / 60.0) + "min)")
import keras
keras.backend.clear_session()