File size: 1,238 Bytes
2f0f031
7dcb60d
 
 
 
 
c81e62d
7dcb60d
 
 
 
 
 
 
 
 
 
c81e62d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7dcb60d
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
38
39
40
#!/usr/bin/env python

import pathlib

import gradio as gr

from model import run_model

DESCRIPTION = '''# CutLER

This is an unofficial demo for [https://github.com/facebookresearch/CutLER](https://github.com/facebookresearch/CutLER).
'''

paths = sorted(pathlib.Path('CutLER/cutler/demo/imgs').glob('*.jpg'))

with gr.Blocks(css='style.css') as demo:
    gr.Markdown(DESCRIPTION)
    with gr.Row():
        with gr.Column():
            image = gr.Image(label='Input image', type='filepath')
            score_threshold = gr.Slider(label='Score threshold',
                                        minimum=0,
                                        maximum=1,
                                        value=0.5,
                                        step=0.05)
            run_button = gr.Button('Run')
        with gr.Column():
            result = gr.Image(label='Result', type='numpy')
    with gr.Row():
        gr.Examples(examples=[[path.as_posix()] for path in paths],
                    inputs=[image])

    run_button.click(fn=run_model,
                     inputs=[
                         image,
                         score_threshold,
                     ],
                     outputs=result)
demo.queue().launch()