File size: 1,653 Bytes
de583e8 372418a 0f7f21f 864f147 7c05f8d de583e8 f843583 de583e8 864f147 9db6e59 864f147 9db6e59 864f147 9db6e59 d05a10f 864f147 9db6e59 864f147 de583e8 ca454d0 7fc7cc1 ca454d0 864f147 de583e8 188a88f 7fc7cc1 864f147 de583e8 864f147 7fc7cc1 de583e8 |
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 |
import gradio as gr # used to build simple interface
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import joblib
from preprocessing.numeric_selector import NumericSelector
from cluster_ops.clustering import explore_clusters, final_clustering
#========== GRADIO INTERFACE ==========
with gr.Blocks(title="PERCEUL: Perception-Based Worker Profiler") as app:
gr.Markdown("# 🧠 PERCEUL: Profiler of Perception and Cognitive Ergonomics in the Workplace")
file_input = gr.File(label="Upload CSV")
with gr.Tab("Cluster Exploration"):
btn = gr.Button("Explore Clusters")
plot_output = gr.Plot()
cluster_summary_output = gr.JSON(label="Cluster Sizes")
outlier_output = gr.Markdown("### Exploration Report")
btn.click(
fn=explore_clusters,
inputs=[file_input],
outputs=[plot_output, cluster_summary_output, outlier_output]
)
with gr.Tab("Final Clustering"):
top_features = gr.Number(
value=5,
label="Number of Features to Display",
minimum=3,
maximum=10,
step=1,
precision=0
)
run_btn = gr.Button("Run Final Clustering")
best_k_out = gr.Number(label="Number of Clusters `K` (Read-Only)", interactive=False, precision=0)
gr.Markdown("### Cluster Characteristics")
deviations_out = gr.Markdown()
run_btn.click(
final_clustering,
inputs=[file_input, top_features],
outputs=[best_k_out, deviations_out]
)
app.launch() |