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
File size: 717 Bytes
2577656 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import math
from diffusers.configuration_utils import ConfigMixin, register_to_config
class YuE2SemanticGuider(ConfigMixin):
config_name = "guider_config.json"
@register_to_config
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)
|