mkthoma commited on
Commit
b9ca665
1 Parent(s): 11223c6
Files changed (1) hide show
  1. app.py +4 -13
app.py CHANGED
@@ -16,10 +16,6 @@ title = "<center><strong><font size='10'> Fast Segment Anything </font></strong>
16
 
17
  css = "h1 { text-align: center } .about { text-align: justify; padding-left: 10%; padding-right: 10%; }"
18
 
19
- examples = [["examples/sa_8776.jpg"], ["examples/sa_414.jpg"], ["examples/sa_1309.jpg"], ["examples/sa_11025.jpg"],
20
- ["examples/sa_561.jpg"], ["examples/sa_192.jpg"], ["examples/sa_10039.jpg"], ["examples/sa_862.jpg"]]
21
-
22
- default_example = examples[0]
23
 
24
  def segment_everything(
25
  input,
@@ -130,12 +126,7 @@ def get_points_with_draw(image, label, evt: gr.SelectData):
130
  return image
131
 
132
 
133
- cond_img_e = gr.Image(label="Input", value=default_example[0], type='pil')
134
- cond_img_p = gr.Image(label="Input with points", value=default_example[0], type='pil')
135
  cond_img_t = gr.Image(label="Input with text", value="examples/dogs.jpg", type='pil')
136
-
137
- segm_img_e = gr.Image(label="Segmented Image", interactive=False, type='pil')
138
- segm_img_p = gr.Image(label="Segmented Image with points", interactive=False, type='pil')
139
  segm_img_t = gr.Image(label="Segmented Image with text", interactive=False, type='pil')
140
 
141
  global_points = []
@@ -146,7 +137,7 @@ input_size_slider = gr.components.Slider(minimum=512,
146
  value=1024,
147
  step=64,
148
  label='Input_size',
149
- info='Our model was trained on a size of 1024')
150
 
151
  with gr.Blocks(css=css, title='Fast Segment Anything') as demo:
152
  with gr.Row():
@@ -182,9 +173,9 @@ with gr.Blocks(css=css, title='Fast Segment Anything') as demo:
182
  clear_btn_t = gr.Button("Clear", variant="secondary")
183
 
184
  gr.Markdown("Try some of the examples below ⬇️")
185
- gr.Examples(examples=[["examples/dogs.jpg"], ["examples/fruits.jpg"], ["examples/flowers.jpg"]],
186
  inputs=[cond_img_t],
187
- examples_per_page=4)
188
 
189
  with gr.Column():
190
  with gr.Accordion("Advanced options", open=False):
@@ -216,7 +207,7 @@ with gr.Blocks(css=css, title='Fast Segment Anything') as demo:
216
  return None, None, None
217
 
218
  # clear_btn_p.click(clear, outputs=[cond_img_p, segm_img_p])
219
- clear_btn_t.click(clear_text, outputs=[cond_img_p, segm_img_p, text_box])
220
 
221
  demo.queue()
222
  demo.launch()
 
16
 
17
  css = "h1 { text-align: center } .about { text-align: justify; padding-left: 10%; padding-right: 10%; }"
18
 
 
 
 
 
19
 
20
  def segment_everything(
21
  input,
 
126
  return image
127
 
128
 
 
 
129
  cond_img_t = gr.Image(label="Input with text", value="examples/dogs.jpg", type='pil')
 
 
 
130
  segm_img_t = gr.Image(label="Segmented Image with text", interactive=False, type='pil')
131
 
132
  global_points = []
 
137
  value=1024,
138
  step=64,
139
  label='Input_size',
140
+ info='The model was trained on a size of 1024')
141
 
142
  with gr.Blocks(css=css, title='Fast Segment Anything') as demo:
143
  with gr.Row():
 
173
  clear_btn_t = gr.Button("Clear", variant="secondary")
174
 
175
  gr.Markdown("Try some of the examples below ⬇️")
176
+ gr.Examples(examples=[["examples/dogs.jpg"], ["examples/fruits.jpg"], ["examples/flowers.jpg"], ["examples/dog2.jpg"], ["examples/cat.jpg"], ["examples/person.jpg"]],
177
  inputs=[cond_img_t],
178
+ examples_per_page=6)
179
 
180
  with gr.Column():
181
  with gr.Accordion("Advanced options", open=False):
 
207
  return None, None, None
208
 
209
  # clear_btn_p.click(clear, outputs=[cond_img_p, segm_img_p])
210
+ clear_btn_t.click(clear_text, outputs=[text_box])
211
 
212
  demo.queue()
213
  demo.launch()