-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwelcome.py
More file actions
304 lines (231 loc) · 8.32 KB
/
Copy pathwelcome.py
File metadata and controls
304 lines (231 loc) · 8.32 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
from kivy.app import App
from kivy.uix.pagelayout import PageLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.boxlayout import BoxLayout
# from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.progressbar import ProgressBar
from kivy.uix.image import Image
from kivy.animation import Animation
from kivy.clock import Clock
from kivy.uix.screenmanager import ScreenManager, Screen, SlideTransition
from threading import Thread,Event
# from multiprocessing import Process, Queue
from time import sleep
import os
# import sys
# sys.path.insert(0, './..')
import pre_works_train as phase1
import create_model as phase2
import pre_works_test as phase3
import test as phase4
import sys
sys.path.insert(0, './helper_modules')
import front_end_helper as hfg
import helper_functions as hf
class splashClass(FloatLayout):
"""docstring for splashClass"""
def callSecondScreen(self, *args):
self.clear_widgets()
self.add_widget( screenClass())
# self.add_widget( firstClass() )
def secondSplash(self, *args):
self.clear_widgets()
label = Label(text="Coloriser", font_size=80, color=[1,1,1,0])
self.add_widget(label)
def hide_label(w):
w.hidden = True
Animation(color=[1,1,1,1], duration=3, t='in_out_cubic').start(label)
Clock.schedule_once(self.callSecondScreen, 4)
def __init__(self, **kwargs):
super(splashClass, self).__init__(**kwargs)
# Splash Screen
wing = Image(source='./splash.png',pos=(800,800))
animation = Animation(x=0, y=0, d=2, t='out_bounce');
animation.start(wing)
Clock.schedule_once(self.secondSplash, 5)
self.add_widget(wing)
return
class firstClass(BoxLayout):
"""docstring for firstClass"""
def __init__(self, **kwargs):
super(firstClass, self).__init__(**kwargs)
def trainClick(self):
print("YUMMY")
class secondClass(Screen):
path = './dataset/train'
def __init__(self, **kwargs):
# self.path = './dataset/train'
super(secondClass, self).__init__(**kwargs)
def pathset(self):
self.path = self.ids.pathInput.text
print("New PATH: ",self.path)
def callBack(self, image_no):
self.ids.statusBar.text = "Preprocessing of "+image_no+" images complete."
self.ids.nextBut.disabled = False
def updateBar(self, x):
self.ids.progressBarIndicator.value = x
self.ids.progressLabel.text = str(x) + '%'
def sublu(self ):
# pid=os.fork()
# if pid:
callBack_to_call = self.callBack
callBack_to_update = self.updateBar
Thread( target = phase1.begin_threaded_execution, args=(callBack_to_call, self.path, callBack_to_update)).start()
def begin_phase_1(self):
# queue = Queue()
# queue.put(0)
self.ids.progressLabel.text = "begin disco"
self.ids.statusBar.text = "Preprocessing . . ."
self.ids.nextBut.disabled = True
self.ids.beginButton.disabled = True
self.sublu()
class thirdClass( Screen ):
"""docstring for thirdClass"""
def __init__(self, **kwargs):
super(thirdClass, self).__init__(**kwargs)
def callBack(self, model_name):
self.ids.statusBox.text = "Model " + model_name +" created"
self.ids.a_model_but.disabled = False
self.ids.b_model_but.disabled = False
self.ids.nextBut.disabled = False
self.ids.backBut.disabled = False
def begin_phase_2a(self):
callBack_to_call = self.callBack
self.ids.a_model_but.disabled = True
self.ids.b_model_but.disabled = True
self.ids.nextBut.disabled = True
self.ids.backBut.disabled = True
Thread( target = phase2.make_a_model, args=((callBack_to_call),)).start()
self.ids.statusBox.text = "Creating a_model"
def begin_phase_2b(self):
callBack_to_call = self.callBack
self.ids.a_model_but.disabled = True
self.ids.b_model_but.disabled = True
self.ids.nextBut.disabled = True
self.ids.backBut.disabled = True
Thread( target = phase2.make_b_model, args=((callBack_to_call),)).start()
self.ids.statusBox.text = "Creating b_model"
class fourthClass(Screen):
path = './dataset/test'
def __init__(self, **kwargs):
super(fourthClass, self).__init__(**kwargs)
def pathset(self):
self.path = self.ids.pathInput.text
print("New PATH: ",self.path)
def callBack(self, image_no):
self.ids.statusBar.text = "Preprocessing of "+image_no+" images complete."
self.ids.nextBut.disabled = False
self.ids.backBut.disabled = False
def updateBar(self, x):
self.ids.progressBarIndicator.value = x
self.ids.progressLabel.text = str(x) + '%'
def lasagu(self ):
# pid=os.fork()
# if pid:
callBack_to_call = self.callBack
callBack_to_update = self.updateBar
Thread( target = phase3.begin_threaded_execution, args=(callBack_to_call, self.path, callBack_to_update)).start()
def begin_phase_3(self):
self.ids.progressLabel.text = "begin disco"
self.ids.statusBar.text = "Preprocessing . . ."
self.ids.nextBut.disabled = True
self.ids.backBut.disabled = True
self.ids.beginButton.disabled = True
self.lasagu()
class fifthClass( Screen ):
"""docstring for thirdClass"""
def __init__(self, **kwargs):
super(fifthClass, self).__init__(**kwargs)
def callBack(self, model_name):
callBack_to_call = self.callBack
self.ids.statusBox.text = "Model a created"
if(model_name=='b'):
self.ids.statusBox.text = "B completed"
Thread( target = phase4.start, args=('ab',(callBack_to_call),)).start()
elif model_name=='ab':
self.ids.statusBox.text = "AB completed"
self.ids.test_model_but.disabled = False
# self.ids.b_model_but.disabled = False
self.ids.nextBut.disabled = False
self.ids.backBut.disabled = False
def beginTest(self):
callBack_to_call = self.callBack
self.ids.test_model_but.disabled = False
# self.ids.b_model_but.disabled = True
self.ids.nextBut.disabled = True
self.ids.backBut.disabled = True
Thread( target = phase4.start, args=('a',(callBack_to_call),)).start()
self.ids.statusBox.text = "Creating a_model"
class sixthClass( Screen ):
"""docstring for thirdClass"""
callBack_to_call = 0
def __init__(self, **kwargs):
super(sixthClass, self).__init__(**kwargs)
callBack_to_call = self.callBack
# initialise references
imageGray = self.ids.imageGray
imagePredicted = self.ids.imagePredicted
imageGround = self.ids.imageGround
imageList = []
imageList = hfg.getAndFilterPaths( )
def loadImages(base_name):
self.ids.btn.text = base_name
base_name = "./predicted_images/" + base_name.split('_')[0]
imageGray.source = base_name+"_G.jpg"
imagePredicted.source = base_name + "_B.jpg"
imageGround.source = base_name + "_GT.jpg"
if(imageList != []):
loadImages(hfg.refineName(imageList[0]))
# Name on default placeholder
dropdownIdentifier = self.ids.dropdown
def changeName(instance):
base_name = instance.text
loadImages(base_name)
for eachImage in imageList:
name = hfg.refineName(eachImage)
dropdownButton = Button(text=name, height='48dp', size_hint_y=None)
dropdownButton.bind(on_release=changeName)
dropdownIdentifier.add_widget(dropdownButton)
# for i in range(1,5):
# src = "http://placehold.it/480x270.png&text=slide-%d&.png" % i
# #load images asynchronously
# image = Factory.AsyncImage(source=src, allow_stretch=True)
# # self.ids.carousel.add_widget(image)
def callBack(self, model_name):
# self.ids.statusBox.text = "Model " + model_name +" created"
if(model_name=='b'):
Thread( target = phase4.start, args=('a',(callBack_to_call),)).start()
elif model_name=='ab':
self.ids.test_model_but.disabled = False
# self.ids.b_model_but.disabled = False
self.ids.nextBut.disabled = False
self.ids.backBut.disabled = False
class screenClass(ScreenManager):
"""docstring for screenClass"""
def __init__(self, **kwargs):
super(screenClass, self).__init__(**kwargs)
self.transition=SlideTransition()
screen1 = secondClass(name='second_screen')
screen2 = thirdClass(name='third_screen')
screen3 = fourthClass(name='fourth_screen')
screen4 = fifthClass(name='fifth_screen')
screen5 = sixthClass(name='sixth_screen')
self.add_widget(screen1)
self.add_widget(screen2)
self.add_widget(screen3)
self.add_widget(screen4)
self.add_widget(screen5)
class ColoriserGUIApp(App):
def build(self):
return splashClass()
# return secondClass()
# return thirdClass()
# return firstClass()
# return screenClass()
# return fifthClass()
# return sixthClass()
if __name__ == '__main__':
ColoriserGUIApp().run()