ovi054 commited on
Commit
fd0a6a1
·
verified ·
1 Parent(s): ddf21d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -8
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  import numpy as np
3
  import imageio
4
 
5
- def dummy(img):
6
  imageio.imwrite("output_image.png", img["composite"])
7
 
8
  alpha_channel = img["layers"][0][:, :, 3]
@@ -10,12 +10,22 @@ def dummy(img):
10
 
11
  return img["background"], mask
12
 
13
- with gr.Blocks() as demo:
14
- with gr.Row():
15
- img = gr.ImageMask(sources=["upload"], layers=False, transforms=[], format="png", label="base image", show_label=True)
16
- img1 = gr.Image()
17
- img2 = gr.Image(label="mask image", show_label=True)
18
- btn = gr.Button()
19
- btn.click(dummy, img, [img1, img2])
 
 
 
 
 
 
 
 
 
 
20
 
21
  demo.launch(debug=True)
 
2
  import numpy as np
3
  import imageio
4
 
5
+ def process_image(img):
6
  imageio.imwrite("output_image.png", img["composite"])
7
 
8
  alpha_channel = img["layers"][0][:, :, 3]
 
10
 
11
  return img["background"], mask
12
 
13
+ # with gr.Blocks() as demo:
14
+ # with gr.Row():
15
+ # img = gr.ImageMask(sources=["upload"], layers=False, transforms=[], format="png", label="base image", show_label=True)
16
+ # img1 = gr.Image()
17
+ # img2 = gr.Image(label="mask image", show_label=True)
18
+ # btn = gr.Button()
19
+ # btn.click(dummy, img, [img1, img2])
20
+
21
+ # Define the Gradio interface
22
+ demo = gr.Interface(
23
+ fn=process_image,
24
+ inputs=gr.ImageMask(sources=["upload"], layers=False, transforms=[], format="png", label="base image", show_label=True),
25
+ outputs=[
26
+ gr.Image(label="Background Image"),
27
+ gr.Image(label="Mask Image"),
28
+ ],
29
+ )
30
 
31
  demo.launch(debug=True)