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.
- diffusers/__init__.py +94 -3
- diffusers/commands/env.py +1 -5
- diffusers/configuration_utils.py +4 -9
- diffusers/dependency_versions_table.py +2 -2
- diffusers/image_processor.py +1 -2
- diffusers/loaders/__init__.py +17 -2
- diffusers/loaders/ip_adapter.py +10 -7
- diffusers/loaders/lora_base.py +752 -0
- diffusers/loaders/lora_pipeline.py +2222 -0
- diffusers/loaders/peft.py +213 -5
- diffusers/loaders/single_file.py +1 -12
- diffusers/loaders/single_file_model.py +31 -10
- diffusers/loaders/single_file_utils.py +262 -2
- diffusers/loaders/textual_inversion.py +1 -6
- diffusers/loaders/unet.py +23 -208
- diffusers/models/__init__.py +20 -0
- diffusers/models/activations.py +22 -0
- diffusers/models/attention.py +386 -7
- diffusers/models/attention_processor.py +1795 -629
- diffusers/models/autoencoders/__init__.py +2 -0
- diffusers/models/autoencoders/autoencoder_kl.py +14 -3
- diffusers/models/autoencoders/autoencoder_kl_cogvideox.py +1035 -0
- diffusers/models/autoencoders/autoencoder_kl_temporal_decoder.py +1 -1
- diffusers/models/autoencoders/autoencoder_oobleck.py +464 -0
- diffusers/models/autoencoders/autoencoder_tiny.py +1 -0
- diffusers/models/autoencoders/consistency_decoder_vae.py +1 -1
- diffusers/models/autoencoders/vq_model.py +4 -4
- diffusers/models/controlnet.py +2 -3
- diffusers/models/controlnet_hunyuan.py +401 -0
- diffusers/models/controlnet_sd3.py +11 -11
- diffusers/models/controlnet_sparsectrl.py +789 -0
- diffusers/models/controlnet_xs.py +40 -10
- diffusers/models/downsampling.py +68 -0
- diffusers/models/embeddings.py +319 -36
- diffusers/models/model_loading_utils.py +1 -3
- diffusers/models/modeling_flax_utils.py +1 -6
- diffusers/models/modeling_utils.py +4 -16
- diffusers/models/normalization.py +203 -12
- diffusers/models/transformers/__init__.py +6 -0
- diffusers/models/transformers/auraflow_transformer_2d.py +527 -0
- diffusers/models/transformers/cogvideox_transformer_3d.py +345 -0
- diffusers/models/transformers/hunyuan_transformer_2d.py +19 -15
- diffusers/models/transformers/latte_transformer_3d.py +327 -0
- diffusers/models/transformers/lumina_nextdit2d.py +340 -0
- diffusers/models/transformers/pixart_transformer_2d.py +102 -1
- diffusers/models/transformers/prior_transformer.py +1 -1
- diffusers/models/transformers/stable_audio_transformer.py +458 -0
- diffusers/models/transformers/transformer_flux.py +455 -0
- diffusers/models/transformers/transformer_sd3.py +18 -4
- diffusers/models/unets/unet_1d_blocks.py +1 -1
- diffusers/models/unets/unet_2d_condition.py +8 -1
- diffusers/models/unets/unet_3d_blocks.py +51 -920
- diffusers/models/unets/unet_3d_condition.py +4 -1
- diffusers/models/unets/unet_i2vgen_xl.py +4 -1
- diffusers/models/unets/unet_kandinsky3.py +1 -1
- diffusers/models/unets/unet_motion_model.py +1330 -84
- diffusers/models/unets/unet_spatio_temporal_condition.py +1 -1
- diffusers/models/unets/unet_stable_cascade.py +1 -3
- diffusers/models/unets/uvit_2d.py +1 -1
- diffusers/models/upsampling.py +64 -0
- diffusers/models/vq_model.py +8 -4
- diffusers/optimization.py +1 -1
- diffusers/pipelines/__init__.py +100 -3
- diffusers/pipelines/animatediff/__init__.py +4 -0
- diffusers/pipelines/animatediff/pipeline_animatediff.py +50 -40
- diffusers/pipelines/animatediff/pipeline_animatediff_controlnet.py +1076 -0
- diffusers/pipelines/animatediff/pipeline_animatediff_sdxl.py +17 -27
- diffusers/pipelines/animatediff/pipeline_animatediff_sparsectrl.py +1008 -0
- diffusers/pipelines/animatediff/pipeline_animatediff_video2video.py +51 -38
- diffusers/pipelines/audioldm2/modeling_audioldm2.py +1 -1
- diffusers/pipelines/audioldm2/pipeline_audioldm2.py +1 -0
- diffusers/pipelines/aura_flow/__init__.py +48 -0
- diffusers/pipelines/aura_flow/pipeline_aura_flow.py +591 -0
- diffusers/pipelines/auto_pipeline.py +97 -19
- diffusers/pipelines/cogvideo/__init__.py +48 -0
- diffusers/pipelines/cogvideo/pipeline_cogvideox.py +687 -0
- diffusers/pipelines/consistency_models/pipeline_consistency_models.py +1 -1
- diffusers/pipelines/controlnet/pipeline_controlnet.py +24 -30
- diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +31 -30
- diffusers/pipelines/controlnet/pipeline_controlnet_inpaint.py +24 -153
- diffusers/pipelines/controlnet/pipeline_controlnet_inpaint_sd_xl.py +19 -28
- diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +18 -28
- diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py +29 -32
- diffusers/pipelines/controlnet/pipeline_flax_controlnet.py +2 -2
- diffusers/pipelines/controlnet_hunyuandit/__init__.py +48 -0
- diffusers/pipelines/controlnet_hunyuandit/pipeline_hunyuandit_controlnet.py +1042 -0
- diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet.py +35 -0
- diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs.py +10 -6
- diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs_sd_xl.py +0 -4
- diffusers/pipelines/deepfloyd_if/pipeline_if.py +2 -2
- diffusers/pipelines/deepfloyd_if/pipeline_if_img2img.py +2 -2
- diffusers/pipelines/deepfloyd_if/pipeline_if_img2img_superresolution.py +2 -2
- diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting.py +2 -2
- diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting_superresolution.py +2 -2
- diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py +2 -2
- diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion.py +11 -6
- diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion_img2img.py +11 -6
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_cycle_diffusion.py +6 -6
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_inpaint_legacy.py +6 -6
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_model_editing.py +10 -10
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_paradigms.py +10 -6
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_pix2pix_zero.py +3 -3
- diffusers/pipelines/deprecated/versatile_diffusion/modeling_text_unet.py +1 -1
- diffusers/pipelines/flux/__init__.py +47 -0
- diffusers/pipelines/flux/pipeline_flux.py +749 -0
- diffusers/pipelines/flux/pipeline_output.py +21 -0
- diffusers/pipelines/free_init_utils.py +2 -0
- diffusers/pipelines/free_noise_utils.py +236 -0
- diffusers/pipelines/kandinsky3/pipeline_kandinsky3.py +2 -2
- diffusers/pipelines/kandinsky3/pipeline_kandinsky3_img2img.py +2 -2
- diffusers/pipelines/kolors/__init__.py +54 -0
- diffusers/pipelines/kolors/pipeline_kolors.py +1070 -0
- diffusers/pipelines/kolors/pipeline_kolors_img2img.py +1247 -0
- diffusers/pipelines/kolors/pipeline_output.py +21 -0
- diffusers/pipelines/kolors/text_encoder.py +889 -0
- diffusers/pipelines/kolors/tokenizer.py +334 -0
- diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_img2img.py +30 -29
- diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_text2img.py +23 -29
- diffusers/pipelines/latte/__init__.py +48 -0
- diffusers/pipelines/latte/pipeline_latte.py +881 -0
- diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py +4 -4
- diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion_xl.py +0 -4
- diffusers/pipelines/lumina/__init__.py +48 -0
- diffusers/pipelines/lumina/pipeline_lumina.py +897 -0
- diffusers/pipelines/pag/__init__.py +67 -0
- diffusers/pipelines/pag/pag_utils.py +237 -0
- diffusers/pipelines/pag/pipeline_pag_controlnet_sd.py +1329 -0
- diffusers/pipelines/pag/pipeline_pag_controlnet_sd_xl.py +1612 -0
- diffusers/pipelines/pag/pipeline_pag_hunyuandit.py +953 -0
- diffusers/pipelines/pag/pipeline_pag_kolors.py +1136 -0
- diffusers/pipelines/pag/pipeline_pag_pixart_sigma.py +872 -0
- diffusers/pipelines/pag/pipeline_pag_sd.py +1050 -0
- diffusers/pipelines/pag/pipeline_pag_sd_3.py +985 -0
- diffusers/pipelines/pag/pipeline_pag_sd_animatediff.py +862 -0
- diffusers/pipelines/pag/pipeline_pag_sd_xl.py +1333 -0
- diffusers/pipelines/pag/pipeline_pag_sd_xl_img2img.py +1529 -0
- diffusers/pipelines/pag/pipeline_pag_sd_xl_inpaint.py +1753 -0
- diffusers/pipelines/pia/pipeline_pia.py +30 -37
- diffusers/pipelines/pipeline_flax_utils.py +4 -9
- diffusers/pipelines/pipeline_loading_utils.py +0 -3
- diffusers/pipelines/pipeline_utils.py +2 -14
- diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py +0 -1
- diffusers/pipelines/stable_audio/__init__.py +50 -0
- diffusers/pipelines/stable_audio/modeling_stable_audio.py +158 -0
- diffusers/pipelines/stable_audio/pipeline_stable_audio.py +745 -0
- diffusers/pipelines/stable_diffusion/convert_from_ckpt.py +2 -0
- diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +23 -29
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py +15 -8
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +30 -29
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +23 -152
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py +8 -4
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py +11 -11
- diffusers/pipelines/stable_diffusion/pipeline_stable_unclip.py +8 -6
- diffusers/pipelines/stable_diffusion/pipeline_stable_unclip_img2img.py +6 -6
- diffusers/pipelines/stable_diffusion_3/__init__.py +2 -0
- diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3.py +34 -3
- diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_img2img.py +33 -7
- diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_inpaint.py +1201 -0
- diffusers/pipelines/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py +3 -3
- diffusers/pipelines/stable_diffusion_diffedit/pipeline_stable_diffusion_diffedit.py +6 -6
- diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen.py +5 -5
- diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen_text_image.py +5 -5
- diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_k_diffusion.py +6 -6
- diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_xl_k_diffusion.py +0 -4
- diffusers/pipelines/stable_diffusion_ldm3d/pipeline_stable_diffusion_ldm3d.py +23 -29
- diffusers/pipelines/stable_diffusion_panorama/pipeline_stable_diffusion_panorama.py +27 -29
- diffusers/pipelines/stable_diffusion_sag/pipeline_stable_diffusion_sag.py +3 -3
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +17 -27
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +26 -29
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py +17 -145
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_instruct_pix2pix.py +0 -4
- diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_adapter.py +6 -6
- diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_xl_adapter.py +18 -28
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth.py +8 -6
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth_img2img.py +8 -6
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero.py +6 -4
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero_sdxl.py +0 -4
- diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py +3 -3
- diffusers/pipelines/wuerstchen/modeling_wuerstchen_prior.py +1 -1
- diffusers/pipelines/wuerstchen/pipeline_wuerstchen_prior.py +5 -4
- diffusers/schedulers/__init__.py +8 -0
- diffusers/schedulers/scheduling_cosine_dpmsolver_multistep.py +572 -0
- diffusers/schedulers/scheduling_ddim.py +1 -1
- diffusers/schedulers/scheduling_ddim_cogvideox.py +449 -0
- diffusers/schedulers/scheduling_ddpm.py +1 -1
- diffusers/schedulers/scheduling_ddpm_parallel.py +1 -1
- diffusers/schedulers/scheduling_deis_multistep.py +2 -2
- diffusers/schedulers/scheduling_dpm_cogvideox.py +489 -0
- diffusers/schedulers/scheduling_dpmsolver_multistep.py +1 -1
- diffusers/schedulers/scheduling_dpmsolver_multistep_inverse.py +1 -1
- diffusers/schedulers/scheduling_dpmsolver_singlestep.py +64 -19
- diffusers/schedulers/scheduling_edm_dpmsolver_multistep.py +2 -2
- diffusers/schedulers/scheduling_flow_match_euler_discrete.py +63 -39
- diffusers/schedulers/scheduling_flow_match_heun_discrete.py +321 -0
- diffusers/schedulers/scheduling_ipndm.py +1 -1
- diffusers/schedulers/scheduling_unipc_multistep.py +1 -1
- diffusers/schedulers/scheduling_utils.py +1 -3
- diffusers/schedulers/scheduling_utils_flax.py +1 -3
- diffusers/training_utils.py +99 -14
- diffusers/utils/__init__.py +2 -2
- diffusers/utils/dummy_pt_objects.py +210 -0
- diffusers/utils/dummy_torch_and_torchsde_objects.py +15 -0
- diffusers/utils/dummy_torch_and_transformers_and_sentencepiece_objects.py +47 -0
- diffusers/utils/dummy_torch_and_transformers_objects.py +315 -0
- diffusers/utils/dynamic_modules_utils.py +1 -11
- diffusers/utils/export_utils.py +1 -4
- diffusers/utils/hub_utils.py +45 -42
- diffusers/utils/import_utils.py +19 -16
- diffusers/utils/loading_utils.py +76 -3
- diffusers/utils/testing_utils.py +11 -8
- {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/METADATA +73 -83
- {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/RECORD +217 -164
- {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/WHEEL +1 -1
- diffusers/loaders/autoencoder.py +0 -146
- diffusers/loaders/controlnet.py +0 -136
- diffusers/loaders/lora.py +0 -1728
- {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/LICENSE +0 -0
- {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/entry_points.txt +0 -0
- {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/top_level.txt +0 -0
diffusers/utils/import_utils.py
CHANGED
@@ -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
|
-
|
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
|
|
diffusers/utils/loading_utils.py
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
import os
|
2
|
-
|
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
|
diffusers/utils/testing_utils.py
CHANGED
@@ -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.
|
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
|
26
|
+
Requires-Dist: huggingface-hub>=0.23.2
|
27
27
|
Requires-Dist: numpy
|
28
|
-
Requires-Dist: regex
|
28
|
+
Requires-Dist: regex!=2019.12.17
|
29
29
|
Requires-Dist: requests
|
30
|
-
Requires-Dist: safetensors
|
30
|
+
Requires-Dist: safetensors>=0.3.1
|
31
31
|
Requires-Dist: Pillow
|
32
32
|
Provides-Extra: dev
|
33
|
-
Requires-Dist: urllib3
|
34
|
-
Requires-Dist: isort
|
35
|
-
Requires-Dist: ruff
|
36
|
-
Requires-Dist: hf-doc-builder
|
37
|
-
Requires-Dist: compel
|
38
|
-
Requires-Dist: GitPython
|
39
|
-
Requires-Dist: datasets
|
40
|
-
Requires-Dist: Jinja2
|
41
|
-
Requires-Dist: invisible-watermark
|
42
|
-
Requires-Dist: k-diffusion
|
43
|
-
Requires-Dist: librosa
|
44
|
-
Requires-Dist: parameterized
|
45
|
-
Requires-Dist: pytest
|
46
|
-
Requires-Dist: pytest-timeout
|
47
|
-
Requires-Dist: pytest-xdist
|
48
|
-
Requires-Dist: requests-mock
|
49
|
-
Requires-Dist: safetensors
|
50
|
-
Requires-Dist: sentencepiece
|
51
|
-
Requires-Dist: scipy
|
52
|
-
Requires-Dist: torchvision
|
53
|
-
Requires-Dist: transformers
|
54
|
-
Requires-Dist: accelerate
|
55
|
-
Requires-Dist: protobuf
|
56
|
-
Requires-Dist: tensorboard
|
57
|
-
Requires-Dist: peft
|
58
|
-
Requires-Dist: torch
|
59
|
-
Requires-Dist: jax
|
60
|
-
Requires-Dist: jaxlib
|
61
|
-
Requires-Dist: flax
|
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
|
63
|
+
Requires-Dist: hf-doc-builder>=0.3.0; extra == "docs"
|
64
64
|
Provides-Extra: flax
|
65
|
-
Requires-Dist: jax
|
66
|
-
Requires-Dist: jaxlib
|
67
|
-
Requires-Dist: 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
|
70
|
-
Requires-Dist: isort
|
71
|
-
Requires-Dist: ruff
|
72
|
-
Requires-Dist: hf-doc-builder
|
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
|
75
|
-
Requires-Dist: GitPython
|
76
|
-
Requires-Dist: datasets
|
77
|
-
Requires-Dist: Jinja2
|
78
|
-
Requires-Dist: invisible-watermark
|
79
|
-
Requires-Dist: k-diffusion
|
80
|
-
Requires-Dist: librosa
|
81
|
-
Requires-Dist: parameterized
|
82
|
-
Requires-Dist: pytest
|
83
|
-
Requires-Dist: pytest-timeout
|
84
|
-
Requires-Dist: pytest-xdist
|
85
|
-
Requires-Dist: requests-mock
|
86
|
-
Requires-Dist: safetensors
|
87
|
-
Requires-Dist: sentencepiece
|
88
|
-
Requires-Dist: scipy
|
89
|
-
Requires-Dist: torchvision
|
90
|
-
Requires-Dist: transformers
|
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
|
93
|
-
Requires-Dist: accelerate
|
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
|
96
|
-
Requires-Dist: datasets
|
97
|
-
Requires-Dist: protobuf
|
98
|
-
Requires-Dist: tensorboard
|
99
|
-
Requires-Dist: Jinja2
|
100
|
-
Requires-Dist: peft
|
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
|
-
|
126
|
-
|
127
|
-
<a href="https://
|
128
|
-
|
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
|
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
|
-
- +
|
313
|
+
- +14,000 other amazing GitHub repositories 💪
|
324
314
|
|
325
315
|
Thank you for using us ❤️.
|
326
316
|
|