mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Suggested changes
Co-Authored-By: Ryan Dick <14897797+RyanJDick@users.noreply.github.com>
This commit is contained in:
parent
bd8890be11
commit
5810cee6c9
@ -775,6 +775,10 @@ class DenoiseLatentsInvocation(BaseInvocation):
|
|||||||
|
|
||||||
### inpaint
|
### inpaint
|
||||||
mask, masked_latents, is_gradient_mask = self.prep_inpaint_mask(context, latents)
|
mask, masked_latents, is_gradient_mask = self.prep_inpaint_mask(context, latents)
|
||||||
|
# NOTE: We used to identify inpainting models by inpecting the shape of the loaded UNet model weights. Now we
|
||||||
|
# use the ModelVariantType config. During testing, there was a report of a user with models that had an
|
||||||
|
# incorrect ModelVariantType value. Re-installing the model fixed the issue. If this issue turns out to be
|
||||||
|
# prevalent, we will have to revisit how we initialize the inpainting extensions.
|
||||||
if unet_config.variant == ModelVariantType.Inpaint:
|
if unet_config.variant == ModelVariantType.Inpaint:
|
||||||
ext_manager.add_extension(InpaintModelExt(mask, masked_latents, is_gradient_mask))
|
ext_manager.add_extension(InpaintModelExt(mask, masked_latents, is_gradient_mask))
|
||||||
elif mask is not None:
|
elif mask is not None:
|
||||||
@ -830,6 +834,8 @@ class DenoiseLatentsInvocation(BaseInvocation):
|
|||||||
seed, noise, latents = self.prepare_noise_and_latents(context, self.noise, self.latents)
|
seed, noise, latents = self.prepare_noise_and_latents(context, self.noise, self.latents)
|
||||||
|
|
||||||
mask, masked_latents, gradient_mask = self.prep_inpaint_mask(context, latents)
|
mask, masked_latents, gradient_mask = self.prep_inpaint_mask(context, latents)
|
||||||
|
# At this point, the mask ranges from 0 (leave unchanged) to 1 (inpaint).
|
||||||
|
# We invert the mask here for compatibility with the old backend implementation.
|
||||||
if mask is not None:
|
if mask is not None:
|
||||||
mask = 1 - mask
|
mask = 1 - mask
|
||||||
|
|
||||||
|
@ -75,7 +75,11 @@ class InpaintExt(ExtensionBase):
|
|||||||
@callback(ExtensionCallbackType.PRE_DENOISE_LOOP)
|
@callback(ExtensionCallbackType.PRE_DENOISE_LOOP)
|
||||||
def init_tensors(self, ctx: DenoiseContext):
|
def init_tensors(self, ctx: DenoiseContext):
|
||||||
if not self._is_normal_model(ctx.unet):
|
if not self._is_normal_model(ctx.unet):
|
||||||
raise ValueError("InpaintExt should be used only on normal models!")
|
raise ValueError(
|
||||||
|
"InpaintExt should be used only on normal (non-inpainting) models. This could be caused by an "
|
||||||
|
"inpainting model that was incorrectly marked as a non-inpainting model. In some cases, this can be "
|
||||||
|
"fixed by removing and re-adding the model (so that it gets re-probed)."
|
||||||
|
)
|
||||||
|
|
||||||
self._mask = self._mask.to(device=ctx.latents.device, dtype=ctx.latents.dtype)
|
self._mask = self._mask.to(device=ctx.latents.device, dtype=ctx.latents.dtype)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user