Skip to content

Commit 28ba65d

Browse files
committed
pass diff check
1 parent 641c6c9 commit 28ba65d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/test_pipelines_oneflow_graph_load.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from diffusers import utils
1717

1818
_model_id = "stabilityai/stable-diffusion-2"
19-
_generator = torch.Generator("cuda").manual_seed(1024)
2019
_with_image_save = True
2120

2221
def _reset_session():
@@ -88,14 +87,15 @@ def text_to_image(prompt, image_size, num_images_per_prompt=1, prefix="", with_g
8887
else:
8988
raise ValueError(f"invalie image_size {image_size}")
9089

90+
cur_generator = torch.Generator("cuda").manual_seed(1024)
9191
images = pipe(
9292
prompt,
9393
height=image_height,
9494
width=image_weight,
9595
compile_unet=with_graph,
9696
compile_vae=False,
9797
num_images_per_prompt=num_images_per_prompt,
98-
generator=_generator,
98+
generator=cur_generator,
9999
output_type="np",
100100
).images
101101

@@ -116,8 +116,8 @@ def text_to_image(prompt, image_size, num_images_per_prompt=1, prefix="", with_g
116116
with_g_images = text_to_image(prompt, (i, j), prefix=f"is_save_{str(is_save)}-", with_graph=True)
117117
assert len(no_g_images) == len(with_g_images)
118118
for img_idx in range(len(no_g_images)):
119-
#assert np.abs(no_g_images[img_idx].flatten() - with_g_images[img_idx].flatten()).max() < 1e-2
120-
print("====> diff ", np.abs(no_g_images[img_idx].flatten() - with_g_images[img_idx].flatten()).max())
119+
print("====> diff ", np.abs(no_g_images[img_idx] - with_g_images[img_idx]).mean())
120+
assert np.abs(no_g_images[img_idx] - with_g_images[img_idx]).mean() < 1e-2
121121
total_end_t = time.time()
122122
print("st init and run time ", total_end_t - total_start_t, 's.')
123123

0 commit comments

Comments
 (0)