Spaces:
Sleeping
Sleeping
SlipStream90 commited on
Commit ·
d543306
1
Parent(s): ce541cc
Add application file
Browse files
app.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
# ---------------- STYLES ----------------
|
| 4 |
+
css = """
|
| 5 |
+
body {background-color:#0f172a;}
|
| 6 |
+
.gradio-container {font-family: Arial;}
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
# ---------------- FUNCTIONS ----------------
|
| 10 |
+
def monitor(image):
|
| 11 |
+
status = "SAFE ✅"
|
| 12 |
+
return image, status
|
| 13 |
+
|
| 14 |
+
def grocery_calc(protein_goal):
|
| 15 |
+
return f"Estimated Intake: 62g / {protein_goal}g"
|
| 16 |
+
|
| 17 |
+
# ---------------- APP ----------------
|
| 18 |
+
with gr.Blocks(css=css, title="Kitchen AI Dashboard") as demo:
|
| 19 |
+
|
| 20 |
+
gr.Markdown("# 🍳 AI Kitchen Safety & Smart Grocery Dashboard")
|
| 21 |
+
|
| 22 |
+
with gr.Row():
|
| 23 |
+
|
| 24 |
+
# -------- SIDEBAR ----------
|
| 25 |
+
with gr.Column(scale=1):
|
| 26 |
+
gr.Markdown("## Navigation")
|
| 27 |
+
|
| 28 |
+
overview_btn = gr.Button("Overview")
|
| 29 |
+
monitor_btn = gr.Button("Live Monitor")
|
| 30 |
+
grocery_btn = gr.Button("Smart Grocery")
|
| 31 |
+
model_btn = gr.Button("Model Details")
|
| 32 |
+
logs_btn = gr.Button("Weekly Logs")
|
| 33 |
+
team_btn = gr.Button("Team")
|
| 34 |
+
|
| 35 |
+
# -------- MAIN PANEL ----------
|
| 36 |
+
with gr.Column(scale=4):
|
| 37 |
+
|
| 38 |
+
content = gr.Markdown("Welcome to Kitchen AI System")
|
| 39 |
+
|
| 40 |
+
# MONITOR AREA
|
| 41 |
+
cam = gr.Image(source="webcam", visible=False)
|
| 42 |
+
status = gr.Textbox(label="Hazard Status", visible=False)
|
| 43 |
+
|
| 44 |
+
# GROCERY AREA
|
| 45 |
+
protein = gr.Slider(50,150,value=100,
|
| 46 |
+
label="Daily Protein Goal",
|
| 47 |
+
visible=False)
|
| 48 |
+
grocery_output = gr.Textbox(
|
| 49 |
+
label="Protein Analysis",
|
| 50 |
+
visible=False)
|
| 51 |
+
|
| 52 |
+
# ---------- NAVIGATION LOGIC ----------
|
| 53 |
+
def show_overview():
|
| 54 |
+
return (
|
| 55 |
+
"AI system for kitchen safety and nutrition monitoring.",
|
| 56 |
+
gr.update(visible=False),
|
| 57 |
+
gr.update(visible=False),
|
| 58 |
+
gr.update(visible=False),
|
| 59 |
+
gr.update(visible=False),
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
def show_monitor():
|
| 63 |
+
return (
|
| 64 |
+
"Live Kitchen Monitoring",
|
| 65 |
+
gr.update(visible=True),
|
| 66 |
+
gr.update(visible=True),
|
| 67 |
+
gr.update(visible=False),
|
| 68 |
+
gr.update(visible=False),
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
def show_grocery():
|
| 72 |
+
return (
|
| 73 |
+
"Smart Grocery Intelligence",
|
| 74 |
+
gr.update(visible=False),
|
| 75 |
+
gr.update(visible=False),
|
| 76 |
+
gr.update(visible=True),
|
| 77 |
+
gr.update(visible=True),
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
overview_btn.click(
|
| 81 |
+
show_overview,
|
| 82 |
+
outputs=[content, cam, status, protein, grocery_output]
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
monitor_btn.click(
|
| 86 |
+
show_monitor,
|
| 87 |
+
outputs=[content, cam, status, protein, grocery_output]
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
grocery_btn.click(
|
| 91 |
+
show_grocery,
|
| 92 |
+
outputs=[content, cam, status, protein, grocery_output]
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
cam.change(monitor, cam, [cam, status])
|
| 96 |
+
protein.change(grocery_calc, protein, grocery_output)
|
| 97 |
+
|
| 98 |
+
demo.launch()
|