Skip to content

Commit bae208b

Browse files
authored
Fix outpainting params (huggingface#1089)
1 parent b6c14ad commit bae208b

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

apps/stable_diffusion/scripts/outpaint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ def outpaint_inf(
157157
prompt,
158158
negative_prompt,
159159
image,
160-
args.pixels,
161-
args.mask_blur,
160+
pixels,
161+
mask_blur,
162162
left,
163163
right,
164164
top,

apps/stable_diffusion/src/pipelines/pipeline_shark_stable_diffusion_outpaint.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@ def prepare_latents(
6969
latents = latents * self.scheduler.init_noise_sigma
7070
return latents
7171

72-
def prepare_mask_and_masked_image(self, image, mask, mask_blur):
72+
def prepare_mask_and_masked_image(
73+
self, image, mask, mask_blur, width, height
74+
):
7375
if mask_blur > 0:
7476
mask = mask.filter(ImageFilter.GaussianBlur(mask_blur))
75-
image = image.resize((512, 512))
76-
mask = mask.resize((512, 512))
77+
image = image.resize((width, height))
78+
mask = mask.resize((width, height))
7779

7880
# preprocess image
7981
if isinstance(image, (Image.Image, np.ndarray)):
@@ -478,7 +480,7 @@ def expand(
478480

479481
# Preprocess mask and image
480482
mask, masked_image = self.prepare_mask_and_masked_image(
481-
image_to_process, mask_to_process, mask_blur
483+
image_to_process, mask_to_process, mask_blur, width, height
482484
)
483485

484486
# Prepare mask latent variables

apps/stable_diffusion/src/utils/stable_args.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ def path_expand(s):
6161
"--height",
6262
type=int,
6363
default=512,
64+
choices=range(384, 768, 8),
6465
help="the height of the output image.",
6566
)
6667

6768
p.add_argument(
6869
"--width",
6970
type=int,
7071
default=512,
72+
choices=range(384, 768, 8),
7173
help="the width of the output image.",
7274
)
7375

0 commit comments

Comments
 (0)