Spaces:
Sleeping
Sleeping
mistermprah
commited on
Commit
•
5c30903
1
Parent(s):
6da5de1
Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ st.markdown(
|
|
24 |
"""
|
25 |
<style>
|
26 |
body {
|
27 |
-
background-color: #
|
28 |
}
|
29 |
.stApp {
|
30 |
color: #006064; /* Dark sea blue text */
|
@@ -36,6 +36,15 @@ st.markdown(
|
|
36 |
.stButton > button:hover {
|
37 |
background-color: #004d40; /* Darker sea blue on hover */
|
38 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
</style>
|
40 |
""",
|
41 |
unsafe_allow_html=True
|
@@ -66,11 +75,20 @@ if uploaded_file is not None:
|
|
66 |
|
67 |
# Audio Test Samples for classification
|
68 |
st.write("Audio Test Samples:")
|
|
|
69 |
examples = ['normal.wav', 'murmur.wav', 'extra_systole.wav', 'extra_hystole.wav', 'artifact.wav']
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
for idx, example in enumerate(examples):
|
73 |
-
col = cols[idx %
|
74 |
if col.button(example):
|
75 |
col.subheader(f"Sample Audio: {example}")
|
76 |
audio_bytes = open(example, 'rb').read()
|
@@ -79,3 +97,14 @@ for idx, example in enumerate(examples):
|
|
79 |
col.write("Results:")
|
80 |
results_str = "\n".join([f"{label}: {score:.2f}" for label, score in results.items()])
|
81 |
col.text(results_str)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
"""
|
25 |
<style>
|
26 |
body {
|
27 |
+
background-color: #f0f4c3; /* Light green background */
|
28 |
}
|
29 |
.stApp {
|
30 |
color: #006064; /* Dark sea blue text */
|
|
|
36 |
.stButton > button:hover {
|
37 |
background-color: #004d40; /* Darker sea blue on hover */
|
38 |
}
|
39 |
+
.stFileUpload > div {
|
40 |
+
background-color: #006064; /* Dark sea blue file uploader background */
|
41 |
+
color: white; /* White text */
|
42 |
+
border-radius: 5px;
|
43 |
+
padding: 10px;
|
44 |
+
}
|
45 |
+
.stFileUpload > div:hover {
|
46 |
+
background-color: #004d40; /* Darker sea blue on hover */
|
47 |
+
}
|
48 |
</style>
|
49 |
""",
|
50 |
unsafe_allow_html=True
|
|
|
75 |
|
76 |
# Audio Test Samples for classification
|
77 |
st.write("Audio Test Samples:")
|
78 |
+
|
79 |
examples = ['normal.wav', 'murmur.wav', 'extra_systole.wav', 'extra_hystole.wav', 'artifact.wav']
|
80 |
+
|
81 |
+
# Determine the number of columns based on the screen size
|
82 |
+
if st.session_state.get("is_mobile", False):
|
83 |
+
num_columns = 1 # Single column for mobile view
|
84 |
+
else:
|
85 |
+
num_columns = 3 # Multiple columns for desktop view
|
86 |
+
|
87 |
+
# Arrange buttons in the columns
|
88 |
+
cols = st.columns(num_columns)
|
89 |
|
90 |
for idx, example in enumerate(examples):
|
91 |
+
col = cols[idx % num_columns] # Rotate columns for better arrangement
|
92 |
if col.button(example):
|
93 |
col.subheader(f"Sample Audio: {example}")
|
94 |
audio_bytes = open(example, 'rb').read()
|
|
|
97 |
col.write("Results:")
|
98 |
results_str = "\n".join([f"{label}: {score:.2f}" for label, score in results.items()])
|
99 |
col.text(results_str)
|
100 |
+
|
101 |
+
# JavaScript to detect if the user is on a mobile device
|
102 |
+
st.markdown(
|
103 |
+
"""
|
104 |
+
<script>
|
105 |
+
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
106 |
+
window.parent.postMessage({type: 'streamlit:storeSessionState', key: 'is_mobile', value: isMobile}, '*');
|
107 |
+
</script>
|
108 |
+
""",
|
109 |
+
unsafe_allow_html=True
|
110 |
+
)
|