MCPcopy
hub / github.com/huggingface/diffusers / requires_backends

Function requires_backends

src/diffusers/utils/import_utils.py:621–649  ·  view source on GitHub ↗
(obj, backends)

Source from the content-addressed store, hash-verified

619
620
621def requires_backends(obj, backends):
622 if not isinstance(backends, (list, tuple)):
623 backends = [backends]
624
625 name = obj.__name__ if hasattr(obj, "__name__") else obj.__class__.__name__
626 checks = (BACKENDS_MAPPING[backend] for backend in backends)
627 failed = [msg.format(name) for available, msg in checks if not available()]
628 if failed:
629 raise ImportError("".join(failed))
630
631 if name in [
632 "VersatileDiffusionTextToImagePipeline",
633 "VersatileDiffusionPipeline",
634 "VersatileDiffusionDualGuidedPipeline",
635 "StableDiffusionImageVariationPipeline",
636 "UnCLIPPipeline",
637 ] and is_transformers_version("<", "4.25.0"):
638 raise ImportError(
639 f"You need to install `transformers>=4.25` in order to use {name}: \n```\n pip install"
640 " --upgrade transformers \n```"
641 )
642
643 if name in ["StableDiffusionDepth2ImgPipeline", "StableDiffusionPix2PixZeroPipeline"] and is_transformers_version(
644 "<", "4.26.0"
645 ):
646 raise ImportError(
647 f"You need to install `transformers>=4.26` in order to use {name}: \n```\n pip install"
648 " --upgrade transformers \n```"
649 )
650
651
652class DummyObject(type):

Callers 15

__init__Method · 0.85
from_configMethod · 0.85
from_pretrainedMethod · 0.85
__init__Method · 0.85
from_configMethod · 0.85
from_pretrainedMethod · 0.85
__getattr__Method · 0.85
__init__Method · 0.85
from_configMethod · 0.85
from_pretrainedMethod · 0.85
__init__Method · 0.85
from_configMethod · 0.85

Calls 1

is_transformers_versionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…