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
5da71f8f
Commit
5da71f8f
authored
Jun 07, 2022
by
Patrick von Platen
Browse files
fix generator 2
parent
8edf5981
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
tests/test_modeling_utils.py
tests/test_modeling_utils.py
+4
-1
No files found.
tests/test_modeling_utils.py
View file @
5da71f8f
...
...
@@ -22,6 +22,7 @@ import os
from
distutils.util
import
strtobool
import
torch
import
numpy
as
np
from
diffusers
import
GaussianDDPMScheduler
,
UNetModel
from
diffusers.pipeline_utils
import
DiffusionPipeline
...
...
@@ -35,7 +36,7 @@ torch_device = "cuda" if torch.cuda.is_available() else "cpu"
def
get_random_generator
(
seed
):
seed
=
1234
random
.
seed
(
seed
)
os
.
environ
[
‘
PYTHONHASHSEED
’
]
=
str
(
seed
)
os
.
environ
[
"
PYTHONHASHSEED
"
]
=
str
(
seed
)
np
.
random
.
seed
(
seed
)
torch
.
manual_seed
(
seed
)
torch
.
cuda
.
manual_seed
(
seed
)
...
...
@@ -176,6 +177,7 @@ class SamplerTesterMixin(unittest.TestCase):
assert
image
.
shape
==
(
1
,
3
,
256
,
256
)
image_slice
=
image
[
0
,
-
1
,
-
3
:,
-
3
:].
cpu
()
import
ipdb
;
ipdb
.
set_trace
()
assert
(
image_slice
-
torch
.
tensor
([[
-
0.0598
,
-
0.0611
,
-
0.0506
],
[
-
0.0726
,
0.0220
,
0.0103
],
[
-
0.0723
,
-
0.1310
,
-
0.2458
]])).
abs
().
sum
()
<
1e-3
def
test_sample_fast
(
self
):
...
...
@@ -216,6 +218,7 @@ class SamplerTesterMixin(unittest.TestCase):
assert
image
.
shape
==
(
1
,
3
,
256
,
256
)
image_slice
=
image
[
0
,
-
1
,
-
3
:,
-
3
:].
cpu
()
import
ipdb
;
ipdb
.
set_trace
()
assert
(
image_slice
-
torch
.
tensor
([[
0.1746
,
0.5125
,
-
0.7920
],
[
-
0.5734
,
-
0.2910
,
-
0.1984
],
[
0.4090
,
-
0.7740
,
-
0.3941
]])).
abs
().
sum
()
<
1e-3
...
...
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