Spaces:
Sleeping
Sleeping
GitHub Actions
commited on
Commit
·
b5b39b7
1
Parent(s):
f281169
Sync App from main repo
Browse files
app.py
CHANGED
@@ -1,15 +1,17 @@
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
import pandas as pd
|
4 |
-
|
5 |
st.title("Arrhythmia Detection")
|
6 |
|
7 |
-
models = {
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
13 |
|
14 |
# Model selection
|
15 |
model_name = st.selectbox("Select a Model", list(models.keys()))
|
@@ -18,15 +20,23 @@ model_name = st.selectbox("Select a Model", list(models.keys()))
|
|
18 |
uploaded_file = st.file_uploader("Upload a CSV file", type="csv")
|
19 |
if uploaded_file is not None:
|
20 |
df = pd.read_csv(uploaded_file)
|
21 |
-
st.write("Uploaded Data:", df)
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
if st.button("Predict"):
|
24 |
model = models[model_name]
|
25 |
|
26 |
-
#
|
|
|
|
|
|
|
27 |
response = requests.post(
|
28 |
-
"https://fabriciojm-hadt-api.hf.space/predict
|
29 |
-
|
30 |
)
|
31 |
|
32 |
if response.status_code == 200:
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
import pandas as pd
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
st.title("Arrhythmia Detection")
|
6 |
|
7 |
+
models = {
|
8 |
+
"LSTM Multi": "lstm_multi_model.h5",
|
9 |
+
"CNN Multi": "cnn_multi_model.h5",
|
10 |
+
"PCA XGBoost Multi": "pca_xgboost_multi_model.pkl",
|
11 |
+
"LSTM Binary": "lstm_binary_model.h5",
|
12 |
+
"CNN Binary": "cnn_binary_model.h5",
|
13 |
+
"PCA XGBoost Binary": "pca_xgboost_binary_model.pkl",
|
14 |
+
}
|
15 |
|
16 |
# Model selection
|
17 |
model_name = st.selectbox("Select a Model", list(models.keys()))
|
|
|
20 |
uploaded_file = st.file_uploader("Upload a CSV file", type="csv")
|
21 |
if uploaded_file is not None:
|
22 |
df = pd.read_csv(uploaded_file)
|
23 |
+
# st.write("Uploaded Data:", df)
|
24 |
+
|
25 |
+
st.write("Visualized Data:")
|
26 |
+
fig, ax = plt.subplots(figsize=(10, 6))
|
27 |
+
df.plot(ax=ax)
|
28 |
+
st.pyplot(fig)
|
29 |
|
30 |
if st.button("Predict"):
|
31 |
model = models[model_name]
|
32 |
|
33 |
+
# Reset the file pointer to the beginning
|
34 |
+
uploaded_file.seek(0)
|
35 |
+
|
36 |
+
# Call the API with the file directly
|
37 |
response = requests.post(
|
38 |
+
f"https://fabriciojm-hadt-api.hf.space/predict?model_name={model}",
|
39 |
+
files={"filepath_csv": (uploaded_file.name, uploaded_file, "text/csv")},
|
40 |
)
|
41 |
|
42 |
if response.status_code == 200:
|