|
import gradio as gr |
|
import json |
|
from itertools import product |
|
|
|
import concurrent |
|
import re |
|
|
|
|
|
def run_analysis(datasets, machines): |
|
selected_datasets = [dataset for dataset, selected in datasets.items() if selected] |
|
selected_machines = [machine for machine, selected in machines.items() if selected] |
|
|
|
if not selected_datasets: |
|
return "Please select at least one dataset." |
|
|
|
if not selected_machines: |
|
return "Please select at least one machine." |
|
|
|
configurations = [] |
|
for dataset, machine in product(selected_datasets, selected_machines): |
|
config = { |
|
"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" |
|
} |
|
configurations.append(config) |
|
|
|
output_filepath = "results/evaluation_scores.txt" |
|
filepath = "results/models-parameters_list.txt" |
|
|
|
with open(filepath, 'w') as f: |
|
for config in configurations: |
|
f.write(json.dumps(config)) |
|
f.write("\n\n") |
|
|
|
|
|
|
|
|
|
|
|
|
|
result = subprocess.run(["run_on_scc.sh"], capture_output=True, text=True) |
|
|
|
return "Computing..." |
|
|
|
|
|
|
|
|
|
def update_summary(datasets, machines): |
|
selected_datasets = [dataset for dataset, selected in datasets.items() if selected] |
|
selected_machines = [machine for machine, selected in machines.items() if selected] |
|
|
|
summary_text = f"Selected Datasets:\n{', '.join(selected_datasets) if selected_datasets else 'None'}\n\n" |
|
summary_text += f"Selected Machines:\n{', '.join(selected_machines) if selected_machines else 'None'}" |
|
return summary_text |
|
|
|
|
|
with gr.Blocks() as app: |
|
gr.Markdown("# Cancer Analysis Tool") |
|
|
|
|
|
with gr.Tab("Dataset"): |
|
datasets = gr.CheckboxGroup( |
|
["Binary Colon", "Binary Lung", "Binary Prostate"], |
|
label="Select Datasets:" |
|
) |
|
|
|
|
|
with gr.Tab("Machines"): |
|
machines = gr.CheckboxGroup( |
|
["Binary SVM", "Binary KNN", "Binary Deepnet"], |
|
label="Select Machines:" |
|
) |
|
|
|
|
|
with gr.Tab("Analysis"): |
|
summary = gr.Textbox(label="Summary of Selections", interactive=False) |
|
run_button = gr.Button("Run Analysis") |
|
result = gr.Textbox(label="Result", interactive=False) |
|
|
|
run_button.click( |
|
run_analysis, |
|
inputs=[datasets, machines], |
|
outputs=result |
|
) |
|
datasets.change(update_summary, [datasets, machines], summary) |
|
machines.change(update_summary, [datasets, machines], summary) |
|
|
|
|
|
app.launch(share=True) |