File size: 590 Bytes
d081bf3
d82a7f0
 
 
 
d081bf3
a966c99
afac99d
d13c8a5
 
d82a7f0
afac99d
 
 
d13c8a5
afac99d
 
112b4db
d081bf3
 
d82a7f0
 
112b4db
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
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()