OppaAI commited on
Commit
7081f59
·
verified ·
1 Parent(s): cf34c2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -27
app.py CHANGED
@@ -1,34 +1,18 @@
1
  import gradio as gr
2
- import base64
3
- from PIL import Image
4
- import io
5
- import json
6
 
7
- # The input will now be a raw text string representing the JSON data
8
- def process(json_text_input):
9
- try:
10
- # Manually parse the incoming text string into a Python dictionary
11
- data = json.loads(json_text_input)
12
-
13
- img_bytes = base64.b64decode(data["image_b64"])
14
- img = Image.open(io.BytesIO(img_bytes))
15
-
16
- response = {
17
- "received": True,
18
- "robot_id": data.get("robot_id", "unknown"),
19
- "image_size": img.size
20
- }
21
- return response
22
-
23
- except Exception as e:
24
- # Return error as a JSON dictionary which Gradio handles
25
- return {"error": str(e)}
26
 
27
  demo = gr.Interface(
28
- fn=process,
29
- # Change input type to Textbox
30
- inputs=gr.Textbox(label="Input JSON as Plain Text"),
31
- outputs=gr.JSON(label="Reply to Jetson"),
32
  )
33
 
34
  demo.launch()
 
1
  import gradio as gr
 
 
 
 
2
 
3
+ # The function now accepts a simple string (plain text)
4
+ def process_text(input_text):
5
+ response = {
6
+ "received": True,
7
+ "message": f"Received: {input_text}",
8
+ "status": "Success"
9
+ }
10
+ return response
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  demo = gr.Interface(
13
+ fn=process_text,
14
+ inputs=gr.Textbox(label="Input Text"), # Changed input type
15
+ outputs=gr.JSON(label="Reply"),
 
16
  )
17
 
18
  demo.launch()