Views
No views yet

ComfyUI/custom_nodes folder!!! You're encouraged to adjust the eta parameter to get better results 🌟!ComfyUI/custom_nodes folder!!!Hyper-FLUX.1-dev-Nsteps-lora.safetensors: Lora checkpoint, for FLUX.1-dev-related models.Hyper-SD3-Nsteps-CFG-lora.safetensors: Lora checkpoint, for SD3-related models.Hyper-SDXL-Nstep-lora.safetensors: Lora checkpoint, for SDXL-related models.Hyper-SD15-Nstep-lora.safetensors: Lora checkpoint, for SD1.5-related models.Hyper-SDXL-1step-unet.safetensors: Unet checkpoint distilled from SDXL-Base.1import torch
2from diffusers import FluxPipeline
3from huggingface_hub import hf_hub_download
4base_model_id = "black-forest-labs/FLUX.1-dev"
5repo_name = "ByteDance/Hyper-SD"
6# Take 8-steps lora as an example
7ckpt_name = "Hyper-FLUX.1-dev-8steps-lora.safetensors"
8# Load model, please fill in your access tokens since FLUX.1-dev repo is a gated model.
9pipe = FluxPipeline.from_pretrained(base_model_id, token="xxx")
10pipe.load_lora_weights(hf_hub_download(repo_name, ckpt_name))
11pipe.fuse_lora(lora_scale=0.125)
12pipe.to("cuda", dtype=torch.float16)
13image=pipe(prompt="a photo of a cat", num_inference_steps=8, guidance_scale=3.5).images[0]
14image.save("output.png")1import torch
2from diffusers import StableDiffusion3Pipeline
3from huggingface_hub import hf_hub_download
4base_model_id = "stabilityai/stable-diffusion-3-medium-diffusers"
5repo_name = "ByteDance/Hyper-SD"
6# Take 8-steps lora as an example
7ckpt_name = "Hyper-SD3-8steps-CFG-lora.safetensors"
8# Load model, please fill in your access tokens since SD3 repo is a gated model.
9pipe = StableDiffusion3Pipeline.from_pretrained(base_model_id, token="xxx")
10pipe.load_lora_weights(hf_hub_download(repo_name, ckpt_name))
11pipe.fuse_lora(lora_scale=0.125)
12pipe.to("cuda", dtype=torch.float16)
13image=pipe(prompt="a photo of a cat", num_inference_steps=8, guidance_scale=5.0).images[0]
14image.save("output.png")1import torch
2from diffusers import DiffusionPipeline, DDIMScheduler
3from huggingface_hub import hf_hub_download
4base_model_id = "stabilityai/stable-diffusion-xl-base-1.0"
5repo_name = "ByteDance/Hyper-SD"
6# Take 2-steps lora as an example
7ckpt_name = "Hyper-SDXL-2steps-lora.safetensors"
8# Load model.
9pipe = DiffusionPipeline.from_pretrained(base_model_id, torch_dtype=torch.float16, variant="fp16").to("cuda")
10pipe.load_lora_weights(hf_hub_download(repo_name, ckpt_name))
11pipe.fuse_lora()
12# Ensure ddim scheduler timestep spacing set as trailing !!!
13pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
14# lower eta results in more detail
15prompt="a photo of a cat"
16image=pipe(prompt=prompt, num_inference_steps=2, guidance_scale=0).images[0]1import torch
2from diffusers import DiffusionPipeline, TCDScheduler
3from huggingface_hub import hf_hub_download
4base_model_id = "stabilityai/stable-diffusion-xl-base-1.0"
5repo_name = "ByteDance/Hyper-SD"
6ckpt_name = "Hyper-SDXL-1step-lora.safetensors"
7# Load model.
8pipe = DiffusionPipeline.from_pretrained(base_model_id, torch_dtype=torch.float16, variant="fp16").to("cuda")
9pipe.load_lora_weights(hf_hub_download(repo_name, ckpt_name))
10pipe.fuse_lora()
11# Use TCD scheduler to achieve better image quality
12pipe.scheduler = TCDScheduler.from_config(pipe.scheduler.config)
13# Lower eta results in more detail for multi-steps inference
14eta=1.0
15prompt="a photo of a cat"
16image=pipe(prompt=prompt, num_inference_steps=1, guidance_scale=0, eta=eta).images[0]1import torch
2from diffusers import DiffusionPipeline, UNet2DConditionModel, LCMScheduler
3from huggingface_hub import hf_hub_download
4from safetensors.torch import load_file
5base_model_id = "stabilityai/stable-diffusion-xl-base-1.0"
6repo_name = "ByteDance/Hyper-SD"
7ckpt_name = "Hyper-SDXL-1step-Unet.safetensors"
8# Load model.
9unet = UNet2DConditionModel.from_config(base_model_id, subfolder="unet").to("cuda", torch.float16)
10unet.load_state_dict(load_file(hf_hub_download(repo_name, ckpt_name), device="cuda"))
11pipe = DiffusionPipeline.from_pretrained(base_model_id, unet=unet, torch_dtype=torch.float16, variant="fp16").to("cuda")
12# Use LCM scheduler instead of ddim scheduler to support specific timestep number inputs
13pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
14# Set start timesteps to 800 in the one-step inference to get better results
15prompt="a photo of a cat"
16image=pipe(prompt=prompt, num_inference_steps=1, guidance_scale=0, timesteps=[800]).images[0]1import torch
2from diffusers import DiffusionPipeline, DDIMScheduler
3from huggingface_hub import hf_hub_download
4base_model_id = "runwayml/stable-diffusion-v1-5"
5repo_name = "ByteDance/Hyper-SD"
6# Take 2-steps lora as an example
7ckpt_name = "Hyper-SD15-2steps-lora.safetensors"
8# Load model.
9pipe = DiffusionPipeline.from_pretrained(base_model_id, torch_dtype=torch.float16, variant="fp16").to("cuda")
10pipe.load_lora_weights(hf_hub_download(repo_name, ckpt_name))
11pipe.fuse_lora()
12# Ensure ddim scheduler timestep spacing set as trailing !!!
13pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
14prompt="a photo of a cat"
15image=pipe(prompt=prompt, num_inference_steps=2, guidance_scale=0).images[0]1import torch
2from diffusers import DiffusionPipeline, TCDScheduler
3from huggingface_hub import hf_hub_download
4base_model_id = "runwayml/stable-diffusion-v1-5"
5repo_name = "ByteDance/Hyper-SD"
6ckpt_name = "Hyper-SD15-1step-lora.safetensors"
7# Load model.
8pipe = DiffusionPipeline.from_pretrained(base_model_id, torch_dtype=torch.float16, variant="fp16").to("cuda")
9pipe.load_lora_weights(hf_hub_download(repo_name, ckpt_name))
10pipe.fuse_lora()
11# Use TCD scheduler to achieve better image quality
12pipe.scheduler = TCDScheduler.from_config(pipe.scheduler.config)
13# Lower eta results in more detail for multi-steps inference
14eta=1.0
15prompt="a photo of a cat"
16image=pipe(prompt=prompt, num_inference_steps=1, guidance_scale=0, eta=eta).images[0]1import torch
2from diffusers.utils import load_image
3import numpy as np
4import cv2
5from PIL import Image
6from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, AutoencoderKL, DDIMScheduler
7from huggingface_hub import hf_hub_download
8
9# Load original image
10image = load_image("https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/hf-logo.png")
11image = np.array(image)
12# Prepare Canny Control Image
13low_threshold = 100
14high_threshold = 200
15image = cv2.Canny(image, low_threshold, high_threshold)
16image = image[:, :, None]
17image = np.concatenate([image, image, image], axis=2)
18control_image = Image.fromarray(image)
19control_image.save("control.png")
20control_weight = 0.5 # recommended for good generalization
21
22# Initialize pipeline
23controlnet = ControlNetModel.from_pretrained(
24 "diffusers/controlnet-canny-sdxl-1.0",
25 torch_dtype=torch.float16
26)
27vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
28pipe = StableDiffusionXLControlNetPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", controlnet=controlnet, vae=vae, torch_dtype=torch.float16).to("cuda")
29
30pipe.load_lora_weights(hf_hub_download("ByteDance/Hyper-SD", "Hyper-SDXL-2steps-lora.safetensors"))
31# Ensure ddim scheduler timestep spacing set as trailing !!!
32pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
33pipe.fuse_lora()
34image = pipe("A chocolate cookie", num_inference_steps=2, image=control_image, guidance_scale=0, controlnet_conditioning_scale=control_weight).images[0]
35image.save('image_out.png')1import torch
2from diffusers.utils import load_image
3import numpy as np
4import cv2
5from PIL import Image
6from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, AutoencoderKL, TCDScheduler
7from huggingface_hub import hf_hub_download
8
9# Load original image
10image = load_image("https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/hf-logo.png")
11image = np.array(image)
12# Prepare Canny Control Image
13low_threshold = 100
14high_threshold = 200
15image = cv2.Canny(image, low_threshold, high_threshold)
16image = image[:, :, None]
17image = np.concatenate([image, image, image], axis=2)
18control_image = Image.fromarray(image)
19control_image.save("control.png")
20control_weight = 0.5 # recommended for good generalization
21
22# Initialize pipeline
23controlnet = ControlNetModel.from_pretrained(
24 "diffusers/controlnet-canny-sdxl-1.0",
25 torch_dtype=torch.float16
26)
27vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
28pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
29 "stabilityai/stable-diffusion-xl-base-1.0",
30 controlnet=controlnet, vae=vae, torch_dtype=torch.float16).to("cuda")
31
32# Load Hyper-SD15-1step lora
33pipe.load_lora_weights(hf_hub_download("ByteDance/Hyper-SD", "Hyper-SDXL-1step-lora.safetensors"))
34pipe.fuse_lora()
35# Use TCD scheduler to achieve better image quality
36pipe.scheduler = TCDScheduler.from_config(pipe.scheduler.config)
37# Lower eta results in more detail for multi-steps inference
38eta=1.0
39image = pipe("A chocolate cookie", num_inference_steps=4, image=control_image, guidance_scale=0, controlnet_conditioning_scale=control_weight, eta=eta).images[0]
40image.save('image_out.png')1import torch
2from diffusers.utils import load_image
3import numpy as np
4import cv2
5from PIL import Image
6from diffusers import ControlNetModel, StableDiffusionControlNetPipeline, DDIMScheduler
7
8from huggingface_hub import hf_hub_download
9
10controlnet_checkpoint = "lllyasviel/control_v11p_sd15_canny"
11
12# Load original image
13image = load_image("https://huggingface.co/lllyasviel/control_v11p_sd15_canny/resolve/main/images/input.png")
14image = np.array(image)
15# Prepare Canny Control Image
16low_threshold = 100
17high_threshold = 200
18image = cv2.Canny(image, low_threshold, high_threshold)
19image = image[:, :, None]
20image = np.concatenate([image, image, image], axis=2)
21control_image = Image.fromarray(image)
22control_image.save("control.png")
23
24# Initialize pipeline
25controlnet = ControlNetModel.from_pretrained(controlnet_checkpoint, torch_dtype=torch.float16)
26pipe = StableDiffusionControlNetPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16).to("cuda")
27pipe.load_lora_weights(hf_hub_download("ByteDance/Hyper-SD", "Hyper-SD15-2steps-lora.safetensors"))
28pipe.fuse_lora()
29# Ensure ddim scheduler timestep spacing set as trailing !!!
30pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
31image = pipe("a blue paradise bird in the jungle", num_inference_steps=2, image=control_image, guidance_scale=0).images[0]
32image.save('image_out.png')1import torch
2from diffusers.utils import load_image
3import numpy as np
4import cv2
5from PIL import Image
6from diffusers import ControlNetModel, StableDiffusionControlNetPipeline, TCDScheduler
7from huggingface_hub import hf_hub_download
8
9controlnet_checkpoint = "lllyasviel/control_v11p_sd15_canny"
10
11# Load original image
12image = load_image("https://huggingface.co/lllyasviel/control_v11p_sd15_canny/resolve/main/images/input.png")
13image = np.array(image)
14# Prepare Canny Control Image
15low_threshold = 100
16high_threshold = 200
17image = cv2.Canny(image, low_threshold, high_threshold)
18image = image[:, :, None]
19image = np.concatenate([image, image, image], axis=2)
20control_image = Image.fromarray(image)
21control_image.save("control.png")
22
23# Initialize pipeline
24controlnet = ControlNetModel.from_pretrained(controlnet_checkpoint, torch_dtype=torch.float16)
25pipe = StableDiffusionControlNetPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16).to("cuda")
26# Load Hyper-SD15-1step lora
27pipe.load_lora_weights(hf_hub_download("ByteDance/Hyper-SD", "Hyper-SD15-1step-lora.safetensors"))
28pipe.fuse_lora()
29# Use TCD scheduler to achieve better image quality
30pipe.scheduler = TCDScheduler.from_config(pipe.scheduler.config)
31# Lower eta results in more detail for multi-steps inference
32eta=1.0
33image = pipe("a blue paradise bird in the jungle", num_inference_steps=1, image=control_image, guidance_scale=0, eta=eta).images[0]
34image.save('image_out.png')Hyper-SDXL-Nsteps-lora.safetensors: text-to-image workflowHyper-SD15-Nsteps-lora.safetensors: text-to-image workflowHyper-SDXL-1step-Unet-Comfyui.fp16.safetensors: text-to-image workflow
ComfyUI/custom_nodes to enable sampling from 800 timestep instead of 999.ComfyUI/custom_nodes/ComfyUI-HyperSDXL1StepUnetScheduler folder exist.Hyper-SD15-1step-lora.safetensors: text-to-image workflowHyper-SDXL-1step-lora.safetensors: text-to-image workflow
ComfyUI/custom_nodes to enable TCDScheduler with support of different inference steps (1~8) using single checkpoint.ComfyUI/custom_nodes/ComfyUI-TCD folder exist.1@misc{ren2024hypersd,
2 title={Hyper-SD: Trajectory Segmented Consistency Model for Efficient Image Synthesis},
3 author={Yuxi Ren and Xin Xia and Yanzuo Lu and Jiacheng Zhang and Jie Wu and Pan Xie and Xing Wang and Xuefeng Xiao},
4 year={2024},
5 eprint={2404.13686},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV}
8}