SeedVR2-3B-ONNX / README.md
jennyxue's picture
Model card and the original license
e2a111d verified
|
Raw History Blame Contribute Delete
15.7 kB
---
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
<div align="center">
<img src="assets/seedvr_logo.png" alt="SeedVR" width="400"/>
</div>
# SeedVR2: One-Step Video Restoration via Diffusion Adversarial Post-Training
> [Jianyi Wang](https://iceclear.github.io), [Shanchuan Lin](https://scholar.google.com/citations?user=EDWUw7gAAAAJ&hl=en), [Zhijie Lin](https://scholar.google.com/citations?user=xXMj6_EAAAAJ&hl=en), [Yuxi Ren](https://scholar.google.com.hk/citations?user=C_6JH-IAAAAJ&hl=en), [Meng Wei](https://openreview.net/profile?id=~Meng_Wei11), [Zongsheng Yue](https://zsyoaoa.github.io/), [Shangchen Zhou](https://shangchenzhou.com/), [Hao Chen](https://haochen-rye.github.io/), [Yang Zhao](https://scholar.google.com/citations?user=uPmTOHAAAAAJ&hl=en), [Ceyuan Yang](https://ceyuan.me/), [Xuefeng Xiao](https://scholar.google.com/citations?user=CVkM9TQAAAAJ&hl=en), [Chen Change Loy](https://www.mmlab-ntu.com/person/ccloy/index.html), [Lu Jiang](http://www.lujiang.info/)
<p align="center">
<a href="https://iceclear.github.io/projects/seedvr2/">
<img
src="https://img.shields.io/badge/SeedVR2-Website-0A66C2?logo=safari&logoColor=white"
alt="SeedVR Website"
/>
</a>
<a href="http://arxiv.org/abs/2506.05301">
<img
src="https://img.shields.io/badge/SeedVR2-Paper-red?logo=arxiv&logoColor=red"
alt="SeedVR2 Paper on ArXiv"
/>
</a>
<a href="https://github.com/ByteDance-Seed/SeedVR">
<img
alt="Github" src="https://img.shields.io/badge/SeedVR2-Codebase-536af5?color=536af5&logo=github"
alt="SeedVR2 Codebase"
/>
</a>
<a href="https://huggingface.co/collections/ByteDance-Seed/seedvr-6849deeb461c4e425f3e6f9e">
<img
src="https://img.shields.io/badge/SeedVR-Models-yellow?logo=huggingface&logoColor=yellow"
alt="SeedVR Models"
/>
</a>
<a href="https://huggingface.co/spaces/ByteDance-Seed/SeedVR2-3B">
<img
src="https://img.shields.io/badge/SeedVR2-Space-orange?logo=huggingface&logoColor=yellow"
alt="SeedVR2 Space"
/>
</a>
<a href="https://www.youtube.com/watch?v=tM8J-WhuAH0" target='_blank'>
<img
src="https://img.shields.io/badge/Demo%20Video-%23FF0000.svg?logo=YouTube&logoColor=white"
alt="SeedVR2 Video Demo on YouTube"
/>
</a>
</p>
>
> Recent advances in diffusion-based video restoration (VR) demonstrate significant improvement in visual quality, yet yield a prohibitive computational cost during inference. While several distillation-based approaches have exhibited the potential of one-step image restoration, extending existing approaches to VR remains challenging and underexplored, due to the limited generation ability and poor temporal consistency, particularly when dealing with high-resolution video in real-world settings. In this work, we propose a one-step diffusion-based VR model, termed as SeedVR2, which performs adversarial VR training against real data. To handle the challenging high-resolution VR within a single step, we introduce several enhancements to both model architecture and training procedures. Specifically, an adaptive window attention mechanism is proposed, where the window size is dynamically adjusted to fit the output resolutions, avoiding window inconsistency observed under high-resolution VR using window attention with a predefined window size. To stabilize and improve the adversarial post-training towards VR, we further verify the effectiveness of a series of losses, including a proposed feature matching loss without significantly sacrificing training efficiency. Extensive experiments show that SeedVR2 can achieve comparable or even better performance compared with existing VR approaches in a single step.
<p align="center"><img src="assets/teaser.png" width="100%"></p>
## 📮 Notice
**Limitations:** These are the prototype models and the performance may not be perfectly align with the paper. Our methods are sometimes not robust to heavy degradations and very large motions, and shares some failure cases with existing methods, e.g., fail to fully remove the degradation or simply generate unpleasing details. Moreover, due to the strong generation ability, Our methods tend to overly generate details on inputs with very light degradations, e.g., 720p AIGC videos, leading to oversharpened results occasionally.
## ✍️ Citation
```bibtex
@article{wang2025seedvr2,
title={SeedVR2: One-Step Video Restoration via Diffusion Adversarial Post-Training},
author={Wang, Jianyi and Lin, Shanchuan and Lin, Zhijie and Ren, Yuxi and Wei, Meng and Yue, Zongsheng and Zhou, Shangchen and Chen, Hao and Zhao, Yang and Yang, Ceyuan and Xiao, Xuefeng and Loy, Chen Change and Jiang, Lu},
booktitle={arXiv preprint arXiv:2506.05301},
year={2025}
}
@inproceedings{wang2025seedvr,
title={SeedVR: Seeding Infinity in Diffusion Transformer Towards Generic Video Restoration},
author={Wang, Jianyi and Lin, Zhijie and Wei, Meng and Zhao, Yang and Yang, Ceyuan and Loy, Chen Change and Jiang, Lu},
booktitle={CVPR},
year={2025}
}
```
## 📜 License
SeedVR and SeedVR2 are licensed under the Apache 2.0.