Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
416749ff
Commit
416749ff
authored
Jul 21, 2022
by
Patrick von Platen
Browse files
modelcards and tensorboard are optional
parent
b1b99b59
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
setup.py
setup.py
+2
-3
src/diffusers/hub_utils.py
src/diffusers/hub_utils.py
+11
-1
src/diffusers/utils/__init__.py
src/diffusers/utils/__init__.py
+12
-0
No files found.
setup.py
View file @
416749ff
...
...
@@ -161,10 +161,11 @@ extras = {}
extras
=
{}
extras
[
"quality"
]
=
[
"black ~= 22.0"
,
"isort >= 5.5.4"
,
"flake8 >= 3.8.3"
]
extras
[
"docs"
]
=
[]
extras
[
"training"
]
=
[
"tensorboard"
,
"modelcards"
]
extras
[
"test"
]
=
[
"pytest"
,
]
extras
[
"dev"
]
=
extras
[
"quality"
]
+
extras
[
"test"
]
extras
[
"dev"
]
=
extras
[
"quality"
]
+
extras
[
"test"
]
+
extras
[
"training"
]
install_requires
=
[
deps
[
"filelock"
],
...
...
@@ -174,8 +175,6 @@ install_requires = [
deps
[
"requests"
],
deps
[
"torch"
],
deps
[
"Pillow"
],
deps
[
"tensorboard"
],
deps
[
"modelcards"
],
]
setup
(
...
...
src/diffusers/hub_utils.py
View file @
416749ff
...
...
@@ -21,7 +21,11 @@ from typing import Optional
from
diffusers
import
DiffusionPipeline
from
huggingface_hub
import
HfFolder
,
Repository
,
whoami
from
modelcards
import
CardData
,
ModelCard
from
utils
import
is_modelcards_available
if
is_modelcards_available
():
from
modelcards
import
CardData
,
ModelCard
from
.utils
import
logging
...
...
@@ -147,6 +151,12 @@ def push_to_hub(
def
create_model_card
(
args
,
model_name
):
if
not
is_modelcards_available
:
raise
ValueError
(
"Please make sure to have `modelcards` installed when using the `create_model_card` function. You can"
" install the package with `pip install modelcards`."
)
if
hasattr
(
args
,
"local_rank"
)
and
args
.
local_rank
not
in
[
-
1
,
0
]:
return
...
...
src/diffusers/utils/__init__.py
View file @
416749ff
...
...
@@ -61,6 +61,14 @@ except importlib_metadata.PackageNotFoundError:
_unidecode_available
=
False
_modelcards_available
=
importlib
.
util
.
find_spec
(
"modelcards"
)
is
not
None
try
:
_modelcards_version
=
importlib_metadata
.
version
(
"modelcards"
)
logger
.
debug
(
f
"Successfully imported modelcards version
{
_modelcards_version
}
"
)
except
importlib_metadata
.
PackageNotFoundError
:
_modelcards_available
=
False
def
is_transformers_available
():
return
_transformers_available
...
...
@@ -73,6 +81,10 @@ def is_unidecode_available():
return
_unidecode_available
def
is_modelcards_available
():
return
_modelcards_available
class
RepositoryNotFoundError
(
HTTPError
):
"""
Raised when trying to access a hf.co URL with an invalid repository name, or with a private repo name the user does
...
...
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