Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import numpy as np | |
| import joblib | |
| import json | |
| # Load updated model and scaler | |
| model = joblib.load("epilepsy_rf_model_9features.pkl") | |
| scaler = joblib.load("scaler_9features.pkl") | |
| # Load updated feature names | |
| with open("feature_names.json", "r") as f: | |
| feature_names = json.load(f) | |
| # Define prediction function | |
| def predict_epilepsy(*inputs): | |
| input_array = np.array(inputs).reshape(1, -1) | |
| scaled_input = scaler.transform(input_array) | |
| prediction = model.predict(scaled_input)[0] | |
| return "🧠 Epileptic" if prediction == 1 else "✅ Not Epileptic" | |
| # Build Gradio UI | |
| inputs = [gr.Number(label=feature) for feature in feature_names] | |
| demo = gr.Interface( | |
| fn=predict_epilepsy, | |
| inputs=inputs, | |
| outputs="text", | |
| title="🧠 Epilepsy Seizure Prediction", | |
| description="Enter EEG signal features to predict if a patient has epilepsy.", | |
| ) | |
| demo.launch() | |