Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
9fb02175
Unverified
Commit
9fb02175
authored
Mar 24, 2023
by
Bahjat Kawar
Committed by
GitHub
Mar 24, 2023
Browse files
StableDiffusionModelEditingPipeline documentation (#2810)
* comment update * comment update
parent
5883d8d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py
...able_diffusion/pipeline_stable_diffusion_model_editing.py
+22
-4
No files found.
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py
View file @
9fb02175
...
...
@@ -467,10 +467,28 @@ class StableDiffusionModelEditingPipeline(DiffusionPipeline):
return
latents
@
torch
.
no_grad
()
def
edit_model
(
self
,
source_prompt
,
destination_prompt
,
lamb
=
0.1
,
restart_params
=
True
):
# Apply model editing via closed-form solution (see Eq. 5 in the TIME paper https://arxiv.org/abs/2303.08084)
# When `restart_params` is True (default), the model parameters restart to their pre-trained version.
# This is done to avoid edit compounding. When it is False, edits accumulate (behavior not studied in paper).
def
edit_model
(
self
,
source_prompt
:
str
,
destination_prompt
:
str
,
lamb
:
float
=
0.1
,
restart_params
:
bool
=
True
,
):
r
"""
Apply model editing via closed-form solution (see Eq. 5 in the TIME paper https://arxiv.org/abs/2303.08084)
Args:
source_prompt (`str`):
The source prompt containing the concept to be edited.
destination_prompt (`str`):
The destination prompt. Must contain all words from source_prompt with additional ones to specify the
target edit.
lamb (`float`, *optional*, defaults to 0.1):
The lambda parameter specifying the regularization intesity. Smaller values increase the editing power.
restart_params (`bool`, *optional*, defaults to True):
Restart the model parameters to their pre-trained version before editing. This is done to avoid edit
compounding. When it is False, edits accumulate.
"""
# restart LDM parameters
if
restart_params
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment