Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
diffusers
Commits
79db3eb6
Commit
79db3eb6
authored
Jun 28, 2022
by
Patrick von Platen
Browse files
fix tests
parent
e372767c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
tests/test_modeling_utils.py
tests/test_modeling_utils.py
+5
-4
No files found.
tests/test_modeling_utils.py
View file @
79db3eb6
...
...
@@ -845,7 +845,6 @@ class PipelineTesterMixin(unittest.TestCase):
@
slow
def
test_ddpm_cifar10
(
self
):
generator
=
torch
.
manual_seed
(
0
)
model_id
=
"fusing/ddpm-cifar10"
unet
=
UNetModel
.
from_pretrained
(
model_id
)
...
...
@@ -853,12 +852,14 @@ class PipelineTesterMixin(unittest.TestCase):
noise_scheduler
=
noise_scheduler
.
set_format
(
"pt"
)
ddpm
=
DDPMPipeline
(
unet
=
unet
,
noise_scheduler
=
noise_scheduler
)
generator
=
torch
.
manual_seed
(
0
)
image
=
ddpm
(
generator
=
generator
)
image_slice
=
image
[
0
,
-
1
,
-
3
:,
-
3
:].
cpu
()
assert
image
.
shape
==
(
1
,
3
,
32
,
32
)
expected_slice
=
torch
.
tensor
([
0.
2249
,
0.
337
5
,
0.
23
59
,
0.
0929
,
0.
3439
,
0.
3156
,
0.
1937
,
0.
3585
,
0.
1761
])
expected_slice
=
torch
.
tensor
([
-
0.
5712
,
-
0.
621
5
,
-
0.59
53
,
-
0.
5438
,
-
0.
4775
,
-
0.
4539
,
-
0.
5172
,
-
0.
4872
,
-
0.
5105
])
assert
(
image_slice
.
flatten
()
-
expected_slice
).
abs
().
max
()
<
1e-2
@
slow
...
...
@@ -883,20 +884,20 @@ class PipelineTesterMixin(unittest.TestCase):
@
slow
def
test_pndm_cifar10
(
self
):
generator
=
torch
.
manual_seed
(
0
)
model_id
=
"fusing/ddpm-cifar10"
unet
=
UNetModel
.
from_pretrained
(
model_id
)
noise_scheduler
=
PNDMScheduler
(
tensor_format
=
"pt"
)
pndm
=
PNDMPipeline
(
unet
=
unet
,
noise_scheduler
=
noise_scheduler
)
generator
=
torch
.
manual_seed
(
0
)
image
=
pndm
(
generator
=
generator
)
image_slice
=
image
[
0
,
-
1
,
-
3
:,
-
3
:].
cpu
()
assert
image
.
shape
==
(
1
,
3
,
32
,
32
)
expected_slice
=
torch
.
tensor
(
[
-
0.
7925
,
-
0.7
902
,
-
0.7
789
,
-
0.7
796
,
-
0.
8000
,
-
0.7
596
,
-
0.
6852
,
-
0.7
12
5
,
-
0.7
494
]
[
-
0.
6872
,
-
0.7
071
,
-
0.7
188
,
-
0.7
057
,
-
0.
7515
,
-
0.7
191
,
-
0.
7377
,
-
0.7
56
5
,
-
0.7
500
]
)
assert
(
image_slice
.
flatten
()
-
expected_slice
).
abs
().
max
()
<
1e-2
...
...
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