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
3be48918
Unverified
Commit
3be48918
authored
Mar 29, 2023
by
Yaman Ahlawat
Committed by
GitHub
Mar 29, 2023
Browse files
feat: allow offset_noise in dreambooth training example (#2826)
parent
d82b0323
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
examples/dreambooth/train_dreambooth.py
examples/dreambooth/train_dreambooth.py
+16
-1
No files found.
examples/dreambooth/train_dreambooth.py
View file @
3be48918
...
...
@@ -417,6 +417,16 @@ def parse_args(input_args=None):
),
)
parser
.
add_argument
(
"--offset_noise"
,
action
=
"store_true"
,
default
=
False
,
help
=
(
"Fine-tuning against a modified noise"
" See: https://www.crosslabs.org//blog/diffusion-with-offset-noise for more information."
),
)
if
input_args
is
not
None
:
args
=
parser
.
parse_args
(
input_args
)
else
:
...
...
@@ -943,7 +953,12 @@ def main(args):
latents
=
latents
*
vae
.
config
.
scaling_factor
# Sample noise that we'll add to the latents
noise
=
torch
.
randn_like
(
latents
)
if
args
.
offset_noise
:
noise
=
torch
.
randn_like
(
latents
)
+
0.1
*
torch
.
randn
(
latents
.
shape
[
0
],
latents
.
shape
[
1
],
1
,
1
,
device
=
latents
.
device
)
else
:
noise
=
torch
.
randn_like
(
latents
)
bsz
=
latents
.
shape
[
0
]
# Sample a random timestep for each image
timesteps
=
torch
.
randint
(
0
,
noise_scheduler
.
config
.
num_train_timesteps
,
(
bsz
,),
device
=
latents
.
device
)
...
...
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