Spaces:
Sleeping
Sleeping
File size: 820 Bytes
d081bf3 d82a7f0 d081bf3 a966c99 afac99d a7a79ed d82a7f0 eb6d527 afac99d eb6d527 afac99d eb6d527 d081bf3 d82a7f0 eb6d527 afac99d d081bf3 a966c99 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
import gradio as gr
import base64
from PIL import Image
import io
import json
def process(json_input):
try:
#data = json.loads(json_input)
# decode base64 image
img_bytes = base64.b64decode(data["image_b64"])
img = Image.open(io.BytesIO(img_bytes))
# This goes to Jetson
reply = {
"received": True,
"robot_id": data.get("robot_id"),
"size": img.size
}
# return only the msg: (Jetson JSON)
return reply
except Exception as e:
return None, {"error": str(e)}
demo = gr.Interface(
fn=process,
inputs=gr.JSON(label="Jetson JSON"),
outputs=[
gr.Image(type="pil", label="Image Preview"),
gr.JSON(label="Reply to Jetson")
],
api_name="predict"
)
demo.launch()
|