Spaces:
Sleeping
Sleeping
SlipStream90 commited on
Commit ·
803a72b
1
Parent(s): 8cea92d
fixes
Browse files
app.py
CHANGED
|
@@ -1,35 +1,23 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
# ======================
|
| 4 |
# FUNCTIONS
|
| 5 |
-
# ======================
|
| 6 |
|
| 7 |
def monitor(image):
|
| 8 |
if image is None:
|
| 9 |
return None, "Waiting for camera..."
|
| 10 |
-
|
| 11 |
-
return image, status
|
| 12 |
|
| 13 |
|
| 14 |
-
def grocery_calc(
|
| 15 |
-
current = 62
|
| 16 |
-
return f"Estimated Protein Intake: {current}g / {
|
| 17 |
|
| 18 |
|
| 19 |
-
# ======================
|
| 20 |
-
# CUSTOM CSS
|
| 21 |
-
# ===============================
|
| 22 |
-
|
| 23 |
-
css = """
|
| 24 |
-
body {
|
| 25 |
-
background-color: #0f172a;
|
| 26 |
-
color: white;
|
| 27 |
-
}
|
| 28 |
-
"""
|
| 29 |
-
|
| 30 |
-
# ===============================
|
| 31 |
# UI
|
| 32 |
-
# ======================
|
| 33 |
|
| 34 |
with gr.Blocks(title="Kitchen AI Dashboard") as demo:
|
| 35 |
|
|
@@ -44,17 +32,14 @@ with gr.Blocks(title="Kitchen AI Dashboard") as demo:
|
|
| 44 |
overview_btn = gr.Button("Overview")
|
| 45 |
monitor_btn = gr.Button("Live Monitor")
|
| 46 |
grocery_btn = gr.Button("Smart Grocery")
|
| 47 |
-
logs_btn = gr.Button("Weekly Logs")
|
| 48 |
-
team_btn = gr.Button("Team")
|
| 49 |
|
| 50 |
# -------- MAIN PANEL ----------
|
| 51 |
with gr.Column(scale=4):
|
| 52 |
|
| 53 |
content = gr.Markdown(
|
| 54 |
-
"Welcome to
|
| 55 |
)
|
| 56 |
|
| 57 |
-
# CAMERA
|
| 58 |
cam = gr.Image(
|
| 59 |
sources=["webcam"],
|
| 60 |
visible=False,
|
|
@@ -66,10 +51,8 @@ with gr.Blocks(title="Kitchen AI Dashboard") as demo:
|
|
| 66 |
visible=False
|
| 67 |
)
|
| 68 |
|
| 69 |
-
# GROCERY
|
| 70 |
protein = gr.Slider(
|
| 71 |
-
50,
|
| 72 |
-
150,
|
| 73 |
value=100,
|
| 74 |
label="Daily Protein Goal",
|
| 75 |
visible=False
|
|
@@ -80,75 +63,71 @@ with gr.Blocks(title="Kitchen AI Dashboard") as demo:
|
|
| 80 |
visible=False
|
| 81 |
)
|
| 82 |
|
| 83 |
-
# ======================
|
| 84 |
-
# NAVIGATION FUNCTIONS
|
| 85 |
-
# ======================
|
| 86 |
-
|
| 87 |
-
def show_overview():
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
)
|
| 97 |
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
"## Live Kitchen Monitoring",
|
| 102 |
-
gr.update(visible=True),
|
| 103 |
-
gr.update(visible=True),
|
| 104 |
-
gr.update(visible=False),
|
| 105 |
-
gr.update(visible=False),
|
| 106 |
)
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
"## Smart Grocery Intelligence",
|
| 112 |
-
gr.update(visible=False),
|
| 113 |
-
gr.update(visible=False),
|
| 114 |
-
gr.update(visible=True),
|
| 115 |
-
gr.update(visible=True),
|
| 116 |
)
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
show_overview,
|
| 125 |
-
outputs=[content, cam, status, protein, grocery_output],
|
| 126 |
-
)
|
| 127 |
-
|
| 128 |
-
monitor_btn.click(
|
| 129 |
-
show_monitor,
|
| 130 |
-
outputs=[content, cam, status, protein, grocery_output],
|
| 131 |
-
)
|
| 132 |
-
|
| 133 |
-
grocery_btn.click(
|
| 134 |
-
show_grocery,
|
| 135 |
-
outputs=[content, cam, status, protein, grocery_output],
|
| 136 |
-
)
|
| 137 |
-
|
| 138 |
-
cam.change(
|
| 139 |
-
monitor,
|
| 140 |
-
inputs=cam,
|
| 141 |
-
outputs=[cam, status],
|
| 142 |
-
)
|
| 143 |
|
| 144 |
-
protein.change(
|
| 145 |
-
grocery_calc,
|
| 146 |
-
inputs=protein,
|
| 147 |
-
outputs=grocery_output,
|
| 148 |
-
)
|
| 149 |
|
| 150 |
-
# ======================
|
| 151 |
# LAUNCH
|
| 152 |
-
# ======================
|
| 153 |
|
| 154 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# ======================
|
| 4 |
# FUNCTIONS
|
| 5 |
+
# ======================
|
| 6 |
|
| 7 |
def monitor(image):
|
| 8 |
if image is None:
|
| 9 |
return None, "Waiting for camera..."
|
| 10 |
+
return image, "SAFE ✅"
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
+
def grocery_calc(goal):
|
| 14 |
+
current = 62
|
| 15 |
+
return f"Estimated Protein Intake: {current}g / {goal}g"
|
| 16 |
|
| 17 |
|
| 18 |
+
# ======================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# UI
|
| 20 |
+
# ======================
|
| 21 |
|
| 22 |
with gr.Blocks(title="Kitchen AI Dashboard") as demo:
|
| 23 |
|
|
|
|
| 32 |
overview_btn = gr.Button("Overview")
|
| 33 |
monitor_btn = gr.Button("Live Monitor")
|
| 34 |
grocery_btn = gr.Button("Smart Grocery")
|
|
|
|
|
|
|
| 35 |
|
| 36 |
# -------- MAIN PANEL ----------
|
| 37 |
with gr.Column(scale=4):
|
| 38 |
|
| 39 |
content = gr.Markdown(
|
| 40 |
+
"Welcome to AI Kitchen Monitoring System"
|
| 41 |
)
|
| 42 |
|
|
|
|
| 43 |
cam = gr.Image(
|
| 44 |
sources=["webcam"],
|
| 45 |
visible=False,
|
|
|
|
| 51 |
visible=False
|
| 52 |
)
|
| 53 |
|
|
|
|
| 54 |
protein = gr.Slider(
|
| 55 |
+
50, 150,
|
|
|
|
| 56 |
value=100,
|
| 57 |
label="Daily Protein Goal",
|
| 58 |
visible=False
|
|
|
|
| 63 |
visible=False
|
| 64 |
)
|
| 65 |
|
| 66 |
+
# ======================
|
| 67 |
+
# NAVIGATION FUNCTIONS
|
| 68 |
+
# ======================
|
| 69 |
+
|
| 70 |
+
def show_overview():
|
| 71 |
+
return (
|
| 72 |
+
"## Overview\nAI Kitchen Safety + Smart Grocery System",
|
| 73 |
+
gr.update(visible=False),
|
| 74 |
+
gr.update(visible=False),
|
| 75 |
+
gr.update(visible=False),
|
| 76 |
+
gr.update(visible=False),
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
def show_monitor():
|
| 80 |
+
return (
|
| 81 |
+
"## Live Kitchen Monitoring",
|
| 82 |
+
gr.update(visible=True),
|
| 83 |
+
gr.update(visible=True),
|
| 84 |
+
gr.update(visible=False),
|
| 85 |
+
gr.update(visible=False),
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
+
def show_grocery():
|
| 89 |
+
return (
|
| 90 |
+
"## Smart Grocery Intelligence",
|
| 91 |
+
gr.update(visible=False),
|
| 92 |
+
gr.update(visible=False),
|
| 93 |
+
gr.update(visible=True),
|
| 94 |
+
gr.update(visible=True),
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
# ======================
|
| 98 |
+
# EVENTS (INSIDE BLOCKS ✅)
|
| 99 |
+
# ======================
|
| 100 |
+
|
| 101 |
+
overview_btn.click(
|
| 102 |
+
show_overview,
|
| 103 |
+
outputs=[content, cam, status, protein, grocery_output],
|
| 104 |
)
|
| 105 |
|
| 106 |
+
monitor_btn.click(
|
| 107 |
+
show_monitor,
|
| 108 |
+
outputs=[content, cam, status, protein, grocery_output],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
)
|
| 110 |
|
| 111 |
+
grocery_btn.click(
|
| 112 |
+
show_grocery,
|
| 113 |
+
outputs=[content, cam, status, protein, grocery_output],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
)
|
| 115 |
|
| 116 |
+
cam.change(
|
| 117 |
+
monitor,
|
| 118 |
+
inputs=cam,
|
| 119 |
+
outputs=[cam, status],
|
| 120 |
+
)
|
| 121 |
|
| 122 |
+
protein.change(
|
| 123 |
+
grocery_calc,
|
| 124 |
+
inputs=protein,
|
| 125 |
+
outputs=grocery_output,
|
| 126 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
+
# ======================
|
| 130 |
# LAUNCH
|
| 131 |
+
# ======================
|
| 132 |
|
| 133 |
demo.launch()
|