JSCPPProgrammer's picture
Upload Anima RDBT Gradio Space (Diffusers backend)
f2fa09a verified
|
Raw
History Blame Contribute Delete
5.48 kB

A newer version of the Gradio SDK is available: 6.26.0

Upgrade
metadata
title: Anima RDBT (Gradio)
emoji: 🎨
colorFrom: purple
colorTo: blue
sdk: gradio
app_file: app.py
python_version: 3.11
pinned: false

Anima RDBT — Gradio + ZeroGPU

This Hugging Face Gradio Space replaces the ComfyUI canvas with a focused UI and runs the RDBT checkpoint in-process with Hugging Face Diffusers and the community diffusers-anima AnimaPipeline (RDBT loaded via from_single_file).

See docs/DIFFUSERS_COMPATIBILITY.md for how this relates to the old Comfy graph and to stock diffusers alone.

License (read before use): Anima is licensed under the CircleStone Labs Non-Commercial License and is a derivative of Cosmos-Predict2-2B-Text2Image (NVIDIA Open Model License applies where stated). Use non-commercially unless you have a separate commercial license. See circlestone-labs/Anima and LICENSE.md on the model repo.

Hardware

  • In Space Settings → Hardware, select ZeroGPU (Gradio-only; required for this pattern).
  • First cold start may take several minutes: pip installs (diffusers, diffusers-anima) and a multi‑GB RDBT download from Civitai (unless already cached).
  • Optional: attach persistent storage so the hub cache and ComfyUI/models (or ANIMA_MODELS_ROOT) survive host moves.

Runtime behavior

  1. On Space startup (import): the app blocks until the RDBT file is available under .../diffusion_models/ (CPU/network only; no GPU). Optional rows in config.ARTIFACTS also download; by default the list is empty so only Civitai RDBT is fetched.
  2. On first Generate: a @spaces.GPU window runs, torch loads, and the Diffusers pipeline is built. Auxiliary weights (text encoder, VAE, tokenizers) may be downloaded from the Hub on first use (hdae/diffusers-anima-preview) if not already cached. Later requests reuse the loaded pipeline.
  3. Inference is wrapped in @spaces.GPU with a dynamic duration from steps × batch (cap ANIMA_MAX_GPU_DURATION, default 300s).
  4. For tests or local work without large downloads, set ANIMA_SKIP_STARTUP_BOOTSTRAP=1; the first Generate then runs the full ensure_prepared() path (still needs a GPU to load the pipeline).

Backend notes

If a Comfy-style sampler or scheduler is not available in the Anima scheduler, the backend maps to the closest supported pair (often euler_ancestral-style and simple). Unknown dropdown values are still normalized in the validation layer. On H200 (ZeroGPU), TORCH_CUDNN_SDPA_ENABLED=0 is set unless ANIMA_ALLOW_CUDNN_SDPA=1.

import torch before first inference is required for this in-process design (unlike the old “do not pre-import torch before Comfy’s main.py” constraint).

Parameter reference

Control Default Allowed / notes
prompt style prompt from original RDBT template Non-empty; max 20k chars
negative_prompt (empty) max 20k chars
width 1024 512–2048 (slider step 64; out-of-range values are clamped with a notice)
height 1024 512–2048 (same)
steps 16 1–50
cfg 1.0 1.0–2.0, step 0.1
batch_size 1 1–4 (safety cap for shared ZeroGPU memory)
sampler_name euler_ancestral Dropdown; unknown → euler_ancestral + notice
scheduler simple Dropdown; unknown → simple + notice
denoise 1.00 0.00–1.00, step 0.01. Txt2img: Diffusers Anima path uses full strength; non-1.0 is noted (see compatibility doc)

RDBT checkpoint on disk: rdbt-anima-p3-v024f-16step-dmd2.safetensors (under diffusion_models/).

Environment variables

Variable Purpose
PORT Gradio listen port (HF sets this; usually 7860).
ANIMA_SKIP_STARTUP_BOOTSTRAP Set to 1 to skip import-time weight download (e.g. unit tests).
SKIP_CIVITAI Set to 1 to skip Civitai download of the RDBT file (only if you provide that file another way).
CIVITAI_TOKEN Optional bearer token for Civitai API downloads.
ANIMA_COMFY_ROOT Legacy: directory whose models/ subfolder holds weights (default parent ./ComfyUI).
ANIMA_MODELS_ROOT If set, absolute path to the models directory (contains diffusion_models/, etc.). Overrides .../ComfyUI/models default.
ANIMA_MAX_GPU_DURATION Upper bound (seconds) for ZeroGPU duration budgeting (default 300).
ANIMA_ALLOW_CUDNN_SDPA Set to 1 to not set TORCH_CUDNN_SDPA_ENABLED=0 (debug only).
HF_TOKEN Optional; for gated Hub assets.

Development / tests (optional)

pip install -r requirements.txt
python -m pytest

This repository targets Hugging Face Spaces; local runs are best-effort (large downloads, GPU).

Acknowledgements