Text-to-Image
Diffusers
PyTorch
flow-matching
rectified-flow
dit
dual-stream-dit
sprint
anime
How to use from the
Use from the
Diffusers library
pip install -U diffusers transformers accelerate
import torch
from diffusers import DiffusionPipeline

# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("aipracticecafe/dual-stream-dit", dtype=torch.bfloat16, device_map="cuda")

prompt = "1girl, souryuu asuka langley, neon genesis evangelion, rebuild of evangelion, evangelion: 3.0 you can \\(not\\) redo, momoko \\(momopoco\\), toosaka asagi, ebifurya, sensitive, masterpiece, good score, absurdres, highres, best quality, amazing quality, great quality, solo, long hair, blue eyes, orange hair, breasts, parted lips, official alternate costume, pilot suit, red bodysuit, black eye patch, animal hat, cabbie hat, cat hat, black hat, gloves, hat, hat horns, jacket, mecha pilot suit, bodysuit under clothes, red gloves, red jacket, track jacket, turtleneck, turtleneck jacket, interface headset, multicolored clothes, interface headset \\(evangelion\\), upper body, simple background"
image = pipe(prompt).images[0]

Asuka-FM: 200M Dual-Stream SPRINT DiT (Flow Matching)

An ultra-efficient, 200M-parameter Dual-Stream Diffusion Transformer (DiT) trained from scratch on consumer hardware (1x NVIDIA RTX 4090 in ~50 hours) using Rectified Flow / Flow Matching, SPRINT token-dropping, and Continuous Aspect-Normalized RoPE.

Despite its compact size, the model generates high-fidelity anime art with accurate character reproduction, prompt alignment, and zero-shot camera control (panning and zoom) at inference time.

  • Developed by: aipracticecafe
  • Repository: deeplearningcafe/asuka-fm
  • Dataset: curated-danbooru-2026 (~337K samples)
  • Architecture: Dual-Stream DiT (SPRINT-aligned, SwiGLU, Sandwich RMSNorm)
  • Parameters: ~200M (Backbone) + 230M (Text Encoder)
  • Objective: Conditional Flow Matching (Logit-Normal timestep sampling)
  • License: OpenRAIL++
Prompt
1girl, souryuu asuka langley, neon genesis evangelion, rebuild of evangelion, evangelion: 3.0 you can \(not\) redo, momoko \(momopoco\), toosaka asagi, ebifurya, sensitive, masterpiece, good score, absurdres, highres, best quality, amazing quality, great quality, solo, long hair, blue eyes, orange hair, breasts, parted lips, official alternate costume, pilot suit, red bodysuit, black eye patch, animal hat, cabbie hat, cat hat, black hat, gloves, hat, hat horns, jacket, mecha pilot suit, bodysuit under clothes, red gloves, red jacket, track jacket, turtleneck, turtleneck jacket, interface headset, multicolored clothes, interface headset \(evangelion\), upper body, simple background
Prompt
1girl, hoshino ai, oshi no ko, ebifurya, sensitive, masterpiece, good score, absurdres, highres, best quality, amazing quality, great quality, dress, gloves, hair ornament, idol, idol clothes, long hair, looking at viewer, microphone, one eye closed, open mouth, pink dress, pink gloves, pointing, purple eyes, purple hair, solo, star-shaped pupils, star, star in eye, symbol-shaped pupils, symbol in eye, anime coloring, black shirt, brooch, frilled gloves, frilled shirt, frilled sleeves, frills, hair between eyes, heart, heart brooch, jewelry, messy hair, one side up, pink shirt, rabbit hair ornament, shiny clothes, shiny skin, shirt, short sleeves, solo, star \(symbol\), turtleneck, wing brooch, wings, yellow shirt, upper body, simple background
Prompt
1girl, souryuu asuka langley, neon genesis evangelion, rebuild of evangelion, evangelion: 3.0 you can \(not\) redo, momoko \(momopoco\), toosaka asagi, ebifurya, sensitive, masterpiece, good score, absurdres, highres, best quality, amazing quality, great quality, solo, long hair, blue eyes, orange hair, breasts, official alternate costume, bodysuit, breasts, brown hair, closed mouth, clothing cutout, dark background, expressionless, eyepatch, falling petals, floating hair, hair ornament, holding, lance of longinus \(evangelion\), long hair, looking at viewer, looking down, mecha pilot suit, medium breasts, petals, plugsuit \(evangelion\), polearm, red bodysuit, solo, spear, standing, taut clothes, weapon, holding weapon, holding polearm, plugsuit, interface headset, light particle, upper body
Prompt
2girls, claire francois, rae taylor, watashi no oshi wa akuyaku reijou, sensitive, masterpiece, good score, absurdres, highres, best quality, amazing quality, great quality, :d, ^ ^, blonde hair, blue eyes, blush, white ascot, bow, brown hair, closed eyes, collared shirt, cropped jacket, drill hair, drill sidelocks, floating hair, frills, gem, hair bow, half updo, holding another's arm, jacket, long hair, long sleeves, multiple girls, red bow, red jacket, school uniform, shirt, short hair, smile, yuri, brown eyes, multiple girls, white shirt, ascot, brooch, frilled jacket, jewelry, medium breasts, very long hair, upper body
Prompt
1girl, kurokawa akane, oshi no ko, momoko \(momopoco\), toosaka asagi, ebifurya, hanagata, sensitive, masterpiece, good score, absurdres, highres, best quality, amazing quality, great quality, solo, blue eyes, blue hair, cherry blossoms, closed mouth, dutch angle, falling petals, floating hair, floral print, floral print kimono, hair ribbon, hakama, half updo, holding, holding umbrella, japanese clothes, kimono, light blush, long hair, looking at viewer, multicolored eyes, official alternate hairstyle, oil-paper umbrella, parted bangs, petals, pink hakama, pink kimono, pink petals, pink ribbon, print hakama, print kimono, ribbon, simple background, smile, solo, straight hair, swept bangs, two-tone eyes, umbrella, white background, wide sleeves, light particle,upper body

Key Architecture & Features

1. SPRINT Dual-Stream Transformer Backbone

The base architecture is based on the results from (i1: A Simple and Fully Open Recipe for Strong Text-to-Image Models)[https://arxiv.org/abs/2606.11289]

  • Minimalist Conditioning: Uses prepended time tokens rather than heavy per-block AdaLN modulation, reducing parameter overhead.
  • Sandwich Normalization & SwiGLU: RMSNorm placed before and after attention and FFN operations ensures training stability in bfloat16.
  • SPRINT Acceleration: Employs structured group-wise 2x2 patch dropping (75% drop ratio during early pretraining), cutting compute demands by half while retaining global semantic context.

2. HDM Continuous Aspect-Normalized RoPE (Camera Control)

Based on the Patch Diffusion: Faster and More Data-Efficient implementation proposed in the HDM paper. Early experiments with discrete integer position IDs caused severe multi-head replication when deviating from trained aspect ratios. We resolve this by adopting continuous aspect-normalized coordinate mapping which was the original idea proposed in HDM:

rH=HW,rW=WHr_H = \sqrt{\frac{H}{W}}, \quad r_W = \sqrt{\frac{W}{H}}

ypos=(ycenterH)(2rH)rH,xpos=(xcenterW)(2rW)rWy_{\text{pos}} = \left(\frac{y_{\text{center}}}{H}\right) \cdot (2 r_H) - r_H, \quad x_{\text{pos}} = \left(\frac{x_{\text{center}}}{W}\right) \cdot (2 r_W) - r_W

Manipulating $(x_{\text{pos}}, y_{\text{pos}})$ directly controls the visual framing at inference time:

  • X-Shift / Y-Shift: Translates the virtual camera viewport horizontally or vertically.
  • Zoom: Scales spatial coordinates around the focal center.

3. Components

  • Text Encoder: LiquidAI/LFM2.5-230M (unidirectional causal LM hidden states passed via a 2-layer Transformer Text Adapter).
  • Autoencoder: kaiyuyue/FLUX.2-dev-vae (C=32, f=8, patch size p=2, effective image token size 16x16).

Training Recipe & Multi-Stage Progression (1x RTX 4090, ~100h)

The model uses progressive multi-resolution pretraining on 337,000 curated Danbooru samples with shifted square cropping and in-RAM latent caching.

  • Optimizer: 8-bit AdamW (bitsandbytes), $\beta=(0.9, 0.95)$, WD=0.01
  • Learning Rate: 5e-4 with warmup and cosine annealing only for last stage
  • Effective Batch Size: 256 (Batch size 64x4 gradient accumulation)
  • Precision: Mixed Precision (torch.bfloat16 with torch.compile)

Stage 1: 256px Base Pretraining (Epochs 0 – 170)

  • Goal: Establish character concept learning, global structure, and RoPE spatial alignment.
Phase Epochs Token Drop RoPE Mode Description
1A 0 – 100 0.75 (SPRINT) Discrete Rapid macro semantic convergence
1B 100 – 120 0.75 (SPRINT) Continuous RoPE coordinate adaptation
1C 120 – 145 0.00 (Dense) Continuous Full-sequence detail refinement
1D 145 – 170 0.00 (Dense) Continuous WSD cosine learning rate decay

Stage 2: 512px Resolution Adaptation (Epochs 170 – 209)

  • Goal: Adapt patch receptive fields to higher frequency textures and sharper lineart.
Phase Epochs Token Drop RoPE Mode Description
2A 170 – 194 (25 ep) 0.75 (SPRINT) Continuous High-res structural adaptation
2B 194 – 204 (10 ep) 0.00 (Dense) Continuous Fine-tuning with constant LR
2C 204 – 209 (5 ep) 0.00 (Dense) Continuous Final cosine annealing decay

Stage 3: 1MP Native Training (Active Run)

  • Scaling from 512px to 1024px aspect ratio buckets.

Checkpoint Guide

Checkpoint Directory Stage Epoch / Step Recommended Usage
epoch_169_step_229206 Stage 1 Final Ep 169 (Step 229k) Final 256px decayed checkpoint
epoch_194_step_265389 Stage 2A Final Ep 194 (Step 265k) Fast 512px SPRINT-sparse checkpoint
epoch_204_step_281281 Stage 2B Final Ep 204 (Step 281k) Dense 512px pre-decay checkpoint
epoch_209_step_290199 Stage 2 Final Ep 209 (Step 290k) Recommended for 512px–768px inference

512px Generation Outputs

512px Samples Figure: 512px generations demonstrating improved micro-texture, eyes, and line definition achieved in Stage 2.


Inference and WebUI

The training repository has a simple Gradio UI to perform sampling with camera controls. ui_app.py

Recommended Settings

  • Sampling Algorithm: Forward Euler ODE Solver (Rectified Flow)
  • Inference Steps: 25 – 35
  • CFG Scale: 4.5 – 6.0
  • Time Shift: 1.0 – 3.0 (higher values enhance contrast/saturation)

Tag Formatting Template

1girl/1boy, character name, series name, artists, rating, quality tags, actions/clothing

Negative prompt:

sketch, monochrome, english text, realistic, traditional media, very displeasing, displeasing, bad score, worse score, bad quality,worst quality, worst detail, watermark, signature, blurry, bad hands, bad anatomy, bad fingers, extra fingers, extra limbs, deformed limbs, comic, speech bubble, lowres

Python Sampling Script

import torch
from omegaconf import OmegaConf
from src.models.factory import load_trainable_model
from src.diffusion.schedules import LinearSchedule
from src.diffusion.sampling import generate_samples
cfg = OmegaConf.load("config.yaml")
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
dtype = torch.bfloat16
unet, text_encoder, vae, tokenizer, _ = load_trainable_model(
    models_path=cfg.paths.models,
    device=device,
    dtype=dtype,
    resume_from_checkpoint="path_to_checkpoint",
    model_type="sprint_dual",
    model_cfg=cfg.models,
    autocast_dtype=dtype,
)
schedule = LinearSchedule(device=device)
sample_configs = [
    {
        "prompt": "1girl, souryuu asuka langley, neon genesis evangelion, "
                  "masterpiece, absurdres",
        "negative_prompt": "very displeasing, displeasing, bad score",
        "height": 256,
        "width": 384,
        "sample_steps": 30,
        "cfg_scale": 6.0,
        "shift": 1.0,
        "zoom": 1.0,
        "x_shift": 0.0,
        "y_shift": 0.0,
        "seed": 42,
    }
]
images = generate_samples(
    unet=unet,
    text_encoder=text_encoder,
    tokenizer=tokenizer,
    vae=vae,
    schedule=schedule,
    sample_configs=sample_configs,
    global_batch_size=1,
    diffusion_type="flow_matching",
    device=device,
    dtype=dtype,
    autocast_dtype=dtype,
    use_unet_mult=False,
    vae_mean=cfg.models.vae_mean,
    vae_std=cfg.models.vae_std,
    in_channels=cfg.models.in_channels,
    coord_system="aspect_norm",
)
images[0].save("output.png")

Content Advisory & Limitations

  • Resolution Scope: Checkpoints up to epoch_209_* are natively optimized for 512px generation and reliably scale up to 768px/1024px with aspect-normalized RoPE. Native 1024px fidelity will be unlocked upon completion of Stage 3.
  • Complex Hands: The compact 200M parameter count prioritizes prompt faithfulness and character identity; complex hand interactions may still require multiple seed attempts.
  • NSFW & Sensitive Content: The model was trained on a dataset that contains uncensored anime-style art, including sensitive, questionable, and explicit material (g, s, q, e ratings). Use appropriate tag filtering during training if a SFW-only model is required.
  • Legal Disclaimer: Images are sourced from Danbooru for research, educational, and generative modeling purposes under fair use. Copyright of all underlying illustrations belongs to their respective creators.

References

License

This model is licensed under the CreativeML Open RAIL++-M License. You are free to use, modify, and distribute the model weights provided you include the license text and respect the behavioral use restrictions.

Downloads last month
-
Inference Examples
Examples
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Datasets used to train aipracticecafe/dual-stream-dit

Papers for aipracticecafe/dual-stream-dit