File tree 2 files changed +78
-36
lines changed
2 files changed +78
-36
lines changed Original file line number Diff line number Diff line change 8
8
from diffusers import FluxPipeline , FluxPriorReduxPipeline
9
9
from diffusers .utils import load_image
10
10
from diffusers .utils .testing_utils import (
11
+ Expectations ,
11
12
backend_empty_cache ,
12
13
numpy_cosine_similarity_distance ,
13
14
require_big_accelerator ,
21
22
@pytest .mark .big_gpu_with_torch_cuda
22
23
class FluxReduxSlowTests (unittest .TestCase ):
23
24
pipeline_class = FluxPriorReduxPipeline
24
- repo_id = "YiYiXu/yiyi-redux" # update to " black-forest-labs/FLUX.1-Redux-dev" once PR is merged
25
+ repo_id = "black-forest-labs/FLUX.1-Redux-dev"
25
26
base_pipeline_class = FluxPipeline
26
27
base_repo_id = "black-forest-labs/FLUX.1-schnell"
27
28
@@ -69,41 +70,82 @@ def test_flux_redux_inference(self):
69
70
image = pipe_base (** base_pipeline_inputs , ** redux_pipeline_output ).images [0 ]
70
71
71
72
image_slice = image [0 , :10 , :10 ]
72
- expected_slice = np .array (
73
- [
74
- 0.30078125 ,
75
- 0.37890625 ,
76
- 0.46875 ,
77
- 0.28125 ,
78
- 0.36914062 ,
79
- 0.47851562 ,
80
- 0.28515625 ,
81
- 0.375 ,
82
- 0.4765625 ,
83
- 0.28125 ,
84
- 0.375 ,
85
- 0.48046875 ,
86
- 0.27929688 ,
87
- 0.37695312 ,
88
- 0.47851562 ,
89
- 0.27734375 ,
90
- 0.38085938 ,
91
- 0.4765625 ,
92
- 0.2734375 ,
93
- 0.38085938 ,
94
- 0.47265625 ,
95
- 0.27539062 ,
96
- 0.37890625 ,
97
- 0.47265625 ,
98
- 0.27734375 ,
99
- 0.37695312 ,
100
- 0.47070312 ,
101
- 0.27929688 ,
102
- 0.37890625 ,
103
- 0.47460938 ,
104
- ],
105
- dtype = np .float32 ,
73
+ expected_slices = Expectations (
74
+ {
75
+ ("cuda" , 7 ): np .array (
76
+ [
77
+ 0.30078125 ,
78
+ 0.37890625 ,
79
+ 0.46875 ,
80
+ 0.28125 ,
81
+ 0.36914062 ,
82
+ 0.47851562 ,
83
+ 0.28515625 ,
84
+ 0.375 ,
85
+ 0.4765625 ,
86
+ 0.28125 ,
87
+ 0.375 ,
88
+ 0.48046875 ,
89
+ 0.27929688 ,
90
+ 0.37695312 ,
91
+ 0.47851562 ,
92
+ 0.27734375 ,
93
+ 0.38085938 ,
94
+ 0.4765625 ,
95
+ 0.2734375 ,
96
+ 0.38085938 ,
97
+ 0.47265625 ,
98
+ 0.27539062 ,
99
+ 0.37890625 ,
100
+ 0.47265625 ,
101
+ 0.27734375 ,
102
+ 0.37695312 ,
103
+ 0.47070312 ,
104
+ 0.27929688 ,
105
+ 0.37890625 ,
106
+ 0.47460938 ,
107
+ ],
108
+ dtype = np .float32 ,
109
+ ),
110
+ ("xpu" , 3 ): np .array (
111
+ [
112
+ 0.20507812 ,
113
+ 0.30859375 ,
114
+ 0.3984375 ,
115
+ 0.18554688 ,
116
+ 0.30078125 ,
117
+ 0.41015625 ,
118
+ 0.19921875 ,
119
+ 0.3125 ,
120
+ 0.40625 ,
121
+ 0.19726562 ,
122
+ 0.3125 ,
123
+ 0.41601562 ,
124
+ 0.19335938 ,
125
+ 0.31445312 ,
126
+ 0.4140625 ,
127
+ 0.1953125 ,
128
+ 0.3203125 ,
129
+ 0.41796875 ,
130
+ 0.19726562 ,
131
+ 0.32421875 ,
132
+ 0.41992188 ,
133
+ 0.19726562 ,
134
+ 0.32421875 ,
135
+ 0.41992188 ,
136
+ 0.20117188 ,
137
+ 0.32421875 ,
138
+ 0.41796875 ,
139
+ 0.203125 ,
140
+ 0.32617188 ,
141
+ 0.41796875 ,
142
+ ],
143
+ dtype = np .float32 ,
144
+ ),
145
+ }
106
146
)
147
+ expected_slice = expected_slices .get_expectation ()
148
+
107
149
max_diff = numpy_cosine_similarity_distance (expected_slice .flatten (), image_slice .flatten ())
108
150
109
151
assert max_diff < 1e-4
Original file line number Diff line number Diff line change @@ -1347,7 +1347,7 @@ def test_components_function(self):
1347
1347
1348
1348
@unittest .skipIf (torch_device not in ["cuda" , "xpu" ], reason = "float16 requires CUDA or XPU" )
1349
1349
@require_accelerator
1350
- def test_float16_inference (self , expected_max_diff = 5e -2 ):
1350
+ def test_float16_inference (self , expected_max_diff = 6e -2 ):
1351
1351
components = self .get_dummy_components ()
1352
1352
pipe = self .pipeline_class (** components )
1353
1353
for component in pipe .components .values ():
You can’t perform that action at this time.
0 commit comments