(obj, backends)
| 623 | |
| 624 | |
| 625 | def 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 | |
| 656 | class DummyObject(type): |
no test coverage detected