CoolFace
Apppublic

DevakiPHuggingface/CKD_prediction_system

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes
app.py114 linesDownload Raw Back to root
1import streamlit as st
2import pickle
3import numpy as np
4
5# Load model
6model = pickle.load(open("model.pkl", "rb"))
7
8st.set_page_config(page_title="CKD Prediction", layout="wide")
9
10# ๐ŸŽจ Styling
11st.markdown("""
12<style>
13body {
14    background-color: #f4f8fb;
15}
16h1 {
17    color: #1f77b4;
18}
19.section {
20    background-color: white;
21    padding: 20px;
22    border-radius: 12px;
23    box-shadow: 0px 0px 8px rgba(0,0,0,0.1);
24}
25</style>
26""", unsafe_allow_html=True)
27
28# ๐Ÿฅ HEADER
29st.markdown("<h1 style='text-align:center;'>๐Ÿฉบ CKD Prediction System</h1>", unsafe_allow_html=True)
30st.markdown("<p style='text-align:center; color:gray;'>AI-based Kidney Disease Detection Platform</p>", unsafe_allow_html=True)
31
32st.markdown("---")
33
34# ๐Ÿ“ LAYOUT
35left, center, right = st.columns([1,2,1])
36
37# ๐Ÿ–ผ๏ธ LEFT SIDE (Kidney + Medical Icons)
38with left:
39    st.image("https://cdn-icons-png.flaticon.com/512/2966/2966487.png", width=150)
40    st.caption("Kidney Health")
41
42    st.image("https://cdn-icons-png.flaticon.com/512/2966/2966334.png", width=120)
43    st.caption("Blood Pressure")
44
45# ๐Ÿ“‹ CENTER FORM
46with center:
47    st.markdown('<div class="section">', unsafe_allow_html=True)
48    st.markdown("### ๐Ÿงพ Patient Details")
49
50    col1, col2 = st.columns(2)
51
52    with col1:
53        age = st.number_input("Age", 1, 100)
54        bp = st.number_input("Blood Pressure")
55        sg = st.number_input("Specific Gravity")
56        al = st.number_input("Albumin")
57        su = st.number_input("Sugar")
58
59    with col2:
60        hemo = st.number_input("Hemoglobin")
61        pcv = st.number_input("Packed Cell Volume")
62        wc = st.number_input("WBC Count")
63        rc = st.number_input("RBC Count")
64
65    st.markdown("<br>", unsafe_allow_html=True)
66
67    if st.button("๐Ÿ” Predict", use_container_width=True):
68        features = np.array([[age, bp, sg, al, su, hemo, pcv, wc, rc]])
69        prediction = model.predict(features)
70
71        st.markdown("---")
72
73        if prediction[0] == 0:
74            st.error("โš ๏ธ Chronic Kidney Disease Detected")
75
76            st.markdown("### ๐Ÿ’Š Recommended Care")
77            st.markdown("""
78            <div style="background-color:#ffe6e6; padding:15px; border-radius:10px;">
79            โœ” Reduce salt intake<br>
80            โœ” Control blood pressure<br>
81            โœ” Drink water as advised<br>
82            โœ” Avoid processed foods<br>
83            โœ” Regular doctor consultation<br>
84            โœ” Monitor kidney function<br>
85            </div>
86            """, unsafe_allow_html=True)
87
88        else:
89            st.success("โœ… No Kidney Disease Detected")
90
91            st.markdown("### ๐ŸŒฟ Healthy Lifestyle Tips")
92            st.markdown("""
93            <div style="background-color:#e6ffe6; padding:15px; border-radius:10px;">
94            โœ” Stay hydrated<br>
95            โœ” Balanced diet<br>
96            โœ” Exercise regularly<br>
97            โœ” Avoid excess salt<br>
98            โœ” Routine health checkups<br>
99            </div>
100            """, unsafe_allow_html=True)
101
102    st.markdown('</div>', unsafe_allow_html=True)
103
104# ๐Ÿฅ RIGHT SIDE (Hospital + Health Icons)
105with right:
106    st.image("https://cdn-icons-png.flaticon.com/512/3209/3209265.png", width=150)
107    st.caption("Hospital Care")
108
109    st.image("https://cdn-icons-png.flaticon.com/512/387/387561.png", width=120)
110    st.caption("Healthcare Monitoring")
111
112# Footer
113st.markdown("---")
114st.markdown("<p style='text-align:center; color:gray;'>๐Ÿฅ CKD ML Project | Smart Healthcare System</p>", unsafe_allow_html=True)