Spaces:
seosnaps
/
Runtime error

taesiri commited on
Commit
c3521e3
1 Parent(s): f250033

transparent output

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -56,7 +56,11 @@ def process_image(image, prompt, threhsold, alpha_value, draw_rectangles):
56
  ax.axis("off")
57
  plt.tight_layout()
58
 
59
- return fig, mask
 
 
 
 
60
 
61
 
62
  title = "Interactive demo: zero-shot image segmentation with CLIPSeg"
@@ -85,7 +89,8 @@ with gr.Blocks() as demo:
85
 
86
  with gr.Column():
87
  output_plot = gr.Plot(label="Segmentation Result")
88
- output_image = gr.Image(label="Mask")
 
89
 
90
  btn_process.click(
91
  process_image,
@@ -96,7 +101,7 @@ with gr.Blocks() as demo:
96
  input_slider_A,
97
  draw_rectangles,
98
  ],
99
- outputs=[output_plot, output_image],
100
  )
101
 
102
  gr.Examples(
 
56
  ax.axis("off")
57
  plt.tight_layout()
58
 
59
+ bmask = Image.fromarray(bmask.astype(np.uint8) * 255, "L")
60
+ output_image = Image.new("RGBA", image.size, (0, 0, 0, 0))
61
+ output_image.paste(image, mask=bmask)
62
+
63
+ return fig, mask, output_image
64
 
65
 
66
  title = "Interactive demo: zero-shot image segmentation with CLIPSeg"
 
89
 
90
  with gr.Column():
91
  output_plot = gr.Plot(label="Segmentation Result")
92
+ output_mask = gr.Image(label="Mask")
93
+ output_image = gr.Image(label="Output Image")
94
 
95
  btn_process.click(
96
  process_image,
 
101
  input_slider_A,
102
  draw_rectangles,
103
  ],
104
+ outputs=[output_plot, output_mask, output_image],
105
  )
106
 
107
  gr.Examples(