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
2c60f7d1
Unverified
Commit
2c60f7d1
authored
Sep 11, 2023
by
Patrick von Platen
Committed by
GitHub
Sep 11, 2023
Browse files
[Core] Remove TF import checks (#4968)
[TF] Remove tf
parent
b6e0b016
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1 addition
and
49 deletions
+1
-49
src/diffusers/utils/__init__.py
src/diffusers/utils/__init__.py
+0
-1
src/diffusers/utils/import_utils.py
src/diffusers/utils/import_utils.py
+0
-41
utils/check_repo.py
utils/check_repo.py
+1
-7
No files found.
src/diffusers/utils/__init__.py
View file @
2c60f7d1
...
@@ -69,7 +69,6 @@ from .import_utils import (
...
@@ -69,7 +69,6 @@ from .import_utils import (
is_onnx_available
,
is_onnx_available
,
is_scipy_available
,
is_scipy_available
,
is_tensorboard_available
,
is_tensorboard_available
,
is_tf_available
,
is_torch_available
,
is_torch_available
,
is_torch_version
,
is_torch_version
,
is_torchsde_available
,
is_torchsde_available
,
...
...
src/diffusers/utils/import_utils.py
View file @
2c60f7d1
...
@@ -62,43 +62,6 @@ else:
...
@@ -62,43 +62,6 @@ else:
logger
.
info
(
"Disabling PyTorch because USE_TORCH is set"
)
logger
.
info
(
"Disabling PyTorch because USE_TORCH is set"
)
_torch_available
=
False
_torch_available
=
False
_tf_version
=
"N/A"
if
USE_TF
in
ENV_VARS_TRUE_AND_AUTO_VALUES
and
USE_TORCH
not
in
ENV_VARS_TRUE_VALUES
:
_tf_available
=
importlib
.
util
.
find_spec
(
"tensorflow"
)
is
not
None
if
_tf_available
:
candidates
=
(
"tensorflow"
,
"tensorflow-cpu"
,
"tensorflow-gpu"
,
"tf-nightly"
,
"tf-nightly-cpu"
,
"tf-nightly-gpu"
,
"intel-tensorflow"
,
"intel-tensorflow-avx512"
,
"tensorflow-rocm"
,
"tensorflow-macos"
,
"tensorflow-aarch64"
,
)
_tf_version
=
None
# For the metadata, we have to look for both tensorflow and tensorflow-cpu
for
pkg
in
candidates
:
try
:
_tf_version
=
importlib_metadata
.
version
(
pkg
)
break
except
importlib_metadata
.
PackageNotFoundError
:
pass
_tf_available
=
_tf_version
is
not
None
if
_tf_available
:
if
version
.
parse
(
_tf_version
)
<
version
.
parse
(
"2"
):
logger
.
info
(
f
"TensorFlow found but with version
{
_tf_version
}
. Diffusers requires version 2 minimum."
)
_tf_available
=
False
else
:
logger
.
info
(
f
"TensorFlow version
{
_tf_version
}
available."
)
else
:
logger
.
info
(
"Disabling Tensorflow because USE_TORCH is set"
)
_tf_available
=
False
_jax_version
=
"N/A"
_jax_version
=
"N/A"
_flax_version
=
"N/A"
_flax_version
=
"N/A"
if
USE_JAX
in
ENV_VARS_TRUE_AND_AUTO_VALUES
:
if
USE_JAX
in
ENV_VARS_TRUE_AND_AUTO_VALUES
:
...
@@ -308,10 +271,6 @@ def is_torch_available():
...
@@ -308,10 +271,6 @@ def is_torch_available():
return
_torch_available
return
_torch_available
def
is_tf_available
():
return
_tf_available
def
is_flax_available
():
def
is_flax_available
():
return
_flax_available
return
_flax_available
...
...
utils/check_repo.py
View file @
2c60f7d1
...
@@ -23,7 +23,7 @@ from difflib import get_close_matches
...
@@ -23,7 +23,7 @@ from difflib import get_close_matches
from
pathlib
import
Path
from
pathlib
import
Path
from
diffusers.models.auto
import
get_values
from
diffusers.models.auto
import
get_values
from
diffusers.utils
import
ENV_VARS_TRUE_VALUES
,
is_flax_available
,
is_tf_available
,
is_torch_available
from
diffusers.utils
import
ENV_VARS_TRUE_VALUES
,
is_flax_available
,
is_torch_available
# All paths are set with the intent you should run this script from the root of the repo with the command
# All paths are set with the intent you should run this script from the root of the repo with the command
...
@@ -421,10 +421,6 @@ def get_all_auto_configured_models():
...
@@ -421,10 +421,6 @@ def get_all_auto_configured_models():
for
attr_name
in
dir
(
diffusers
.
models
.
auto
.
modeling_auto
):
for
attr_name
in
dir
(
diffusers
.
models
.
auto
.
modeling_auto
):
if
attr_name
.
startswith
(
"MODEL_"
)
and
attr_name
.
endswith
(
"MAPPING_NAMES"
):
if
attr_name
.
startswith
(
"MODEL_"
)
and
attr_name
.
endswith
(
"MAPPING_NAMES"
):
result
=
result
|
set
(
get_values
(
getattr
(
diffusers
.
models
.
auto
.
modeling_auto
,
attr_name
)))
result
=
result
|
set
(
get_values
(
getattr
(
diffusers
.
models
.
auto
.
modeling_auto
,
attr_name
)))
if
is_tf_available
():
for
attr_name
in
dir
(
diffusers
.
models
.
auto
.
modeling_tf_auto
):
if
attr_name
.
startswith
(
"TF_MODEL_"
)
and
attr_name
.
endswith
(
"MAPPING_NAMES"
):
result
=
result
|
set
(
get_values
(
getattr
(
diffusers
.
models
.
auto
.
modeling_tf_auto
,
attr_name
)))
if
is_flax_available
():
if
is_flax_available
():
for
attr_name
in
dir
(
diffusers
.
models
.
auto
.
modeling_flax_auto
):
for
attr_name
in
dir
(
diffusers
.
models
.
auto
.
modeling_flax_auto
):
if
attr_name
.
startswith
(
"FLAX_MODEL_"
)
and
attr_name
.
endswith
(
"MAPPING_NAMES"
):
if
attr_name
.
startswith
(
"FLAX_MODEL_"
)
and
attr_name
.
endswith
(
"MAPPING_NAMES"
):
...
@@ -462,8 +458,6 @@ def check_all_models_are_auto_configured():
...
@@ -462,8 +458,6 @@ def check_all_models_are_auto_configured():
missing_backends
=
[]
missing_backends
=
[]
if
not
is_torch_available
():
if
not
is_torch_available
():
missing_backends
.
append
(
"PyTorch"
)
missing_backends
.
append
(
"PyTorch"
)
if
not
is_tf_available
():
missing_backends
.
append
(
"TensorFlow"
)
if
not
is_flax_available
():
if
not
is_flax_available
():
missing_backends
.
append
(
"Flax"
)
missing_backends
.
append
(
"Flax"
)
if
len
(
missing_backends
)
>
0
:
if
len
(
missing_backends
)
>
0
:
...
...
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