diffusers 0.28.2__py3-none-any.whl → 0.29.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. diffusers/__init__.py +15 -1
  2. diffusers/commands/env.py +1 -5
  3. diffusers/dependency_versions_table.py +1 -1
  4. diffusers/image_processor.py +2 -1
  5. diffusers/loaders/__init__.py +2 -2
  6. diffusers/loaders/lora.py +406 -140
  7. diffusers/loaders/lora_conversion_utils.py +7 -1
  8. diffusers/loaders/single_file.py +13 -1
  9. diffusers/loaders/single_file_model.py +15 -8
  10. diffusers/loaders/single_file_utils.py +267 -17
  11. diffusers/loaders/unet.py +307 -272
  12. diffusers/models/__init__.py +7 -3
  13. diffusers/models/attention.py +125 -1
  14. diffusers/models/attention_processor.py +169 -1
  15. diffusers/models/autoencoders/__init__.py +1 -0
  16. diffusers/models/autoencoders/autoencoder_asym_kl.py +1 -1
  17. diffusers/models/autoencoders/autoencoder_kl.py +17 -6
  18. diffusers/models/autoencoders/autoencoder_kl_temporal_decoder.py +4 -2
  19. diffusers/models/autoencoders/consistency_decoder_vae.py +9 -9
  20. diffusers/models/autoencoders/vq_model.py +182 -0
  21. diffusers/models/controlnet_sd3.py +418 -0
  22. diffusers/models/controlnet_xs.py +6 -6
  23. diffusers/models/embeddings.py +112 -84
  24. diffusers/models/model_loading_utils.py +55 -0
  25. diffusers/models/modeling_utils.py +138 -20
  26. diffusers/models/normalization.py +11 -6
  27. diffusers/models/transformers/__init__.py +1 -0
  28. diffusers/models/transformers/dual_transformer_2d.py +5 -4
  29. diffusers/models/transformers/hunyuan_transformer_2d.py +149 -2
  30. diffusers/models/transformers/prior_transformer.py +5 -5
  31. diffusers/models/transformers/transformer_2d.py +2 -2
  32. diffusers/models/transformers/transformer_sd3.py +353 -0
  33. diffusers/models/transformers/transformer_temporal.py +12 -10
  34. diffusers/models/unets/unet_1d.py +3 -3
  35. diffusers/models/unets/unet_2d.py +3 -3
  36. diffusers/models/unets/unet_2d_condition.py +4 -15
  37. diffusers/models/unets/unet_3d_condition.py +5 -17
  38. diffusers/models/unets/unet_i2vgen_xl.py +4 -4
  39. diffusers/models/unets/unet_motion_model.py +4 -4
  40. diffusers/models/unets/unet_spatio_temporal_condition.py +3 -3
  41. diffusers/models/vq_model.py +8 -165
  42. diffusers/pipelines/__init__.py +11 -0
  43. diffusers/pipelines/animatediff/pipeline_animatediff.py +4 -3
  44. diffusers/pipelines/animatediff/pipeline_animatediff_video2video.py +4 -3
  45. diffusers/pipelines/auto_pipeline.py +8 -0
  46. diffusers/pipelines/controlnet/pipeline_controlnet.py +4 -3
  47. diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +4 -3
  48. diffusers/pipelines/controlnet/pipeline_controlnet_inpaint.py +4 -3
  49. diffusers/pipelines/controlnet_sd3/__init__.py +53 -0
  50. diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet.py +1062 -0
  51. diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs.py +4 -3
  52. diffusers/pipelines/deepfloyd_if/watermark.py +1 -1
  53. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_cycle_diffusion.py +4 -3
  54. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_inpaint_legacy.py +4 -3
  55. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_model_editing.py +4 -3
  56. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_paradigms.py +4 -3
  57. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_pix2pix_zero.py +4 -3
  58. diffusers/pipelines/hunyuandit/pipeline_hunyuandit.py +24 -5
  59. diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_img2img.py +4 -3
  60. diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_text2img.py +4 -3
  61. diffusers/pipelines/marigold/marigold_image_processing.py +35 -20
  62. diffusers/pipelines/pia/pipeline_pia.py +4 -3
  63. diffusers/pipelines/pixart_alpha/pipeline_pixart_alpha.py +1 -1
  64. diffusers/pipelines/pixart_alpha/pipeline_pixart_sigma.py +1 -1
  65. diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py +17 -17
  66. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +4 -3
  67. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py +5 -4
  68. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +4 -3
  69. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +4 -3
  70. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py +4 -3
  71. diffusers/pipelines/stable_diffusion/pipeline_stable_unclip.py +4 -3
  72. diffusers/pipelines/stable_diffusion/pipeline_stable_unclip_img2img.py +7 -6
  73. diffusers/pipelines/stable_diffusion_3/__init__.py +52 -0
  74. diffusers/pipelines/stable_diffusion_3/pipeline_output.py +21 -0
  75. diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3.py +904 -0
  76. diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_img2img.py +941 -0
  77. diffusers/pipelines/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py +4 -3
  78. diffusers/pipelines/stable_diffusion_diffedit/pipeline_stable_diffusion_diffedit.py +10 -11
  79. diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen.py +4 -3
  80. diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen_text_image.py +4 -3
  81. diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_k_diffusion.py +4 -3
  82. diffusers/pipelines/stable_diffusion_ldm3d/pipeline_stable_diffusion_ldm3d.py +4 -3
  83. diffusers/pipelines/stable_diffusion_panorama/pipeline_stable_diffusion_panorama.py +4 -3
  84. diffusers/pipelines/stable_diffusion_sag/pipeline_stable_diffusion_sag.py +4 -3
  85. diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_adapter.py +4 -3
  86. diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth.py +4 -3
  87. diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth_img2img.py +4 -3
  88. diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero.py +4 -3
  89. diffusers/pipelines/unidiffuser/modeling_uvit.py +1 -1
  90. diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py +4 -3
  91. diffusers/schedulers/__init__.py +2 -0
  92. diffusers/schedulers/scheduling_dpmsolver_sde.py +2 -2
  93. diffusers/schedulers/scheduling_edm_dpmsolver_multistep.py +2 -3
  94. diffusers/schedulers/scheduling_edm_euler.py +2 -4
  95. diffusers/schedulers/scheduling_flow_match_euler_discrete.py +287 -0
  96. diffusers/schedulers/scheduling_lms_discrete.py +2 -2
  97. diffusers/training_utils.py +4 -4
  98. diffusers/utils/__init__.py +3 -0
  99. diffusers/utils/constants.py +2 -0
  100. diffusers/utils/dummy_pt_objects.py +60 -0
  101. diffusers/utils/dummy_torch_and_transformers_objects.py +45 -0
  102. diffusers/utils/dynamic_modules_utils.py +15 -13
  103. diffusers/utils/hub_utils.py +106 -0
  104. diffusers/utils/import_utils.py +0 -1
  105. diffusers/utils/logging.py +3 -1
  106. diffusers/utils/state_dict_utils.py +2 -0
  107. {diffusers-0.28.2.dist-info → diffusers-0.29.1.dist-info}/METADATA +3 -3
  108. {diffusers-0.28.2.dist-info → diffusers-0.29.1.dist-info}/RECORD +112 -112
  109. {diffusers-0.28.2.dist-info → diffusers-0.29.1.dist-info}/WHEEL +1 -1
  110. diffusers/models/dual_transformer_2d.py +0 -20
  111. diffusers/models/prior_transformer.py +0 -12
  112. diffusers/models/t5_film_transformer.py +0 -70
  113. diffusers/models/transformer_2d.py +0 -25
  114. diffusers/models/transformer_temporal.py +0 -34
  115. diffusers/models/unet_1d.py +0 -26
  116. diffusers/models/unet_1d_blocks.py +0 -203
  117. diffusers/models/unet_2d.py +0 -27
  118. diffusers/models/unet_2d_blocks.py +0 -375
  119. diffusers/models/unet_2d_condition.py +0 -25
  120. {diffusers-0.28.2.dist-info → diffusers-0.29.1.dist-info}/LICENSE +0 -0
  121. {diffusers-0.28.2.dist-info → diffusers-0.29.1.dist-info}/entry_points.txt +0 -0
  122. {diffusers-0.28.2.dist-info → diffusers-0.29.1.dist-info}/top_level.txt +0 -0
@@ -157,19 +157,19 @@ def compute_dream_and_update_latents(
157
157
  with torch.no_grad():
158
158
  pred = unet(noisy_latents, timesteps, encoder_hidden_states).sample
159
159
 
160
- noisy_latents, target = (None, None)
160
+ _noisy_latents, _target = (None, None)
161
161
  if noise_scheduler.config.prediction_type == "epsilon":
162
162
  predicted_noise = pred
163
163
  delta_noise = (noise - predicted_noise).detach()
164
164
  delta_noise.mul_(dream_lambda)
165
- noisy_latents = noisy_latents.add(sqrt_one_minus_alphas_cumprod * delta_noise)
166
- target = target.add(delta_noise)
165
+ _noisy_latents = noisy_latents.add(sqrt_one_minus_alphas_cumprod * delta_noise)
166
+ _target = target.add(delta_noise)
167
167
  elif noise_scheduler.config.prediction_type == "v_prediction":
168
168
  raise NotImplementedError("DREAM has not been implemented for v-prediction")
169
169
  else:
170
170
  raise ValueError(f"Unknown prediction type {noise_scheduler.config.prediction_type}")
171
171
 
172
- return noisy_latents, target
172
+ return _noisy_latents, _target
173
173
 
174
174
 
175
175
  def unet_lora_state_dict(unet: UNet2DConditionModel) -> Dict[str, torch.Tensor]:
@@ -28,9 +28,11 @@ from .constants import (
28
28
  MIN_PEFT_VERSION,
29
29
  ONNX_EXTERNAL_WEIGHTS_NAME,
30
30
  ONNX_WEIGHTS_NAME,
31
+ SAFE_WEIGHTS_INDEX_NAME,
31
32
  SAFETENSORS_FILE_EXTENSION,
32
33
  SAFETENSORS_WEIGHTS_NAME,
33
34
  USE_PEFT_BACKEND,
35
+ WEIGHTS_INDEX_NAME,
34
36
  WEIGHTS_NAME,
35
37
  )
36
38
  from .deprecation_utils import deprecate
@@ -40,6 +42,7 @@ from .export_utils import export_to_gif, export_to_obj, export_to_ply, export_to
40
42
  from .hub_utils import (
41
43
  PushToHubMixin,
42
44
  _add_variant,
45
+ _get_checkpoint_shard_files,
43
46
  _get_model_file,
44
47
  extract_commit_hash,
45
48
  http_user_agent,
@@ -28,9 +28,11 @@ _CHECK_PEFT = os.environ.get("_CHECK_PEFT", "1") in ENV_VARS_TRUE_VALUES
28
28
 
29
29
  CONFIG_NAME = "config.json"
30
30
  WEIGHTS_NAME = "diffusion_pytorch_model.bin"
31
+ WEIGHTS_INDEX_NAME = "diffusion_pytorch_model.bin.index.json"
31
32
  FLAX_WEIGHTS_NAME = "diffusion_flax_model.msgpack"
32
33
  ONNX_WEIGHTS_NAME = "model.onnx"
33
34
  SAFETENSORS_WEIGHTS_NAME = "diffusion_pytorch_model.safetensors"
35
+ SAFE_WEIGHTS_INDEX_NAME = "diffusion_pytorch_model.safetensors.index.json"
34
36
  SAFETENSORS_FILE_EXTENSION = "safetensors"
35
37
  ONNX_EXTERNAL_WEIGHTS_NAME = "weights.pb"
36
38
  HUGGINGFACE_CO_RESOLVE_ENDPOINT = os.environ.get("HF_ENDPOINT", "https://huggingface.co")
@@ -242,6 +242,51 @@ class PriorTransformer(metaclass=DummyObject):
242
242
  requires_backends(cls, ["torch"])
243
243
 
244
244
 
245
+ class SD3ControlNetModel(metaclass=DummyObject):
246
+ _backends = ["torch"]
247
+
248
+ def __init__(self, *args, **kwargs):
249
+ requires_backends(self, ["torch"])
250
+
251
+ @classmethod
252
+ def from_config(cls, *args, **kwargs):
253
+ requires_backends(cls, ["torch"])
254
+
255
+ @classmethod
256
+ def from_pretrained(cls, *args, **kwargs):
257
+ requires_backends(cls, ["torch"])
258
+
259
+
260
+ class SD3MultiControlNetModel(metaclass=DummyObject):
261
+ _backends = ["torch"]
262
+
263
+ def __init__(self, *args, **kwargs):
264
+ requires_backends(self, ["torch"])
265
+
266
+ @classmethod
267
+ def from_config(cls, *args, **kwargs):
268
+ requires_backends(cls, ["torch"])
269
+
270
+ @classmethod
271
+ def from_pretrained(cls, *args, **kwargs):
272
+ requires_backends(cls, ["torch"])
273
+
274
+
275
+ class SD3Transformer2DModel(metaclass=DummyObject):
276
+ _backends = ["torch"]
277
+
278
+ def __init__(self, *args, **kwargs):
279
+ requires_backends(self, ["torch"])
280
+
281
+ @classmethod
282
+ def from_config(cls, *args, **kwargs):
283
+ requires_backends(cls, ["torch"])
284
+
285
+ @classmethod
286
+ def from_pretrained(cls, *args, **kwargs):
287
+ requires_backends(cls, ["torch"])
288
+
289
+
245
290
  class T2IAdapter(metaclass=DummyObject):
246
291
  _backends = ["torch"]
247
292
 
@@ -1005,6 +1050,21 @@ class EulerDiscreteScheduler(metaclass=DummyObject):
1005
1050
  requires_backends(cls, ["torch"])
1006
1051
 
1007
1052
 
1053
+ class FlowMatchEulerDiscreteScheduler(metaclass=DummyObject):
1054
+ _backends = ["torch"]
1055
+
1056
+ def __init__(self, *args, **kwargs):
1057
+ requires_backends(self, ["torch"])
1058
+
1059
+ @classmethod
1060
+ def from_config(cls, *args, **kwargs):
1061
+ requires_backends(cls, ["torch"])
1062
+
1063
+ @classmethod
1064
+ def from_pretrained(cls, *args, **kwargs):
1065
+ requires_backends(cls, ["torch"])
1066
+
1067
+
1008
1068
  class HeunDiscreteScheduler(metaclass=DummyObject):
1009
1069
  _backends = ["torch"]
1010
1070
 
@@ -902,6 +902,51 @@ class StableCascadePriorPipeline(metaclass=DummyObject):
902
902
  requires_backends(cls, ["torch", "transformers"])
903
903
 
904
904
 
905
+ class StableDiffusion3ControlNetPipeline(metaclass=DummyObject):
906
+ _backends = ["torch", "transformers"]
907
+
908
+ def __init__(self, *args, **kwargs):
909
+ requires_backends(self, ["torch", "transformers"])
910
+
911
+ @classmethod
912
+ def from_config(cls, *args, **kwargs):
913
+ requires_backends(cls, ["torch", "transformers"])
914
+
915
+ @classmethod
916
+ def from_pretrained(cls, *args, **kwargs):
917
+ requires_backends(cls, ["torch", "transformers"])
918
+
919
+
920
+ class StableDiffusion3Img2ImgPipeline(metaclass=DummyObject):
921
+ _backends = ["torch", "transformers"]
922
+
923
+ def __init__(self, *args, **kwargs):
924
+ requires_backends(self, ["torch", "transformers"])
925
+
926
+ @classmethod
927
+ def from_config(cls, *args, **kwargs):
928
+ requires_backends(cls, ["torch", "transformers"])
929
+
930
+ @classmethod
931
+ def from_pretrained(cls, *args, **kwargs):
932
+ requires_backends(cls, ["torch", "transformers"])
933
+
934
+
935
+ class StableDiffusion3Pipeline(metaclass=DummyObject):
936
+ _backends = ["torch", "transformers"]
937
+
938
+ def __init__(self, *args, **kwargs):
939
+ requires_backends(self, ["torch", "transformers"])
940
+
941
+ @classmethod
942
+ def from_config(cls, *args, **kwargs):
943
+ requires_backends(cls, ["torch", "transformers"])
944
+
945
+ @classmethod
946
+ def from_pretrained(cls, *args, **kwargs):
947
+ requires_backends(cls, ["torch", "transformers"])
948
+
949
+
905
950
  class StableDiffusionAdapterPipeline(metaclass=DummyObject):
906
951
  _backends = ["torch", "transformers"]
907
952
 
@@ -25,21 +25,19 @@ from pathlib import Path
25
25
  from typing import Dict, Optional, Union
26
26
  from urllib import request
27
27
 
28
- from huggingface_hub import cached_download, hf_hub_download, model_info
29
- from huggingface_hub.utils import validate_hf_hub_args
28
+ from huggingface_hub import hf_hub_download, model_info
29
+ from huggingface_hub.utils import RevisionNotFoundError, validate_hf_hub_args
30
30
  from packaging import version
31
31
 
32
32
  from .. import __version__
33
33
  from . import DIFFUSERS_DYNAMIC_MODULE_NAME, HF_MODULES_CACHE, logging
34
34
 
35
35
 
36
- COMMUNITY_PIPELINES_URL = (
37
- "https://raw.githubusercontent.com/huggingface/diffusers/{revision}/examples/community/{pipeline}.py"
38
- )
39
-
40
-
41
36
  logger = logging.get_logger(__name__) # pylint: disable=invalid-name
42
37
 
38
+ # See https://huggingface.co/datasets/diffusers/community-pipelines-mirror
39
+ COMMUNITY_PIPELINES_MIRROR_ID = "diffusers/community-pipelines-mirror"
40
+
43
41
 
44
42
  def get_diffusers_versions():
45
43
  url = "https://pypi.org/pypi/diffusers/json"
@@ -281,20 +279,24 @@ def get_cached_module_file(
281
279
  f" {', '.join(available_versions + ['main'])}."
282
280
  )
283
281
 
284
- # community pipeline on GitHub
285
- github_url = COMMUNITY_PIPELINES_URL.format(revision=revision, pipeline=pretrained_model_name_or_path)
286
282
  try:
287
- resolved_module_file = cached_download(
288
- github_url,
283
+ resolved_module_file = hf_hub_download(
284
+ repo_id=COMMUNITY_PIPELINES_MIRROR_ID,
285
+ repo_type="dataset",
286
+ filename=f"{revision}/{pretrained_model_name_or_path}.py",
289
287
  cache_dir=cache_dir,
290
288
  force_download=force_download,
291
289
  proxies=proxies,
292
- resume_download=resume_download,
293
290
  local_files_only=local_files_only,
294
- token=False,
295
291
  )
296
292
  submodule = "git"
297
293
  module_file = pretrained_model_name_or_path + ".py"
294
+ except RevisionNotFoundError as e:
295
+ raise EnvironmentError(
296
+ f"Revision '{revision}' not found in the community pipelines mirror. Check available revisions on"
297
+ " https://huggingface.co/datasets/diffusers/community-pipelines-mirror/tree/main."
298
+ " If you don't find the revision you are looking for, please open an issue on https://github.com/huggingface/diffusers/issues."
299
+ ) from e
298
300
  except EnvironmentError:
299
301
  logger.error(f"Could not locate the {module_file} inside {pretrained_model_name_or_path}.")
300
302
  raise
@@ -14,6 +14,7 @@
14
14
  # limitations under the License.
15
15
 
16
16
 
17
+ import json
17
18
  import os
18
19
  import re
19
20
  import sys
@@ -29,6 +30,8 @@ from huggingface_hub import (
29
30
  ModelCardData,
30
31
  create_repo,
31
32
  hf_hub_download,
33
+ model_info,
34
+ snapshot_download,
32
35
  upload_folder,
33
36
  )
34
37
  from huggingface_hub.constants import HF_HUB_CACHE, HF_HUB_DISABLE_TELEMETRY, HF_HUB_OFFLINE
@@ -393,6 +396,109 @@ def _get_model_file(
393
396
  )
394
397
 
395
398
 
399
+ # Adapted from
400
+ # https://github.com/huggingface/transformers/blob/1360801a69c0b169e3efdbb0cd05d9a0e72bfb70/src/transformers/utils/hub.py#L976
401
+ # Differences are in parallelization of shard downloads and checking if shards are present.
402
+
403
+
404
+ def _check_if_shards_exist_locally(local_dir, subfolder, original_shard_filenames):
405
+ shards_path = os.path.join(local_dir, subfolder)
406
+ shard_filenames = [os.path.join(shards_path, f) for f in original_shard_filenames]
407
+ for shard_file in shard_filenames:
408
+ if not os.path.exists(shard_file):
409
+ raise ValueError(
410
+ f"{shards_path} does not appear to have a file named {shard_file} which is "
411
+ "required according to the checkpoint index."
412
+ )
413
+
414
+
415
+ def _get_checkpoint_shard_files(
416
+ pretrained_model_name_or_path,
417
+ index_filename,
418
+ cache_dir=None,
419
+ proxies=None,
420
+ resume_download=False,
421
+ local_files_only=False,
422
+ token=None,
423
+ user_agent=None,
424
+ revision=None,
425
+ subfolder="",
426
+ ):
427
+ """
428
+ For a given model:
429
+
430
+ - download and cache all the shards of a sharded checkpoint if `pretrained_model_name_or_path` is a model ID on the
431
+ Hub
432
+ - returns the list of paths to all the shards, as well as some metadata.
433
+
434
+ For the description of each arg, see [`PreTrainedModel.from_pretrained`]. `index_filename` is the full path to the
435
+ index (downloaded and cached if `pretrained_model_name_or_path` is a model ID on the Hub).
436
+ """
437
+ if not os.path.isfile(index_filename):
438
+ raise ValueError(f"Can't find a checkpoint index ({index_filename}) in {pretrained_model_name_or_path}.")
439
+
440
+ with open(index_filename, "r") as f:
441
+ index = json.loads(f.read())
442
+
443
+ original_shard_filenames = sorted(set(index["weight_map"].values()))
444
+ sharded_metadata = index["metadata"]
445
+ sharded_metadata["all_checkpoint_keys"] = list(index["weight_map"].keys())
446
+ sharded_metadata["weight_map"] = index["weight_map"].copy()
447
+ shards_path = os.path.join(pretrained_model_name_or_path, subfolder)
448
+
449
+ # First, let's deal with local folder.
450
+ if os.path.isdir(pretrained_model_name_or_path):
451
+ _check_if_shards_exist_locally(
452
+ pretrained_model_name_or_path, subfolder=subfolder, original_shard_filenames=original_shard_filenames
453
+ )
454
+ return pretrained_model_name_or_path, sharded_metadata
455
+
456
+ # At this stage pretrained_model_name_or_path is a model identifier on the Hub
457
+ allow_patterns = original_shard_filenames
458
+ ignore_patterns = ["*.json", "*.md"]
459
+ if not local_files_only:
460
+ # `model_info` call must guarded with the above condition.
461
+ model_files_info = model_info(pretrained_model_name_or_path)
462
+ for shard_file in original_shard_filenames:
463
+ shard_file_present = any(shard_file in k.rfilename for k in model_files_info.siblings)
464
+ if not shard_file_present:
465
+ raise EnvironmentError(
466
+ f"{shards_path} does not appear to have a file named {shard_file} which is "
467
+ "required according to the checkpoint index."
468
+ )
469
+
470
+ try:
471
+ # Load from URL
472
+ cached_folder = snapshot_download(
473
+ pretrained_model_name_or_path,
474
+ cache_dir=cache_dir,
475
+ resume_download=resume_download,
476
+ proxies=proxies,
477
+ local_files_only=local_files_only,
478
+ token=token,
479
+ revision=revision,
480
+ allow_patterns=allow_patterns,
481
+ ignore_patterns=ignore_patterns,
482
+ user_agent=user_agent,
483
+ )
484
+
485
+ # We have already dealt with RepositoryNotFoundError and RevisionNotFoundError when getting the index, so
486
+ # we don't have to catch them here. We have also dealt with EntryNotFoundError.
487
+ except HTTPError as e:
488
+ raise EnvironmentError(
489
+ f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load {pretrained_model_name_or_path}. You should try"
490
+ " again after checking your internet connection."
491
+ ) from e
492
+
493
+ # If `local_files_only=True`, `cached_folder` may not contain all the shard files.
494
+ if local_files_only:
495
+ _check_if_shards_exist_locally(
496
+ local_dir=cache_dir, subfolder=subfolder, original_shard_filenames=original_shard_filenames
497
+ )
498
+
499
+ return cached_folder, sharded_metadata
500
+
501
+
396
502
  class PushToHubMixin:
397
503
  """
398
504
  A Mixin to push a model, scheduler, or pipeline to the Hugging Face Hub.
@@ -131,7 +131,6 @@ try:
131
131
  except importlib_metadata.PackageNotFoundError:
132
132
  _unidecode_available = False
133
133
 
134
-
135
134
  _onnxruntime_version = "N/A"
136
135
  _onnx_available = importlib.util.find_spec("onnxruntime") is not None
137
136
  if _onnx_available:
@@ -82,7 +82,9 @@ def _configure_library_root_logger() -> None:
82
82
  # This library has already configured the library root logger.
83
83
  return
84
84
  _default_handler = logging.StreamHandler() # Set sys.stderr as stream.
85
- _default_handler.flush = sys.stderr.flush
85
+
86
+ if sys.stderr: # only if sys.stderr exists, e.g. when not using pythonw in windows
87
+ _default_handler.flush = sys.stderr.flush
86
88
 
87
89
  # Apply our default configuration to the library root logger.
88
90
  library_root_logger = _get_library_root_logger()
@@ -62,6 +62,8 @@ DIFFUSERS_TO_PEFT = {
62
62
  ".out_proj.lora_linear_layer.down": ".out_proj.lora_A",
63
63
  ".lora_linear_layer.up": ".lora_B",
64
64
  ".lora_linear_layer.down": ".lora_A",
65
+ "text_projection.lora.down.weight": "text_projection.lora_A.weight",
66
+ "text_projection.lora.up.weight": "text_projection.lora_B.weight",
65
67
  }
66
68
 
67
69
  DIFFUSERS_OLD_TO_PEFT = {
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: diffusers
3
- Version: 0.28.2
3
+ Version: 0.29.1
4
4
  Summary: State-of-the-art diffusion in PyTorch and JAX.
5
5
  Home-page: https://github.com/huggingface/diffusers
6
6
  Author: The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/diffusers/graphs/contributors)
7
- Author-email: patrick@huggingface.co
7
+ Author-email: diffusers@huggingface.co
8
8
  License: Apache 2.0 License
9
9
  Keywords: deep learning diffusion jax pytorch stable diffusion audioldm
10
10
  Classifier: Development Status :: 5 - Production/Stable
@@ -23,7 +23,7 @@ Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
24
  Requires-Dist: importlib-metadata
25
25
  Requires-Dist: filelock
26
- Requires-Dist: huggingface-hub >=0.20.2
26
+ Requires-Dist: huggingface-hub >=0.23.2
27
27
  Requires-Dist: numpy
28
28
  Requires-Dist: regex !=2019.12.17
29
29
  Requires-Dist: requests