Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
diffusers
Commits
0d68ddf3
Unverified
Commit
0d68ddf3
authored
Jun 07, 2024
by
Lucain
Committed by
GitHub
Jun 07, 2024
Browse files
Move away from `cached_download` (#8419)
* Move away from * unused constant * Add custom error
parent
7d887118
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
13 deletions
+15
-13
src/diffusers/utils/dynamic_modules_utils.py
src/diffusers/utils/dynamic_modules_utils.py
+15
-13
No files found.
src/diffusers/utils/dynamic_modules_utils.py
View file @
0d68ddf3
...
...
@@ -25,21 +25,19 @@ from pathlib import Path
from
typing
import
Dict
,
Optional
,
Union
from
urllib
import
request
from
huggingface_hub
import
cached_download
,
hf_hub_download
,
model_info
from
huggingface_hub.utils
import
validate_hf_hub_args
from
huggingface_hub
import
hf_hub_download
,
model_info
from
huggingface_hub.utils
import
RevisionNotFoundError
,
validate_hf_hub_args
from
packaging
import
version
from
..
import
__version__
from
.
import
DIFFUSERS_DYNAMIC_MODULE_NAME
,
HF_MODULES_CACHE
,
logging
COMMUNITY_PIPELINES_URL
=
(
"https://raw.githubusercontent.com/huggingface/diffusers/{revision}/examples/community/{pipeline}.py"
)
logger
=
logging
.
get_logger
(
__name__
)
# pylint: disable=invalid-name
# See https://huggingface.co/datasets/diffusers/community-pipelines-mirror
COMMUNITY_PIPELINES_MIRROR_ID
=
"diffusers/community-pipelines-mirror"
def
get_diffusers_versions
():
url
=
"https://pypi.org/pypi/diffusers/json"
...
...
@@ -281,20 +279,24 @@ def get_cached_module_file(
f
"
{
', '
.
join
(
available_versions
+
[
'main'
])
}
."
)
# community pipeline on GitHub
github_url
=
COMMUNITY_PIPELINES_URL
.
format
(
revision
=
revision
,
pipeline
=
pretrained_model_name_or_path
)
try
:
resolved_module_file
=
cached_download
(
github_url
,
resolved_module_file
=
hf_hub_download
(
repo_id
=
COMMUNITY_PIPELINES_MIRROR_ID
,
repo_type
=
"dataset"
,
filename
=
f
"
{
revision
}
/
{
pretrained_model_name_or_path
}
.py"
,
cache_dir
=
cache_dir
,
force_download
=
force_download
,
proxies
=
proxies
,
resume_download
=
resume_download
,
local_files_only
=
local_files_only
,
token
=
False
,
)
submodule
=
"git"
module_file
=
pretrained_model_name_or_path
+
".py"
except
RevisionNotFoundError
as
e
:
raise
EnvironmentError
(
f
"Revision '
{
revision
}
' not found in the community pipelines mirror. Check available revisions on"
" https://huggingface.co/datasets/diffusers/community-pipelines-mirror/tree/main."
" If you don't find the revision you are looking for, please open an issue on https://github.com/huggingface/diffusers/issues."
)
from
e
except
EnvironmentError
:
logger
.
error
(
f
"Could not locate the
{
module_file
}
inside
{
pretrained_model_name_or_path
}
."
)
raise
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment