File size: 3,332 Bytes
0639876
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
923a604
 
 
0639876
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9d621a0
0639876
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import json
from itertools import product
import subprocess  # assuming you need this for calling run_on_scc.sh

# Helper function to run the analysis
def run_analysis(datasets, machines):
    selected_datasets = datasets  # it's already a list
    selected_machines = machines  # it's already a list

    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)

    filepath = "results/models-parameters_list.txt"
    output_filepath = "results/evaluation_scores.txt"

    with open(filepath, 'w') as f:
        for config in configurations:
            f.write(json.dumps(config))
            f.write("\n\n")

    # Call the SCC script and return computing status
    result = subprocess.run(["ssh", "-i", "~/.ssh/gradio_key", "[email protected]", "bash", "run_on_scc.sh"],
                            capture_output=True,
                            text=True)
    return "Computing..."

# Function to update the summary textbox
def update_summary(datasets, machines):
    # datasets and machines are lists, not dictionaries
    summary_text = f"Selected Datasets:\n{', '.join(datasets) if datasets else 'None'}\n\n"
    summary_text += f"Selected Machines:\n{', '.join(machines) if machines else 'None'}"
    return summary_text

# Gradio components
with gr.Blocks() as app:
    gr.Markdown("# Cancer Analysis Tool")

    # Tab 1: Dataset Selection
    with gr.Tab("Dataset"):
        datasets = gr.CheckboxGroup(
            ["Binary Colon", "Binary Lung", "Binary Prostate"],
            label="Select Datasets:"
        )

    # Tab 2: Machine Selection
    with gr.Tab("Machines"):
        machines = gr.CheckboxGroup(
            ["Binary SVM", "Binary KNN", "Binary Deepnet"],
            label="Select Machines:"
        )

    # Tab 3: Summary and Analysis
    with gr.Tab("Analysis"):
        summary = gr.Textbox(label="Summary of Selections", interactive=False, lines=5)
        run_button = gr.Button("Run Analysis")
        result = gr.Textbox(label="Result", interactive=False)

        # Trigger analysis
        run_button.click(
            run_analysis,
            inputs=[datasets, machines],
            outputs=result
        )

        # Update summary when selections change
        datasets.change(update_summary, [datasets, machines], summary)
        machines.change(update_summary, [datasets, machines], summary)

# Launch the Gradio interface
app.launch(share=True)