diffusers 0.29.2__py3-none-any.whl → 0.30.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- diffusers/__init__.py +94 -3
- diffusers/commands/env.py +1 -5
- diffusers/configuration_utils.py +4 -9
- diffusers/dependency_versions_table.py +2 -2
- diffusers/image_processor.py +1 -2
- diffusers/loaders/__init__.py +17 -2
- diffusers/loaders/ip_adapter.py +10 -7
- diffusers/loaders/lora_base.py +752 -0
- diffusers/loaders/lora_pipeline.py +2222 -0
- diffusers/loaders/peft.py +213 -5
- diffusers/loaders/single_file.py +1 -12
- diffusers/loaders/single_file_model.py +31 -10
- diffusers/loaders/single_file_utils.py +262 -2
- diffusers/loaders/textual_inversion.py +1 -6
- diffusers/loaders/unet.py +23 -208
- diffusers/models/__init__.py +20 -0
- diffusers/models/activations.py +22 -0
- diffusers/models/attention.py +386 -7
- diffusers/models/attention_processor.py +1795 -629
- diffusers/models/autoencoders/__init__.py +2 -0
- diffusers/models/autoencoders/autoencoder_kl.py +14 -3
- diffusers/models/autoencoders/autoencoder_kl_cogvideox.py +1035 -0
- diffusers/models/autoencoders/autoencoder_kl_temporal_decoder.py +1 -1
- diffusers/models/autoencoders/autoencoder_oobleck.py +464 -0
- diffusers/models/autoencoders/autoencoder_tiny.py +1 -0
- diffusers/models/autoencoders/consistency_decoder_vae.py +1 -1
- diffusers/models/autoencoders/vq_model.py +4 -4
- diffusers/models/controlnet.py +2 -3
- diffusers/models/controlnet_hunyuan.py +401 -0
- diffusers/models/controlnet_sd3.py +11 -11
- diffusers/models/controlnet_sparsectrl.py +789 -0
- diffusers/models/controlnet_xs.py +40 -10
- diffusers/models/downsampling.py +68 -0
- diffusers/models/embeddings.py +319 -36
- diffusers/models/model_loading_utils.py +1 -3
- diffusers/models/modeling_flax_utils.py +1 -6
- diffusers/models/modeling_utils.py +4 -16
- diffusers/models/normalization.py +203 -12
- diffusers/models/transformers/__init__.py +6 -0
- diffusers/models/transformers/auraflow_transformer_2d.py +527 -0
- diffusers/models/transformers/cogvideox_transformer_3d.py +345 -0
- diffusers/models/transformers/hunyuan_transformer_2d.py +19 -15
- diffusers/models/transformers/latte_transformer_3d.py +327 -0
- diffusers/models/transformers/lumina_nextdit2d.py +340 -0
- diffusers/models/transformers/pixart_transformer_2d.py +102 -1
- diffusers/models/transformers/prior_transformer.py +1 -1
- diffusers/models/transformers/stable_audio_transformer.py +458 -0
- diffusers/models/transformers/transformer_flux.py +455 -0
- diffusers/models/transformers/transformer_sd3.py +18 -4
- diffusers/models/unets/unet_1d_blocks.py +1 -1
- diffusers/models/unets/unet_2d_condition.py +8 -1
- diffusers/models/unets/unet_3d_blocks.py +51 -920
- diffusers/models/unets/unet_3d_condition.py +4 -1
- diffusers/models/unets/unet_i2vgen_xl.py +4 -1
- diffusers/models/unets/unet_kandinsky3.py +1 -1
- diffusers/models/unets/unet_motion_model.py +1330 -84
- diffusers/models/unets/unet_spatio_temporal_condition.py +1 -1
- diffusers/models/unets/unet_stable_cascade.py +1 -3
- diffusers/models/unets/uvit_2d.py +1 -1
- diffusers/models/upsampling.py +64 -0
- diffusers/models/vq_model.py +8 -4
- diffusers/optimization.py +1 -1
- diffusers/pipelines/__init__.py +100 -3
- diffusers/pipelines/animatediff/__init__.py +4 -0
- diffusers/pipelines/animatediff/pipeline_animatediff.py +50 -40
- diffusers/pipelines/animatediff/pipeline_animatediff_controlnet.py +1076 -0
- diffusers/pipelines/animatediff/pipeline_animatediff_sdxl.py +17 -27
- diffusers/pipelines/animatediff/pipeline_animatediff_sparsectrl.py +1008 -0
- diffusers/pipelines/animatediff/pipeline_animatediff_video2video.py +51 -38
- diffusers/pipelines/audioldm2/modeling_audioldm2.py +1 -1
- diffusers/pipelines/audioldm2/pipeline_audioldm2.py +1 -0
- diffusers/pipelines/aura_flow/__init__.py +48 -0
- diffusers/pipelines/aura_flow/pipeline_aura_flow.py +591 -0
- diffusers/pipelines/auto_pipeline.py +97 -19
- diffusers/pipelines/cogvideo/__init__.py +48 -0
- diffusers/pipelines/cogvideo/pipeline_cogvideox.py +687 -0
- diffusers/pipelines/consistency_models/pipeline_consistency_models.py +1 -1
- diffusers/pipelines/controlnet/pipeline_controlnet.py +24 -30
- diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +31 -30
- diffusers/pipelines/controlnet/pipeline_controlnet_inpaint.py +24 -153
- diffusers/pipelines/controlnet/pipeline_controlnet_inpaint_sd_xl.py +19 -28
- diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +18 -28
- diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py +29 -32
- diffusers/pipelines/controlnet/pipeline_flax_controlnet.py +2 -2
- diffusers/pipelines/controlnet_hunyuandit/__init__.py +48 -0
- diffusers/pipelines/controlnet_hunyuandit/pipeline_hunyuandit_controlnet.py +1042 -0
- diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet.py +35 -0
- diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs.py +10 -6
- diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs_sd_xl.py +0 -4
- diffusers/pipelines/deepfloyd_if/pipeline_if.py +2 -2
- diffusers/pipelines/deepfloyd_if/pipeline_if_img2img.py +2 -2
- diffusers/pipelines/deepfloyd_if/pipeline_if_img2img_superresolution.py +2 -2
- diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting.py +2 -2
- diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting_superresolution.py +2 -2
- diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py +2 -2
- diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion.py +11 -6
- diffusers/pipelines/deprecated/alt_diffusion/pipeline_alt_diffusion_img2img.py +11 -6
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_cycle_diffusion.py +6 -6
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_inpaint_legacy.py +6 -6
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_model_editing.py +10 -10
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_paradigms.py +10 -6
- diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_stable_diffusion_pix2pix_zero.py +3 -3
- diffusers/pipelines/deprecated/versatile_diffusion/modeling_text_unet.py +1 -1
- diffusers/pipelines/flux/__init__.py +47 -0
- diffusers/pipelines/flux/pipeline_flux.py +749 -0
- diffusers/pipelines/flux/pipeline_output.py +21 -0
- diffusers/pipelines/free_init_utils.py +2 -0
- diffusers/pipelines/free_noise_utils.py +236 -0
- diffusers/pipelines/kandinsky3/pipeline_kandinsky3.py +2 -2
- diffusers/pipelines/kandinsky3/pipeline_kandinsky3_img2img.py +2 -2
- diffusers/pipelines/kolors/__init__.py +54 -0
- diffusers/pipelines/kolors/pipeline_kolors.py +1070 -0
- diffusers/pipelines/kolors/pipeline_kolors_img2img.py +1247 -0
- diffusers/pipelines/kolors/pipeline_output.py +21 -0
- diffusers/pipelines/kolors/text_encoder.py +889 -0
- diffusers/pipelines/kolors/tokenizer.py +334 -0
- diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_img2img.py +30 -29
- diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_text2img.py +23 -29
- diffusers/pipelines/latte/__init__.py +48 -0
- diffusers/pipelines/latte/pipeline_latte.py +881 -0
- diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py +4 -4
- diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion_xl.py +0 -4
- diffusers/pipelines/lumina/__init__.py +48 -0
- diffusers/pipelines/lumina/pipeline_lumina.py +897 -0
- diffusers/pipelines/pag/__init__.py +67 -0
- diffusers/pipelines/pag/pag_utils.py +237 -0
- diffusers/pipelines/pag/pipeline_pag_controlnet_sd.py +1329 -0
- diffusers/pipelines/pag/pipeline_pag_controlnet_sd_xl.py +1612 -0
- diffusers/pipelines/pag/pipeline_pag_hunyuandit.py +953 -0
- diffusers/pipelines/pag/pipeline_pag_kolors.py +1136 -0
- diffusers/pipelines/pag/pipeline_pag_pixart_sigma.py +872 -0
- diffusers/pipelines/pag/pipeline_pag_sd.py +1050 -0
- diffusers/pipelines/pag/pipeline_pag_sd_3.py +985 -0
- diffusers/pipelines/pag/pipeline_pag_sd_animatediff.py +862 -0
- diffusers/pipelines/pag/pipeline_pag_sd_xl.py +1333 -0
- diffusers/pipelines/pag/pipeline_pag_sd_xl_img2img.py +1529 -0
- diffusers/pipelines/pag/pipeline_pag_sd_xl_inpaint.py +1753 -0
- diffusers/pipelines/pia/pipeline_pia.py +30 -37
- diffusers/pipelines/pipeline_flax_utils.py +4 -9
- diffusers/pipelines/pipeline_loading_utils.py +0 -3
- diffusers/pipelines/pipeline_utils.py +2 -14
- diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py +0 -1
- diffusers/pipelines/stable_audio/__init__.py +50 -0
- diffusers/pipelines/stable_audio/modeling_stable_audio.py +158 -0
- diffusers/pipelines/stable_audio/pipeline_stable_audio.py +745 -0
- diffusers/pipelines/stable_diffusion/convert_from_ckpt.py +2 -0
- diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion.py +1 -1
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +23 -29
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py +15 -8
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +30 -29
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +23 -152
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py +8 -4
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py +11 -11
- diffusers/pipelines/stable_diffusion/pipeline_stable_unclip.py +8 -6
- diffusers/pipelines/stable_diffusion/pipeline_stable_unclip_img2img.py +6 -6
- diffusers/pipelines/stable_diffusion_3/__init__.py +2 -0
- diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3.py +34 -3
- diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_img2img.py +33 -7
- diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_inpaint.py +1201 -0
- diffusers/pipelines/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py +3 -3
- diffusers/pipelines/stable_diffusion_diffedit/pipeline_stable_diffusion_diffedit.py +6 -6
- diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen.py +5 -5
- diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen_text_image.py +5 -5
- diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_k_diffusion.py +6 -6
- diffusers/pipelines/stable_diffusion_k_diffusion/pipeline_stable_diffusion_xl_k_diffusion.py +0 -4
- diffusers/pipelines/stable_diffusion_ldm3d/pipeline_stable_diffusion_ldm3d.py +23 -29
- diffusers/pipelines/stable_diffusion_panorama/pipeline_stable_diffusion_panorama.py +27 -29
- diffusers/pipelines/stable_diffusion_sag/pipeline_stable_diffusion_sag.py +3 -3
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +17 -27
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +26 -29
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py +17 -145
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_instruct_pix2pix.py +0 -4
- diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_adapter.py +6 -6
- diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_xl_adapter.py +18 -28
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth.py +8 -6
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth_img2img.py +8 -6
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero.py +6 -4
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero_sdxl.py +0 -4
- diffusers/pipelines/unidiffuser/pipeline_unidiffuser.py +3 -3
- diffusers/pipelines/wuerstchen/modeling_wuerstchen_prior.py +1 -1
- diffusers/pipelines/wuerstchen/pipeline_wuerstchen_prior.py +5 -4
- diffusers/schedulers/__init__.py +8 -0
- diffusers/schedulers/scheduling_cosine_dpmsolver_multistep.py +572 -0
- diffusers/schedulers/scheduling_ddim.py +1 -1
- diffusers/schedulers/scheduling_ddim_cogvideox.py +449 -0
- diffusers/schedulers/scheduling_ddpm.py +1 -1
- diffusers/schedulers/scheduling_ddpm_parallel.py +1 -1
- diffusers/schedulers/scheduling_deis_multistep.py +2 -2
- diffusers/schedulers/scheduling_dpm_cogvideox.py +489 -0
- diffusers/schedulers/scheduling_dpmsolver_multistep.py +1 -1
- diffusers/schedulers/scheduling_dpmsolver_multistep_inverse.py +1 -1
- diffusers/schedulers/scheduling_dpmsolver_singlestep.py +64 -19
- diffusers/schedulers/scheduling_edm_dpmsolver_multistep.py +2 -2
- diffusers/schedulers/scheduling_flow_match_euler_discrete.py +63 -39
- diffusers/schedulers/scheduling_flow_match_heun_discrete.py +321 -0
- diffusers/schedulers/scheduling_ipndm.py +1 -1
- diffusers/schedulers/scheduling_unipc_multistep.py +1 -1
- diffusers/schedulers/scheduling_utils.py +1 -3
- diffusers/schedulers/scheduling_utils_flax.py +1 -3
- diffusers/training_utils.py +99 -14
- diffusers/utils/__init__.py +2 -2
- diffusers/utils/dummy_pt_objects.py +210 -0
- diffusers/utils/dummy_torch_and_torchsde_objects.py +15 -0
- diffusers/utils/dummy_torch_and_transformers_and_sentencepiece_objects.py +47 -0
- diffusers/utils/dummy_torch_and_transformers_objects.py +315 -0
- diffusers/utils/dynamic_modules_utils.py +1 -11
- diffusers/utils/export_utils.py +1 -4
- diffusers/utils/hub_utils.py +45 -42
- diffusers/utils/import_utils.py +19 -16
- diffusers/utils/loading_utils.py +76 -3
- diffusers/utils/testing_utils.py +11 -8
- {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/METADATA +73 -83
- {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/RECORD +217 -164
- {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/WHEEL +1 -1
- diffusers/loaders/autoencoder.py +0 -146
- diffusers/loaders/controlnet.py +0 -136
- diffusers/loaders/lora.py +0 -1728
- {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/LICENSE +0 -0
- {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/entry_points.txt +0 -0
- {diffusers-0.29.2.dist-info → diffusers-0.30.0.dist-info}/top_level.txt +0 -0
@@ -77,6 +77,36 @@ class AmusedPipeline(metaclass=DummyObject):
|
|
77
77
|
requires_backends(cls, ["torch", "transformers"])
|
78
78
|
|
79
79
|
|
80
|
+
class AnimateDiffControlNetPipeline(metaclass=DummyObject):
|
81
|
+
_backends = ["torch", "transformers"]
|
82
|
+
|
83
|
+
def __init__(self, *args, **kwargs):
|
84
|
+
requires_backends(self, ["torch", "transformers"])
|
85
|
+
|
86
|
+
@classmethod
|
87
|
+
def from_config(cls, *args, **kwargs):
|
88
|
+
requires_backends(cls, ["torch", "transformers"])
|
89
|
+
|
90
|
+
@classmethod
|
91
|
+
def from_pretrained(cls, *args, **kwargs):
|
92
|
+
requires_backends(cls, ["torch", "transformers"])
|
93
|
+
|
94
|
+
|
95
|
+
class AnimateDiffPAGPipeline(metaclass=DummyObject):
|
96
|
+
_backends = ["torch", "transformers"]
|
97
|
+
|
98
|
+
def __init__(self, *args, **kwargs):
|
99
|
+
requires_backends(self, ["torch", "transformers"])
|
100
|
+
|
101
|
+
@classmethod
|
102
|
+
def from_config(cls, *args, **kwargs):
|
103
|
+
requires_backends(cls, ["torch", "transformers"])
|
104
|
+
|
105
|
+
@classmethod
|
106
|
+
def from_pretrained(cls, *args, **kwargs):
|
107
|
+
requires_backends(cls, ["torch", "transformers"])
|
108
|
+
|
109
|
+
|
80
110
|
class AnimateDiffPipeline(metaclass=DummyObject):
|
81
111
|
_backends = ["torch", "transformers"]
|
82
112
|
|
@@ -107,6 +137,21 @@ class AnimateDiffSDXLPipeline(metaclass=DummyObject):
|
|
107
137
|
requires_backends(cls, ["torch", "transformers"])
|
108
138
|
|
109
139
|
|
140
|
+
class AnimateDiffSparseControlNetPipeline(metaclass=DummyObject):
|
141
|
+
_backends = ["torch", "transformers"]
|
142
|
+
|
143
|
+
def __init__(self, *args, **kwargs):
|
144
|
+
requires_backends(self, ["torch", "transformers"])
|
145
|
+
|
146
|
+
@classmethod
|
147
|
+
def from_config(cls, *args, **kwargs):
|
148
|
+
requires_backends(cls, ["torch", "transformers"])
|
149
|
+
|
150
|
+
@classmethod
|
151
|
+
def from_pretrained(cls, *args, **kwargs):
|
152
|
+
requires_backends(cls, ["torch", "transformers"])
|
153
|
+
|
154
|
+
|
110
155
|
class AnimateDiffVideoToVideoPipeline(metaclass=DummyObject):
|
111
156
|
_backends = ["torch", "transformers"]
|
112
157
|
|
@@ -182,6 +227,21 @@ class AudioLDMPipeline(metaclass=DummyObject):
|
|
182
227
|
requires_backends(cls, ["torch", "transformers"])
|
183
228
|
|
184
229
|
|
230
|
+
class AuraFlowPipeline(metaclass=DummyObject):
|
231
|
+
_backends = ["torch", "transformers"]
|
232
|
+
|
233
|
+
def __init__(self, *args, **kwargs):
|
234
|
+
requires_backends(self, ["torch", "transformers"])
|
235
|
+
|
236
|
+
@classmethod
|
237
|
+
def from_config(cls, *args, **kwargs):
|
238
|
+
requires_backends(cls, ["torch", "transformers"])
|
239
|
+
|
240
|
+
@classmethod
|
241
|
+
def from_pretrained(cls, *args, **kwargs):
|
242
|
+
requires_backends(cls, ["torch", "transformers"])
|
243
|
+
|
244
|
+
|
185
245
|
class CLIPImageProjection(metaclass=DummyObject):
|
186
246
|
_backends = ["torch", "transformers"]
|
187
247
|
|
@@ -197,6 +257,21 @@ class CLIPImageProjection(metaclass=DummyObject):
|
|
197
257
|
requires_backends(cls, ["torch", "transformers"])
|
198
258
|
|
199
259
|
|
260
|
+
class CogVideoXPipeline(metaclass=DummyObject):
|
261
|
+
_backends = ["torch", "transformers"]
|
262
|
+
|
263
|
+
def __init__(self, *args, **kwargs):
|
264
|
+
requires_backends(self, ["torch", "transformers"])
|
265
|
+
|
266
|
+
@classmethod
|
267
|
+
def from_config(cls, *args, **kwargs):
|
268
|
+
requires_backends(cls, ["torch", "transformers"])
|
269
|
+
|
270
|
+
@classmethod
|
271
|
+
def from_pretrained(cls, *args, **kwargs):
|
272
|
+
requires_backends(cls, ["torch", "transformers"])
|
273
|
+
|
274
|
+
|
200
275
|
class CycleDiffusionPipeline(metaclass=DummyObject):
|
201
276
|
_backends = ["torch", "transformers"]
|
202
277
|
|
@@ -212,6 +287,51 @@ class CycleDiffusionPipeline(metaclass=DummyObject):
|
|
212
287
|
requires_backends(cls, ["torch", "transformers"])
|
213
288
|
|
214
289
|
|
290
|
+
class FluxPipeline(metaclass=DummyObject):
|
291
|
+
_backends = ["torch", "transformers"]
|
292
|
+
|
293
|
+
def __init__(self, *args, **kwargs):
|
294
|
+
requires_backends(self, ["torch", "transformers"])
|
295
|
+
|
296
|
+
@classmethod
|
297
|
+
def from_config(cls, *args, **kwargs):
|
298
|
+
requires_backends(cls, ["torch", "transformers"])
|
299
|
+
|
300
|
+
@classmethod
|
301
|
+
def from_pretrained(cls, *args, **kwargs):
|
302
|
+
requires_backends(cls, ["torch", "transformers"])
|
303
|
+
|
304
|
+
|
305
|
+
class HunyuanDiTControlNetPipeline(metaclass=DummyObject):
|
306
|
+
_backends = ["torch", "transformers"]
|
307
|
+
|
308
|
+
def __init__(self, *args, **kwargs):
|
309
|
+
requires_backends(self, ["torch", "transformers"])
|
310
|
+
|
311
|
+
@classmethod
|
312
|
+
def from_config(cls, *args, **kwargs):
|
313
|
+
requires_backends(cls, ["torch", "transformers"])
|
314
|
+
|
315
|
+
@classmethod
|
316
|
+
def from_pretrained(cls, *args, **kwargs):
|
317
|
+
requires_backends(cls, ["torch", "transformers"])
|
318
|
+
|
319
|
+
|
320
|
+
class HunyuanDiTPAGPipeline(metaclass=DummyObject):
|
321
|
+
_backends = ["torch", "transformers"]
|
322
|
+
|
323
|
+
def __init__(self, *args, **kwargs):
|
324
|
+
requires_backends(self, ["torch", "transformers"])
|
325
|
+
|
326
|
+
@classmethod
|
327
|
+
def from_config(cls, *args, **kwargs):
|
328
|
+
requires_backends(cls, ["torch", "transformers"])
|
329
|
+
|
330
|
+
@classmethod
|
331
|
+
def from_pretrained(cls, *args, **kwargs):
|
332
|
+
requires_backends(cls, ["torch", "transformers"])
|
333
|
+
|
334
|
+
|
215
335
|
class HunyuanDiTPipeline(metaclass=DummyObject):
|
216
336
|
_backends = ["torch", "transformers"]
|
217
337
|
|
@@ -662,6 +782,21 @@ class LatentConsistencyModelPipeline(metaclass=DummyObject):
|
|
662
782
|
requires_backends(cls, ["torch", "transformers"])
|
663
783
|
|
664
784
|
|
785
|
+
class LattePipeline(metaclass=DummyObject):
|
786
|
+
_backends = ["torch", "transformers"]
|
787
|
+
|
788
|
+
def __init__(self, *args, **kwargs):
|
789
|
+
requires_backends(self, ["torch", "transformers"])
|
790
|
+
|
791
|
+
@classmethod
|
792
|
+
def from_config(cls, *args, **kwargs):
|
793
|
+
requires_backends(cls, ["torch", "transformers"])
|
794
|
+
|
795
|
+
@classmethod
|
796
|
+
def from_pretrained(cls, *args, **kwargs):
|
797
|
+
requires_backends(cls, ["torch", "transformers"])
|
798
|
+
|
799
|
+
|
665
800
|
class LDMTextToImagePipeline(metaclass=DummyObject):
|
666
801
|
_backends = ["torch", "transformers"]
|
667
802
|
|
@@ -707,6 +842,21 @@ class LEditsPPPipelineStableDiffusionXL(metaclass=DummyObject):
|
|
707
842
|
requires_backends(cls, ["torch", "transformers"])
|
708
843
|
|
709
844
|
|
845
|
+
class LuminaText2ImgPipeline(metaclass=DummyObject):
|
846
|
+
_backends = ["torch", "transformers"]
|
847
|
+
|
848
|
+
def __init__(self, *args, **kwargs):
|
849
|
+
requires_backends(self, ["torch", "transformers"])
|
850
|
+
|
851
|
+
@classmethod
|
852
|
+
def from_config(cls, *args, **kwargs):
|
853
|
+
requires_backends(cls, ["torch", "transformers"])
|
854
|
+
|
855
|
+
@classmethod
|
856
|
+
def from_pretrained(cls, *args, **kwargs):
|
857
|
+
requires_backends(cls, ["torch", "transformers"])
|
858
|
+
|
859
|
+
|
710
860
|
class MarigoldDepthPipeline(metaclass=DummyObject):
|
711
861
|
_backends = ["torch", "transformers"]
|
712
862
|
|
@@ -797,6 +947,21 @@ class PixArtAlphaPipeline(metaclass=DummyObject):
|
|
797
947
|
requires_backends(cls, ["torch", "transformers"])
|
798
948
|
|
799
949
|
|
950
|
+
class PixArtSigmaPAGPipeline(metaclass=DummyObject):
|
951
|
+
_backends = ["torch", "transformers"]
|
952
|
+
|
953
|
+
def __init__(self, *args, **kwargs):
|
954
|
+
requires_backends(self, ["torch", "transformers"])
|
955
|
+
|
956
|
+
@classmethod
|
957
|
+
def from_config(cls, *args, **kwargs):
|
958
|
+
requires_backends(cls, ["torch", "transformers"])
|
959
|
+
|
960
|
+
@classmethod
|
961
|
+
def from_pretrained(cls, *args, **kwargs):
|
962
|
+
requires_backends(cls, ["torch", "transformers"])
|
963
|
+
|
964
|
+
|
800
965
|
class PixArtSigmaPipeline(metaclass=DummyObject):
|
801
966
|
_backends = ["torch", "transformers"]
|
802
967
|
|
@@ -857,6 +1022,36 @@ class ShapEPipeline(metaclass=DummyObject):
|
|
857
1022
|
requires_backends(cls, ["torch", "transformers"])
|
858
1023
|
|
859
1024
|
|
1025
|
+
class StableAudioPipeline(metaclass=DummyObject):
|
1026
|
+
_backends = ["torch", "transformers"]
|
1027
|
+
|
1028
|
+
def __init__(self, *args, **kwargs):
|
1029
|
+
requires_backends(self, ["torch", "transformers"])
|
1030
|
+
|
1031
|
+
@classmethod
|
1032
|
+
def from_config(cls, *args, **kwargs):
|
1033
|
+
requires_backends(cls, ["torch", "transformers"])
|
1034
|
+
|
1035
|
+
@classmethod
|
1036
|
+
def from_pretrained(cls, *args, **kwargs):
|
1037
|
+
requires_backends(cls, ["torch", "transformers"])
|
1038
|
+
|
1039
|
+
|
1040
|
+
class StableAudioProjectionModel(metaclass=DummyObject):
|
1041
|
+
_backends = ["torch", "transformers"]
|
1042
|
+
|
1043
|
+
def __init__(self, *args, **kwargs):
|
1044
|
+
requires_backends(self, ["torch", "transformers"])
|
1045
|
+
|
1046
|
+
@classmethod
|
1047
|
+
def from_config(cls, *args, **kwargs):
|
1048
|
+
requires_backends(cls, ["torch", "transformers"])
|
1049
|
+
|
1050
|
+
@classmethod
|
1051
|
+
def from_pretrained(cls, *args, **kwargs):
|
1052
|
+
requires_backends(cls, ["torch", "transformers"])
|
1053
|
+
|
1054
|
+
|
860
1055
|
class StableCascadeCombinedPipeline(metaclass=DummyObject):
|
861
1056
|
_backends = ["torch", "transformers"]
|
862
1057
|
|
@@ -932,6 +1127,36 @@ class StableDiffusion3Img2ImgPipeline(metaclass=DummyObject):
|
|
932
1127
|
requires_backends(cls, ["torch", "transformers"])
|
933
1128
|
|
934
1129
|
|
1130
|
+
class StableDiffusion3InpaintPipeline(metaclass=DummyObject):
|
1131
|
+
_backends = ["torch", "transformers"]
|
1132
|
+
|
1133
|
+
def __init__(self, *args, **kwargs):
|
1134
|
+
requires_backends(self, ["torch", "transformers"])
|
1135
|
+
|
1136
|
+
@classmethod
|
1137
|
+
def from_config(cls, *args, **kwargs):
|
1138
|
+
requires_backends(cls, ["torch", "transformers"])
|
1139
|
+
|
1140
|
+
@classmethod
|
1141
|
+
def from_pretrained(cls, *args, **kwargs):
|
1142
|
+
requires_backends(cls, ["torch", "transformers"])
|
1143
|
+
|
1144
|
+
|
1145
|
+
class StableDiffusion3PAGPipeline(metaclass=DummyObject):
|
1146
|
+
_backends = ["torch", "transformers"]
|
1147
|
+
|
1148
|
+
def __init__(self, *args, **kwargs):
|
1149
|
+
requires_backends(self, ["torch", "transformers"])
|
1150
|
+
|
1151
|
+
@classmethod
|
1152
|
+
def from_config(cls, *args, **kwargs):
|
1153
|
+
requires_backends(cls, ["torch", "transformers"])
|
1154
|
+
|
1155
|
+
@classmethod
|
1156
|
+
def from_pretrained(cls, *args, **kwargs):
|
1157
|
+
requires_backends(cls, ["torch", "transformers"])
|
1158
|
+
|
1159
|
+
|
935
1160
|
class StableDiffusion3Pipeline(metaclass=DummyObject):
|
936
1161
|
_backends = ["torch", "transformers"]
|
937
1162
|
|
@@ -1007,6 +1232,21 @@ class StableDiffusionControlNetInpaintPipeline(metaclass=DummyObject):
|
|
1007
1232
|
requires_backends(cls, ["torch", "transformers"])
|
1008
1233
|
|
1009
1234
|
|
1235
|
+
class StableDiffusionControlNetPAGPipeline(metaclass=DummyObject):
|
1236
|
+
_backends = ["torch", "transformers"]
|
1237
|
+
|
1238
|
+
def __init__(self, *args, **kwargs):
|
1239
|
+
requires_backends(self, ["torch", "transformers"])
|
1240
|
+
|
1241
|
+
@classmethod
|
1242
|
+
def from_config(cls, *args, **kwargs):
|
1243
|
+
requires_backends(cls, ["torch", "transformers"])
|
1244
|
+
|
1245
|
+
@classmethod
|
1246
|
+
def from_pretrained(cls, *args, **kwargs):
|
1247
|
+
requires_backends(cls, ["torch", "transformers"])
|
1248
|
+
|
1249
|
+
|
1010
1250
|
class StableDiffusionControlNetPipeline(metaclass=DummyObject):
|
1011
1251
|
_backends = ["torch", "transformers"]
|
1012
1252
|
|
@@ -1217,6 +1457,21 @@ class StableDiffusionModelEditingPipeline(metaclass=DummyObject):
|
|
1217
1457
|
requires_backends(cls, ["torch", "transformers"])
|
1218
1458
|
|
1219
1459
|
|
1460
|
+
class StableDiffusionPAGPipeline(metaclass=DummyObject):
|
1461
|
+
_backends = ["torch", "transformers"]
|
1462
|
+
|
1463
|
+
def __init__(self, *args, **kwargs):
|
1464
|
+
requires_backends(self, ["torch", "transformers"])
|
1465
|
+
|
1466
|
+
@classmethod
|
1467
|
+
def from_config(cls, *args, **kwargs):
|
1468
|
+
requires_backends(cls, ["torch", "transformers"])
|
1469
|
+
|
1470
|
+
@classmethod
|
1471
|
+
def from_pretrained(cls, *args, **kwargs):
|
1472
|
+
requires_backends(cls, ["torch", "transformers"])
|
1473
|
+
|
1474
|
+
|
1220
1475
|
class StableDiffusionPanoramaPipeline(metaclass=DummyObject):
|
1221
1476
|
_backends = ["torch", "transformers"]
|
1222
1477
|
|
@@ -1367,6 +1622,21 @@ class StableDiffusionXLControlNetInpaintPipeline(metaclass=DummyObject):
|
|
1367
1622
|
requires_backends(cls, ["torch", "transformers"])
|
1368
1623
|
|
1369
1624
|
|
1625
|
+
class StableDiffusionXLControlNetPAGPipeline(metaclass=DummyObject):
|
1626
|
+
_backends = ["torch", "transformers"]
|
1627
|
+
|
1628
|
+
def __init__(self, *args, **kwargs):
|
1629
|
+
requires_backends(self, ["torch", "transformers"])
|
1630
|
+
|
1631
|
+
@classmethod
|
1632
|
+
def from_config(cls, *args, **kwargs):
|
1633
|
+
requires_backends(cls, ["torch", "transformers"])
|
1634
|
+
|
1635
|
+
@classmethod
|
1636
|
+
def from_pretrained(cls, *args, **kwargs):
|
1637
|
+
requires_backends(cls, ["torch", "transformers"])
|
1638
|
+
|
1639
|
+
|
1370
1640
|
class StableDiffusionXLControlNetPipeline(metaclass=DummyObject):
|
1371
1641
|
_backends = ["torch", "transformers"]
|
1372
1642
|
|
@@ -1442,6 +1712,51 @@ class StableDiffusionXLInstructPix2PixPipeline(metaclass=DummyObject):
|
|
1442
1712
|
requires_backends(cls, ["torch", "transformers"])
|
1443
1713
|
|
1444
1714
|
|
1715
|
+
class StableDiffusionXLPAGImg2ImgPipeline(metaclass=DummyObject):
|
1716
|
+
_backends = ["torch", "transformers"]
|
1717
|
+
|
1718
|
+
def __init__(self, *args, **kwargs):
|
1719
|
+
requires_backends(self, ["torch", "transformers"])
|
1720
|
+
|
1721
|
+
@classmethod
|
1722
|
+
def from_config(cls, *args, **kwargs):
|
1723
|
+
requires_backends(cls, ["torch", "transformers"])
|
1724
|
+
|
1725
|
+
@classmethod
|
1726
|
+
def from_pretrained(cls, *args, **kwargs):
|
1727
|
+
requires_backends(cls, ["torch", "transformers"])
|
1728
|
+
|
1729
|
+
|
1730
|
+
class StableDiffusionXLPAGInpaintPipeline(metaclass=DummyObject):
|
1731
|
+
_backends = ["torch", "transformers"]
|
1732
|
+
|
1733
|
+
def __init__(self, *args, **kwargs):
|
1734
|
+
requires_backends(self, ["torch", "transformers"])
|
1735
|
+
|
1736
|
+
@classmethod
|
1737
|
+
def from_config(cls, *args, **kwargs):
|
1738
|
+
requires_backends(cls, ["torch", "transformers"])
|
1739
|
+
|
1740
|
+
@classmethod
|
1741
|
+
def from_pretrained(cls, *args, **kwargs):
|
1742
|
+
requires_backends(cls, ["torch", "transformers"])
|
1743
|
+
|
1744
|
+
|
1745
|
+
class StableDiffusionXLPAGPipeline(metaclass=DummyObject):
|
1746
|
+
_backends = ["torch", "transformers"]
|
1747
|
+
|
1748
|
+
def __init__(self, *args, **kwargs):
|
1749
|
+
requires_backends(self, ["torch", "transformers"])
|
1750
|
+
|
1751
|
+
@classmethod
|
1752
|
+
def from_config(cls, *args, **kwargs):
|
1753
|
+
requires_backends(cls, ["torch", "transformers"])
|
1754
|
+
|
1755
|
+
@classmethod
|
1756
|
+
def from_pretrained(cls, *args, **kwargs):
|
1757
|
+
requires_backends(cls, ["torch", "transformers"])
|
1758
|
+
|
1759
|
+
|
1445
1760
|
class StableDiffusionXLPipeline(metaclass=DummyObject):
|
1446
1761
|
_backends = ["torch", "transformers"]
|
1447
1762
|
|
@@ -199,7 +199,6 @@ def get_cached_module_file(
|
|
199
199
|
module_file: str,
|
200
200
|
cache_dir: Optional[Union[str, os.PathLike]] = None,
|
201
201
|
force_download: bool = False,
|
202
|
-
resume_download: Optional[bool] = None,
|
203
202
|
proxies: Optional[Dict[str, str]] = None,
|
204
203
|
token: Optional[Union[bool, str]] = None,
|
205
204
|
revision: Optional[str] = None,
|
@@ -226,9 +225,7 @@ def get_cached_module_file(
|
|
226
225
|
cache should not be used.
|
227
226
|
force_download (`bool`, *optional*, defaults to `False`):
|
228
227
|
Whether or not to force to (re-)download the configuration files and override the cached versions if they
|
229
|
-
exist.
|
230
|
-
Deprecated and ignored. All downloads are now resumed by default when possible. Will be removed in v1
|
231
|
-
of Diffusers.
|
228
|
+
exist.
|
232
229
|
proxies (`Dict[str, str]`, *optional*):
|
233
230
|
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
|
234
231
|
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
|
@@ -309,7 +306,6 @@ def get_cached_module_file(
|
|
309
306
|
cache_dir=cache_dir,
|
310
307
|
force_download=force_download,
|
311
308
|
proxies=proxies,
|
312
|
-
resume_download=resume_download,
|
313
309
|
local_files_only=local_files_only,
|
314
310
|
token=token,
|
315
311
|
)
|
@@ -366,7 +362,6 @@ def get_cached_module_file(
|
|
366
362
|
f"{module_needed}.py",
|
367
363
|
cache_dir=cache_dir,
|
368
364
|
force_download=force_download,
|
369
|
-
resume_download=resume_download,
|
370
365
|
proxies=proxies,
|
371
366
|
token=token,
|
372
367
|
revision=revision,
|
@@ -382,7 +377,6 @@ def get_class_from_dynamic_module(
|
|
382
377
|
class_name: Optional[str] = None,
|
383
378
|
cache_dir: Optional[Union[str, os.PathLike]] = None,
|
384
379
|
force_download: bool = False,
|
385
|
-
resume_download: Optional[bool] = None,
|
386
380
|
proxies: Optional[Dict[str, str]] = None,
|
387
381
|
token: Optional[Union[bool, str]] = None,
|
388
382
|
revision: Optional[str] = None,
|
@@ -419,9 +413,6 @@ def get_class_from_dynamic_module(
|
|
419
413
|
force_download (`bool`, *optional*, defaults to `False`):
|
420
414
|
Whether or not to force to (re-)download the configuration files and override the cached versions if they
|
421
415
|
exist.
|
422
|
-
resume_download:
|
423
|
-
Deprecated and ignored. All downloads are now resumed by default when possible. Will be removed in v1 of
|
424
|
-
Diffusers.
|
425
416
|
proxies (`Dict[str, str]`, *optional*):
|
426
417
|
A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
|
427
418
|
'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
|
@@ -458,7 +449,6 @@ def get_class_from_dynamic_module(
|
|
458
449
|
module_file,
|
459
450
|
cache_dir=cache_dir,
|
460
451
|
force_download=force_download,
|
461
|
-
resume_download=resume_download,
|
462
452
|
proxies=proxies,
|
463
453
|
token=token,
|
464
454
|
revision=revision,
|
diffusers/utils/export_utils.py
CHANGED
diffusers/utils/hub_utils.py
CHANGED
@@ -271,7 +271,8 @@ if cache_version < 1:
|
|
271
271
|
def _add_variant(weights_name: str, variant: Optional[str] = None) -> str:
|
272
272
|
if variant is not None:
|
273
273
|
splits = weights_name.split(".")
|
274
|
-
|
274
|
+
split_index = -2 if weights_name.endswith(".index.json") else -1
|
275
|
+
splits = splits[:-split_index] + [variant] + splits[-split_index:]
|
275
276
|
weights_name = ".".join(splits)
|
276
277
|
|
277
278
|
return weights_name
|
@@ -286,7 +287,6 @@ def _get_model_file(
|
|
286
287
|
cache_dir: Optional[str] = None,
|
287
288
|
force_download: bool = False,
|
288
289
|
proxies: Optional[Dict] = None,
|
289
|
-
resume_download: Optional[bool] = None,
|
290
290
|
local_files_only: bool = False,
|
291
291
|
token: Optional[str] = None,
|
292
292
|
user_agent: Optional[Union[Dict, str]] = None,
|
@@ -324,7 +324,6 @@ def _get_model_file(
|
|
324
324
|
cache_dir=cache_dir,
|
325
325
|
force_download=force_download,
|
326
326
|
proxies=proxies,
|
327
|
-
resume_download=resume_download,
|
328
327
|
local_files_only=local_files_only,
|
329
328
|
token=token,
|
330
329
|
user_agent=user_agent,
|
@@ -349,7 +348,6 @@ def _get_model_file(
|
|
349
348
|
cache_dir=cache_dir,
|
350
349
|
force_download=force_download,
|
351
350
|
proxies=proxies,
|
352
|
-
resume_download=resume_download,
|
353
351
|
local_files_only=local_files_only,
|
354
352
|
token=token,
|
355
353
|
user_agent=user_agent,
|
@@ -358,42 +356,42 @@ def _get_model_file(
|
|
358
356
|
)
|
359
357
|
return model_file
|
360
358
|
|
361
|
-
except RepositoryNotFoundError:
|
359
|
+
except RepositoryNotFoundError as e:
|
362
360
|
raise EnvironmentError(
|
363
361
|
f"{pretrained_model_name_or_path} is not a local folder and is not a valid model identifier "
|
364
362
|
"listed on 'https://huggingface.co/models'\nIf this is a private repository, make sure to pass a "
|
365
363
|
"token having permission to this repo with `token` or log in with `huggingface-cli "
|
366
364
|
"login`."
|
367
|
-
)
|
368
|
-
except RevisionNotFoundError:
|
365
|
+
) from e
|
366
|
+
except RevisionNotFoundError as e:
|
369
367
|
raise EnvironmentError(
|
370
368
|
f"{revision} is not a valid git identifier (branch name, tag name or commit id) that exists for "
|
371
369
|
"this model name. Check the model page at "
|
372
370
|
f"'https://huggingface.co/{pretrained_model_name_or_path}' for available revisions."
|
373
|
-
)
|
374
|
-
except EntryNotFoundError:
|
371
|
+
) from e
|
372
|
+
except EntryNotFoundError as e:
|
375
373
|
raise EnvironmentError(
|
376
374
|
f"{pretrained_model_name_or_path} does not appear to have a file named {weights_name}."
|
377
|
-
)
|
378
|
-
except HTTPError as
|
375
|
+
) from e
|
376
|
+
except HTTPError as e:
|
379
377
|
raise EnvironmentError(
|
380
|
-
f"There was a specific connection error when trying to load {pretrained_model_name_or_path}:\n{
|
381
|
-
)
|
382
|
-
except ValueError:
|
378
|
+
f"There was a specific connection error when trying to load {pretrained_model_name_or_path}:\n{e}"
|
379
|
+
) from e
|
380
|
+
except ValueError as e:
|
383
381
|
raise EnvironmentError(
|
384
382
|
f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load this model, couldn't find it"
|
385
383
|
f" in the cached files and it looks like {pretrained_model_name_or_path} is not the path to a"
|
386
384
|
f" directory containing a file named {weights_name} or"
|
387
385
|
" \nCheckout your internet connection or see how to run the library in"
|
388
386
|
" offline mode at 'https://huggingface.co/docs/diffusers/installation#offline-mode'."
|
389
|
-
)
|
390
|
-
except EnvironmentError:
|
387
|
+
) from e
|
388
|
+
except EnvironmentError as e:
|
391
389
|
raise EnvironmentError(
|
392
390
|
f"Can't load the model for '{pretrained_model_name_or_path}'. If you were trying to load it from "
|
393
391
|
"'https://huggingface.co/models', make sure you don't have a local directory with the same name. "
|
394
392
|
f"Otherwise, make sure '{pretrained_model_name_or_path}' is the correct path to a directory "
|
395
393
|
f"containing a file named {weights_name}"
|
396
|
-
)
|
394
|
+
) from e
|
397
395
|
|
398
396
|
|
399
397
|
# Adapted from
|
@@ -417,7 +415,6 @@ def _get_checkpoint_shard_files(
|
|
417
415
|
index_filename,
|
418
416
|
cache_dir=None,
|
419
417
|
proxies=None,
|
420
|
-
resume_download=False,
|
421
418
|
local_files_only=False,
|
422
419
|
token=None,
|
423
420
|
user_agent=None,
|
@@ -451,14 +448,17 @@ def _get_checkpoint_shard_files(
|
|
451
448
|
_check_if_shards_exist_locally(
|
452
449
|
pretrained_model_name_or_path, subfolder=subfolder, original_shard_filenames=original_shard_filenames
|
453
450
|
)
|
454
|
-
return
|
451
|
+
return shards_path, sharded_metadata
|
455
452
|
|
456
453
|
# At this stage pretrained_model_name_or_path is a model identifier on the Hub
|
457
454
|
allow_patterns = original_shard_filenames
|
455
|
+
if subfolder is not None:
|
456
|
+
allow_patterns = [os.path.join(subfolder, p) for p in allow_patterns]
|
457
|
+
|
458
458
|
ignore_patterns = ["*.json", "*.md"]
|
459
459
|
if not local_files_only:
|
460
460
|
# `model_info` call must guarded with the above condition.
|
461
|
-
model_files_info = model_info(pretrained_model_name_or_path)
|
461
|
+
model_files_info = model_info(pretrained_model_name_or_path, revision=revision)
|
462
462
|
for shard_file in original_shard_filenames:
|
463
463
|
shard_file_present = any(shard_file in k.rfilename for k in model_files_info.siblings)
|
464
464
|
if not shard_file_present:
|
@@ -467,34 +467,37 @@ def _get_checkpoint_shard_files(
|
|
467
467
|
"required according to the checkpoint index."
|
468
468
|
)
|
469
469
|
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
470
|
+
try:
|
471
|
+
# Load from URL
|
472
|
+
cached_folder = snapshot_download(
|
473
|
+
pretrained_model_name_or_path,
|
474
|
+
cache_dir=cache_dir,
|
475
|
+
proxies=proxies,
|
476
|
+
local_files_only=local_files_only,
|
477
|
+
token=token,
|
478
|
+
revision=revision,
|
479
|
+
allow_patterns=allow_patterns,
|
480
|
+
ignore_patterns=ignore_patterns,
|
481
|
+
user_agent=user_agent,
|
482
|
+
)
|
483
|
+
if subfolder is not None:
|
484
|
+
cached_folder = os.path.join(cached_folder, subfolder)
|
484
485
|
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
486
|
+
# We have already dealt with RepositoryNotFoundError and RevisionNotFoundError when getting the index, so
|
487
|
+
# we don't have to catch them here. We have also dealt with EntryNotFoundError.
|
488
|
+
except HTTPError as e:
|
489
|
+
raise EnvironmentError(
|
490
|
+
f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load {pretrained_model_name_or_path}. You should try"
|
491
|
+
" again after checking your internet connection."
|
492
|
+
) from e
|
492
493
|
|
493
494
|
# If `local_files_only=True`, `cached_folder` may not contain all the shard files.
|
494
|
-
|
495
|
+
elif local_files_only:
|
495
496
|
_check_if_shards_exist_locally(
|
496
497
|
local_dir=cache_dir, subfolder=subfolder, original_shard_filenames=original_shard_filenames
|
497
498
|
)
|
499
|
+
if subfolder is not None:
|
500
|
+
cached_folder = os.path.join(cached_folder, subfolder)
|
498
501
|
|
499
502
|
return cached_folder, sharded_metadata
|
500
503
|
|