OppaAI commited on
Commit
95881bf
·
verified ·
1 Parent(s): 94ef720

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -9
app.py CHANGED
@@ -6,29 +6,25 @@ 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()
 
6
 
7
  def process(json_input):
8
  try:
9
+ data = json_input # no need to json.loads
10
 
 
11
  img_bytes = base64.b64decode(data["image_b64"])
12
  img = Image.open(io.BytesIO(img_bytes))
13
 
 
14
  response = {
15
  "received": True,
16
  "robot_id": data.get("robot_id", "unknown"),
17
  "image_size": img.size
18
  }
19
+ return response
 
20
 
21
  except Exception as e:
22
+ return {"error": str(e)}
23
 
 
24
  demo = gr.Interface(
25
  fn=process,
26
+ inputs=gr.JSON(label="Input JSON from Jetson"),
27
+ outputs=gr.JSON(label="Reply to Jetson"),
28
  )
29
 
30
  demo.launch()