OppaAI's picture
Update app.py
d13c8a5 verified
raw
history blame
590 Bytes
import gradio as gr
import base64
from PIL import Image
import io
import json
def process(json_input):
try:
# json_input from gr.JSON() is STRING, so must parse
data = json.loads(json_input)
img_bytes = base64.b64decode(data["image_b64"])
img = Image.open(io.BytesIO(img_bytes))
return img # show image
except Exception as e:
return None
demo = gr.Interface(
fn=process,
inputs=gr.JSON(label="Input JSON from Jetson"),
outputs=gr.Image(type="pil", label="Image From Jetson"),
api_name="predict"
)
demo.launch()