Spaces:
Running
on
Zero
Running
on
Zero
Update
Browse files
app.py
CHANGED
@@ -123,7 +123,11 @@ def run(
|
|
123 |
trimap: PIL.Image.Image,
|
124 |
apply_background_replacement: bool,
|
125 |
background_image: PIL.Image.Image | None,
|
126 |
-
) -> tuple[
|
|
|
|
|
|
|
|
|
127 |
if image.size != trimap.size:
|
128 |
raise gr.Error("Image and trimap must have the same size.")
|
129 |
if max(image.size) > MAX_IMAGE_SIZE:
|
@@ -147,7 +151,11 @@ def run(
|
|
147 |
|
148 |
res_bg_replacement = replace_background(image, alpha, background_image) if apply_background_replacement else None
|
149 |
|
150 |
-
return
|
|
|
|
|
|
|
|
|
151 |
|
152 |
|
153 |
with gr.Blocks(css_paths="style.css") as demo:
|
@@ -179,9 +187,9 @@ with gr.Blocks(css_paths="style.css") as demo:
|
|
179 |
run_button = gr.Button("Run")
|
180 |
with gr.Column():
|
181 |
with gr.Group():
|
182 |
-
out_alpha = gr.
|
183 |
-
out_foreground = gr.
|
184 |
-
out_background_replacement = gr.
|
185 |
|
186 |
inputs = [
|
187 |
image,
|
|
|
123 |
trimap: PIL.Image.Image,
|
124 |
apply_background_replacement: bool,
|
125 |
background_image: PIL.Image.Image | None,
|
126 |
+
) -> tuple[
|
127 |
+
tuple[PIL.Image.Image, np.ndarray],
|
128 |
+
tuple[PIL.Image.Image, PIL.Image.Image],
|
129 |
+
tuple[PIL.Image.Image, PIL.Image.Image] | None,
|
130 |
+
]:
|
131 |
if image.size != trimap.size:
|
132 |
raise gr.Error("Image and trimap must have the same size.")
|
133 |
if max(image.size) > MAX_IMAGE_SIZE:
|
|
|
151 |
|
152 |
res_bg_replacement = replace_background(image, alpha, background_image) if apply_background_replacement else None
|
153 |
|
154 |
+
return (
|
155 |
+
(image, alpha),
|
156 |
+
(image, foreground),
|
157 |
+
((image, res_bg_replacement) if res_bg_replacement is not None else None),
|
158 |
+
)
|
159 |
|
160 |
|
161 |
with gr.Blocks(css_paths="style.css") as demo:
|
|
|
187 |
run_button = gr.Button("Run")
|
188 |
with gr.Column():
|
189 |
with gr.Group():
|
190 |
+
out_alpha = gr.ImageSlider(label="Alpha")
|
191 |
+
out_foreground = gr.ImageSlider(label="Foreground")
|
192 |
+
out_background_replacement = gr.ImageSlider(label="Background replacement", visible=False)
|
193 |
|
194 |
inputs = [
|
195 |
image,
|