Skip to content

Commit 08ac5cb

Browse files
authored
[Fix] Test of sd3 lora (#9843)
* fix test * fix test asser * fix format * Update test_lora_layers_sd3.py
1 parent 3f329a4 commit 08ac5cb

File tree

1 file changed

+3
-37
lines changed

1 file changed

+3
-37
lines changed

tests/lora/test_lora_layers_sd3.py

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -166,48 +166,14 @@ def get_inputs(self, device, seed=0):
166166

167167
def test_sd3_img2img_lora(self):
168168
pipe = self.pipeline_class.from_pretrained(self.repo_id, torch_dtype=torch.float16)
169-
pipe.load_lora_weights("nerijs/pixel-art-xl", weight_name="pixel-art-xl.safetensors")
169+
pipe.load_lora_weights("zwloong/sd3-lora-training-rank16-v2", weight_name="pytorch_lora_weights.safetensors")
170170
pipe.enable_sequential_cpu_offload()
171171

172172
inputs = self.get_inputs(torch_device)
173173

174174
image = pipe(**inputs).images[0]
175-
image_slice = image[0, :10, :10]
176-
expected_slice = np.array(
177-
[
178-
0.47827148,
179-
0.5,
180-
0.71972656,
181-
0.3955078,
182-
0.4194336,
183-
0.69628906,
184-
0.37036133,
185-
0.40820312,
186-
0.6923828,
187-
0.36450195,
188-
0.40429688,
189-
0.6904297,
190-
0.35595703,
191-
0.39257812,
192-
0.68652344,
193-
0.35498047,
194-
0.3984375,
195-
0.68310547,
196-
0.34716797,
197-
0.3996582,
198-
0.6855469,
199-
0.3388672,
200-
0.3959961,
201-
0.6816406,
202-
0.34033203,
203-
0.40429688,
204-
0.6845703,
205-
0.34228516,
206-
0.4086914,
207-
0.6870117,
208-
]
209-
)
210-
175+
image_slice = image[0, -3:, -3:]
176+
expected_slice = np.array([0.5396, 0.5776, 0.7432, 0.5151, 0.5586, 0.7383, 0.5537, 0.5933, 0.7153])
211177
max_diff = numpy_cosine_similarity_distance(expected_slice.flatten(), image_slice.flatten())
212178

213179
assert max_diff < 1e-4, f"Outputs are not close enough, got {max_diff}"

0 commit comments

Comments
 (0)