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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import streamlit.components.v1 as components
|
| 3 |
+
import os
|
| 4 |
+
from PIL import Image
|
| 5 |
+
# Set the page layout
|
| 6 |
+
st.set_page_config(layout="wide")
|
| 7 |
+
import json
|
| 8 |
+
import base64
|
| 9 |
+
import time
|
| 10 |
+
from dotenv import load_dotenv
|
| 11 |
+
import os
|
| 12 |
+
import requests
|
| 13 |
+
import pickle
|
| 14 |
+
import numpy as np
|
| 15 |
+
import google.generativeai as genai
|
| 16 |
+
|
| 17 |
+
# Load model once
|
| 18 |
+
with open("best_clf.pkl", "rb") as file:
|
| 19 |
+
best_clf = pickle.load(file)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
# Try loading environment variables locally
|
| 23 |
+
try:
|
| 24 |
+
from dotenv import load_dotenv
|
| 25 |
+
load_dotenv()
|
| 26 |
+
except:
|
| 27 |
+
pass
|
| 28 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 29 |
+
|
| 30 |
+
# Get the token from environment variables
|
| 31 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 32 |
+
# --- Step 1 ---
|
| 33 |
+
if 'name' not in st.session_state:
|
| 34 |
+
st.session_state.name = "Ange"
|
| 35 |
+
|
| 36 |
+
if 'gender' not in st.session_state:
|
| 37 |
+
st.session_state.gender = "Male"
|
| 38 |
+
|
| 39 |
+
if 'age' not in st.session_state:
|
| 40 |
+
st.session_state.age = 25
|
| 41 |
+
|
| 42 |
+
if 'currentSmoker' not in st.session_state:
|
| 43 |
+
st.session_state.currentSmoker = "Yes"
|
| 44 |
+
|
| 45 |
+
if 'cigsPerDay' not in st.session_state:
|
| 46 |
+
st.session_state.cigsPerDay = 0
|
| 47 |
+
|
| 48 |
+
if 'BPMeds' not in st.session_state:
|
| 49 |
+
st.session_state.BPMeds = False
|
| 50 |
+
|
| 51 |
+
if 'diabetes' not in st.session_state:
|
| 52 |
+
st.session_state.diabetes = False
|
| 53 |
+
|
| 54 |
+
# --- Step 2 ---
|
| 55 |
+
if 'totChol' not in st.session_state:
|
| 56 |
+
st.session_state.totChol = 180 # mg/dL
|
| 57 |
+
|
| 58 |
+
if 'sysBP' not in st.session_state:
|
| 59 |
+
st.session_state.sysBP = 120 # mmHg
|
| 60 |
+
|
| 61 |
+
if 'diaBP' not in st.session_state:
|
| 62 |
+
st.session_state.diaBP = 80 # mmHg
|
| 63 |
+
|
| 64 |
+
# --- Step 3 ---
|
| 65 |
+
if 'BMI' not in st.session_state:
|
| 66 |
+
st.session_state.BMI = 22.0
|
| 67 |
+
|
| 68 |
+
if 'heartRate' not in st.session_state:
|
| 69 |
+
st.session_state.heartRate = 70 # bpm
|
| 70 |
+
|
| 71 |
+
if 'glucose' not in st.session_state:
|
| 72 |
+
st.session_state.glucose = 90 # mg/dL
|
| 73 |
+
|
| 74 |
+
# Optional: prediction result
|
| 75 |
+
if 'Risk' not in st.session_state:
|
| 76 |
+
st.session_state.Risk = 1
|
| 77 |
+
if 'proba' not in st.session_state:
|
| 78 |
+
st.session_state.proba = 80
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
if "framework" not in st.session_state:
|
| 83 |
+
st.session_state.framework = "gen"
|
| 84 |
+
# Initialize state
|
| 85 |
+
|
| 86 |
+
if "form1" not in st.session_state:
|
| 87 |
+
st.session_state.form1 = "back"
|
| 88 |
+
if "form2" not in st.session_state:
|
| 89 |
+
st.session_state.form2 = "back"
|
| 90 |
+
if "form3" not in st.session_state:
|
| 91 |
+
st.session_state.form3 = "back"
|
| 92 |
+
if "form4" not in st.session_state:
|
| 93 |
+
st.session_state.form4 = "back"
|
| 94 |
+
if "form5" not in st.session_state:
|
| 95 |
+
st.session_state.form5 = "back"
|
| 96 |
+
if "form6" not in st.session_state:
|
| 97 |
+
st.session_state.form6 = "back"
|
| 98 |
+
|
| 99 |
+
if st.session_state.form1 == "next":
|
| 100 |
+
start1 = 46
|
| 101 |
+
back1 = "#6dc9e4"
|
| 102 |
+
background = "#f3f3f4"
|
| 103 |
+
fill = '#6dc9e4'
|
| 104 |
+
back2 = "#4794ff"
|
| 105 |
+
back3 = "#6dc9e4"
|
| 106 |
+
back4 = "#6dc9e4"
|
| 107 |
+
elif st.session_state.form1 == "back":
|
| 108 |
+
start1 = 0
|
| 109 |
+
back1 = "#4794ff"
|
| 110 |
+
back2 = "#6dc9e4"
|
| 111 |
+
back3 = "#6dc9e4"
|
| 112 |
+
back4 = "#6dc9e4"
|
| 113 |
+
|
| 114 |
+
background =" white"
|
| 115 |
+
fill = "#f7f7f7"
|
| 116 |
+
|
| 117 |
+
##################################
|
| 118 |
+
if st.session_state.form2 == "next":
|
| 119 |
+
start2 = 46
|
| 120 |
+
background2 = "#f3f3f4"
|
| 121 |
+
fill2 = '#6dc9e4'
|
| 122 |
+
back3 = "#4794ff"
|
| 123 |
+
back2 = "#6dc9e4"
|
| 124 |
+
back1 = "#6dc9e4"
|
| 125 |
+
back4 = "#6dc9e4"
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
elif st.session_state.form2 == "back":
|
| 129 |
+
|
| 130 |
+
start2 = 0
|
| 131 |
+
background2 =" white"
|
| 132 |
+
fill2 = "#f7f7f7"
|
| 133 |
+
|
| 134 |
+
####################################
|
| 135 |
+
if st.session_state.form3 == "next":
|
| 136 |
+
start3 = 46
|
| 137 |
+
background3 = "#f3f3f4"
|
| 138 |
+
back4 = "#4794ff"
|
| 139 |
+
back2 = "#6dc9e4"
|
| 140 |
+
back1 = "#6dc9e4"
|
| 141 |
+
back3 = "#6dc9e4"
|
| 142 |
+
fill3 = '#6dc9e4'
|
| 143 |
+
border = "grey"
|
| 144 |
+
|
| 145 |
+
elif st.session_state.form3 == "back":
|
| 146 |
+
start3 = 0
|
| 147 |
+
background3 =" white"
|
| 148 |
+
fill3 = "#f7f7f7"
|
| 149 |
+
|
| 150 |
+
####################################
|
| 151 |
+
if st.session_state.form4 == "next":
|
| 152 |
+
start4 = 46
|
| 153 |
+
background4 = "#f3f3f4"
|
| 154 |
+
fill4 = '#6dc9e4'
|
| 155 |
+
back4 = "#6dc9e4"
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
elif st.session_state.form4 == "back":
|
| 159 |
+
start4 = 0
|
| 160 |
+
background4 =" white"
|
| 161 |
+
fill4 = "#f7f7f7"
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
if st.session_state.framework == "gen":
|
| 166 |
+
encoded_logo = "hugging.png"
|
| 167 |
+
main_bg_ext = "png"
|
| 168 |
+
main_bg = "image.gif"
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
st.markdown(
|
| 173 |
+
f"""
|
| 174 |
+
<style>
|
| 175 |
+
/* Container for logo and text */
|
| 176 |
+
/* Container for logo and text */
|
| 177 |
+
.logo-text-container {{
|
| 178 |
+
position: fixed;
|
| 179 |
+
top: 20px; /* Adjust vertical position */
|
| 180 |
+
left: 30px; /* Align with sidebar */
|
| 181 |
+
display: flex;
|
| 182 |
+
align-items: center;
|
| 183 |
+
gap: 10px;
|
| 184 |
+
width: 70%;
|
| 185 |
+
z-index:1000;
|
| 186 |
+
}}
|
| 187 |
+
|
| 188 |
+
/* Logo styling */
|
| 189 |
+
.logo-text-container img {{
|
| 190 |
+
width: 90px; /* Adjust logo size */
|
| 191 |
+
border-radius: 10px; /* Optional: round edges */
|
| 192 |
+
margin-left:-5px;
|
| 193 |
+
margin-top: -15px;
|
| 194 |
+
|
| 195 |
+
}}
|
| 196 |
+
|
| 197 |
+
/* Bold text styling */
|
| 198 |
+
.logo-text-container h1 {{
|
| 199 |
+
font-family: Nunito;
|
| 200 |
+
color: #0175C2;
|
| 201 |
+
font-size: 20px;
|
| 202 |
+
font-weight: bold;
|
| 203 |
+
margin-left :-30px;
|
| 204 |
+
padding:0px;
|
| 205 |
+
top:0;
|
| 206 |
+
margin-top: 10px;
|
| 207 |
+
}}
|
| 208 |
+
.logo-text-container h1 span{{
|
| 209 |
+
font-family: Nunito;
|
| 210 |
+
color: green;
|
| 211 |
+
font-size: 20px;
|
| 212 |
+
margin-right :10px;
|
| 213 |
+
font-weight: bold;
|
| 214 |
+
padding:0px;
|
| 215 |
+
margin-left:1px;
|
| 216 |
+
margin-top:2% !important;
|
| 217 |
+
}}
|
| 218 |
+
|
| 219 |
+
/* Sidebar styling */
|
| 220 |
+
section[data-testid="stSidebar"][aria-expanded="true"] {{
|
| 221 |
+
margin-top: 100px !important; /* Space for the logo */
|
| 222 |
+
border-radius: 0 60px 0px 60px !important; /* Top-left and bottom-right corners */
|
| 223 |
+
width: 300px !important; /* Sidebar width */
|
| 224 |
+
background: none; /* No background */
|
| 225 |
+
color: white !important;
|
| 226 |
+
}}
|
| 227 |
+
|
| 228 |
+
header[data-testid="stHeader"] {{
|
| 229 |
+
background: #e4f8f8 !important;
|
| 230 |
+
margin-left: -80px !important;
|
| 231 |
+
margin-top: 1px !important;
|
| 232 |
+
z-index: 1 !important;
|
| 233 |
+
color: blue; /* White text */
|
| 234 |
+
font-family: "Times New Roman " !important; /* Font */
|
| 235 |
+
font-size: 18px !important; /* Font size */
|
| 236 |
+
font-weight: bold !important; /* Bold text */
|
| 237 |
+
padding: 10px 20px; /* Padding for buttons */
|
| 238 |
+
border-top-left-radius: 30px;
|
| 239 |
+
border-top-right-radius: 30px;
|
| 240 |
+
|
| 241 |
+
transition: all 0.3s ease-in-out; /* Smooth transition */
|
| 242 |
+
display: flex;
|
| 243 |
+
align-items: center;
|
| 244 |
+
justify-content: center;
|
| 245 |
+
margin: 10px 0;
|
| 246 |
+
width:100% !important;
|
| 247 |
+
left:5.5%;
|
| 248 |
+
height:420px;
|
| 249 |
+
margin-top:30px;
|
| 250 |
+
backdrop-filter: blur(10px);
|
| 251 |
+
|
| 252 |
+
}}
|
| 253 |
+
|
| 254 |
+
div[data-testid="stDecoration"] {{
|
| 255 |
+
background-image: none;
|
| 256 |
+
}}
|
| 257 |
+
|
| 258 |
+
div[data-testid="stApp"] {{
|
| 259 |
+
|
| 260 |
+
background-size: cover; /* Ensure the image covers the full page */
|
| 261 |
+
background-position: center;
|
| 262 |
+
background-repeat:no-repeat;
|
| 263 |
+
height: 98vh;
|
| 264 |
+
width: 99.3%;
|
| 265 |
+
border-radius: 20px !important;
|
| 266 |
+
margin-left: 5px;
|
| 267 |
+
margin-right: 20px;
|
| 268 |
+
margin-top: 10px;
|
| 269 |
+
overflow: hidden;
|
| 270 |
+
backdrop-filter: blur(10px); /* Glass effect */
|
| 271 |
+
-webkit-backdrop-filter: blur(10px);
|
| 272 |
+
border: 1px solid rgba(255, 255, 255, 0.2); /* Light border */
|
| 273 |
+
border-radius:25px;
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
}}
|
| 277 |
+
[class*="st-key-main"] {{
|
| 278 |
+
position: absolute;
|
| 279 |
+
width: 85vw !important;
|
| 280 |
+
margin-left: 50px;
|
| 281 |
+
z-index:10000000;
|
| 282 |
+
border-radius:30px;
|
| 283 |
+
padding: 10px;
|
| 284 |
+
margin-top:-20px;
|
| 285 |
+
background:white;
|
| 286 |
+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1); /* Shadow effect */
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
height: 61vh;
|
| 290 |
+
width: 95.3%;
|
| 291 |
+
}}
|
| 292 |
+
[class*="st-key-side"] {{
|
| 293 |
+
position: absolute;
|
| 294 |
+
width: 40vw !important;
|
| 295 |
+
margin-left: 5px;
|
| 296 |
+
z-index:10000000;
|
| 297 |
+
border-radius:30px;
|
| 298 |
+
padding: 10px;
|
| 299 |
+
background-image: url(data:image/png;base64,{base64.b64encode(open('back.gif', "rb").read()).decode()});
|
| 300 |
+
margin-top:10px;
|
| 301 |
+
background-size: cover; /* Ensure the image covers the full page */
|
| 302 |
+
background-position: center;
|
| 303 |
+
background-repeat:no-repeat;
|
| 304 |
+
box-shadow: -5px 0px 10px rgba(0, 0, 0, 0.1); /* Shadow on the left */
|
| 305 |
+
|
| 306 |
+
height: 56vh;
|
| 307 |
+
border-bottom-right-radius: 0px ;
|
| 308 |
+
border-top-right-radius: 0px ;
|
| 309 |
+
border-left:2px solid #4794ff;
|
| 310 |
+
border-right:2px solid #4794ff;
|
| 311 |
+
width: 95.3%;
|
| 312 |
+
}}
|
| 313 |
+
.result{{
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
}}
|
| 317 |
+
.result h3{{
|
| 318 |
+
font-family: "Times New Roman" !important;
|
| 319 |
+
font-size:16px;
|
| 320 |
+
margin-top:-30px;
|
| 321 |
+
|
| 322 |
+
}}
|
| 323 |
+
[class*="st-key-result"]{{
|
| 324 |
+
height: 56vh;
|
| 325 |
+
border-radius:30px;
|
| 326 |
+
margin-top:10px;
|
| 327 |
+
position:absolute;
|
| 328 |
+
margin-left:-5px !important;
|
| 329 |
+
box-shadow: 6px 0px 10px rgba(0, 0, 0, 0.1);
|
| 330 |
+
border-right:2px solid #4794ff;
|
| 331 |
+
|
| 332 |
+
}}
|
| 333 |
+
[class*="st-key-explain"]{{
|
| 334 |
+
background-image: url(data:image/png;base64,{base64.b64encode(open("gem.jpg", "rb").read()).decode()});
|
| 335 |
+
background-size: contain; /* size of the image */
|
| 336 |
+
background-repeat: no-repeat;
|
| 337 |
+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2); /* Shadow effect */
|
| 338 |
+
width:250px;
|
| 339 |
+
margin-left:370px;
|
| 340 |
+
border-radius: 30px;
|
| 341 |
+
height:50px !important;
|
| 342 |
+
margin-top:70px;
|
| 343 |
+
border-right:2px solid #4794ff;
|
| 344 |
+
border-left:2px solid #4794ff;
|
| 345 |
+
|
| 346 |
+
}}
|
| 347 |
+
[class*="st-key-explain"] > div.stButton > button{{
|
| 348 |
+
width:300px;
|
| 349 |
+
background: transparent;
|
| 350 |
+
border-radius:35px;
|
| 351 |
+
height:30px;
|
| 352 |
+
|
| 353 |
+
}}
|
| 354 |
+
[class*="st-key-explain"] > div.stButton > button p{{
|
| 355 |
+
margin-left:5px;
|
| 356 |
+
color :#0175C2 !important;
|
| 357 |
+
align-item:center;
|
| 358 |
+
font-size:14px !important;
|
| 359 |
+
margin-top:5px;
|
| 360 |
+
|
| 361 |
+
}}
|
| 362 |
+
|
| 363 |
+
[class*="st-key-explain"] > div.stButton{{
|
| 364 |
+
|
| 365 |
+
border-radius:35px;
|
| 366 |
+
|
| 367 |
+
|
| 368 |
+
}}
|
| 369 |
+
[class*="st-key-expert"]{{
|
| 370 |
+
overflow-y:scroll;
|
| 371 |
+
|
| 372 |
+
max-height:420px;
|
| 373 |
+
}}
|
| 374 |
+
[class*="st-key-step_"] {{
|
| 375 |
+
width:100px;
|
| 376 |
+
height:60px;
|
| 377 |
+
border-radius:50px;
|
| 378 |
+
margin-left:490px;
|
| 379 |
+
margin-bottom:20px;
|
| 380 |
+
margin-top:15px;
|
| 381 |
+
}}
|
| 382 |
+
[class*="st-key-step_1"] {{
|
| 383 |
+
background:{background};
|
| 384 |
+
border:2px solid {back1};
|
| 385 |
+
padding-left:{start1}px;
|
| 386 |
+
}}
|
| 387 |
+
[class*="st-key-step_2"] {{
|
| 388 |
+
border:2px solid {back2};
|
| 389 |
+
|
| 390 |
+
background:{background2};
|
| 391 |
+
padding-left:{start2}px;
|
| 392 |
+
}}
|
| 393 |
+
[class*="st-key-step_3"] {{
|
| 394 |
+
border:2px solid {back3};
|
| 395 |
+
|
| 396 |
+
background:{background3};
|
| 397 |
+
padding-left:{start3}px;
|
| 398 |
+
}}
|
| 399 |
+
[class*="st-key-step_4"] {{
|
| 400 |
+
border:2px solid {back4};
|
| 401 |
+
|
| 402 |
+
background:{background4};
|
| 403 |
+
padding-left:{start4}px;
|
| 404 |
+
}}
|
| 405 |
+
[class*="st-key-step_1"] > div.stButton > button{{
|
| 406 |
+
background:{fill} !important;
|
| 407 |
+
border:2px solid #00e7df;
|
| 408 |
+
}}
|
| 409 |
+
[class*="st-key-step_2"] > div.stButton > button{{
|
| 410 |
+
background:{fill2} !important;
|
| 411 |
+
border:2px solid #00e7df;
|
| 412 |
+
}}
|
| 413 |
+
[class*="st-key-step_3"] > div.stButton > button{{
|
| 414 |
+
background:{fill3} !important;
|
| 415 |
+
border:2px solid #00e7df;
|
| 416 |
+
}}
|
| 417 |
+
[class*="st-key-step_4"] > div.stButton > button{{
|
| 418 |
+
background:{fill4} !important;
|
| 419 |
+
border:2px solid #00e7df;
|
| 420 |
+
}}
|
| 421 |
+
[class*="st-key-step_"] > div.stButton > button{{
|
| 422 |
+
background:#e7e7e7;
|
| 423 |
+
border:2px solid linear-gradient(145deg, #007BFF, #005FCC);
|
| 424 |
+
}}
|
| 425 |
+
[class*="st-key-step_"] > div.stButton > button:active{{
|
| 426 |
+
border:2px solid green !important;
|
| 427 |
+
}}
|
| 428 |
+
[class*="st-key-step_"] > div.stButton > button:not(:active){{
|
| 429 |
+
border:2px solid #00e7df !important;
|
| 430 |
+
}}
|
| 431 |
+
|
| 432 |
+
section[data-testid="stMain"] {{
|
| 433 |
+
overflow:hidden !important;
|
| 434 |
+
|
| 435 |
+
}}
|
| 436 |
+
|
| 437 |
+
div[data-testid="stSlider"] {{
|
| 438 |
+
margin-top:45px;
|
| 439 |
+
}}
|
| 440 |
+
label[data-testid="stWidgetLabel"]{{
|
| 441 |
+
margin-left:20px !important;
|
| 442 |
+
}}
|
| 443 |
+
|
| 444 |
+
div[data-baseweb="slider"] {{
|
| 445 |
+
border-radius: 30px;
|
| 446 |
+
padding-right:40px;
|
| 447 |
+
z-index: 1;
|
| 448 |
+
/* Glass effect background */
|
| 449 |
+
backdrop-filter: blur(2px);
|
| 450 |
+
-webkit-backdrop-filter: blur(12px);
|
| 451 |
+
/* Shiny blue borders (left & right) */
|
| 452 |
+
border-top: 2px solid rgba(255, 255, 155, 0.4); /* Light border */
|
| 453 |
+
margin-left:13px;
|
| 454 |
+
border-bottom: 2px solid rgba(255, 255, 155, 0.4); /* Light border */
|
| 455 |
+
|
| 456 |
+
|
| 457 |
+
}}
|
| 458 |
+
div[data-baseweb="slider"] > :nth-child(1)> div {{
|
| 459 |
+
margin-left:20px !important;
|
| 460 |
+
margin-top:10px;
|
| 461 |
+
}}
|
| 462 |
+
div[data-testid="stSliderTickBarMin"]{{
|
| 463 |
+
background:none !important;
|
| 464 |
+
margin-left:20px !important;
|
| 465 |
+
font-size:12px;
|
| 466 |
+
margin-bottom:5px;
|
| 467 |
+
font-family: "Times New Roman " !important; /* Font */
|
| 468 |
+
}}
|
| 469 |
+
div[data-testid="stSliderTickBarMax"]{{
|
| 470 |
+
background:none !important;
|
| 471 |
+
font-size:12px;
|
| 472 |
+
margin-bottom:5px;
|
| 473 |
+
|
| 474 |
+
font-family: "Times New Roman " !important; /* Font */
|
| 475 |
+
}}
|
| 476 |
+
div[data-testid="stSliderThumbValue"]{{
|
| 477 |
+
font-size:12px;
|
| 478 |
+
font-family: "Times New Roman " !important; /* Font */
|
| 479 |
+
|
| 480 |
+
}}
|
| 481 |
+
div[data-testid="stProgress"]{{
|
| 482 |
+
margin-right:25px;
|
| 483 |
+
margin-top:-70px;
|
| 484 |
+
height:10px !important;
|
| 485 |
+
|
| 486 |
+
}}
|
| 487 |
+
[class*="st-key-content-container-3"] {{
|
| 488 |
+
margin-top: 50px; /* Adjust top margin */
|
| 489 |
+
margin-left:500px !important;
|
| 490 |
+
color:orange;
|
| 491 |
+
font-size:2.2rem;
|
| 492 |
+
|
| 493 |
+
}}
|
| 494 |
+
div[data-testid="stForm"]{{
|
| 495 |
+
|
| 496 |
+
|
| 497 |
+
|
| 498 |
+
}}
|
| 499 |
+
[class*="st-key-form-head"] {{
|
| 500 |
+
margin-top:-50px;
|
| 501 |
+
}}
|
| 502 |
+
[class*="st-key-form-head"] img {{
|
| 503 |
+
align-self:center;
|
| 504 |
+
width:40%;
|
| 505 |
+
margin-left:250px;
|
| 506 |
+
height:120px;
|
| 507 |
+
|
| 508 |
+
}}
|
| 509 |
+
|
| 510 |
+
[class*="st-key-form-content"] {{
|
| 511 |
+
margin-top:-50px;
|
| 512 |
+
height:450px;
|
| 513 |
+
border-radius:35px;
|
| 514 |
+
|
| 515 |
+
}}
|
| 516 |
+
[class*="st-key-form-content1"] {{
|
| 517 |
+
margin-top:25px;
|
| 518 |
+
height:450px;
|
| 519 |
+
border-radius:35px;
|
| 520 |
+
margin-bottom:15px;
|
| 521 |
+
border-top:none;
|
| 522 |
+
|
| 523 |
+
|
| 524 |
+
}}
|
| 525 |
+
[class*="st-key-currentSmoker"]>div>label>div > p {{
|
| 526 |
+
margin-left:-20px;
|
| 527 |
+
|
| 528 |
+
|
| 529 |
+
}}
|
| 530 |
+
|
| 531 |
+
[class*="st-key-form-content2"] {{
|
| 532 |
+
margin-top:25px;
|
| 533 |
+
height:450px;
|
| 534 |
+
border-radius:35px;
|
| 535 |
+
margin-bottom:15px;
|
| 536 |
+
|
| 537 |
+
}}
|
| 538 |
+
|
| 539 |
+
[class*="st-key-form-content3"] {{
|
| 540 |
+
margin-top:25px;
|
| 541 |
+
height:450px;
|
| 542 |
+
border-radius:35px;
|
| 543 |
+
margin-bottom:15px;
|
| 544 |
+
|
| 545 |
+
}}
|
| 546 |
+
|
| 547 |
+
/* Button row styling */
|
| 548 |
+
.button-row {{
|
| 549 |
+
display: flex;
|
| 550 |
+
justify-content: flex-start;
|
| 551 |
+
gap: 20px;
|
| 552 |
+
margin-bottom: 20px;
|
| 553 |
+
}}
|
| 554 |
+
|
| 555 |
+
|
| 556 |
+
|
| 557 |
+
.custom-button:hover {{
|
| 558 |
+
background-color: #0056b3;
|
| 559 |
+
}}
|
| 560 |
+
div.stButton > button p{{
|
| 561 |
+
color: green !important;
|
| 562 |
+
font-weight:bold;
|
| 563 |
+
}}
|
| 564 |
+
div.stButton > button {{
|
| 565 |
+
color: green !important; /* White text */
|
| 566 |
+
font-family: "Times New Roman " !important; /* Font */
|
| 567 |
+
font-size: 18px !important; /* Font size */
|
| 568 |
+
font-weight: bold !important; /* Bold text */
|
| 569 |
+
padding: 10px 20px; /* Padding for buttons */
|
| 570 |
+
border: none; /* Remove border */
|
| 571 |
+
border-radius: 35px; /* Rounded corners */
|
| 572 |
+
transition: all 0.3s ease-in-out; /* Smooth transition */
|
| 573 |
+
display: flex;
|
| 574 |
+
align-items: center;
|
| 575 |
+
transform: scale(1.05); /* Slightly enlarge button */
|
| 576 |
+
transform: scale(1.1); /* Slight zoom on hover */
|
| 577 |
+
justify-content: center;
|
| 578 |
+
|
| 579 |
+
|
| 580 |
+
|
| 581 |
+
}}
|
| 582 |
+
|
| 583 |
+
/* Hover effect */
|
| 584 |
+
div.stButton > button:hover {{
|
| 585 |
+
background: rgba(255, 255, 255, 0.2);
|
| 586 |
+
box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.4); /* Enhanced shadow on hover */
|
| 587 |
+
transform: scale(1.05); /* Slightly enlarge button */
|
| 588 |
+
transform: scale(1.1); /* Slight zoom on hover */
|
| 589 |
+
box-shadow: 0px 4px 12px rgba(255, 255, 255, 0.4); /* Glow effect */
|
| 590 |
+
}}
|
| 591 |
+
div[data-testid="stFormSubmitButton"] button{{
|
| 592 |
+
font-family: "Times New Roman " !important; /* Font */
|
| 593 |
+
font-size: 18px !important; /* Font size */
|
| 594 |
+
font-weight: bold !important; /* Bold text */
|
| 595 |
+
padding: 10px 20px; /* Padding for buttons */
|
| 596 |
+
border: none; /* Remove border */
|
| 597 |
+
border-radius: 35px; /* Rounded corners */
|
| 598 |
+
transition: all 0.3s ease-in-out; /* Smooth transition */
|
| 599 |
+
display: flex;
|
| 600 |
+
align-items: center;
|
| 601 |
+
transform: scale(1.05); /* Slightly enlarge button */
|
| 602 |
+
transform: scale(1.1); /* Slight zoom on hover */
|
| 603 |
+
justify-content: center;
|
| 604 |
+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2); /* Shadow effect */
|
| 605 |
+
width:110px;
|
| 606 |
+
|
| 607 |
+
}}
|
| 608 |
+
div[data-testid="stFormSubmitButton"] button:active{{
|
| 609 |
+
background-color: #6dc9e4 !important;
|
| 610 |
+
|
| 611 |
+
}}
|
| 612 |
+
|
| 613 |
+
div[data-testid="stMarkdownContainer"] p {{
|
| 614 |
+
font-family: "Times New Roman" !important; /* Elegant font for title */
|
| 615 |
+
color:black !important;
|
| 616 |
+
|
| 617 |
+
}}
|
| 618 |
+
.titles{{
|
| 619 |
+
margin-top:-60px !important;
|
| 620 |
+
margin-left:40px;
|
| 621 |
+
margin-bottom:50px;
|
| 622 |
+
text-align:center;
|
| 623 |
+
align-items:center;
|
| 624 |
+
z-index:10000;
|
| 625 |
+
position:relative;
|
| 626 |
+
font-family: "Times New Roman" !important;
|
| 627 |
+
|
| 628 |
+
}}
|
| 629 |
+
.header {{
|
| 630 |
+
align-items: center;
|
| 631 |
+
gap: 20px; /* Optional: adds space between image and text */
|
| 632 |
+
}}
|
| 633 |
+
|
| 634 |
+
/* Title styling */
|
| 635 |
+
.header h1{{
|
| 636 |
+
font-size: 1.7rem;
|
| 637 |
+
font-weight: bold;
|
| 638 |
+
margin-left: 5px;
|
| 639 |
+
/* margin-top:-100px;*/
|
| 640 |
+
margin-bottom:10px;
|
| 641 |
+
padding: 0;
|
| 642 |
+
color: black; /* Neutral color for text */
|
| 643 |
+
}}
|
| 644 |
+
|
| 645 |
+
|
| 646 |
+
.titles .content{{
|
| 647 |
+
font-family: "Times New Roman" !important; /* Elegant font for title */
|
| 648 |
+
font-size: 1rem;
|
| 649 |
+
margin-bottom:1px;
|
| 650 |
+
padding: 0;
|
| 651 |
+
color:black; /* Neutral color for text */
|
| 652 |
+
}}
|
| 653 |
+
|
| 654 |
+
|
| 655 |
+
|
| 656 |
+
</style>
|
| 657 |
+
|
| 658 |
+
""",
|
| 659 |
+
unsafe_allow_html=True,
|
| 660 |
+
)
|
| 661 |
+
# Overlay container
|
| 662 |
+
st.markdown(
|
| 663 |
+
f"""
|
| 664 |
+
<style>
|
| 665 |
+
.logo-text-containers {{
|
| 666 |
+
position: absolute;
|
| 667 |
+
top: -60px;
|
| 668 |
+
right: 40px;
|
| 669 |
+
background-color: rgba(255, 255, 255, 0.9);
|
| 670 |
+
padding: 15px;
|
| 671 |
+
border-radius: 12px;
|
| 672 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
| 673 |
+
z-index: 10;
|
| 674 |
+
width:80vw;
|
| 675 |
+
height:620px;
|
| 676 |
+
}}
|
| 677 |
+
.logo-text-containers img {{
|
| 678 |
+
height: 40px;
|
| 679 |
+
right:0;
|
| 680 |
+
}}
|
| 681 |
+
.logo-text-containers h1 {{
|
| 682 |
+
display: inline;
|
| 683 |
+
font-size: 20px;
|
| 684 |
+
vertical-align: middle;
|
| 685 |
+
}}
|
| 686 |
+
|
| 687 |
+
div[class*="st-key-try"] >div>button > div >p{{
|
| 688 |
+
top: 5px;
|
| 689 |
+
font-size: 30px !important;
|
| 690 |
+
font-weight: bold !important;
|
| 691 |
+
cursor: pointer;
|
| 692 |
+
color:orange !important;
|
| 693 |
+
z-index:1000;
|
| 694 |
+
}}
|
| 695 |
+
div[class*="st-key-try"] >div>button {{
|
| 696 |
+
height:70px !important;
|
| 697 |
+
width:250px !important;
|
| 698 |
+
background: rgba(255, 255, 255, 0.2) !important;
|
| 699 |
+
backdrop-filter: blur(10px) !important;
|
| 700 |
+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2); /* Shadow effect */
|
| 701 |
+
margin-left:20px;
|
| 702 |
+
|
| 703 |
+
|
| 704 |
+
|
| 705 |
+
}}
|
| 706 |
+
[class*="st-key-close-btn"]:hover {{
|
| 707 |
+
color: #f00;
|
| 708 |
+
}}
|
| 709 |
+
[class*="st-key-divider-col"] {{
|
| 710 |
+
border-left: 3px solid rgba(255, 255, 155, 0.5); /* Light border */
|
| 711 |
+
border-radius: 35px; /* Rounded corners */
|
| 712 |
+
margin-top:-15px;
|
| 713 |
+
margin-left:3px;
|
| 714 |
+
|
| 715 |
+
}}
|
| 716 |
+
[class*="st-key-col1"] {{
|
| 717 |
+
border-right: 3px solid rgba(255, 255, 155, 0.5); /* Light border */
|
| 718 |
+
border-radius: 35px; /* Rounded corners */
|
| 719 |
+
margin-left:20px;
|
| 720 |
+
margin-top:-15px;
|
| 721 |
+
|
| 722 |
+
}}
|
| 723 |
+
[class*="st-key-form"] >div >div >div >p {{
|
| 724 |
+
font-weight:bold;
|
| 725 |
+
color :green !important;
|
| 726 |
+
font-size:20px;
|
| 727 |
+
|
| 728 |
+
}}
|
| 729 |
+
[class*="st-key-logo-text-containers"] {{
|
| 730 |
+
margin: 10px; /* Set a margin inside the container */
|
| 731 |
+
max-width: 100%;
|
| 732 |
+
overflow: hidden;
|
| 733 |
+
|
| 734 |
+
position: absolute;
|
| 735 |
+
top:-43px;
|
| 736 |
+
left:10px;
|
| 737 |
+
overflow: hidden;
|
| 738 |
+
background-color: tansparent;
|
| 739 |
+
padding: 15px;
|
| 740 |
+
border-radius: 30px;
|
| 741 |
+
padding-right:40px;
|
| 742 |
+
z-index: 1;
|
| 743 |
+
width:88vw;
|
| 744 |
+
height:660px;
|
| 745 |
+
/* Glass effect background */
|
| 746 |
+
background: rgba(255, 255, 255, 0.15);
|
| 747 |
+
backdrop-filter: blur(12px);
|
| 748 |
+
-webkit-backdrop-filter: blur(12px);
|
| 749 |
+
/* Shiny blue borders (left & right) */
|
| 750 |
+
border-left: 3px solid rgba(255, 255, 255, 0.9); /* Light border */
|
| 751 |
+
border-right: 3px solid rgba(255, 255, 255, 0.9); /* Light border */
|
| 752 |
+
|
| 753 |
+
|
| 754 |
+
}}
|
| 755 |
+
|
| 756 |
+
@media (max-width: 768px) {{
|
| 757 |
+
.logo-text-container h1 {{
|
| 758 |
+
font-size: 12px;
|
| 759 |
+
|
| 760 |
+
}}
|
| 761 |
+
.logo-text-container i {{
|
| 762 |
+
font-size: 10px;
|
| 763 |
+
ma
|
| 764 |
+
}}
|
| 765 |
+
|
| 766 |
+
|
| 767 |
+
.logo-text-container img {{
|
| 768 |
+
width: 30px; /* Adjust logo size */
|
| 769 |
+
border-radius: 10px; /* Optional: round edges */
|
| 770 |
+
margin-left:15px;
|
| 771 |
+
margin-top: -35px;
|
| 772 |
+
|
| 773 |
+
}}
|
| 774 |
+
|
| 775 |
+
}}
|
| 776 |
+
</style>
|
| 777 |
+
""",
|
| 778 |
+
unsafe_allow_html=True,
|
| 779 |
+
)
|
| 780 |
+
st.markdown("""
|
| 781 |
+
<style>
|
| 782 |
+
/* Number input */
|
| 783 |
+
input:focus {
|
| 784 |
+
/* border: 2px solid grey !important; /* change to your desired color */
|
| 785 |
+
outline: none;
|
| 786 |
+
}
|
| 787 |
+
|
| 788 |
+
/* Radio buttons (kind of hacky since they use labels) */
|
| 789 |
+
.stRadio > div[role='radiogroup'] > label:focus-within {
|
| 790 |
+
border-radius: 4px;
|
| 791 |
+
}
|
| 792 |
+
div[data-testid="stTextInputRootElement"]{
|
| 793 |
+
border:1px solid #CCC;
|
| 794 |
+
}
|
| 795 |
+
div[data-testid="stNumberInputContainer"].focused{
|
| 796 |
+
border:1px solid #CCC !important;
|
| 797 |
+
|
| 798 |
+
}
|
| 799 |
+
|
| 800 |
+
button[data-testid="stNumberInputStepDown"]:hover:enabled,
|
| 801 |
+
button[data-testid="stNumberInputStepDown"]:focus:enabled{
|
| 802 |
+
background-color: #6dc9e4 !important;
|
| 803 |
+
}
|
| 804 |
+
button[data-testid="stNumberInputStepUp"]:hover:enabled,
|
| 805 |
+
button[data-testid="stNumberInputStepUp"]:focus:enabled{
|
| 806 |
+
background-color: #6dc9e4 !important;
|
| 807 |
+
}
|
| 808 |
+
label[data-baseweb="radio"]> :nth-child(1){
|
| 809 |
+
background-color: #6dc9e4 !important;
|
| 810 |
+
|
| 811 |
+
}
|
| 812 |
+
</style>
|
| 813 |
+
""", unsafe_allow_html=True)
|
| 814 |
+
|
| 815 |
+
st.markdown(
|
| 816 |
+
f""" <div class="logo-text-container">
|
| 817 |
+
<img src="data:image/png;base64,{base64.b64encode(open("download.png","rb").read()).decode()}" alt="Uploaded Image">
|
| 818 |
+
<h1>HeartCheck <span> AI </span> </h1>
|
| 819 |
+
</div>
|
| 820 |
+
|
| 821 |
+
""",
|
| 822 |
+
unsafe_allow_html=True,
|
| 823 |
+
)
|
| 824 |
+
|
| 825 |
+
|
| 826 |
+
|
| 827 |
+
st.markdown(
|
| 828 |
+
f""" <div class="titles">
|
| 829 |
+
<div class = "header">
|
| 830 |
+
<h1></br><span>Predict Your Risk, Protect Your Heart
|
| 831 |
+
</h1>
|
| 832 |
+
</div>
|
| 833 |
+
<div class="content">
|
| 834 |
+
HeartGuard uses intelligent risk analysis to predict your likelihood of <br>heart disease.
|
| 835 |
+
βempowering you with personalized insights, early warnings, and lifestyle tips to keep your heart healthy and strong.
|
| 836 |
+
</div>
|
| 837 |
+
</div>
|
| 838 |
+
""",
|
| 839 |
+
unsafe_allow_html=True,
|
| 840 |
+
)
|
| 841 |
+
|
| 842 |
+
|
| 843 |
+
with st.container(key = "main"):
|
| 844 |
+
col1,col2 = st.columns([3,3])
|
| 845 |
+
with col1:
|
| 846 |
+
with st.container(key= "side"):
|
| 847 |
+
if st.button("1",key="step_1"):
|
| 848 |
+
st.session_state.form1 = "back"
|
| 849 |
+
st.session_state.form2 = "back"
|
| 850 |
+
st.session_state.form3 = "back"
|
| 851 |
+
st.session_state.form4 = "back"
|
| 852 |
+
st.session_state.form5 = "back"
|
| 853 |
+
|
| 854 |
+
st.rerun()
|
| 855 |
+
if st.button("2",key="step_2"):
|
| 856 |
+
st.session_state.form2 = "back"
|
| 857 |
+
st.session_state.form3 = "back"
|
| 858 |
+
st.session_state.form4 = "back"
|
| 859 |
+
st.session_state.form5 = "back"
|
| 860 |
+
|
| 861 |
+
st.rerun()
|
| 862 |
+
if st.button("3",key="step_3"):
|
| 863 |
+
st.session_state.form3 = "back"
|
| 864 |
+
st.session_state.form4 = "back"
|
| 865 |
+
st.session_state.form5 = "back"
|
| 866 |
+
|
| 867 |
+
st.rerun()
|
| 868 |
+
if st.button("4",key="step_4"):
|
| 869 |
+
st.session_state.form4 = "back"
|
| 870 |
+
st.session_state.form5 = "back"
|
| 871 |
+
|
| 872 |
+
st.rerun()
|
| 873 |
+
|
| 874 |
+
with col2:
|
| 875 |
+
if st.session_state.form1 == "back":
|
| 876 |
+
with st.container(key="form1"):
|
| 877 |
+
st.write("π§ Step 1: Personal Info")
|
| 878 |
+
with st.container(key="form-head"):
|
| 879 |
+
st.image("icon.png")
|
| 880 |
+
with st.form( key="first"):
|
| 881 |
+
with st.container(key="form-content"):
|
| 882 |
+
# Input fields
|
| 883 |
+
st.session_state.name = st.text_input("Name", value=st.session_state.name)
|
| 884 |
+
st.session_state.age = st.number_input("Age", min_value=0, max_value=120, step=1, value=st.session_state.age)
|
| 885 |
+
st.session_state.gender = st.radio("Sex:", ["Male", "Female"], horizontal=True, index=0 if st.session_state.gender == "Male" else 1)
|
| 886 |
+
|
| 887 |
+
# Navigation buttons
|
| 888 |
+
col1, col2 = st.columns([4, 1])
|
| 889 |
+
next = col2.form_submit_button("Next β‘οΈ")
|
| 890 |
+
|
| 891 |
+
if next:
|
| 892 |
+
st.session_state.form1 = "next"
|
| 893 |
+
st.rerun()
|
| 894 |
+
elif st.session_state.form1 == "next" and st.session_state.form2 == "back":
|
| 895 |
+
with st.container(key="form2"):
|
| 896 |
+
st.write("π¬ Step 2: Clinical History")
|
| 897 |
+
|
| 898 |
+
st.radio("Do you currently smoke?", ["Yes", "No"], horizontal=True, key="currentSmoker")
|
| 899 |
+
print(st.session_state.currentSmoker)
|
| 900 |
+
with st.form("form_step_2"):
|
| 901 |
+
with st.container(key="form-content1"):
|
| 902 |
+
# Show 'cigsPerDay' only if smoker
|
| 903 |
+
if st.session_state.currentSmoker == "Yes":
|
| 904 |
+
if st.session_state.cigsPerDay == 0:
|
| 905 |
+
st.session_state.cigsPerDay = 1
|
| 906 |
+
else:
|
| 907 |
+
st.session_state.cigsPerDay = st.session_state.cigsPerDay
|
| 908 |
+
print(f"tessst:{st.session_state['currentSmoker']}")
|
| 909 |
+
|
| 910 |
+
st.session_state.cigsPerDay = st.number_input("How many cigarettes per day?", min_value=1, max_value=60, step=1,value = st.session_state.cigsPerDay)
|
| 911 |
+
else:
|
| 912 |
+
st.session_state.cigsPerDay = 0 # default to 0 if non-smoker
|
| 913 |
+
r1,r2 = st.columns([6,3])
|
| 914 |
+
with r1:
|
| 915 |
+
if st.session_state.BPMeds == "Yes":
|
| 916 |
+
bp = 0
|
| 917 |
+
else:
|
| 918 |
+
bp = 1
|
| 919 |
+
st.session_state.BPMeds = st.radio("Do you take blood pressure medication?", ["Yes", "No"], horizontal=True,index = bp)
|
| 920 |
+
with r2:
|
| 921 |
+
if st.session_state.diabetes == "Yes":
|
| 922 |
+
db = 0
|
| 923 |
+
else:
|
| 924 |
+
db = 1
|
| 925 |
+
st.session_state.diabetes = st.radio("Do you have diabetes?", ["Yes", "No"], horizontal=True,index = db )
|
| 926 |
+
|
| 927 |
+
|
| 928 |
+
col1, col2 = st.columns([4,1])
|
| 929 |
+
back = col1.form_submit_button("Back")
|
| 930 |
+
if back:
|
| 931 |
+
st.session_state.form1 = "back"
|
| 932 |
+
st.rerun()
|
| 933 |
+
next = col2.form_submit_button("Next")
|
| 934 |
+
if next:
|
| 935 |
+
st.session_state.form2 = "next"
|
| 936 |
+
st.rerun()
|
| 937 |
+
elif st.session_state.form2 == "next" and st.session_state.form3 == "back":
|
| 938 |
+
with st.container(key="form2"):
|
| 939 |
+
st.write("π Step 3: Vital Signs & Cholesterol")
|
| 940 |
+
|
| 941 |
+
with st.form("form_step_2"):
|
| 942 |
+
with st.container(key="form-content2"):
|
| 943 |
+
# Step 3 inputs
|
| 944 |
+
|
| 945 |
+
st.session_state.totChol = st.number_input("Total Cholesterol (mg/dL)", min_value=100, max_value=400, step=1,value= st.session_state.totChol)
|
| 946 |
+
st.session_state.sysBP = st.number_input("Systolic Blood Pressure (mmHg)", min_value=80, max_value=250, step=1,value = st.session_state.sysBP)
|
| 947 |
+
st.session_state.diaBP = st.number_input("Diastolic Blood Pressure (mmHg)", min_value=50, max_value=150, step=1,value= st.session_state.diaBP)
|
| 948 |
+
|
| 949 |
+
|
| 950 |
+
col1, col2 = st.columns([4,1])
|
| 951 |
+
back = col1.form_submit_button("Back")
|
| 952 |
+
if back:
|
| 953 |
+
st.session_state.form2 = "back"
|
| 954 |
+
|
| 955 |
+
st.rerun()
|
| 956 |
+
next = col2.form_submit_button("Next")
|
| 957 |
+
if next:
|
| 958 |
+
st.session_state.form3 = "next"
|
| 959 |
+
st.rerun()
|
| 960 |
+
elif st.session_state.form3 == "next" and st.session_state.form4 == "back":
|
| 961 |
+
with st.container(key="form3"):
|
| 962 |
+
st.write("π§ͺ Step 4: Body Metrics & Glucose")
|
| 963 |
+
|
| 964 |
+
with st.form("form_step_3"):
|
| 965 |
+
with st.container(key="form-content3"):
|
| 966 |
+
# Step 3 inputs
|
| 967 |
+
|
| 968 |
+
st.session_state.BMI = st.number_input("Body Mass Index (BMI)", min_value=10.0, max_value=60.0, step=0.1,value=st.session_state.BMI)
|
| 969 |
+
st.session_state.heartRate = st.number_input("Heart Rate (bpm)", min_value=40, max_value=200, step=1,value= st.session_state.heartRate)
|
| 970 |
+
st.session_state.glucose = st.number_input("Glucose Level (mg/dL)", min_value=50, max_value=300, step=1,value= st.session_state.glucose)
|
| 971 |
+
|
| 972 |
+
|
| 973 |
+
col1, col2 = st.columns([4,1])
|
| 974 |
+
back = col1.form_submit_button("Back")
|
| 975 |
+
if back:
|
| 976 |
+
st.session_state.form3 = "back"
|
| 977 |
+
|
| 978 |
+
st.rerun()
|
| 979 |
+
next = col2.form_submit_button("Next")
|
| 980 |
+
if next:
|
| 981 |
+
st.session_state.form4 = "next"
|
| 982 |
+
st.rerun()
|
| 983 |
+
elif st.session_state.form4 == "next" and st.session_state.form5 == "back":
|
| 984 |
+
|
| 985 |
+
# Construct input array from collected values
|
| 986 |
+
new_data = np.array([[
|
| 987 |
+
1 if st.session_state.gender == "Male" else 0, # gender
|
| 988 |
+
st.session_state.age,
|
| 989 |
+
1 if st.session_state.currentSmoker == "Yes" else 0,
|
| 990 |
+
float(st.session_state.cigsPerDay),
|
| 991 |
+
1.0 if st.session_state.BPMeds else 0.0,
|
| 992 |
+
1 if st.session_state.diabetes else 0,
|
| 993 |
+
st.session_state.totChol,
|
| 994 |
+
st.session_state.sysBP,
|
| 995 |
+
st.session_state.diaBP,
|
| 996 |
+
st.session_state.BMI,
|
| 997 |
+
st.session_state.heartRate,
|
| 998 |
+
st.session_state.glucose
|
| 999 |
+
]])
|
| 1000 |
+
loading_placeholder = st.empty()
|
| 1001 |
+
|
| 1002 |
+
with loading_placeholder.container():
|
| 1003 |
+
# Make prediction
|
| 1004 |
+
with st.spinner("Analyzing your heart health..."):
|
| 1005 |
+
st.image('load.gif', use_container_width=True)
|
| 1006 |
+
time.sleep(3) # Wait for 1 second
|
| 1007 |
+
# Remove the loading image
|
| 1008 |
+
loading_placeholder.empty()
|
| 1009 |
+
prediction = best_clf.predict(new_data)
|
| 1010 |
+
prediction_proba = best_clf.predict_proba(new_data)
|
| 1011 |
+
st.session_state.Risk = prediction
|
| 1012 |
+
risk_percent = prediction_proba[0][1]*100
|
| 1013 |
+
risk_label = "At Risk of having a heart failure"
|
| 1014 |
+
st.session_state.proba = risk_percent
|
| 1015 |
+
|
| 1016 |
+
name = st.session_state.name # Get from session or fallback
|
| 1017 |
+
with st.container(key = "result"):
|
| 1018 |
+
# Display result
|
| 1019 |
+
st.markdown(f"""
|
| 1020 |
+
<div class = "result" style="text-align: center; padding-top: 30px;">
|
| 1021 |
+
<h1 style="color: #444;">Hi {name} π, you are</h1>
|
| 1022 |
+
<h1 class = "name" style="font-size: 80px; color: #0175C2; margin-top: -5px ;">{risk_percent:.2f}%</h1>
|
| 1023 |
+
<h3 style="color: {'#d9534f' if prediction == 1 else '#28a745'}; margin-bottom: 10px;">{risk_label}</h3>
|
| 1024 |
+
</div>
|
| 1025 |
+
""", unsafe_allow_html=True)
|
| 1026 |
+
st.session_state.form5 = "next"
|
| 1027 |
+
|
| 1028 |
+
if st.button("explain the result", key = "explain"):
|
| 1029 |
+
st.session_state.form5 = "next"
|
| 1030 |
+
st.rerun()
|
| 1031 |
+
|
| 1032 |
+
elif st.session_state.form5 == "next" :
|
| 1033 |
+
model = genai.GenerativeModel('gemini-2.0-flash')
|
| 1034 |
+
with st.container(key = "expert"):
|
| 1035 |
+
with st.spinner("Model is generating a response..."):
|
| 1036 |
+
response = model.generate_content(f"""
|
| 1037 |
+
Hi! A person named {st.session_state.name} has just been assessed for heart disease risk.
|
| 1038 |
+
|
| 1039 |
+
π **Prediction**: {"High Risk" if st.session_state.Risk == 1 else "Low Risk"}
|
| 1040 |
+
π **Risk Percentage**: {st.session_state.proba:.2f}%
|
| 1041 |
+
|
| 1042 |
+
π **Input Parameters**:
|
| 1043 |
+
- Sex: {st.session_state.gender}
|
| 1044 |
+
- Age: {st.session_state.age}
|
| 1045 |
+
- Current Smoker: {st.session_state.currentSmoker}
|
| 1046 |
+
- Cigarettes per Day: {st.session_state.cigsPerDay}
|
| 1047 |
+
- On Blood Pressure Meds: {"Yes" if st.session_state.BPMeds else "No"}
|
| 1048 |
+
- Has Diabetes: {"Yes" if st.session_state.diabetes else "No"}
|
| 1049 |
+
- Total Cholesterol: {st.session_state.totChol} mg/dL
|
| 1050 |
+
- Systolic BP: {st.session_state.sysBP} mmHg
|
| 1051 |
+
- Diastolic BP: {st.session_state.diaBP} mmHg
|
| 1052 |
+
- BMI: {st.session_state.BMI}
|
| 1053 |
+
- Heart Rate: {st.session_state.heartRate} bpm
|
| 1054 |
+
- Glucose: {st.session_state.glucose} mg/dL
|
| 1055 |
+
|
| 1056 |
+
π¬ Please give a personalized, kind, and easy-to-understand explanation of this result. Include practical lifestyle advice and possible early warning signs to watch out for. Use an encouraging, empathetic tone.
|
| 1057 |
+
""")
|
| 1058 |
+
st.markdown(f"""
|
| 1059 |
+
<div style="
|
| 1060 |
+
font-size: 18px;
|
| 1061 |
+
font-weight: 600;
|
| 1062 |
+
color: #0175C2;
|
| 1063 |
+
margin-top: 5px;
|
| 1064 |
+
margin-bottom: 20px;
|
| 1065 |
+
padding: 10px 20px;
|
| 1066 |
+
border-radius: 10px;
|
| 1067 |
+
background: #f4faff;
|
| 1068 |
+
display: flex;
|
| 1069 |
+
align-items: center;
|
| 1070 |
+
justify-content: center;
|
| 1071 |
+
margin-left:-20px !important;
|
| 1072 |
+
gap: 15px;
|
| 1073 |
+
font-family: 'Times New Roman', Times, serif;
|
| 1074 |
+
">
|
| 1075 |
+
<img src="data:image/png;base64,{base64.b64encode(open("gem.png","rb").read()).decode()}" alt="Uploaded Image"width="40" height="40" style="margin-right: 10px;" >
|
| 1076 |
+
Personalized Heart Health Advice
|
| 1077 |
+
</div>
|
| 1078 |
+
""", unsafe_allow_html=True)
|
| 1079 |
+
|
| 1080 |
+
st.write(response.text)
|
| 1081 |
+
|
| 1082 |
+
|
| 1083 |
+
|
| 1084 |
+
|