kitooo commited on
Commit
6bc05db
1 Parent(s): 2fefa77

updated app

Browse files
Files changed (1) hide show
  1. app.py +10 -12
app.py CHANGED
@@ -26,26 +26,24 @@ def segment_sidewalk(image):
26
  save_image(prediction, 'mask.png', cmap='gray')
27
  return Image.open('image.png'), Image.open('mask.png'), Image.open('prob.png')
28
 
29
- def save_image(image, path, **kwargs):
30
- plt.figure(figsize=(8, 8))
31
- plt.imshow(image, interpolation='nearest', **kwargs)
32
- plt.axis('off')
33
- plt.tight_layout()
34
- plt.savefig(path, bbox_inches='tight', pad_inches=0)
35
- plt.close()
36
 
37
  with gr.Blocks() as demo:
38
  with gr.Row():
39
  with gr.Column():
40
  image_input = gr.Image(type='pil', label='TIFF Image')
41
- # threshold_slider = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.5, label='Prediction Threshold')
42
- segment_button = gr.Button('Get Sidewalk Mask')
43
  with gr.Column():
44
  mask = gr.Image(type='pil', label='Predicted Mask')
45
  prob_map = gr.Image(type='pil', label='Predicted Probability Map')
46
- segment_button.click(
47
- segment_sidewalk,
48
- # inputs=[image_input, threshold_slider],
49
  inputs=[image_input],
50
  outputs=[image_input, mask, prob_map]
51
  )
 
26
  save_image(prediction, 'mask.png', cmap='gray')
27
  return Image.open('image.png'), Image.open('mask.png'), Image.open('prob.png')
28
 
29
+ # def save_image(image, path, **kwargs):
30
+ # plt.figure(figsize=(8, 8))
31
+ # plt.imshow(image, interpolation='nearest', **kwargs)
32
+ # plt.axis('off')
33
+ # plt.tight_layout()
34
+ # plt.savefig(path, bbox_inches='tight', pad_inches=0)
35
+ # plt.close()
36
 
37
  with gr.Blocks() as demo:
38
  with gr.Row():
39
  with gr.Column():
40
  image_input = gr.Image(type='pil', label='TIFF Image')
41
+ button = gr.Button('Get Sidewalk Mask')
 
42
  with gr.Column():
43
  mask = gr.Image(type='pil', label='Predicted Mask')
44
  prob_map = gr.Image(type='pil', label='Predicted Probability Map')
45
+ button.click(
46
+ segment_sidewalk,
 
47
  inputs=[image_input],
48
  outputs=[image_input, mask, prob_map]
49
  )