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
@@ -294,6 +294,13 @@ try:
294
294
  except importlib_metadata.PackageNotFoundError:
295
295
  _torchvision_available = False
296
296
 
297
+ _sentencepiece_available = importlib.util.find_spec("sentencepiece") is not None
298
+ try:
299
+ _sentencepiece_version = importlib_metadata.version("sentencepiece")
300
+ logger.info(f"Successfully imported sentencepiece version {_sentencepiece_version}")
301
+ except importlib_metadata.PackageNotFoundError:
302
+ _sentencepiece_available = False
303
+
297
304
  _matplotlib_available = importlib.util.find_spec("matplotlib") is not None
298
305
  try:
299
306
  _matplotlib_version = importlib_metadata.version("matplotlib")
@@ -321,18 +328,7 @@ try:
321
328
  except importlib_metadata.PackageNotFoundError:
322
329
  _bitsandbytes_available = False
323
330
 
324
- # Taken from `huggingface_hub`.
325
- _is_notebook = False
326
- try:
327
- shell_class = get_ipython().__class__ # type: ignore # noqa: F821
328
- for parent_class in shell_class.__mro__: # e.g. "is subclass of"
329
- if parent_class.__name__ == "ZMQInteractiveShell":
330
- _is_notebook = True # Jupyter notebook, Google colab or qtconsole
331
- break
332
- except NameError:
333
- pass # Probably standard Python interpreter
334
-
335
- _is_google_colab = "google.colab" in sys.modules
331
+ _is_google_colab = "google.colab" in sys.modules or any(k.startswith("COLAB_") for k in os.environ)
336
332
 
337
333
 
338
334
  def is_torch_available():
@@ -443,14 +439,14 @@ def is_bitsandbytes_available():
443
439
  return _bitsandbytes_available
444
440
 
445
441
 
446
- def is_notebook():
447
- return _is_notebook
448
-
449
-
450
442
  def is_google_colab():
451
443
  return _is_google_colab
452
444
 
453
445
 
446
+ def is_sentencepiece_available():
447
+ return _sentencepiece_available
448
+
449
+
454
450
  # docstyle-ignore
455
451
  FLAX_IMPORT_ERROR = """
456
452
  {0} requires the FLAX library but it was not found in your environment. Checkout the instructions on the
@@ -568,6 +564,12 @@ SAFETENSORS_IMPORT_ERROR = """
568
564
  {0} requires the safetensors library but it was not found in your environment. You can install it with pip: `pip install safetensors`
569
565
  """
570
566
 
567
+ # docstyle-ignore
568
+ SENTENCEPIECE_IMPORT_ERROR = """
569
+ {0} requires the sentencepiece library but it was not found in your environment. You can install it with pip: `pip install sentencepiece`
570
+ """
571
+
572
+
571
573
  # docstyle-ignore
572
574
  BITSANDBYTES_IMPORT_ERROR = """
573
575
  {0} requires the bitsandbytes library but it was not found in your environment. You can install it with pip: `pip install bitsandbytes`
@@ -596,6 +598,7 @@ BACKENDS_MAPPING = OrderedDict(
596
598
  ("peft", (is_peft_available, PEFT_IMPORT_ERROR)),
597
599
  ("safetensors", (is_safetensors_available, SAFETENSORS_IMPORT_ERROR)),
598
600
  ("bitsandbytes", (is_bitsandbytes_available, BITSANDBYTES_IMPORT_ERROR)),
601
+ ("sentencepiece", (is_sentencepiece_available, SENTENCEPIECE_IMPORT_ERROR)),
599
602
  ]
600
603
  )
601
604
 
@@ -1,13 +1,16 @@
1
1
  import os
2
- from typing import Callable, Union
2
+ import tempfile
3
+ from typing import Callable, List, Optional, Union
3
4
 
4
5
  import PIL.Image
5
6
  import PIL.ImageOps
6
7
  import requests
7
8
 
9
+ from .import_utils import BACKENDS_MAPPING, is_opencv_available
10
+
8
11
 
9
12
  def load_image(
10
- image: Union[str, PIL.Image.Image], convert_method: Callable[[PIL.Image.Image], PIL.Image.Image] = None
13
+ image: Union[str, PIL.Image.Image], convert_method: Optional[Callable[[PIL.Image.Image], PIL.Image.Image]] = None
11
14
  ) -> PIL.Image.Image:
12
15
  """
13
16
  Loads `image` to a PIL Image.
@@ -15,7 +18,7 @@ def load_image(
15
18
  Args:
16
19
  image (`str` or `PIL.Image.Image`):
17
20
  The image to convert to the PIL Image format.
18
- convert_method (Callable[[PIL.Image.Image], PIL.Image.Image], optional):
21
+ convert_method (Callable[[PIL.Image.Image], PIL.Image.Image], *optional*):
19
22
  A conversion method to apply to the image after loading it. When set to `None` the image will be converted
20
23
  "RGB".
21
24
 
@@ -47,3 +50,73 @@ def load_image(
47
50
  image = image.convert("RGB")
48
51
 
49
52
  return image
53
+
54
+
55
+ def load_video(
56
+ video: str,
57
+ convert_method: Optional[Callable[[List[PIL.Image.Image]], List[PIL.Image.Image]]] = None,
58
+ ) -> List[PIL.Image.Image]:
59
+ """
60
+ Loads `video` to a list of PIL Image.
61
+
62
+ Args:
63
+ video (`str`):
64
+ A URL or Path to a video to convert to a list of PIL Image format.
65
+ convert_method (Callable[[List[PIL.Image.Image]], List[PIL.Image.Image]], *optional*):
66
+ A conversion method to apply to the video after loading it. When set to `None` the images will be converted
67
+ to "RGB".
68
+
69
+ Returns:
70
+ `List[PIL.Image.Image]`:
71
+ The video as a list of PIL images.
72
+ """
73
+ is_url = video.startswith("http://") or video.startswith("https://")
74
+ is_file = os.path.isfile(video)
75
+ was_tempfile_created = False
76
+
77
+ if not (is_url or is_file):
78
+ raise ValueError(
79
+ f"Incorrect path or URL. URLs must start with `http://` or `https://`, and {video} is not a valid path."
80
+ )
81
+
82
+ if is_url:
83
+ video_data = requests.get(video, stream=True).raw
84
+ video_path = tempfile.NamedTemporaryFile(suffix=os.path.splitext(video)[1], delete=False).name
85
+ was_tempfile_created = True
86
+ with open(video_path, "wb") as f:
87
+ f.write(video_data.read())
88
+
89
+ video = video_path
90
+
91
+ pil_images = []
92
+ if video.endswith(".gif"):
93
+ gif = PIL.Image.open(video)
94
+ try:
95
+ while True:
96
+ pil_images.append(gif.copy())
97
+ gif.seek(gif.tell() + 1)
98
+ except EOFError:
99
+ pass
100
+
101
+ else:
102
+ if is_opencv_available():
103
+ import cv2
104
+ else:
105
+ raise ImportError(BACKENDS_MAPPING["opencv"][1].format("load_video"))
106
+
107
+ video_capture = cv2.VideoCapture(video)
108
+ success, frame = video_capture.read()
109
+ while success:
110
+ frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
111
+ pil_images.append(PIL.Image.fromarray(frame))
112
+ success, frame = video_capture.read()
113
+
114
+ video_capture.release()
115
+
116
+ if was_tempfile_created:
117
+ os.remove(video_path)
118
+
119
+ if convert_method is not None:
120
+ pil_images = convert_method(pil_images)
121
+
122
+ return pil_images
@@ -187,6 +187,7 @@ def parse_flag_from_env(key, default=False):
187
187
 
188
188
  _run_slow_tests = parse_flag_from_env("RUN_SLOW", default=False)
189
189
  _run_nightly_tests = parse_flag_from_env("RUN_NIGHTLY", default=False)
190
+ _run_compile_tests = parse_flag_from_env("RUN_COMPILE", default=False)
190
191
 
191
192
 
192
193
  def floats_tensor(shape, scale=1.0, rng=None, name=None):
@@ -225,6 +226,16 @@ def nightly(test_case):
225
226
  return unittest.skipUnless(_run_nightly_tests, "test is nightly")(test_case)
226
227
 
227
228
 
229
+ def is_torch_compile(test_case):
230
+ """
231
+ Decorator marking a test that runs compile tests in the diffusers CI.
232
+
233
+ Compile tests are skipped by default. Set the RUN_COMPILE environment variable to a truthy value to run them.
234
+
235
+ """
236
+ return unittest.skipUnless(_run_compile_tests, "test is torch compile")(test_case)
237
+
238
+
228
239
  def require_torch(test_case):
229
240
  """
230
241
  Decorator marking a test that requires PyTorch. These tests are skipped when PyTorch isn't installed.
@@ -390,14 +401,6 @@ def get_python_version():
390
401
  return major, minor
391
402
 
392
403
 
393
- def require_python39_or_higher(test_case):
394
- def python39_available():
395
- major, minor = get_python_version()
396
- return major == 3 and minor >= 9
397
-
398
- return unittest.skipUnless(python39_available(), "test requires Python 3.9 or higher")(test_case)
399
-
400
-
401
404
  def load_numpy(arry: Union[str, np.ndarray], local_path: Optional[str] = None) -> np.ndarray:
402
405
  if isinstance(arry, str):
403
406
  if local_path is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: diffusers
3
- Version: 0.29.2
3
+ Version: 0.30.0
4
4
  Summary: State-of-the-art diffusion in PyTorch and JAX.
5
5
  Home-page: https://github.com/huggingface/diffusers
6
6
  Author: The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/diffusers/graphs/contributors)
@@ -23,81 +23,81 @@ Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
24
  Requires-Dist: importlib-metadata
25
25
  Requires-Dist: filelock
26
- Requires-Dist: huggingface-hub >=0.23.2
26
+ Requires-Dist: huggingface-hub>=0.23.2
27
27
  Requires-Dist: numpy
28
- Requires-Dist: regex !=2019.12.17
28
+ Requires-Dist: regex!=2019.12.17
29
29
  Requires-Dist: requests
30
- Requires-Dist: safetensors >=0.3.1
30
+ Requires-Dist: safetensors>=0.3.1
31
31
  Requires-Dist: Pillow
32
32
  Provides-Extra: dev
33
- Requires-Dist: urllib3 <=2.0.0 ; extra == 'dev'
34
- Requires-Dist: isort >=5.5.4 ; extra == 'dev'
35
- Requires-Dist: ruff ==0.1.5 ; extra == 'dev'
36
- Requires-Dist: hf-doc-builder >=0.3.0 ; extra == 'dev'
37
- Requires-Dist: compel ==0.1.8 ; extra == 'dev'
38
- Requires-Dist: GitPython <3.1.19 ; extra == 'dev'
39
- Requires-Dist: datasets ; extra == 'dev'
40
- Requires-Dist: Jinja2 ; extra == 'dev'
41
- Requires-Dist: invisible-watermark >=0.2.0 ; extra == 'dev'
42
- Requires-Dist: k-diffusion >=0.0.12 ; extra == 'dev'
43
- Requires-Dist: librosa ; extra == 'dev'
44
- Requires-Dist: parameterized ; extra == 'dev'
45
- Requires-Dist: pytest ; extra == 'dev'
46
- Requires-Dist: pytest-timeout ; extra == 'dev'
47
- Requires-Dist: pytest-xdist ; extra == 'dev'
48
- Requires-Dist: requests-mock ==1.10.0 ; extra == 'dev'
49
- Requires-Dist: safetensors >=0.3.1 ; extra == 'dev'
50
- Requires-Dist: sentencepiece !=0.1.92,>=0.1.91 ; extra == 'dev'
51
- Requires-Dist: scipy ; extra == 'dev'
52
- Requires-Dist: torchvision ; extra == 'dev'
53
- Requires-Dist: transformers >=4.25.1 ; extra == 'dev'
54
- Requires-Dist: accelerate >=0.29.3 ; extra == 'dev'
55
- Requires-Dist: protobuf <4,>=3.20.3 ; extra == 'dev'
56
- Requires-Dist: tensorboard ; extra == 'dev'
57
- Requires-Dist: peft >=0.6.0 ; extra == 'dev'
58
- Requires-Dist: torch >=1.4 ; extra == 'dev'
59
- Requires-Dist: jax >=0.4.1 ; extra == 'dev'
60
- Requires-Dist: jaxlib >=0.4.1 ; extra == 'dev'
61
- Requires-Dist: flax >=0.4.1 ; extra == 'dev'
33
+ Requires-Dist: urllib3<=2.0.0; extra == "dev"
34
+ Requires-Dist: isort>=5.5.4; extra == "dev"
35
+ Requires-Dist: ruff==0.1.5; extra == "dev"
36
+ Requires-Dist: hf-doc-builder>=0.3.0; extra == "dev"
37
+ Requires-Dist: compel==0.1.8; extra == "dev"
38
+ Requires-Dist: GitPython<3.1.19; extra == "dev"
39
+ Requires-Dist: datasets; extra == "dev"
40
+ Requires-Dist: Jinja2; extra == "dev"
41
+ Requires-Dist: invisible-watermark>=0.2.0; extra == "dev"
42
+ Requires-Dist: k-diffusion>=0.0.12; extra == "dev"
43
+ Requires-Dist: librosa; extra == "dev"
44
+ Requires-Dist: parameterized; extra == "dev"
45
+ Requires-Dist: pytest; extra == "dev"
46
+ Requires-Dist: pytest-timeout; extra == "dev"
47
+ Requires-Dist: pytest-xdist; extra == "dev"
48
+ Requires-Dist: requests-mock==1.10.0; extra == "dev"
49
+ Requires-Dist: safetensors>=0.3.1; extra == "dev"
50
+ Requires-Dist: sentencepiece!=0.1.92,>=0.1.91; extra == "dev"
51
+ Requires-Dist: scipy; extra == "dev"
52
+ Requires-Dist: torchvision; extra == "dev"
53
+ Requires-Dist: transformers>=4.41.2; extra == "dev"
54
+ Requires-Dist: accelerate>=0.31.0; extra == "dev"
55
+ Requires-Dist: protobuf<4,>=3.20.3; extra == "dev"
56
+ Requires-Dist: tensorboard; extra == "dev"
57
+ Requires-Dist: peft>=0.6.0; extra == "dev"
58
+ Requires-Dist: torch>=1.4; extra == "dev"
59
+ Requires-Dist: jax>=0.4.1; extra == "dev"
60
+ Requires-Dist: jaxlib>=0.4.1; extra == "dev"
61
+ Requires-Dist: flax>=0.4.1; extra == "dev"
62
62
  Provides-Extra: docs
63
- Requires-Dist: hf-doc-builder >=0.3.0 ; extra == 'docs'
63
+ Requires-Dist: hf-doc-builder>=0.3.0; extra == "docs"
64
64
  Provides-Extra: flax
65
- Requires-Dist: jax >=0.4.1 ; extra == 'flax'
66
- Requires-Dist: jaxlib >=0.4.1 ; extra == 'flax'
67
- Requires-Dist: flax >=0.4.1 ; extra == 'flax'
65
+ Requires-Dist: jax>=0.4.1; extra == "flax"
66
+ Requires-Dist: jaxlib>=0.4.1; extra == "flax"
67
+ Requires-Dist: flax>=0.4.1; extra == "flax"
68
68
  Provides-Extra: quality
69
- Requires-Dist: urllib3 <=2.0.0 ; extra == 'quality'
70
- Requires-Dist: isort >=5.5.4 ; extra == 'quality'
71
- Requires-Dist: ruff ==0.1.5 ; extra == 'quality'
72
- Requires-Dist: hf-doc-builder >=0.3.0 ; extra == 'quality'
69
+ Requires-Dist: urllib3<=2.0.0; extra == "quality"
70
+ Requires-Dist: isort>=5.5.4; extra == "quality"
71
+ Requires-Dist: ruff==0.1.5; extra == "quality"
72
+ Requires-Dist: hf-doc-builder>=0.3.0; extra == "quality"
73
73
  Provides-Extra: test
74
- Requires-Dist: compel ==0.1.8 ; extra == 'test'
75
- Requires-Dist: GitPython <3.1.19 ; extra == 'test'
76
- Requires-Dist: datasets ; extra == 'test'
77
- Requires-Dist: Jinja2 ; extra == 'test'
78
- Requires-Dist: invisible-watermark >=0.2.0 ; extra == 'test'
79
- Requires-Dist: k-diffusion >=0.0.12 ; extra == 'test'
80
- Requires-Dist: librosa ; extra == 'test'
81
- Requires-Dist: parameterized ; extra == 'test'
82
- Requires-Dist: pytest ; extra == 'test'
83
- Requires-Dist: pytest-timeout ; extra == 'test'
84
- Requires-Dist: pytest-xdist ; extra == 'test'
85
- Requires-Dist: requests-mock ==1.10.0 ; extra == 'test'
86
- Requires-Dist: safetensors >=0.3.1 ; extra == 'test'
87
- Requires-Dist: sentencepiece !=0.1.92,>=0.1.91 ; extra == 'test'
88
- Requires-Dist: scipy ; extra == 'test'
89
- Requires-Dist: torchvision ; extra == 'test'
90
- Requires-Dist: transformers >=4.25.1 ; extra == 'test'
74
+ Requires-Dist: compel==0.1.8; extra == "test"
75
+ Requires-Dist: GitPython<3.1.19; extra == "test"
76
+ Requires-Dist: datasets; extra == "test"
77
+ Requires-Dist: Jinja2; extra == "test"
78
+ Requires-Dist: invisible-watermark>=0.2.0; extra == "test"
79
+ Requires-Dist: k-diffusion>=0.0.12; extra == "test"
80
+ Requires-Dist: librosa; extra == "test"
81
+ Requires-Dist: parameterized; extra == "test"
82
+ Requires-Dist: pytest; extra == "test"
83
+ Requires-Dist: pytest-timeout; extra == "test"
84
+ Requires-Dist: pytest-xdist; extra == "test"
85
+ Requires-Dist: requests-mock==1.10.0; extra == "test"
86
+ Requires-Dist: safetensors>=0.3.1; extra == "test"
87
+ Requires-Dist: sentencepiece!=0.1.92,>=0.1.91; extra == "test"
88
+ Requires-Dist: scipy; extra == "test"
89
+ Requires-Dist: torchvision; extra == "test"
90
+ Requires-Dist: transformers>=4.41.2; extra == "test"
91
91
  Provides-Extra: torch
92
- Requires-Dist: torch >=1.4 ; extra == 'torch'
93
- Requires-Dist: accelerate >=0.29.3 ; extra == 'torch'
92
+ Requires-Dist: torch>=1.4; extra == "torch"
93
+ Requires-Dist: accelerate>=0.31.0; extra == "torch"
94
94
  Provides-Extra: training
95
- Requires-Dist: accelerate >=0.29.3 ; extra == 'training'
96
- Requires-Dist: datasets ; extra == 'training'
97
- Requires-Dist: protobuf <4,>=3.20.3 ; extra == 'training'
98
- Requires-Dist: tensorboard ; extra == 'training'
99
- Requires-Dist: Jinja2 ; extra == 'training'
100
- Requires-Dist: peft >=0.6.0 ; extra == 'training'
95
+ Requires-Dist: accelerate>=0.31.0; extra == "training"
96
+ Requires-Dist: datasets; extra == "training"
97
+ Requires-Dist: protobuf<4,>=3.20.3; extra == "training"
98
+ Requires-Dist: tensorboard; extra == "training"
99
+ Requires-Dist: Jinja2; extra == "training"
100
+ Requires-Dist: peft>=0.6.0; extra == "training"
101
101
 
102
102
  <!---
103
103
  Copyright 2022 - The HuggingFace Team. All rights reserved.
@@ -121,21 +121,11 @@ limitations under the License.
121
121
  <br>
122
122
  <p>
123
123
  <p align="center">
124
- <a href="https://github.com/huggingface/diffusers/blob/main/LICENSE">
125
- <img alt="GitHub" src="https://img.shields.io/github/license/huggingface/datasets.svg?color=blue">
126
- </a>
127
- <a href="https://github.com/huggingface/diffusers/releases">
128
- <img alt="GitHub release" src="https://img.shields.io/github/release/huggingface/diffusers.svg">
129
- </a>
130
- <a href="https://pepy.tech/project/diffusers">
131
- <img alt="GitHub release" src="https://static.pepy.tech/badge/diffusers/month">
132
- </a>
133
- <a href="CODE_OF_CONDUCT.md">
134
- <img alt="Contributor Covenant" src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg">
135
- </a>
136
- <a href="https://twitter.com/diffuserslib">
137
- <img alt="X account" src="https://img.shields.io/twitter/url/https/twitter.com/diffuserslib.svg?style=social&label=Follow%20%40diffuserslib">
138
- </a>
124
+ <a href="https://github.com/huggingface/diffusers/blob/main/LICENSE"><img alt="GitHub" src="https://img.shields.io/github/license/huggingface/datasets.svg?color=blue"></a>
125
+ <a href="https://github.com/huggingface/diffusers/releases"><img alt="GitHub release" src="https://img.shields.io/github/release/huggingface/diffusers.svg"></a>
126
+ <a href="https://pepy.tech/project/diffusers"><img alt="GitHub release" src="https://static.pepy.tech/badge/diffusers/month"></a>
127
+ <a href="CODE_OF_CONDUCT.md"><img alt="Contributor Covenant" src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg"></a>
128
+ <a href="https://twitter.com/diffuserslib"><img alt="X account" src="https://img.shields.io/twitter/url/https/twitter.com/diffuserslib.svg?style=social&label=Follow%20%40diffuserslib"></a>
139
129
  </p>
140
130
 
141
131
  🤗 Diffusers is the go-to library for state-of-the-art pretrained diffusion models for generating images, audio, and even 3D structures of molecules. Whether you're looking for a simple inference solution or training your own diffusion models, 🤗 Diffusers is a modular toolbox that supports both. Our library is designed with a focus on [usability over performance](https://huggingface.co/docs/diffusers/conceptual/philosophy#usability-over-performance), [simple over easy](https://huggingface.co/docs/diffusers/conceptual/philosophy#simple-over-easy), and [customizability over abstractions](https://huggingface.co/docs/diffusers/conceptual/philosophy#tweakable-contributorfriendly-over-abstraction).
@@ -178,7 +168,7 @@ Please refer to the [How to use Stable Diffusion in Apple Silicon](https://huggi
178
168
 
179
169
  ## Quickstart
180
170
 
181
- Generating outputs is super easy with 🤗 Diffusers. To generate an image from text, use the `from_pretrained` method to load any pretrained diffusion model (browse the [Hub](https://huggingface.co/models?library=diffusers&sort=downloads) for 25.000+ checkpoints):
171
+ Generating outputs is super easy with 🤗 Diffusers. To generate an image from text, use the `from_pretrained` method to load any pretrained diffusion model (browse the [Hub](https://huggingface.co/models?library=diffusers&sort=downloads) for 30,000+ checkpoints):
182
172
 
183
173
  ```python
184
174
  from diffusers import DiffusionPipeline
@@ -320,7 +310,7 @@ Also, say 👋 in our public Discord channel <a href="https://discord.gg/G7tWnz9
320
310
  - https://github.com/deep-floyd/IF
321
311
  - https://github.com/bentoml/BentoML
322
312
  - https://github.com/bmaltais/kohya_ss
323
- - +11.000 other amazing GitHub repositories 💪
313
+ - +14,000 other amazing GitHub repositories 💪
324
314
 
325
315
  Thank you for using us ❤️.
326
316