mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Added resizing of controlnet image based on noise latent. Fixes a tensor mismatch issue.
This commit is contained in:
parent
9c8c2e49d6
commit
0096fb2790
@ -371,6 +371,10 @@ class TextToLatentsInvocation(BaseInvocation):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
latents_shape = noise.shape
|
||||||
|
control_height_resize = latents_shape[2] * 8
|
||||||
|
control_width_resize = latents_shape[3] * 8
|
||||||
|
|
||||||
# copied from old backend/txt2img.py
|
# copied from old backend/txt2img.py
|
||||||
# FIXME: still need to test with different widths, heights, devices, dtypes
|
# FIXME: still need to test with different widths, heights, devices, dtypes
|
||||||
# and add in batch_size, num_images_per_prompt?
|
# and add in batch_size, num_images_per_prompt?
|
||||||
@ -380,10 +384,8 @@ class TextToLatentsInvocation(BaseInvocation):
|
|||||||
image=control_image,
|
image=control_image,
|
||||||
# do_classifier_free_guidance=do_classifier_free_guidance,
|
# do_classifier_free_guidance=do_classifier_free_guidance,
|
||||||
do_classifier_free_guidance=True,
|
do_classifier_free_guidance=True,
|
||||||
# width=width,
|
width=control_width_resize,
|
||||||
# height=height,
|
height=control_height_resize,
|
||||||
width=512,
|
|
||||||
height=512,
|
|
||||||
# batch_size=batch_size * num_images_per_prompt,
|
# batch_size=batch_size * num_images_per_prompt,
|
||||||
# num_images_per_prompt=num_images_per_prompt,
|
# num_images_per_prompt=num_images_per_prompt,
|
||||||
device=control_model.device,
|
device=control_model.device,
|
||||||
@ -396,10 +398,8 @@ class TextToLatentsInvocation(BaseInvocation):
|
|||||||
image=image_,
|
image=image_,
|
||||||
# do_classifier_free_guidance=do_classifier_free_guidance,
|
# do_classifier_free_guidance=do_classifier_free_guidance,
|
||||||
do_classifier_free_guidance=True,
|
do_classifier_free_guidance=True,
|
||||||
# width=width,
|
width=control_width_resize,
|
||||||
# height=height,
|
height=control_height_resize,
|
||||||
width=512,
|
|
||||||
height=512,
|
|
||||||
# batch_size=batch_size * num_images_per_prompt,
|
# batch_size=batch_size * num_images_per_prompt,
|
||||||
# num_images_per_prompt=num_images_per_prompt,
|
# num_images_per_prompt=num_images_per_prompt,
|
||||||
device=control_model.device,
|
device=control_model.device,
|
||||||
@ -408,8 +408,6 @@ class TextToLatentsInvocation(BaseInvocation):
|
|||||||
images.append(image_)
|
images.append(image_)
|
||||||
control_image = images
|
control_image = images
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: Verify the noise is the right size
|
# TODO: Verify the noise is the right size
|
||||||
result_latents, result_attention_map_saver = model.latents_from_embeddings(
|
result_latents, result_attention_map_saver = model.latents_from_embeddings(
|
||||||
latents=torch.zeros_like(noise, dtype=torch_dtype(model.device)),
|
latents=torch.zeros_like(noise, dtype=torch_dtype(model.device)),
|
||||||
|
@ -1003,6 +1003,7 @@ class StableDiffusionGeneratorPipeline(StableDiffusionPipeline):
|
|||||||
dtype=torch.float16,
|
dtype=torch.float16,
|
||||||
do_classifier_free_guidance=True,
|
do_classifier_free_guidance=True,
|
||||||
):
|
):
|
||||||
|
|
||||||
if not isinstance(image, torch.Tensor):
|
if not isinstance(image, torch.Tensor):
|
||||||
if isinstance(image, PIL.Image.Image):
|
if isinstance(image, PIL.Image.Image):
|
||||||
image = [image]
|
image = [image]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user