Osama Bashir Dabbousi commited on
Commit
8e5cd5e
·
1 Parent(s): 320fcf0

Uploaded the GUI

Browse files
Files changed (1) hide show
  1. app.py +83 -0
app.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import json
3
+ from itertools import product
4
+ # import run_function
5
+ import concurrent
6
+ import re
7
+
8
+ # Helper function to run the analysis
9
+ def run_analysis(datasets, machines):
10
+ selected_datasets = [dataset for dataset, selected in datasets.items() if selected]
11
+ selected_machines = [machine for machine, selected in machines.items() if selected]
12
+
13
+ if not selected_datasets:
14
+ return "Please select at least one dataset."
15
+
16
+ if not selected_machines:
17
+ return "Please select at least one machine."
18
+
19
+ configurations = []
20
+ for dataset, machine in product(selected_datasets, selected_machines):
21
+ config = {
22
+ "Dataset": dataset, "Binary": "True", "Image": "False", "TM_use": False, "value": "None", "Interpolation_value": "None", "Noise": False, "noise_type": False, "augmentation": False, "shear_factor": "None", "shear_prop": 0, "crop_scale_factor": "None", "crop_scale_prop": 0, "flip_code": "None", "flip_prop": 0, "rotation_angle": "None", "rotate_prop": 0, "color_number": "None", "color_prop": 0, "blur_param": "None", "blur_prop": 0, "features": "False", "glcm_distance": "None", "glcm_angle": "None", "glcm_prop": 0, "lbp_radius": "None", "lbp_prop": 0, "haralick_prop": 0, "Machine": machine, "lr": "None", "epochs": "None"
23
+ }
24
+ configurations.append(config)
25
+
26
+ output_filepath = "results/evaluation_scores.txt"
27
+ filepath = "results/models-parameters_list.txt"
28
+
29
+ with open(filepath, 'w') as f:
30
+ for config in configurations:
31
+ f.write(json.dumps(config))
32
+ f.write("\n\n")
33
+
34
+ # VISH CODE GOES HERE
35
+ # Should run bash script to move file with name filepath to SCC before
36
+ # calling "main.py filepath output_filepath" and ending by return output_filepath
37
+ # to the users directory
38
+
39
+
40
+
41
+ # Gradio Interface
42
+ def update_summary(datasets, machines):
43
+ selected_datasets = [dataset for dataset, selected in datasets.items() if selected]
44
+ selected_machines = [machine for machine, selected in machines.items() if selected]
45
+
46
+ summary_text = f"Selected Datasets:\n{', '.join(selected_datasets) if selected_datasets else 'None'}\n\n"
47
+ summary_text += f"Selected Machines:\n{', '.join(selected_machines) if selected_machines else 'None'}"
48
+ return summary_text
49
+
50
+ # Gradio components
51
+ with gr.Blocks() as app:
52
+ gr.Markdown("# Cancer Analysis Tool")
53
+
54
+ # Tab 1: Dataset Selection
55
+ with gr.Tab("Dataset"):
56
+ datasets = gr.CheckboxGroup(
57
+ ["Binary Colon", "Binary Lung", "Binary Prostate"],
58
+ label="Select Datasets:"
59
+ )
60
+
61
+ # Tab 2: Machine Selection
62
+ with gr.Tab("Machines"):
63
+ machines = gr.CheckboxGroup(
64
+ ["Binary SVM", "Binary KNN", "Binary Deepnet"],
65
+ label="Select Machines:"
66
+ )
67
+
68
+ # Tab 3: Summary and Analysis
69
+ with gr.Tab("Analysis"):
70
+ summary = gr.Textbox(label="Summary of Selections", interactive=False)
71
+ run_button = gr.Button("Run Analysis")
72
+ result = gr.Textbox(label="Result", interactive=False)
73
+
74
+ run_button.click(
75
+ run_analysis,
76
+ inputs=[datasets, machines],
77
+ outputs=result
78
+ )
79
+ datasets.change(update_summary, [datasets, machines], summary)
80
+ machines.change(update_summary, [datasets, machines], summary)
81
+
82
+ # Launch the Gradio interface
83
+ app.launch()