Spaces:
Sleeping
Sleeping
File size: 3,093 Bytes
d543306 803a72b 8cea92d 803a72b d543306 8cea92d 803a72b d543306 8cea92d 803a72b 8cea92d d543306 803a72b 8cea92d 803a72b 8cea92d d543306 8cea92d 803a72b 8cea92d 803a72b 8cea92d d543306 8cea92d 803a72b d543306 803a72b d543306 803a72b d543306 803a72b 8cea92d 803a72b 8cea92d 803a72b 8cea92d 803a72b d543306 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | import gradio as gr
# ======================
# FUNCTIONS
# ======================
def monitor(image):
if image is None:
return None, "Waiting for camera..."
return image, "SAFE ✅"
def grocery_calc(goal):
current = 62
return f"Estimated Protein Intake: {current}g / {goal}g"
# ======================
# UI
# ======================
with gr.Blocks(title="Kitchen AI Dashboard") as demo:
gr.Markdown("# 🍳 AI Kitchen Safety & Smart Grocery Dashboard")
with gr.Row():
# -------- SIDEBAR ----------
with gr.Column(scale=1):
gr.Markdown("## Navigation")
overview_btn = gr.Button("Overview")
monitor_btn = gr.Button("Live Monitor")
grocery_btn = gr.Button("Smart Grocery")
# -------- MAIN PANEL ----------
with gr.Column(scale=4):
content = gr.Markdown(
"Welcome to AI Kitchen Monitoring System"
)
cam = gr.Image(
sources=["webcam"],
visible=False,
label="Kitchen Camera"
)
status = gr.Textbox(
label="Hazard Status",
visible=False
)
protein = gr.Slider(
50, 150,
value=100,
label="Daily Protein Goal",
visible=False
)
grocery_output = gr.Textbox(
label="Protein Analysis",
visible=False
)
# ======================
# NAVIGATION FUNCTIONS
# ======================
def show_overview():
return (
"## Overview\nAI Kitchen Safety + Smart Grocery System",
gr.update(visible=False),
gr.update(visible=False),
gr.update(visible=False),
gr.update(visible=False),
)
def show_monitor():
return (
"## Live Kitchen Monitoring",
gr.update(visible=True),
gr.update(visible=True),
gr.update(visible=False),
gr.update(visible=False),
)
def show_grocery():
return (
"## Smart Grocery Intelligence",
gr.update(visible=False),
gr.update(visible=False),
gr.update(visible=True),
gr.update(visible=True),
)
# ======================
# EVENTS (INSIDE BLOCKS ✅)
# ======================
overview_btn.click(
show_overview,
outputs=[content, cam, status, protein, grocery_output],
)
monitor_btn.click(
show_monitor,
outputs=[content, cam, status, protein, grocery_output],
)
grocery_btn.click(
show_grocery,
outputs=[content, cam, status, protein, grocery_output],
)
cam.change(
monitor,
inputs=cam,
outputs=[cam, status],
)
protein.change(
grocery_calc,
inputs=protein,
outputs=grocery_output,
)
# ======================
# LAUNCH
# ======================
demo.launch() |