MCPcopy Create free account
hub / github.com/huggingface/diffusers / test_lycoris

Method test_lycoris

tests/lora/test_lora_layers_sd.py:404–425  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

402 release_memory(pipe)
403
404 def test_lycoris(self):
405 generator = torch.Generator().manual_seed(0)
406
407 pipe = StableDiffusionPipeline.from_pretrained(
408 "hf-internal-testing/Amixx", safety_checker=None, use_safetensors=True, variant="fp16"
409 ).to(torch_device)
410 lora_model_id = "hf-internal-testing/edgLycorisMugler-light"
411 lora_filename = "edgLycorisMugler-light.safetensors"
412 pipe.load_lora_weights(lora_model_id, weight_name=lora_filename)
413
414 images = pipe(
415 "masterpiece, best quality, mountain", output_type="np", generator=generator, num_inference_steps=2
416 ).images
417
418 images = images[0, -3:, -3:, -1].flatten()
419 expected = np.array([0.6463, 0.658, 0.599, 0.6542, 0.6512, 0.6213, 0.658, 0.6485, 0.6017])
420
421 max_diff = numpy_cosine_similarity_distance(expected, images)
422 assert max_diff < 1e-3
423
424 pipe.unload_lora_weights()
425 release_memory(pipe)
426
427 def test_a1111_with_model_cpu_offload(self):
428 generator = torch.Generator().manual_seed(0)

Callers

nothing calls this directly

Calls 6

pipeFunction · 0.85
toMethod · 0.45
from_pretrainedMethod · 0.45
load_lora_weightsMethod · 0.45
unload_lora_weightsMethod · 0.45

Tested by

no test coverage detected