File size: 1,237 Bytes
f474bbc dfcc607 f474bbc dfcc607 f474bbc dfcc607 f474bbc |
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 29 30 31 32 33 34 35 36 37 |
import os
import gradio as gr
from PIL import Image
from index import query_character
def _fn(image: Image.Image, count: int = 10, threshold: float = 0.8):
return query_character(image, count, order_by='same_ratio', threshold=threshold)
if __name__ == '__main__':
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
gr_input_image = gr.Image(type='pil', label='Original Image')
gr_max_count = gr.Slider(minimum=1, maximum=30, step=1, value=10, label='Max Query Count')
gr_threshold = gr.Slider(minimum=0.0, maximum=0.99, step=0.01, value=0.8, label='Threshold')
gr_submit = gr.Button(value='Submit', variant='primary')
with gr.Column():
with gr.Tabs():
with gr.Tab('Gallery'):
gr_gallery = gr.Gallery(label='Gallery')
with gr.Tab('Information'):
gr_table = gr.DataFrame(label='Information')
gr_submit.click(
_fn,
inputs=[gr_input_image, gr_max_count, gr_threshold],
outputs=[gr_gallery, gr_table],
)
demo.queue(os.cpu_count()).launch()
|