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
ad310af0
Unverified
Commit
ad310af0
authored
Feb 26, 2024
by
M. Tolga Cangöz
Committed by
GitHub
Feb 26, 2024
Browse files
Fix EMA in train_text_to_image_sdxl.py (#7048)
* Fix typos
parent
d603ccb6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
0 deletions
+5
-0
examples/text_to_image/train_text_to_image_sdxl.py
examples/text_to_image/train_text_to_image_sdxl.py
+5
-0
No files found.
examples/text_to_image/train_text_to_image_sdxl.py
View file @
ad310af0
...
@@ -951,6 +951,9 @@ def main(args):
...
@@ -951,6 +951,9 @@ def main(args):
unet
,
optimizer
,
train_dataloader
,
lr_scheduler
unet
,
optimizer
,
train_dataloader
,
lr_scheduler
)
)
if
args
.
use_ema
:
ema_unet
.
to
(
accelerator
.
device
)
# We need to recalculate our total training steps as the size of the training dataloader may have changed.
# We need to recalculate our total training steps as the size of the training dataloader may have changed.
num_update_steps_per_epoch
=
math
.
ceil
(
len
(
train_dataloader
)
/
args
.
gradient_accumulation_steps
)
num_update_steps_per_epoch
=
math
.
ceil
(
len
(
train_dataloader
)
/
args
.
gradient_accumulation_steps
)
if
overrode_max_train_steps
:
if
overrode_max_train_steps
:
...
@@ -1126,6 +1129,8 @@ def main(args):
...
@@ -1126,6 +1129,8 @@ def main(args):
# Checks if the accelerator has performed an optimization step behind the scenes
# Checks if the accelerator has performed an optimization step behind the scenes
if
accelerator
.
sync_gradients
:
if
accelerator
.
sync_gradients
:
if
args
.
use_ema
:
ema_unet
.
step
(
unet
.
parameters
())
progress_bar
.
update
(
1
)
progress_bar
.
update
(
1
)
global_step
+=
1
global_step
+=
1
accelerator
.
log
({
"train_loss"
:
train_loss
},
step
=
global_step
)
accelerator
.
log
({
"train_loss"
:
train_loss
},
step
=
global_step
)
...
...
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