Spaces:
Running
on
Zero
Running
on
Zero
Fix mask
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ import spaces
|
|
7 |
import torch
|
8 |
from diffusers import FluxFillPipeline
|
9 |
from gradio.components.image_editor import EditorValue
|
10 |
-
from PIL import Image, ImageOps
|
11 |
|
12 |
DEVICE = "cuda"
|
13 |
|
@@ -122,12 +122,16 @@ def infer(
|
|
122 |
(255, 255, 255),
|
123 |
)
|
124 |
mask.paste(_furniture_mask, (0, 0))
|
125 |
-
mask.paste(_room_mask, (FIXED_DIMENSION, 0))
|
126 |
|
127 |
width, height = calculate_optimal_dimensions(image)
|
128 |
# Resize the image and mask to the optimal dimensions for the VAe
|
129 |
image = image.resize((width, height))
|
130 |
mask = mask.resize((width, height))
|
|
|
|
|
|
|
|
|
131 |
|
132 |
if randomize_seed:
|
133 |
seed = secrets.randbelow(MAX_SEED)
|
@@ -183,7 +187,7 @@ with gr.Blocks(css=css) as demo:
|
|
183 |
label="Room Image - Draw mask for inpainting",
|
184 |
type="pil",
|
185 |
sources=["upload"],
|
186 |
-
image_mode="
|
187 |
layers=False,
|
188 |
brush=gr.Brush(colors=["#FFFFFF"], color_mode="fixed"),
|
189 |
height=300,
|
|
|
7 |
import torch
|
8 |
from diffusers import FluxFillPipeline
|
9 |
from gradio.components.image_editor import EditorValue
|
10 |
+
from PIL import Image, ImageFilter, ImageOps
|
11 |
|
12 |
DEVICE = "cuda"
|
13 |
|
|
|
122 |
(255, 255, 255),
|
123 |
)
|
124 |
mask.paste(_furniture_mask, (0, 0))
|
125 |
+
mask.paste(_room_mask, (FIXED_DIMENSION, 0), _room_mask)
|
126 |
|
127 |
width, height = calculate_optimal_dimensions(image)
|
128 |
# Resize the image and mask to the optimal dimensions for the VAe
|
129 |
image = image.resize((width, height))
|
130 |
mask = mask.resize((width, height))
|
131 |
+
# Invert the mask
|
132 |
+
mask = ImageOps.invert(mask)
|
133 |
+
# Blur the mask
|
134 |
+
mask = mask.filter(ImageFilter.GaussianBlur(radius=33))
|
135 |
|
136 |
if randomize_seed:
|
137 |
seed = secrets.randbelow(MAX_SEED)
|
|
|
187 |
label="Room Image - Draw mask for inpainting",
|
188 |
type="pil",
|
189 |
sources=["upload"],
|
190 |
+
image_mode="RGBA",
|
191 |
layers=False,
|
192 |
brush=gr.Brush(colors=["#FFFFFF"], color_mode="fixed"),
|
193 |
height=300,
|