Instructions to use ngoctham/SwiftVR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use ngoctham/SwiftVR with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("ngoctham/SwiftVR", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Duplicate from H-oliday/SwiftVR
Browse filesCo-authored-by: H-oliday <H-oliday@users.noreply.huggingface.co>
- .gitattributes +8 -0
- README.md +211 -0
- assets/demo_1.mp4 +3 -0
- assets/demo_2.mp4 +3 -0
- assets/demo_3.mp4 +3 -0
- assets/qualitative.png +3 -0
- assets/teaser.avif +3 -0
- prompt_embedding.safetensors +3 -0
- reae.safetensors +3 -0
- transformer/config.json +24 -0
- transformer/diffusion_pytorch_model.safetensors +3 -0
.gitattributes
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
videos/demo_1.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
videos/demo_2.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
videos/demo_3.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
assets/demo_1.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
assets/demo_2.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
assets/demo_3.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
assets/qualitative.png filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
assets/teaser.avif filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
pipeline_tag: video-to-video
|
| 4 |
+
library_name: diffusers
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
<h1 align="center">SwiftVR: Real-Time One-Step Generative Video Restoration</h1>
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
<p align="center"><img src="assets/teaser.avif" width="100%" alt="SwiftVR teaser"></p>
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
> **SwiftVR** is the first generative video restoration model to reach **real-time 1080p streaming on a consumer-grade GPU** (≈26 FPS on a single RTX 5090), sustains **31 FPS at QHD (2560×1440)** and **14 FPS at 4K (3840×2160)** on a single H100, and streams at resolutions where every compared diffusion-based VR baseline runs out of memory.
|
| 16 |
+
|
| 17 |
+
<p>
|
| 18 |
+
<a href="https://arxiv.org/abs/2606.09516"><img src="https://img.shields.io/badge/arXiv-2606.09516-b31b1b.svg?style=flat-square" alt="arXiv"></a>
|
| 19 |
+
<a href="https://h-oliday.github.io/SwiftVR/"><img src="https://img.shields.io/badge/Project-Page-1f8acb.svg?style=flat-square" alt="Project Page"></a>
|
| 20 |
+
<a href="https://github.com/H-oliday/SwiftVR">
|
| 21 |
+
<img src="https://img.shields.io/badge/GitHub-Code-181717.svg?style=flat-square&logo=github" alt="GitHub">
|
| 22 |
+
</a>
|
| 23 |
+
<a href="https://github.com/H-oliday/SwiftVR/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-green.svg?style=flat-square" alt="License"></a>
|
| 24 |
+
</p>
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
SwiftVR is a streaming one-step generative video restoration (VR) framework presented in [SwiftVR: Real-Time One-Step Generative Video Restoration](https://arxiv.org/abs/2606.09516).
|
| 28 |
+
|
| 29 |
+
## Updates
|
| 30 |
+
|
| 31 |
+
- [2026/06] Release the inference code and pretrained weights 🎉
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
## ✨ Highlights
|
| 38 |
+
|
| 39 |
+
- **Mask-free shifted-window self-attention (MFSWA).** Each spatial window is **pre-gathered into a dense tensor**, so every attention call reduces to a single standard scaled-dot-product (SDPA) call — *no attention mask, cyclic shift, or padding ever enters the graph*. This gives a **1.62× throughput gain over its full-attention teacher** at essentially identical quality, with **no dedicated sparse kernel**.
|
| 40 |
+
- **Restoration-aware Autoencoder (ReAE).** A lightweight encoder–decoder jointly fine-tuned with the DiT in pixel space removes the heavy-3D-VAE / tiled-decoding bottleneck.
|
| 41 |
+
- **Causal chunk-wise streaming.** A minimal causal protocol (no rolling KV cache, no overlapped DiT inference) bounds the temporal axis, confining the residual \(\mathcal{O}(N^2)\) cost to the spatial axes.
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
## 📊 Results
|
| 45 |
+
|
| 46 |
+
### Efficiency at 2560×1440 (single H100, causal streaming, 24 frames)
|
| 47 |
+
|
| 48 |
+
| Metric | DOVE (tile) | SeedVR2-3B (tile)| FlashVSR-Tiny | **SwiftVR (Ours)** |
|
| 49 |
+
|---|:---:|:---:|:---:|:---:|
|
| 50 |
+
| Avg. Time (s) ↓ | 27.615 | 17.320 | 2.493 | 0.766 |
|
| 51 |
+
| FPS ↑ | 0.85 | 1.39 | 9.61 | 31.32 |
|
| 52 |
+
| Peak Mem. (GB) ↓ | 59.24 | 35.35 | 34.35 | 38.01 |
|
| 53 |
+
|
| 54 |
+
> At **3840×2160**, every compared diffusion-based VR baseline **OOMs** on a single H100; SwiftVR sustains **14 FPS**.
|
| 55 |
+
|
| 56 |
+
### Qualitative comparison
|
| 57 |
+
|
| 58 |
+
<img src="assets/qualitative.png" width="100%" alt="SwiftVR teaser">
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
## 🛠 Installation
|
| 63 |
+
|
| 64 |
+
```bash
|
| 65 |
+
git clone https://github.com/H-oliday/SwiftVR.git
|
| 66 |
+
cd SwiftVR
|
| 67 |
+
|
| 68 |
+
conda create -n swiftvr python=3.10 -y
|
| 69 |
+
conda activate swiftvr
|
| 70 |
+
|
| 71 |
+
# Install PyTorch matching your CUDA toolkit first, e.g. CUDA 12.4:
|
| 72 |
+
pip install torch==2.10.0 torchvision==0.25.0 --index-url https://download.pytorch.org/whl/cu124
|
| 73 |
+
|
| 74 |
+
# Install SwiftVR (editable) and its dependencies:
|
| 75 |
+
pip install -e .
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
<details>
|
| 79 |
+
<summary><b>Hardware notes</b></summary>
|
| 80 |
+
|
| 81 |
+
- **Server:** single H100-80G reproduces the QHD/4K numbers above.
|
| 82 |
+
- **Consumer:** single RTX 5090 reaches ≈26 FPS at 1080p with the *same checkpoint* (default PyTorch SDPA path, bfloat16, causal chunk protocol).
|
| 83 |
+
- No hardware-specific retraining or kernel rewrite is required on any platform.
|
| 84 |
+
</details>
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
## 🗂 Model Zoo
|
| 89 |
+
|
| 90 |
+
| Model Name | Date | Backbone | Link |
|
| 91 |
+
|---|---|---|---|
|
| 92 |
+
| SwiftVR | 2026.06 | Wan2.2-TI2V-5B | [🤗 HuggingFace](https://huggingface.co/H-oliday/SwiftVR) |
|
| 93 |
+
|
| 94 |
+
```bash
|
| 95 |
+
huggingface-cli download H-oliday/SwiftVR --local-dir checkpoints/
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
Expected checkpoint layout (the directory passed to `from_pretrained`):
|
| 99 |
+
|
| 100 |
+
```
|
| 101 |
+
checkpoints/
|
| 102 |
+
├── reae.safetensors # Restoration-aware Autoencoder weights
|
| 103 |
+
├── prompt_embedding.safetensors# precomputed empty-prompt text embedding (key: "prompt_emb")
|
| 104 |
+
└── transformer/ # diffusers-format DiT
|
| 105 |
+
├── config.json
|
| 106 |
+
└── diffusion_pytorch_model.safetensors
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
## 🚀 Quick Start
|
| 111 |
+
|
| 112 |
+
### Python API
|
| 113 |
+
|
| 114 |
+
```python
|
| 115 |
+
from swiftvr import SwiftVRPipeline
|
| 116 |
+
|
| 117 |
+
pipe = SwiftVRPipeline.from_pretrained("H-oliday/SwiftVR").to("cuda", dtype="bfloat16")
|
| 118 |
+
|
| 119 |
+
pipe.restore_video("low_quality.mp4", "restored.mp4", upscale=4)
|
| 120 |
+
```
|
| 121 |
+
|
| 122 |
+
`restore_video` also accepts an image folder as input and can write a PNG sequence with `png_save=True`.
|
| 123 |
+
|
| 124 |
+
Tunable knobs include:
|
| 125 |
+
|
| 126 |
+
* `clip_len`: middle chunk size, multiple of 4
|
| 127 |
+
* `dit_overlap`: overlap for DiT inference
|
| 128 |
+
* `fps`: output video frame rate
|
| 129 |
+
* `quality`: 0–100, mapped to x265 CRF
|
| 130 |
+
* `queue_size`: pipeline queue size
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
### Streaming (causal, chunk by chunk, no future frames)
|
| 134 |
+
|
| 135 |
+
Causal, chunk-by-chunk restoration without future frames.
|
| 136 |
+
|
| 137 |
+
```python
|
| 138 |
+
session = pipe.stream(clip_len=24, resolution=(1920, 1080))
|
| 139 |
+
|
| 140 |
+
for lq_chunk in read_chunks("low_quality.mp4", n=24): # lq_chunk: [T, H, W, 3] uint8
|
| 141 |
+
hq = session.step(lq_chunk) # [1, T', 3, H', W'] in [0, 1], or None if buffered
|
| 142 |
+
if hq is not None:
|
| 143 |
+
write(hq)
|
| 144 |
+
|
| 145 |
+
tail = session.flush() # flush the final buffered frames
|
| 146 |
+
```
|
| 147 |
+
|
| 148 |
+
### Command line
|
| 149 |
+
|
| 150 |
+
```bash
|
| 151 |
+
python scripts/inference.py \
|
| 152 |
+
--input low_quality.mp4 \
|
| 153 |
+
--output restored.mp4 \
|
| 154 |
+
--checkpoint checkpoints/ \
|
| 155 |
+
--upscale 4 \
|
| 156 |
+
--clip-len 24 \
|
| 157 |
+
--dtype bfloat16 \
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
Use `--png` to write a PNG sequence.
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
## 🎬 More Visual Results
|
| 164 |
+
|
| 165 |
+
> Full-length restored clips (low-quality input → SwiftVR, played back to back).
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
<video src="https://huggingface.co/H-oliday/SwiftVR/resolve/main/assets/demo_1.mp4" controls width="100%"></video>
|
| 169 |
+
|
| 170 |
+
<video src="https://huggingface.co/H-oliday/SwiftVR/resolve/main/assets/demo_2.mp4" controls width="100%"></video>
|
| 171 |
+
|
| 172 |
+
<video src="https://huggingface.co/H-oliday/SwiftVR/resolve/main/assets/demo_3.mp4" controls width="100%"></video>
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
## 🙏 Acknowledgements
|
| 178 |
+
|
| 179 |
+
SwiftVR builds on [Wan2.2-TI2V-5B](https://github.com/Wan-Video), the lightweight autoencoder [TAEHV](https://github.com/madebyollin/taehv), and the [RealBasicVSR](https://github.com/ckkelvinchan/RealBasicVSR) degradation pipeline. We thank the authors of [DOVE](https://github.com/zhengchen1999/DOVE), [SeedVR2](https://github.com/ByteDance-Seed/SeedVR), and [FlashVSR](https://github.com/OpenImagingLab/FlashVSR) for releasing strong baselines, and the [UltraVideo](https://github.com/Tele-AI/UltraVideo) team for the training corpus.
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
## 📜 License
|
| 184 |
+
|
| 185 |
+
SwiftVR is released under the **Apache License 2.0**.
|
| 186 |
+
|
| 187 |
+
Copyright 2026 SwiftVR Authors.
|
| 188 |
+
|
| 189 |
+
Licensed under the Apache License, Version 2.0. You may obtain a copy of the License at:
|
| 190 |
+
|
| 191 |
+
https://www.apache.org/licenses/LICENSE-2.0
|
| 192 |
+
|
| 193 |
+
Unless required by applicable law or agreed to in writing, this project is distributed on an **"AS IS" BASIS**, without warranties or conditions of any kind, either express or implied. See the [LICENSE](./LICENSE) file for the full license text.
|
| 194 |
+
|
| 195 |
+
## 📜 Citation
|
| 196 |
+
|
| 197 |
+
```bibtex
|
| 198 |
+
@article{yan2026swiftvr,
|
| 199 |
+
title={SwiftVR: Real-Time One-Step Generative Video Restoration},
|
| 200 |
+
author={Yan, Jiaqi and Chen, Xiangyu and Zhong, Xinlin and Huang, Haibin and Zhang, Chi and Liu, Jie and Zhou, Jiantao and Li, Xuelong},
|
| 201 |
+
journal={arXiv preprint arXiv:2606.09516},
|
| 202 |
+
year={2026}
|
| 203 |
+
}
|
| 204 |
+
```
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
## Contact
|
| 208 |
+
|
| 209 |
+
If you have any questions, feel free to reach out:
|
| 210 |
+
|
| 211 |
+
* Email: [kakibluee@gmail.com](mailto:kakibluee@gmail.com)
|
assets/demo_1.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a16afce37f246f656bd10173a48229b6963d15524f993fd4994b9f5418300502
|
| 3 |
+
size 47893064
|
assets/demo_2.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f70c43561acac06b9bc98df9c148f8b05671fad52ab4510ea083c695bff8463a
|
| 3 |
+
size 65596485
|
assets/demo_3.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:696127bbaf6f04382bdcf3889d84d5c6ebf9d933d8bac01d2c659a9e2027ef3e
|
| 3 |
+
size 60469172
|
assets/qualitative.png
ADDED
|
Git LFS Details
|
assets/teaser.avif
ADDED
|
Git LFS Details
|
prompt_embedding.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cc4cf7b9aa9def4026bb5952b8aaec846ffc83eee43cafff0d3796b7e9fdf922
|
| 3 |
+
size 4202976
|
reae.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c915205d1833677b6887e2fdf675499d3fc781af0c644c99330f7d22fd855514
|
| 3 |
+
size 163797568
|
transformer/config.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "WanTransformer3DModel",
|
| 3 |
+
"_diffusers_version": "0.35.0.dev0",
|
| 4 |
+
"added_kv_proj_dim": null,
|
| 5 |
+
"attention_head_dim": 128,
|
| 6 |
+
"cross_attn_norm": true,
|
| 7 |
+
"eps": 1e-06,
|
| 8 |
+
"ffn_dim": 14336,
|
| 9 |
+
"freq_dim": 256,
|
| 10 |
+
"image_dim": null,
|
| 11 |
+
"in_channels": 48,
|
| 12 |
+
"num_attention_heads": 24,
|
| 13 |
+
"num_layers": 30,
|
| 14 |
+
"out_channels": 48,
|
| 15 |
+
"patch_size": [
|
| 16 |
+
1,
|
| 17 |
+
2,
|
| 18 |
+
2
|
| 19 |
+
],
|
| 20 |
+
"pos_embed_seq_len": null,
|
| 21 |
+
"qk_norm": "rms_norm_across_heads",
|
| 22 |
+
"rope_max_seq_len": 1024,
|
| 23 |
+
"text_dim": 4096
|
| 24 |
+
}
|
transformer/diffusion_pytorch_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f7ade5b8f7f4ff8b4e26a581772ebe5bcfb6a619ece2dd3483c5395c2d7e1a31
|
| 3 |
+
size 19999235584
|