"""Поиск компонентов модели: bundle самодостаточен, локальные папки — фолбэк. Раскладка bundle (совпадает с конвенцией diffusers): ra4-218M/ transformer/ обученное: config.json + safetensors (fp16) text_encoder/ LongCLIP-L, заморожен tokenizer/ CLIP BPE vae/ AsymmetricAutoencoderKL (32 канала, f8/f16) README.md карточка модели """ from __future__ import annotations from pathlib import Path def resolve(kind: str, model: Path | str | None = None) -> Path | None: """`kind` ∈ {transformer, text_encoder, tokenizer, vae}. 1) `/`, 2) `` если это уже нужная папка, 3) локальная `/` рядом с проектом. """ root = Path(model) if model else None if root is not None: cand = root / kind if cand.exists(): return cand if root.name == kind and root.exists(): # передали саму папку компонента return root if root.is_dir() and kind == "transformer" and (root / "config.json").exists(): return root # передали саму transformer/ local = Path(__file__).resolve().parent.parent / kind return local if local.exists() else (root / kind if root is not None else None)