|
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
|
|
0 commit comments