Views
No views yet
Fork maintained by @mainbrains — Base model for my VFX Cinematic LoRA. Custom ComfyUI pipeline integration for VFX reference generation.Workflow: Automated batch generation → compositing reference pipeline. See the LoRA repo for cinematic-specific fine-tuning.


generative-models Github repository (https://github.com/Stability-AI/generative-models), which implements the most popular diffusion frameworks (both training and inference) and for which new functionalities like distillation will be added over time.
Clipdrop provides free SDXL inference.
pip install diffusers --upgradetransformers, safetensors, accelerate as well as the invisible watermark:pip install invisible_watermark transformers accelerate safetensors1from diffusers import DiffusionPipeline
2import torch
3
4pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
5pipe.to("cuda")
6
7# if using torch < 2.0
8# pipe.enable_xformers_memory_efficient_attention()
9
10prompt = "An astronaut riding a green horse"
11
12images = pipe(prompt=prompt).images[0]1from diffusers import DiffusionPipeline
2import torch
3
4# load both base & refiner
5base = DiffusionPipeline.from_pretrained(
6 "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
7)
8base.to("cuda")
9refiner = DiffusionPipeline.from_pretrained(
10 "stabilityai/stable-diffusion-xl-refiner-1.0",
11 text_encoder_2=base.text_encoder_2,
12 vae=base.vae,
13 torch_dtype=torch.float16,
14 use_safetensors=True,
15 variant="fp16",
16)
17refiner.to("cuda")
18
19# Define how many steps and what % of steps to be run on each experts (80/20) here
20n_steps = 40
21high_noise_frac = 0.8
22
23prompt = "A majestic lion jumping from a big stone at night"
24
25# run both experts
26image = base(
27 prompt=prompt,
28 num_inference_steps=n_steps,
29 denoising_end=high_noise_frac,
30 output_type="latent",
31).images
32image = refiner(
33 prompt=prompt,
34 num_inference_steps=n_steps,
35 denoising_start=high_noise_frac,
36 image=image,
37).images[0]torch >= 2.0, you can improve the inference speed by 20-30% with torch.compile. Simple wrap the unet with torch compile before running the pipeline:pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)pipe.enable_model_cpu_offload
instead of .to("cuda"):1- pipe.to("cuda")
2+ pipe.enable_model_cpu_offload()diffusers, please have a look at the Stable Diffusion XL Docs.pip install optimum[openvino]StableDiffusionXLPipeline with Optimum OVStableDiffusionXLPipeline. In case you want to load a PyTorch model and convert it to the OpenVINO format on-the-fly, you can set export=True.1- from diffusers import StableDiffusionXLPipeline
2+ from optimum.intel import OVStableDiffusionXLPipeline
3
4model_id = "stabilityai/stable-diffusion-xl-base-1.0"
5- pipeline = StableDiffusionXLPipeline.from_pretrained(model_id)
6+ pipeline = OVStableDiffusionXLPipeline.from_pretrained(model_id)
7prompt = "A majestic lion jumping from a big stone at night"
8image = pipeline(prompt).images[0]pip install optimum[onnxruntime]StableDiffusionXLPipeline with Optimum ORTStableDiffusionXLPipeline. In case you want to load a PyTorch model and convert it to the ONNX format on-the-fly, you can set export=True.1- from diffusers import StableDiffusionXLPipeline
2+ from optimum.onnxruntime import ORTStableDiffusionXLPipeline
3
4model_id = "stabilityai/stable-diffusion-xl-base-1.0"
5- pipeline = StableDiffusionXLPipeline.from_pretrained(model_id)
6+ pipeline = ORTStableDiffusionXLPipeline.from_pretrained(model_id)
7prompt = "A majestic lion jumping from a big stone at night"
8image = pipeline(prompt).images[0]