Spaces:
Sleeping
Sleeping
GitHub Actions
commited on
Commit
·
aaf5034
1
Parent(s):
6761eaf
Sync App from main repo
Browse files
app.py
CHANGED
@@ -42,7 +42,7 @@ st.markdown("""Upload a CSV file with single heartbeat (csv with 180 points) or
|
|
42 |
""")
|
43 |
|
44 |
# Option to upload or load a file
|
45 |
-
option = st.radio("Choose input method", ("Load example file", "Upload CSV file"))
|
46 |
|
47 |
if option == "Load example file":
|
48 |
# Load example files from Hugging Face dataset
|
@@ -58,9 +58,20 @@ if option == "Load example file":
|
|
58 |
df = pd.read_csv(uploaded_file)
|
59 |
# st.write("Loaded Data:", df)
|
60 |
|
61 |
-
|
62 |
# File uploader
|
63 |
uploaded_file = st.file_uploader("Upload a CSV file", type="csv")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
if uploaded_file is not None:
|
65 |
df = pd.read_csv(uploaded_file)
|
66 |
# st.write("Uploaded Data:", df)
|
@@ -86,6 +97,8 @@ if 'df' in locals():
|
|
86 |
|
87 |
if response.status_code == 200:
|
88 |
prediction = response.json()["prediction"]
|
89 |
-
st.write(f"Prediction using {model_name}:
|
|
|
|
|
90 |
else:
|
91 |
st.error(f"Error: {response.json().get('detail', 'Unknown error')}")
|
|
|
42 |
""")
|
43 |
|
44 |
# Option to upload or load a file
|
45 |
+
option = st.radio("Choose input method", ("Load example file", "Upload CSV file", "Upload Apple Watch ECG CSV file"))
|
46 |
|
47 |
if option == "Load example file":
|
48 |
# Load example files from Hugging Face dataset
|
|
|
58 |
df = pd.read_csv(uploaded_file)
|
59 |
# st.write("Loaded Data:", df)
|
60 |
|
61 |
+
elif option == "Upload CSV file":
|
62 |
# File uploader
|
63 |
uploaded_file = st.file_uploader("Upload a CSV file", type="csv")
|
64 |
+
st.write("The CSV file should have 180 points per row, following the format in [the examples](https://huggingface.co/datasets/fabriciojm/ecg-examples)")
|
65 |
+
if uploaded_file is not None:
|
66 |
+
df = pd.read_csv(uploaded_file)
|
67 |
+
# st.write("Uploaded Data:", df)
|
68 |
+
|
69 |
+
elif option == "Upload Apple Watch ECG CSV file":
|
70 |
+
# File uploader
|
71 |
+
st.write("DISCLAIMER: this is an experimental feature, and the results may not be accurate. This should not be used as professional medical advice.")
|
72 |
+
uploaded_file = st.file_uploader("Upload a CSV file", type="csv")
|
73 |
+
st.write("The Apple Watch CSV file should have the same format as [the examples](https://huggingface.co/datasets/fabriciojm/apple-ecg-examples)")
|
74 |
+
|
75 |
if uploaded_file is not None:
|
76 |
df = pd.read_csv(uploaded_file)
|
77 |
# st.write("Uploaded Data:", df)
|
|
|
97 |
|
98 |
if response.status_code == 200:
|
99 |
prediction = response.json()["prediction"]
|
100 |
+
st.write(f"Prediction using {model_name}:")
|
101 |
+
for i, p in enumerate(prediction):
|
102 |
+
st.write(f"Beat {i+1}: {beat_labels[p]} (class {p})") # {beat_labels[prediction]} (class {prediction}) heartbeat
|
103 |
else:
|
104 |
st.error(f"Error: {response.json().get('detail', 'Unknown error')}")
|