mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Renames
This commit is contained in:
parent
bd8ae5d896
commit
3a9dda9177
@ -781,7 +781,7 @@ class DenoiseLatentsInvocation(BaseInvocation):
|
|||||||
unet_config = context.models.get_config(self.unet.unet.key)
|
unet_config = context.models.get_config(self.unet.unet.key)
|
||||||
|
|
||||||
# ext: t2i/ip adapter
|
# ext: t2i/ip adapter
|
||||||
ext_manager.callbacks.pre_unet_load(denoise_ctx, ext_manager)
|
ext_manager.callbacks.setup(denoise_ctx, ext_manager)
|
||||||
|
|
||||||
unet_info = context.models.load(self.unet.unet)
|
unet_info = context.models.load(self.unet.unet)
|
||||||
assert isinstance(unet_info.model, UNet2DConditionModel)
|
assert isinstance(unet_info.model, UNet2DConditionModel)
|
||||||
|
@ -129,6 +129,7 @@ class TextConditioningData:
|
|||||||
device = unet_kwargs.sample.device
|
device = unet_kwargs.sample.device
|
||||||
dtype = unet_kwargs.sample.dtype
|
dtype = unet_kwargs.sample.dtype
|
||||||
|
|
||||||
|
# TODO: combine regions with conditionings
|
||||||
if conditioning_mode == "both":
|
if conditioning_mode == "both":
|
||||||
conditionings = [self.uncond_text.embeds, self.cond_text.embeds]
|
conditionings = [self.uncond_text.embeds, self.cond_text.embeds]
|
||||||
c_regions = [self.uncond_regions, self.cond_regions]
|
c_regions = [self.uncond_regions, self.cond_regions]
|
||||||
|
@ -61,7 +61,10 @@ class StableDiffusionBackend:
|
|||||||
def step(self, ctx: DenoiseContext, ext_manager: ExtensionsManager) -> SchedulerOutput:
|
def step(self, ctx: DenoiseContext, ext_manager: ExtensionsManager) -> SchedulerOutput:
|
||||||
ctx.latent_model_input = ctx.scheduler.scale_model_input(ctx.latents, ctx.timestep)
|
ctx.latent_model_input = ctx.scheduler.scale_model_input(ctx.latents, ctx.timestep)
|
||||||
|
|
||||||
# TODO: conditionings as list
|
# TODO: conditionings as list(conditioning_data.to_unet_kwargs - ready)
|
||||||
|
# Note: The current handling of conditioning doesn't feel very future-proof.
|
||||||
|
# This might change in the future as new requirements come up, but for now,
|
||||||
|
# this is the rough plan.
|
||||||
if self.sequential_guidance:
|
if self.sequential_guidance:
|
||||||
ctx.negative_noise_pred = self.run_unet(ctx, ext_manager, "negative")
|
ctx.negative_noise_pred = self.run_unet(ctx, ext_manager, "negative")
|
||||||
ctx.positive_noise_pred = self.run_unet(ctx, ext_manager, "positive")
|
ctx.positive_noise_pred = self.run_unet(ctx, ext_manager, "positive")
|
||||||
@ -74,7 +77,7 @@ class StableDiffusionBackend:
|
|||||||
|
|
||||||
# ext: cfg_rescale [modify_noise_prediction]
|
# ext: cfg_rescale [modify_noise_prediction]
|
||||||
# TODO: rename
|
# TODO: rename
|
||||||
ext_manager.callbacks.modify_noise_prediction(ctx, ext_manager)
|
ext_manager.callbacks.post_apply_cfg(ctx, ext_manager)
|
||||||
|
|
||||||
# compute the previous noisy sample x_t -> x_t-1
|
# compute the previous noisy sample x_t -> x_t-1
|
||||||
step_output = ctx.scheduler.step(ctx.noise_pred, ctx.timestep, ctx.latents, **ctx.scheduler_step_kwargs)
|
step_output = ctx.scheduler.step(ctx.noise_pred, ctx.timestep, ctx.latents, **ctx.scheduler_step_kwargs)
|
||||||
@ -113,14 +116,16 @@ class StableDiffusionBackend:
|
|||||||
ctx.conditioning_mode = conditioning_mode
|
ctx.conditioning_mode = conditioning_mode
|
||||||
ctx.conditioning_data.to_unet_kwargs(ctx.unet_kwargs, ctx.conditioning_mode)
|
ctx.conditioning_data.to_unet_kwargs(ctx.unet_kwargs, ctx.conditioning_mode)
|
||||||
|
|
||||||
# ext: controlnet/ip/t2i [pre_unet_forward]
|
# ext: controlnet/ip/t2i [pre_unet]
|
||||||
ext_manager.callbacks.pre_unet_forward(ctx, ext_manager)
|
ext_manager.callbacks.pre_unet(ctx, ext_manager)
|
||||||
|
|
||||||
# ext: inpaint [pre_unet_forward, priority=low]
|
# ext: inpaint [pre_unet, priority=low]
|
||||||
# or
|
# or
|
||||||
# ext: inpaint [override: unet_forward]
|
# ext: inpaint [override: unet_forward]
|
||||||
noise_pred = self._unet_forward(**vars(ctx.unet_kwargs))
|
noise_pred = self._unet_forward(**vars(ctx.unet_kwargs))
|
||||||
|
|
||||||
|
ext_manager.callbacks.post_unet(ctx, ext_manager)
|
||||||
|
|
||||||
del ctx.unet_kwargs
|
del ctx.unet_kwargs
|
||||||
del ctx.conditioning_mode
|
del ctx.conditioning_mode
|
||||||
|
|
||||||
|
@ -16,6 +16,10 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
class ExtCallbacksApi(ABC):
|
class ExtCallbacksApi(ABC):
|
||||||
|
@abstractmethod
|
||||||
|
def setup(self, ctx: DenoiseContext, ext_manager: ExtensionsManager):
|
||||||
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def pre_denoise_loop(self, ctx: DenoiseContext, ext_manager: ExtensionsManager):
|
def pre_denoise_loop(self, ctx: DenoiseContext, ext_manager: ExtensionsManager):
|
||||||
pass
|
pass
|
||||||
@ -33,15 +37,15 @@ class ExtCallbacksApi(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def modify_noise_prediction(self, ctx: DenoiseContext, ext_manager: ExtensionsManager):
|
def pre_unet(self, ctx: DenoiseContext, ext_manager: ExtensionsManager):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def pre_unet_forward(self, ctx: DenoiseContext, ext_manager: ExtensionsManager):
|
def post_unet(self, ctx: DenoiseContext, ext_manager: ExtensionsManager):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def pre_unet_load(self, ctx: DenoiseContext, ext_manager: ExtensionsManager):
|
def post_apply_cfg(self, ctx: DenoiseContext, ext_manager: ExtensionsManager):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user