Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -56,6 +56,7 @@ with st.sidebar:
|
|
| 56 |
# Label dictionary for multilingual UI
|
| 57 |
LABELS = {
|
| 58 |
"user_type": {"English": "I am a...", "中文": "我的身份是...", "Malay": "Saya seorang..."},
|
|
|
|
| 59 |
"input_header": {"English": "Enter Health Info", "中文": "輸入健康資料", "Malay": "Masukkan Maklumat Kesihatan"},
|
| 60 |
"age": {"English": "Patient's Age", "中文": "年齡", "Malay": "Umur"},
|
| 61 |
"height": {"English": "Patient's Height (cm)", "中文": "身高 (cm)", "Malay": "Tinggi (cm)"},
|
|
@@ -91,18 +92,18 @@ with st.sidebar:
|
|
| 91 |
if selected == MENU[lang][0]:
|
| 92 |
with st.sidebar:
|
| 93 |
st.header(LABELS["input_header"][lang])
|
| 94 |
-
user_type = st.selectbox(LABELS["user_type"][lang], ["
|
| 95 |
age = st.number_input(LABELS["age"][lang], min_value=18, max_value=100, value=50)
|
| 96 |
height = st.number_input(LABELS["height"][lang], min_value=100, max_value=250, value=170)
|
| 97 |
weight = st.number_input(LABELS["weight"][lang], min_value=30, max_value=200, value=70)
|
| 98 |
systolic = st.number_input(LABELS["systolic"][lang], min_value=80, max_value=250, value=120)
|
| 99 |
diastolic = st.number_input(LABELS["diastolic"][lang], min_value=40, max_value=150, value=80)
|
| 100 |
-
cholesterol = st.selectbox(LABELS["cholesterol"][lang], [0, 1, 2], format_func=lambda x:
|
| 101 |
-
gluc = st.selectbox(LABELS["gluc"][lang], [0, 1, 2], format_func=lambda x:
|
| 102 |
-
gender = st.selectbox(LABELS["gender"][lang], [0, 1], format_func=lambda x:
|
| 103 |
-
smoke = st.selectbox(LABELS["smoke"][lang], [0, 1], format_func=lambda x:
|
| 104 |
-
alco = st.selectbox(LABELS["alco"][lang], [0, 1], format_func=lambda x:
|
| 105 |
-
active = st.selectbox(LABELS["active"][lang], [0, 1], format_func=lambda x:
|
| 106 |
input_data = pd.DataFrame([{ "age": age * 365, "height": height, "weight": weight, "ap_hi": systolic, "ap_lo": diastolic, "cholesterol": cholesterol, "gluc": gluc, "gender": gender, "smoke": smoke, "alco": alco, "active": active }])
|
| 107 |
predict_clicked = st.button(LABELS["predict"][lang])
|
| 108 |
|
|
@@ -151,7 +152,7 @@ if selected == MENU[lang][0]:
|
|
| 151 |
original_text = response.text
|
| 152 |
|
| 153 |
if lang == "中文":
|
| 154 |
-
translated = GoogleTranslator(source="auto", target="zh-
|
| 155 |
st.markdown("### 🔹 AI 健康建議")
|
| 156 |
st.write(translated)
|
| 157 |
elif lang == "Malay":
|
|
|
|
| 56 |
# Label dictionary for multilingual UI
|
| 57 |
LABELS = {
|
| 58 |
"user_type": {"English": "I am a...", "中文": "我的身份是...", "Malay": "Saya seorang..."},
|
| 59 |
+
"user_type_options": {"English": ["Patient", "Medical Professional"], "中文": ["病患", "醫護人員"], "Malay": ["Pesakit", "Profesional Perubatan"]},
|
| 60 |
"input_header": {"English": "Enter Health Info", "中文": "輸入健康資料", "Malay": "Masukkan Maklumat Kesihatan"},
|
| 61 |
"age": {"English": "Patient's Age", "中文": "年齡", "Malay": "Umur"},
|
| 62 |
"height": {"English": "Patient's Height (cm)", "中文": "身高 (cm)", "Malay": "Tinggi (cm)"},
|
|
|
|
| 92 |
if selected == MENU[lang][0]:
|
| 93 |
with st.sidebar:
|
| 94 |
st.header(LABELS["input_header"][lang])
|
| 95 |
+
user_type = st.selectbox(LABELS["user_type"][lang], LABELS["user_type_options"][lang])
|
| 96 |
age = st.number_input(LABELS["age"][lang], min_value=18, max_value=100, value=50)
|
| 97 |
height = st.number_input(LABELS["height"][lang], min_value=100, max_value=250, value=170)
|
| 98 |
weight = st.number_input(LABELS["weight"][lang], min_value=30, max_value=200, value=70)
|
| 99 |
systolic = st.number_input(LABELS["systolic"][lang], min_value=80, max_value=250, value=120)
|
| 100 |
diastolic = st.number_input(LABELS["diastolic"][lang], min_value=40, max_value=150, value=80)
|
| 101 |
+
cholesterol = st.selectbox(LABELS["cholesterol"][lang], [0, 1, 2], format_func=lambda x: chol_options[lang][x])
|
| 102 |
+
gluc = st.selectbox(LABELS["gluc"][lang], [0, 1, 2], format_func=lambda x: gluc_options[lang][x])
|
| 103 |
+
gender = st.selectbox(LABELS["gender"][lang], [0, 1], format_func=lambda x: gender_options[lang][x])
|
| 104 |
+
smoke = st.selectbox(LABELS["smoke"][lang], [0, 1], format_func=lambda x: yn_options[lang][x])
|
| 105 |
+
alco = st.selectbox(LABELS["alco"][lang], [0, 1], format_func=lambda x: yn_options[lang][x])
|
| 106 |
+
active = st.selectbox(LABELS["active"][lang], [0, 1], format_func=lambda x: yn_options[lang][x])
|
| 107 |
input_data = pd.DataFrame([{ "age": age * 365, "height": height, "weight": weight, "ap_hi": systolic, "ap_lo": diastolic, "cholesterol": cholesterol, "gluc": gluc, "gender": gender, "smoke": smoke, "alco": alco, "active": active }])
|
| 108 |
predict_clicked = st.button(LABELS["predict"][lang])
|
| 109 |
|
|
|
|
| 152 |
original_text = response.text
|
| 153 |
|
| 154 |
if lang == "中文":
|
| 155 |
+
translated = GoogleTranslator(source="auto", target="zh-TW").translate(original_text)
|
| 156 |
st.markdown("### 🔹 AI 健康建議")
|
| 157 |
st.write(translated)
|
| 158 |
elif lang == "Malay":
|