Update app.py
Browse files
app.py
CHANGED
|
@@ -4,18 +4,25 @@ import gradio as gr
|
|
| 4 |
from components.auth import register, login, logout
|
| 5 |
from components.predict import predict
|
| 6 |
|
| 7 |
-
# --- 1. New Theme and Style ---
|
| 8 |
-
# We
|
| 9 |
-
# Custom CSS
|
| 10 |
-
theme = gr.themes.
|
| 11 |
-
primary_hue="
|
| 12 |
-
secondary_hue="
|
| 13 |
neutral_hue="slate"
|
| 14 |
-
).set(
|
| 15 |
-
body_background_fill='linear-gradient(to right, #F0F8FF, #E6E6FA)',
|
| 16 |
)
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# A state object to hold the user's session information
|
| 21 |
user_state = gr.State({"email": None, "logged_in": False})
|
|
@@ -23,7 +30,7 @@ with gr.Blocks(title="Diabetech Predict", theme=theme, css=".gradio-container {m
|
|
| 23 |
# --- Header ---
|
| 24 |
with gr.Row(equal_height=False):
|
| 25 |
with gr.Column(scale=4):
|
| 26 |
-
gr.Markdown("# 🩺 Welcome to
|
| 27 |
gr.Markdown("#### Your Proactive Partner in Health Awareness")
|
| 28 |
|
| 29 |
with gr.Column(scale=1, min_width=200):
|
|
@@ -37,49 +44,52 @@ with gr.Blocks(title="Diabetech Predict", theme=theme, css=".gradio-container {m
|
|
| 37 |
# --- Main Tabs ---
|
| 38 |
with gr.Tabs():
|
| 39 |
|
| 40 |
-
# --- 2.
|
| 41 |
with gr.TabItem("Home"):
|
| 42 |
-
gr.Markdown("## Understand Your Diabetes Risk, Privately and Securely")
|
| 43 |
gr.Markdown(
|
| 44 |
-
""
|
| 45 |
-
|
| 46 |
-
By using a machine learning model, our application provides an instant analysis based on key health metrics. This is not a diagnosis, but an educational first step to empower you on your health journey.
|
| 47 |
-
"""
|
| 48 |
)
|
| 49 |
-
gr.Markdown("---")
|
| 50 |
-
|
| 51 |
-
with gr.Row():
|
| 52 |
-
with gr.Column():
|
| 53 |
-
gr.Markdown("### Why Use Diabetech Predict?")
|
| 54 |
-
gr.Markdown(
|
| 55 |
-
"""
|
| 56 |
-
* **📈 Gain Insight:** Learn how different health factors like Glucose levels and BMI contribute to your risk profile.
|
| 57 |
-
* **🧠 Promote Awareness:** Being aware of potential risks is the first step towards preventive care and healthier lifestyle choices.
|
| 58 |
-
* **🔒 Completely Private:** Your data is your own. With our secure login system, your prediction history is tied to your account and is never shared.
|
| 59 |
-
"""
|
| 60 |
-
)
|
| 61 |
-
with gr.Column():
|
| 62 |
-
gr.Markdown("### How It Works")
|
| 63 |
-
gr.Markdown(
|
| 64 |
-
"""
|
| 65 |
-
1. **Create Your Secure Account:** Use the 'Login / Signup' tab to create a free, private account.
|
| 66 |
-
2. **Enter Your Health Metrics:** Navigate to the 'Prediction' tab and input your information into the provided fields.
|
| 67 |
-
3. **Receive Your Instant Analysis:** Our model will provide an immediate risk assessment based on the data you provided.
|
| 68 |
-
"""
|
| 69 |
-
)
|
| 70 |
-
|
| 71 |
-
gr.Markdown("### An Important Note on Your Health")
|
| 72 |
gr.Markdown(
|
| 73 |
"""
|
| 74 |
-
|
| 75 |
-
|
| 76 |
"""
|
| 77 |
)
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
with gr.TabItem("Login / Signup"):
|
| 82 |
-
auth_message = gr.Markdown()
|
| 83 |
with gr.Row():
|
| 84 |
with gr.Column(scale=1):
|
| 85 |
gr.Markdown("### Sign Up")
|
|
@@ -100,7 +110,7 @@ with gr.Blocks(title="Diabetech Predict", theme=theme, css=".gradio-container {m
|
|
| 100 |
|
| 101 |
logout_btn = gr.Button("Logout")
|
| 102 |
|
| 103 |
-
# --- Prediction Tab (No changes
|
| 104 |
with gr.TabItem("Prediction"):
|
| 105 |
with gr.Row():
|
| 106 |
with gr.Column():
|
|
|
|
| 4 |
from components.auth import register, login, logout
|
| 5 |
from components.predict import predict
|
| 6 |
|
| 7 |
+
# --- 1. New High-Contrast Theme and Custom Style ---
|
| 8 |
+
# We use the Monochrome theme for maximum text visibility and a clean look.
|
| 9 |
+
# Custom CSS provides a soft background and centers key text elements.
|
| 10 |
+
theme = gr.themes.Monochrome(
|
| 11 |
+
primary_hue="indigo",
|
| 12 |
+
secondary_hue="blue",
|
| 13 |
neutral_hue="slate"
|
|
|
|
|
|
|
| 14 |
)
|
| 15 |
|
| 16 |
+
css = """
|
| 17 |
+
.gradio-container {
|
| 18 |
+
max-width: 1000px !important;
|
| 19 |
+
margin: auto !important;
|
| 20 |
+
background-color: #F7F7F7 !important; /* Soft off-white background for the whole app */
|
| 21 |
+
}
|
| 22 |
+
.centered-text { text-align: center; }
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
with gr.Blocks(title="DiaSpark: Your spark for early detection", theme=theme, css=css) as demo:
|
| 26 |
|
| 27 |
# A state object to hold the user's session information
|
| 28 |
user_state = gr.State({"email": None, "logged_in": False})
|
|
|
|
| 30 |
# --- Header ---
|
| 31 |
with gr.Row(equal_height=False):
|
| 32 |
with gr.Column(scale=4):
|
| 33 |
+
gr.Markdown("# 🩺 Welcome to DiaSpark : An AI based Diabetes Detector")
|
| 34 |
gr.Markdown("#### Your Proactive Partner in Health Awareness")
|
| 35 |
|
| 36 |
with gr.Column(scale=1, min_width=200):
|
|
|
|
| 44 |
# --- Main Tabs ---
|
| 45 |
with gr.Tabs():
|
| 46 |
|
| 47 |
+
# --- 2. Redesigned Homepage with Accordions for a Clean Look ---
|
| 48 |
with gr.TabItem("Home"):
|
|
|
|
| 49 |
gr.Markdown(
|
| 50 |
+
"<h2 class='centered-text'>A Smart First Step in Understanding Your Health</h2>",
|
| 51 |
+
elem_classes="centered-text"
|
|
|
|
|
|
|
| 52 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
gr.Markdown(
|
| 54 |
"""
|
| 55 |
+
DiaSpark is a confidential tool that uses machine learning to provide an educational analysis of your diabetes risk factors.
|
| 56 |
+
Our goal is to promote health awareness, not to provide a medical diagnosis.
|
| 57 |
"""
|
| 58 |
)
|
| 59 |
+
gr.Markdown("---")
|
| 60 |
+
|
| 61 |
+
# Accordion layout prevents a cluttered look
|
| 62 |
+
with gr.Accordion("🎯 Our Mission: The 'Why'", open=True):
|
| 63 |
+
gr.Markdown(
|
| 64 |
+
"""
|
| 65 |
+
We believe that awareness is the first and most powerful step towards a healthier life.
|
| 66 |
+
This tool was built to help you:
|
| 67 |
+
* **Gain Insight:** Understand how key health metrics can contribute to your overall risk profile.
|
| 68 |
+
* **Encourage Proactive Care:** Use this information as a starting point for meaningful conversations with your doctor.
|
| 69 |
+
* **Do It All Privately:** Your health data is sensitive. Our secure login ensures your prediction history is for your eyes only.
|
| 70 |
+
"""
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
with gr.Accordion("🚀 Getting Started: The 'How'", open=False):
|
| 74 |
+
gr.Markdown(
|
| 75 |
+
"""
|
| 76 |
+
1. **Create Your Secure Account:** Navigate to the **'Login / Signup'** tab. The process is quick and requires only an email and password.
|
| 77 |
+
2. **Enter Your Health Metrics:** Once logged in, go to the **'Prediction'** tab. Fill in the fields with your most recent health information.
|
| 78 |
+
3. **Receive Your Instant Analysis:** Click the 'Predict My Risk' button. Our AI model will provide an immediate, educational assessment based on your data.
|
| 79 |
+
"""
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
with gr.Accordion("⚠️ Important Disclaimer", open=False):
|
| 83 |
+
gr.Markdown(
|
| 84 |
+
"""
|
| 85 |
+
**This tool is NOT a substitute for professional medical advice, diagnosis, or treatment.**
|
| 86 |
+
The results from DiaSpark are for informational purposes only. Always seek the advice of your physician or another qualified health provider with any questions you may have regarding a medical condition. Never disregard professional medical advice or delay in seeking it because of something you have read or seen on this application.
|
| 87 |
+
"""
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
# --- Authentication Tab (No changes needed, theme will fix visibility) ---
|
| 91 |
with gr.TabItem("Login / Signup"):
|
| 92 |
+
auth_message = gr.Markdown()
|
| 93 |
with gr.Row():
|
| 94 |
with gr.Column(scale=1):
|
| 95 |
gr.Markdown("### Sign Up")
|
|
|
|
| 110 |
|
| 111 |
logout_btn = gr.Button("Logout")
|
| 112 |
|
| 113 |
+
# --- Prediction Tab (No changes needed, theme will fix visibility) ---
|
| 114 |
with gr.TabItem("Prediction"):
|
| 115 |
with gr.Row():
|
| 116 |
with gr.Column():
|