diffusers 0.29.2__py3-none-any.whl → 0.30.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. diffusers/__init__.py +94 -3
  2. diffusers/commands/env.py +1 -5
  3. diffusers/configuration_utils.py +4 -9
  4. diffusers/dependency_versions_table.py +2 -2
  5. diffusers/image_processor.py +1 -2
  6. diffusers/loaders/__init__.py +17 -2
  7. diffusers/loaders/ip_adapter.py +10 -7
  8. diffusers/loaders/lora_base.py +752 -0
  9. diffusers/loaders/lora_pipeline.py +2222 -0
  10. diffusers/loaders/peft.py +213 -5
  11. diffusers/loaders/single_file.py +1 -12
  12. diffusers/loaders/single_file_model.py +31 -10
  13. diffusers/loaders/single_file_utils.py +262 -2
  14. diffusers/loaders/textual_inversion.py +1 -6
  15. diffusers/loaders/unet.py +23 -208
  16. diffusers/models/__init__.py +20 -0
  17. diffusers/models/activations.py +22 -0
  18. diffusers/models/attention.py +386 -7
  19. diffusers/models/attention_processor.py +1795 -629
  20. diffusers/models/autoencoders/__init__.py +2 -0
  21. diffusers/models/autoencoders/autoencoder_kl.py +14 -3
  22. diffusers/models/autoencoders/autoencoder_kl_cogvideox.py +1035 -0
  23. diffusers/models/autoencoders/autoencoder_kl_temporal_decoder.py +1 -1
  24. diffusers/models/autoencoders/autoencoder_oobleck.py +464 -0
  25. diffusers/models/autoencoders/autoencoder_tiny.py +1 -0
  26. diffusers/models/autoencoders/consistency_decoder_vae.py +1 -1
  27. diffusers/models/autoencoders/vq_model.py +4 -4
  28. diffusers/models/controlnet.py +2 -3
  29. diffusers/models/controlnet_hunyuan.py +401 -0
  30. diffusers/models/controlnet_sd3.py +11 -11
  31. diffusers/models/controlnet_sparsectrl.py +789 -0
  32. diffusers/models/controlnet_xs.py +40 -10
  33. diffusers/models/downsampling.py +68 -0
  34. diffusers/models/embeddings.py +319 -36
  35. diffusers/models/model_loading_utils.py +1 -3
  36. diffusers/models/modeling_flax_utils.py +1 -6
  37. diffusers/models/modeling_utils.py +4 -16
  38. diffusers/models/normalization.py +203 -12
  39. diffusers/models/transformers/__init__.py +6 -0
  40. diffusers/models/transformers/auraflow_transformer_2d.py +527 -0
  41. diffusers/models/transformers/cogvideox_transformer_3d.py +345 -0
  42. diffusers/models/transformers/hunyuan_transformer_2d.py +19 -15
  43. diffusers/models/transformers/latte_transformer_3d.py +327 -0
  44. diffusers/models/transformers/lumina_nextdit2d.py +340 -0
  45. diffusers/models/transformers/pixart_transformer_2d.py +102 -1
  46. diffusers/models/transformers/prior_transformer.py +1 -1
  47. diffusers/models/transformers/stable_audio_transformer.py +458 -0
  48. diffusers/models/transformers/transformer_flux.py +455 -0
  49. diffusers/models/transformers/transformer_sd3.py +18 -4
  50. diffusers/models/unets/unet_1d_blocks.py +1 -1
  51. diffusers/models/unets/unet_2d_condition.py +8 -1
  52. diffusers/models/unets/unet_3d_blocks.py +51 -920
  53. diffusers/models/unets/unet_3d_condition.py +4 -1
  54. diffusers/models/unets/unet_i2vgen_xl.py +4 -1
  55. diffusers/models/unets/unet_kandinsky3.py +1 -1
  56. diffusers/models/unets/unet_motion_model.py +1330 -84
  57. diffusers/models/unets/unet_spatio_temporal_condition.py +1 -1
  58. diffusers/models/unets/unet_stable_cascade.py +1 -3
  59. diffusers/models/unets/uvit_2d.py +1 -1
  60. diffusers/models/upsampling.py +64 -0
  61. diffusers/models/vq_model.py +8 -4
  62. diffusers/optimization.py +1 -1
  63. diffusers/pipelines/__init__.py +100 -3
  64. diffusers/pipelines/animatediff/__init__.py +4 -0
  65. diffusers/pipelines/animatediff/pipeline_animatediff.py +50 -40
  66. diffusers/pipelines/animatediff/pipeline_animatediff_controlnet.py +1076 -0
  67. diffusers/pipelines/animatediff/pipeline_animatediff_sdxl.py +17 -27
  68. diffusers/pipelines/animatediff/pipeline_animatediff_sparsectrl.py +1008 -0
  69. diffusers/pipelines/animatediff/pipeline_animatediff_video2video.py +51 -38
  70. diffusers/pipelines/audioldm2/modeling_audioldm2.py +1 -1
  71. diffusers/pipelines/audioldm2/pipeline_audioldm2.py +1 -0
  72. diffusers/pipelines/aura_flow/__init__.py +48 -0
  73. diffusers/pipelines/aura_flow/pipeline_aura_flow.py +591 -0
  74. diffusers/pipelines/auto_pipeline.py +97 -19
  75. diffusers/pipelines/cogvideo/__init__.py +48 -0
  76. diffusers/pipelines/cogvideo/pipeline_cogvideox.py +687 -0
  77. diffusers/pipelines/consistency_models/pipeline_consistency_models.py +1 -1
  78. diffusers/pipelines/controlnet/pipeline_controlnet.py +24 -30
  79. diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +31 -30
  80. diffusers/pipelines/controlnet/pipeline_controlnet_inpaint.py +24 -153
  81. diffusers/pipelines/controlnet/pipeline_controlnet_inpaint_sd_xl.py +19 -28
  82. diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +18 -28
  83. diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py +29 -32
  84. diffusers/pipelines/controlnet/pipeline_flax_controlnet.py +2 -2
  85. diffusers/pipelines/controlnet_hunyuandit/__init__.py +48 -0
  86. diffusers/pipelines/controlnet_hunyuandit/pipeline_hunyuandit_controlnet.py +1042 -0
  87. diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet.py +35 -0
  88. diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs.py +10 -6
  89. diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs_sd_xl.py +0 -4
  90. diffusers/pipelines/deepfloyd_if/pipeline_if.py +2 -2
  91. diffusers/pipelines/deepfloyd_if/pipeline_if_img2img.py +2 -2
  92. diffusers/pipelines/deepfloyd_if/pipeline_if_img2img_superresolution.py +2 -2
  93. diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting.py +2 -2
  94. diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting_superresolution.py +2 -2
  95. diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py +2 -2
  96. diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion.py +11 -6
  97. diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion_img2img.py +11 -6
  98. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_cycle_diffusion.py +6 -6
  99. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_inpaint_legacy.py +6 -6
  100. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_model_editing.py +10 -10
  101. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_paradigms.py +10 -6
  102. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_pix2pix_zero.py +3 -3
  103. diffusers/pipelines/deprecated/versatile_diffusion/modeling_text_unet.py +1 -1
  104. diffusers/pipelines/flux/__init__.py +47 -0
  105. diffusers/pipelines/flux/pipeline_flux.py +749 -0
  106. diffusers/pipelines/flux/pipeline_output.py +21 -0
  107. diffusers/pipelines/free_init_utils.py +2 -0
  108. diffusers/pipelines/free_noise_utils.py +236 -0
  109. diffusers/pipelines/kandinsky3/pipeline_kandinsky3.py +2 -2
  110. diffusers/pipelines/kandinsky3/pipeline_kandinsky3_img2img.py +2 -2
  111. diffusers/pipelines/kolors/__init__.py +54 -0
  112. diffusers/pipelines/kolors/pipeline_kolors.py +1070 -0
  113. diffusers/pipelines/kolors/pipeline_kolors_img2img.py +1247 -0
  114. diffusers/pipelines/kolors/pipeline_output.py +21 -0
  115. diffusers/pipelines/kolors/text_encoder.py +889 -0
  116. diffusers/pipelines/kolors/tokenizer.py +334 -0
  117. diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_img2img.py +30 -29
  118. diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_text2img.py +23 -29
  119. diffusers/pipelines/latte/__init__.py +48 -0
  120. diffusers/pipelines/latte/pipeline_latte.py +881 -0
  121. diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py +4 -4
  122. diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion_xl.py +0 -4
  123. diffusers/pipelines/lumina/__init__.py +48 -0
  124. diffusers/pipelines/lumina/pipeline_lumina.py +897 -0
  125. diffusers/pipelines/pag/__init__.py +67 -0
  126. diffusers/pipelines/pag/pag_utils.py +237 -0
  127. diffusers/pipelines/pag/pipeline_pag_controlnet_sd.py +1329 -0
  128. diffusers/pipelines/pag/pipeline_pag_controlnet_sd_xl.py +1612 -0
  129. diffusers/pipelines/pag/pipeline_pag_hunyuandit.py +953 -0
  130. diffusers/pipelines/pag/pipeline_pag_kolors.py +1136 -0
  131. diffusers/pipelines/pag/pipeline_pag_pixart_sigma.py +872 -0
  132. diffusers/pipelines/pag/pipeline_pag_sd.py +1050 -0
  133. diffusers/pipelines/pag/pipeline_pag_sd_3.py +985 -0
  134. diffusers/pipelines/pag/pipeline_pag_sd_animatediff.py +862 -0
  135. diffusers/pipelines/pag/pipeline_pag_sd_xl.py +1333 -0
  136. diffusers/pipelines/pag/pipeline_pag_sd_xl_img2img.py +1529 -0
  137. diffusers/pipelines/pag/pipeline_pag_sd_xl_inpaint.py +1753 -0
  138. diffusers/pipelines/pia/pipeline_pia.py +30 -37
  139. diffusers/pipelines/pipeline_flax_utils.py +4 -9
  140. diffusers/pipelines/pipeline_loading_utils.py +0 -3
  141. diffusers/pipelines/pipeline_utils.py +2 -14
  142. diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py +0 -1
  143. diffusers/pipelines/stable_audio/__init__.py +50 -0
  144. diffusers/pipelines/stable_audio/modeling_stable_audio.py +158 -0
  145. diffusers/pipelines/stable_audio/pipeline_stable_audio.py +745 -0
  146. diffusers/pipelines/stable_diffusion/convert_from_ckpt.py +2 -0
  147. diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion.py +1 -1
  148. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +23 -29
  149. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py +15 -8
  150. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +30 -29
  151. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +23 -152
  152. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py +8 -4
  153. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py +11 -11
  154. diffusers/pipelines/stable_diffusion/pipeline_stable_unclip.py +8 -6
  155. diffusers/pipelines/stable_diffusion/pipeline_stable_unclip_img2img.py +6 -6
  156. diffusers/pipelines/stable_diffusion_3/__init__.py +2 -0
  157. diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3.py +34 -3
  158. diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_img2img.py +33 -7
  159. diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_inpaint.py +1201 -0
  160. diffusers/pipelines/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py +3 -3
  161. diffusers/pipelines/stable_diffusion_diffedit/pipeline_stable_diffusion_diffedit.py +6 -6
  162. diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen.py +5 -5
  163. diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen_text_image.py +5 -5
  164. diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_k_diffusion.py +6 -6
  165. diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_xl_k_diffusion.py +0 -4
  166. diffusers/pipelines/stable_diffusion_ldm3d/pipeline_stable_diffusion_ldm3d.py +23 -29
  167. diffusers/pipelines/stable_diffusion_panorama/pipeline_stable_diffusion_panorama.py +27 -29
  168. diffusers/pipelines/stable_diffusion_sag/pipeline_stable_diffusion_sag.py +3 -3
  169. diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +17 -27
  170. diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +26 -29
  171. diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py +17 -145
  172. diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_instruct_pix2pix.py +0 -4
  173. diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_adapter.py +6 -6
  174. diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_xl_adapter.py +18 -28
  175. diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth.py +8 -6
  176. diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth_img2img.py +8 -6
  177. diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero.py +6 -4
  178. diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero_sdxl.py +0 -4
  179. diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py +3 -3
  180. diffusers/pipelines/wuerstchen/modeling_wuerstchen_prior.py +1 -1
  181. diffusers/pipelines/wuerstchen/pipeline_wuerstchen_prior.py +5 -4
  182. diffusers/schedulers/__init__.py +8 -0
  183. diffusers/schedulers/scheduling_cosine_dpmsolver_multistep.py +572 -0
  184. diffusers/schedulers/scheduling_ddim.py +1 -1
  185. diffusers/schedulers/scheduling_ddim_cogvideox.py +449 -0
  186. diffusers/schedulers/scheduling_ddpm.py +1 -1
  187. diffusers/schedulers/scheduling_ddpm_parallel.py +1 -1
  188. diffusers/schedulers/scheduling_deis_multistep.py +2 -2
  189. diffusers/schedulers/scheduling_dpm_cogvideox.py +489 -0
  190. diffusers/schedulers/scheduling_dpmsolver_multistep.py +1 -1
  191. diffusers/schedulers/scheduling_dpmsolver_multistep_inverse.py +1 -1
  192. diffusers/schedulers/scheduling_dpmsolver_singlestep.py +64 -19
  193. diffusers/schedulers/scheduling_edm_dpmsolver_multistep.py +2 -2
  194. diffusers/schedulers/scheduling_flow_match_euler_discrete.py +63 -39
  195. diffusers/schedulers/scheduling_flow_match_heun_discrete.py +321 -0
  196. diffusers/schedulers/scheduling_ipndm.py +1 -1
  197. diffusers/schedulers/scheduling_unipc_multistep.py +1 -1
  198. diffusers/schedulers/scheduling_utils.py +1 -3
  199. diffusers/schedulers/scheduling_utils_flax.py +1 -3
  200. diffusers/training_utils.py +99 -14
  201. diffusers/utils/__init__.py +2 -2
  202. diffusers/utils/dummy_pt_objects.py +210 -0
  203. diffusers/utils/dummy_torch_and_torchsde_objects.py +15 -0
  204. diffusers/utils/dummy_torch_and_transformers_and_sentencepiece_objects.py +47 -0
  205. diffusers/utils/dummy_torch_and_transformers_objects.py +315 -0
  206. diffusers/utils/dynamic_modules_utils.py +1 -11
  207. diffusers/utils/export_utils.py +1 -4
  208. diffusers/utils/hub_utils.py +45 -42
  209. diffusers/utils/import_utils.py +19 -16
  210. diffusers/utils/loading_utils.py +76 -3
  211. diffusers/utils/testing_utils.py +11 -8
  212. {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/METADATA +73 -83
  213. {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/RECORD +217 -164
  214. {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/WHEEL +1 -1
  215. diffusers/loaders/autoencoder.py +0 -146
  216. diffusers/loaders/controlnet.py +0 -136
  217. diffusers/loaders/lora.py +0 -1728
  218. {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/LICENSE +0 -0
  219. {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/entry_points.txt +0 -0
  220. {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.1.1)
2
+ Generator: setuptools (72.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,146 +0,0 @@
1
- # Copyright 2024 The HuggingFace Team. All rights reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- from huggingface_hub.utils import validate_hf_hub_args
16
-
17
- from .single_file_utils import (
18
- create_diffusers_vae_model_from_ldm,
19
- fetch_ldm_config_and_checkpoint,
20
- )
21
-
22
-
23
- class FromOriginalVAEMixin:
24
- """
25
- Load pretrained AutoencoderKL weights saved in the `.ckpt` or `.safetensors` format into a [`AutoencoderKL`].
26
- """
27
-
28
- @classmethod
29
- @validate_hf_hub_args
30
- def from_single_file(cls, pretrained_model_link_or_path, **kwargs):
31
- r"""
32
- Instantiate a [`AutoencoderKL`] from pretrained ControlNet weights saved in the original `.ckpt` or
33
- `.safetensors` format. The pipeline is set in evaluation mode (`model.eval()`) by default.
34
-
35
- Parameters:
36
- pretrained_model_link_or_path (`str` or `os.PathLike`, *optional*):
37
- Can be either:
38
- - A link to the `.ckpt` file (for example
39
- `"https://huggingface.co/<repo_id>/blob/main/<path_to_file>.ckpt"`) on the Hub.
40
- - A path to a *file* containing all pipeline weights.
41
- config_file (`str`, *optional*):
42
- Filepath to the configuration YAML file associated with the model. If not provided it will default to:
43
- https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml
44
- torch_dtype (`str` or `torch.dtype`, *optional*):
45
- Override the default `torch.dtype` and load the model with another dtype. If `"auto"` is passed, the
46
- dtype is automatically derived from the model's weights.
47
- force_download (`bool`, *optional*, defaults to `False`):
48
- Whether or not to force the (re-)download of the model weights and configuration files, overriding the
49
- cached versions if they exist.
50
- cache_dir (`Union[str, os.PathLike]`, *optional*):
51
- Path to a directory where a downloaded pretrained model configuration is cached if the standard cache
52
- is not used.
53
- resume_download:
54
- Deprecated and ignored. All downloads are now resumed by default when possible. Will be removed in v1
55
- of Diffusers.
56
- proxies (`Dict[str, str]`, *optional*):
57
- A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128',
58
- 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request.
59
- local_files_only (`bool`, *optional*, defaults to `False`):
60
- Whether to only load local model weights and configuration files or not. If set to True, the model
61
- won't be downloaded from the Hub.
62
- token (`str` or *bool*, *optional*):
63
- The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from
64
- `diffusers-cli login` (stored in `~/.huggingface`) is used.
65
- revision (`str`, *optional*, defaults to `"main"`):
66
- The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier
67
- allowed by Git.
68
- image_size (`int`, *optional*, defaults to 512):
69
- The image size the model was trained on. Use 512 for all Stable Diffusion v1 models and the Stable
70
- Diffusion v2 base model. Use 768 for Stable Diffusion v2.
71
- scaling_factor (`float`, *optional*, defaults to 0.18215):
72
- The component-wise standard deviation of the trained latent space computed using the first batch of the
73
- training set. This is used to scale the latent space to have unit variance when training the diffusion
74
- model. The latents are scaled with the formula `z = z * scaling_factor` before being passed to the
75
- diffusion model. When decoding, the latents are scaled back to the original scale with the formula: `z
76
- = 1 / scaling_factor * z`. For more details, refer to sections 4.3.2 and D.1 of the [High-Resolution
77
- Image Synthesis with Latent Diffusion Models](https://arxiv.org/abs/2112.10752) paper.
78
- kwargs (remaining dictionary of keyword arguments, *optional*):
79
- Can be used to overwrite load and saveable variables (for example the pipeline components of the
80
- specific pipeline class). The overwritten components are directly passed to the pipelines `__init__`
81
- method. See example below for more information.
82
-
83
- <Tip warning={true}>
84
-
85
- Make sure to pass both `image_size` and `scaling_factor` to `from_single_file()` if you're loading
86
- a VAE from SDXL or a Stable Diffusion v2 model or higher.
87
-
88
- </Tip>
89
-
90
- Examples:
91
-
92
- ```py
93
- from diffusers import AutoencoderKL
94
-
95
- url = "https://huggingface.co/stabilityai/sd-vae-ft-mse-original/blob/main/vae-ft-mse-840000-ema-pruned.safetensors" # can also be local file
96
- model = AutoencoderKL.from_single_file(url)
97
- ```
98
- """
99
-
100
- original_config_file = kwargs.pop("original_config_file", None)
101
- config_file = kwargs.pop("config_file", None)
102
- resume_download = kwargs.pop("resume_download", None)
103
- force_download = kwargs.pop("force_download", False)
104
- proxies = kwargs.pop("proxies", None)
105
- token = kwargs.pop("token", None)
106
- cache_dir = kwargs.pop("cache_dir", None)
107
- local_files_only = kwargs.pop("local_files_only", None)
108
- revision = kwargs.pop("revision", None)
109
- torch_dtype = kwargs.pop("torch_dtype", None)
110
-
111
- class_name = cls.__name__
112
-
113
- if (config_file is not None) and (original_config_file is not None):
114
- raise ValueError(
115
- "You cannot pass both `config_file` and `original_config_file` to `from_single_file`. Please use only one of these arguments."
116
- )
117
-
118
- original_config_file = original_config_file or config_file
119
- original_config, checkpoint = fetch_ldm_config_and_checkpoint(
120
- pretrained_model_link_or_path=pretrained_model_link_or_path,
121
- class_name=class_name,
122
- original_config_file=original_config_file,
123
- resume_download=resume_download,
124
- force_download=force_download,
125
- proxies=proxies,
126
- token=token,
127
- revision=revision,
128
- local_files_only=local_files_only,
129
- cache_dir=cache_dir,
130
- )
131
-
132
- image_size = kwargs.pop("image_size", None)
133
- scaling_factor = kwargs.pop("scaling_factor", None)
134
- component = create_diffusers_vae_model_from_ldm(
135
- class_name,
136
- original_config,
137
- checkpoint,
138
- image_size=image_size,
139
- scaling_factor=scaling_factor,
140
- torch_dtype=torch_dtype,
141
- )
142
- vae = component["vae"]
143
- if torch_dtype is not None:
144
- vae = vae.to(torch_dtype)
145
-
146
- return vae
@@ -1,136 +0,0 @@
1
- # Copyright 2024 The HuggingFace Team. All rights reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- from huggingface_hub.utils import validate_hf_hub_args
16
-
17
- from .single_file_utils import (
18
- create_diffusers_controlnet_model_from_ldm,
19
- fetch_ldm_config_and_checkpoint,
20
- )
21
-
22
-
23
- class FromOriginalControlNetMixin:
24
- """
25
- Load pretrained ControlNet weights saved in the `.ckpt` or `.safetensors` format into a [`ControlNetModel`].
26
- """
27
-
28
- @classmethod
29
- @validate_hf_hub_args
30
- def from_single_file(cls, pretrained_model_link_or_path, **kwargs):
31
- r"""
32
- Instantiate a [`ControlNetModel`] from pretrained ControlNet weights saved in the original `.ckpt` or
33
- `.safetensors` format. The pipeline is set in evaluation mode (`model.eval()`) by default.
34
-
35
- Parameters:
36
- pretrained_model_link_or_path (`str` or `os.PathLike`, *optional*):
37
- Can be either:
38
- - A link to the `.ckpt` file (for example
39
- `"https://huggingface.co/<repo_id>/blob/main/<path_to_file>.ckpt"`) on the Hub.
40
- - A path to a *file* containing all pipeline weights.
41
- config_file (`str`, *optional*):
42
- Filepath to the configuration YAML file associated with the model. If not provided it will default to:
43
- https://raw.githubusercontent.com/lllyasviel/ControlNet/main/models/cldm_v15.yaml
44
- torch_dtype (`str` or `torch.dtype`, *optional*):
45
- Override the default `torch.dtype` and load the model with another dtype. If `"auto"` is passed, the
46
- dtype is automatically derived from the model's weights.
47
- force_download (`bool`, *optional*, defaults to `False`):
48
- Whether or not to force the (re-)download of the model weights and configuration files, overriding the
49
- cached versions if they exist.
50
- cache_dir (`Union[str, os.PathLike]`, *optional*):
51
- Path to a directory where a downloaded pretrained model configuration is cached if the standard cache
52
- is not used.
53
- resume_download:
54
- Deprecated and ignored. All downloads are now resumed by default when possible. Will be removed in v1
55
- of Diffusers.
56
- proxies (`Dict[str, str]`, *optional*):
57
- A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128',
58
- 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request.
59
- local_files_only (`bool`, *optional*, defaults to `False`):
60
- Whether to only load local model weights and configuration files or not. If set to True, the model
61
- won't be downloaded from the Hub.
62
- token (`str` or *bool*, *optional*):
63
- The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from
64
- `diffusers-cli login` (stored in `~/.huggingface`) is used.
65
- revision (`str`, *optional*, defaults to `"main"`):
66
- The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier
67
- allowed by Git.
68
- image_size (`int`, *optional*, defaults to 512):
69
- The image size the model was trained on. Use 512 for all Stable Diffusion v1 models and the Stable
70
- Diffusion v2 base model. Use 768 for Stable Diffusion v2.
71
- upcast_attention (`bool`, *optional*, defaults to `None`):
72
- Whether the attention computation should always be upcasted.
73
- kwargs (remaining dictionary of keyword arguments, *optional*):
74
- Can be used to overwrite load and saveable variables (for example the pipeline components of the
75
- specific pipeline class). The overwritten components are directly passed to the pipelines `__init__`
76
- method. See example below for more information.
77
-
78
- Examples:
79
-
80
- ```py
81
- from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
82
-
83
- url = "https://huggingface.co/lllyasviel/ControlNet-v1-1/blob/main/control_v11p_sd15_canny.pth" # can also be a local path
84
- model = ControlNetModel.from_single_file(url)
85
-
86
- url = "https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned.safetensors" # can also be a local path
87
- pipe = StableDiffusionControlNetPipeline.from_single_file(url, controlnet=controlnet)
88
- ```
89
- """
90
- original_config_file = kwargs.pop("original_config_file", None)
91
- config_file = kwargs.pop("config_file", None)
92
- resume_download = kwargs.pop("resume_download", None)
93
- force_download = kwargs.pop("force_download", False)
94
- proxies = kwargs.pop("proxies", None)
95
- token = kwargs.pop("token", None)
96
- cache_dir = kwargs.pop("cache_dir", None)
97
- local_files_only = kwargs.pop("local_files_only", None)
98
- revision = kwargs.pop("revision", None)
99
- torch_dtype = kwargs.pop("torch_dtype", None)
100
-
101
- class_name = cls.__name__
102
- if (config_file is not None) and (original_config_file is not None):
103
- raise ValueError(
104
- "You cannot pass both `config_file` and `original_config_file` to `from_single_file`. Please use only one of these arguments."
105
- )
106
-
107
- original_config_file = config_file or original_config_file
108
- original_config, checkpoint = fetch_ldm_config_and_checkpoint(
109
- pretrained_model_link_or_path=pretrained_model_link_or_path,
110
- class_name=class_name,
111
- original_config_file=original_config_file,
112
- resume_download=resume_download,
113
- force_download=force_download,
114
- proxies=proxies,
115
- token=token,
116
- revision=revision,
117
- local_files_only=local_files_only,
118
- cache_dir=cache_dir,
119
- )
120
-
121
- upcast_attention = kwargs.pop("upcast_attention", False)
122
- image_size = kwargs.pop("image_size", None)
123
-
124
- component = create_diffusers_controlnet_model_from_ldm(
125
- class_name,
126
- original_config,
127
- checkpoint,
128
- upcast_attention=upcast_attention,
129
- image_size=image_size,
130
- torch_dtype=torch_dtype,
131
- )
132
- controlnet = component["controlnet"]
133
- if torch_dtype is not None:
134
- controlnet = controlnet.to(torch_dtype)
135
-
136
- return controlnet