Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,18 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import imageio
|
3 |
|
4 |
def dummy(img):
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
7 |
|
8 |
with gr.Blocks() as demo:
|
9 |
with gr.Row():
|
10 |
-
img = gr.
|
11 |
img1 = gr.Image()
|
12 |
img2 = gr.Image(label="mask image", show_label=True)
|
13 |
btn = gr.Button()
|
|
|
1 |
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]
|
9 |
+
mask = np.where(alpha_channel == 0, 0, 255)
|
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()
|