Views
No views yet

1pip install diffusers --upgrade
2pip install transformers accelerate safetensors1import torch
2import datetime
3from PIL import Image
4import matplotlib.pyplot as plt
5from diffusers import (
6 StableDiffusionXLPipeline,
7 EulerAncestralDiscreteScheduler,
8 AutoencoderKL
9)
10
11# LoRA Hugging Face ID
12lora_id = "TfiyuenLau/GirlsFrontline2_SDXL_LoRA"
13
14# Load VAE component
15vae = AutoencoderKL.from_pretrained(
16 "madebyollin/sdxl-vae-fp16-fix",
17 torch_dtype=torch.float16
18)
19
20# Configure the pipeline
21pipe = StableDiffusionXLPipeline.from_pretrained(
22 "cagliostrolab/animagine-xl-3.0",
23 vae=vae,
24 torch_dtype=torch.float16,
25 use_safetensors=True,
26)
27pipe.load_lora_weights(lora_id)
28pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
29pipe.to('cuda')1# Define Prompt
2output = "./output.png"
3prompt = "1girl, OTs14, gloves, looking at viewer, smile, food, holding, solo, closed mouth, sitting, yellow eyes, black gloves, masterpiece, best quality"
4negative_prompt = "nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name"
5
6# Generate Image
7image = pipe(
8 prompt,
9 negative_prompt=negative_prompt,
10 width=1024,
11 height=1024,
12 guidance_scale=7,
13 num_inference_steps=28
14).images[0]
15
16# Save & Show
17image.save(output)
18image = Image.open(output)
19plt.axis('off')
20plt.imshow(image)
21image.close()