Semantic Detour Flow, JiT-B/16, standard window (0, 1), 20 and 30 epochs
A pixel-space flow-matching model (JiT-B/16) whose noisy state passes through the image's DINOv2-B code before it reaches pixels. The target is handed over from the code to the image by a smoothstep over the whole time axis, w(t) = 3t² − 2t³ (t = 0 is noise, t = 1 is the clean image). Sampling is a pixel ODE from Gaussian noise straight to RGB; no encoder or decoder is used at sampling time.
ImageNet 256×256, class-conditional, batch 1024. The root folder holds the epoch-20 checkpoint, epoch30/ the same run continued to 30 epochs. Unguided (cfg 1.0), Heun 50, scored on the EMA2 weights:
| Model (batch 1024) | Epochs | FID-10k ↓ | FID-50k ↓ | IS ↑ (10k) |
|---|---|---|---|---|
This repo, epoch30/, Detour (0, 1), EMA2 | 30 | 52.1 | — | 33.1 |
| This repo, root, Detour (0, 1), EMA2 | 20 | 66.6 | 63.9 | 24.3 |
| Detour (0.10, 1.00), same setup (not in this repo) | 20 | 68.6 | — | 24.0 |
| Detour (0.40, 0.85), earlier release | 20 | 89.2 | — | 18.2 |
| Plain pixel JiT-B/16 | 20 | 98.1 | — | 12.8 |
All FIDs against JiT's ImageNet-256 training statistics, on the 0.9996 EMA of the weights (raw weights swing by about ±13 FID between checkpoints at this stage).
Files
| File | Contents |
|---|---|
model_ema2_0.9996.safetensors | Recommended. EMA with decay 0.9996; the numbers above come from these weights |
model_raw.safetensors | Raw weights after 20 epochs |
model_ema1_0.9999.safetensors | EMA with decay 0.9999 (lags too far behind at 20 epochs; not recommended yet) |
training_args.json | Full training configuration (local paths and logging settings removed) |
detour_init_dinov2b_C768.pt | Per-channel normalization statistics of the DINOv2-B code, required to build the model |
epoch30/ | The same three weight files and training_args.json after 30 epochs (continuation of the same run; EMA1 is still 0.9999) |
Model
- JiT-B/16 with two changes: no patch bottleneck (
--bottleneck_dim 768), and an RAE DiT^DH-style wide head (2 blocks of width 2048, per-token adaLN from the encoder features, its own full-width 16×16 patchify of the noisy input;--ddt_head_dim 2048). - Two output heads: the clean image x̂ and the DINOv2-B code ĉ (embedded in pixel space by a fixed PixelShuffle). Training loss: squared error on the Detour path velocity.
- AdamW, lr 2e-4, 5 warm-up epochs, logit-normal t (mean −0.8, std 0.8), 10% label dropout, bf16.
Usage
Needs the project code (JiT/ from the rae_pixel repository) and its environment.
import json, sys, torch
from safetensors.torch import load_file
sys.path.insert(0, "rae_pixel/JiT") # the project code
from main_jit import get_args_parser
from denoiser import Denoiser
args = get_args_parser().parse_args([])
for k, v in json.load(open("training_args.json")).items():
setattr(args, k, v)
args.detour_init = "detour_init_dinov2b_C768.pt"
args.cfg = 1.0 # unguided; for CFG use args.interval_min = 0.0 (see below)
args.num_sampling_steps = 50 # Heun
model = Denoiser(args).cuda().eval()
model.load_state_dict(load_file("epoch30/model_ema2_0.9996.safetensors")) # or the root file for epoch 20
with torch.no_grad(), torch.autocast("cuda", dtype=torch.bfloat16):
images = model.generate(torch.tensor([207, 88, 279, 417], device="cuda")) # about [-1, 1], shape [4, 3, 256, 256]
images = ((images.float() + 1) / 2).clamp(0, 1)
Samplers: args.sampling_method = "heun" | "euler" | "remix" (remix is the Detour endpoint-remix step), and
args.time_grid = "uniform" | "jump".
Guidance. Classifier-free guidance changes the content of a Detour sample only when it acts at t < 0.1, where the
state is mostly the semantic code. Use args.interval_min = 0.0 (JiT's default interval [0.1, 1] gives almost no effect).
Limitations
20-epoch research checkpoint: objects are recognisable, but fine detail is missing and some samples have 16-pixel seams. It needs about 4 network calls for a recognisable layout and about 10 for the final composition; a single call returns the code pattern, not an image. A 40-epoch continuation of this run is training and will be added.