ovi054 commited on
Commit
237c48a
·
verified ·
1 Parent(s): c02a13e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -6,14 +6,15 @@ def process_image(img):
6
  imageio.imwrite("output_image.png", img["composite"])
7
 
8
  alpha_channel = img["layers"][0][:, :, 3]
9
- mask = np.where(alpha_channel == 0, 0, 255).astype(np.uint8)
 
10
 
11
  # return img["background"], mask
12
  # Save the mask as a PNG file
13
- output_path = "mask_output.png"
14
- imageio.imwrite(output_path, mask) # Save the mask as a PNG
15
 
16
- return output_path
17
 
18
  # with gr.Blocks() as demo:
19
  # with gr.Row():
@@ -29,7 +30,7 @@ demo = gr.Interface(
29
  inputs=gr.ImageMask(sources=["upload"], layers=False, transforms=[], format="png", label="base image", show_label=True),
30
  outputs=[
31
  # gr.Image(label="Background Image"),
32
- gr.Image(label="Mask Image"),
33
  ],
34
  )
35
 
 
6
  imageio.imwrite("output_image.png", img["composite"])
7
 
8
  alpha_channel = img["layers"][0][:, :, 3]
9
+ mask = np.where(alpha_channel == 0, 0, 255)
10
+ # mask = np.where(alpha_channel == 0, 0, 255).astype(np.uint8)
11
 
12
  # return img["background"], mask
13
  # Save the mask as a PNG file
14
+ # output_path = "mask_output.png"
15
+ # imageio.imwrite(output_path, mask) # Save the mask as a PNG
16
 
17
+ return mask
18
 
19
  # with gr.Blocks() as demo:
20
  # with gr.Row():
 
30
  inputs=gr.ImageMask(sources=["upload"], layers=False, transforms=[], format="png", label="base image", show_label=True),
31
  outputs=[
32
  # gr.Image(label="Background Image"),
33
+ gr.Image(label="Mask Image", format="png"),
34
  ],
35
  )
36