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 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.
|
@@ -23,7 +23,6 @@ from ....configuration_utils import FrozenDict
|
|
23
23
|
from ....image_processor import PipelineImageInput, VaeImageProcessor
|
24
24
|
from ....loaders import FromSingleFileMixin, IPAdapterMixin, LoraLoaderMixin, TextualInversionLoaderMixin
|
25
25
|
from ....models import AutoencoderKL, ImageProjection, UNet2DConditionModel
|
26
|
-
from ....models.attention_processor import FusedAttnProcessor2_0
|
27
26
|
from ....models.lora import adjust_lora_scale_text_encoder
|
28
27
|
from ....schedulers import KarrasDiffusionSchedulers
|
29
28
|
from ....utils import (
|
@@ -35,7 +34,7 @@ from ....utils import (
|
|
35
34
|
unscale_lora_layers,
|
36
35
|
)
|
37
36
|
from ....utils.torch_utils import randn_tensor
|
38
|
-
from ...pipeline_utils import DiffusionPipeline
|
37
|
+
from ...pipeline_utils import DiffusionPipeline, StableDiffusionMixin
|
39
38
|
from ...stable_diffusion.safety_checker import StableDiffusionSafetyChecker
|
40
39
|
from .modeling_roberta_series import RobertaSeriesModelWithTransformation
|
41
40
|
from .pipeline_output import AltDiffusionPipelineOutput
|
@@ -120,7 +119,12 @@ def retrieve_timesteps(
|
|
120
119
|
|
121
120
|
|
122
121
|
class AltDiffusionPipeline(
|
123
|
-
DiffusionPipeline,
|
122
|
+
DiffusionPipeline,
|
123
|
+
StableDiffusionMixin,
|
124
|
+
TextualInversionLoaderMixin,
|
125
|
+
LoraLoaderMixin,
|
126
|
+
IPAdapterMixin,
|
127
|
+
FromSingleFileMixin,
|
124
128
|
):
|
125
129
|
r"""
|
126
130
|
Pipeline for text-to-image generation using Alt Diffusion.
|
@@ -252,35 +256,6 @@ class AltDiffusionPipeline(
|
|
252
256
|
self.image_processor = VaeImageProcessor(vae_scale_factor=self.vae_scale_factor)
|
253
257
|
self.register_to_config(requires_safety_checker=requires_safety_checker)
|
254
258
|
|
255
|
-
def enable_vae_slicing(self):
|
256
|
-
r"""
|
257
|
-
Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to
|
258
|
-
compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.
|
259
|
-
"""
|
260
|
-
self.vae.enable_slicing()
|
261
|
-
|
262
|
-
def disable_vae_slicing(self):
|
263
|
-
r"""
|
264
|
-
Disable sliced VAE decoding. If `enable_vae_slicing` was previously enabled, this method will go back to
|
265
|
-
computing decoding in one step.
|
266
|
-
"""
|
267
|
-
self.vae.disable_slicing()
|
268
|
-
|
269
|
-
def enable_vae_tiling(self):
|
270
|
-
r"""
|
271
|
-
Enable tiled VAE decoding. When this option is enabled, the VAE will split the input tensor into tiles to
|
272
|
-
compute decoding and encoding in several steps. This is useful for saving a large amount of memory and to allow
|
273
|
-
processing larger images.
|
274
|
-
"""
|
275
|
-
self.vae.enable_tiling()
|
276
|
-
|
277
|
-
def disable_vae_tiling(self):
|
278
|
-
r"""
|
279
|
-
Disable tiled VAE decoding. If `enable_vae_tiling` was previously enabled, this method will go back to
|
280
|
-
computing decoding in one step.
|
281
|
-
"""
|
282
|
-
self.vae.disable_tiling()
|
283
|
-
|
284
259
|
def _encode_prompt(
|
285
260
|
self,
|
286
261
|
prompt,
|
@@ -373,7 +348,7 @@ class AltDiffusionPipeline(
|
|
373
348
|
batch_size = prompt_embeds.shape[0]
|
374
349
|
|
375
350
|
if prompt_embeds is None:
|
376
|
-
# textual inversion:
|
351
|
+
# textual inversion: process multi-vector tokens if necessary
|
377
352
|
if isinstance(self, TextualInversionLoaderMixin):
|
378
353
|
prompt = self.maybe_convert_prompt(prompt, self.tokenizer)
|
379
354
|
|
@@ -455,7 +430,7 @@ class AltDiffusionPipeline(
|
|
455
430
|
else:
|
456
431
|
uncond_tokens = negative_prompt
|
457
432
|
|
458
|
-
# textual inversion:
|
433
|
+
# textual inversion: process multi-vector tokens if necessary
|
459
434
|
if isinstance(self, TextualInversionLoaderMixin):
|
460
435
|
uncond_tokens = self.maybe_convert_prompt(uncond_tokens, self.tokenizer)
|
461
436
|
|
@@ -629,91 +604,6 @@ class AltDiffusionPipeline(
|
|
629
604
|
latents = latents * self.scheduler.init_noise_sigma
|
630
605
|
return latents
|
631
606
|
|
632
|
-
def enable_freeu(self, s1: float, s2: float, b1: float, b2: float):
|
633
|
-
r"""Enables the FreeU mechanism as in https://arxiv.org/abs/2309.11497.
|
634
|
-
|
635
|
-
The suffixes after the scaling factors represent the stages where they are being applied.
|
636
|
-
|
637
|
-
Please refer to the [official repository](https://github.com/ChenyangSi/FreeU) for combinations of the values
|
638
|
-
that are known to work well for different pipelines such as Alt Diffusion v1, v2, and Alt Diffusion XL.
|
639
|
-
|
640
|
-
Args:
|
641
|
-
s1 (`float`):
|
642
|
-
Scaling factor for stage 1 to attenuate the contributions of the skip features. This is done to
|
643
|
-
mitigate "oversmoothing effect" in the enhanced denoising process.
|
644
|
-
s2 (`float`):
|
645
|
-
Scaling factor for stage 2 to attenuate the contributions of the skip features. This is done to
|
646
|
-
mitigate "oversmoothing effect" in the enhanced denoising process.
|
647
|
-
b1 (`float`): Scaling factor for stage 1 to amplify the contributions of backbone features.
|
648
|
-
b2 (`float`): Scaling factor for stage 2 to amplify the contributions of backbone features.
|
649
|
-
"""
|
650
|
-
if not hasattr(self, "unet"):
|
651
|
-
raise ValueError("The pipeline must have `unet` for using FreeU.")
|
652
|
-
self.unet.enable_freeu(s1=s1, s2=s2, b1=b1, b2=b2)
|
653
|
-
|
654
|
-
def disable_freeu(self):
|
655
|
-
"""Disables the FreeU mechanism if enabled."""
|
656
|
-
self.unet.disable_freeu()
|
657
|
-
|
658
|
-
def fuse_qkv_projections(self, unet: bool = True, vae: bool = True):
|
659
|
-
"""
|
660
|
-
Enables fused QKV projections. For self-attention modules, all projection matrices (i.e., query,
|
661
|
-
key, value) are fused. For cross-attention modules, key and value projection matrices are fused.
|
662
|
-
|
663
|
-
<Tip warning={true}>
|
664
|
-
|
665
|
-
This API is 🧪 experimental.
|
666
|
-
|
667
|
-
</Tip>
|
668
|
-
|
669
|
-
Args:
|
670
|
-
unet (`bool`, defaults to `True`): To apply fusion on the UNet.
|
671
|
-
vae (`bool`, defaults to `True`): To apply fusion on the VAE.
|
672
|
-
"""
|
673
|
-
self.fusing_unet = False
|
674
|
-
self.fusing_vae = False
|
675
|
-
|
676
|
-
if unet:
|
677
|
-
self.fusing_unet = True
|
678
|
-
self.unet.fuse_qkv_projections()
|
679
|
-
self.unet.set_attn_processor(FusedAttnProcessor2_0())
|
680
|
-
|
681
|
-
if vae:
|
682
|
-
if not isinstance(self.vae, AutoencoderKL):
|
683
|
-
raise ValueError("`fuse_qkv_projections()` is only supported for the VAE of type `AutoencoderKL`.")
|
684
|
-
|
685
|
-
self.fusing_vae = True
|
686
|
-
self.vae.fuse_qkv_projections()
|
687
|
-
self.vae.set_attn_processor(FusedAttnProcessor2_0())
|
688
|
-
|
689
|
-
def unfuse_qkv_projections(self, unet: bool = True, vae: bool = True):
|
690
|
-
"""Disable QKV projection fusion if enabled.
|
691
|
-
|
692
|
-
<Tip warning={true}>
|
693
|
-
|
694
|
-
This API is 🧪 experimental.
|
695
|
-
|
696
|
-
</Tip>
|
697
|
-
|
698
|
-
Args:
|
699
|
-
unet (`bool`, defaults to `True`): To apply fusion on the UNet.
|
700
|
-
vae (`bool`, defaults to `True`): To apply fusion on the VAE.
|
701
|
-
|
702
|
-
"""
|
703
|
-
if unet:
|
704
|
-
if not self.fusing_unet:
|
705
|
-
logger.warning("The UNet was not initially fused for QKV projections. Doing nothing.")
|
706
|
-
else:
|
707
|
-
self.unet.unfuse_qkv_projections()
|
708
|
-
self.fusing_unet = False
|
709
|
-
|
710
|
-
if vae:
|
711
|
-
if not self.fusing_vae:
|
712
|
-
logger.warning("The VAE was not initially fused for QKV projections. Doing nothing.")
|
713
|
-
else:
|
714
|
-
self.vae.unfuse_qkv_projections()
|
715
|
-
self.fusing_vae = False
|
716
|
-
|
717
607
|
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
718
608
|
"""
|
719
609
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
@@ -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.
|
@@ -25,7 +25,6 @@ from ....configuration_utils import FrozenDict
|
|
25
25
|
from ....image_processor import PipelineImageInput, VaeImageProcessor
|
26
26
|
from ....loaders import FromSingleFileMixin, IPAdapterMixin, LoraLoaderMixin, TextualInversionLoaderMixin
|
27
27
|
from ....models import AutoencoderKL, ImageProjection, UNet2DConditionModel
|
28
|
-
from ....models.attention_processor import FusedAttnProcessor2_0
|
29
28
|
from ....models.lora import adjust_lora_scale_text_encoder
|
30
29
|
from ....schedulers import KarrasDiffusionSchedulers
|
31
30
|
from ....utils import (
|
@@ -38,7 +37,7 @@ from ....utils import (
|
|
38
37
|
unscale_lora_layers,
|
39
38
|
)
|
40
39
|
from ....utils.torch_utils import randn_tensor
|
41
|
-
from ...pipeline_utils import DiffusionPipeline
|
40
|
+
from ...pipeline_utils import DiffusionPipeline, StableDiffusionMixin
|
42
41
|
from ...stable_diffusion.safety_checker import StableDiffusionSafetyChecker
|
43
42
|
from .modeling_roberta_series import RobertaSeriesModelWithTransformation
|
44
43
|
from .pipeline_output import AltDiffusionPipelineOutput
|
@@ -160,7 +159,12 @@ def retrieve_timesteps(
|
|
160
159
|
|
161
160
|
|
162
161
|
class AltDiffusionImg2ImgPipeline(
|
163
|
-
DiffusionPipeline,
|
162
|
+
DiffusionPipeline,
|
163
|
+
StableDiffusionMixin,
|
164
|
+
TextualInversionLoaderMixin,
|
165
|
+
IPAdapterMixin,
|
166
|
+
LoraLoaderMixin,
|
167
|
+
FromSingleFileMixin,
|
164
168
|
):
|
165
169
|
r"""
|
166
170
|
Pipeline for text-guided image-to-image generation using Alt Diffusion.
|
@@ -384,7 +388,7 @@ class AltDiffusionImg2ImgPipeline(
|
|
384
388
|
batch_size = prompt_embeds.shape[0]
|
385
389
|
|
386
390
|
if prompt_embeds is None:
|
387
|
-
# textual inversion:
|
391
|
+
# textual inversion: process multi-vector tokens if necessary
|
388
392
|
if isinstance(self, TextualInversionLoaderMixin):
|
389
393
|
prompt = self.maybe_convert_prompt(prompt, self.tokenizer)
|
390
394
|
|
@@ -466,7 +470,7 @@ class AltDiffusionImg2ImgPipeline(
|
|
466
470
|
else:
|
467
471
|
uncond_tokens = negative_prompt
|
468
472
|
|
469
|
-
# textual inversion:
|
473
|
+
# textual inversion: process multi-vector tokens if necessary
|
470
474
|
if isinstance(self, TextualInversionLoaderMixin):
|
471
475
|
uncond_tokens = self.maybe_convert_prompt(uncond_tokens, self.tokenizer)
|
472
476
|
|
@@ -689,91 +693,6 @@ class AltDiffusionImg2ImgPipeline(
|
|
689
693
|
|
690
694
|
return latents
|
691
695
|
|
692
|
-
def enable_freeu(self, s1: float, s2: float, b1: float, b2: float):
|
693
|
-
r"""Enables the FreeU mechanism as in https://arxiv.org/abs/2309.11497.
|
694
|
-
|
695
|
-
The suffixes after the scaling factors represent the stages where they are being applied.
|
696
|
-
|
697
|
-
Please refer to the [official repository](https://github.com/ChenyangSi/FreeU) for combinations of the values
|
698
|
-
that are known to work well for different pipelines such as Alt Diffusion v1, v2, and Alt Diffusion XL.
|
699
|
-
|
700
|
-
Args:
|
701
|
-
s1 (`float`):
|
702
|
-
Scaling factor for stage 1 to attenuate the contributions of the skip features. This is done to
|
703
|
-
mitigate "oversmoothing effect" in the enhanced denoising process.
|
704
|
-
s2 (`float`):
|
705
|
-
Scaling factor for stage 2 to attenuate the contributions of the skip features. This is done to
|
706
|
-
mitigate "oversmoothing effect" in the enhanced denoising process.
|
707
|
-
b1 (`float`): Scaling factor for stage 1 to amplify the contributions of backbone features.
|
708
|
-
b2 (`float`): Scaling factor for stage 2 to amplify the contributions of backbone features.
|
709
|
-
"""
|
710
|
-
if not hasattr(self, "unet"):
|
711
|
-
raise ValueError("The pipeline must have `unet` for using FreeU.")
|
712
|
-
self.unet.enable_freeu(s1=s1, s2=s2, b1=b1, b2=b2)
|
713
|
-
|
714
|
-
def disable_freeu(self):
|
715
|
-
"""Disables the FreeU mechanism if enabled."""
|
716
|
-
self.unet.disable_freeu()
|
717
|
-
|
718
|
-
def fuse_qkv_projections(self, unet: bool = True, vae: bool = True):
|
719
|
-
"""
|
720
|
-
Enables fused QKV projections. For self-attention modules, all projection matrices (i.e., query,
|
721
|
-
key, value) are fused. For cross-attention modules, key and value projection matrices are fused.
|
722
|
-
|
723
|
-
<Tip warning={true}>
|
724
|
-
|
725
|
-
This API is 🧪 experimental.
|
726
|
-
|
727
|
-
</Tip>
|
728
|
-
|
729
|
-
Args:
|
730
|
-
unet (`bool`, defaults to `True`): To apply fusion on the UNet.
|
731
|
-
vae (`bool`, defaults to `True`): To apply fusion on the VAE.
|
732
|
-
"""
|
733
|
-
self.fusing_unet = False
|
734
|
-
self.fusing_vae = False
|
735
|
-
|
736
|
-
if unet:
|
737
|
-
self.fusing_unet = True
|
738
|
-
self.unet.fuse_qkv_projections()
|
739
|
-
self.unet.set_attn_processor(FusedAttnProcessor2_0())
|
740
|
-
|
741
|
-
if vae:
|
742
|
-
if not isinstance(self.vae, AutoencoderKL):
|
743
|
-
raise ValueError("`fuse_qkv_projections()` is only supported for the VAE of type `AutoencoderKL`.")
|
744
|
-
|
745
|
-
self.fusing_vae = True
|
746
|
-
self.vae.fuse_qkv_projections()
|
747
|
-
self.vae.set_attn_processor(FusedAttnProcessor2_0())
|
748
|
-
|
749
|
-
def unfuse_qkv_projections(self, unet: bool = True, vae: bool = True):
|
750
|
-
"""Disable QKV projection fusion if enabled.
|
751
|
-
|
752
|
-
<Tip warning={true}>
|
753
|
-
|
754
|
-
This API is 🧪 experimental.
|
755
|
-
|
756
|
-
</Tip>
|
757
|
-
|
758
|
-
Args:
|
759
|
-
unet (`bool`, defaults to `True`): To apply fusion on the UNet.
|
760
|
-
vae (`bool`, defaults to `True`): To apply fusion on the VAE.
|
761
|
-
|
762
|
-
"""
|
763
|
-
if unet:
|
764
|
-
if not self.fusing_unet:
|
765
|
-
logger.warning("The UNet was not initially fused for QKV projections. Doing nothing.")
|
766
|
-
else:
|
767
|
-
self.unet.unfuse_qkv_projections()
|
768
|
-
self.fusing_unet = False
|
769
|
-
|
770
|
-
if vae:
|
771
|
-
if not self.fusing_vae:
|
772
|
-
logger.warning("The VAE was not initially fused for QKV projections. Doing nothing.")
|
773
|
-
else:
|
774
|
-
self.vae.unfuse_qkv_projections()
|
775
|
-
self.fusing_vae = False
|
776
|
-
|
777
696
|
def get_guidance_scale_embedding(self, w, embedding_dim=512, dtype=torch.float32):
|
778
697
|
"""
|
779
698
|
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2024 ETH Zurich Computer Vision Lab and 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.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright 2022 The Music Spectrogram Diffusion Authors.
|
2
|
-
# Copyright
|
2
|
+
# Copyright 2024 The HuggingFace Team. All rights reserved.
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
# you may not use this file except in compliance with the License.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright 2022 The Music Spectrogram Diffusion Authors.
|
2
|
-
# Copyright
|
2
|
+
# Copyright 2024 The HuggingFace Team. All rights reserved.
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
# you may not use this file except in compliance with the License.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright 2022 The Music Spectrogram Diffusion Authors.
|
2
|
-
# Copyright
|
2
|
+
# Copyright 2024 The HuggingFace Team. All rights reserved.
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
# you may not use this file except in compliance with the License.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright 2022 The Music Spectrogram Diffusion Authors.
|
2
|
-
# Copyright
|
2
|
+
# Copyright 2024 The HuggingFace Team. All rights reserved.
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
# you may not use this file except in compliance with the License.
|
@@ -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.
|
@@ -341,7 +341,7 @@ class CycleDiffusionPipeline(DiffusionPipeline, TextualInversionLoaderMixin, Lor
|
|
341
341
|
batch_size = prompt_embeds.shape[0]
|
342
342
|
|
343
343
|
if prompt_embeds is None:
|
344
|
-
# textual inversion:
|
344
|
+
# textual inversion: process multi-vector tokens if necessary
|
345
345
|
if isinstance(self, TextualInversionLoaderMixin):
|
346
346
|
prompt = self.maybe_convert_prompt(prompt, self.tokenizer)
|
347
347
|
|
@@ -423,7 +423,7 @@ class CycleDiffusionPipeline(DiffusionPipeline, TextualInversionLoaderMixin, Lor
|
|
423
423
|
else:
|
424
424
|
uncond_tokens = negative_prompt
|
425
425
|
|
426
|
-
# textual inversion:
|
426
|
+
# textual inversion: process multi-vector tokens if necessary
|
427
427
|
if isinstance(self, TextualInversionLoaderMixin):
|
428
428
|
uncond_tokens = self.maybe_convert_prompt(uncond_tokens, self.tokenizer)
|
429
429
|
|
@@ -462,7 +462,6 @@ class CycleDiffusionPipeline(DiffusionPipeline, TextualInversionLoaderMixin, Lor
|
|
462
462
|
|
463
463
|
return prompt_embeds, negative_prompt_embeds
|
464
464
|
|
465
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_img2img.StableDiffusionImg2ImgPipeline.check_inputs
|
466
465
|
def check_inputs(
|
467
466
|
self,
|
468
467
|
prompt,
|
@@ -566,6 +565,8 @@ class CycleDiffusionPipeline(DiffusionPipeline, TextualInversionLoaderMixin, Lor
|
|
566
565
|
|
567
566
|
t_start = max(num_inference_steps - init_timestep, 0)
|
568
567
|
timesteps = self.scheduler.timesteps[t_start * self.scheduler.order :]
|
568
|
+
if hasattr(self.scheduler, "set_begin_index"):
|
569
|
+
self.scheduler.set_begin_index(t_start * self.scheduler.order)
|
569
570
|
|
570
571
|
return timesteps, num_inference_steps - t_start
|
571
572
|
|
diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_inpaint_legacy.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.
|
@@ -311,7 +311,7 @@ class StableDiffusionInpaintPipelineLegacy(
|
|
311
311
|
batch_size = prompt_embeds.shape[0]
|
312
312
|
|
313
313
|
if prompt_embeds is None:
|
314
|
-
# textual inversion:
|
314
|
+
# textual inversion: process multi-vector tokens if necessary
|
315
315
|
if isinstance(self, TextualInversionLoaderMixin):
|
316
316
|
prompt = self.maybe_convert_prompt(prompt, self.tokenizer)
|
317
317
|
|
@@ -393,7 +393,7 @@ class StableDiffusionInpaintPipelineLegacy(
|
|
393
393
|
else:
|
394
394
|
uncond_tokens = negative_prompt
|
395
395
|
|
396
|
-
# textual inversion:
|
396
|
+
# textual inversion: process multi-vector tokens if necessary
|
397
397
|
if isinstance(self, TextualInversionLoaderMixin):
|
398
398
|
uncond_tokens = self.maybe_convert_prompt(uncond_tokens, self.tokenizer)
|
399
399
|
|
@@ -477,7 +477,6 @@ class StableDiffusionInpaintPipelineLegacy(
|
|
477
477
|
extra_step_kwargs["generator"] = generator
|
478
478
|
return extra_step_kwargs
|
479
479
|
|
480
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_img2img.StableDiffusionImg2ImgPipeline.check_inputs
|
481
480
|
def check_inputs(
|
482
481
|
self,
|
483
482
|
prompt,
|
@@ -536,6 +535,8 @@ class StableDiffusionInpaintPipelineLegacy(
|
|
536
535
|
|
537
536
|
t_start = max(num_inference_steps - init_timestep, 0)
|
538
537
|
timesteps = self.scheduler.timesteps[t_start * self.scheduler.order :]
|
538
|
+
if hasattr(self.scheduler, "set_begin_index"):
|
539
|
+
self.scheduler.set_begin_index(t_start * self.scheduler.order)
|
539
540
|
|
540
541
|
return timesteps, num_inference_steps - t_start
|
541
542
|
|
diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_model_editing.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2024 TIME Authors and The HuggingFace Team. All rights reserved."
|
2
2
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
3
|
# you may not use this file except in compliance with the License.
|
4
4
|
# You may obtain a copy of the License at
|
@@ -26,7 +26,7 @@ from ....schedulers import PNDMScheduler
|
|
26
26
|
from ....schedulers.scheduling_utils import SchedulerMixin
|
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.pipeline_output import StableDiffusionPipelineOutput
|
31
31
|
from ...stable_diffusion.safety_checker import StableDiffusionSafetyChecker
|
32
32
|
|
@@ -36,7 +36,9 @@ logger = logging.get_logger(__name__) # pylint: disable=invalid-name
|
|
36
36
|
AUGS_CONST = ["A photo of ", "An image of ", "A picture of "]
|
37
37
|
|
38
38
|
|
39
|
-
class StableDiffusionModelEditingPipeline(
|
39
|
+
class StableDiffusionModelEditingPipeline(
|
40
|
+
DiffusionPipeline, StableDiffusionMixin, TextualInversionLoaderMixin, LoraLoaderMixin
|
41
|
+
):
|
40
42
|
r"""
|
41
43
|
Pipeline for text-to-image model editing.
|
42
44
|
|
@@ -153,22 +155,6 @@ class StableDiffusionModelEditingPipeline(DiffusionPipeline, TextualInversionLoa
|
|
153
155
|
self.projection_matrices = self.projection_matrices + [l.to_k for l in self.ca_clip_layers]
|
154
156
|
self.og_matrices = self.og_matrices + [copy.deepcopy(l.to_k) for l in self.ca_clip_layers]
|
155
157
|
|
156
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.enable_vae_slicing
|
157
|
-
def enable_vae_slicing(self):
|
158
|
-
r"""
|
159
|
-
Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to
|
160
|
-
compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.
|
161
|
-
"""
|
162
|
-
self.vae.enable_slicing()
|
163
|
-
|
164
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.disable_vae_slicing
|
165
|
-
def disable_vae_slicing(self):
|
166
|
-
r"""
|
167
|
-
Disable sliced VAE decoding. If `enable_vae_slicing` was previously enabled, this method will go back to
|
168
|
-
computing decoding in one step.
|
169
|
-
"""
|
170
|
-
self.vae.disable_slicing()
|
171
|
-
|
172
158
|
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline._encode_prompt
|
173
159
|
def _encode_prompt(
|
174
160
|
self,
|
@@ -263,7 +249,7 @@ class StableDiffusionModelEditingPipeline(DiffusionPipeline, TextualInversionLoa
|
|
263
249
|
batch_size = prompt_embeds.shape[0]
|
264
250
|
|
265
251
|
if prompt_embeds is None:
|
266
|
-
# textual inversion:
|
252
|
+
# textual inversion: process multi-vector tokens if necessary
|
267
253
|
if isinstance(self, TextualInversionLoaderMixin):
|
268
254
|
prompt = self.maybe_convert_prompt(prompt, self.tokenizer)
|
269
255
|
|
@@ -345,7 +331,7 @@ class StableDiffusionModelEditingPipeline(DiffusionPipeline, TextualInversionLoa
|
|
345
331
|
else:
|
346
332
|
uncond_tokens = negative_prompt
|
347
333
|
|
348
|
-
# textual inversion:
|
334
|
+
# textual inversion: process multi-vector tokens if necessary
|
349
335
|
if isinstance(self, TextualInversionLoaderMixin):
|
350
336
|
uncond_tokens = self.maybe_convert_prompt(uncond_tokens, self.tokenizer)
|
351
337
|
|
@@ -429,7 +415,6 @@ class StableDiffusionModelEditingPipeline(DiffusionPipeline, TextualInversionLoa
|
|
429
415
|
extra_step_kwargs["generator"] = generator
|
430
416
|
return extra_step_kwargs
|
431
417
|
|
432
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.check_inputs
|
433
418
|
def check_inputs(
|
434
419
|
self,
|
435
420
|
prompt,
|
diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_paradigms.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2024 ParaDiGMS authors and 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.
|
@@ -32,7 +32,7 @@ from ....utils import (
|
|
32
32
|
unscale_lora_layers,
|
33
33
|
)
|
34
34
|
from ....utils.torch_utils import randn_tensor
|
35
|
-
from ...pipeline_utils import DiffusionPipeline
|
35
|
+
from ...pipeline_utils import DiffusionPipeline, StableDiffusionMixin
|
36
36
|
from ...stable_diffusion.pipeline_output import StableDiffusionPipelineOutput
|
37
37
|
from ...stable_diffusion.safety_checker import StableDiffusionSafetyChecker
|
38
38
|
|
@@ -63,7 +63,7 @@ EXAMPLE_DOC_STRING = """
|
|
63
63
|
|
64
64
|
|
65
65
|
class StableDiffusionParadigmsPipeline(
|
66
|
-
DiffusionPipeline, TextualInversionLoaderMixin, LoraLoaderMixin, FromSingleFileMixin
|
66
|
+
DiffusionPipeline, StableDiffusionMixin, TextualInversionLoaderMixin, LoraLoaderMixin, FromSingleFileMixin
|
67
67
|
):
|
68
68
|
r"""
|
69
69
|
Pipeline for text-to-image generation using a parallelized version of Stable Diffusion.
|
@@ -146,39 +146,6 @@ class StableDiffusionParadigmsPipeline(
|
|
146
146
|
# attribute to wrap the unet with torch.nn.DataParallel when running multiple denoising steps on multiple GPUs
|
147
147
|
self.wrapped_unet = self.unet
|
148
148
|
|
149
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.enable_vae_slicing
|
150
|
-
def enable_vae_slicing(self):
|
151
|
-
r"""
|
152
|
-
Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to
|
153
|
-
compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.
|
154
|
-
"""
|
155
|
-
self.vae.enable_slicing()
|
156
|
-
|
157
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.disable_vae_slicing
|
158
|
-
def disable_vae_slicing(self):
|
159
|
-
r"""
|
160
|
-
Disable sliced VAE decoding. If `enable_vae_slicing` was previously enabled, this method will go back to
|
161
|
-
computing decoding in one step.
|
162
|
-
"""
|
163
|
-
self.vae.disable_slicing()
|
164
|
-
|
165
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.enable_vae_tiling
|
166
|
-
def enable_vae_tiling(self):
|
167
|
-
r"""
|
168
|
-
Enable tiled VAE decoding. When this option is enabled, the VAE will split the input tensor into tiles to
|
169
|
-
compute decoding and encoding in several steps. This is useful for saving a large amount of memory and to allow
|
170
|
-
processing larger images.
|
171
|
-
"""
|
172
|
-
self.vae.enable_tiling()
|
173
|
-
|
174
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.disable_vae_tiling
|
175
|
-
def disable_vae_tiling(self):
|
176
|
-
r"""
|
177
|
-
Disable tiled VAE decoding. If `enable_vae_tiling` was previously enabled, this method will go back to
|
178
|
-
computing decoding in one step.
|
179
|
-
"""
|
180
|
-
self.vae.disable_tiling()
|
181
|
-
|
182
149
|
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline._encode_prompt
|
183
150
|
def _encode_prompt(
|
184
151
|
self,
|
@@ -273,7 +240,7 @@ class StableDiffusionParadigmsPipeline(
|
|
273
240
|
batch_size = prompt_embeds.shape[0]
|
274
241
|
|
275
242
|
if prompt_embeds is None:
|
276
|
-
# textual inversion:
|
243
|
+
# textual inversion: process multi-vector tokens if necessary
|
277
244
|
if isinstance(self, TextualInversionLoaderMixin):
|
278
245
|
prompt = self.maybe_convert_prompt(prompt, self.tokenizer)
|
279
246
|
|
@@ -355,7 +322,7 @@ class StableDiffusionParadigmsPipeline(
|
|
355
322
|
else:
|
356
323
|
uncond_tokens = negative_prompt
|
357
324
|
|
358
|
-
# textual inversion:
|
325
|
+
# textual inversion: process multi-vector tokens if necessary
|
359
326
|
if isinstance(self, TextualInversionLoaderMixin):
|
360
327
|
uncond_tokens = self.maybe_convert_prompt(uncond_tokens, self.tokenizer)
|
361
328
|
|
@@ -427,7 +394,6 @@ class StableDiffusionParadigmsPipeline(
|
|
427
394
|
extra_step_kwargs["generator"] = generator
|
428
395
|
return extra_step_kwargs
|
429
396
|
|
430
|
-
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.check_inputs
|
431
397
|
def check_inputs(
|
432
398
|
self,
|
433
399
|
prompt,
|