Spaces:
Sleeping
Sleeping
Update app.py
Browse filesupload app script
app.py
CHANGED
|
@@ -35,26 +35,33 @@ def predict_heart_disease(age, sex, cp, restbp, chol, thalach, exang, ca, thal):
|
|
| 35 |
|
| 36 |
return f"{result_text}<br><div style='margin-top: 10px; color: #a1a1aa;'>Confidence: {confidence*100:.2f}%</div>"
|
| 37 |
|
| 38 |
-
# --- 3. Custom CSS for
|
| 39 |
custom_css = """
|
| 40 |
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
|
| 41 |
.gradio-container { background-color: #1f2937; border-radius: 15px !important; }
|
| 42 |
|
| 43 |
-
/*
|
| 44 |
-
.gradio-
|
| 45 |
-
.gradio-radio-button.selected { background-color: #34d399 !important; color: white !important; border-color: #34d399 !important; }
|
| 46 |
-
|
| 47 |
-
/* Slider Color */
|
| 48 |
-
.gradio-slider-track-color { background-color: #60a5fa !important; }
|
| 49 |
|
| 50 |
-
/* Button
|
| 51 |
#buttons-row { display: flex; gap: 10px; justify-content: center; width: 100%; }
|
| 52 |
#buttons-row > button { flex-grow: 1; }
|
| 53 |
.gradio-button { transition: all 0.2s ease-in-out !important; transform: scale(1.0); }
|
| 54 |
.gradio-button:hover { transform: scale(1.03); filter: brightness(1.1); }
|
| 55 |
.gradio-button:active { transform: scale(0.98); }
|
| 56 |
|
| 57 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
#result-box {
|
| 59 |
background-color: #374151; border: 1px solid #4b5563; padding: 20px;
|
| 60 |
border-radius: 10px; text-align: center; min-height: 120px;
|
|
@@ -63,18 +70,16 @@ body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
|
|
| 63 |
}
|
| 64 |
"""
|
| 65 |
|
| 66 |
-
# --- 4. Define the Custom Theme
|
| 67 |
-
#
|
| 68 |
-
theme = gr.themes.Soft(
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
block_label_text_color_dark="#f97316", # Orange color for labels in dark mode
|
| 72 |
-
block_label_text_color="#f97316" # Orange color for labels in light mode
|
| 73 |
)
|
| 74 |
|
| 75 |
|
| 76 |
# --- 5. Build the UI with Gradio Blocks ---
|
| 77 |
-
with gr.Blocks(theme=theme, css=custom_css) as demo:
|
| 78 |
gr.Markdown("# ❤️ CardioCompass: Heart Disease Predictor")
|
| 79 |
gr.Markdown("Enter patient details to predict the likelihood of having heart disease.")
|
| 80 |
|
|
@@ -93,8 +98,8 @@ with gr.Blocks(theme=theme, css=custom_css) as demo: # We pass our new theme obj
|
|
| 93 |
with gr.Column(scale=1):
|
| 94 |
result_out = gr.HTML(value="<div style='color: #9ca3af;'>Prediction will appear here...</div>", elem_id="result-box")
|
| 95 |
with gr.Row(elem_id="buttons-row"):
|
| 96 |
-
clear_button = gr.ClearButton(value="Clear")
|
| 97 |
-
submit_button = gr.Button("Submit", variant="primary")
|
| 98 |
|
| 99 |
# --- 6. Connect the components ---
|
| 100 |
inputs_list = [age_in, sex_in, cp_in, restbp_in, chol_in, thalach_in, exang_in, ca_in, thal_in]
|
|
@@ -104,8 +109,6 @@ with gr.Blocks(theme=theme, css=custom_css) as demo: # We pass our new theme obj
|
|
| 104 |
# --- 7. Launch the App ---
|
| 105 |
demo.launch(share=True)
|
| 106 |
|
| 107 |
-
|
| 108 |
-
|
| 109 |
|
| 110 |
|
| 111 |
|
|
|
|
| 35 |
|
| 36 |
return f"{result_text}<br><div style='margin-top: 10px; color: #a1a1aa;'>Confidence: {confidence*100:.2f}%</div>"
|
| 37 |
|
| 38 |
+
# --- 3. Custom CSS for Specific Component Styling ---
|
| 39 |
custom_css = """
|
| 40 |
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
|
| 41 |
.gradio-container { background-color: #1f2937; border-radius: 15px !important; }
|
| 42 |
|
| 43 |
+
/* --- Slider Color is now BLUE --- */
|
| 44 |
+
.gradio-slider-track-color { background-color: #3b82f6 !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
/* --- Button Colors and Interactivity --- */
|
| 47 |
#buttons-row { display: flex; gap: 10px; justify-content: center; width: 100%; }
|
| 48 |
#buttons-row > button { flex-grow: 1; }
|
| 49 |
.gradio-button { transition: all 0.2s ease-in-out !important; transform: scale(1.0); }
|
| 50 |
.gradio-button:hover { transform: scale(1.03); filter: brightness(1.1); }
|
| 51 |
.gradio-button:active { transform: scale(0.98); }
|
| 52 |
|
| 53 |
+
/* Submit button is now RED */
|
| 54 |
+
.gradio-button.primary { background-color: #ef4444 !important; border-color: #ef4444 !important; }
|
| 55 |
+
.gradio-button.primary:hover { background-color: #dc2626 !important; border-color: #dc2626 !important; }
|
| 56 |
+
|
| 57 |
+
/* Clear button is now GRAY */
|
| 58 |
+
.gradio-button.secondary { background-color: #6b7280 !important; border-color: #6b7280 !important; }
|
| 59 |
+
.gradio-button.secondary:hover { background-color: #4b5563 !important; border-color: #4b5563 !important; }
|
| 60 |
+
|
| 61 |
+
/* --- Radio Button Color (Selected) --- */
|
| 62 |
+
.gradio-radio-button.selected { background-color: #34d399 !important; color: white !important; border-color: #34d399 !important; }
|
| 63 |
+
|
| 64 |
+
/* --- Permanent Result Box Styling (No changes here) --- */
|
| 65 |
#result-box {
|
| 66 |
background-color: #374151; border: 1px solid #4b5563; padding: 20px;
|
| 67 |
border-radius: 10px; text-align: center; min-height: 120px;
|
|
|
|
| 70 |
}
|
| 71 |
"""
|
| 72 |
|
| 73 |
+
# --- 4. Define the Custom Theme for ORANGE Labels ---
|
| 74 |
+
# We removed primary_hue and are only setting the label color here.
|
| 75 |
+
theme = gr.themes.Soft().set(
|
| 76 |
+
block_label_text_color_dark="#f97316", # Orange color for labels
|
| 77 |
+
block_label_text_color="#f97316"
|
|
|
|
|
|
|
| 78 |
)
|
| 79 |
|
| 80 |
|
| 81 |
# --- 5. Build the UI with Gradio Blocks ---
|
| 82 |
+
with gr.Blocks(theme=theme, css=custom_css) as demo:
|
| 83 |
gr.Markdown("# ❤️ CardioCompass: Heart Disease Predictor")
|
| 84 |
gr.Markdown("Enter patient details to predict the likelihood of having heart disease.")
|
| 85 |
|
|
|
|
| 98 |
with gr.Column(scale=1):
|
| 99 |
result_out = gr.HTML(value="<div style='color: #9ca3af;'>Prediction will appear here...</div>", elem_id="result-box")
|
| 100 |
with gr.Row(elem_id="buttons-row"):
|
| 101 |
+
clear_button = gr.ClearButton(value="Clear", variant="secondary") # Using secondary variant
|
| 102 |
+
submit_button = gr.Button("Submit", variant="primary") # Using primary variant
|
| 103 |
|
| 104 |
# --- 6. Connect the components ---
|
| 105 |
inputs_list = [age_in, sex_in, cp_in, restbp_in, chol_in, thalach_in, exang_in, ca_in, thal_in]
|
|
|
|
| 109 |
# --- 7. Launch the App ---
|
| 110 |
demo.launch(share=True)
|
| 111 |
|
|
|
|
|
|
|
| 112 |
|
| 113 |
|
| 114 |
|