2018-09-27 20:24:09 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import sys
|
2018-09-28 18:57:37 +00:00
|
|
|
if sys.version_info[0] >= 3:
|
2018-09-27 20:24:09 +00:00
|
|
|
import PySimpleGUI as sg
|
2018-09-28 18:57:37 +00:00
|
|
|
else:
|
|
|
|
import PySimpleGUI27 as sg
|
|
|
|
|
2018-08-09 17:18:04 +00:00
|
|
|
def MachineLearningGUI():
|
|
|
|
sg.SetOptions(text_justification='right')
|
2018-09-18 01:59:11 +00:00
|
|
|
|
|
|
|
flags = [[sg.Checkbox('Normalize', size=(12, 1), default=True), sg.Checkbox('Verbose', size=(20, 1))],
|
|
|
|
[sg.Checkbox('Cluster', size=(12, 1)), sg.Checkbox('Flush Output', size=(20, 1), default=True)],
|
|
|
|
[sg.Checkbox('Write Results', size=(12, 1)), sg.Checkbox('Keep Intermediate Data', size=(20, 1))],
|
|
|
|
[sg.Checkbox('Normalize', size=(12, 1), default=True), sg.Checkbox('Verbose', size=(20, 1))],
|
|
|
|
[sg.Checkbox('Cluster', size=(12, 1)), sg.Checkbox('Flush Output', size=(20, 1), default=True)],
|
|
|
|
[sg.Checkbox('Write Results', size=(12, 1)), sg.Checkbox('Keep Intermediate Data', size=(20, 1))],]
|
|
|
|
|
|
|
|
loss_functions = [[sg.Radio('Cross-Entropy', 'loss', size=(12, 1)), sg.Radio('Logistic', 'loss', default=True, size=(12, 1))],
|
|
|
|
[sg.Radio('Hinge', 'loss', size=(12, 1)), sg.Radio('Huber', 'loss', size=(12, 1))],
|
|
|
|
[sg.Radio('Kullerback', 'loss', size=(12, 1)), sg.Radio('MAE(L1)', 'loss', size=(12, 1))],
|
|
|
|
[sg.Radio('MSE(L2)', 'loss', size=(12, 1)), sg.Radio('MB(L0)', 'loss', size=(12, 1))],]
|
|
|
|
|
|
|
|
command_line_parms = [[sg.Text('Passes', size=(8, 1)), sg.Spin(values=[i for i in range(1, 1000)], initial_value=20, size=(6, 1)),
|
|
|
|
sg.Text('Steps', size=(8, 1), pad=((7,3))), sg.Spin(values=[i for i in range(1, 1000)], initial_value=20, size=(6, 1))],
|
|
|
|
[sg.Text('ooa', size=(8, 1)), sg.In(default_text='6', size=(8, 1)), sg.Text('nn', size=(8, 1)),
|
|
|
|
sg.In(default_text='10', size=(10, 1))],
|
|
|
|
[sg.Text('q', size=(8, 1)), sg.In(default_text='ff', size=(8, 1)), sg.Text('ngram', size=(8, 1)),
|
|
|
|
sg.In(default_text='5', size=(10, 1))],
|
|
|
|
[sg.Text('l', size=(8, 1)), sg.In(default_text='0.4', size=(8, 1)), sg.Text('Layers', size=(8, 1)),
|
|
|
|
sg.Drop(values=('BatchNorm', 'other'), auto_size_text=True)],]
|
|
|
|
|
2018-09-18 16:05:44 +00:00
|
|
|
layout = [[sg.Frame('Command Line Parameteres', command_line_parms, title_color='green', font='Any 12')],
|
|
|
|
[sg.Frame('Flags', flags, font='Any 12', title_color='blue')],
|
|
|
|
[sg.Frame('Loss Functions', loss_functions, font='Any 12', title_color='red')],
|
2018-08-09 17:18:04 +00:00
|
|
|
[sg.Submit(), sg.Cancel()]]
|
2018-09-18 01:59:11 +00:00
|
|
|
|
2018-09-24 22:01:00 +00:00
|
|
|
window = sg.Window('Machine Learning Front End', font=("Helvetica", 12)).Layout(layout)
|
|
|
|
button, values = window.Read()
|
2018-08-09 17:18:04 +00:00
|
|
|
sg.SetOptions(text_justification='left')
|
|
|
|
|
2018-09-04 23:43:22 +00:00
|
|
|
print(button, values)
|
2018-08-09 17:18:04 +00:00
|
|
|
|
|
|
|
def CustomMeter():
|
2018-08-11 23:36:07 +00:00
|
|
|
# layout the form
|
2018-08-09 17:18:04 +00:00
|
|
|
layout = [[sg.Text('A custom progress meter')],
|
2018-09-24 22:01:00 +00:00
|
|
|
[sg.ProgressBar(10000, orientation='h', size=(20,20), key='progress')],
|
2018-08-09 17:18:04 +00:00
|
|
|
[sg.Cancel()]]
|
|
|
|
|
2018-09-04 23:43:22 +00:00
|
|
|
# create the form`
|
2018-09-24 22:01:00 +00:00
|
|
|
window = sg.Window('Custom Progress Meter').Layout(layout)
|
|
|
|
progress_bar = window.FindElement('progress')
|
2018-08-11 23:36:07 +00:00
|
|
|
# loop that would normally do something useful
|
2018-08-09 17:18:04 +00:00
|
|
|
for i in range(10000):
|
2018-08-11 23:36:07 +00:00
|
|
|
# check to see if the cancel button was clicked and exit loop if clicked
|
2018-10-15 20:07:23 +00:00
|
|
|
event, values = window.ReadNonBlocking()
|
|
|
|
if event == 'Cancel' or values == None:
|
2018-08-11 23:36:07 +00:00
|
|
|
break
|
|
|
|
# update bar with loop value +1 so that bar eventually reaches the maximum
|
|
|
|
progress_bar.UpdateBar(i+1)
|
|
|
|
# done with loop... need to destroy the window as it's still open
|
2018-09-24 22:01:00 +00:00
|
|
|
window.CloseNonBlocking()
|
2018-08-09 17:18:04 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2018-09-24 22:01:00 +00:00
|
|
|
CustomMeter()
|
2018-08-09 17:18:04 +00:00
|
|
|
MachineLearningGUI()
|