CoolFace
Apppublic

cfggg/B3L

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
app.py40 linesDownload Raw Back to root
1import gradio as gr2import tensorflow as tf3import pandas as pd4from sklearn.preprocessing import StandardScaler5from joblib import load6 7scaler = load('scaler.pkl')8 9model = tf.keras.models.load_model('model.h5')10 11columns = ['wiek', 'płeć', 'ból_w_klatce', 'ciśnienie_krwi', 'cholesterol', 12    'cukier_we_krwi', 'wynik_EKG', 'tętno', 'ból_wysiłkowy', 13    'depresja_ST', 'nachylenie_ST', 'naczynia', 'thal', 'choroba_serca']14 15data = pd.read_csv('heart.csv')16 17inputs = [gr.Textbox(label=feature) for feature in data.columns[:-1]]18 19def predict_heart_disease(age, sex, cp, trestbps, chol, fbs, restecg, thalach, exang, oldpeak, slope, ca, thal):20    try:21        input_data = pd.DataFrame([[22            age, sex, cp, trestbps, chol, fbs, restecg, thalach, exang, oldpeak, slope, ca, thal23        ]], columns=columns[:-1])24 25        prediction = model.predict(scaler.transform(input_data))26 27        return "Heart Disease Detected" if round(prediction[0][0]) == 1 else "No Heart Disease"28    except Exception as e:29        return f"Error: {e}"30 31 32iface = gr.Interface(33    fn=predict_heart_disease,34    inputs=inputs,35    outputs="text",36    title="HDP-Heart Disease Prediction",37    description="Enter patient details to predict heart disease."38)39 40iface.launch(share=True)