OppaAI commited on
Commit
d081bf3
·
verified ·
1 Parent(s): c07c6e8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import base64
3
+ from PIL import Image
4
+ import io
5
+ import json
6
+
7
+ def process(json_input):
8
+ try:
9
+ data = json.loads(json_input)
10
+
11
+ # Decode Base64
12
+ img_bytes = base64.b64decode(data["image_b64"])
13
+ img = Image.open(io.BytesIO(img_bytes))
14
+
15
+ # You can do CV/LLM here later
16
+ response = {
17
+ "received": True,
18
+ "robot_id": data.get("robot_id", "unknown"),
19
+ "image_size": img.size
20
+ }
21
+
22
+ return json.dumps(response)
23
+
24
+ except Exception as e:
25
+ return json.dumps({"error": str(e)})
26
+
27
+ # Gradio interface
28
+ demo = gr.Interface(
29
+ fn=process,
30
+ inputs=gr.Textbox(lines=10, label="Input JSON from Jetson"),
31
+ outputs=gr.Textbox(lines=10, label="Reply to Jetson"),
32
+ )
33
+
34
+ demo.launch()