SlipStream90 commited on
Commit
8cea92d
·
1 Parent(s): d543306
Files changed (2) hide show
  1. app.py +117 -61
  2. requirements.txt +4 -0
app.py CHANGED
@@ -1,21 +1,37 @@
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
 
@@ -28,71 +44,111 @@ with gr.Blocks(css=css, title="Kitchen AI Dashboard") as demo:
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()
 
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
  status = "SAFE ✅"
11
  return image, status
12
 
13
+
14
  def grocery_calc(protein_goal):
15
+ current = 62 # demo value
16
+ return f"Estimated Protein Intake: {current}g / {protein_goal}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
 
36
  gr.Markdown("# 🍳 AI Kitchen Safety & Smart Grocery Dashboard")
37
 
 
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 the AI Kitchen Monitoring System"
55
+ )
56
+
57
+ # CAMERA
58
+ cam = gr.Image(
59
+ sources=["webcam"],
60
+ visible=False,
61
+ label="Kitchen Camera"
62
+ )
63
+
64
+ status = gr.Textbox(
65
+ label="Hazard Status",
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
76
+ )
77
 
 
 
 
 
78
  grocery_output = gr.Textbox(
79
+ label="Protein Analysis",
80
+ visible=False
81
+ )
82
+
83
+ # ===============================
84
+ # NAVIGATION FUNCTIONS
85
+ # ===============================
86
+
87
+ def show_overview():
88
+ return (
89
+ "## Overview\n"
90
+ "AI system for kitchen safety monitoring and "
91
+ "smart grocery intelligence using HOG + ML models.",
92
+ gr.update(visible=False),
93
+ gr.update(visible=False),
94
+ gr.update(visible=False),
95
+ gr.update(visible=False),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  )
97
 
98
+
99
+ def show_monitor():
100
+ return (
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
+ def show_grocery():
110
+ return (
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
+ # BUTTON EVENTS
121
+ # ===============================
122
+
123
+ overview_btn.click(
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()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ opencv-python-headless
3
+ numpy
4
+ scikit-learn