mirror of
https://github.com/huggingface/diffusers.git
synced 2026-01-27 17:22:53 +03:00
Adapt to forced transformers version in some dependent libraries (#1638)
* Adapt to forced transformers version in some dependent libraries * style * Update __init__.py * update requires_backends
This commit is contained in:
@@ -18,18 +18,6 @@ from .utils import (
|
||||
)
|
||||
|
||||
|
||||
# Make sure `transformers` is up to date
|
||||
if is_transformers_available():
|
||||
import transformers
|
||||
|
||||
if is_transformers_version("<", "4.25.1"):
|
||||
raise ImportError(
|
||||
f"`diffusers` requires transformers >= 4.25.1 to function correctly, but {transformers.__version__} was"
|
||||
" found in your environment. You can upgrade it with pip: `pip install transformers --upgrade`"
|
||||
)
|
||||
else:
|
||||
pass
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
|
||||
@@ -46,7 +46,7 @@ if is_transformers_available() and is_torch_available():
|
||||
from .safety_checker import StableDiffusionSafetyChecker
|
||||
|
||||
try:
|
||||
if not (is_transformers_available() and is_torch_available()):
|
||||
if not (is_transformers_available() and is_torch_available() and is_transformers_version(">=", "4.25.0")):
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
from ...utils.dummy_torch_and_transformers_objects import StableDiffusionImageVariationPipeline
|
||||
|
||||
@@ -7,7 +7,7 @@ from ...utils import (
|
||||
|
||||
|
||||
try:
|
||||
if not (is_transformers_available() and is_torch_available()):
|
||||
if not (is_transformers_available() and is_torch_available() and is_transformers_version(">=", "4.25.0")):
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
from ...utils.dummy_torch_and_transformers_objects import (
|
||||
|
||||
@@ -354,7 +354,20 @@ def requires_backends(obj, backends):
|
||||
if failed:
|
||||
raise ImportError("".join(failed))
|
||||
|
||||
if name in ["StableDiffusionDepth2ImgPipeline"] and is_transformers_version("<", "4.26.0.dev0"):
|
||||
if name in [
|
||||
"VersatileDiffusionTextToImagePipeline",
|
||||
"VersatileDiffusionPipeline",
|
||||
"VersatileDiffusionDualGuidedPipeline",
|
||||
"StableDiffusionImageVariationPipeline",
|
||||
] and is_transformers_version("<", "4.25.0"):
|
||||
raise ImportError(
|
||||
f"You need to install `transformers>=4.25` in order to use {name}: \n```\n pip install"
|
||||
" --upgrade transformers \n```"
|
||||
)
|
||||
|
||||
if name in [
|
||||
"StableDiffusionDepth2ImgPipeline",
|
||||
] and is_transformers_version("<", "4.26.0.dev0"):
|
||||
raise ImportError(
|
||||
f"You need to install `transformers` from 'main' in order to use {name}: \n```\n pip install"
|
||||
" git+https://github.com/huggingface/transformers \n```"
|
||||
|
||||
Reference in New Issue
Block a user