Skip to content

Commit 2da4741

Browse files
committed
fix w h
1 parent 0c92360 commit 2da4741

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

examples/text_to_image/pipeline_stable_diffusion_img2img_render_text.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,18 @@ def __call__(
206206
)
207207
# 6.1 Prepare latent variables
208208
num_channels_latents = self.unet.in_channels // 2
209+
210+
# copied from https://github.com/huggingface/diffusers/blob/main/examples/community/img2img_inpainting.py
211+
if isinstance(image, PIL.Image.Image):
212+
w, h = image.size
213+
elif isinstance(image, torch.Tensor):
214+
*_, h, w = image.shape
215+
209216
latents = self.prepare_latents(
210217
batch_size * num_images_per_prompt,
211218
num_channels_latents,
212-
image.shape[2],
213-
image.shape[1],
219+
h,
220+
w,
214221
text_embeddings.dtype,
215222
device,
216223
generator,

0 commit comments

Comments
 (0)