diffusers 0.26.3__py3-none-any.whl → 0.27.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- diffusers/__init__.py +20 -1
- diffusers/commands/__init__.py +1 -1
- diffusers/commands/diffusers_cli.py +1 -1
- diffusers/commands/env.py +1 -1
- diffusers/commands/fp16_safetensors.py +1 -1
- diffusers/configuration_utils.py +7 -3
- diffusers/dependency_versions_check.py +1 -1
- diffusers/dependency_versions_table.py +2 -2
- diffusers/experimental/rl/value_guided_sampling.py +1 -1
- diffusers/image_processor.py +110 -4
- diffusers/loaders/autoencoder.py +7 -8
- diffusers/loaders/controlnet.py +17 -8
- diffusers/loaders/ip_adapter.py +86 -23
- diffusers/loaders/lora.py +105 -310
- diffusers/loaders/lora_conversion_utils.py +1 -1
- diffusers/loaders/peft.py +1 -1
- diffusers/loaders/single_file.py +51 -12
- diffusers/loaders/single_file_utils.py +274 -49
- diffusers/loaders/textual_inversion.py +23 -4
- diffusers/loaders/unet.py +195 -41
- diffusers/loaders/utils.py +1 -1
- diffusers/models/__init__.py +3 -1
- diffusers/models/activations.py +9 -9
- diffusers/models/attention.py +26 -36
- diffusers/models/attention_flax.py +1 -1
- diffusers/models/attention_processor.py +171 -114
- diffusers/models/autoencoders/autoencoder_asym_kl.py +1 -1
- diffusers/models/autoencoders/autoencoder_kl.py +3 -1
- diffusers/models/autoencoders/autoencoder_kl_temporal_decoder.py +1 -1
- diffusers/models/autoencoders/autoencoder_tiny.py +4 -2
- diffusers/models/autoencoders/consistency_decoder_vae.py +1 -1
- diffusers/models/autoencoders/vae.py +1 -1
- diffusers/models/controlnet.py +1 -1
- diffusers/models/controlnet_flax.py +1 -1
- diffusers/models/downsampling.py +8 -12
- diffusers/models/dual_transformer_2d.py +1 -1
- diffusers/models/embeddings.py +3 -4
- diffusers/models/embeddings_flax.py +1 -1
- diffusers/models/lora.py +33 -10
- diffusers/models/modeling_flax_pytorch_utils.py +1 -1
- diffusers/models/modeling_flax_utils.py +1 -1
- diffusers/models/modeling_pytorch_flax_utils.py +1 -1
- diffusers/models/modeling_utils.py +4 -6
- diffusers/models/normalization.py +1 -1
- diffusers/models/resnet.py +31 -58
- diffusers/models/resnet_flax.py +1 -1
- diffusers/models/t5_film_transformer.py +1 -1
- diffusers/models/transformer_2d.py +1 -1
- diffusers/models/transformer_temporal.py +1 -1
- diffusers/models/transformers/dual_transformer_2d.py +1 -1
- diffusers/models/transformers/t5_film_transformer.py +1 -1
- diffusers/models/transformers/transformer_2d.py +29 -31
- diffusers/models/transformers/transformer_temporal.py +1 -1
- diffusers/models/unet_1d.py +1 -1
- diffusers/models/unet_1d_blocks.py +1 -1
- diffusers/models/unet_2d.py +1 -1
- diffusers/models/unet_2d_blocks.py +1 -1
- diffusers/models/unet_2d_condition.py +1 -1
- diffusers/models/unets/__init__.py +1 -0
- diffusers/models/unets/unet_1d.py +1 -1
- diffusers/models/unets/unet_1d_blocks.py +1 -1
- diffusers/models/unets/unet_2d.py +4 -4
- diffusers/models/unets/unet_2d_blocks.py +238 -98
- diffusers/models/unets/unet_2d_blocks_flax.py +1 -1
- diffusers/models/unets/unet_2d_condition.py +420 -323
- diffusers/models/unets/unet_2d_condition_flax.py +21 -12
- diffusers/models/unets/unet_3d_blocks.py +50 -40
- diffusers/models/unets/unet_3d_condition.py +47 -8
- diffusers/models/unets/unet_i2vgen_xl.py +75 -30
- diffusers/models/unets/unet_kandinsky3.py +1 -1
- diffusers/models/unets/unet_motion_model.py +48 -8
- diffusers/models/unets/unet_spatio_temporal_condition.py +1 -1
- diffusers/models/unets/unet_stable_cascade.py +610 -0
- diffusers/models/unets/uvit_2d.py +1 -1
- diffusers/models/upsampling.py +10 -16
- diffusers/models/vae_flax.py +1 -1
- diffusers/models/vq_model.py +1 -1
- diffusers/optimization.py +1 -1
- diffusers/pipelines/__init__.py +26 -0
- diffusers/pipelines/amused/pipeline_amused.py +1 -1
- diffusers/pipelines/amused/pipeline_amused_img2img.py +1 -1
- diffusers/pipelines/amused/pipeline_amused_inpaint.py +1 -1
- diffusers/pipelines/animatediff/pipeline_animatediff.py +162 -417
- diffusers/pipelines/animatediff/pipeline_animatediff_video2video.py +165 -137
- diffusers/pipelines/animatediff/pipeline_output.py +7 -6
- diffusers/pipelines/audioldm/pipeline_audioldm.py +3 -19
- diffusers/pipelines/audioldm2/modeling_audioldm2.py +1 -1
- diffusers/pipelines/audioldm2/pipeline_audioldm2.py +3 -3
- diffusers/pipelines/auto_pipeline.py +7 -16
- diffusers/pipelines/blip_diffusion/blip_image_processing.py +1 -1
- diffusers/pipelines/blip_diffusion/modeling_blip2.py +1 -1
- diffusers/pipelines/blip_diffusion/modeling_ctx_clip.py +2 -2
- diffusers/pipelines/blip_diffusion/pipeline_blip_diffusion.py +2 -2
- diffusers/pipelines/consistency_models/pipeline_consistency_models.py +1 -1
- diffusers/pipelines/controlnet/pipeline_controlnet.py +90 -90
- diffusers/pipelines/controlnet/pipeline_controlnet_blip_diffusion.py +2 -2
- diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +98 -90
- diffusers/pipelines/controlnet/pipeline_controlnet_inpaint.py +92 -90
- diffusers/pipelines/controlnet/pipeline_controlnet_inpaint_sd_xl.py +145 -70
- diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +126 -89
- diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py +108 -96
- diffusers/pipelines/controlnet/pipeline_flax_controlnet.py +2 -2
- diffusers/pipelines/dance_diffusion/pipeline_dance_diffusion.py +1 -1
- diffusers/pipelines/ddim/pipeline_ddim.py +1 -1
- diffusers/pipelines/ddpm/pipeline_ddpm.py +1 -1
- diffusers/pipelines/deepfloyd_if/pipeline_if.py +4 -4
- diffusers/pipelines/deepfloyd_if/pipeline_if_img2img.py +4 -4
- diffusers/pipelines/deepfloyd_if/pipeline_if_img2img_superresolution.py +5 -5
- diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting.py +4 -4
- diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting_superresolution.py +5 -5
- diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py +5 -5
- diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion.py +10 -120
- diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion_img2img.py +10 -91
- diffusers/pipelines/deprecated/audio_diffusion/mel.py +1 -1
- diffusers/pipelines/deprecated/audio_diffusion/pipeline_audio_diffusion.py +1 -1
- diffusers/pipelines/deprecated/latent_diffusion_uncond/pipeline_latent_diffusion_uncond.py +1 -1
- diffusers/pipelines/deprecated/pndm/pipeline_pndm.py +1 -1
- diffusers/pipelines/deprecated/repaint/pipeline_repaint.py +1 -1
- diffusers/pipelines/deprecated/score_sde_ve/pipeline_score_sde_ve.py +1 -1
- diffusers/pipelines/deprecated/spectrogram_diffusion/continuous_encoder.py +1 -1
- diffusers/pipelines/deprecated/spectrogram_diffusion/midi_utils.py +1 -1
- diffusers/pipelines/deprecated/spectrogram_diffusion/notes_encoder.py +1 -1
- diffusers/pipelines/deprecated/spectrogram_diffusion/pipeline_spectrogram_diffusion.py +1 -1
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_cycle_diffusion.py +5 -4
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_inpaint_legacy.py +5 -4
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_model_editing.py +7 -22
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_paradigms.py +5 -39
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_pix2pix_zero.py +5 -5
- diffusers/pipelines/deprecated/stochastic_karras_ve/pipeline_stochastic_karras_ve.py +1 -1
- diffusers/pipelines/deprecated/versatile_diffusion/modeling_text_unet.py +31 -22
- diffusers/pipelines/deprecated/versatile_diffusion/pipeline_versatile_diffusion_dual_guided.py +1 -1
- diffusers/pipelines/deprecated/versatile_diffusion/pipeline_versatile_diffusion_image_variation.py +1 -1
- diffusers/pipelines/deprecated/versatile_diffusion/pipeline_versatile_diffusion_text_to_image.py +1 -2
- diffusers/pipelines/deprecated/vq_diffusion/pipeline_vq_diffusion.py +1 -1
- diffusers/pipelines/dit/pipeline_dit.py +1 -1
- diffusers/pipelines/free_init_utils.py +184 -0
- diffusers/pipelines/i2vgen_xl/pipeline_i2vgen_xl.py +22 -104
- diffusers/pipelines/kandinsky/pipeline_kandinsky.py +1 -1
- diffusers/pipelines/kandinsky/pipeline_kandinsky_combined.py +1 -1
- diffusers/pipelines/kandinsky/pipeline_kandinsky_img2img.py +1 -1
- diffusers/pipelines/kandinsky/pipeline_kandinsky_inpaint.py +2 -2
- diffusers/pipelines/kandinsky/pipeline_kandinsky_prior.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_combined.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet_img2img.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_img2img.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_inpainting.py +2 -2
- diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_img2img.py +104 -93
- diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_text2img.py +112 -74
- diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py +1 -1
- diffusers/pipelines/ledits_pp/__init__.py +55 -0
- diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py +1505 -0
- diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion_xl.py +1797 -0
- diffusers/pipelines/ledits_pp/pipeline_output.py +43 -0
- diffusers/pipelines/musicldm/pipeline_musicldm.py +3 -19
- diffusers/pipelines/onnx_utils.py +1 -1
- diffusers/pipelines/paint_by_example/image_encoder.py +1 -1
- diffusers/pipelines/paint_by_example/pipeline_paint_by_example.py +3 -3
- diffusers/pipelines/pia/pipeline_pia.py +168 -327
- diffusers/pipelines/pipeline_flax_utils.py +1 -1
- diffusers/pipelines/pipeline_loading_utils.py +508 -0
- diffusers/pipelines/pipeline_utils.py +188 -534
- diffusers/pipelines/pixart_alpha/pipeline_pixart_alpha.py +56 -10
- diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py +3 -3
- diffusers/pipelines/shap_e/camera.py +1 -1
- diffusers/pipelines/shap_e/pipeline_shap_e.py +1 -1
- diffusers/pipelines/shap_e/pipeline_shap_e_img2img.py +1 -1
- diffusers/pipelines/shap_e/renderer.py +1 -1
- diffusers/pipelines/stable_cascade/__init__.py +50 -0
- diffusers/pipelines/stable_cascade/pipeline_stable_cascade.py +482 -0
- diffusers/pipelines/stable_cascade/pipeline_stable_cascade_combined.py +311 -0
- diffusers/pipelines/stable_cascade/pipeline_stable_cascade_prior.py +638 -0
- diffusers/pipelines/stable_diffusion/clip_image_project_model.py +1 -1
- diffusers/pipelines/stable_diffusion/convert_from_ckpt.py +4 -1
- diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion_img2img.py +2 -2
- diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion_inpaint.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_img2img.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_inpaint.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_upscale.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +90 -146
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py +5 -4
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_image_variation.py +4 -32
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +92 -119
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +92 -119
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py +13 -59
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_latent_upscale.py +3 -31
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py +5 -33
- diffusers/pipelines/stable_diffusion/pipeline_stable_unclip.py +5 -21
- diffusers/pipelines/stable_diffusion/pipeline_stable_unclip_img2img.py +7 -21
- diffusers/pipelines/stable_diffusion/safety_checker.py +1 -1
- diffusers/pipelines/stable_diffusion/safety_checker_flax.py +1 -1
- diffusers/pipelines/stable_diffusion/stable_unclip_image_normalizer.py +1 -1
- diffusers/pipelines/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py +5 -21
- diffusers/pipelines/stable_diffusion_diffedit/pipeline_stable_diffusion_diffedit.py +9 -38
- diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen.py +5 -34
- diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen_text_image.py +6 -35
- diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_k_diffusion.py +7 -6
- diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_xl_k_diffusion.py +4 -124
- diffusers/pipelines/stable_diffusion_ldm3d/pipeline_stable_diffusion_ldm3d.py +282 -80
- diffusers/pipelines/stable_diffusion_panorama/pipeline_stable_diffusion_panorama.py +94 -46
- diffusers/pipelines/stable_diffusion_safe/pipeline_stable_diffusion_safe.py +3 -3
- diffusers/pipelines/stable_diffusion_safe/safety_checker.py +1 -1
- diffusers/pipelines/stable_diffusion_sag/pipeline_stable_diffusion_sag.py +6 -22
- diffusers/pipelines/stable_diffusion_xl/pipeline_flax_stable_diffusion_xl.py +1 -1
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +96 -148
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +98 -154
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py +98 -153
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_instruct_pix2pix.py +25 -87
- diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py +89 -80
- diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_adapter.py +5 -49
- diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_xl_adapter.py +80 -88
- diffusers/pipelines/text_to_video_synthesis/pipeline_output.py +8 -6
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth.py +15 -86
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth_img2img.py +20 -93
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero.py +5 -5
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero_sdxl.py +3 -19
- diffusers/pipelines/unclip/pipeline_unclip.py +1 -1
- diffusers/pipelines/unclip/pipeline_unclip_image_variation.py +1 -1
- diffusers/pipelines/unclip/text_proj.py +1 -1
- diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py +35 -35
- diffusers/pipelines/wuerstchen/modeling_paella_vq_model.py +1 -1
- diffusers/pipelines/wuerstchen/modeling_wuerstchen_common.py +4 -21
- diffusers/pipelines/wuerstchen/modeling_wuerstchen_diffnext.py +2 -2
- diffusers/pipelines/wuerstchen/modeling_wuerstchen_prior.py +4 -5
- diffusers/pipelines/wuerstchen/pipeline_wuerstchen.py +8 -8
- diffusers/pipelines/wuerstchen/pipeline_wuerstchen_combined.py +1 -1
- diffusers/pipelines/wuerstchen/pipeline_wuerstchen_prior.py +2 -2
- diffusers/schedulers/__init__.py +7 -1
- diffusers/schedulers/deprecated/scheduling_karras_ve.py +1 -1
- diffusers/schedulers/deprecated/scheduling_sde_vp.py +1 -1
- diffusers/schedulers/scheduling_consistency_models.py +42 -19
- diffusers/schedulers/scheduling_ddim.py +2 -4
- diffusers/schedulers/scheduling_ddim_flax.py +13 -5
- diffusers/schedulers/scheduling_ddim_inverse.py +2 -4
- diffusers/schedulers/scheduling_ddim_parallel.py +2 -4
- diffusers/schedulers/scheduling_ddpm.py +2 -4
- diffusers/schedulers/scheduling_ddpm_flax.py +1 -1
- diffusers/schedulers/scheduling_ddpm_parallel.py +2 -4
- diffusers/schedulers/scheduling_ddpm_wuerstchen.py +1 -1
- diffusers/schedulers/scheduling_deis_multistep.py +46 -19
- diffusers/schedulers/scheduling_dpmsolver_multistep.py +107 -21
- diffusers/schedulers/scheduling_dpmsolver_multistep_flax.py +1 -1
- diffusers/schedulers/scheduling_dpmsolver_multistep_inverse.py +9 -7
- diffusers/schedulers/scheduling_dpmsolver_sde.py +35 -35
- diffusers/schedulers/scheduling_dpmsolver_singlestep.py +49 -18
- diffusers/schedulers/scheduling_edm_dpmsolver_multistep.py +683 -0
- diffusers/schedulers/scheduling_edm_euler.py +381 -0
- diffusers/schedulers/scheduling_euler_ancestral_discrete.py +43 -15
- diffusers/schedulers/scheduling_euler_discrete.py +42 -17
- diffusers/schedulers/scheduling_euler_discrete_flax.py +1 -1
- diffusers/schedulers/scheduling_heun_discrete.py +35 -35
- diffusers/schedulers/scheduling_ipndm.py +37 -11
- diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py +44 -44
- diffusers/schedulers/scheduling_k_dpm_2_discrete.py +44 -44
- diffusers/schedulers/scheduling_karras_ve_flax.py +1 -1
- diffusers/schedulers/scheduling_lcm.py +38 -14
- diffusers/schedulers/scheduling_lms_discrete.py +43 -15
- diffusers/schedulers/scheduling_lms_discrete_flax.py +1 -1
- diffusers/schedulers/scheduling_pndm.py +2 -4
- diffusers/schedulers/scheduling_pndm_flax.py +2 -4
- diffusers/schedulers/scheduling_repaint.py +1 -1
- diffusers/schedulers/scheduling_sasolver.py +41 -9
- diffusers/schedulers/scheduling_sde_ve.py +1 -1
- diffusers/schedulers/scheduling_sde_ve_flax.py +1 -1
- diffusers/schedulers/scheduling_tcd.py +686 -0
- diffusers/schedulers/scheduling_unclip.py +1 -1
- diffusers/schedulers/scheduling_unipc_multistep.py +46 -19
- diffusers/schedulers/scheduling_utils.py +2 -1
- diffusers/schedulers/scheduling_utils_flax.py +1 -1
- diffusers/schedulers/scheduling_vq_diffusion.py +1 -1
- diffusers/training_utils.py +9 -2
- diffusers/utils/__init__.py +2 -1
- diffusers/utils/accelerate_utils.py +1 -1
- diffusers/utils/constants.py +1 -1
- diffusers/utils/doc_utils.py +1 -1
- diffusers/utils/dummy_pt_objects.py +60 -0
- diffusers/utils/dummy_torch_and_transformers_objects.py +75 -0
- diffusers/utils/dynamic_modules_utils.py +1 -1
- diffusers/utils/export_utils.py +3 -3
- diffusers/utils/hub_utils.py +60 -16
- diffusers/utils/import_utils.py +15 -1
- diffusers/utils/loading_utils.py +2 -0
- diffusers/utils/logging.py +1 -1
- diffusers/utils/model_card_template.md +24 -0
- diffusers/utils/outputs.py +14 -7
- diffusers/utils/peft_utils.py +1 -1
- diffusers/utils/state_dict_utils.py +1 -1
- diffusers/utils/testing_utils.py +2 -0
- diffusers/utils/torch_utils.py +1 -1
- {diffusers-0.26.3.dist-info → diffusers-0.27.0.dist-info}/METADATA +46 -46
- diffusers-0.27.0.dist-info/RECORD +399 -0
- {diffusers-0.26.3.dist-info → diffusers-0.27.0.dist-info}/WHEEL +1 -1
- diffusers-0.26.3.dist-info/RECORD +0 -384
- {diffusers-0.26.3.dist-info → diffusers-0.27.0.dist-info}/LICENSE +0 -0
- {diffusers-0.26.3.dist-info → diffusers-0.27.0.dist-info}/entry_points.txt +0 -0
- {diffusers-0.26.3.dist-info → diffusers-0.27.0.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2024 The GLIGEN Authors and HuggingFace Team. All rights reserved.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -34,7 +34,7 @@ from ...models.lora import adjust_lora_scale_text_encoder
|
|
34
34
|
from ...schedulers import KarrasDiffusionSchedulers
|
35
35
|
from ...utils import USE_PEFT_BACKEND, logging, replace_example_docstring, scale_lora_layers, unscale_lora_layers
|
36
36
|
from ...utils.torch_utils import randn_tensor
|
37
|
-
from ..pipeline_utils import DiffusionPipeline
|
37
|
+
from ..pipeline_utils import DiffusionPipeline, StableDiffusionMixin
|
38
38
|
from ..stable_diffusion import StableDiffusionPipelineOutput
|
39
39
|
from ..stable_diffusion.clip_image_project_model import CLIPImageProjection
|
40
40
|
from ..stable_diffusion.safety_checker import StableDiffusionSafetyChecker
|
@@ -145,7 +145,7 @@ EXAMPLE_DOC_STRING = """
|
|
145
145
|
"""
|
146
146
|
|
147
147
|
|
148
|
-
class StableDiffusionGLIGENTextImagePipeline(DiffusionPipeline):
|
148
|
+
class StableDiffusionGLIGENTextImagePipeline(DiffusionPipeline, StableDiffusionMixin):
|
149
149
|
r"""
|
150
150
|
Pipeline for text-to-image generation using Stable Diffusion with Grounded-Language-to-Image Generation (GLIGEN).
|
151
151
|
|
@@ -230,35 +230,6 @@ class StableDiffusionGLIGENTextImagePipeline(DiffusionPipeline):
|
|
230
230
|
self.image_processor = VaeImageProcessor(vae_scale_factor=self.vae_scale_factor, do_convert_rgb=True)
|
231
231
|
self.register_to_config(requires_safety_checker=requires_safety_checker)
|
232
232
|
|
233
|
-
def enable_vae_slicing(self):
|
234
|
-
r"""
|
235
|
-
Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to
|
236
|
-
compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.
|
237
|
-
"""
|
238
|
-
self.vae.enable_slicing()
|
239
|
-
|
240
|
-
def disable_vae_slicing(self):
|
241
|
-
r"""
|
242
|
-
Disable sliced VAE decoding. If `enable_vae_slicing` was previously enabled, this method will go back to
|
243
|
-
computing decoding in one step.
|
244
|
-
"""
|
245
|
-
self.vae.disable_slicing()
|
246
|
-
|
247
|
-
def enable_vae_tiling(self):
|
248
|
-
r"""
|
249
|
-
Enable tiled VAE decoding. When this option is enabled, the VAE will split the input tensor into tiles to
|
250
|
-
compute decoding and encoding in several steps. This is useful for saving a large amount of memory and to allow
|
251
|
-
processing larger images.
|
252
|
-
"""
|
253
|
-
self.vae.enable_tiling()
|
254
|
-
|
255
|
-
def disable_vae_tiling(self):
|
256
|
-
r"""
|
257
|
-
Disable tiled VAE decoding. If `enable_vae_tiling` was previously enabled, this method will go back to
|
258
|
-
computing decoding in one step.
|
259
|
-
"""
|
260
|
-
self.vae.disable_tiling()
|
261
|
-
|
262
233
|
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.encode_prompt
|
263
234
|
def encode_prompt(
|
264
235
|
self,
|
@@ -320,7 +291,7 @@ class StableDiffusionGLIGENTextImagePipeline(DiffusionPipeline):
|
|
320
291
|
batch_size = prompt_embeds.shape[0]
|
321
292
|
|
322
293
|
if prompt_embeds is None:
|
323
|
-
# textual inversion:
|
294
|
+
# textual inversion: process multi-vector tokens if necessary
|
324
295
|
if isinstance(self, TextualInversionLoaderMixin):
|
325
296
|
prompt = self.maybe_convert_prompt(prompt, self.tokenizer)
|
326
297
|
|
@@ -402,7 +373,7 @@ class StableDiffusionGLIGENTextImagePipeline(DiffusionPipeline):
|
|
402
373
|
else:
|
403
374
|
uncond_tokens = negative_prompt
|
404
375
|
|
405
|
-
# textual inversion:
|
376
|
+
# textual inversion: process multi-vector tokens if necessary
|
406
377
|
if isinstance(self, TextualInversionLoaderMixin):
|
407
378
|
uncond_tokens = self.maybe_convert_prompt(uncond_tokens, self.tokenizer)
|
408
379
|
|
@@ -474,7 +445,7 @@ class StableDiffusionGLIGENTextImagePipeline(DiffusionPipeline):
|
|
474
445
|
extra_step_kwargs["generator"] = generator
|
475
446
|
return extra_step_kwargs
|
476
447
|
|
477
|
-
# Copied from diffusers.pipelines.
|
448
|
+
# Copied from diffusers.pipelines.stable_diffusion_k_diffusion.pipeline_stable_diffusion_k_diffusion.StableDiffusionKDiffusionPipeline.check_inputs
|
478
449
|
def check_inputs(
|
479
450
|
self,
|
480
451
|
prompt,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2024 The HuggingFace Team. All rights reserved.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -26,7 +26,7 @@ from ...models.lora import adjust_lora_scale_text_encoder
|
|
26
26
|
from ...schedulers import LMSDiscreteScheduler
|
27
27
|
from ...utils import USE_PEFT_BACKEND, deprecate, logging, scale_lora_layers, unscale_lora_layers
|
28
28
|
from ...utils.torch_utils import randn_tensor
|
29
|
-
from ..pipeline_utils import DiffusionPipeline
|
29
|
+
from ..pipeline_utils import DiffusionPipeline, StableDiffusionMixin
|
30
30
|
from ..stable_diffusion import StableDiffusionPipelineOutput
|
31
31
|
|
32
32
|
|
@@ -47,7 +47,9 @@ class ModelWrapper:
|
|
47
47
|
return self.model(*args, encoder_hidden_states=encoder_hidden_states, **kwargs).sample
|
48
48
|
|
49
49
|
|
50
|
-
class StableDiffusionKDiffusionPipeline(
|
50
|
+
class StableDiffusionKDiffusionPipeline(
|
51
|
+
DiffusionPipeline, StableDiffusionMixin, TextualInversionLoaderMixin, LoraLoaderMixin
|
52
|
+
):
|
51
53
|
r"""
|
52
54
|
Pipeline for text-to-image generation using Stable Diffusion.
|
53
55
|
|
@@ -238,7 +240,7 @@ class StableDiffusionKDiffusionPipeline(DiffusionPipeline, TextualInversionLoade
|
|
238
240
|
batch_size = prompt_embeds.shape[0]
|
239
241
|
|
240
242
|
if prompt_embeds is None:
|
241
|
-
# textual inversion:
|
243
|
+
# textual inversion: process multi-vector tokens if necessary
|
242
244
|
if isinstance(self, TextualInversionLoaderMixin):
|
243
245
|
prompt = self.maybe_convert_prompt(prompt, self.tokenizer)
|
244
246
|
|
@@ -320,7 +322,7 @@ class StableDiffusionKDiffusionPipeline(DiffusionPipeline, TextualInversionLoade
|
|
320
322
|
else:
|
321
323
|
uncond_tokens = negative_prompt
|
322
324
|
|
323
|
-
# textual inversion:
|
325
|
+
# textual inversion: process multi-vector tokens if necessary
|
324
326
|
if isinstance(self, TextualInversionLoaderMixin):
|
325
327
|
uncond_tokens = self.maybe_convert_prompt(uncond_tokens, self.tokenizer)
|
326
328
|
|
@@ -386,7 +388,6 @@ class StableDiffusionKDiffusionPipeline(DiffusionPipeline, TextualInversionLoade
|
|
386
388
|
image = image.cpu().permute(0, 2, 3, 1).float().numpy()
|
387
389
|
return image
|
388
390
|
|
389
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.check_inputs
|
390
391
|
def check_inputs(
|
391
392
|
self,
|
392
393
|
prompt,
|
diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_xl_k_diffusion.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2024 The HuggingFace Team. All rights reserved.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -50,7 +50,7 @@ from ...utils import (
|
|
50
50
|
unscale_lora_layers,
|
51
51
|
)
|
52
52
|
from ...utils.torch_utils import randn_tensor
|
53
|
-
from ..pipeline_utils import DiffusionPipeline
|
53
|
+
from ..pipeline_utils import DiffusionPipeline, StableDiffusionMixin
|
54
54
|
from ..stable_diffusion_xl.pipeline_output import StableDiffusionXLPipelineOutput
|
55
55
|
|
56
56
|
|
@@ -91,6 +91,7 @@ class ModelWrapper:
|
|
91
91
|
|
92
92
|
class StableDiffusionXLKDiffusionPipeline(
|
93
93
|
DiffusionPipeline,
|
94
|
+
StableDiffusionMixin,
|
94
95
|
FromSingleFileMixin,
|
95
96
|
StableDiffusionXLLoraLoaderMixin,
|
96
97
|
TextualInversionLoaderMixin,
|
@@ -196,39 +197,6 @@ class StableDiffusionXLKDiffusionPipeline(
|
|
196
197
|
|
197
198
|
raise ValueError(f"Invalid scheduler type {scheduler_type}. Please choose one of {valid_samplers}.")
|
198
199
|
|
199
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.enable_vae_slicing
|
200
|
-
def enable_vae_slicing(self):
|
201
|
-
r"""
|
202
|
-
Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to
|
203
|
-
compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.
|
204
|
-
"""
|
205
|
-
self.vae.enable_slicing()
|
206
|
-
|
207
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.disable_vae_slicing
|
208
|
-
def disable_vae_slicing(self):
|
209
|
-
r"""
|
210
|
-
Disable sliced VAE decoding. If `enable_vae_slicing` was previously enabled, this method will go back to
|
211
|
-
computing decoding in one step.
|
212
|
-
"""
|
213
|
-
self.vae.disable_slicing()
|
214
|
-
|
215
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.enable_vae_tiling
|
216
|
-
def enable_vae_tiling(self):
|
217
|
-
r"""
|
218
|
-
Enable tiled VAE decoding. When this option is enabled, the VAE will split the input tensor into tiles to
|
219
|
-
compute decoding and encoding in several steps. This is useful for saving a large amount of memory and to allow
|
220
|
-
processing larger images.
|
221
|
-
"""
|
222
|
-
self.vae.enable_tiling()
|
223
|
-
|
224
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.disable_vae_tiling
|
225
|
-
def disable_vae_tiling(self):
|
226
|
-
r"""
|
227
|
-
Disable tiled VAE decoding. If `enable_vae_tiling` was previously enabled, this method will go back to
|
228
|
-
computing decoding in one step.
|
229
|
-
"""
|
230
|
-
self.vae.disable_tiling()
|
231
|
-
|
232
200
|
# Copied from diffusers.pipelines.stable_diffusion_xl.pipeline_stable_diffusion_xl.StableDiffusionXLPipeline.encode_prompt
|
233
201
|
def encode_prompt(
|
234
202
|
self,
|
@@ -325,7 +293,7 @@ class StableDiffusionXLKDiffusionPipeline(
|
|
325
293
|
prompt_2 = prompt_2 or prompt
|
326
294
|
prompt_2 = [prompt_2] if isinstance(prompt_2, str) else prompt_2
|
327
295
|
|
328
|
-
# textual inversion:
|
296
|
+
# textual inversion: process multi-vector tokens if necessary
|
329
297
|
prompt_embeds_list = []
|
330
298
|
prompts = [prompt, prompt_2]
|
331
299
|
for prompt, tokenizer, text_encoder in zip(prompts, tokenizers, text_encoders):
|
@@ -582,94 +550,6 @@ class StableDiffusionXLKDiffusionPipeline(
|
|
582
550
|
self.vae.decoder.conv_in.to(dtype)
|
583
551
|
self.vae.decoder.mid_block.to(dtype)
|
584
552
|
|
585
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.enable_freeu
|
586
|
-
def enable_freeu(self, s1: float, s2: float, b1: float, b2: float):
|
587
|
-
r"""Enables the FreeU mechanism as in https://arxiv.org/abs/2309.11497.
|
588
|
-
|
589
|
-
The suffixes after the scaling factors represent the stages where they are being applied.
|
590
|
-
|
591
|
-
Please refer to the [official repository](https://github.com/ChenyangSi/FreeU) for combinations of the values
|
592
|
-
that are known to work well for different pipelines such as Stable Diffusion v1, v2, and Stable Diffusion XL.
|
593
|
-
|
594
|
-
Args:
|
595
|
-
s1 (`float`):
|
596
|
-
Scaling factor for stage 1 to attenuate the contributions of the skip features. This is done to
|
597
|
-
mitigate "oversmoothing effect" in the enhanced denoising process.
|
598
|
-
s2 (`float`):
|
599
|
-
Scaling factor for stage 2 to attenuate the contributions of the skip features. This is done to
|
600
|
-
mitigate "oversmoothing effect" in the enhanced denoising process.
|
601
|
-
b1 (`float`): Scaling factor for stage 1 to amplify the contributions of backbone features.
|
602
|
-
b2 (`float`): Scaling factor for stage 2 to amplify the contributions of backbone features.
|
603
|
-
"""
|
604
|
-
if not hasattr(self, "unet"):
|
605
|
-
raise ValueError("The pipeline must have `unet` for using FreeU.")
|
606
|
-
self.unet.enable_freeu(s1=s1, s2=s2, b1=b1, b2=b2)
|
607
|
-
|
608
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.disable_freeu
|
609
|
-
def disable_freeu(self):
|
610
|
-
"""Disables the FreeU mechanism if enabled."""
|
611
|
-
self.unet.disable_freeu()
|
612
|
-
|
613
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.fuse_qkv_projections
|
614
|
-
def fuse_qkv_projections(self, unet: bool = True, vae: bool = True):
|
615
|
-
"""
|
616
|
-
Enables fused QKV projections. For self-attention modules, all projection matrices (i.e., query,
|
617
|
-
key, value) are fused. For cross-attention modules, key and value projection matrices are fused.
|
618
|
-
|
619
|
-
<Tip warning={true}>
|
620
|
-
|
621
|
-
This API is 🧪 experimental.
|
622
|
-
|
623
|
-
</Tip>
|
624
|
-
|
625
|
-
Args:
|
626
|
-
unet (`bool`, defaults to `True`): To apply fusion on the UNet.
|
627
|
-
vae (`bool`, defaults to `True`): To apply fusion on the VAE.
|
628
|
-
"""
|
629
|
-
self.fusing_unet = False
|
630
|
-
self.fusing_vae = False
|
631
|
-
|
632
|
-
if unet:
|
633
|
-
self.fusing_unet = True
|
634
|
-
self.unet.fuse_qkv_projections()
|
635
|
-
self.unet.set_attn_processor(FusedAttnProcessor2_0())
|
636
|
-
|
637
|
-
if vae:
|
638
|
-
if not isinstance(self.vae, AutoencoderKL):
|
639
|
-
raise ValueError("`fuse_qkv_projections()` is only supported for the VAE of type `AutoencoderKL`.")
|
640
|
-
|
641
|
-
self.fusing_vae = True
|
642
|
-
self.vae.fuse_qkv_projections()
|
643
|
-
self.vae.set_attn_processor(FusedAttnProcessor2_0())
|
644
|
-
|
645
|
-
def unfuse_qkv_projections(self, unet: bool = True, vae: bool = True):
|
646
|
-
"""Disable QKV projection fusion if enabled.
|
647
|
-
|
648
|
-
<Tip warning={true}>
|
649
|
-
|
650
|
-
This API is 🧪 experimental.
|
651
|
-
|
652
|
-
</Tip>
|
653
|
-
|
654
|
-
Args:
|
655
|
-
unet (`bool`, defaults to `True`): To apply fusion on the UNet.
|
656
|
-
vae (`bool`, defaults to `True`): To apply fusion on the VAE.
|
657
|
-
|
658
|
-
"""
|
659
|
-
if unet:
|
660
|
-
if not self.fusing_unet:
|
661
|
-
logger.warning("The UNet was not initially fused for QKV projections. Doing nothing.")
|
662
|
-
else:
|
663
|
-
self.unet.unfuse_qkv_projections()
|
664
|
-
self.fusing_unet = False
|
665
|
-
|
666
|
-
if vae:
|
667
|
-
if not self.fusing_vae:
|
668
|
-
logger.warning("The VAE was not initially fused for QKV projections. Doing nothing.")
|
669
|
-
else:
|
670
|
-
self.vae.unfuse_qkv_projections()
|
671
|
-
self.fusing_vae = False
|
672
|
-
|
673
553
|
@property
|
674
554
|
def guidance_scale(self):
|
675
555
|
return self._guidance_scale
|