Instructions to use recoilme/ra4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use recoilme/ra4 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("recoilme/ra4", 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
- Local Apps Settings
- Draw Things
- DiffusionBee
File size: 1,506 Bytes
eb8084e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | """Поиск компонентов модели: 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) `<model>/<kind>`, 2) `<model>` если это уже нужная папка,
3) локальная `<kind>/` рядом с проектом.
"""
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)
|