forked from skaravind/AutoEncoder-GUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.py
62 lines (51 loc) · 1.36 KB
/
gui.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
from tkinter import *
import cv2, os
from PIL.ImageTk import PhotoImage
from PIL import Image
from keras.models import load_model,model_from_json
import numpy as np
def load_predictor_models():
json_file = open('model/aae_decoder.json','r').read()
gen = model_from_json(json_file)
del json_file
gen.load_weights('model/aae_decoder_weights.hdf5')
return gen
root = Tk()
root.title('GANesha')
G = load_predictor_models()
sliders = []
no = 0
z = np.random.normal(size=(1,100))
class SliderClass:
def __init__(self,master,i,j):
global no
self.no = no
self.w = Scale(master, from_=10, to=-10, tickinterval=0.1)
self.w.grid(row=i,column=j)
self.w.bind("<ButtonRelease-1>", self.change)
self.w.set(np.clip(z[0,self.no]*10,-10.0,10.0))
no +=1
def change(self, event):
z[0,self.no] = self.w.get()/2
im = G.predict(z)
im = (0.5 * im + 0.5)*255
im = im[0,:,:,:].astype('uint8')
im = cv2.resize(im,(150,150))
im = Image.fromarray(im)
im = PhotoImage(im)
panel.configure(image=im)
root.mainloop()
im = G.predict(z)
im = (0.5 * im + 0.5)*255
im = im[0,:,:,:].astype('uint8')
im = cv2.resize(im,(150,150))
im = Image.fromarray(im)
im = PhotoImage(im)
panel = Label(root, image = im, width=200,height=200)
panel.grid(rowspan=5,column=0)
r,c = 5,20
for i in range(r):
for j in range(1,c+1):
s = SliderClass(root,i,j)
sliders.append(s)
root.mainloop()