Spaces:
Sleeping
Sleeping
File size: 1,187 Bytes
7b0aaea f281169 7b0aaea |
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 |
import streamlit as st
import requests
import pandas as pd
st.title("Arrhythmia Detection")
models = {"CNN Binary": "cnn_binary_model.h5",
"LSTM Binary": "lstm_binary_model.h5",
"PCA XGBoost Binary": "pca_xgboost_binary_model.pkl",
"CNN Multi": "cnn_multi_model.h5",
"LSTM Multi": "lstm_multi_model.h5",
"PCA XGBoost Multi": "pca_xgboost_multi_model.pkl"}
# Model selection
model_name = st.selectbox("Select a Model", list(models.keys()))
# File uploader
uploaded_file = st.file_uploader("Upload a CSV file", type="csv")
if uploaded_file is not None:
df = pd.read_csv(uploaded_file)
st.write("Uploaded Data:", df)
if st.button("Predict"):
model = models[model_name]
# Call the API
response = requests.post(
"https://fabriciojm-hadt-api.hf.space/predict/",
json={"model_name": model, "input_data": df},
)
if response.status_code == 200:
prediction = response.json()["prediction"]
st.write(f"Prediction using {model_name}:", prediction)
else:
st.error(f"Error: {response.json().get('detail', 'Unknown error')}")
|