File size: 781 Bytes
f67b8d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2cdb710
f67b8d5
 
 
 
 
 
9b8d0fe
 
 
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
import torch
import gradio as gr
from utils import (
    predict,
    get_html,
    get_examples
)

examples = get_examples()
placeholder = 'Enter a word/phrase or multiple words/phrases separated by commas...'


with gr.Blocks() as interface:
  gr.HTML(value=get_html, show_label=True)
  with gr.Row():
    inputs = [gr.Image(type="pil"),
              gr.Textbox(label='Text Prompts', placeholder=placeholder, lines=3)]

  with gr.Row():
    outputs = gr.AnnotatedImage(label="Segmentation Masks", height=500, width=500)

  with gr.Row():
    button = gr.Button("Visualize Segments")
    button.click(predict, inputs=inputs, outputs=outputs)

  with gr.Row():
    gr.Examples(examples=examples, inputs=inputs, outputs=outputs, fn=predict, cache_examples=True)

interface.launch()