diffusers 0.26.2__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 +28 -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 +278 -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 +52 -21
- 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.2.dist-info → diffusers-0.27.0.dist-info}/METADATA +5 -5
- diffusers-0.27.0.dist-info/RECORD +399 -0
- diffusers-0.26.2.dist-info/RECORD +0 -384
- {diffusers-0.26.2.dist-info → diffusers-0.27.0.dist-info}/LICENSE +0 -0
- {diffusers-0.26.2.dist-info → diffusers-0.27.0.dist-info}/WHEEL +0 -0
- {diffusers-0.26.2.dist-info → diffusers-0.27.0.dist-info}/entry_points.txt +0 -0
- {diffusers-0.26.2.dist-info → diffusers-0.27.0.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2024 Ollin Boer Bohan 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.
|
@@ -292,7 +292,9 @@ class AutoencoderTiny(ModelMixin, ConfigMixin):
|
|
292
292
|
self, x: torch.FloatTensor, return_dict: bool = True
|
293
293
|
) -> Union[AutoencoderTinyOutput, Tuple[torch.FloatTensor]]:
|
294
294
|
if self.use_slicing and x.shape[0] > 1:
|
295
|
-
output = [
|
295
|
+
output = [
|
296
|
+
self._tiled_encode(x_slice) if self.use_tiling else self.encoder(x_slice) for x_slice in x.split(1)
|
297
|
+
]
|
296
298
|
output = torch.cat(output)
|
297
299
|
else:
|
298
300
|
output = self._tiled_encode(x) if self.use_tiling else self.encoder(x)
|
diffusers/models/controlnet.py
CHANGED
diffusers/models/downsampling.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.
|
@@ -18,8 +18,7 @@ import torch
|
|
18
18
|
import torch.nn as nn
|
19
19
|
import torch.nn.functional as F
|
20
20
|
|
21
|
-
from ..utils import
|
22
|
-
from .lora import LoRACompatibleConv
|
21
|
+
from ..utils import deprecate
|
23
22
|
from .normalization import RMSNorm
|
24
23
|
from .upsampling import upfirdn2d_native
|
25
24
|
|
@@ -103,7 +102,7 @@ class Downsample2D(nn.Module):
|
|
103
102
|
self.padding = padding
|
104
103
|
stride = 2
|
105
104
|
self.name = name
|
106
|
-
conv_cls = nn.Conv2d
|
105
|
+
conv_cls = nn.Conv2d
|
107
106
|
|
108
107
|
if norm_type == "ln_norm":
|
109
108
|
self.norm = nn.LayerNorm(channels, eps, elementwise_affine)
|
@@ -131,7 +130,10 @@ class Downsample2D(nn.Module):
|
|
131
130
|
else:
|
132
131
|
self.conv = conv
|
133
132
|
|
134
|
-
def forward(self, hidden_states: torch.FloatTensor,
|
133
|
+
def forward(self, hidden_states: torch.FloatTensor, *args, **kwargs) -> torch.FloatTensor:
|
134
|
+
if len(args) > 0 or kwargs.get("scale", None) is not None:
|
135
|
+
deprecation_message = "The `scale` argument is deprecated and will be ignored. Please remove it, as passing it will raise an error in the future. `scale` should directly be passed while calling the underlying pipeline component i.e., via `cross_attention_kwargs`."
|
136
|
+
deprecate("scale", "1.0.0", deprecation_message)
|
135
137
|
assert hidden_states.shape[1] == self.channels
|
136
138
|
|
137
139
|
if self.norm is not None:
|
@@ -143,13 +145,7 @@ class Downsample2D(nn.Module):
|
|
143
145
|
|
144
146
|
assert hidden_states.shape[1] == self.channels
|
145
147
|
|
146
|
-
|
147
|
-
if isinstance(self.conv, LoRACompatibleConv):
|
148
|
-
hidden_states = self.conv(hidden_states, scale)
|
149
|
-
else:
|
150
|
-
hidden_states = self.conv(hidden_states)
|
151
|
-
else:
|
152
|
-
hidden_states = self.conv(hidden_states)
|
148
|
+
hidden_states = self.conv(hidden_states)
|
153
149
|
|
154
150
|
return hidden_states
|
155
151
|
|
diffusers/models/embeddings.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.
|
@@ -18,10 +18,9 @@ import numpy as np
|
|
18
18
|
import torch
|
19
19
|
from torch import nn
|
20
20
|
|
21
|
-
from ..utils import
|
21
|
+
from ..utils import deprecate
|
22
22
|
from .activations import get_activation
|
23
23
|
from .attention_processor import Attention
|
24
|
-
from .lora import LoRACompatibleLinear
|
25
24
|
|
26
25
|
|
27
26
|
def get_timestep_embedding(
|
@@ -200,7 +199,7 @@ class TimestepEmbedding(nn.Module):
|
|
200
199
|
sample_proj_bias=True,
|
201
200
|
):
|
202
201
|
super().__init__()
|
203
|
-
linear_cls = nn.Linear
|
202
|
+
linear_cls = nn.Linear
|
204
203
|
|
205
204
|
self.linear_1 = linear_cls(in_channels, time_embed_dim, sample_proj_bias)
|
206
205
|
|
diffusers/models/lora.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.
|
@@ -27,7 +27,7 @@ import torch
|
|
27
27
|
import torch.nn.functional as F
|
28
28
|
from torch import nn
|
29
29
|
|
30
|
-
from ..utils import logging
|
30
|
+
from ..utils import deprecate, logging
|
31
31
|
from ..utils.import_utils import is_transformers_available
|
32
32
|
|
33
33
|
|
@@ -82,6 +82,9 @@ def adjust_lora_scale_text_encoder(text_encoder, lora_scale: float = 1.0):
|
|
82
82
|
|
83
83
|
class PatchedLoraProjection(torch.nn.Module):
|
84
84
|
def __init__(self, regular_linear_layer, lora_scale=1, network_alpha=None, rank=4, dtype=None):
|
85
|
+
deprecation_message = "Use of `PatchedLoraProjection` is deprecated. Please switch to PEFT backend by installing PEFT: `pip install peft`."
|
86
|
+
deprecate("PatchedLoraProjection", "1.0.0", deprecation_message)
|
87
|
+
|
85
88
|
super().__init__()
|
86
89
|
from ..models.lora import LoRALinearLayer
|
87
90
|
|
@@ -201,6 +204,9 @@ class LoRALinearLayer(nn.Module):
|
|
201
204
|
):
|
202
205
|
super().__init__()
|
203
206
|
|
207
|
+
deprecation_message = "Use of `LoRALinearLayer` is deprecated. Please switch to PEFT backend by installing PEFT: `pip install peft`."
|
208
|
+
deprecate("LoRALinearLayer", "1.0.0", deprecation_message)
|
209
|
+
|
204
210
|
self.down = nn.Linear(in_features, rank, bias=False, device=device, dtype=dtype)
|
205
211
|
self.up = nn.Linear(rank, out_features, bias=False, device=device, dtype=dtype)
|
206
212
|
# This value has the same meaning as the `--network_alpha` option in the kohya-ss trainer script.
|
@@ -261,6 +267,9 @@ class LoRAConv2dLayer(nn.Module):
|
|
261
267
|
):
|
262
268
|
super().__init__()
|
263
269
|
|
270
|
+
deprecation_message = "Use of `LoRAConv2dLayer` is deprecated. Please switch to PEFT backend by installing PEFT: `pip install peft`."
|
271
|
+
deprecate("LoRAConv2dLayer", "1.0.0", deprecation_message)
|
272
|
+
|
264
273
|
self.down = nn.Conv2d(in_features, rank, kernel_size=kernel_size, stride=stride, padding=padding, bias=False)
|
265
274
|
# according to the official kohya_ss trainer kernel_size are always fixed for the up layer
|
266
275
|
# # see: https://github.com/bmaltais/kohya_ss/blob/2accb1305979ba62f5077a23aabac23b4c37e935/networks/lora_diffusers.py#L129
|
@@ -293,10 +302,16 @@ class LoRACompatibleConv(nn.Conv2d):
|
|
293
302
|
"""
|
294
303
|
|
295
304
|
def __init__(self, *args, lora_layer: Optional[LoRAConv2dLayer] = None, **kwargs):
|
305
|
+
deprecation_message = "Use of `LoRACompatibleConv` is deprecated. Please switch to PEFT backend by installing PEFT: `pip install peft`."
|
306
|
+
deprecate("LoRACompatibleConv", "1.0.0", deprecation_message)
|
307
|
+
|
296
308
|
super().__init__(*args, **kwargs)
|
297
309
|
self.lora_layer = lora_layer
|
298
310
|
|
299
311
|
def set_lora_layer(self, lora_layer: Optional[LoRAConv2dLayer]):
|
312
|
+
deprecation_message = "Use of `set_lora_layer()` is deprecated. Please switch to PEFT backend by installing PEFT: `pip install peft`."
|
313
|
+
deprecate("set_lora_layer", "1.0.0", deprecation_message)
|
314
|
+
|
300
315
|
self.lora_layer = lora_layer
|
301
316
|
|
302
317
|
def _fuse_lora(self, lora_scale: float = 1.0, safe_fusing: bool = False):
|
@@ -352,16 +367,19 @@ class LoRACompatibleConv(nn.Conv2d):
|
|
352
367
|
self.w_down = None
|
353
368
|
|
354
369
|
def forward(self, hidden_states: torch.Tensor, scale: float = 1.0) -> torch.Tensor:
|
370
|
+
if self.padding_mode != "zeros":
|
371
|
+
hidden_states = F.pad(hidden_states, self._reversed_padding_repeated_twice, mode=self.padding_mode)
|
372
|
+
padding = (0, 0)
|
373
|
+
else:
|
374
|
+
padding = self.padding
|
375
|
+
|
376
|
+
original_outputs = F.conv2d(
|
377
|
+
hidden_states, self.weight, self.bias, self.stride, padding, self.dilation, self.groups
|
378
|
+
)
|
379
|
+
|
355
380
|
if self.lora_layer is None:
|
356
|
-
|
357
|
-
# see: https://github.com/huggingface/diffusers/pull/4315
|
358
|
-
return F.conv2d(
|
359
|
-
hidden_states, self.weight, self.bias, self.stride, self.padding, self.dilation, self.groups
|
360
|
-
)
|
381
|
+
return original_outputs
|
361
382
|
else:
|
362
|
-
original_outputs = F.conv2d(
|
363
|
-
hidden_states, self.weight, self.bias, self.stride, self.padding, self.dilation, self.groups
|
364
|
-
)
|
365
383
|
return original_outputs + (scale * self.lora_layer(hidden_states))
|
366
384
|
|
367
385
|
|
@@ -371,10 +389,15 @@ class LoRACompatibleLinear(nn.Linear):
|
|
371
389
|
"""
|
372
390
|
|
373
391
|
def __init__(self, *args, lora_layer: Optional[LoRALinearLayer] = None, **kwargs):
|
392
|
+
deprecation_message = "Use of `LoRACompatibleLinear` is deprecated. Please switch to PEFT backend by installing PEFT: `pip install peft`."
|
393
|
+
deprecate("LoRACompatibleLinear", "1.0.0", deprecation_message)
|
394
|
+
|
374
395
|
super().__init__(*args, **kwargs)
|
375
396
|
self.lora_layer = lora_layer
|
376
397
|
|
377
398
|
def set_lora_layer(self, lora_layer: Optional[LoRALinearLayer]):
|
399
|
+
deprecation_message = "Use of `set_lora_layer()` is deprecated. Please switch to PEFT backend by installing PEFT: `pip install peft`."
|
400
|
+
deprecate("set_lora_layer", "1.0.0", deprecation_message)
|
378
401
|
self.lora_layer = lora_layer
|
379
402
|
|
380
403
|
def _fuse_lora(self, lora_scale: float = 1.0, safe_fusing: bool = False):
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# coding=utf-8
|
2
|
-
# Copyright
|
2
|
+
# Copyright 2024 The HuggingFace Inc. team.
|
3
3
|
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -124,9 +124,7 @@ def load_state_dict(checkpoint_file: Union[str, os.PathLike], variant: Optional[
|
|
124
124
|
) from e
|
125
125
|
except (UnicodeDecodeError, ValueError):
|
126
126
|
raise OSError(
|
127
|
-
f"Unable to load weights from checkpoint file for '{checkpoint_file}' "
|
128
|
-
f"at '{checkpoint_file}'. "
|
129
|
-
"If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True."
|
127
|
+
f"Unable to load weights from checkpoint file for '{checkpoint_file}' " f"at '{checkpoint_file}'. "
|
130
128
|
)
|
131
129
|
|
132
130
|
|
@@ -679,7 +677,7 @@ class ModelMixin(torch.nn.Module, PushToHubMixin):
|
|
679
677
|
unexpected_keys = [k for k in unexpected_keys if re.search(pat, k) is None]
|
680
678
|
|
681
679
|
if len(unexpected_keys) > 0:
|
682
|
-
logger.
|
680
|
+
logger.warning(
|
683
681
|
f"Some weights of the model checkpoint were not used when initializing {cls.__name__}: \n {[', '.join(unexpected_keys)]}"
|
684
682
|
)
|
685
683
|
|
@@ -707,7 +705,7 @@ class ModelMixin(torch.nn.Module, PushToHubMixin):
|
|
707
705
|
# the weights so we don't have to do this again.
|
708
706
|
|
709
707
|
if "'Attention' object has no attribute" in str(e):
|
710
|
-
logger.
|
708
|
+
logger.warning(
|
711
709
|
f"Taking `{str(e)}` while using `accelerate.load_checkpoint_and_dispatch` to mean {pretrained_model_name_or_path}"
|
712
710
|
" was saved with deprecated attention block weight names. We will load it with the deprecated attention block"
|
713
711
|
" names and convert them on the fly to the new attention block format. Please re-save the model after this conversion,"
|
diffusers/models/resnet.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# Copyright
|
2
|
-
# `TemporalConvLayer` Copyright
|
1
|
+
# Copyright 2024 The HuggingFace Team. All rights reserved.
|
2
|
+
# `TemporalConvLayer` Copyright 2024 Alibaba DAMO-VILAB, The ModelScope Team and 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.
|
@@ -20,7 +20,7 @@ import torch
|
|
20
20
|
import torch.nn as nn
|
21
21
|
import torch.nn.functional as F
|
22
22
|
|
23
|
-
from ..utils import
|
23
|
+
from ..utils import deprecate
|
24
24
|
from .activations import get_activation
|
25
25
|
from .attention_processor import SpatialNorm
|
26
26
|
from .downsampling import ( # noqa
|
@@ -30,7 +30,6 @@ from .downsampling import ( # noqa
|
|
30
30
|
KDownsample2D,
|
31
31
|
downsample_2d,
|
32
32
|
)
|
33
|
-
from .lora import LoRACompatibleConv, LoRACompatibleLinear
|
34
33
|
from .normalization import AdaGroupNorm
|
35
34
|
from .upsampling import ( # noqa
|
36
35
|
FirUpsample2D,
|
@@ -102,7 +101,7 @@ class ResnetBlockCondNorm2D(nn.Module):
|
|
102
101
|
self.output_scale_factor = output_scale_factor
|
103
102
|
self.time_embedding_norm = time_embedding_norm
|
104
103
|
|
105
|
-
conv_cls = nn.Conv2d
|
104
|
+
conv_cls = nn.Conv2d
|
106
105
|
|
107
106
|
if groups_out is None:
|
108
107
|
groups_out = groups
|
@@ -149,12 +148,11 @@ class ResnetBlockCondNorm2D(nn.Module):
|
|
149
148
|
bias=conv_shortcut_bias,
|
150
149
|
)
|
151
150
|
|
152
|
-
def forward(
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
) -> torch.FloatTensor:
|
151
|
+
def forward(self, input_tensor: torch.FloatTensor, temb: torch.FloatTensor, *args, **kwargs) -> torch.FloatTensor:
|
152
|
+
if len(args) > 0 or kwargs.get("scale", None) is not None:
|
153
|
+
deprecation_message = "The `scale` argument is deprecated and will be ignored. Please remove it, as passing it will raise an error in the future. `scale` should directly be passed while calling the underlying pipeline component i.e., via `cross_attention_kwargs`."
|
154
|
+
deprecate("scale", "1.0.0", deprecation_message)
|
155
|
+
|
158
156
|
hidden_states = input_tensor
|
159
157
|
|
160
158
|
hidden_states = self.norm1(hidden_states, temb)
|
@@ -166,26 +164,24 @@ class ResnetBlockCondNorm2D(nn.Module):
|
|
166
164
|
if hidden_states.shape[0] >= 64:
|
167
165
|
input_tensor = input_tensor.contiguous()
|
168
166
|
hidden_states = hidden_states.contiguous()
|
169
|
-
input_tensor = self.upsample(input_tensor
|
170
|
-
hidden_states = self.upsample(hidden_states
|
167
|
+
input_tensor = self.upsample(input_tensor)
|
168
|
+
hidden_states = self.upsample(hidden_states)
|
171
169
|
|
172
170
|
elif self.downsample is not None:
|
173
|
-
input_tensor = self.downsample(input_tensor
|
174
|
-
hidden_states = self.downsample(hidden_states
|
171
|
+
input_tensor = self.downsample(input_tensor)
|
172
|
+
hidden_states = self.downsample(hidden_states)
|
175
173
|
|
176
|
-
hidden_states = self.conv1(hidden_states
|
174
|
+
hidden_states = self.conv1(hidden_states)
|
177
175
|
|
178
176
|
hidden_states = self.norm2(hidden_states, temb)
|
179
177
|
|
180
178
|
hidden_states = self.nonlinearity(hidden_states)
|
181
179
|
|
182
180
|
hidden_states = self.dropout(hidden_states)
|
183
|
-
hidden_states = self.conv2(hidden_states
|
181
|
+
hidden_states = self.conv2(hidden_states)
|
184
182
|
|
185
183
|
if self.conv_shortcut is not None:
|
186
|
-
input_tensor = (
|
187
|
-
self.conv_shortcut(input_tensor, scale) if not USE_PEFT_BACKEND else self.conv_shortcut(input_tensor)
|
188
|
-
)
|
184
|
+
input_tensor = self.conv_shortcut(input_tensor)
|
189
185
|
|
190
186
|
output_tensor = (input_tensor + hidden_states) / self.output_scale_factor
|
191
187
|
|
@@ -267,8 +263,8 @@ class ResnetBlock2D(nn.Module):
|
|
267
263
|
self.time_embedding_norm = time_embedding_norm
|
268
264
|
self.skip_time_act = skip_time_act
|
269
265
|
|
270
|
-
linear_cls = nn.Linear
|
271
|
-
conv_cls = nn.Conv2d
|
266
|
+
linear_cls = nn.Linear
|
267
|
+
conv_cls = nn.Conv2d
|
272
268
|
|
273
269
|
if groups_out is None:
|
274
270
|
groups_out = groups
|
@@ -326,12 +322,11 @@ class ResnetBlock2D(nn.Module):
|
|
326
322
|
bias=conv_shortcut_bias,
|
327
323
|
)
|
328
324
|
|
329
|
-
def forward(
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
) -> torch.FloatTensor:
|
325
|
+
def forward(self, input_tensor: torch.FloatTensor, temb: torch.FloatTensor, *args, **kwargs) -> torch.FloatTensor:
|
326
|
+
if len(args) > 0 or kwargs.get("scale", None) is not None:
|
327
|
+
deprecation_message = "The `scale` argument is deprecated and will be ignored. Please remove it, as passing it will raise an error in the future. `scale` should directly be passed while calling the underlying pipeline component i.e., via `cross_attention_kwargs`."
|
328
|
+
deprecate("scale", "1.0.0", deprecation_message)
|
329
|
+
|
335
330
|
hidden_states = input_tensor
|
336
331
|
|
337
332
|
hidden_states = self.norm1(hidden_states)
|
@@ -342,38 +337,18 @@ class ResnetBlock2D(nn.Module):
|
|
342
337
|
if hidden_states.shape[0] >= 64:
|
343
338
|
input_tensor = input_tensor.contiguous()
|
344
339
|
hidden_states = hidden_states.contiguous()
|
345
|
-
input_tensor = (
|
346
|
-
|
347
|
-
if isinstance(self.upsample, Upsample2D)
|
348
|
-
else self.upsample(input_tensor)
|
349
|
-
)
|
350
|
-
hidden_states = (
|
351
|
-
self.upsample(hidden_states, scale=scale)
|
352
|
-
if isinstance(self.upsample, Upsample2D)
|
353
|
-
else self.upsample(hidden_states)
|
354
|
-
)
|
340
|
+
input_tensor = self.upsample(input_tensor)
|
341
|
+
hidden_states = self.upsample(hidden_states)
|
355
342
|
elif self.downsample is not None:
|
356
|
-
input_tensor = (
|
357
|
-
|
358
|
-
if isinstance(self.downsample, Downsample2D)
|
359
|
-
else self.downsample(input_tensor)
|
360
|
-
)
|
361
|
-
hidden_states = (
|
362
|
-
self.downsample(hidden_states, scale=scale)
|
363
|
-
if isinstance(self.downsample, Downsample2D)
|
364
|
-
else self.downsample(hidden_states)
|
365
|
-
)
|
343
|
+
input_tensor = self.downsample(input_tensor)
|
344
|
+
hidden_states = self.downsample(hidden_states)
|
366
345
|
|
367
|
-
hidden_states = self.conv1(hidden_states
|
346
|
+
hidden_states = self.conv1(hidden_states)
|
368
347
|
|
369
348
|
if self.time_emb_proj is not None:
|
370
349
|
if not self.skip_time_act:
|
371
350
|
temb = self.nonlinearity(temb)
|
372
|
-
temb = (
|
373
|
-
self.time_emb_proj(temb, scale)[:, :, None, None]
|
374
|
-
if not USE_PEFT_BACKEND
|
375
|
-
else self.time_emb_proj(temb)[:, :, None, None]
|
376
|
-
)
|
351
|
+
temb = self.time_emb_proj(temb)[:, :, None, None]
|
377
352
|
|
378
353
|
if self.time_embedding_norm == "default":
|
379
354
|
if temb is not None:
|
@@ -393,12 +368,10 @@ class ResnetBlock2D(nn.Module):
|
|
393
368
|
hidden_states = self.nonlinearity(hidden_states)
|
394
369
|
|
395
370
|
hidden_states = self.dropout(hidden_states)
|
396
|
-
hidden_states = self.conv2(hidden_states
|
371
|
+
hidden_states = self.conv2(hidden_states)
|
397
372
|
|
398
373
|
if self.conv_shortcut is not None:
|
399
|
-
input_tensor = (
|
400
|
-
self.conv_shortcut(input_tensor, scale) if not USE_PEFT_BACKEND else self.conv_shortcut(input_tensor)
|
401
|
-
)
|
374
|
+
input_tensor = self.conv_shortcut(input_tensor)
|
402
375
|
|
403
376
|
output_tensor = (input_tensor + hidden_states) / self.output_scale_factor
|
404
377
|
|
diffusers/models/resnet_flax.py
CHANGED