Vish2005 commited on
Commit
0639876
·
verified ·
1 Parent(s): 7e334dd

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +80 -0
app.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import json
3
+ from itertools import product
4
+ import subprocess # assuming you need this for calling run_on_scc.sh
5
+
6
+ # Helper function to run the analysis
7
+ def run_analysis(datasets, machines):
8
+ selected_datasets = datasets # it's already a list
9
+ selected_machines = machines # it's already a list
10
+
11
+ if not selected_datasets:
12
+ return "Please select at least one dataset."
13
+
14
+ if not selected_machines:
15
+ return "Please select at least one machine."
16
+
17
+ configurations = []
18
+ for dataset, machine in product(selected_datasets, selected_machines):
19
+ config = {
20
+ "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"
21
+ }
22
+ configurations.append(config)
23
+
24
+ filepath = "results/models-parameters_list.txt"
25
+ output_filepath = "results/evaluation_scores.txt"
26
+
27
+ with open(filepath, 'w') as f:
28
+ for config in configurations:
29
+ f.write(json.dumps(config))
30
+ f.write("\n\n")
31
+
32
+ # Call the SCC script and return computing status
33
+ result = subprocess.run(["run_on_scc.sh"], capture_output=True, text=True)
34
+
35
+ return "Computing..."
36
+
37
+ # Function to update the summary textbox
38
+ def update_summary(datasets, machines):
39
+ # datasets and machines are lists, not dictionaries
40
+ summary_text = f"Selected Datasets:\n{', '.join(datasets) if datasets else 'None'}\n\n"
41
+ summary_text += f"Selected Machines:\n{', '.join(machines) if machines else 'None'}"
42
+ return summary_text
43
+
44
+ # Gradio components
45
+ with gr.Blocks() as app:
46
+ gr.Markdown("# Cancer Analysis Tool")
47
+
48
+ # Tab 1: Dataset Selection
49
+ with gr.Tab("Dataset"):
50
+ datasets = gr.CheckboxGroup(
51
+ ["Binary Colon", "Binary Lung", "Binary Prostate"],
52
+ label="Select Datasets:"
53
+ )
54
+
55
+ # Tab 2: Machine Selection
56
+ with gr.Tab("Machines"):
57
+ machines = gr.CheckboxGroup(
58
+ ["Binary SVM", "Binary KNN", "Binary Deepnet"],
59
+ label="Select Machines:"
60
+ )
61
+
62
+ # Tab 3: Summary and Analysis
63
+ with gr.Tab("Analysis"):
64
+ summary = gr.Textbox(label="Summary of Selections", interactive=False)
65
+ run_button = gr.Button("Run Analysis")
66
+ result = gr.Textbox(label="Result", interactive=False)
67
+
68
+ # Trigger analysis
69
+ run_button.click(
70
+ run_analysis,
71
+ inputs=[datasets, machines],
72
+ outputs=result
73
+ )
74
+
75
+ # Update summary when selections change
76
+ datasets.change(update_summary, [datasets, machines], summary)
77
+ machines.change(update_summary, [datasets, machines], summary)
78
+
79
+ # Launch the Gradio interface
80
+ app.launch(share=True)