Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,10 +42,14 @@ transform = T.Compose([
|
|
| 42 |
])
|
| 43 |
|
| 44 |
# ==========================================
|
| 45 |
-
# 4.
|
| 46 |
# ==========================================
|
| 47 |
-
#
|
| 48 |
-
waiting_text = "
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
def predict(image):
|
| 51 |
if image is None:
|
|
@@ -66,8 +70,14 @@ def predict(image):
|
|
| 66 |
top_class = max(confidences, key=confidences.get)
|
| 67 |
top_score = confidences[top_class]
|
| 68 |
|
| 69 |
-
# Styled Success
|
| 70 |
-
message = f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
return confidences, message
|
| 73 |
|
|
@@ -121,10 +131,12 @@ with gr.Blocks(theme=theme, css=custom_css) as demo:
|
|
| 121 |
|
| 122 |
# Left Column: Inputs
|
| 123 |
with gr.Column(scale=1):
|
| 124 |
-
# Styled
|
| 125 |
gr.HTML("""
|
| 126 |
-
<
|
| 127 |
-
|
|
|
|
|
|
|
| 128 |
""")
|
| 129 |
input_image = gr.Image(
|
| 130 |
type="pil", label="Input Image", elem_classes="image-box")
|
|
@@ -136,8 +148,12 @@ with gr.Blocks(theme=theme, css=custom_css) as demo:
|
|
| 136 |
|
| 137 |
# Right Column: Outputs
|
| 138 |
with gr.Column(scale=1):
|
| 139 |
-
# Styled
|
| 140 |
-
gr.HTML("
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
output_message = gr.HTML(waiting_text)
|
| 143 |
output_label = gr.Label(
|
|
|
|
| 42 |
])
|
| 43 |
|
| 44 |
# ==========================================
|
| 45 |
+
# 4. Styled Text Blocks & Inference
|
| 46 |
# ==========================================
|
| 47 |
+
# Styled "Waiting" Box - Soft light gray background with dashed border
|
| 48 |
+
waiting_text = """
|
| 49 |
+
<div style="background-color: #f1f5f9; padding: 15px; border-radius: 10px; border: 2px dashed #cbd5e1; text-align: center; margin-bottom: 15px;">
|
| 50 |
+
<h3 style="color: #64748b; margin: 0; font-weight: 600;">⏳ Waiting for upload...</h3>
|
| 51 |
+
</div>
|
| 52 |
+
"""
|
| 53 |
|
| 54 |
def predict(image):
|
| 55 |
if image is None:
|
|
|
|
| 70 |
top_class = max(confidences, key=confidences.get)
|
| 71 |
top_score = confidences[top_class]
|
| 72 |
|
| 73 |
+
# Styled Success Box - Soft light indigo background, dark indigo text, nice shadow
|
| 74 |
+
message = f"""
|
| 75 |
+
<div style="background-color: #e0e7ff; padding: 15px; border-radius: 10px; border-left: 6px solid #4f46e5; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); text-align: center; margin-bottom: 15px;">
|
| 76 |
+
<h3 style="color: #312e81; margin: 0; font-weight: 800; font-size: 1.2rem;">
|
| 77 |
+
🧠 The model is {top_score*100:.1f}% confident that the primary expression is {top_class}.
|
| 78 |
+
</h3>
|
| 79 |
+
</div>
|
| 80 |
+
"""
|
| 81 |
|
| 82 |
return confidences, message
|
| 83 |
|
|
|
|
| 131 |
|
| 132 |
# Left Column: Inputs
|
| 133 |
with gr.Column(scale=1):
|
| 134 |
+
# Styled Upload Header - White card, subtle shadow, indigo accent
|
| 135 |
gr.HTML("""
|
| 136 |
+
<div style="background-color: #ffffff; padding: 15px; border-radius: 10px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); border-left: 5px solid #4f46e5; margin-bottom: 15px;">
|
| 137 |
+
<h3 style="color: #1e293b; margin: 0 0 5px 0; font-weight: 800;">📸 Upload Image</h3>
|
| 138 |
+
<p style="color: #475569; margin: 0; font-size: 0.95rem;">Upload a clear photo of a child's face to begin the analysis.</p>
|
| 139 |
+
</div>
|
| 140 |
""")
|
| 141 |
input_image = gr.Image(
|
| 142 |
type="pil", label="Input Image", elem_classes="image-box")
|
|
|
|
| 148 |
|
| 149 |
# Right Column: Outputs
|
| 150 |
with gr.Column(scale=1):
|
| 151 |
+
# Styled Results Header - White card, subtle shadow, blue accent
|
| 152 |
+
gr.HTML("""
|
| 153 |
+
<div style="background-color: #ffffff; padding: 15px; border-radius: 10px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); border-left: 5px solid #3b82f6; margin-bottom: 15px;">
|
| 154 |
+
<h3 style="color: #1e293b; margin: 0; font-weight: 800;">📊 AI Analysis Results</h3>
|
| 155 |
+
</div>
|
| 156 |
+
""")
|
| 157 |
|
| 158 |
output_message = gr.HTML(waiting_text)
|
| 159 |
output_label = gr.Label(
|