app.py 951 字节
Newer Older
1 2
import gradio as gr
import numpy as np
W
wangxinxin08 已提交
3 4
import os
from src.detection import Detector
5 6 7 8


# UGC: Define the inference fn() for your models
def model_inference(image):
W
wangxinxin08 已提交
9
    image, json_out = Detector('PP-YOLOv2')(image)
10 11 12 13 14 15 16 17 18 19 20 21
    return image, json_out


def clear_all():
    return None, None, None


with gr.Blocks() as demo:
    gr.Markdown("Objective Detection")

    with gr.Column(scale=1, min_width=100):

22
        img_in = gr.Image(value="https://paddledet.bj.bcebos.com/modelcenter/images/General/000000014439.jpg",label="Input").style(height=200)
23 24 25 26 27

        with gr.Row():
            btn1 = gr.Button("Clear")
            btn2 = gr.Button("Submit")

W
wangxinxin08 已提交
28
        img_out = gr.Image(label="Output").style(height=200)
29 30 31 32 33 34 35
        json_out = gr.JSON(label="jsonOutput")

    btn2.click(fn=model_inference, inputs=img_in, outputs=[img_out, json_out])
    btn1.click(fn=clear_all, inputs=None, outputs=[img_in, img_out, json_out])
    gr.Button.style(1)

demo.launch()