import os from PIL import Image import gradio as gr def create_interface_sddfrcnn(runner): with gr.Blocks(): with gr.Row(): gr.Markdown( '1. 上传输入图片.\n' '2. 选择模型架构.\n' '3. 点击`Run`检测.' ) with gr.Row(): with gr.Column(): content_image = gr.Image(label='输入图像',type='pil',interactive=True,value=None) run_button = gr.Button(value='Run') with gr.Accordion('选项',open=True): model = gr.Radio(choices=['SDD','FRCNN'],value='FRCNN',label='选择模型') with gr.Column(): gr.Markdown('### 输出图像:\n') result_gallery = gr.Gallery(label='Output',elem_id='gallery',columns=2,height='auto',preview=True) dectection_message = gr.Textbox(label='结果:',value='',interactive=False) ips = [content_image,model] run_button.click(fn=runner.run_sddfrcnn,inputs=ips,outputs=[result_gallery,dectection_message])