File size: 1,067 Bytes
2023a9f |
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 |
import os
import gradio as gr
from cls import _CLS_MODELS, _DEFAULT_CLS_MODEL, _gr_classification
if __name__ == '__main__':
with gr.Blocks() as demo:
with gr.Tabs():
with gr.Tab('Classification'):
with gr.Row():
with gr.Column():
gr_cls_input_image = gr.Image(type='pil', label='Original Image')
gr_cls_model = gr.Dropdown(_CLS_MODELS, value=_DEFAULT_CLS_MODEL, label='Model')
gr_cls_infer_size = gr.Slider(224, 640, value=384, step=32, label='Infer Size')
gr_cls_submit = gr.Button(value='Submit', variant='primary')
with gr.Column():
gr_cls_output = gr.Label(label='Classes')
gr_cls_submit.click(
_gr_classification,
inputs=[gr_cls_input_image, gr_cls_model, gr_cls_infer_size],
outputs=[gr_cls_output],
)
demo.queue(os.cpu_count()).launch()
|