prismer / gradio_vqa.py
shikunl's picture
Update example image
35156d3
raw
history blame
1.52 kB
import gradio as gr
from PIL import Image
import tempfile
def predict_depth(model, image):
depth = model.infer_pil(image)
return depth
def create_demo():
with gr.Row():
with gr.Column(scale=1):
model_type = gr.Dropdown(["Prismer-Base", "Prismer-Large"], label="Model Size", value="Prismer-Base")
ques = gr.Textbox(label="Question", placeholder="What's the number of this player?")
rgb = gr.Image(label="Input Image", type='pil', elem_id='img-display-input').style(height="auto")
submit = gr.Button("Submit")
with gr.Column(scale=2):
pred = gr.Textbox(label="Model Prediction")
with gr.Row():
depth = gr.Image(label="Depth", elem_id='img-display-output')
edge = gr.Image(label="Edge", elem_id='img-display-output')
normals = gr.Image(label="Normals", elem_id='img-display-output')
with gr.Row():
seg = gr.Image(label="Segmentation", elem_id='img-display-output')
obj_det = gr.Image(label="Object Detection", elem_id='img-display-output')
ocr_det = gr.Image(label="OCR Detection", elem_id='img-display-output')
def on_submit(im, q, model_type):
return pred, depth, edge, normals, seg, obj_det, ocr_det
submit.click(on_submit, inputs=[rgb, ques, model_type], outputs=[pred, depth, edge, normals, seg, obj_det, ocr_det])
examples = gr.Examples(examples=["examples/1.png"], inputs=[rgb])