Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import streamlit as st
|
|
2 |
from PIL import Image
|
3 |
import numpy as np
|
4 |
import torch
|
5 |
-
from transformers import ViTForImageClassification
|
6 |
|
7 |
# Load the Hugging Face model for ECG classification
|
8 |
model_name = "adilsaleem/ecg-image-multilabel-classification"
|
@@ -13,7 +13,6 @@ except Exception as e:
|
|
13 |
st.error(f"Error loading model: {str(e)}")
|
14 |
st.stop()
|
15 |
|
16 |
-
|
17 |
# CSS for styling
|
18 |
st.markdown(
|
19 |
"""
|
@@ -21,12 +20,17 @@ st.markdown(
|
|
21 |
body {
|
22 |
background-color: #F5F7FA; /* Light background color */
|
23 |
font-family: 'Arial', sans-serif;
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
.title {
|
26 |
font-size: 40px;
|
27 |
text-align: center;
|
28 |
color: #2980B9; /* Beautiful blue color */
|
29 |
font-weight: bold; /* Bold text */
|
|
|
30 |
}
|
31 |
.subtitle {
|
32 |
font-size: 20px;
|
@@ -35,14 +39,19 @@ st.markdown(
|
|
35 |
margin-bottom: 20px;
|
36 |
}
|
37 |
.footer {
|
38 |
-
background-color: #
|
39 |
color: white; /* Text color in footer */
|
40 |
text-align: center;
|
41 |
-
padding:
|
42 |
-
position:
|
43 |
bottom: 0;
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
46 |
}
|
47 |
</style>
|
48 |
""",
|
@@ -52,6 +61,19 @@ st.markdown(
|
|
52 |
# App Title
|
53 |
st.markdown('<div class="title">ECG READER</div>', unsafe_allow_html=True)
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
def preprocess_image(image):
|
56 |
try:
|
57 |
image = image.convert("RGB")
|
@@ -86,7 +108,6 @@ def get_ecg_explanation(status):
|
|
86 |
}
|
87 |
return explanations.get(status, "No explanation available.")
|
88 |
|
89 |
-
|
90 |
uploaded_file = st.file_uploader("Select an ECG image", type=["jpg", "jpeg", "png"])
|
91 |
|
92 |
if uploaded_file:
|
@@ -105,22 +126,6 @@ if uploaded_file:
|
|
105 |
except Exception as e:
|
106 |
st.error(f"Error uploading or displaying image: {str(e)}")
|
107 |
|
108 |
-
|
109 |
-
# About Us Section
|
110 |
-
with st.expander("About the App"):st.write("""
|
111 |
-
This ECG Reader application uses AI to analyze ECG images and provide insights into heart health.
|
112 |
-
It helps users determine whether their ECG results are clear or unclear.
|
113 |
-
|
114 |
-
Developed by Hamaad Ayub Khan.
|
115 |
-
|
116 |
-
Connect with me:
|
117 |
-
- [Instagram](https://www.instagram.com/hamaadayubkhan)
|
118 |
-
- [GitHub](https://github.com/hakgs1234)
|
119 |
-
- Email: [My Email](mailto:[email protected])
|
120 |
-
- [Facebook](https://www.facebook.com/hamaadayubkhan)
|
121 |
-
""")
|
122 |
-
|
123 |
-
|
124 |
# Footer
|
125 |
st.markdown(
|
126 |
"""
|
@@ -130,4 +135,4 @@ st.markdown(
|
|
130 |
</div>
|
131 |
""",
|
132 |
unsafe_allow_html=True,
|
133 |
-
)
|
|
|
2 |
from PIL import Image
|
3 |
import numpy as np
|
4 |
import torch
|
5 |
+
from transformers import ViTForImageClassification
|
6 |
|
7 |
# Load the Hugging Face model for ECG classification
|
8 |
model_name = "adilsaleem/ecg-image-multilabel-classification"
|
|
|
13 |
st.error(f"Error loading model: {str(e)}")
|
14 |
st.stop()
|
15 |
|
|
|
16 |
# CSS for styling
|
17 |
st.markdown(
|
18 |
"""
|
|
|
20 |
body {
|
21 |
background-color: #F5F7FA; /* Light background color */
|
22 |
font-family: 'Arial', sans-serif;
|
23 |
+
display: flex;
|
24 |
+
flex-direction: column;
|
25 |
+
height: 100vh;
|
26 |
+
margin: 0;
|
27 |
}
|
28 |
.title {
|
29 |
font-size: 40px;
|
30 |
text-align: center;
|
31 |
color: #2980B9; /* Beautiful blue color */
|
32 |
font-weight: bold; /* Bold text */
|
33 |
+
margin: 20px 0;
|
34 |
}
|
35 |
.subtitle {
|
36 |
font-size: 20px;
|
|
|
39 |
margin-bottom: 20px;
|
40 |
}
|
41 |
.footer {
|
42 |
+
background-color: #2C3E50; /* Darker blue for footer */
|
43 |
color: white; /* Text color in footer */
|
44 |
text-align: center;
|
45 |
+
padding: 15px; /* Padding for footer */
|
46 |
+
position: sticky;
|
47 |
bottom: 0;
|
48 |
+
width: 100%;
|
49 |
+
font-size: 14px; /* Font size for footer */
|
50 |
+
}
|
51 |
+
.about {
|
52 |
+
margin: 20px 0;
|
53 |
+
text-align: center;
|
54 |
+
color: #34495E; /* Darker shade for about section */
|
55 |
}
|
56 |
</style>
|
57 |
""",
|
|
|
61 |
# App Title
|
62 |
st.markdown('<div class="title">ECG READER</div>', unsafe_allow_html=True)
|
63 |
|
64 |
+
# About Us Section in Expander
|
65 |
+
with st.expander("About the App", expanded=True):
|
66 |
+
st.write("""
|
67 |
+
This ECG Reader application uses AI to analyze ECG images and provide insights into heart health.
|
68 |
+
It helps users determine whether their ECG results are clear or unclear.
|
69 |
+
Developed by Hamaad Ayub Khan.
|
70 |
+
""")
|
71 |
+
st.write("Connect with me:")
|
72 |
+
st.markdown('- [Instagram](https://www.instagram.com/hamaadayubkhan)', unsafe_allow_html=True)
|
73 |
+
st.markdown('- [GitHub](https://github.com/hakgs1234)', unsafe_allow_html=True)
|
74 |
+
st.markdown('- [My Email](mailto:[email protected])', unsafe_allow_html=True)
|
75 |
+
st.markdown('- [Facebook](https://www.facebook.com/hamaadayubkhan)', unsafe_allow_html=True)
|
76 |
+
|
77 |
def preprocess_image(image):
|
78 |
try:
|
79 |
image = image.convert("RGB")
|
|
|
108 |
}
|
109 |
return explanations.get(status, "No explanation available.")
|
110 |
|
|
|
111 |
uploaded_file = st.file_uploader("Select an ECG image", type=["jpg", "jpeg", "png"])
|
112 |
|
113 |
if uploaded_file:
|
|
|
126 |
except Exception as e:
|
127 |
st.error(f"Error uploading or displaying image: {str(e)}")
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
# Footer
|
130 |
st.markdown(
|
131 |
"""
|
|
|
135 |
</div>
|
136 |
""",
|
137 |
unsafe_allow_html=True,
|
138 |
+
)
|