facebook/CutLER
35
1#!/usr/bin/env python2 3import pathlib4 5import gradio as gr6 7from model import run_model8 9DESCRIPTION = '# [CutLER](https://github.com/facebookresearch/CutLER)'10 11paths = sorted(pathlib.Path('CutLER/cutler/demo/imgs').glob('*.jpg'))12 13with gr.Blocks(css='style.css') as demo:14 gr.Markdown(DESCRIPTION)15 with gr.Row():16 with gr.Column():17 image = gr.Image(label='Input image', type='filepath')18 score_threshold = gr.Slider(label='Score threshold',19 minimum=0,20 maximum=1,21 value=0.5,22 step=0.05)23 run_button = gr.Button('Run')24 with gr.Column():25 result = gr.Image(label='Result', type='numpy')26 with gr.Row():27 gr.Examples(examples=[[path.as_posix()] for path in paths],28 inputs=image)29 30 run_button.click(fn=run_model,31 inputs=[32 image,33 score_threshold,34 ],35 outputs=result,36 api_name='run')37demo.queue(max_size=20).launch()38 