Upload folder using huggingface_hub
Browse files- main/README.md +96 -97
- main/README_community_scripts.md +5 -5
- main/marigold_depth_estimation.py +1 -1
main/README.md
CHANGED
|
@@ -120,7 +120,7 @@ from pipeline_stg_mochi import MochiSTGPipeline
|
|
| 120 |
from diffusers.utils import export_to_video
|
| 121 |
|
| 122 |
# Load the pipeline
|
| 123 |
-
pipe = MochiSTGPipeline.from_pretrained("genmo/mochi-1-preview", variant="bf16",
|
| 124 |
|
| 125 |
# Enable memory savings
|
| 126 |
pipe = pipe.to("cuda")
|
|
@@ -257,7 +257,7 @@ if __name__ == "__main__":
|
|
| 257 |
pipeline = AdaptiveMaskInpaintPipeline.from_pretrained(
|
| 258 |
"Uminosachi/realisticVisionV51_v51VAE-inpainting",
|
| 259 |
scheduler=scheduler,
|
| 260 |
-
|
| 261 |
requires_safety_checker=False
|
| 262 |
).to(device)
|
| 263 |
|
|
@@ -318,7 +318,7 @@ negative_prompt = "pink"
|
|
| 318 |
# Load the diffusion pipeline
|
| 319 |
pipeline = DiffusionPipeline.from_pretrained(
|
| 320 |
model_name,
|
| 321 |
-
|
| 322 |
custom_pipeline="pipeline_flux_with_cfg"
|
| 323 |
)
|
| 324 |
pipeline.enable_model_cpu_offload()
|
|
@@ -363,7 +363,7 @@ from examples.community.pipeline_stable_diffusion_xl_differential_img2img import
|
|
| 363 |
|
| 364 |
|
| 365 |
pipeline = StableDiffusionXLDifferentialImg2ImgPipeline.from_pretrained(
|
| 366 |
-
"SG161222/RealVisXL_V4.0",
|
| 367 |
).to("cuda")
|
| 368 |
pipeline.scheduler = DPMSolverMultistepScheduler.from_config(pipeline.scheduler.config, use_karras_sigmas=True)
|
| 369 |
|
|
@@ -474,16 +474,16 @@ from diffusers.utils import load_image
|
|
| 474 |
pipe = DiffusionPipeline.from_pretrained(
|
| 475 |
"prs-eth/marigold-v1-0",
|
| 476 |
custom_pipeline="marigold_depth_estimation"
|
| 477 |
-
#
|
| 478 |
-
# variant="fp16", # (optional) Use with `
|
| 479 |
)
|
| 480 |
|
| 481 |
# (New) LCM version (faster speed)
|
| 482 |
pipe = DiffusionPipeline.from_pretrained(
|
| 483 |
"prs-eth/marigold-depth-lcm-v1-0",
|
| 484 |
custom_pipeline="marigold_depth_estimation"
|
| 485 |
-
#
|
| 486 |
-
# variant="fp16", # (optional) Use with `
|
| 487 |
)
|
| 488 |
|
| 489 |
pipe.to("cuda")
|
|
@@ -543,7 +543,7 @@ pipe = DiffusionPipeline.from_pretrained(
|
|
| 543 |
"longlian/lmd_plus",
|
| 544 |
custom_pipeline="llm_grounded_diffusion",
|
| 545 |
custom_revision="main",
|
| 546 |
-
variant="fp16",
|
| 547 |
)
|
| 548 |
pipe.enable_model_cpu_offload()
|
| 549 |
|
|
@@ -578,7 +578,7 @@ from diffusers import DiffusionPipeline
|
|
| 578 |
pipe = DiffusionPipeline.from_pretrained(
|
| 579 |
"longlian/lmd_plus",
|
| 580 |
custom_pipeline="llm_grounded_diffusion",
|
| 581 |
-
variant="fp16",
|
| 582 |
)
|
| 583 |
pipe.enable_model_cpu_offload()
|
| 584 |
|
|
@@ -615,7 +615,7 @@ import torch
|
|
| 615 |
|
| 616 |
|
| 617 |
feature_extractor = CLIPImageProcessor.from_pretrained("laion/CLIP-ViT-B-32-laion2B-s34B-b79K")
|
| 618 |
-
clip_model = CLIPModel.from_pretrained("laion/CLIP-ViT-B-32-laion2B-s34B-b79K",
|
| 619 |
|
| 620 |
|
| 621 |
guided_pipeline = DiffusionPipeline.from_pretrained(
|
|
@@ -623,7 +623,7 @@ guided_pipeline = DiffusionPipeline.from_pretrained(
|
|
| 623 |
custom_pipeline="clip_guided_stable_diffusion",
|
| 624 |
clip_model=clip_model,
|
| 625 |
feature_extractor=feature_extractor,
|
| 626 |
-
|
| 627 |
)
|
| 628 |
guided_pipeline.enable_attention_slicing()
|
| 629 |
guided_pipeline = guided_pipeline.to("cuda")
|
|
@@ -678,7 +678,7 @@ import torch
|
|
| 678 |
pipe = DiffusionPipeline.from_pretrained(
|
| 679 |
"CompVis/stable-diffusion-v1-4",
|
| 680 |
variant='fp16',
|
| 681 |
-
|
| 682 |
safety_checker=None, # Very important for videos...lots of false positives while interpolating
|
| 683 |
custom_pipeline="interpolate_stable_diffusion",
|
| 684 |
).to('cuda')
|
|
@@ -718,7 +718,7 @@ def download_image(url):
|
|
| 718 |
response = requests.get(url)
|
| 719 |
return PIL.Image.open(BytesIO(response.content)).convert("RGB")
|
| 720 |
|
| 721 |
-
pipe = DiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", custom_pipeline="stable_diffusion_mega",
|
| 722 |
pipe.to("cuda")
|
| 723 |
pipe.enable_attention_slicing()
|
| 724 |
|
|
@@ -773,7 +773,7 @@ import torch
|
|
| 773 |
pipe = DiffusionPipeline.from_pretrained(
|
| 774 |
'hakurei/waifu-diffusion',
|
| 775 |
custom_pipeline="lpw_stable_diffusion",
|
| 776 |
-
|
| 777 |
)
|
| 778 |
pipe = pipe.to("cuda")
|
| 779 |
|
|
@@ -837,7 +837,7 @@ diffuser_pipeline = DiffusionPipeline.from_pretrained(
|
|
| 837 |
custom_pipeline="speech_to_image_diffusion",
|
| 838 |
speech_model=model,
|
| 839 |
speech_processor=processor,
|
| 840 |
-
|
| 841 |
)
|
| 842 |
|
| 843 |
diffuser_pipeline.enable_attention_slicing()
|
|
@@ -896,7 +896,7 @@ import torch
|
|
| 896 |
pipe = DiffusionPipeline.from_pretrained(
|
| 897 |
"CompVis/stable-diffusion-v1-4",
|
| 898 |
custom_pipeline="wildcard_stable_diffusion",
|
| 899 |
-
|
| 900 |
)
|
| 901 |
prompt = "__animal__ sitting on a __object__ wearing a __clothing__"
|
| 902 |
out = pipe(
|
|
@@ -1135,7 +1135,7 @@ diffuser_pipeline = DiffusionPipeline.from_pretrained(
|
|
| 1135 |
detection_pipeline=language_detection_pipeline,
|
| 1136 |
translation_model=trans_model,
|
| 1137 |
translation_tokenizer=trans_tokenizer,
|
| 1138 |
-
|
| 1139 |
)
|
| 1140 |
|
| 1141 |
diffuser_pipeline.enable_attention_slicing()
|
|
@@ -1298,7 +1298,7 @@ mask_image = load_image(mask_url, mode="RGB")
|
|
| 1298 |
pipe = DiffusionPipeline.from_pretrained(
|
| 1299 |
"stable-diffusion-v1-5/stable-diffusion-inpainting",
|
| 1300 |
custom_pipeline="img2img_inpainting",
|
| 1301 |
-
|
| 1302 |
)
|
| 1303 |
pipe = pipe.to("cuda")
|
| 1304 |
|
|
@@ -1587,7 +1587,7 @@ device = torch.device("cpu" if not torch.cuda.is_available() else "cuda")
|
|
| 1587 |
|
| 1588 |
pipeline = DiffusionPipeline.from_pretrained(
|
| 1589 |
"kakaobrain/karlo-v1-alpha",
|
| 1590 |
-
|
| 1591 |
custom_pipeline="stable_unclip",
|
| 1592 |
decoder_pipe_kwargs=dict(
|
| 1593 |
image_encoder=None,
|
|
@@ -1671,7 +1671,7 @@ device = torch.device("cpu" if not torch.cuda.is_available() else "cuda")
|
|
| 1671 |
|
| 1672 |
pipe = DiffusionPipeline.from_pretrained(
|
| 1673 |
"kakaobrain/karlo-v1-alpha",
|
| 1674 |
-
|
| 1675 |
custom_pipeline="unclip_text_interpolation"
|
| 1676 |
)
|
| 1677 |
pipe.to(device)
|
|
@@ -1712,7 +1712,7 @@ dtype = torch.float16 if torch.cuda.is_available() else torch.bfloat16
|
|
| 1712 |
|
| 1713 |
pipe = DiffusionPipeline.from_pretrained(
|
| 1714 |
"kakaobrain/karlo-v1-alpha-image-variations",
|
| 1715 |
-
|
| 1716 |
custom_pipeline="unclip_image_interpolation"
|
| 1717 |
)
|
| 1718 |
pipe.to(device)
|
|
@@ -1817,7 +1817,7 @@ feature_extractor = CLIPImageProcessor.from_pretrained(
|
|
| 1817 |
"laion/CLIP-ViT-B-32-laion2B-s34B-b79K"
|
| 1818 |
)
|
| 1819 |
clip_model = CLIPModel.from_pretrained(
|
| 1820 |
-
"laion/CLIP-ViT-B-32-laion2B-s34B-b79K",
|
| 1821 |
)
|
| 1822 |
|
| 1823 |
# Load guided pipeline
|
|
@@ -1826,7 +1826,7 @@ guided_pipeline = DiffusionPipeline.from_pretrained(
|
|
| 1826 |
custom_pipeline="clip_guided_stable_diffusion_img2img",
|
| 1827 |
clip_model=clip_model,
|
| 1828 |
feature_extractor=feature_extractor,
|
| 1829 |
-
|
| 1830 |
)
|
| 1831 |
guided_pipeline.enable_attention_slicing()
|
| 1832 |
guided_pipeline = guided_pipeline.to("cuda")
|
|
@@ -1884,7 +1884,7 @@ scheduler = DDIMScheduler.from_pretrained("stabilityai/stable-diffusion-2-1", su
|
|
| 1884 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1",
|
| 1885 |
custom_pipeline="stable_diffusion_tensorrt_txt2img",
|
| 1886 |
variant='fp16',
|
| 1887 |
-
|
| 1888 |
scheduler=scheduler,)
|
| 1889 |
|
| 1890 |
# re-use cached folder to save ONNX models and TensorRT Engines
|
|
@@ -1923,7 +1923,7 @@ def center_crop_and_resize(im):
|
|
| 1923 |
|
| 1924 |
return im.crop((left, upper, right, lower)).resize((512, 512))
|
| 1925 |
|
| 1926 |
-
|
| 1927 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 1928 |
|
| 1929 |
# scheduler and text_encoder param values as in the paper
|
|
@@ -1938,7 +1938,7 @@ scheduler = DDIMScheduler(
|
|
| 1938 |
|
| 1939 |
text_encoder = CLIPTextModel.from_pretrained(
|
| 1940 |
pretrained_model_name_or_path="openai/clip-vit-large-patch14",
|
| 1941 |
-
|
| 1942 |
)
|
| 1943 |
|
| 1944 |
# initialize pipeline
|
|
@@ -1949,7 +1949,7 @@ pipeline = DiffusionPipeline.from_pretrained(
|
|
| 1949 |
scheduler=scheduler,
|
| 1950 |
text_encoder=text_encoder,
|
| 1951 |
leapfrog_steps=True,
|
| 1952 |
-
|
| 1953 |
).to(device)
|
| 1954 |
|
| 1955 |
# download image
|
|
@@ -2009,7 +2009,7 @@ init_image = download_image(img_url).resize((512, 512))
|
|
| 2009 |
mask_image = download_image(mask_url).resize((512, 512))
|
| 2010 |
mask_image = PIL.ImageOps.invert(mask_image)
|
| 2011 |
pipe = StableDiffusionPipeline.from_pretrained(
|
| 2012 |
-
"CompVis/stable-diffusion-v1-4",
|
| 2013 |
)
|
| 2014 |
pipe.scheduler = RePaintScheduler.from_config(pipe.scheduler.config)
|
| 2015 |
pipe = pipe.to("cuda")
|
|
@@ -2038,7 +2038,7 @@ scheduler = DDIMScheduler.from_pretrained("stabilityai/stable-diffusion-2-1",
|
|
| 2038 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1",
|
| 2039 |
custom_pipeline="stable_diffusion_tensorrt_img2img",
|
| 2040 |
variant='fp16',
|
| 2041 |
-
|
| 2042 |
scheduler=scheduler,)
|
| 2043 |
|
| 2044 |
# re-use cached folder to save ONNX models and TensorRT Engines
|
|
@@ -2076,7 +2076,7 @@ def draw_box_with_text(img, boxes, names):
|
|
| 2076 |
|
| 2077 |
pipe = StableDiffusionBoxDiffPipeline.from_pretrained(
|
| 2078 |
"stabilityai/stable-diffusion-2-1-base",
|
| 2079 |
-
|
| 2080 |
)
|
| 2081 |
pipe.to("cuda")
|
| 2082 |
|
|
@@ -2134,7 +2134,7 @@ input_image = load_image("https://hf.co/datasets/huggingface/documentation-image
|
|
| 2134 |
pipe = StableDiffusionReferencePipeline.from_pretrained(
|
| 2135 |
"stable-diffusion-v1-5/stable-diffusion-v1-5",
|
| 2136 |
safety_checker=None,
|
| 2137 |
-
|
| 2138 |
).to('cuda:0')
|
| 2139 |
|
| 2140 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
|
@@ -2187,12 +2187,12 @@ image = image[:, :, None]
|
|
| 2187 |
image = np.concatenate([image, image, image], axis=2)
|
| 2188 |
canny_image = Image.fromarray(image)
|
| 2189 |
|
| 2190 |
-
controlnet = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny",
|
| 2191 |
pipe = StableDiffusionControlNetReferencePipeline.from_pretrained(
|
| 2192 |
"stable-diffusion-v1-5/stable-diffusion-v1-5",
|
| 2193 |
controlnet=controlnet,
|
| 2194 |
safety_checker=None,
|
| 2195 |
-
|
| 2196 |
).to('cuda:0')
|
| 2197 |
|
| 2198 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
|
@@ -2455,7 +2455,7 @@ feature_extractor = CLIPImageProcessor.from_pretrained(
|
|
| 2455 |
"laion/CLIP-ViT-B-32-laion2B-s34B-b79K"
|
| 2456 |
)
|
| 2457 |
clip_model = CLIPModel.from_pretrained(
|
| 2458 |
-
"laion/CLIP-ViT-B-32-laion2B-s34B-b79K",
|
| 2459 |
)
|
| 2460 |
coca_model = open_clip.create_model('coca_ViT-L-14', pretrained='laion2B-s13B-b90k').to('cuda')
|
| 2461 |
coca_model.dtype = torch.float16
|
|
@@ -2476,7 +2476,7 @@ mixing_pipeline = DiffusionPipeline.from_pretrained(
|
|
| 2476 |
coca_model=coca_model,
|
| 2477 |
coca_tokenizer=coca_tokenizer,
|
| 2478 |
coca_transform=coca_transform,
|
| 2479 |
-
|
| 2480 |
)
|
| 2481 |
mixing_pipeline.enable_attention_slicing()
|
| 2482 |
mixing_pipeline = mixing_pipeline.to("cuda")
|
|
@@ -2525,7 +2525,7 @@ import torch
|
|
| 2525 |
|
| 2526 |
pipe = DiffusionPipeline.from_pretrained(
|
| 2527 |
"stabilityai/stable-diffusion-xl-base-1.0"
|
| 2528 |
-
,
|
| 2529 |
, use_safetensors = True
|
| 2530 |
, variant = "fp16"
|
| 2531 |
, custom_pipeline = "lpw_stable_diffusion_xl",
|
|
@@ -2655,7 +2655,7 @@ device="cuda"
|
|
| 2655 |
|
| 2656 |
# Load fixed vae (optional)
|
| 2657 |
vae = AutoencoderKL.from_pretrained(
|
| 2658 |
-
"madebyollin/sdxl-vae-fp16-fix",
|
| 2659 |
).to(device)
|
| 2660 |
|
| 2661 |
# Create scheduler and model (similar to StableDiffusionPipeline)
|
|
@@ -2663,7 +2663,7 @@ model_id="stablediffusionapi/yamermix-v8-vae"
|
|
| 2663 |
scheduler = DPMSolverMultistepScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000)
|
| 2664 |
pipe = DiffusionPipeline.from_pretrained(
|
| 2665 |
model_id,
|
| 2666 |
-
|
| 2667 |
vae=vae,
|
| 2668 |
custom_pipeline="mixture_tiling_sdxl",
|
| 2669 |
scheduler=scheduler,
|
|
@@ -2713,14 +2713,14 @@ device = "cuda"
|
|
| 2713 |
|
| 2714 |
# Initialize the models and pipeline
|
| 2715 |
controlnet = ControlNetUnionModel.from_pretrained(
|
| 2716 |
-
"brad-twinkl/controlnet-union-sdxl-1.0-promax",
|
| 2717 |
).to(device=device)
|
| 2718 |
-
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix",
|
| 2719 |
|
| 2720 |
model_id = "SG161222/RealVisXL_V5.0"
|
| 2721 |
pipe = DiffusionPipeline.from_pretrained(
|
| 2722 |
model_id,
|
| 2723 |
-
|
| 2724 |
vae=vae,
|
| 2725 |
controlnet=controlnet,
|
| 2726 |
custom_pipeline="mod_controlnet_tile_sr_sdxl",
|
|
@@ -2814,7 +2814,7 @@ scheduler = PNDMScheduler.from_pretrained("stabilityai/stable-diffusion-2-inpain
|
|
| 2814 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-inpainting",
|
| 2815 |
custom_pipeline="stable_diffusion_tensorrt_inpaint",
|
| 2816 |
variant='fp16',
|
| 2817 |
-
|
| 2818 |
scheduler=scheduler,
|
| 2819 |
)
|
| 2820 |
|
|
@@ -2904,7 +2904,7 @@ from diffusers.utils import load_image
|
|
| 2904 |
|
| 2905 |
model_id = "kxic/zero123-165000" # zero123-105000, zero123-165000, zero123-xl
|
| 2906 |
|
| 2907 |
-
pipe = Zero1to3StableDiffusionPipeline.from_pretrained(model_id,
|
| 2908 |
|
| 2909 |
pipe.enable_xformers_memory_efficient_attention()
|
| 2910 |
pipe.enable_vae_tiling()
|
|
@@ -2984,13 +2984,13 @@ input_image = load_image("https://huggingface.co/datasets/huggingface/documentat
|
|
| 2984 |
# pipe = DiffusionPipeline.from_pretrained(
|
| 2985 |
# "stabilityai/stable-diffusion-xl-base-1.0",
|
| 2986 |
# custom_pipeline="stable_diffusion_xl_reference",
|
| 2987 |
-
#
|
| 2988 |
# use_safetensors=True,
|
| 2989 |
# variant="fp16").to('cuda:0')
|
| 2990 |
|
| 2991 |
pipe = StableDiffusionXLReferencePipeline.from_pretrained(
|
| 2992 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 2993 |
-
|
| 2994 |
use_safetensors=True,
|
| 2995 |
variant="fp16").to('cuda:0')
|
| 2996 |
|
|
@@ -3062,11 +3062,11 @@ ref_image = load_image(
|
|
| 3062 |
# initialize the models and pipeline
|
| 3063 |
controlnet_conditioning_scale = 0.5 # recommended for good generalization
|
| 3064 |
controlnet = ControlNetModel.from_pretrained(
|
| 3065 |
-
"diffusers/controlnet-canny-sdxl-1.0",
|
| 3066 |
)
|
| 3067 |
-
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix",
|
| 3068 |
pipe = StableDiffusionXLControlNetReferencePipeline.from_pretrained(
|
| 3069 |
-
"stabilityai/stable-diffusion-xl-base-1.0", controlnet=controlnet, vae=vae,
|
| 3070 |
).to("cuda:0")
|
| 3071 |
|
| 3072 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
|
@@ -3134,7 +3134,7 @@ from diffusers import DiffusionPipeline
|
|
| 3134 |
# make sure you're logged in with `hf auth login`
|
| 3135 |
model_id_or_path = "stable-diffusion-v1-5/stable-diffusion-v1-5"
|
| 3136 |
# can also be used with dreamlike-art/dreamlike-photoreal-2.0
|
| 3137 |
-
pipe = DiffusionPipeline.from_pretrained(model_id_or_path,
|
| 3138 |
|
| 3139 |
# let's specify a prompt
|
| 3140 |
prompt = "An astronaut riding an elephant"
|
|
@@ -3376,7 +3376,7 @@ import torch
|
|
| 3376 |
pipe = DiffusionPipeline.from_pretrained("SimianLuo/LCM_Dreamshaper_v7", custom_pipeline="latent_consistency_txt2img", custom_revision="main")
|
| 3377 |
|
| 3378 |
# To save GPU memory, torch.float16 can be used, but it may compromise image quality.
|
| 3379 |
-
pipe.to(torch_device="cuda",
|
| 3380 |
```
|
| 3381 |
|
| 3382 |
- 2. Run inference with as little as 4 steps:
|
|
@@ -3405,7 +3405,7 @@ import torch
|
|
| 3405 |
pipe = DiffusionPipeline.from_pretrained("SimianLuo/LCM_Dreamshaper_v7", custom_pipeline="latent_consistency_img2img")
|
| 3406 |
|
| 3407 |
# To save GPU memory, torch.float16 can be used, but it may compromise image quality.
|
| 3408 |
-
pipe.to(torch_device="cuda",
|
| 3409 |
```
|
| 3410 |
|
| 3411 |
- 2. Run inference with as little as 4 steps:
|
|
@@ -3437,7 +3437,7 @@ from diffusers import DiffusionPipeline
|
|
| 3437 |
pipe = DiffusionPipeline.from_pretrained("SimianLuo/LCM_Dreamshaper_v7", custom_pipeline="latent_consistency_interpolate")
|
| 3438 |
|
| 3439 |
# To save GPU memory, torch.float16 can be used, but it may compromise image quality.
|
| 3440 |
-
pipe.to(torch_device="cuda",
|
| 3441 |
|
| 3442 |
prompts = [
|
| 3443 |
"Self-portrait oil painting, a beautiful cyborg with golden hair, Margot Robbie, 8k",
|
|
@@ -3534,14 +3534,14 @@ from examples.community.pipeline_stable_diffusion_xl_controlnet_adapter import (
|
|
| 3534 |
|
| 3535 |
controlnet_depth = ControlNetModel.from_pretrained(
|
| 3536 |
"diffusers/controlnet-depth-sdxl-1.0",
|
| 3537 |
-
|
| 3538 |
variant="fp16",
|
| 3539 |
use_safetensors=True
|
| 3540 |
)
|
| 3541 |
adapter_depth = T2IAdapter.from_pretrained(
|
| 3542 |
-
"TencentARC/t2i-adapter-depth-midas-sdxl-1.0",
|
| 3543 |
)
|
| 3544 |
-
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix",
|
| 3545 |
|
| 3546 |
pipe = StableDiffusionXLControlNetAdapterPipeline.from_pretrained(
|
| 3547 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
|
@@ -3550,7 +3550,7 @@ pipe = StableDiffusionXLControlNetAdapterPipeline.from_pretrained(
|
|
| 3550 |
vae=vae,
|
| 3551 |
variant="fp16",
|
| 3552 |
use_safetensors=True,
|
| 3553 |
-
|
| 3554 |
)
|
| 3555 |
pipe = pipe.to("cuda")
|
| 3556 |
pipe.enable_xformers_memory_efficient_attention()
|
|
@@ -3599,14 +3599,14 @@ from examples.community.pipeline_stable_diffusion_xl_controlnet_adapter_inpaint
|
|
| 3599 |
|
| 3600 |
controlnet_depth = ControlNetModel.from_pretrained(
|
| 3601 |
"diffusers/controlnet-depth-sdxl-1.0",
|
| 3602 |
-
|
| 3603 |
variant="fp16",
|
| 3604 |
use_safetensors=True
|
| 3605 |
)
|
| 3606 |
adapter_depth = T2IAdapter.from_pretrained(
|
| 3607 |
-
"TencentARC/t2i-adapter-depth-midas-sdxl-1.0",
|
| 3608 |
)
|
| 3609 |
-
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix",
|
| 3610 |
|
| 3611 |
pipe = StableDiffusionXLControlNetAdapterInpaintPipeline.from_pretrained(
|
| 3612 |
"diffusers/stable-diffusion-xl-1.0-inpainting-0.1",
|
|
@@ -3615,7 +3615,7 @@ pipe = StableDiffusionXLControlNetAdapterInpaintPipeline.from_pretrained(
|
|
| 3615 |
vae=vae,
|
| 3616 |
variant="fp16",
|
| 3617 |
use_safetensors=True,
|
| 3618 |
-
|
| 3619 |
)
|
| 3620 |
pipe = pipe.to("cuda")
|
| 3621 |
pipe.enable_xformers_memory_efficient_attention()
|
|
@@ -4042,8 +4042,8 @@ from PIL import Image
|
|
| 4042 |
|
| 4043 |
motion_id = "guoyww/animatediff-motion-adapter-v1-5-2"
|
| 4044 |
adapter = MotionAdapter.from_pretrained(motion_id)
|
| 4045 |
-
controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_openpose",
|
| 4046 |
-
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse",
|
| 4047 |
|
| 4048 |
model_id = "SG161222/Realistic_Vision_V5.1_noVAE"
|
| 4049 |
pipe = DiffusionPipeline.from_pretrained(
|
|
@@ -4052,7 +4052,7 @@ pipe = DiffusionPipeline.from_pretrained(
|
|
| 4052 |
controlnet=controlnet,
|
| 4053 |
vae=vae,
|
| 4054 |
custom_pipeline="pipeline_animatediff_controlnet",
|
| 4055 |
-
|
| 4056 |
).to(device="cuda")
|
| 4057 |
pipe.scheduler = DPMSolverMultistepScheduler.from_pretrained(
|
| 4058 |
model_id, subfolder="scheduler", beta_schedule="linear", clip_sample=False, timestep_spacing="linspace", steps_offset=1
|
|
@@ -4104,9 +4104,9 @@ from PIL import Image
|
|
| 4104 |
|
| 4105 |
motion_id = "guoyww/animatediff-motion-adapter-v1-5-2"
|
| 4106 |
adapter = MotionAdapter.from_pretrained(motion_id)
|
| 4107 |
-
controlnet1 = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_openpose",
|
| 4108 |
-
controlnet2 = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny",
|
| 4109 |
-
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse",
|
| 4110 |
|
| 4111 |
model_id = "SG161222/Realistic_Vision_V5.1_noVAE"
|
| 4112 |
pipe = DiffusionPipeline.from_pretrained(
|
|
@@ -4115,7 +4115,7 @@ pipe = DiffusionPipeline.from_pretrained(
|
|
| 4115 |
controlnet=[controlnet1, controlnet2],
|
| 4116 |
vae=vae,
|
| 4117 |
custom_pipeline="pipeline_animatediff_controlnet",
|
| 4118 |
-
|
| 4119 |
).to(device="cuda")
|
| 4120 |
pipe.scheduler = DPMSolverMultistepScheduler.from_pretrained(
|
| 4121 |
model_id, subfolder="scheduler", clip_sample=False, timestep_spacing="linspace", steps_offset=1, beta_schedule="linear",
|
|
@@ -4203,7 +4203,7 @@ pipe = DiffusionPipeline.from_pretrained(
|
|
| 4203 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 4204 |
custom_pipeline="pipeline_demofusion_sdxl",
|
| 4205 |
custom_revision="main",
|
| 4206 |
-
|
| 4207 |
)
|
| 4208 |
pipe = pipe.to("cuda")
|
| 4209 |
|
|
@@ -4359,7 +4359,7 @@ from diffusers import DiffusionPipeline
|
|
| 4359 |
import torch
|
| 4360 |
|
| 4361 |
|
| 4362 |
-
pipe = DiffusionPipeline.from_pretrained("XCLIU/instaflow_0_9B_from_sd_1_5",
|
| 4363 |
pipe.to("cuda") ### if GPU is not available, comment this line
|
| 4364 |
prompt = "A hyper-realistic photo of a cute cat."
|
| 4365 |
|
|
@@ -4379,7 +4379,7 @@ import torch
|
|
| 4379 |
|
| 4380 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 4381 |
|
| 4382 |
-
pipe = DiffusionPipeline.from_pretrained("XCLIU/instaflow_0_9B_from_sd_1_5",
|
| 4383 |
pipe.to(device) ### if GPU is not available, comment this line
|
| 4384 |
pipe.load_lora_weights("artificialguybr/logo-redmond-1-5v-logo-lora-for-liberteredmond-sd-1-5")
|
| 4385 |
prompt = "logo, A logo for a fitness app, dynamic running figure, energetic colors (red, orange) ),LogoRedAF ,"
|
|
@@ -4424,7 +4424,7 @@ prompt = "A lying dog"
|
|
| 4424 |
# Float32 is essential to a well optimization
|
| 4425 |
model_path = "stable-diffusion-v1-5/stable-diffusion-v1-5"
|
| 4426 |
scheduler = DDIMScheduler(num_train_timesteps=1000, beta_start=0.00085, beta_end=0.0120, beta_schedule="scaled_linear")
|
| 4427 |
-
pipeline = NullTextPipeline.from_pretrained(model_path, scheduler=scheduler,
|
| 4428 |
|
| 4429 |
# Saves the inverted_latent to save time
|
| 4430 |
inverted_latent, uncond = pipeline.invert(input_image, invert_prompt, num_inner_steps=10, early_stop_epsilon=1e-5, num_inference_steps=steps)
|
|
@@ -4530,7 +4530,7 @@ from diffusers import DiffusionPipeline
|
|
| 4530 |
from PIL import Image
|
| 4531 |
|
| 4532 |
model_id = "a-r-r-o-w/dreamshaper-xl-turbo"
|
| 4533 |
-
pipe = DiffusionPipeline.from_pretrained(model_id,
|
| 4534 |
pipe = pipe.to("cuda")
|
| 4535 |
|
| 4536 |
# Enable memory saving techniques
|
|
@@ -4629,7 +4629,7 @@ noise_scheduler = DDIMScheduler(
|
|
| 4629 |
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse").to(dtype=torch.float16)
|
| 4630 |
pipeline = DiffusionPipeline.from_pretrained(
|
| 4631 |
"SG161222/Realistic_Vision_V4.0_noVAE",
|
| 4632 |
-
|
| 4633 |
scheduler=noise_scheduler,
|
| 4634 |
vae=vae,
|
| 4635 |
custom_pipeline="ip_adapter_face_id"
|
|
@@ -4694,13 +4694,13 @@ face_adapter = './checkpoints/ip-adapter.bin'
|
|
| 4694 |
controlnet_path = './checkpoints/ControlNetModel'
|
| 4695 |
|
| 4696 |
# load IdentityNet
|
| 4697 |
-
controlnet = ControlNetModel.from_pretrained(controlnet_path,
|
| 4698 |
|
| 4699 |
base_model = 'wangqixun/YamerMIX_v8'
|
| 4700 |
pipe = StableDiffusionXLInstantIDPipeline.from_pretrained(
|
| 4701 |
base_model,
|
| 4702 |
controlnet=controlnet,
|
| 4703 |
-
|
| 4704 |
)
|
| 4705 |
pipe.to("cuda")
|
| 4706 |
|
|
@@ -4744,7 +4744,7 @@ from scheduling_ufogen import UFOGenScheduler
|
|
| 4744 |
ufogen_model_id_or_path = "/path/to/ufogen/model"
|
| 4745 |
pipe = StableDiffusionPipeline(
|
| 4746 |
ufogen_model_id_or_path,
|
| 4747 |
-
|
| 4748 |
)
|
| 4749 |
|
| 4750 |
# You can initialize a UFOGenScheduler as follows:
|
|
@@ -4871,7 +4871,7 @@ python -m pip install intel_extension_for_pytorch==<version_name> -f https://dev
|
|
| 4871 |
2. After pipeline initialization, `prepare_for_ipex()` should be called to enable IPEX acceleration. Supported inference datatypes are Float32 and BFloat16.
|
| 4872 |
|
| 4873 |
```python
|
| 4874 |
-
pipe = AnimateDiffPipelineIpex.from_pretrained(base, motion_adapter=adapter,
|
| 4875 |
# For Float32
|
| 4876 |
pipe.prepare_for_ipex(torch.float32, prompt="A girl smiling")
|
| 4877 |
# For BFloat16
|
|
@@ -4924,12 +4924,12 @@ def elapsed_time(pipeline, nb_pass=3, num_inference_steps=1):
|
|
| 4924 |
############## bf16 inference performance ###############
|
| 4925 |
|
| 4926 |
# 1. IPEX Pipeline initialization
|
| 4927 |
-
pipe = AnimateDiffPipelineIpex.from_pretrained(base, motion_adapter=adapter,
|
| 4928 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
|
| 4929 |
pipe.prepare_for_ipex(torch.bfloat16, prompt = prompt)
|
| 4930 |
|
| 4931 |
# 2. Original Pipeline initialization
|
| 4932 |
-
pipe2 = AnimateDiffPipeline.from_pretrained(base, motion_adapter=adapter,
|
| 4933 |
pipe2.scheduler = EulerDiscreteScheduler.from_config(pipe2.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
|
| 4934 |
|
| 4935 |
# 3. Compare performance between Original Pipeline and IPEX Pipeline
|
|
@@ -4942,12 +4942,12 @@ with torch.cpu.amp.autocast(enabled=True, dtype=torch.bfloat16):
|
|
| 4942 |
############## fp32 inference performance ###############
|
| 4943 |
|
| 4944 |
# 1. IPEX Pipeline initialization
|
| 4945 |
-
pipe3 = AnimateDiffPipelineIpex.from_pretrained(base, motion_adapter=adapter,
|
| 4946 |
pipe3.scheduler = EulerDiscreteScheduler.from_config(pipe3.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
|
| 4947 |
pipe3.prepare_for_ipex(torch.float32, prompt = prompt)
|
| 4948 |
|
| 4949 |
# 2. Original Pipeline initialization
|
| 4950 |
-
pipe4 = AnimateDiffPipeline.from_pretrained(base, motion_adapter=adapter,
|
| 4951 |
pipe4.scheduler = EulerDiscreteScheduler.from_config(pipe4.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
|
| 4952 |
|
| 4953 |
# 3. Compare performance between Original Pipeline and IPEX Pipeline
|
|
@@ -4973,7 +4973,7 @@ from pipeline_hunyuandit_differential_img2img import (
|
|
| 4973 |
|
| 4974 |
|
| 4975 |
pipe = HunyuanDiTDifferentialImg2ImgPipeline.from_pretrained(
|
| 4976 |
-
"Tencent-Hunyuan/HunyuanDiT-Diffusers",
|
| 4977 |
).to("cuda")
|
| 4978 |
|
| 4979 |
|
|
@@ -5077,7 +5077,7 @@ pipeline = DiffusionPipeline.from_pretrained(
|
|
| 5077 |
scheduler=scheduler,
|
| 5078 |
variant="fp16",
|
| 5079 |
use_safetensors=True,
|
| 5080 |
-
|
| 5081 |
).to(device)
|
| 5082 |
|
| 5083 |
|
|
@@ -5155,7 +5155,7 @@ from diffusers.utils.torch_utils import randn_tensor
|
|
| 5155 |
pipe = StableDiffusionPipeline.from_pretrained(
|
| 5156 |
"stable-diffusion-v1-5/stable-diffusion-v1-5",
|
| 5157 |
custom_pipeline="hyoungwoncho/sd_perturbed_attention_guidance",
|
| 5158 |
-
|
| 5159 |
)
|
| 5160 |
|
| 5161 |
device = "cuda"
|
|
@@ -5250,14 +5250,14 @@ torch.manual_seed(0)
|
|
| 5250 |
# load controlnet
|
| 5251 |
controlnet = PixArtControlNetAdapterModel.from_pretrained(
|
| 5252 |
controlnet_repo_id,
|
| 5253 |
-
|
| 5254 |
use_safetensors=True,
|
| 5255 |
).to(device)
|
| 5256 |
|
| 5257 |
pipe = PixArtAlphaControlnetPipeline.from_pretrained(
|
| 5258 |
"PixArt-alpha/PixArt-XL-2-1024-MS",
|
| 5259 |
controlnet=controlnet,
|
| 5260 |
-
|
| 5261 |
use_safetensors=True,
|
| 5262 |
).to(device)
|
| 5263 |
|
|
@@ -5317,7 +5317,7 @@ from examples.community.cogvideox_ddim_inversion import CogVideoXPipelineForDDIM
|
|
| 5317 |
# Load pretrained pipeline
|
| 5318 |
pipeline = CogVideoXPipelineForDDIMInversion.from_pretrained(
|
| 5319 |
"THUDM/CogVideoX1.5-5B",
|
| 5320 |
-
|
| 5321 |
).to("cuda")
|
| 5322 |
|
| 5323 |
# Run DDIM inversion, and the videos will be generated in the output_path
|
|
@@ -5369,12 +5369,12 @@ model_file = hf_hub_download(
|
|
| 5369 |
)
|
| 5370 |
|
| 5371 |
# Initialize the models and pipeline
|
| 5372 |
-
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix",
|
| 5373 |
|
| 5374 |
model_id = "SG161222/RealVisXL_V4.0"
|
| 5375 |
pipe = DiffusionPipeline.from_pretrained(
|
| 5376 |
model_id,
|
| 5377 |
-
|
| 5378 |
vae=vae,
|
| 5379 |
unet=None, #<- Do not load with original model.
|
| 5380 |
custom_pipeline="pipeline_faithdiff_stable_diffusion_xl",
|
|
@@ -5459,9 +5459,9 @@ edit_instruction = "Turn sky into a sunny one"
|
|
| 5459 |
|
| 5460 |
|
| 5461 |
pipe = DiffusionPipeline.from_pretrained(
|
| 5462 |
-
"stabilityai/stable-diffusion-3-medium-diffusers", custom_pipeline="pipeline_stable_diffusion_3_instruct_pix2pix",
|
| 5463 |
|
| 5464 |
-
pipe.transformer = SD3Transformer2DModel.from_pretrained("CaptainZZZ/sd3-instructpix2pix",
|
| 5465 |
|
| 5466 |
edited_image = pipe(
|
| 5467 |
prompt=edit_instruction,
|
|
@@ -5503,7 +5503,7 @@ from diffusers.utils import load_image
|
|
| 5503 |
|
| 5504 |
pipe = FluxKontextPipeline.from_pretrained(
|
| 5505 |
"black-forest-labs/FLUX.1-Kontext-dev",
|
| 5506 |
-
|
| 5507 |
custom_pipeline="pipeline_flux_kontext_multiple_images",
|
| 5508 |
)
|
| 5509 |
pipe.to("cuda")
|
|
@@ -5559,14 +5559,14 @@ prior_model = "black-forest-labs/FLUX.1-Redux-dev"
|
|
| 5559 |
# Load ControlNet
|
| 5560 |
controlnet = FluxControlNetModel.from_pretrained(
|
| 5561 |
controlnet_model,
|
| 5562 |
-
|
| 5563 |
)
|
| 5564 |
|
| 5565 |
# Load Fill + ControlNet Pipeline
|
| 5566 |
fill_pipe = FluxControlNetFillInpaintPipeline.from_pretrained(
|
| 5567 |
base_model,
|
| 5568 |
controlnet=controlnet,
|
| 5569 |
-
|
| 5570 |
).to(device)
|
| 5571 |
|
| 5572 |
# OPTIONAL FP8
|
|
@@ -5578,7 +5578,7 @@ fill_pipe = FluxControlNetFillInpaintPipeline.from_pretrained(
|
|
| 5578 |
# OPTIONAL Prior Redux
|
| 5579 |
#pipe_prior_redux = FluxPriorReduxPipeline.from_pretrained(
|
| 5580 |
# prior_model,
|
| 5581 |
-
#
|
| 5582 |
#).to(device)
|
| 5583 |
|
| 5584 |
# Inputs
|
|
@@ -5629,4 +5629,3 @@ from datetime import datetime
|
|
| 5629 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 5630 |
result.images[0].save(f"flux_fill_controlnet_inpaint_depth{timestamp}.jpg")
|
| 5631 |
```
|
| 5632 |
-
|
|
|
|
| 120 |
from diffusers.utils import export_to_video
|
| 121 |
|
| 122 |
# Load the pipeline
|
| 123 |
+
pipe = MochiSTGPipeline.from_pretrained("genmo/mochi-1-preview", variant="bf16", dtype=torch.bfloat16)
|
| 124 |
|
| 125 |
# Enable memory savings
|
| 126 |
pipe = pipe.to("cuda")
|
|
|
|
| 257 |
pipeline = AdaptiveMaskInpaintPipeline.from_pretrained(
|
| 258 |
"Uminosachi/realisticVisionV51_v51VAE-inpainting",
|
| 259 |
scheduler=scheduler,
|
| 260 |
+
dtype=torch.float16,
|
| 261 |
requires_safety_checker=False
|
| 262 |
).to(device)
|
| 263 |
|
|
|
|
| 318 |
# Load the diffusion pipeline
|
| 319 |
pipeline = DiffusionPipeline.from_pretrained(
|
| 320 |
model_name,
|
| 321 |
+
dtype=torch.bfloat16,
|
| 322 |
custom_pipeline="pipeline_flux_with_cfg"
|
| 323 |
)
|
| 324 |
pipeline.enable_model_cpu_offload()
|
|
|
|
| 363 |
|
| 364 |
|
| 365 |
pipeline = StableDiffusionXLDifferentialImg2ImgPipeline.from_pretrained(
|
| 366 |
+
"SG161222/RealVisXL_V4.0", dtype=torch.float16, variant="fp16"
|
| 367 |
).to("cuda")
|
| 368 |
pipeline.scheduler = DPMSolverMultistepScheduler.from_config(pipeline.scheduler.config, use_karras_sigmas=True)
|
| 369 |
|
|
|
|
| 474 |
pipe = DiffusionPipeline.from_pretrained(
|
| 475 |
"prs-eth/marigold-v1-0",
|
| 476 |
custom_pipeline="marigold_depth_estimation"
|
| 477 |
+
# dtype=torch.float16, # (optional) Run with half-precision (16-bit float).
|
| 478 |
+
# variant="fp16", # (optional) Use with `dtype=torch.float16`, to directly load fp16 checkpoint
|
| 479 |
)
|
| 480 |
|
| 481 |
# (New) LCM version (faster speed)
|
| 482 |
pipe = DiffusionPipeline.from_pretrained(
|
| 483 |
"prs-eth/marigold-depth-lcm-v1-0",
|
| 484 |
custom_pipeline="marigold_depth_estimation"
|
| 485 |
+
# dtype=torch.float16, # (optional) Run with half-precision (16-bit float).
|
| 486 |
+
# variant="fp16", # (optional) Use with `dtype=torch.float16`, to directly load fp16 checkpoint
|
| 487 |
)
|
| 488 |
|
| 489 |
pipe.to("cuda")
|
|
|
|
| 543 |
"longlian/lmd_plus",
|
| 544 |
custom_pipeline="llm_grounded_diffusion",
|
| 545 |
custom_revision="main",
|
| 546 |
+
variant="fp16", dtype=torch.float16
|
| 547 |
)
|
| 548 |
pipe.enable_model_cpu_offload()
|
| 549 |
|
|
|
|
| 578 |
pipe = DiffusionPipeline.from_pretrained(
|
| 579 |
"longlian/lmd_plus",
|
| 580 |
custom_pipeline="llm_grounded_diffusion",
|
| 581 |
+
variant="fp16", dtype=torch.float16
|
| 582 |
)
|
| 583 |
pipe.enable_model_cpu_offload()
|
| 584 |
|
|
|
|
| 615 |
|
| 616 |
|
| 617 |
feature_extractor = CLIPImageProcessor.from_pretrained("laion/CLIP-ViT-B-32-laion2B-s34B-b79K")
|
| 618 |
+
clip_model = CLIPModel.from_pretrained("laion/CLIP-ViT-B-32-laion2B-s34B-b79K", dtype=torch.float16)
|
| 619 |
|
| 620 |
|
| 621 |
guided_pipeline = DiffusionPipeline.from_pretrained(
|
|
|
|
| 623 |
custom_pipeline="clip_guided_stable_diffusion",
|
| 624 |
clip_model=clip_model,
|
| 625 |
feature_extractor=feature_extractor,
|
| 626 |
+
dtype=torch.float16,
|
| 627 |
)
|
| 628 |
guided_pipeline.enable_attention_slicing()
|
| 629 |
guided_pipeline = guided_pipeline.to("cuda")
|
|
|
|
| 678 |
pipe = DiffusionPipeline.from_pretrained(
|
| 679 |
"CompVis/stable-diffusion-v1-4",
|
| 680 |
variant='fp16',
|
| 681 |
+
dtype=torch.float16,
|
| 682 |
safety_checker=None, # Very important for videos...lots of false positives while interpolating
|
| 683 |
custom_pipeline="interpolate_stable_diffusion",
|
| 684 |
).to('cuda')
|
|
|
|
| 718 |
response = requests.get(url)
|
| 719 |
return PIL.Image.open(BytesIO(response.content)).convert("RGB")
|
| 720 |
|
| 721 |
+
pipe = DiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", custom_pipeline="stable_diffusion_mega", dtype=torch.float16, variant="fp16")
|
| 722 |
pipe.to("cuda")
|
| 723 |
pipe.enable_attention_slicing()
|
| 724 |
|
|
|
|
| 773 |
pipe = DiffusionPipeline.from_pretrained(
|
| 774 |
'hakurei/waifu-diffusion',
|
| 775 |
custom_pipeline="lpw_stable_diffusion",
|
| 776 |
+
dtype=torch.float16
|
| 777 |
)
|
| 778 |
pipe = pipe.to("cuda")
|
| 779 |
|
|
|
|
| 837 |
custom_pipeline="speech_to_image_diffusion",
|
| 838 |
speech_model=model,
|
| 839 |
speech_processor=processor,
|
| 840 |
+
dtype=torch.float16,
|
| 841 |
)
|
| 842 |
|
| 843 |
diffuser_pipeline.enable_attention_slicing()
|
|
|
|
| 896 |
pipe = DiffusionPipeline.from_pretrained(
|
| 897 |
"CompVis/stable-diffusion-v1-4",
|
| 898 |
custom_pipeline="wildcard_stable_diffusion",
|
| 899 |
+
dtype=torch.float16,
|
| 900 |
)
|
| 901 |
prompt = "__animal__ sitting on a __object__ wearing a __clothing__"
|
| 902 |
out = pipe(
|
|
|
|
| 1135 |
detection_pipeline=language_detection_pipeline,
|
| 1136 |
translation_model=trans_model,
|
| 1137 |
translation_tokenizer=trans_tokenizer,
|
| 1138 |
+
dtype=torch.float16,
|
| 1139 |
)
|
| 1140 |
|
| 1141 |
diffuser_pipeline.enable_attention_slicing()
|
|
|
|
| 1298 |
pipe = DiffusionPipeline.from_pretrained(
|
| 1299 |
"stable-diffusion-v1-5/stable-diffusion-inpainting",
|
| 1300 |
custom_pipeline="img2img_inpainting",
|
| 1301 |
+
dtype=torch.float16
|
| 1302 |
)
|
| 1303 |
pipe = pipe.to("cuda")
|
| 1304 |
|
|
|
|
| 1587 |
|
| 1588 |
pipeline = DiffusionPipeline.from_pretrained(
|
| 1589 |
"kakaobrain/karlo-v1-alpha",
|
| 1590 |
+
dtype=torch.float16,
|
| 1591 |
custom_pipeline="stable_unclip",
|
| 1592 |
decoder_pipe_kwargs=dict(
|
| 1593 |
image_encoder=None,
|
|
|
|
| 1671 |
|
| 1672 |
pipe = DiffusionPipeline.from_pretrained(
|
| 1673 |
"kakaobrain/karlo-v1-alpha",
|
| 1674 |
+
dtype=torch.float16,
|
| 1675 |
custom_pipeline="unclip_text_interpolation"
|
| 1676 |
)
|
| 1677 |
pipe.to(device)
|
|
|
|
| 1712 |
|
| 1713 |
pipe = DiffusionPipeline.from_pretrained(
|
| 1714 |
"kakaobrain/karlo-v1-alpha-image-variations",
|
| 1715 |
+
dtype=dtype,
|
| 1716 |
custom_pipeline="unclip_image_interpolation"
|
| 1717 |
)
|
| 1718 |
pipe.to(device)
|
|
|
|
| 1817 |
"laion/CLIP-ViT-B-32-laion2B-s34B-b79K"
|
| 1818 |
)
|
| 1819 |
clip_model = CLIPModel.from_pretrained(
|
| 1820 |
+
"laion/CLIP-ViT-B-32-laion2B-s34B-b79K", dtype=torch.float16
|
| 1821 |
)
|
| 1822 |
|
| 1823 |
# Load guided pipeline
|
|
|
|
| 1826 |
custom_pipeline="clip_guided_stable_diffusion_img2img",
|
| 1827 |
clip_model=clip_model,
|
| 1828 |
feature_extractor=feature_extractor,
|
| 1829 |
+
dtype=torch.float16,
|
| 1830 |
)
|
| 1831 |
guided_pipeline.enable_attention_slicing()
|
| 1832 |
guided_pipeline = guided_pipeline.to("cuda")
|
|
|
|
| 1884 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1",
|
| 1885 |
custom_pipeline="stable_diffusion_tensorrt_txt2img",
|
| 1886 |
variant='fp16',
|
| 1887 |
+
dtype=torch.float16,
|
| 1888 |
scheduler=scheduler,)
|
| 1889 |
|
| 1890 |
# re-use cached folder to save ONNX models and TensorRT Engines
|
|
|
|
| 1923 |
|
| 1924 |
return im.crop((left, upper, right, lower)).resize((512, 512))
|
| 1925 |
|
| 1926 |
+
dtype = torch.float16
|
| 1927 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 1928 |
|
| 1929 |
# scheduler and text_encoder param values as in the paper
|
|
|
|
| 1938 |
|
| 1939 |
text_encoder = CLIPTextModel.from_pretrained(
|
| 1940 |
pretrained_model_name_or_path="openai/clip-vit-large-patch14",
|
| 1941 |
+
dtype=dtype,
|
| 1942 |
)
|
| 1943 |
|
| 1944 |
# initialize pipeline
|
|
|
|
| 1949 |
scheduler=scheduler,
|
| 1950 |
text_encoder=text_encoder,
|
| 1951 |
leapfrog_steps=True,
|
| 1952 |
+
dtype=dtype,
|
| 1953 |
).to(device)
|
| 1954 |
|
| 1955 |
# download image
|
|
|
|
| 2009 |
mask_image = download_image(mask_url).resize((512, 512))
|
| 2010 |
mask_image = PIL.ImageOps.invert(mask_image)
|
| 2011 |
pipe = StableDiffusionPipeline.from_pretrained(
|
| 2012 |
+
"CompVis/stable-diffusion-v1-4", dtype=torch.float16, custom_pipeline="stable_diffusion_repaint",
|
| 2013 |
)
|
| 2014 |
pipe.scheduler = RePaintScheduler.from_config(pipe.scheduler.config)
|
| 2015 |
pipe = pipe.to("cuda")
|
|
|
|
| 2038 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1",
|
| 2039 |
custom_pipeline="stable_diffusion_tensorrt_img2img",
|
| 2040 |
variant='fp16',
|
| 2041 |
+
dtype=torch.float16,
|
| 2042 |
scheduler=scheduler,)
|
| 2043 |
|
| 2044 |
# re-use cached folder to save ONNX models and TensorRT Engines
|
|
|
|
| 2076 |
|
| 2077 |
pipe = StableDiffusionBoxDiffPipeline.from_pretrained(
|
| 2078 |
"stabilityai/stable-diffusion-2-1-base",
|
| 2079 |
+
dtype=torch.float16,
|
| 2080 |
)
|
| 2081 |
pipe.to("cuda")
|
| 2082 |
|
|
|
|
| 2134 |
pipe = StableDiffusionReferencePipeline.from_pretrained(
|
| 2135 |
"stable-diffusion-v1-5/stable-diffusion-v1-5",
|
| 2136 |
safety_checker=None,
|
| 2137 |
+
dtype=torch.float16
|
| 2138 |
).to('cuda:0')
|
| 2139 |
|
| 2140 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
|
|
|
| 2187 |
image = np.concatenate([image, image, image], axis=2)
|
| 2188 |
canny_image = Image.fromarray(image)
|
| 2189 |
|
| 2190 |
+
controlnet = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny", dtype=torch.float16)
|
| 2191 |
pipe = StableDiffusionControlNetReferencePipeline.from_pretrained(
|
| 2192 |
"stable-diffusion-v1-5/stable-diffusion-v1-5",
|
| 2193 |
controlnet=controlnet,
|
| 2194 |
safety_checker=None,
|
| 2195 |
+
dtype=torch.float16
|
| 2196 |
).to('cuda:0')
|
| 2197 |
|
| 2198 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
|
|
|
| 2455 |
"laion/CLIP-ViT-B-32-laion2B-s34B-b79K"
|
| 2456 |
)
|
| 2457 |
clip_model = CLIPModel.from_pretrained(
|
| 2458 |
+
"laion/CLIP-ViT-B-32-laion2B-s34B-b79K", dtype=torch.float16
|
| 2459 |
)
|
| 2460 |
coca_model = open_clip.create_model('coca_ViT-L-14', pretrained='laion2B-s13B-b90k').to('cuda')
|
| 2461 |
coca_model.dtype = torch.float16
|
|
|
|
| 2476 |
coca_model=coca_model,
|
| 2477 |
coca_tokenizer=coca_tokenizer,
|
| 2478 |
coca_transform=coca_transform,
|
| 2479 |
+
dtype=torch.float16,
|
| 2480 |
)
|
| 2481 |
mixing_pipeline.enable_attention_slicing()
|
| 2482 |
mixing_pipeline = mixing_pipeline.to("cuda")
|
|
|
|
| 2525 |
|
| 2526 |
pipe = DiffusionPipeline.from_pretrained(
|
| 2527 |
"stabilityai/stable-diffusion-xl-base-1.0"
|
| 2528 |
+
, dtype = torch.float16
|
| 2529 |
, use_safetensors = True
|
| 2530 |
, variant = "fp16"
|
| 2531 |
, custom_pipeline = "lpw_stable_diffusion_xl",
|
|
|
|
| 2655 |
|
| 2656 |
# Load fixed vae (optional)
|
| 2657 |
vae = AutoencoderKL.from_pretrained(
|
| 2658 |
+
"madebyollin/sdxl-vae-fp16-fix", dtype=torch.float16
|
| 2659 |
).to(device)
|
| 2660 |
|
| 2661 |
# Create scheduler and model (similar to StableDiffusionPipeline)
|
|
|
|
| 2663 |
scheduler = DPMSolverMultistepScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000)
|
| 2664 |
pipe = DiffusionPipeline.from_pretrained(
|
| 2665 |
model_id,
|
| 2666 |
+
dtype=torch.float16,
|
| 2667 |
vae=vae,
|
| 2668 |
custom_pipeline="mixture_tiling_sdxl",
|
| 2669 |
scheduler=scheduler,
|
|
|
|
| 2713 |
|
| 2714 |
# Initialize the models and pipeline
|
| 2715 |
controlnet = ControlNetUnionModel.from_pretrained(
|
| 2716 |
+
"brad-twinkl/controlnet-union-sdxl-1.0-promax", dtype=torch.float16
|
| 2717 |
).to(device=device)
|
| 2718 |
+
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", dtype=torch.float16).to(device=device)
|
| 2719 |
|
| 2720 |
model_id = "SG161222/RealVisXL_V5.0"
|
| 2721 |
pipe = DiffusionPipeline.from_pretrained(
|
| 2722 |
model_id,
|
| 2723 |
+
dtype=torch.float16,
|
| 2724 |
vae=vae,
|
| 2725 |
controlnet=controlnet,
|
| 2726 |
custom_pipeline="mod_controlnet_tile_sr_sdxl",
|
|
|
|
| 2814 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-inpainting",
|
| 2815 |
custom_pipeline="stable_diffusion_tensorrt_inpaint",
|
| 2816 |
variant='fp16',
|
| 2817 |
+
dtype=torch.float16,
|
| 2818 |
scheduler=scheduler,
|
| 2819 |
)
|
| 2820 |
|
|
|
|
| 2904 |
|
| 2905 |
model_id = "kxic/zero123-165000" # zero123-105000, zero123-165000, zero123-xl
|
| 2906 |
|
| 2907 |
+
pipe = Zero1to3StableDiffusionPipeline.from_pretrained(model_id, dtype=torch.float16)
|
| 2908 |
|
| 2909 |
pipe.enable_xformers_memory_efficient_attention()
|
| 2910 |
pipe.enable_vae_tiling()
|
|
|
|
| 2984 |
# pipe = DiffusionPipeline.from_pretrained(
|
| 2985 |
# "stabilityai/stable-diffusion-xl-base-1.0",
|
| 2986 |
# custom_pipeline="stable_diffusion_xl_reference",
|
| 2987 |
+
# dtype=torch.float16,
|
| 2988 |
# use_safetensors=True,
|
| 2989 |
# variant="fp16").to('cuda:0')
|
| 2990 |
|
| 2991 |
pipe = StableDiffusionXLReferencePipeline.from_pretrained(
|
| 2992 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 2993 |
+
dtype=torch.float16,
|
| 2994 |
use_safetensors=True,
|
| 2995 |
variant="fp16").to('cuda:0')
|
| 2996 |
|
|
|
|
| 3062 |
# initialize the models and pipeline
|
| 3063 |
controlnet_conditioning_scale = 0.5 # recommended for good generalization
|
| 3064 |
controlnet = ControlNetModel.from_pretrained(
|
| 3065 |
+
"diffusers/controlnet-canny-sdxl-1.0", dtype=torch.float16
|
| 3066 |
)
|
| 3067 |
+
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", dtype=torch.float16)
|
| 3068 |
pipe = StableDiffusionXLControlNetReferencePipeline.from_pretrained(
|
| 3069 |
+
"stabilityai/stable-diffusion-xl-base-1.0", controlnet=controlnet, vae=vae, dtype=torch.float16
|
| 3070 |
).to("cuda:0")
|
| 3071 |
|
| 3072 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
|
|
|
| 3134 |
# make sure you're logged in with `hf auth login`
|
| 3135 |
model_id_or_path = "stable-diffusion-v1-5/stable-diffusion-v1-5"
|
| 3136 |
# can also be used with dreamlike-art/dreamlike-photoreal-2.0
|
| 3137 |
+
pipe = DiffusionPipeline.from_pretrained(model_id_or_path, dtype=torch.float16, custom_pipeline="pipeline_fabric").to("cuda")
|
| 3138 |
|
| 3139 |
# let's specify a prompt
|
| 3140 |
prompt = "An astronaut riding an elephant"
|
|
|
|
| 3376 |
pipe = DiffusionPipeline.from_pretrained("SimianLuo/LCM_Dreamshaper_v7", custom_pipeline="latent_consistency_txt2img", custom_revision="main")
|
| 3377 |
|
| 3378 |
# To save GPU memory, torch.float16 can be used, but it may compromise image quality.
|
| 3379 |
+
pipe.to(torch_device="cuda", dtype=torch.float32)
|
| 3380 |
```
|
| 3381 |
|
| 3382 |
- 2. Run inference with as little as 4 steps:
|
|
|
|
| 3405 |
pipe = DiffusionPipeline.from_pretrained("SimianLuo/LCM_Dreamshaper_v7", custom_pipeline="latent_consistency_img2img")
|
| 3406 |
|
| 3407 |
# To save GPU memory, torch.float16 can be used, but it may compromise image quality.
|
| 3408 |
+
pipe.to(torch_device="cuda", dtype=torch.float32)
|
| 3409 |
```
|
| 3410 |
|
| 3411 |
- 2. Run inference with as little as 4 steps:
|
|
|
|
| 3437 |
pipe = DiffusionPipeline.from_pretrained("SimianLuo/LCM_Dreamshaper_v7", custom_pipeline="latent_consistency_interpolate")
|
| 3438 |
|
| 3439 |
# To save GPU memory, torch.float16 can be used, but it may compromise image quality.
|
| 3440 |
+
pipe.to(torch_device="cuda", dtype=torch.float32)
|
| 3441 |
|
| 3442 |
prompts = [
|
| 3443 |
"Self-portrait oil painting, a beautiful cyborg with golden hair, Margot Robbie, 8k",
|
|
|
|
| 3534 |
|
| 3535 |
controlnet_depth = ControlNetModel.from_pretrained(
|
| 3536 |
"diffusers/controlnet-depth-sdxl-1.0",
|
| 3537 |
+
dtype=torch.float16,
|
| 3538 |
variant="fp16",
|
| 3539 |
use_safetensors=True
|
| 3540 |
)
|
| 3541 |
adapter_depth = T2IAdapter.from_pretrained(
|
| 3542 |
+
"TencentARC/t2i-adapter-depth-midas-sdxl-1.0", dtype=torch.float16, variant="fp16", use_safetensors=True
|
| 3543 |
)
|
| 3544 |
+
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", dtype=torch.float16, use_safetensors=True)
|
| 3545 |
|
| 3546 |
pipe = StableDiffusionXLControlNetAdapterPipeline.from_pretrained(
|
| 3547 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
|
|
|
| 3550 |
vae=vae,
|
| 3551 |
variant="fp16",
|
| 3552 |
use_safetensors=True,
|
| 3553 |
+
dtype=torch.float16,
|
| 3554 |
)
|
| 3555 |
pipe = pipe.to("cuda")
|
| 3556 |
pipe.enable_xformers_memory_efficient_attention()
|
|
|
|
| 3599 |
|
| 3600 |
controlnet_depth = ControlNetModel.from_pretrained(
|
| 3601 |
"diffusers/controlnet-depth-sdxl-1.0",
|
| 3602 |
+
dtype=torch.float16,
|
| 3603 |
variant="fp16",
|
| 3604 |
use_safetensors=True
|
| 3605 |
)
|
| 3606 |
adapter_depth = T2IAdapter.from_pretrained(
|
| 3607 |
+
"TencentARC/t2i-adapter-depth-midas-sdxl-1.0", dtype=torch.float16, variant="fp16", use_safetensors=True
|
| 3608 |
)
|
| 3609 |
+
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", dtype=torch.float16, use_safetensors=True)
|
| 3610 |
|
| 3611 |
pipe = StableDiffusionXLControlNetAdapterInpaintPipeline.from_pretrained(
|
| 3612 |
"diffusers/stable-diffusion-xl-1.0-inpainting-0.1",
|
|
|
|
| 3615 |
vae=vae,
|
| 3616 |
variant="fp16",
|
| 3617 |
use_safetensors=True,
|
| 3618 |
+
dtype=torch.float16,
|
| 3619 |
)
|
| 3620 |
pipe = pipe.to("cuda")
|
| 3621 |
pipe.enable_xformers_memory_efficient_attention()
|
|
|
|
| 4042 |
|
| 4043 |
motion_id = "guoyww/animatediff-motion-adapter-v1-5-2"
|
| 4044 |
adapter = MotionAdapter.from_pretrained(motion_id)
|
| 4045 |
+
controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_openpose", dtype=torch.float16)
|
| 4046 |
+
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse", dtype=torch.float16)
|
| 4047 |
|
| 4048 |
model_id = "SG161222/Realistic_Vision_V5.1_noVAE"
|
| 4049 |
pipe = DiffusionPipeline.from_pretrained(
|
|
|
|
| 4052 |
controlnet=controlnet,
|
| 4053 |
vae=vae,
|
| 4054 |
custom_pipeline="pipeline_animatediff_controlnet",
|
| 4055 |
+
dtype=torch.float16,
|
| 4056 |
).to(device="cuda")
|
| 4057 |
pipe.scheduler = DPMSolverMultistepScheduler.from_pretrained(
|
| 4058 |
model_id, subfolder="scheduler", beta_schedule="linear", clip_sample=False, timestep_spacing="linspace", steps_offset=1
|
|
|
|
| 4104 |
|
| 4105 |
motion_id = "guoyww/animatediff-motion-adapter-v1-5-2"
|
| 4106 |
adapter = MotionAdapter.from_pretrained(motion_id)
|
| 4107 |
+
controlnet1 = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_openpose", dtype=torch.float16)
|
| 4108 |
+
controlnet2 = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny", dtype=torch.float16)
|
| 4109 |
+
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse", dtype=torch.float16)
|
| 4110 |
|
| 4111 |
model_id = "SG161222/Realistic_Vision_V5.1_noVAE"
|
| 4112 |
pipe = DiffusionPipeline.from_pretrained(
|
|
|
|
| 4115 |
controlnet=[controlnet1, controlnet2],
|
| 4116 |
vae=vae,
|
| 4117 |
custom_pipeline="pipeline_animatediff_controlnet",
|
| 4118 |
+
dtype=torch.float16,
|
| 4119 |
).to(device="cuda")
|
| 4120 |
pipe.scheduler = DPMSolverMultistepScheduler.from_pretrained(
|
| 4121 |
model_id, subfolder="scheduler", clip_sample=False, timestep_spacing="linspace", steps_offset=1, beta_schedule="linear",
|
|
|
|
| 4203 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 4204 |
custom_pipeline="pipeline_demofusion_sdxl",
|
| 4205 |
custom_revision="main",
|
| 4206 |
+
dtype=torch.float16,
|
| 4207 |
)
|
| 4208 |
pipe = pipe.to("cuda")
|
| 4209 |
|
|
|
|
| 4359 |
import torch
|
| 4360 |
|
| 4361 |
|
| 4362 |
+
pipe = DiffusionPipeline.from_pretrained("XCLIU/instaflow_0_9B_from_sd_1_5", dtype=torch.float16, custom_pipeline="instaflow_one_step")
|
| 4363 |
pipe.to("cuda") ### if GPU is not available, comment this line
|
| 4364 |
prompt = "A hyper-realistic photo of a cute cat."
|
| 4365 |
|
|
|
|
| 4379 |
|
| 4380 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 4381 |
|
| 4382 |
+
pipe = DiffusionPipeline.from_pretrained("XCLIU/instaflow_0_9B_from_sd_1_5", dtype=torch.float16, custom_pipeline="instaflow_one_step")
|
| 4383 |
pipe.to(device) ### if GPU is not available, comment this line
|
| 4384 |
pipe.load_lora_weights("artificialguybr/logo-redmond-1-5v-logo-lora-for-liberteredmond-sd-1-5")
|
| 4385 |
prompt = "logo, A logo for a fitness app, dynamic running figure, energetic colors (red, orange) ),LogoRedAF ,"
|
|
|
|
| 4424 |
# Float32 is essential to a well optimization
|
| 4425 |
model_path = "stable-diffusion-v1-5/stable-diffusion-v1-5"
|
| 4426 |
scheduler = DDIMScheduler(num_train_timesteps=1000, beta_start=0.00085, beta_end=0.0120, beta_schedule="scaled_linear")
|
| 4427 |
+
pipeline = NullTextPipeline.from_pretrained(model_path, scheduler=scheduler, dtype=torch.float32).to(device)
|
| 4428 |
|
| 4429 |
# Saves the inverted_latent to save time
|
| 4430 |
inverted_latent, uncond = pipeline.invert(input_image, invert_prompt, num_inner_steps=10, early_stop_epsilon=1e-5, num_inference_steps=steps)
|
|
|
|
| 4530 |
from PIL import Image
|
| 4531 |
|
| 4532 |
model_id = "a-r-r-o-w/dreamshaper-xl-turbo"
|
| 4533 |
+
pipe = DiffusionPipeline.from_pretrained(model_id, dtype=torch.float16, variant="fp16", custom_pipeline="pipeline_sdxl_style_aligned")
|
| 4534 |
pipe = pipe.to("cuda")
|
| 4535 |
|
| 4536 |
# Enable memory saving techniques
|
|
|
|
| 4629 |
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse").to(dtype=torch.float16)
|
| 4630 |
pipeline = DiffusionPipeline.from_pretrained(
|
| 4631 |
"SG161222/Realistic_Vision_V4.0_noVAE",
|
| 4632 |
+
dtype=torch.float16,
|
| 4633 |
scheduler=noise_scheduler,
|
| 4634 |
vae=vae,
|
| 4635 |
custom_pipeline="ip_adapter_face_id"
|
|
|
|
| 4694 |
controlnet_path = './checkpoints/ControlNetModel'
|
| 4695 |
|
| 4696 |
# load IdentityNet
|
| 4697 |
+
controlnet = ControlNetModel.from_pretrained(controlnet_path, dtype=torch.float16)
|
| 4698 |
|
| 4699 |
base_model = 'wangqixun/YamerMIX_v8'
|
| 4700 |
pipe = StableDiffusionXLInstantIDPipeline.from_pretrained(
|
| 4701 |
base_model,
|
| 4702 |
controlnet=controlnet,
|
| 4703 |
+
dtype=torch.float16
|
| 4704 |
)
|
| 4705 |
pipe.to("cuda")
|
| 4706 |
|
|
|
|
| 4744 |
ufogen_model_id_or_path = "/path/to/ufogen/model"
|
| 4745 |
pipe = StableDiffusionPipeline(
|
| 4746 |
ufogen_model_id_or_path,
|
| 4747 |
+
dtype=torch.float16,
|
| 4748 |
)
|
| 4749 |
|
| 4750 |
# You can initialize a UFOGenScheduler as follows:
|
|
|
|
| 4871 |
2. After pipeline initialization, `prepare_for_ipex()` should be called to enable IPEX acceleration. Supported inference datatypes are Float32 and BFloat16.
|
| 4872 |
|
| 4873 |
```python
|
| 4874 |
+
pipe = AnimateDiffPipelineIpex.from_pretrained(base, motion_adapter=adapter, dtype=dtype).to(device)
|
| 4875 |
# For Float32
|
| 4876 |
pipe.prepare_for_ipex(torch.float32, prompt="A girl smiling")
|
| 4877 |
# For BFloat16
|
|
|
|
| 4924 |
############## bf16 inference performance ###############
|
| 4925 |
|
| 4926 |
# 1. IPEX Pipeline initialization
|
| 4927 |
+
pipe = AnimateDiffPipelineIpex.from_pretrained(base, motion_adapter=adapter, dtype=dtype).to(device)
|
| 4928 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
|
| 4929 |
pipe.prepare_for_ipex(torch.bfloat16, prompt = prompt)
|
| 4930 |
|
| 4931 |
# 2. Original Pipeline initialization
|
| 4932 |
+
pipe2 = AnimateDiffPipeline.from_pretrained(base, motion_adapter=adapter, dtype=dtype).to(device)
|
| 4933 |
pipe2.scheduler = EulerDiscreteScheduler.from_config(pipe2.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
|
| 4934 |
|
| 4935 |
# 3. Compare performance between Original Pipeline and IPEX Pipeline
|
|
|
|
| 4942 |
############## fp32 inference performance ###############
|
| 4943 |
|
| 4944 |
# 1. IPEX Pipeline initialization
|
| 4945 |
+
pipe3 = AnimateDiffPipelineIpex.from_pretrained(base, motion_adapter=adapter, dtype=dtype).to(device)
|
| 4946 |
pipe3.scheduler = EulerDiscreteScheduler.from_config(pipe3.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
|
| 4947 |
pipe3.prepare_for_ipex(torch.float32, prompt = prompt)
|
| 4948 |
|
| 4949 |
# 2. Original Pipeline initialization
|
| 4950 |
+
pipe4 = AnimateDiffPipeline.from_pretrained(base, motion_adapter=adapter, dtype=dtype).to(device)
|
| 4951 |
pipe4.scheduler = EulerDiscreteScheduler.from_config(pipe4.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
|
| 4952 |
|
| 4953 |
# 3. Compare performance between Original Pipeline and IPEX Pipeline
|
|
|
|
| 4973 |
|
| 4974 |
|
| 4975 |
pipe = HunyuanDiTDifferentialImg2ImgPipeline.from_pretrained(
|
| 4976 |
+
"Tencent-Hunyuan/HunyuanDiT-Diffusers", dtype=torch.float16
|
| 4977 |
).to("cuda")
|
| 4978 |
|
| 4979 |
|
|
|
|
| 5077 |
scheduler=scheduler,
|
| 5078 |
variant="fp16",
|
| 5079 |
use_safetensors=True,
|
| 5080 |
+
dtype=dtype,
|
| 5081 |
).to(device)
|
| 5082 |
|
| 5083 |
|
|
|
|
| 5155 |
pipe = StableDiffusionPipeline.from_pretrained(
|
| 5156 |
"stable-diffusion-v1-5/stable-diffusion-v1-5",
|
| 5157 |
custom_pipeline="hyoungwoncho/sd_perturbed_attention_guidance",
|
| 5158 |
+
dtype=torch.float16
|
| 5159 |
)
|
| 5160 |
|
| 5161 |
device = "cuda"
|
|
|
|
| 5250 |
# load controlnet
|
| 5251 |
controlnet = PixArtControlNetAdapterModel.from_pretrained(
|
| 5252 |
controlnet_repo_id,
|
| 5253 |
+
dtype=weight_dtype,
|
| 5254 |
use_safetensors=True,
|
| 5255 |
).to(device)
|
| 5256 |
|
| 5257 |
pipe = PixArtAlphaControlnetPipeline.from_pretrained(
|
| 5258 |
"PixArt-alpha/PixArt-XL-2-1024-MS",
|
| 5259 |
controlnet=controlnet,
|
| 5260 |
+
dtype=weight_dtype,
|
| 5261 |
use_safetensors=True,
|
| 5262 |
).to(device)
|
| 5263 |
|
|
|
|
| 5317 |
# Load pretrained pipeline
|
| 5318 |
pipeline = CogVideoXPipelineForDDIMInversion.from_pretrained(
|
| 5319 |
"THUDM/CogVideoX1.5-5B",
|
| 5320 |
+
dtype=torch.bfloat16,
|
| 5321 |
).to("cuda")
|
| 5322 |
|
| 5323 |
# Run DDIM inversion, and the videos will be generated in the output_path
|
|
|
|
| 5369 |
)
|
| 5370 |
|
| 5371 |
# Initialize the models and pipeline
|
| 5372 |
+
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", dtype=dtype)
|
| 5373 |
|
| 5374 |
model_id = "SG161222/RealVisXL_V4.0"
|
| 5375 |
pipe = DiffusionPipeline.from_pretrained(
|
| 5376 |
model_id,
|
| 5377 |
+
dtype=dtype,
|
| 5378 |
vae=vae,
|
| 5379 |
unet=None, #<- Do not load with original model.
|
| 5380 |
custom_pipeline="pipeline_faithdiff_stable_diffusion_xl",
|
|
|
|
| 5459 |
|
| 5460 |
|
| 5461 |
pipe = DiffusionPipeline.from_pretrained(
|
| 5462 |
+
"stabilityai/stable-diffusion-3-medium-diffusers", custom_pipeline="pipeline_stable_diffusion_3_instruct_pix2pix", dtype=torch.float16).to('cuda')
|
| 5463 |
|
| 5464 |
+
pipe.transformer = SD3Transformer2DModel.from_pretrained("CaptainZZZ/sd3-instructpix2pix",dtype=torch.float16).to('cuda')
|
| 5465 |
|
| 5466 |
edited_image = pipe(
|
| 5467 |
prompt=edit_instruction,
|
|
|
|
| 5503 |
|
| 5504 |
pipe = FluxKontextPipeline.from_pretrained(
|
| 5505 |
"black-forest-labs/FLUX.1-Kontext-dev",
|
| 5506 |
+
dtype=torch.bfloat16,
|
| 5507 |
custom_pipeline="pipeline_flux_kontext_multiple_images",
|
| 5508 |
)
|
| 5509 |
pipe.to("cuda")
|
|
|
|
| 5559 |
# Load ControlNet
|
| 5560 |
controlnet = FluxControlNetModel.from_pretrained(
|
| 5561 |
controlnet_model,
|
| 5562 |
+
dtype=dtype,
|
| 5563 |
)
|
| 5564 |
|
| 5565 |
# Load Fill + ControlNet Pipeline
|
| 5566 |
fill_pipe = FluxControlNetFillInpaintPipeline.from_pretrained(
|
| 5567 |
base_model,
|
| 5568 |
controlnet=controlnet,
|
| 5569 |
+
dtype=dtype,
|
| 5570 |
).to(device)
|
| 5571 |
|
| 5572 |
# OPTIONAL FP8
|
|
|
|
| 5578 |
# OPTIONAL Prior Redux
|
| 5579 |
#pipe_prior_redux = FluxPriorReduxPipeline.from_pretrained(
|
| 5580 |
# prior_model,
|
| 5581 |
+
# dtype=dtype,
|
| 5582 |
#).to(device)
|
| 5583 |
|
| 5584 |
# Inputs
|
|
|
|
| 5629 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 5630 |
result.images[0].save(f"flux_fill_controlnet_inpaint_depth{timestamp}.jpg")
|
| 5631 |
```
|
|
|
main/README_community_scripts.md
CHANGED
|
@@ -123,12 +123,12 @@ def prepare_ip_adapter_image_embeds(
|
|
| 123 |
|
| 124 |
vae = AutoencoderKL.from_pretrained(
|
| 125 |
"madebyollin/sdxl-vae-fp16-fix",
|
| 126 |
-
|
| 127 |
).to("cuda")
|
| 128 |
|
| 129 |
pipeline = StableDiffusionXLPipeline.from_pretrained(
|
| 130 |
"RunDiffusion/Juggernaut-XL-v9",
|
| 131 |
-
|
| 132 |
vae=vae,
|
| 133 |
variant="fp16",
|
| 134 |
).to("cuda")
|
|
@@ -210,7 +210,7 @@ def seamless_tiling(pipeline, x_axis, y_axis):
|
|
| 210 |
layer._conv_forward = asymmetric_conv2d_convforward.__get__(layer, torch.nn.Conv2d)
|
| 211 |
return pipeline
|
| 212 |
|
| 213 |
-
pipeline = StableDiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5",
|
| 214 |
pipeline.enable_model_cpu_offload()
|
| 215 |
prompt = ["texture of a red brick wall"]
|
| 216 |
seed = 123456
|
|
@@ -284,7 +284,7 @@ class SDPromptSchedulingCallback(PipelineCallback):
|
|
| 284 |
|
| 285 |
pipeline: StableDiffusionPipeline = StableDiffusionPipeline.from_pretrained(
|
| 286 |
"stable-diffusion-v1-5/stable-diffusion-v1-5",
|
| 287 |
-
|
| 288 |
variant="fp16",
|
| 289 |
use_safetensors=True,
|
| 290 |
).to("cuda")
|
|
@@ -379,7 +379,7 @@ class SDXLPromptSchedulingCallback(PipelineCallback):
|
|
| 379 |
|
| 380 |
pipeline: StableDiffusionXLPipeline = StableDiffusionXLPipeline.from_pretrained(
|
| 381 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 382 |
-
|
| 383 |
variant="fp16",
|
| 384 |
use_safetensors=True,
|
| 385 |
).to("cuda")
|
|
|
|
| 123 |
|
| 124 |
vae = AutoencoderKL.from_pretrained(
|
| 125 |
"madebyollin/sdxl-vae-fp16-fix",
|
| 126 |
+
dtype=torch.float16,
|
| 127 |
).to("cuda")
|
| 128 |
|
| 129 |
pipeline = StableDiffusionXLPipeline.from_pretrained(
|
| 130 |
"RunDiffusion/Juggernaut-XL-v9",
|
| 131 |
+
dtype=torch.float16,
|
| 132 |
vae=vae,
|
| 133 |
variant="fp16",
|
| 134 |
).to("cuda")
|
|
|
|
| 210 |
layer._conv_forward = asymmetric_conv2d_convforward.__get__(layer, torch.nn.Conv2d)
|
| 211 |
return pipeline
|
| 212 |
|
| 213 |
+
pipeline = StableDiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", dtype=torch.float16, use_safetensors=True)
|
| 214 |
pipeline.enable_model_cpu_offload()
|
| 215 |
prompt = ["texture of a red brick wall"]
|
| 216 |
seed = 123456
|
|
|
|
| 284 |
|
| 285 |
pipeline: StableDiffusionPipeline = StableDiffusionPipeline.from_pretrained(
|
| 286 |
"stable-diffusion-v1-5/stable-diffusion-v1-5",
|
| 287 |
+
dtype=torch.float16,
|
| 288 |
variant="fp16",
|
| 289 |
use_safetensors=True,
|
| 290 |
).to("cuda")
|
|
|
|
| 379 |
|
| 380 |
pipeline: StableDiffusionXLPipeline = StableDiffusionXLPipeline.from_pretrained(
|
| 381 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 382 |
+
dtype=torch.float16,
|
| 383 |
variant="fp16",
|
| 384 |
use_safetensors=True,
|
| 385 |
).to("cuda")
|
main/marigold_depth_estimation.py
CHANGED
|
@@ -43,7 +43,7 @@ from diffusers.utils import BaseOutput, check_min_version
|
|
| 43 |
|
| 44 |
|
| 45 |
# Will error if the minimal version of diffusers is not installed. Remove at your own risks.
|
| 46 |
-
check_min_version("0.
|
| 47 |
|
| 48 |
|
| 49 |
class MarigoldDepthOutput(BaseOutput):
|
|
|
|
| 43 |
|
| 44 |
|
| 45 |
# Will error if the minimal version of diffusers is not installed. Remove at your own risks.
|
| 46 |
+
check_min_version("0.41.0.dev0")
|
| 47 |
|
| 48 |
|
| 49 |
class MarigoldDepthOutput(BaseOutput):
|