uttarasawant commited on
Commit
65ddbdd
·
verified ·
1 Parent(s): b2a39e9

Update app.py with mock fridge ingredients

Browse files
Files changed (1) hide show
  1. app.py +77 -12
app.py CHANGED
@@ -1,17 +1,82 @@
1
  import gradio as gr
2
- import spaces
3
- import torch
4
 
5
- # 1. Keep your global imports and setups completely clean of CUDA movements.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
- @spaces.GPU
8
- def greet(n):
9
- # 2. Allocate tensors or load small weights directly inside the function.
10
- # When this function runs, a physical GPU is fully mounted.
11
- zero = torch.Tensor([0]).cuda()
12
- print(f"Active Device: {zero.device}") # Will safely output 'cuda:0'
13
 
14
- return f"Hello {zero + n} Tensor"
15
 
16
- demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
17
- demo.launch()
 
1
  import gradio as gr
2
+ import pandas as pd
3
+ import json
4
 
5
+ # Placeholder processing function mimicking an edge asset inspection pipeline
6
+ def process_fridge_survey(input_image):
7
+ # This structure mirrors how an industrial site survey maps physical gear to JSON
8
+ mock_detected_assets = {
9
+ "assets": [
10
+ {"ingredient": "Greek Yogurt", "qty": "0.5 Liters", "status": "Fresh", "est_cost_usd": 2.50},
11
+ {"ingredient": "Baby Spinach", "qty": "1 Bag", "status": "Wilting (Use Immediately)", "est_cost_usd": 3.00},
12
+ {"ingredient": "Chicken Breast", "qty": "400 Grams", "status": "Fresh", "est_cost_usd": 6.50},
13
+ {"ingredient": "Yellow Onion", "qty": "1 Whole", "status": "Fresh", "est_cost_usd": 0.80}
14
+ ]
15
+ }
16
+
17
+ # Map the unstructured visual results directly into our Digital Twin Dataframe
18
+ df_rows = [
19
+ [item['ingredient'], item['qty'], item['status'], f"${item['est_cost_usd']:.2f}"]
20
+ for item in mock_detected_assets['assets']
21
+ ]
22
+ return df_rows
23
+
24
+ # Build out the Operational Control Center Dashboard Layout
25
+ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
26
+ gr.Markdown("# 🛰️ Parallel Plate: Kitchen Operations & Visual Logistics Engine")
27
+ gr.Markdown("### *Physical-to-Digital Twin Asset Management Pipeline (Sub-32B Model Framework)*")
28
+
29
+ with gr.Row():
30
+ # Left Column: Optical Ingestion Layer (The "Drone Site Survey" equivalent)
31
+ with gr.Column(scale=1):
32
+ gr.Markdown("### 📸 1. Physical Edge Ingestion")
33
+ image_input = gr.Image(label="Upload Fridge Optical Survey Scan", type="pil")
34
+
35
+ with gr.Row():
36
+ budget_slider = gr.Slider(minimum=5, maximum=100, value=25, step=5, label="Remaining Runway Budget ($ USD)")
37
+ days_slider = gr.Slider(minimum=1, maximum=7, value=3, step=1, label="Target Horizon (Days)")
38
+
39
+ scan_btn = gr.Button("🚀 Initialize Asset Optimization Scan", variant="primary")
40
+
41
+ # Right Column: The Asset Manifest State Machine (The Digital Twin Dashboard)
42
+ with gr.Column(scale=1):
43
+ gr.Markdown("### 📊 2. Active Kitchen Digital Twin")
44
+ inventory_df = gr.Dataframe(
45
+ headers=["Ingredient Asset", "Current Volume / Qty", "Telemetry Status", "Book Value (Est)"],
46
+ datatype=["str", "str", "str", "str"],
47
+ label="Live Operational Asset Manifest",
48
+ interactive=True
49
+ )
50
+
51
+ gr.Markdown("### 🛠️ 3. Resource Routing & Recipe Output")
52
+ output_text = gr.Markdown("*Awaiting asset telemetry mapping to generate optimal cooking execution paths...*")
53
+
54
+ # Define the trigger mapping link
55
+ scan_btn.click(
56
+ fn=process_fridge_survey,
57
+ inputs=[image_input],
58
+ outputs=[inventory_df]
59
+ )
60
+
61
+ # Launch the engine
62
+ if __name__ == "__main__":
63
+ demo.launch()
64
+
65
+ ## trial 1
66
+ # import gradio as gr
67
+ # import spaces
68
+ # import torch
69
+
70
+ # # 1. Keep your global imports and setups completely clean of CUDA movements.
71
 
72
+ # @spaces.GPU
73
+ # def greet(n):
74
+ # # 2. Allocate tensors or load small weights directly inside the function.
75
+ # # When this function runs, a physical GPU is fully mounted.
76
+ # zero = torch.Tensor([0]).cuda()
77
+ # print(f"Active Device: {zero.device}") # Will safely output 'cuda:0'
78
 
79
+ # return f"Hello {zero + n} Tensor"
80
 
81
+ # demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
82
+ # demo.launch()