Skip to content

Commit 9fb0217

Browse files
authored
StableDiffusionModelEditingPipeline documentation (#2810)
* comment update * comment update
1 parent 5883d8d commit 9fb0217

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,28 @@ def prepare_latents(self, batch_size, num_channels_latents, height, width, dtype
467467
return latents
468468

469469
@torch.no_grad()
470-
def edit_model(self, source_prompt, destination_prompt, lamb=0.1, restart_params=True):
471-
# Apply model editing via closed-form solution (see Eq. 5 in the TIME paper https://arxiv.org/abs/2303.08084)
472-
# When `restart_params` is True (default), the model parameters restart to their pre-trained version.
473-
# This is done to avoid edit compounding. When it is False, edits accumulate (behavior not studied in paper).
470+
def edit_model(
471+
self,
472+
source_prompt: str,
473+
destination_prompt: str,
474+
lamb: float = 0.1,
475+
restart_params: bool = True,
476+
):
477+
r"""
478+
Apply model editing via closed-form solution (see Eq. 5 in the TIME paper https://arxiv.org/abs/2303.08084)
479+
480+
Args:
481+
source_prompt (`str`):
482+
The source prompt containing the concept to be edited.
483+
destination_prompt (`str`):
484+
The destination prompt. Must contain all words from source_prompt with additional ones to specify the
485+
target edit.
486+
lamb (`float`, *optional*, defaults to 0.1):
487+
The lambda parameter specifying the regularization intesity. Smaller values increase the editing power.
488+
restart_params (`bool`, *optional*, defaults to True):
489+
Restart the model parameters to their pre-trained version before editing. This is done to avoid edit
490+
compounding. When it is False, edits accumulate.
491+
"""
474492

475493
# restart LDM parameters
476494
if restart_params:

0 commit comments

Comments
 (0)