diffengine.engine.hooks
¶ Submodules¶ Package Contents¶ Classes¶
Bases: mmengine.hooks.Hook
Compile Hook.
Args:¶
- backend (str): The backend to use for compilation.
Defaults to “inductor”.
mode (str): The mode to use for compilation. Defaults to None. compile_main (bool): Whether to compile the main network like unet or
transformer. Defaults to False.
Compile the model.
Args:¶runner (Runner): The runner of the training process.
runner (mmengine.runner.Runner) –
None
backend (str) –
mode (str | None) –
compile_main (bool) –
Bases: mmengine.hooks.Hook
ControlNet Save Hook.
Save ControlNet weights with diffusers format and pick up ControlNet weights from checkpoint.
Before save checkpoint hook.
Args:¶
- runner (Runner): The runner of the training, validation or testing
process.
checkpoint (dict): Model’s checkpoint.
runner (mmengine.runner.Runner) –
checkpoint (dict) –
None
Bases: mmengine.hooks.Hook
Fast Normalization Hook.
Replace the normalization layer with a faster one.
Args:¶
- fuse_text_encoder_ln (bool): Whether to fuse the text encoder layer
normalization. Defaults to False.
- fuse_main_ln (bool): Whether to replace the layer normalization
in main module like unet or transformer. Defaults to True.
- fuse_gn (bool)Whether to replace the group normalization.
Defaults to False.
Replace the layer normalization with a fused one.
module (torch.nn.Module) –
name (str) –
device (str) –
None
Replace the layer normalization with a fused one.
module (torch.nn.Module) –
name (str) –
device (str) –
None
Replace the group normalization forward with a faster one.
module (torch.nn.Module) –
name (str) –
None
Replace the normalization layer with a faster one.
Args:¶runner (Runner): The runner of the training process.
runner (mmengine.runner.Runner) –
None
fuse_text_encoder_ln (bool) –
fuse_main_ln (bool) –
fuse_gn (bool) –
Bases: mmengine.hooks.Hook
IP Adapter Save Hook.
Save IP-Adapter weights with diffusers format and pick up weights from checkpoint.
Before save checkpoint hook.
Args:¶
- runner (Runner): The runner of the training, validation or testing
process.
checkpoint (dict): Model’s checkpoint.
runner (mmengine.runner.Runner) –
checkpoint (dict) –
None
Bases: mmengine.hooks.hook.Hook
LCM EMA Update Hook.
Create an ema copy of the model.
Args:¶runner (Runner): The runner of the training process.
runner (mmengine.runner.Runner) –
None
Update ema parameter.
Args:¶runner (Runner): The runner of the training process. batch_idx (int): The index of the current batch in the train loop. data_batch (Sequence[dict], optional): Data from dataloader.
Defaults to None.
outputs (dict, optional): Outputs from model. Defaults to None.
runner (mmengine.runner.Runner) –
batch_idx (int) –
data_batch (mmengine.hooks.hook.DATA_BATCH) –
outputs (dict | None) –
None
Bases: mmengine.hooks.Hook
Peft Save Hook.
Save LoRA weights with diffusers format and pick up LoRA weights from checkpoint.
Before save checkpoint hook.
Args:¶
- runner (Runner): The runner of the training, validation or testing
process.
checkpoint (dict): Model’s checkpoint.
runner (mmengine.runner.Runner) –
checkpoint (dict) –
None
Bases: mmengine.hooks.Hook
Prior Save Hook.
Save Prior weights with diffusers format and pick up Prior weights from checkpoint.
Before save checkpoint hook.
Args:¶
- runner (Runner): The runner of the training, validation or testing
process.
checkpoint (dict): Model’s checkpoint.
runner (mmengine.runner.Runner) –
checkpoint (dict) –
None
Bases: mmengine.hooks.Hook
Delete ‘vae’ from checkpoint for efficient save.
Before save checkpoint hook.
Args:¶
- runner (Runner): The runner of the training, validation or testing
process.
checkpoint (dict): Model’s checkpoint.
runner (mmengine.runner.Runner) –
checkpoint (dict) –
None
Bases: mmengine.hooks.Hook
T2I Adapter Save Hook.
Save T2I-Adapter weights with diffusers format and pick up weights from checkpoint.
Before save checkpoint hook.
Args:¶
- runner (Runner): The runner of the training, validation or testing
process.
checkpoint (dict): Model’s checkpoint.
runner (mmengine.runner.Runner) –
checkpoint (dict) –
None
Bases: mmengine.hooks.Hook
Delete ‘vae’ from checkpoint for efficient save.
Before save checkpoint hook.
Args:¶
- runner (Runner): The runner of the training, validation or testing
process.
checkpoint (dict): Model’s checkpoint.
runner (mmengine.runner.Runner) –
checkpoint (dict) –
None
Bases: mmengine.hooks.ema_hook.EMAHook
Unet EMA Hook.
ema_type (str) –
strict_load (bool) –
begin_iter (int) –
begin_epoch (int) –
Create an ema copy of the model.
Args:¶runner (Runner): The runner of the training process.
runner (mmengine.runner.Runner) –
None
Swap the state dict values of model with ema_model.
checkpoint (dict) –
None
Resume ema parameters from checkpoint.
Args:¶runner (Runner): The runner of the testing process. checkpoint (dict): Model’s checkpoint.
runner (mmengine.runner.Runner) –
checkpoint (dict) –
None
Bases: mmengine.hooks.Hook
Basic hook that invoke visualizers after train epoch.
Args:¶
- prompt (List[str]):
The prompt or prompts to guide the image generation.
- interval (int): Visualization interval (every k iterations).
Defaults to 1.
by_epoch (bool): Whether to visualize by epoch. Defaults to True. height (int, optional, defaults to
self.unet.config.sample_size * self.vae_scale_factor): The height in pixels of the generated image.
- width (int, optional, defaults to
self.unet.config.sample_size * self.vae_scale_factor): The width in pixels of the generated image.
Before train hook.
runner (mmengine.runner.Runner) –
None
After train iter hook.
Args:¶runner (Runner): The runner of the training process. batch_idx (int): The index of the current batch. data_batch (DATA_BATCH, optional): The current data batch. outputs (dict, optional): The outputs of the current batch.
runner (mmengine.runner.Runner) –
batch_idx (int) –
data_batch (mmengine.hooks.hook.DATA_BATCH) –
outputs (Optional[dict]) –
None
After train epoch hook.
Args:¶runner (Runner): The runner of the training process.
runner (mmengine.runner.Runner) –
None
prompt (list[str]) –
interval (int) –
height (int | None) –
width (int | None) –
by_epoch (bool) –
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4