Instructions to use OzzyGT/YuE2-Modular with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use OzzyGT/YuE2-Modular with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("OzzyGT/YuE2-Modular", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Download guidance.py from OzzyGT/YuE2-Modular: direct link, hf CLI and curl.
- Browser
- Download file 717 Bytes
-
https://huggingface.co/OzzyGT/YuE2-Modular/resolve/main/guidance.py
- Command line
-
hf download hf://OzzyGT/YuE2-Modular/guidance.py
-
curl -L -o guidance.py https://huggingface.co/OzzyGT/YuE2-Modular/resolve/main/guidance.py
717 Bytes
| import math | |
| from diffusers.configuration_utils import ConfigMixin, register_to_config | |
| class YuE2SemanticGuider(ConfigMixin): | |
| config_name = "guider_config.json" | |
| def __init__(self, scale=None): | |
| if scale is not None and (not math.isfinite(scale) or not 0 <= scale <= 20): | |
| raise ValueError("Semantic guidance must be finite and in [0,20]") | |
| def scale_for(self, cot): | |
| return (1.01 if cot == "off" else 1.0) if self.config.scale is None else self.config.scale | |
| def combine(self, conditional, unconditional, cot): | |
| scale = self.scale_for(cot) | |
| return conditional if scale == 1.0 else unconditional + scale * (conditional - unconditional) | |