--- base_model: ByteDance-Seed/SeedVR2-3B base_model_relation: quantized license: apache-2.0 pipeline_tag: image-to-video library_name: onnx tags: - onnx - moonbox - onnxruntime - seedvr2 - video-super-resolution - video-restoration --- # SeedVR2 ONNX ONNX builds of [SeedVR2](https://huggingface.co/ByteDance-Seed/SeedVR2-3B), made by Moonbox for on-device use with ONNX Runtime (CPU, CUDA, DirectML). Each precision is one folder holding the graphs and a small Python `pipeline.py` that does the rest (image preprocessing, the frame loop, mask handling); what the graphs take and return is under *How to run*. ## Files The last column is the benchmark against the original PyTorch model (details under *How to run*): how closely each output frame matches the original's on the same clips and masks. | Precision | File | Size | sha256 | Benchmark | |---|---|---|---|---| | fp16 | [`fp16/LICENSE.txt`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/fp16/LICENSE.txt) | 11.5 kB | `fa62fea050d2` | PSNR vs the original: mean 40.8 / 33.3 dB, worst frame 40.5 / 32.9 dB; ~25 s per clip incl. process / session start (CUDA; original 6 s) | | fp16 | [`fp16/dit.onnx`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/fp16/dit.onnx) | 1.6 MB | `2abfbfe54b7a` | PSNR vs the original: mean 40.8 / 33.3 dB, worst frame 40.5 / 32.9 dB; ~25 s per clip incl. process / session start (CUDA; original 6 s) | | fp16 | [`fp16/dit.onnx.data`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/fp16/dit.onnx.data) | 6.69 GB | `bd4afa1dd50e` | PSNR vs the original: mean 40.8 / 33.3 dB, worst frame 40.5 / 32.9 dB; ~25 s per clip incl. process / session start (CUDA; original 6 s) | | fp16 | [`fp16/pipeline.py`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/fp16/pipeline.py) | 12.6 kB | `41341ecf6d57` | PSNR vs the original: mean 40.8 / 33.3 dB, worst frame 40.5 / 32.9 dB; ~25 s per clip incl. process / session start (CUDA; original 6 s) | | fp16 | [`fp16/vae_dec_first.onnx`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/fp16/vae_dec_first.onnx) | 301.7 MB | `8250314ef04d` | PSNR vs the original: mean 40.8 / 33.3 dB, worst frame 40.5 / 32.9 dB; ~25 s per clip incl. process / session start (CUDA; original 6 s) | | fp16 | [`fp16/vae_dec_next.onnx`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/fp16/vae_dec_next.onnx) | 301.5 MB | `e300dd92f6f7` | PSNR vs the original: mean 40.8 / 33.3 dB, worst frame 40.5 / 32.9 dB; ~25 s per clip incl. process / session start (CUDA; original 6 s) | | fp16 | [`fp16/vae_enc_first.onnx`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/fp16/vae_enc_first.onnx) | 200.5 MB | `d6a9041ed8a4` | PSNR vs the original: mean 40.8 / 33.3 dB, worst frame 40.5 / 32.9 dB; ~25 s per clip incl. process / session start (CUDA; original 6 s) | | fp16 | [`fp16/vae_enc_next.onnx`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/fp16/vae_enc_next.onnx) | 200.3 MB | `bcffa79fd16d` | PSNR vs the original: mean 40.8 / 33.3 dB, worst frame 40.5 / 32.9 dB; ~25 s per clip incl. process / session start (CUDA; original 6 s) | | int8 | [`int8/LICENSE.txt`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/int8/LICENSE.txt) | 11.5 kB | `fa62fea050d2` | DiT MatMuls 8-bit: PSNR mean 40.4 / 33.2 dB, worst frame 40.1 / 32.8 dB; ~24 s per clip (CUDA) | | int8 | [`int8/dit.onnx`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/int8/dit.onnx) | 1.6 MB | `e73874804e60` | DiT MatMuls 8-bit: PSNR mean 40.4 / 33.2 dB, worst frame 40.1 / 32.8 dB; ~24 s per clip (CUDA) | | int8 | [`int8/dit.onnx.data`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/int8/dit.onnx.data) | 3.56 GB | `c36caaa97940` | DiT MatMuls 8-bit: PSNR mean 40.4 / 33.2 dB, worst frame 40.1 / 32.8 dB; ~24 s per clip (CUDA) | | int8 | [`int8/pipeline.py`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/int8/pipeline.py) | 12.6 kB | `41341ecf6d57` | DiT MatMuls 8-bit: PSNR mean 40.4 / 33.2 dB, worst frame 40.1 / 32.8 dB; ~24 s per clip (CUDA) | | int8 | [`int8/vae_dec_first.onnx`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/int8/vae_dec_first.onnx) | 301.7 MB | `8250314ef04d` | DiT MatMuls 8-bit: PSNR mean 40.4 / 33.2 dB, worst frame 40.1 / 32.8 dB; ~24 s per clip (CUDA) | | int8 | [`int8/vae_dec_next.onnx`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/int8/vae_dec_next.onnx) | 301.5 MB | `e300dd92f6f7` | DiT MatMuls 8-bit: PSNR mean 40.4 / 33.2 dB, worst frame 40.1 / 32.8 dB; ~24 s per clip (CUDA) | | int8 | [`int8/vae_enc_first.onnx`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/int8/vae_enc_first.onnx) | 200.5 MB | `d6a9041ed8a4` | DiT MatMuls 8-bit: PSNR mean 40.4 / 33.2 dB, worst frame 40.1 / 32.8 dB; ~24 s per clip (CUDA) | | int8 | [`int8/vae_enc_next.onnx`](https://huggingface.co/moonbox-dev/SeedVR2-3B-ONNX/blob/main/int8/vae_enc_next.onnx) | 200.3 MB | `bcffa79fd16d` | DiT MatMuls 8-bit: PSNR mean 40.4 / 33.2 dB, worst frame 40.1 / 32.8 dB; ~24 s per clip (CUDA) | ## How to run SeedVR2-3B (ByteDance Seed: one-step diffusion video restoration and super-resolution) as five ONNX graphs plus `pipeline.py`, a numpy runtime that reproduces the repository's `projects/inference_seedvr2_3b.py`: one diffusion step at t = 1000, guidance 1, the repository's positive text embedding (baked into the DiT graph). Like the script, it has no colour fix: the script's `color_fix.py` isn't in the repository. **How it runs.** Resize the low-quality frames to the output size first, as the script does. Then: - **Encode:** the VAE encoder encodes the frames in causal slices (5 frames, then 4 per slice). - **Restore:** the NaDiT (a 3B diffusion transformer with windowed attention, two window layouts alternating) predicts the clean latent from noise in one step, conditioned on the encoded frames. - **Decode:** the VAE decoder decodes in causal slices (2 latents, then 1 per slice). **The graphs.** - `vae_enc_first.onnx` / `vae_enc_next.onnx`: - inputs: `x` [1, 3, n, H, W] in [-1, 1], plus the causal convolutions' memories; - outputs: moments [1, 32, t, H/8, W/8] (mean, log-variance), plus the new memories. - `dit.onnx`: - inputs: `vid` [T, h, w, 33] (noise, latent, 1), and for each window layout the token indices, key mask, inverse indices and RoPE tables (`pipeline.py` builds them as the repository's `make_720Pwindows_bysize` does); - output: `v` [T, h, w, 16]. - `vae_dec_first.onnx` / `vae_dec_next.onnx`: latents in, frames [1, 3, n, H, W] out (with the memories). ```python import sys from PIL import Image sys.path.insert(0, "fp16") import pipeline p = pipeline.SeedVR2("fp16", "cuda") frames = [Image.open(f"in/{i:05d}.png").convert("RGB") for i in range(17)] # already at the output size out = p(frames, seed=666) # list of uint8 RGB frames ``` Or `python fp16/pipeline.py frames_dir out_dir --cuda`. Frame sides must be multiples of 16. It needs numpy, onnxruntime-gpu and Pillow. **Ported as the original behaves.** - **Steps:** the script's padding to 4n + 1 frames, the VAE's scaling factor 0.9152, and the condition latent concatenated with a ones channel. - **Noise:** `pipeline.py` draws its own noise with numpy (seed 666 by default), so its output differs slightly from the original's. `draws=` replays your own draws. **Memory and processes.** Windows counts GPU allocations toward the commit limit, so `pipeline.py` runs the encode, the DiT and the decode each in its own process (`separate_processes=True`). - **DiT session:** needs about 7 GB with `fp16/` at these sizes. - **Decoder:** its sessions let cuDNN search its algorithms exhaustively, because the heuristic choices for some frame sizes need far more memory. Even so, decoding 17 frames at 384 x 384 peaks near 15 GB of commit on this machine (RTX 3080 Laptop, 16 GB). The runs sometimes had to be repeated to fit. - **Bigger clips:** cut them into shorter clips, or use a machine with more memory. **Precisions.** - `fp16/`: the DiT fp16 (the original runs bf16; here its bf16 weights are cast to fp16); the VAE graphs do fp16 math with fp32 inputs and outputs. - `int8/`: the DiT's MatMuls 8-bit MatMulNBits (block 32); the VAE as `fp16/`. - No int4: tried (the DiT 4-bit) and below the pass mark, 24.8 dB on example1. **Benchmark.** - **Clips:** two of 17 frames from FlashVSR's example clips, the low-res frames resized (bicubic) to the output size: example0 384 x 384, example1 512 x 288. - **Original:** `projects/inference_seedvr2_3b.py` (GitHub ByteDance-Seed/SeedVR @ e4de8c2) on CUDA under bf16 autocast as it runs, seed 666, with every random draw recorded. The builds replay those draws (`draws=`). - The DiT was loaded from bf16 copies of its weights: the script's fp32 weights don't fit in memory here. - Its fused kernels don't build on Windows (apex's fused norms, flash-attn's varlen attention), so the reference used the same operations in plain PyTorch. - **Score:** PSNR of every output frame against the original's. - **Pass mark:** at least 30 dB on every frame. | | PSNR mean (example0 / example1) | worst frame | seconds per clip | |---|---|---|---| | original (PyTorch bf16, CUDA) | - | - | 6.1 / 5.4 | | `fp16/` | 40.8 / 33.3 dB | 40.5 / 32.9 dB | 25 | | `int8/` | 40.4 / 33.2 dB | 40.1 / 32.8 dB | 23-25 | | int4 (not published) | - / 24.8 dB | - / 24.4 dB | 23 | The ONNX times include starting the three phase processes and loading their sessions. **License.** SeedVR2 is Apache-2.0 (`LICENSE.txt` in every folder). ## How these were made From [SeedVR2](https://huggingface.co/ByteDance-Seed/SeedVR2-3B) at revision `37255ff8cc`. The graphs were exported from the original PyTorch modules with torch.onnx (opset 17 / 18) and checked against them. Weight-only quantization: int8 is a per-output-channel int8 weight behind DequantizeLinear, int4 is ONNX Runtime's MatMulNBits (block 32). Each card above says which precision every graph uses. Every precision was benchmarked against the original before upload (the pass mark is under *How to run*), and the `sha256` column above is what the files must hash to. ## License Apache-2.0. These files are a derivative of the original model and carry its license: it is copied in this repository, and it governs your use of these files. The original model card follows unchanged. --- # Original model card
