repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
diffusers | scripts/convert_unclip_txt2img_to_image_variation.py | .py | import argparse
from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection
from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to... | 42 | 1,313 |
diffusers | scripts/convert_joyimage_edit_to_diffusers.py | .py | """Convert JoyImage Edit / Edit Plus checkpoints to diffusers format.
Supports both JoyImage-Edit (single-image editing) and JoyImage-Edit-Plus
(multi-image editing). The transformer weight layout is identical; only the
target model class and pipeline differ.
Usage:
# Convert JoyImage Edit (default)
python co... | 356 | 15,599 |
diffusers | scripts/convert_vae_pt_to_diffusers.py | .py | import argparse
import io
import requests
import torch
import yaml
from diffusers import AutoencoderKL
from diffusers.pipelines.stable_diffusion.convert_from_ckpt import (
assign_to_checkpoint,
conv_attn_to_linear,
create_vae_diffusers_config,
renew_vae_attention_paths,
renew_vae_resnet_paths,
)
f... | 178 | 8,327 |
diffusers | scripts/convert_stable_audio.py | .py | # Run this script to convert the Stable Audio model weights to a diffusers pipeline.
import argparse
import json
import os
from contextlib import nullcontext
import torch
from safetensors.torch import load_file
from transformers import (
AutoTokenizer,
T5EncoderModel,
)
from diffusers import (
Autoencoder... | 280 | 10,992 |
diffusers | scripts/convert_original_stable_diffusion_to_diffusers.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 189 | 7,020 |
diffusers | scripts/convert_consistency_to_diffusers.py | .py | import argparse
import os
import torch
from diffusers import (
CMStochasticIterativeScheduler,
ConsistencyModelPipeline,
UNet2DModel,
)
TEST_UNET_CONFIG = {
"sample_size": 32,
"in_channels": 3,
"out_channels": 3,
"layers_per_block": 2,
"num_class_embeds": 1000,
"block_out_channel... | 316 | 12,727 |
diffusers | scripts/convert_aura_flow_to_diffusers.py | .py | import argparse
import torch
from huggingface_hub import hf_hub_download
from diffusers.models.transformers.auraflow_transformer_2d import AuraFlowTransformer2DModel
def load_original_state_dict(args):
model_pt = hf_hub_download(repo_id=args.original_state_dict_repo_id, filename="aura_diffusion_pytorch_model.bi... | 132 | 5,744 |
diffusers | scripts/convert_ddpm_original_checkpoint_to_diffusers.py | .py | import argparse
import json
import torch
from diffusers import AutoencoderKL, DDPMPipeline, DDPMScheduler, UNet2DModel, VQModel
def shave_segments(path, n_shave_prefix_segments=1):
"""
Removes segments. Positive values shave the first segments, negative shave the last segments.
"""
if n_shave_prefix... | 432 | 18,727 |
diffusers | scripts/convert_cogvideox_to_diffusers.py | .py | import argparse
from typing import Any, Dict
import torch
from transformers import T5EncoderModel, T5Tokenizer
from diffusers import (
AutoencoderKLCogVideoX,
CogVideoXDDIMScheduler,
CogVideoXImageToVideoPipeline,
CogVideoXPipeline,
CogVideoXTransformer3DModel,
)
def reassign_query_key_value_inp... | 347 | 13,020 |
diffusers | scripts/convert_hunyuandit_controlnet_to_diffusers.py | .py | import argparse
import torch
from diffusers import HunyuanDiT2DControlNetModel
def main(args):
state_dict = torch.load(args.pt_checkpoint_path, map_location="cpu")
if args.load_key != "none":
try:
state_dict = state_dict[args.load_key]
except KeyError:
raise KeyError... | 242 | 11,808 |
diffusers | scripts/convert_ms_text_to_video_to_diffusers.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 429 | 19,170 |
diffusers | scripts/convert_diffusers_sdxl_lora_to_webui.py | .py | # Script for converting a Hugging Face Diffusers trained SDXL LoRAs to Kohya format
# This means that you can input your diffusers-trained LoRAs and
# Get the output to work with WebUIs such as AUTOMATIC1111, ComfyUI, SD.Next and others.
# To get started you can find some cool `diffusers` trained LoRAs such as this cu... | 57 | 2,798 |
diffusers | scripts/convert_omnigen_to_diffusers.py | .py | import argparse
import os
import torch
from huggingface_hub import snapshot_download
from safetensors.torch import load_file
from transformers import AutoTokenizer
from diffusers import AutoencoderKL, FlowMatchEulerDiscreteScheduler, OmniGenPipeline, OmniGenTransformer2DModel
def main(args):
# checkpoint from h... | 204 | 7,499 |
diffusers | scripts/convert_k_upscaler_to_diffusers.py | .py | import argparse
import huggingface_hub
import k_diffusion as K
import torch
from diffusers import UNet2DConditionModel
UPSCALER_REPO = "pcuenq/k-upscaler"
def resnet_to_diffusers_checkpoint(resnet, checkpoint, *, diffusers_resnet_prefix, resnet_prefix):
rv = {
# norm1
f"{diffusers_resnet_prefi... | 298 | 12,336 |
diffusers | scripts/convert_ltx2_to_diffusers.py | .py | import argparse
import os
from contextlib import nullcontext
from typing import Any
import safetensors.torch
import torch
from accelerate import init_empty_weights
from huggingface_hub import hf_hub_download
from transformers import AutoConfig, AutoModelForImageTextToText, AutoProcessor, AutoTokenizer
from diffusers ... | 1,670 | 72,349 |
diffusers | scripts/convert_kakao_brain_unclip_to_diffusers.py | .py | import argparse
import tempfile
import torch
from accelerate import load_checkpoint_and_dispatch
from transformers import CLIPTextModelWithProjection, CLIPTokenizer
from diffusers import UnCLIPPipeline, UNet2DConditionModel, UNet2DModel
from diffusers.models.transformers.prior_transformer import PriorTransformer
from... | 1,160 | 41,701 |
diffusers | scripts/convert_pixart_alpha_to_diffusers.py | .py | import argparse
import os
import torch
from transformers import T5EncoderModel, T5Tokenizer
from diffusers import AutoencoderKL, DPMSolverMultistepScheduler, PixArtAlphaPipeline, Transformer2DModel
ckpt_id = "PixArt-alpha/PixArt-alpha"
# https://github.com/PixArt-alpha/PixArt-alpha/blob/0f55e922376d8b797edd44d25d0e... | 199 | 8,993 |
diffusers | scripts/convert_stable_diffusion_controlnet_to_onnx.py | .py | import argparse
import os
import shutil
from pathlib import Path
import onnx
import onnx_graphsurgeon as gs
import torch
from onnx import shape_inference
from packaging import version
from polygraphy.backend.onnx.loader import fold_constants
from torch.onnx import export
from diffusers import (
ControlNetModel,
... | 506 | 18,463 |
diffusers | scripts/convert_sd3_controlnet_to_diffusers.py | .py | """
A script to convert Stable Diffusion 3.5 ControlNet checkpoints to the Diffusers format.
Example:
Convert a SD3.5 ControlNet checkpoint to Diffusers format using local file:
```bash
python scripts/convert_sd3_controlnet_to_diffusers.py \
--checkpoint_path "path/to/local/sd3.5_large_controlnet_c... | 186 | 8,037 |
diffusers | scripts/convert_hunyuandit_to_diffusers.py | .py | import argparse
import torch
from diffusers import HunyuanDiT2DModel
def main(args):
state_dict = torch.load(args.pt_checkpoint_path, map_location="cpu")
if args.load_key != "none":
try:
state_dict = state_dict[args.load_key]
except KeyError:
raise KeyError(
... | 267 | 12,884 |
diffusers | scripts/convert_longcat_audio_dit_to_diffusers.py | .py | #!/usr/bin/env python3
# Copyright 2026 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... | 226 | 8,458 |
diffusers | scripts/convert_cogview4_to_diffusers_megatron.py | .py | """
Convert a CogView4 checkpoint from Megatron to the Diffusers format.
Example usage:
python scripts/convert_cogview4_to_diffusers.py \
--transformer_checkpoint_path 'your path/cogview4_6b/mp_rank_00/model_optim_rng.pt' \
--vae_checkpoint_path 'your path/cogview4_6b/imagekl_ch16.pt' \
--o... | 385 | 13,275 |
diffusers | scripts/generate_logits.py | .py | import random
import torch
from huggingface_hub import HfApi
from diffusers import UNet2DModel
api = HfApi()
results = {}
# fmt: off
results["google_ddpm_cifar10_32"] = torch.tensor([
-0.7515, -1.6883, 0.2420, 0.0300, 0.6347, 1.3433, -1.1743, -3.7467,
1.2342, -2.2485, 0.4636, 0.8076, -0.7991, 0.3969, 0.849... | 128 | 6,012 |
diffusers | scripts/convert_if.py | .py | import argparse
import inspect
import os
import numpy as np
import torch
import yaml
from torch.nn import functional as F
from transformers import CLIPConfig, CLIPImageProcessor, CLIPVisionModelWithProjection, T5EncoderModel, T5Tokenizer
from diffusers import DDPMScheduler, IFPipeline, IFSuperResolutionPipeline, UNet... | 1,251 | 51,214 |
diffusers | scripts/convert_i2vgen_to_diffusers.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 511 | 22,481 |
diffusers | scripts/convert_minimax_h3_to_diffusers.py | .py | """Convert an original MiniMax-H3 checkpoint into the diffusers layout.
The transformer checkpoint is streamed shard by shard, so peak memory stays close to a single shard (~4.9 GiB) and
never approaches the 62 GiB of the full 33B DiT.
Every source key maps onto a diffusers module by renaming alone, except for three ... | 948 | 47,157 |
diffusers | scripts/change_naming_configs_and_checkpoints.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 114 | 3,887 |
diffusers | scripts/convert_sd3_to_diffusers.py | .py | import argparse
from contextlib import nullcontext
import safetensors.torch
import torch
from accelerate import init_empty_weights
from diffusers import AutoencoderKL, SD3Transformer2DModel
from diffusers.loaders.single_file_utils import convert_ldm_vae_checkpoint
from diffusers.models.model_loading_utils import load... | 352 | 16,255 |
diffusers | scripts/convert_versatile_diffusion_to_diffusers.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 792 | 33,589 |
diffusers | scripts/convert_diffusers_to_original_sdxl.py | .py | # Script for converting a HF Diffusers saved pipeline to a Stable Diffusion checkpoint.
# *Only* converts the UNet, VAE, and Text Encoder.
# Does not convert optimizer state or any other thing.
import argparse
import os.path as osp
import re
import torch
from safetensors.torch import load_file, save_file
# ========... | 351 | 13,986 |
diffusers | scripts/convert_pixart_sigma_to_diffusers.py | .py | import argparse
import os
import torch
from transformers import T5EncoderModel, T5Tokenizer
from diffusers import AutoencoderKL, DPMSolverMultistepScheduler, PixArtSigmaPipeline, Transformer2DModel
ckpt_id = "PixArt-alpha"
# https://github.com/PixArt-alpha/PixArt-sigma/blob/dd087141864e30ec44f12cb7448dd654be065e88/... | 224 | 10,380 |
diffusers | scripts/convert_vq_diffusion_to_diffusers.py | .py | """
This script ports models from VQ-diffusion (https://github.com/microsoft/VQ-Diffusion) to diffusers.
It currently only supports porting the ITHQ dataset.
ITHQ dataset:
```sh
# From the root directory of diffusers.
# Download the VQVAE checkpoint
$ Refer to https://github.com/microsoft/VQ-Diffusion/blob/main/vqdi... | 917 | 35,825 |
diffusers | scripts/convert_dcae_to_diffusers.py | .py | import argparse
from typing import Any, Dict
import torch
from huggingface_hub import hf_hub_download
from safetensors.torch import load_file
from diffusers import AutoencoderDC
def remap_qkv_(key: str, state_dict: Dict[str, Any]):
qkv = state_dict.pop(key)
q, k, v = torch.chunk(qkv, 3, dim=0)
parent_mo... | 324 | 11,445 |
diffusers | scripts/convert_diffusers_to_original_stable_diffusion.py | .py | # Script for converting a HF Diffusers saved pipeline to a Stable Diffusion checkpoint.
# *Only* converts the UNet, VAE, and Text Encoder.
# Does not convert optimizer state or any other thing.
import argparse
import os.path as osp
import re
import torch
from safetensors.torch import load_file, save_file
# ========... | 354 | 13,861 |
diffusers | scripts/convert_svd_to_diffusers.py | .py | from diffusers.utils import is_accelerate_available, logging
if is_accelerate_available():
pass
logger = logging.get_logger(__name__) # pylint: disable=invalid-name
def create_unet_diffusers_config(original_config, image_size: int, controlnet=False):
"""
Creates a config for the diffusers based on the... | 731 | 32,810 |
diffusers | scripts/conversion_ldm_uncond.py | .py | import argparse
import torch
import yaml
from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel
def convert_ldm_original(checkpoint_path, config_path, output_path):
config = yaml.safe_load(config_path)
state_dict = torch.load(checkpoint_path, map_location="cpu")["model"]
keys = list(sta... | 57 | 1,930 |
diffusers | scripts/convert_rae_to_diffusers.py | .py | import argparse
from pathlib import Path
from typing import Any
import torch
from huggingface_hub import HfApi, hf_hub_download
from diffusers import AutoencoderRAE
DECODER_CONFIGS = {
"ViTB": {
"decoder_hidden_size": 768,
"decoder_intermediate_size": 3072,
"decoder_num_attention_heads":... | 407 | 16,329 |
diffusers | scripts/convert_vae_diff_to_onnx.py | .py | # Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | 123 | 3,995 |
diffusers | scripts/convert_animatediff_motion_lora_to_diffusers.py | .py | import argparse
import os
import torch
from huggingface_hub import create_repo, upload_folder
from safetensors.torch import load_file, save_file
def convert_motion_module(original_state_dict):
converted_state_dict = {}
for k, v in original_state_dict.items():
if "pos_encoder" in k:
contin... | 70 | 2,152 |
diffusers | scripts/convert_stable_cascade_lite.py | .py | # Run this script to convert the Stable Cascade model weights to a diffusers pipeline.
import argparse
from contextlib import nullcontext
import torch
from safetensors.torch import load_file
from transformers import (
AutoTokenizer,
CLIPConfig,
CLIPImageProcessor,
CLIPTextModelWithProjection,
CLIPV... | 227 | 8,439 |
diffusers | scripts/convert_kandinsky_to_diffusers.py | .py | import argparse
import os
import tempfile
import torch
from accelerate import load_checkpoint_and_dispatch
from diffusers import UNet2DConditionModel
from diffusers.models.transformers.prior_transformer import PriorTransformer
from diffusers.models.vq_model import VQModel
"""
Example - From the diffusers root direc... | 1,412 | 52,905 |
diffusers | scripts/convert_flux2_to_diffusers.py | .py | import argparse
from contextlib import nullcontext
from typing import Any, Dict, Tuple
import safetensors.torch
import torch
from accelerate import init_empty_weights
from huggingface_hub import hf_hub_download
from transformers import AutoProcessor, GenerationConfig, Mistral3ForConditionalGeneration
from diffusers i... | 537 | 22,039 |
diffusers | scripts/convert_original_t2i_adapter.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 251 | 14,274 |
diffusers | scripts/convert_sana_video_to_diffusers.py | .py | #!/usr/bin/env python
from __future__ import annotations
import argparse
import os
from contextlib import nullcontext
import torch
from accelerate import init_empty_weights
from huggingface_hub import hf_hub_download, snapshot_download
from termcolor import colored
from transformers import AutoModelForCausalLM, AutoT... | 361 | 14,576 |
diffusers | scripts/convert_prx_to_diffusers.py | .py | #!/usr/bin/env python3
"""
Script to convert a PRX checkpoint from the original codebase to diffusers format.
Supports two checkpoint layouts:
* a single-file ``torch.save`` checkpoint (``.pt`` / ``.pth``), and
* a sharded torch Distributed Checkpoint (DCP) directory (``.metadata`` + ``*.distcp``),
as produced... | 425 | 17,966 |
diffusers | scripts/convert_hunyuan_video_to_diffusers.py | .py | import argparse
from typing import Any, Dict
import torch
from accelerate import init_empty_weights
from transformers import (
AutoModel,
AutoTokenizer,
CLIPImageProcessor,
CLIPTextModel,
CLIPTokenizer,
LlavaForConditionalGeneration,
)
from diffusers import (
AutoencoderKLHunyuanVideo,
... | 354 | 13,987 |
diffusers | scripts/convert_original_audioldm2_to_diffusers.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 1,136 | 49,271 |
diffusers | scripts/convert_models_diffuser_to_diffusers.py | .py | import json
import os
import torch
from diffusers import UNet1DModel
os.makedirs("hub/hopper-medium-v2/unet/hor32", exist_ok=True)
os.makedirs("hub/hopper-medium-v2/unet/hor128", exist_ok=True)
os.makedirs("hub/hopper-medium-v2/value_function", exist_ok=True)
def unet(hor):
if hor == 128:
down_block_... | 101 | 3,744 |
diffusers | scripts/convert_lumina_to_diffusers.py | .py | import argparse
import os
import torch
from safetensors.torch import load_file
from transformers import AutoModel, AutoTokenizer
from diffusers import AutoencoderKL, FlowMatchEulerDiscreteScheduler, LuminaNextDiT2DModel, LuminaPipeline
def main(args):
# checkpoint from https://huggingface.co/Alpha-VLLM/Lumina-N... | 143 | 7,072 |
diffusers | scripts/convert_lora_safetensor_to_diffusers.py | .py | # coding=utf-8
# Copyright 2024, Haofan Wang, Qixun Wang, All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless re... | 129 | 4,995 |
diffusers | scripts/convert_original_controlnet_to_diffusers.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 110 | 4,243 |
diffusers | scripts/convert_wuerstchen.py | .py | # Run inside root directory of official source code: https://github.com/dome272/wuerstchen/
import os
import torch
from transformers import AutoTokenizer, CLIPTextModel
from vqgan import VQModel
from diffusers import (
DDPMWuerstchenScheduler,
WuerstchenCombinedPipeline,
WuerstchenDecoderPipeline,
Wue... | 116 | 4,899 |
diffusers | scripts/convert_ldm_original_checkpoint_to_diffusers.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 360 | 15,115 |
diffusers | scripts/convert_flux_to_diffusers.py | .py | import argparse
from contextlib import nullcontext
import safetensors.torch
import torch
from accelerate import init_empty_weights
from huggingface_hub import hf_hub_download
from diffusers import AutoencoderKL, FluxTransformer2DModel
from diffusers.loaders.single_file_utils import convert_ldm_vae_checkpoint
from dif... | 309 | 14,371 |
diffusers | scripts/convert_anyflow_to_diffusers.py | .py | # Copyright 2026 The AnyFlow Team, NVIDIA Corp., and The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-... | 161 | 5,609 |
diffusers | scripts/convert_stable_diffusion_checkpoint_to_onnx.py | .py | # Copyright 2026 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | 266 | 9,821 |
diffusers | scripts/convert_animatediff_motion_module_to_diffusers.py | .py | import argparse
import torch
from safetensors.torch import load_file
from diffusers import MotionAdapter
def convert_motion_module(original_state_dict):
converted_state_dict = {}
for k, v in original_state_dict.items():
if "pos_encoder" in k:
continue
else:
converted... | 63 | 2,050 |
diffusers | scripts/convert_stable_diffusion_controlnet_to_tensorrt.py | .py | import argparse
import sys
import tensorrt as trt
def convert_models(onnx_path: str, num_controlnet: int, output_path: str, fp16: bool = False, sd_xl: bool = False):
"""
Function to convert models in stable diffusion controlnet pipeline into TensorRT format
Example:
python convert_stable_diffusion_c... | 122 | 4,378 |
diffusers | scripts/convert_zero123_to_diffusers.py | .py | """
This script modified from
https://github.com/huggingface/diffusers/blob/bc691231360a4cbc7d19a58742ebb8ed0f05e027/scripts/convert_original_stable_diffusion_to_diffusers.py
Convert original Zero1to3 checkpoint to diffusers checkpoint.
# run the convert script
$ python convert_zero123_to_diffusers.py \
--checkpoi... | 808 | 35,060 |
diffusers | scripts/convert_mochi_to_diffusers.py | .py | import argparse
from contextlib import nullcontext
import torch
from accelerate import init_empty_weights
from safetensors.torch import load_file
from transformers import T5EncoderModel, T5Tokenizer
from diffusers import AutoencoderKLMochi, FlowMatchEulerDiscreteScheduler, MochiPipeline, MochiTransformer3DModel
from ... | 464 | 23,008 |
diffusers | scripts/convert_ace_step_to_diffusers.py | .py | # Run this script to convert ACE-Step model weights to a diffusers pipeline.
#
# Usage:
# python scripts/convert_ace_step_to_diffusers.py \
# --checkpoint_dir /path/to/ACE-Step-1.5/checkpoints \
# --dit_config acestep-v15-turbo \
# --output_dir /path/to/output/ACE-Step-v1-5-turbo \
# --dtype b... | 455 | 21,522 |
diffusers | scripts/convert_blipdiffusion_to_diffusers.py | .py | """
This script requires you to build `LAVIS` from source, since the pip version doesn't have BLIP Diffusion. Follow instructions here: https://github.com/salesforce/LAVIS/tree/main.
"""
import argparse
import os
import tempfile
import torch
from lavis.models import load_model_and_preprocess
from transformers import ... | 345 | 13,460 |
diffusers | scripts/convert_kandinsky3_unet.py | .py | #!/usr/bin/env python3
import argparse
import fnmatch
from safetensors.torch import load_file
from diffusers import Kandinsky3UNet
MAPPING = {
"to_time_embed.1": "time_embedding.linear_1",
"to_time_embed.3": "time_embedding.linear_2",
"in_layer": "conv_in",
"out_layer.0": "conv_norm_out",
"out_l... | 99 | 3,273 |
diffusers | scripts/convert_skyreelsv2_to_diffusers.py | .py | import argparse
import os
import pathlib
from typing import Any, Dict
import torch
from accelerate import init_empty_weights
from huggingface_hub import hf_hub_download
from safetensors.torch import load_file
from transformers import AutoProcessor, AutoTokenizer, CLIPVisionModelWithProjection, UMT5EncoderModel
from d... | 638 | 26,206 |
diffusers | scripts/convert_tiny_autoencoder_to_diffusers.py | .py | import argparse
import safetensors.torch
from diffusers import AutoencoderTiny
"""
Example - From the diffusers root directory:
Download the weights:
```sh
$ wget -q https://huggingface.co/madebyollin/taesd/resolve/main/taesd_encoder.safetensors
$ wget -q https://huggingface.co/madebyollin/taesd/resolve/main/taesd... | 72 | 2,382 |
diffusers | scripts/convert_cogview3_to_diffusers.py | .py | """
Convert a CogView3 checkpoint to the Diffusers format.
This script converts a CogView3 checkpoint to the Diffusers format, which can then be used
with the Diffusers library.
Example usage:
python scripts/convert_cogview3_to_diffusers.py \
--transformer_checkpoint_path 'your path/cogview3plus_3b/1/mp_r... | 243 | 10,487 |
diffusers | scripts/convert_hunyuan_video1_5_to_diffusers.py | .py | import argparse
import json
import os
import pathlib
import torch
from accelerate import init_empty_weights
from huggingface_hub import hf_hub_download, snapshot_download
from safetensors.torch import load_file
from transformers import (
AutoModel,
AutoTokenizer,
SiglipImageProcessor,
SiglipVisionModel... | 876 | 39,028 |
diffusers | scripts/convert_asymmetric_vqgan_to_diffusers.py | .py | import argparse
import time
from pathlib import Path
from typing import Any, Dict, Literal
import torch
from diffusers import AsymmetricAutoencoderKL
ASYMMETRIC_AUTOENCODER_KL_x_1_5_CONFIG = {
"in_channels": 3,
"out_channels": 3,
"down_block_types": [
"DownEncoderBlock2D",
"DownEncoderBl... | 185 | 6,905 |
diffusers | scripts/extract_lora_from_model.py | .py | """
This script demonstrates how to extract a LoRA checkpoint from a fully finetuned model with the CogVideoX model.
To make it work for other models:
* Change the model class. Here we use `CogVideoXTransformer3DModel`. For Flux, it would be `FluxTransformer2DModel`,
for example. (TODO: more reason to add `AutoModel`... | 152 | 4,876 |
diffusers | scripts/convert_flux_xlabs_ipadapter_to_diffusers.py | .py | import argparse
from contextlib import nullcontext
import safetensors.torch
from accelerate import init_empty_weights
from huggingface_hub import hf_hub_download
from diffusers.utils.import_utils import is_accelerate_available, is_transformers_available
if is_transformers_available():
from transformers import C... | 98 | 3,679 |
diffusers | scripts/convert_music_spectrogram_to_diffusers.py | .py | #!/usr/bin/env python3
import argparse
import os
import jax as jnp
import numpy as onp
import torch
import torch.nn as nn
from music_spectrogram_diffusion import inference
from t5x import checkpoints
from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline
from diffusers.pipelines.spectrogr... | 204 | 10,249 |
diffusers | scripts/convert_consistency_decoder.py | .py | import math
import os
import urllib
import warnings
from argparse import ArgumentParser
import torch
import torch.nn as nn
import torch.nn.functional as F
from huggingface_hub.utils import insecure_hashlib
from safetensors.torch import load_file as stl
from tqdm import tqdm
from diffusers import AutoencoderKL, Consis... | 1,132 | 44,513 |
diffusers | scripts/convert_wan_to_diffusers.py | .py | import argparse
import pathlib
from typing import Any, Dict, Tuple
import torch
from accelerate import init_empty_weights
from huggingface_hub import hf_hub_download, snapshot_download
from safetensors.torch import load_file
from transformers import (
AutoProcessor,
AutoTokenizer,
CLIPImageProcessor,
C... | 1,288 | 53,482 |
diffusers | scripts/convert_hunyuan_image_to_diffusers.py | .py | import argparse
import logging
import torch
from safetensors import safe_open
from diffusers import AutoencoderKLHunyuanImage, AutoencoderKLHunyuanImageRefiner, HunyuanImageTransformer2DModel
logger = logging.getLogger(__name__) # pylint: disable=invalid-name
"""
Usage examples
==============
python scripts/con... | 1,045 | 53,928 |
diffusers | scripts/convert_dance_diffusion_to_diffusers.py | .py | #!/usr/bin/env python3
import argparse
import math
import os
from copy import deepcopy
import requests
import torch
from audio_diffusion.models import DiffusionAttnUnet1D
from diffusion import sampling
from torch import nn
from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNet1DModel
from diffusers.utils.... | 347 | 10,523 |
diffusers | scripts/convert_shap_e_to_diffusers.py | .py | import argparse
import tempfile
import torch
from accelerate import load_checkpoint_and_dispatch
from diffusers.models.transformers.prior_transformer import PriorTransformer
from diffusers.pipelines.shap_e import ShapERenderer
"""
Example - From the diffusers root directory:
Download weights:
```sh
$ wget "https:... | 1,081 | 40,870 |
diffusers | scripts/convert_animatediff_sparsectrl_to_diffusers.py | .py | import argparse
from typing import Dict
import torch
import torch.nn as nn
from diffusers import SparseControlNetModel
KEYS_RENAME_MAPPING = {
".attention_blocks.0": ".attn1",
".attention_blocks.1": ".attn2",
".attn1.pos_encoder": ".pos_embed",
".ff_norm": ".norm3",
".norms.0": ".norm1",
".n... | 84 | 2,889 |
diffusers | scripts/convert_amused.py | .py | import inspect
import os
from argparse import ArgumentParser
import numpy as np
import torch
from muse import MaskGiTUViT, VQGANModel
from muse import PipelineMuse as OldPipelineMuse
from transformers import CLIPTextModelWithProjection, CLIPTokenizer
from diffusers import VQModel
from diffusers.models.attention_proce... | 524 | 27,733 |
diffusers | scripts/convert_unidiffuser_to_diffusers.py | .py | # Convert the original UniDiffuser checkpoints into diffusers equivalents.
import argparse
from argparse import Namespace
import torch
from transformers import (
CLIPImageProcessor,
CLIPTextConfig,
CLIPTextModel,
CLIPTokenizer,
CLIPVisionConfig,
CLIPVisionModelWithProjection,
GPT2Tokenizer... | 787 | 31,449 |
diffusers | scripts/convert_sana_to_diffusers.py | .py | #!/usr/bin/env python
from __future__ import annotations
import argparse
import os
from contextlib import nullcontext
import torch
from accelerate import init_empty_weights
from huggingface_hub import hf_hub_download, snapshot_download
from termcolor import colored
from transformers import AutoModelForCausalLM, AutoT... | 457 | 19,580 |
diffusers | scripts/convert_original_musicldm_to_diffusers.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 1,057 | 45,655 |
diffusers | scripts/convert_original_audioldm_to_diffusers.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 1,043 | 45,410 |
diffusers | scripts/convert_dit_to_diffusers.py | .py | import argparse
import os
import torch
from torchvision.datasets.utils import download_url
from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, Transformer2DModel
pretrained_models = {512: "DiT-XL-2-512x512.pt", 256: "DiT-XL-2-256x256.pt"}
def download_model(model_name):
"""
Downloads a pre-tr... | 163 | 6,586 |
diffusers | scripts/convert_gligen_to_diffusers.py | .py | import argparse
import re
import torch
import yaml
from transformers import (
CLIPProcessor,
CLIPTextModel,
CLIPTokenizer,
CLIPVisionModelWithProjection,
)
from diffusers import (
AutoencoderKL,
DDIMScheduler,
StableDiffusionGLIGENPipeline,
StableDiffusionGLIGENTextImagePipeline,
U... | 582 | 25,230 |
diffusers | scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 186 | 8,733 |
diffusers | scripts/convert_cosmos_to_diffusers.py | .py | """
# Cosmos 2 Predict
Download checkpoint
```bash
hf download nvidia/Cosmos-Predict2-2B-Text2Image
```
convert checkpoint
```bash
transformer_ckpt_path=~/.cache/huggingface/hub/models--nvidia--Cosmos-Predict2-2B-Text2Image/snapshots/acdb5fde992a73ef0355f287977d002cbfd127e0/model.pt
python scripts/convert_cosmos_to_... | 977 | 35,716 |
diffusers | scripts/convert_ovis_image_to_diffusers.py | .py | import argparse
from contextlib import nullcontext
import safetensors.torch
import torch
from accelerate import init_empty_weights
from huggingface_hub import hf_hub_download
from diffusers import OvisImageTransformer2DModel
from diffusers.utils.import_utils import is_accelerate_available
"""
# Transformer
python ... | 264 | 12,720 |
diffusers | scripts/convert_sana_controlnet_to_diffusers.py | .py | #!/usr/bin/env python
from __future__ import annotations
import argparse
from contextlib import nullcontext
import torch
from accelerate import init_empty_weights
from diffusers import (
SanaControlNetModel,
)
from diffusers.models.model_loading_utils import load_model_dict_into_meta
from diffusers.utils.import_... | 217 | 9,292 |
diffusers | scripts/convert_anima_to_diffusers.py | .py | """
Convert Anima checkpoints to Diffusers format.
Example:
```bash
python scripts/convert_anima_to_diffusers.py \
--transformer_ckpt_path anima_model/anima-preview3-base.safetensors \
--text_encoder_ckpt_path anima_model/qwen_3_06b_base.safetensors \
--vae_ckpt_path anima_model/qwen_image_vae.safetensors ... | 317 | 12,888 |
diffusers | scripts/convert_stable_cascade.py | .py | # Run this script to convert the Stable Cascade model weights to a diffusers pipeline.
import argparse
from contextlib import nullcontext
import torch
from safetensors.torch import load_file
from transformers import (
AutoTokenizer,
CLIPConfig,
CLIPImageProcessor,
CLIPTextModelWithProjection,
CLIPV... | 219 | 8,388 |
diffusers | scripts/convert_cogview4_to_diffusers.py | .py | """
Convert a CogView4 checkpoint from SAT(https://github.com/THUDM/SwissArmyTransformer) to the Diffusers format.
(deprecated Since 2025-02-07 and will remove it in later CogView4 version)
This script converts a CogView4 checkpoint to the Diffusers format, which can then be used
with the Diffusers library.
Example u... | 255 | 10,960 |
diffusers | scripts/convert_minimax_music3_to_diffusers.py | .py | # Conversion script for MiniMax Music 3 (https://huggingface.co/MiniMaxAI/MiniMax-Music3).
#
# Original checkpoint layout:
# flowmatching_vae.pth flow-matching DiT + condition projection
# dav.pth Flow-VAE (DAC-style) decoder
# qwen_7B/qwen_7B/ Qwen3 back... | 270 | 13,128 |
diffusers | scripts/convert_ltx_to_diffusers.py | .py | import argparse
from pathlib import Path
from typing import Any, Dict
import torch
from accelerate import init_empty_weights
from safetensors.torch import load_file
from transformers import T5EncoderModel, T5Tokenizer
from diffusers import (
AutoencoderKLLTXVideo,
FlowMatchEulerDiscreteScheduler,
LTXCondi... | 526 | 19,042 |
diffusers | utils/notify_community_pipelines_mirror.py | .py | # coding=utf-8
# Copyright 2026 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requir... | 55 | 1,885 |
diffusers | utils/check_inits.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 299 | 12,417 |
diffusers | utils/remind_link_issue.py | .py | # Copyright 2026 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | 173 | 6,744 |
diffusers | utils/check_repo.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 750 | 30,349 |
diffusers | utils/consolidated_test_report.py | .py | #!/usr/bin/env python
import argparse
import glob
import os
import re
from datetime import date, datetime
from slack_sdk import WebClient
from tabulate import tabulate
MAX_LEN_MESSAGE = 3001 # slack endpoint has a limit of 3001 characters
parser = argparse.ArgumentParser()
parser.add_argument("--slack_channel_name... | 790 | 35,002 |
diffusers | utils/fetch_torch_cuda_pipeline_test_matrix.py | .py | import json
import logging
import os
from collections import defaultdict
from pathlib import Path
from huggingface_hub import HfApi
import diffusers
PATH_TO_REPO = Path(__file__).parent.parent.resolve()
ALWAYS_TEST_PIPELINE_MODULES = [
"controlnet",
"controlnet_flux",
"controlnet_sd3",
"stable_diffu... | 100 | 2,513 |
diffusers | utils/check_dummies.py | .py | # coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 176 | 6,327 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.