r3gm commited on
Commit
62e1b92
·
verified ·
1 Parent(s): b8c262f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -1,16 +1,21 @@
1
  import gradio as gr
2
  import imageio
 
3
 
4
- def dummy(img):
5
- imageio.imwrite("output_image.png", img["mask"])
6
- return img["image"], img["mask"]
 
 
 
7
 
8
  with gr.Blocks() as demo:
9
  with gr.Row():
10
  img = gr.Image(tool="sketch", label="base image", show_label=True)
11
  img1 = gr.Image()
12
  img2 = gr.Image(label="mask image", show_label=True)
 
13
  btn = gr.Button()
14
- btn.click(dummy, img, [img1, img2])
15
 
16
  demo.launch(debug=True)
 
1
  import gradio as gr
2
  import imageio
3
+ import numpy as np
4
 
5
+ def dummy(img, invert_mask):
6
+ mask = img["mask"]
7
+ if invert_mask and mask is not None:
8
+ mask = 255 - np.array(mask)
9
+ imageio.imwrite("output_image.png", mask)
10
+ return img["image"], mask
11
 
12
  with gr.Blocks() as demo:
13
  with gr.Row():
14
  img = gr.Image(tool="sketch", label="base image", show_label=True)
15
  img1 = gr.Image()
16
  img2 = gr.Image(label="mask image", show_label=True)
17
+ invert = gr.Checkbox(label="Invert mask")
18
  btn = gr.Button()
19
+ btn.click(dummy, [img, invert], [img1, img2])
20
 
21
  demo.launch(debug=True)