Spaces:
Runtime error
Runtime error
negative mask
Browse files
stablediffusion-infinity/app.py
CHANGED
@@ -73,7 +73,6 @@ except Exception as e:
|
|
73 |
blocks = gr.Blocks().queue()
|
74 |
model = {}
|
75 |
|
76 |
-
WHITES = 66846720
|
77 |
STATIC_MASK = Image.open("mask.png")
|
78 |
|
79 |
|
@@ -133,10 +132,10 @@ def run_outpaint(
|
|
133 |
sel_buffer = np.array(input_image)
|
134 |
img = sel_buffer[:, :, 0:3]
|
135 |
mask = sel_buffer[:, :, -1]
|
|
|
136 |
process_size = 512
|
137 |
|
138 |
-
|
139 |
-
if mask_sum >= WHITES:
|
140 |
print("inpaiting with fixed Mask")
|
141 |
mask = np.array(STATIC_MASK)[:, :, 0]
|
142 |
img, mask = functbl[fill_mode](img, mask)
|
@@ -145,7 +144,7 @@ def run_outpaint(
|
|
145 |
mask = skimage.measure.block_reduce(mask, (8, 8), np.max)
|
146 |
mask = mask.repeat(8, axis=0).repeat(8, axis=1)
|
147 |
mask_image = Image.fromarray(mask)
|
148 |
-
elif
|
149 |
print("inpainting")
|
150 |
img, mask = functbl[fill_mode](img, mask)
|
151 |
init_image = Image.fromarray(img)
|
|
|
73 |
blocks = gr.Blocks().queue()
|
74 |
model = {}
|
75 |
|
|
|
76 |
STATIC_MASK = Image.open("mask.png")
|
77 |
|
78 |
|
|
|
132 |
sel_buffer = np.array(input_image)
|
133 |
img = sel_buffer[:, :, 0:3]
|
134 |
mask = sel_buffer[:, :, -1]
|
135 |
+
nmask = 255 - mask
|
136 |
process_size = 512
|
137 |
|
138 |
+
if nmask.sum() < 1:
|
|
|
139 |
print("inpaiting with fixed Mask")
|
140 |
mask = np.array(STATIC_MASK)[:, :, 0]
|
141 |
img, mask = functbl[fill_mode](img, mask)
|
|
|
144 |
mask = skimage.measure.block_reduce(mask, (8, 8), np.max)
|
145 |
mask = mask.repeat(8, axis=0).repeat(8, axis=1)
|
146 |
mask_image = Image.fromarray(mask)
|
147 |
+
elif mask.sum() > 0:
|
148 |
print("inpainting")
|
149 |
img, mask = functbl[fill_mode](img, mask)
|
150 |
init_image = Image.fromarray(img)
|