MCPcopy Index your code
hub / github.com/YesianRohn/TextSSR / requires_backends

Function requires_backends

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

Source from the content-addressed store, hash-verified

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

Callers 15

__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
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