Created
February 8, 2024 15:04
-
-
Save orfeomorello/00598a9ba242bb1c139ceb0c3ba1f4bc to your computer and use it in GitHub Desktop.
Stable Diffusion Turbo example for Intel Arc A770 running with IPEX (intel extension for pytorch)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from diffusers import AutoPipelineForText2Image, DPMSolverMultistepScheduler, AutoencoderKL | |
import torch | |
import intel_extension_for_pytorch as ipex | |
# Initialize LoRA model and weights | |
#lora_model_id = "Linaqruf/style-enhancer-xl-lora" | |
#lora_filename = "style-enhancer-xl.safetensors" | |
#FOR REAL PHOTO AND ART | |
lora_model_id = "PvDeep/Add-Detail-XL" | |
lora_filename = "add-detail-xl.safetensors" | |
#FOR ART ONLY | |
#lora_model_id = "Outrun32/lora_xl_more_art" | |
#lora_filename = "xl_more_art-full_v1.safetensors" | |
# Load VAE component | |
vae = AutoencoderKL.from_pretrained( | |
"madebyollin/sdxl-vae-fp16-fix", | |
torch_dtype=torch.float16 | |
) | |
pipe = AutoPipelineForText2Image.from_pretrained('lykon/dreamshaper-xl-turbo', vae=vae,torch_dtype=torch.float16, variant="fp16") | |
pipe.scheduler = DPMSolverMultistepScheduler.from_config( | |
pipe.scheduler.config, | |
algorithm_type="sde-dpmsolver++", | |
use_karras_sigmas=True | |
) | |
pipe = pipe.to("xpu") | |
# Load and fuse LoRA weights | |
pipe.load_lora_weights(lora_model_id, weight_name=lora_filename) | |
pipe.fuse_lora(lora_scale=0.6) | |
#prompt = "anime woman, night, blue light behind her, ((Galaxy, Lens flare)), short hair, flower field, night sky, cinematic shot. Wallpaper. (Blue color schema), detailed background, a city in the distance" | |
#prompt = "cinematic film still, close up, photo of a cute Pokémon, in the style of hyper-realistic fantasy,, sony fe 12-24mm f/2.8 gm, close up, 32k uhd, light navy and light amber, kushan empirem alluring, perfect skin, seductive, amazing quality, wallpaper, analog film grain" | |
prompt = "Kawaii Chameleon Painter changing its body colors to match its vibrant painting. Render this in an anime style,focusing on the chameleon's cute,wide eyes and intricate patterns on its body" | |
negative_prompt = "(low quality, worst quality:1.4), cgi, text, signature, watermark, extra limbs, ((nipples))" | |
generator = torch.manual_seed(0) | |
image = pipe(prompt=prompt,negative_prompt=negative_prompt, num_inference_steps=8, clip_skip=2, guidance_scale=2, width=1024, height=960, generator=generator).images[0] | |
# Unfuse LoRA before saving the image | |
pipe.unfuse_lora() | |
image.save("./image.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment