Views
No views yet

1from diffusers import DiffusionPipeline
2import torch
3# Load the base model
4infarct_pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1-base", torch_dtype=torch.float16, use_safetensors=True)
5# Load LoRA weights
6infarct_pipe.load_lora_weights("Gavit0/InfarctImage")
7# Move to GPU if available
8infarct_pipe.to(torch.device("cuda" if torch.cuda.is_available() else "cpu"))
9print("Model loaded successfully!")1prompt = ("Elderly man at a sports stadium surrounded by a crowd, "
2 "clutching his chest with a distressed look, indicating a heart attack."
3 )
4negative_prompt = (
5 "blurry, deformed face, bad anatomy, poorly drawn face, out of focus, ugly, noisy, extra fingers, "
6 "distorted, grainy, worst quality, low quality, low resolution, illustration, "
7 "dull, watermark, close-up, 3d, 2d, painting, sketch, render, cartoon, grain, kitsch"
8 )
9trigger = "Person with expression of pain due to a heart attack, "
10full_prompt = f"{trigger}, {prompt}"
11
12image = infarct_pipe(prompt=full_prompt, negative_prompt=negative_prompt,
13 guidance_scale=4, num_inference_steps=40).images[0]
14image.show()| Model | LPIPS (↓ Better) |
|---|---|
| SD 2.1 Base | 0.7366 |
| SD 2.1 + LoRA | 0.6919 |
Person with expression of pain due to a heart attack to trigger the image generation.infarct to trigger the image generation.