-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
122 lines (103 loc) · 4.01 KB
/
main.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# -*- coding:utf-8 -*-
"""
@author:Ls
@file:main.py
@time:2018/7/30 16:14
"""
import tkinter as tk
def compute_conv():
var_w = int(W.get())
var_h = int(H.get())
var_d = int(D.get())
var_f = int(F.get())
var_k = int(K.get())
var_s = int(S.get())
var_p = int(P.get())
out_w = ((var_w - var_f + (2 * var_p)) / var_s) + 1
out_h = ((var_h - var_f + (2 * var_p)) / var_s) + 1
out_d = var_k
if ((var_w - var_f + (2 * var_p)) % var_s) or ((var_h - var_f + (2 * var_p)) % var_s):
var.set('bad parameter!')
else:
var.set('')
w.delete(0,tk.END)
h.delete(0,tk.END)
d.delete(0,tk.END)
w.insert('insert', int(out_w))
h.insert('insert', int(out_h))
d.insert('insert', int(out_d))
def compute_pool():
var_w = int(W.get())
var_h = int(H.get())
var_d = int(D.get())
var_f = int(F.get())
var_k = int(K.get())
var_s = int(S.get())
var_p = int(P.get())
out_w = ((var_w - var_f) / var_s) + 1
out_h = ((var_h - var_f) / var_s) + 1
out_d = var_d
if ((var_w - var_f) % var_s) or ((var_h - var_f) % var_s):
var.set('bad parameter!')
else:
var.set('')
w.delete(0, tk.END)
h.delete(0, tk.END)
d.delete(0, tk.END)
w.insert('insert', int(out_w))
h.insert('insert', int(out_h))
d.insert('insert', int(out_d))
def copy():
var_w = int(w.get())
var_h = int(h.get())
var_d = int(d.get())
W.delete(0, tk.END)
H.delete(0, tk.END)
D.delete(0, tk.END)
W.insert('insert', int(var_w))
H.insert('insert', int(var_h))
D.insert('insert', int(var_d))
window = tk.Tk()
window.title('DNN-parameter-calculator')
window.geometry('800x500')
tk.Label(window, text='in put', font=('Arial', 12), width=15, height=2).place(x=100, y=10, anchor='nw')
tk.Label(window, text='out put', font=('Arial', 12), width=15, height=2).place(x=550, y=10, anchor='nw')
tk.Label(window, text='filter size', font=('Arial', 12), width=15, height=2).place(x=10, y=300, anchor='nw')
tk.Label(window, text='filter number', font=('Arial', 12), width=15, height=2).place(x=10, y=340, anchor='nw')
tk.Label(window, text='stride', font=('Arial', 12), width=15, height=2).place(x=10, y=380, anchor='nw')
tk.Label(window, text='padding', font=('Arial', 12), width=15, height=2).place(x=10, y=420, anchor='nw')
canvas = tk.Canvas(window, height=250, width=700)
canvas.place(x=50, y=50, anchor='nw')
image_file = tk.PhotoImage(file='timg.png')
canvas.create_image(10, 10, anchor='nw', image=image_file)
canvas.create_image(700, 10, anchor='ne', image=image_file)
W = tk.Entry(window)
W.place(x=150, y=120, width=30, height=20, anchor='nw')
H = tk.Entry(window)
H.place(x=60, y=180, width=30, height=20, anchor='nw')
D = tk.Entry(window)
D.place(x=110, y=80, width=30, height=20, anchor='nw')
F = tk.Entry(window)
F.place(x=150, y=310, width=30, height=20, anchor='nw')
K = tk.Entry(window)
K.place(x=150, y=350, width=30, height=20, anchor='nw')
S = tk.Entry(window)
S.place(x=150, y=390, width=30, height=20, anchor='nw')
P = tk.Entry(window)
P.place(x=150, y=430, width=30, height=20, anchor='nw')
w = tk.Entry(window)
w.place(x=580, y=120, width=30, height=20, anchor='nw')
h = tk.Entry(window)
h.place(x=480, y=180, width=30, height=20, anchor='nw')
d = tk.Entry(window)
d.place(x=540, y=80, width=30, height=20, anchor='nw')
conv = tk.Button(window, text='convolution', width=30, height=20, command=compute_conv)
conv.place(x=250, y=320, width=150, height=50, anchor='nw')
pool = tk.Button(window, text='pooling', width=30, height=20, command=compute_pool)
pool.place(x=250, y=400, width=150, height=50, anchor='nw')
copy = tk.Button(window, text='copy', width=30, height=20, command=copy)
copy.place(x=450, y=320, width=150, height=130, anchor='nw')
var = tk.StringVar()
l = tk.Label(window, textvariable=var, font=('Arial', 12), width=15, height=2)
l.place(x=630, y=320, width=150, height=130, anchor='nw')
window.mainloop()