Spaces:
Running
Running
2B-Studio: DAW-Studio, neue Modelle (YuE2, TangoFlux, AudioGen, AudioLDM2), Lizenz-Badges, HF-Login, Einswarm Schwarz/Gold
c600f78 verified Download studio/registry.py from 2Btainment/2b-studio: direct link, hf CLI and curl.
- Browser
- Download file 2.25 kB
-
https://huggingface.co/spaces/2Btainment/2b-studio/resolve/main/studio/registry.py
- Command line
-
hf download hf://spaces/2Btainment/2b-studio/studio/registry.py
-
curl -L -o registry.py https://huggingface.co/spaces/2Btainment/2b-studio/resolve/main/studio/registry.py
2.25 kB
| from __future__ import annotations | |
| from pathlib import Path | |
| from typing import Any | |
| import yaml | |
| from pydantic import BaseModel, Field | |
| DEFAULT_REGISTRY_PATH = Path(__file__).resolve().parents[1] / "schemas" / "model-registry.yaml" | |
| class ModelEntry(BaseModel): | |
| id: str | |
| group: str | |
| label: str | |
| adapter: str | |
| host: str | |
| weights: str | None = None | |
| space_ref: str | None = None | |
| profile: str | None = None | |
| capabilities: dict[str, Any] = Field(default_factory=dict) | |
| blockers: list[str] = Field(default_factory=list) | |
| license: str | None = None | |
| license_badge: str = "check" # free | revenue | nc | check | |
| mvp: bool | str = False | |
| def license_badge_label(self) -> str: | |
| return {"free": "frei", "revenue": "Umsatzgrenze", "nc": "nicht kommerziell"}.get(self.license_badge, "Lizenz prüfen") | |
| def max_duration_s(self) -> int: | |
| return int(self.capabilities.get("max_duration_s", 30)) | |
| def supports_vocals(self) -> bool: | |
| return bool(self.capabilities.get("vocals", False)) | |
| def supports_lyrics(self) -> bool: | |
| return bool(self.capabilities.get("lyrics", False)) | |
| def route_label(self) -> str: | |
| if self.group == "minimax": | |
| return "MiniMax Adapter" | |
| if self.group == "2b-audio": | |
| return "2B-Audio Adapter" | |
| return f"Free Adapter · {self.adapter}" | |
| class ModelRegistry(BaseModel): | |
| version: int | |
| models: list[ModelEntry] | |
| def get(self, model_id: str) -> ModelEntry: | |
| model = next((item for item in self.models if item.id == model_id), None) | |
| if model is None: | |
| raise KeyError(f"Unbekanntes Modell: {model_id}") | |
| return model | |
| def choices(self) -> list[tuple[str, str]]: | |
| return [(model.label, model.id) for model in self.models] | |
| def load_registry(path: Path | None = None) -> ModelRegistry: | |
| registry_path = path or DEFAULT_REGISTRY_PATH | |
| with registry_path.open(encoding="utf-8") as handle: | |
| raw = yaml.safe_load(handle) | |
| if not isinstance(raw, dict): | |
| raise ValueError("Die Model-Registry muss ein YAML-Objekt enthalten.") | |
| return ModelRegistry.model_validate(raw) | |