Skip to content

Commit ed0174f

Browse files
Suggested changes
Co-Authored-By: Ryan Dick <[email protected]>
1 parent 5810cee commit ed0174f

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

invokeai/backend/stable_diffusion/extensions/inpaint.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ def init_tensors(self, ctx: DenoiseContext):
9494
generator=torch.Generator(device="cpu").manual_seed(ctx.seed),
9595
).to(device=ctx.latents.device, dtype=ctx.latents.dtype)
9696

97-
# TODO: order value
97+
# Use negative order to make extensions with default order work with patched latents
9898
@callback(ExtensionCallbackType.PRE_STEP, order=-100)
9999
def apply_mask_to_initial_latents(self, ctx: DenoiseContext):
100100
ctx.latents = self._apply_mask(ctx, ctx.latents, ctx.timestep)
101101

102-
# TODO: order value
103102
# TODO: redo this with preview events rewrite
103+
# Use negative order to make extensions with default order work with patched latents
104104
@callback(ExtensionCallbackType.POST_STEP, order=-100)
105105
def apply_mask_to_step_output(self, ctx: DenoiseContext):
106106
timestep = ctx.scheduler.timesteps[-1]
@@ -111,8 +111,7 @@ def apply_mask_to_step_output(self, ctx: DenoiseContext):
111111
else:
112112
ctx.step_output.pred_original_sample = self._apply_mask(ctx, ctx.step_output.prev_sample, timestep)
113113

114-
# TODO: should here be used order?
115-
# restore unmasked part after the last step is completed
114+
# Restore unmasked part after the last step is completed
116115
@callback(ExtensionCallbackType.POST_DENOISE_LOOP)
117116
def restore_unmasked(self, ctx: DenoiseContext):
118117
if self._is_gradient_mask:

invokeai/backend/stable_diffusion/extensions/inpaint_model.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ def init_tensors(self, ctx: DenoiseContext):
6868
self._masked_latents = torch.zeros_like(ctx.latents[:1])
6969
self._masked_latents = self._masked_latents.to(device=ctx.latents.device, dtype=ctx.latents.dtype)
7070

71-
# TODO: any ideas about order value?
72-
# do last so that other extensions works with normal latents
71+
# Use negative order to make extensions with default order work with patched latents
7372
@callback(ExtensionCallbackType.PRE_UNET, order=1000)
7473
def append_inpaint_layers(self, ctx: DenoiseContext):
7574
batch_size = ctx.unet_kwargs.sample.shape[0]
@@ -80,8 +79,7 @@ def append_inpaint_layers(self, ctx: DenoiseContext):
8079
dim=1,
8180
)
8281

83-
# TODO: should here be used order?
84-
# restore unmasked part as inpaint model can change unmasked part slightly
82+
# Restore unmasked part as inpaint model can change unmasked part slightly
8583
@callback(ExtensionCallbackType.POST_DENOISE_LOOP)
8684
def restore_unmasked(self, ctx: DenoiseContext):
8785
if self._is_gradient_mask:

0 commit comments

Comments
 (0)