Anima-RGBA

localai0301/Anima-RGBA

作者
localai0301
任务
图像生成
下载量
8
点赞数
37
趋势分
37
许可证
apache-2.0
收录时间
2026/11/4

license: apache-2.0 library_name: diffusers base_model: circlestone-labs/Anima tags:

  • vae
  • lora
  • rgba
  • transparency
  • alpha
  • anima
  • qwen-image
  • comfyui pipeline_tag: text-to-image

Anima RGBA

Transparent (RGBA) image generation for Anima.

  • RGBA VAE. A 4-channel version of the Qwen-Image VAE used by Anima. It decodes Anima latents into images with a real alpha channel instead of opaque RGB.
  • RGBA LoRA. Trained on latents from this VAE, so Anima generates latents the VAE decodes with a clean alpha channel.
FileSizeNotes
anima_rgba_vae.safetensors508 MBfull VAE (encoder + decoder), ComfyUI Qwen-Image VAE key format
anima_rgba_lora.safetensors184 MBLoRA for the Anima DiT (step 25,000)

Usage (ComfyUI)

No custom nodes needed. Take an existing Anima workflow and change three things:

  1. VAE. Put anima_rgba_vae.safetensors in models/vae and select it in Load VAE instead of the Qwen-Image VAE.
  2. LoRA. Put anima_rgba_lora.safetensors in models/loras and add it with a normal LoRA loader (strength 1.0).
  3. Trigger. Add transparent background (or isolated on a transparent background) to the prompt.

If the background stays opaque, raise the trigger weight, e.g. (transparent background:1.3), rather than the LoRA strength. A higher trigger weight leaves the image and alpha almost unchanged; LoRA strength 1.5 adds stray semi-transparent debris around the subject.

VAE Decode then outputs a 4-channel image (straight RGB + alpha), and Save Image writes it as an RGBA PNG.

Without the LoRA the VAE still produces an alpha channel, but it is hazy. The base model's latents only roughly match what the VAE expects.

Examples

Anima base, LoRA 1.0, 30 steps, CFG 4.5, er_sde / simple, 1024 × 1024. Top: RGBA output over a checkerboard. Bottom: alpha channel. The original RGBA PNGs are in examples/.

examples

Prompts, each prefixed with masterpiece, best quality, newest, safe, :

ImagePromptSeed
knight.png1boy, solo, transparent background, armor, holding sword, cape, full body, fighting stance202
witch.png1girl, solo, transparent background, witch hat, holding staff, floating hair, magic, upper body202
angel.png1girl, solo, transparent background, angel wings, halo, white dress, looking at viewer, cowboy shot101
cake.pngno humans, transparent background, food, strawberry shortcake, fruit, still life101

Negative: worst quality, low quality, score_1, score_2, score_3, blurry, jpeg artifacts

RGBA VAE

How it works

Original Qwen-Image VAEAnima RGBA VAE
Encoder inputRGBRGB composited over white, then alpha (4 ch)
Latent16 ch, 1/816 ch, 1/8 (same space, small drift)
Decoder outputRGBstraight (un-premultiplied) RGB + alpha (4 ch)
  • Initialisation. The 3-channel weights are copied. The new alpha input column starts at zero. The new alpha output row starts at zero with bias +1, so before training the model behaves exactly like the original VAE and decodes everything as opaque.
  • Why composite over white. RGB is undefined where alpha = 0. A white composite gives those pixels a defined colour, and it is what Anima already draws for "transparent background" prompts. The RGBA latents therefore stay close to latents the base model already produces.
  • Reference loss. During training the new encoder is pulled towards the frozen original encoder's latents for the same white composite. This keeps the latent space where Anima works, so the LoRA only has to learn the small alpha residual.

Comparison with the original VAE

Holdout set at 512 px: 200 transparent images and 50 opaque images. None of them were used in training.

Transparent images (the original VAE cannot represent these, so there is no baseline)

MetricValue
Alpha MAE0.0027 (≈ 0.7 / 255)
Alpha RMSE0.0157 (≈ 4 / 255; error concentrates on edges)
PSNR, composited over white34.94 dB
PSNR, composited over black33.17 dB

Opaque images (RGB reconstruction, same images through both VAEs)

PSNR
Original Qwen-Image VAE34.26 dB
Anima RGBA VAE34.74 dB (+0.48)

Latent drift. The RMS distance between the new and original encoder means, in units of the latent std, is 0.058. The new latents are about 6 % of a standard deviation away from the original ones. This is the gap the LoRA has to bridge when generating RGBA latents.

Training

BaseQwen-Image VAE (split_files/vae/qwen_image_vae.safetensors from Anima)
Steps12,000 at batch 4, 512 px random crops
LRencoder 1e-5, decoder 5e-5, 500 warmup steps
LossesL1 of composites over random solid backgrounds (1.0), LPIPS (0.2), alpha L1 (1.0), alpha Sobel-gradient L1 (0.5), reference latent MSE vs. original encoder (0.1)
Opaque share15 % of each batch

Data

TrainHoldout
Transparent images (RGBA)16,496449
Opaque images (regularisation)3,032167
  • Transparent images have at least 5 % fully transparent and 3 % opaque pixels.
  • Images with a drawn checkerboard instead of real transparency are excluded.
  • Near-duplicates are removed by RGB and alpha dHash.

RGBA LoRA

Dataset

SubsetImagesRepeatsContent
semi4,7543transparent images with semi-transparent areas (> 2 % of pixels with 16 < alpha < 240)
normal11,7421other transparent images
reg1,9301opaque single-character images
Total18,42627,934 samples per epoch
  • Images are downscaled to a maximum side of 1536 and trained with aspect-ratio buckets: 1024 base resolution, 512–1536, steps of 64.
  • Latents are cached with the RGBA VAE.

Captions

Tags in this order:

rating, count, character, copyright, @artist, trigger, general tags

  • Ratings: safe / sensitive only.
  • At most 40 general tags. Dropped: simple_background, white_background, transparent_background, highres, absurdres, lowres, commentary and id-related tags, official_art.
  • Transparent images have two caption lines, one per trigger. A random line is used each step:
    • transparent background
    • isolated on a transparent background
  • Opaque reg images have no trigger.

Training

Trainersd-scripts anima_train_network, networks.lora_anima
Trained modulesDiT only (Qwen3 text encoder and LLM adapter frozen)
Rank / alpha32 / 32
OptimizerAdamW8bit, LR 5e-5, constant with 100 warmup steps
Batch2, bf16, gradient checkpointing
Timestepssigmoid sampling, discrete flow shift 1.0
Steps25,000 (14,363 steps per epoch)

Test results

8 prompts × 2 seeds at 1024 × 1024, decoded with the RGBA VAE. The same prompts and seeds were used for every row.

  • Transparent: at least 5 % of pixels with alpha < 0.5.
  • Semi-transparent pixels: share of pixels with 0.06 < alpha < 0.94 (mean over the 16 images). Lower means a cleaner cut-out; real semi-transparent areas count here too.

Setups:

  • A: Anima base, 30 steps, CFG 4.5.
  • B: Anima fine-tune + turbo LoRA (0.8) + style LoRA, 12 steps, CFG 1.
LoRA strengthTrigger weightA: transparentA: semi-transparentB: transparentB: semi-transparent
no LoRA1.016 / 1612.8 %16 / 1621.1 %
1.01.016 / 160.9 %16 / 163.5 %
1.21.016 / 161.0 %16 / 163.2 %
1.51.016 / 161.4 %16 / 166.0 %
1.01.216 / 160.9 %16 / 163.1 %
1.01.516 / 160.9 %16 / 163.1 %
  • Without the LoRA the VAE still separates a background, but the alpha is hazy: characters and white clothing come out partly transparent.
  • Raising the trigger weight keeps the composition and the alpha almost unchanged.
  • Raising the LoRA strength changes the image. At 1.5 it adds stray semi-transparent debris and smoke around the subject.

Limitations

  • The VAE was trained on 512 px crops. It decodes at higher resolutions, but very fine semi-transparent detail (hair strands, glass, smoke) is the weakest area.
  • Generated alpha is mostly binary. See-through clothing usually comes out opaque.
  • Close-ups that fill the frame sometimes keep an opaque white background, more often with other LoRAs stacked.
  • Built for anime/illustration content (Anima).

License

The VAE is derived from the Qwen-Image VAE (Apache-2.0).

内容来源:Hugging Face 模型卡

在 Hugging Face 查看