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
bf9a641f
Unverified
Commit
bf9a641f
authored
Dec 21, 2024
by
hlky
Committed by
GitHub
Dec 21, 2024
Browse files
Fix EMAModel test_from_pretrained (#10325)
parent
a756694b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
0 deletions
+2
-0
tests/others/test_ema.py
tests/others/test_ema.py
+2
-0
No files found.
tests/others/test_ema.py
View file @
bf9a641f
...
@@ -67,6 +67,7 @@ class EMAModelTests(unittest.TestCase):
...
@@ -67,6 +67,7 @@ class EMAModelTests(unittest.TestCase):
# Load the EMA model from the saved directory
# Load the EMA model from the saved directory
loaded_ema_unet
=
EMAModel
.
from_pretrained
(
tmpdir
,
model_cls
=
UNet2DConditionModel
,
foreach
=
False
)
loaded_ema_unet
=
EMAModel
.
from_pretrained
(
tmpdir
,
model_cls
=
UNet2DConditionModel
,
foreach
=
False
)
loaded_ema_unet
.
to
(
torch_device
)
# Check that the shadow parameters of the loaded model match the original EMA model
# Check that the shadow parameters of the loaded model match the original EMA model
for
original_param
,
loaded_param
in
zip
(
ema_unet
.
shadow_params
,
loaded_ema_unet
.
shadow_params
):
for
original_param
,
loaded_param
in
zip
(
ema_unet
.
shadow_params
,
loaded_ema_unet
.
shadow_params
):
...
@@ -221,6 +222,7 @@ class EMAModelTestsForeach(unittest.TestCase):
...
@@ -221,6 +222,7 @@ class EMAModelTestsForeach(unittest.TestCase):
# Load the EMA model from the saved directory
# Load the EMA model from the saved directory
loaded_ema_unet
=
EMAModel
.
from_pretrained
(
tmpdir
,
model_cls
=
UNet2DConditionModel
,
foreach
=
True
)
loaded_ema_unet
=
EMAModel
.
from_pretrained
(
tmpdir
,
model_cls
=
UNet2DConditionModel
,
foreach
=
True
)
loaded_ema_unet
.
to
(
torch_device
)
# Check that the shadow parameters of the loaded model match the original EMA model
# Check that the shadow parameters of the loaded model match the original EMA model
for
original_param
,
loaded_param
in
zip
(
ema_unet
.
shadow_params
,
loaded_ema_unet
.
shadow_params
):
for
original_param
,
loaded_param
in
zip
(
ema_unet
.
shadow_params
,
loaded_ema_unet
.
shadow_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