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
Show 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):
...
@@ -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
:
if
input_args
is
not
None
:
args
=
parser
.
parse_args
(
input_args
)
args
=
parser
.
parse_args
(
input_args
)
else
:
else
:
...
@@ -943,6 +953,11 @@ def main(args):
...
@@ -943,6 +953,11 @@ def main(args):
latents
=
latents
*
vae
.
config
.
scaling_factor
latents
=
latents
*
vae
.
config
.
scaling_factor
# Sample noise that we'll add to the latents
# Sample noise that we'll add to the 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
)
noise
=
torch
.
randn_like
(
latents
)
bsz
=
latents
.
shape
[
0
]
bsz
=
latents
.
shape
[
0
]
# Sample a random timestep for each image
# Sample a random timestep for each image
...
...
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