| import os | |
| from PIL import Image | |
| import gradio as gr | |
| def create_interface_yolov8(runner): | |
| with gr.Blocks(): | |
| with gr.Row(): | |
| gr.Markdown( | |
| '1. 上传输入图像.\n' | |
| '2. 点击`Run`进行检测.' | |
| ) | |
| with gr.Row(): | |
| with gr.Column(): | |
| gr.Markdown('### 输入图像:\n') | |
| content_image = gr.Image(label='Input Image',type='pil',interactive=True,value=None) | |
| run_button = gr.Button(value='Run') | |
| with gr.Column(): | |
| gr.Markdown('### 输出图像:\n') | |
| result_gallery = gr.Gallery(label='Output',elem_id='gallery',columns=2,height='auto',preview=True) | |
| ips = [content_image] | |
| run_button.click(fn=runner.run_yolov8,inputs=ips,outputs=[result_gallery]) |