Instructions to use nickchiu/Refocusing-Any-Video with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use nickchiu/Refocusing-Any-Video with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-video-diffusion-img2vid", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("nickchiu/Refocusing-Any-Video") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -6,144 +6,64 @@ tags:
|
|
| 6 |
- video-refocusing
|
| 7 |
- video-diffusion
|
| 8 |
- lora
|
| 9 |
-
model-index: []
|
| 10 |
license: other
|
| 11 |
license_name: stable-video-diffusion-community
|
| 12 |
license_link: https://huggingface.co/nickchiu/Refocusing-Any-Video/blob/main/LICENSE-SVD.txt
|
| 13 |
---
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
Powered by Stability AI.
|
| 18 |
-
|
| 19 |
-
Model bundle for Refocusing Any Video (RAV). Video Defocus Deblurring (VDD) recovers an all-in-focus video from an out-of-focus input; Video Bokeh Rendering (VBR) renders a target focal plane using the recovered video and a depth sequence. Optional Identity Adapter and Track4Gen Refiner variants condition VDD on reference faces.
|
| 20 |
-
|
| 21 |
-
Use these weights with the accompanying Refocus Any Video source implementation and its README. This bundle contains adapters and a learned input convolution; it is not a standalone Diffusers pipeline and does not include the Stable Video Diffusion base model.
|
| 22 |
-
|
| 23 |
-
## Included files
|
| 24 |
-
|
| 25 |
-
The repository root maps directly to the source repository's `checkpoints/` directory:
|
| 26 |
-
|
| 27 |
-
```text
|
| 28 |
-
vdd_weights/checkpoint-90000/
|
| 29 |
-
unet_lora/adapter_config.json
|
| 30 |
-
unet_lora/adapter_model.safetensors
|
| 31 |
-
vbr_weights/checkpoint-100000/
|
| 32 |
-
unet_lora/adapter_config.json
|
| 33 |
-
unet_lora/adapter_model.safetensors
|
| 34 |
-
unet_conv_in_refocus.pt
|
| 35 |
-
identity_adapter/ip_adapter.bin
|
| 36 |
-
identity_adapter_track4gen/ip_adapter.bin
|
| 37 |
-
facenet/
|
| 38 |
-
pnet.pt
|
| 39 |
-
rnet.pt
|
| 40 |
-
onet.pt
|
| 41 |
-
LICENSE.md
|
| 42 |
-
README.md
|
| 43 |
-
LICENSE-SVD.txt
|
| 44 |
-
NOTICE.txt
|
| 45 |
-
bundle_manifest.json
|
| 46 |
-
```
|
| 47 |
-
|
| 48 |
-
| Component | Purpose and checkpoint provenance |
|
| 49 |
-
| --- | --- |
|
| 50 |
-
| VDD LoRA | SVD UNet adapters from the supplied `checkpoint-90000` directory. |
|
| 51 |
-
| VBR LoRA and input convolution | Adapters and learned 12-channel input convolution from the supplied `checkpoint-100000` directory. Both files are required for VBR. |
|
| 52 |
-
| Identity Adapter | Copied from the supplied identity experiment's `checkpoint-5000/ip_adapter.bin`. Use with `infer_vdd_identity.sh`. |
|
| 53 |
-
| Identity Adapter + Track4Gen Refiner | Copied from the supplied Track4Gen experiment's `checkpoint-25000/ip_adapter.bin`. Use with `infer_vdd_identity_track4gen.sh`. |
|
| 54 |
-
| MTCNN | Third-party `pnet`, `rnet`, and `onet` detector weights from the implementation's vendored facenet-pytorch assets. The upstream MIT license is retained in `facenet/LICENSE.md`. |
|
| 55 |
-
|
| 56 |
-
The VDD and VBR PEFT configurations both specify LoRA rank 32 and alpha 32. VDD also adapts `conv_in`; VBR saves its expanded input convolution separately from its LoRA. The identity variants load on top of the VDD checkpoint, rather than replacing it.
|
| 57 |
|
| 58 |
-
|
| 59 |
|
| 60 |
-
|
|
|
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
```bash
|
| 65 |
-
python tools/checkpoints/transfer_checkpoints.py download \
|
| 66 |
-
--repo-id nickchiu/Refocusing-Any-Video --local-dir ./checkpoints
|
| 67 |
-
```
|
| 68 |
-
|
| 69 |
-
Alternatively, download with the Hugging Face Python client:
|
| 70 |
-
|
| 71 |
-
```python
|
| 72 |
-
from huggingface_hub import snapshot_download
|
| 73 |
-
|
| 74 |
-
snapshot_download(repo_id="nickchiu/Refocusing-Any-Video", local_dir="./checkpoints")
|
| 75 |
-
```
|
| 76 |
|
| 77 |
-
|
| 78 |
|
| 79 |
-
##
|
| 80 |
|
| 81 |
-
|
|
|
|
| 82 |
|
| 83 |
-
|
| 84 |
-
| --- | --- | --- |
|
| 85 |
-
| Stable Video Diffusion, 14-frame img2vid | [stabilityai/stable-video-diffusion-img2vid](https://huggingface.co/stabilityai/stable-video-diffusion-img2vid) | `checkpoints/svdh/` |
|
| 86 |
-
| Video Depth Anything, relative-depth Large | [Video Depth Anything](https://github.com/DepthAnything/Video-Depth-Anything) | `checkpoints/video_depth_anything_vitl.pth` |
|
| 87 |
-
| FaRL ViT-B/16, ep16 | [FaRL pretrained backbones](https://github.com/FacePerceiver/FaRL#pre-trained-backbones) | `checkpoints/farl/FaRL-Base-Patch16-LAIONFace20M-ep16.pth` |
|
| 88 |
-
| ArcFace IR-SE50 | [pSp pretrained-model instructions](https://github.com/eladrich/pixel2style2pixel#pretrained-models) | `checkpoints/arcface/model_ir_se50.pth` |
|
| 89 |
-
| OpenAI CLIP ViT-B/16 | [OpenAI CLIP](https://github.com/openai/CLIP) | Downloaded into the CLIP cache by `clip.load("ViT-B/16")` for FaRL initialization. |
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
```bash
|
| 100 |
-
mkdir -p inputs results
|
| 101 |
-
|
| 102 |
-
# Estimate depth from the input video.
|
| 103 |
-
python VideoDepthAnything/infer_video_depth.py \
|
| 104 |
-
--input ./inputs/input.mp4 --output ./inputs/depth.mp4 \
|
| 105 |
-
--checkpoint ./checkpoints/video_depth_anything_vitl.pth \
|
| 106 |
-
--encoder vitl --device cuda
|
| 107 |
-
|
| 108 |
-
# Recover an all-in-focus video.
|
| 109 |
-
INPUT_VIDEO=./inputs/input.mp4 \
|
| 110 |
-
CHECKPOINT=./checkpoints/vdd_weights/checkpoint-90000 \
|
| 111 |
-
OUTPUT_DIR=./results/vdd OUTPUT_FPS=24 FP16=1 \
|
| 112 |
-
bash infer_vdd.sh
|
| 113 |
-
|
| 114 |
-
# Render a focal plane using the all-in-focus video and depth.
|
| 115 |
-
INPUT_VIDEO=./results/vdd/output.mp4 DEPTH_INPUT=./inputs/depth.mp4 \
|
| 116 |
-
CHECKPOINT=./checkpoints/vbr_weights/checkpoint-100000 \
|
| 117 |
-
FOCAL_PLANE=0.5 COC=27 OUTPUT_DIR=./results/vbr OUTPUT_FPS=24 FP16=1 \
|
| 118 |
-
bash infer_vbr_defocus_map.sh
|
| 119 |
-
```
|
| 120 |
|
| 121 |
-
|
| 122 |
|
| 123 |
-
|
| 124 |
|
| 125 |
```bash
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
IP_ADAPTER_PATH=./checkpoints/identity_adapter/ip_adapter.bin \
|
| 129 |
-
HEIGHT="" WIDTH="" OUTPUT_DIR=./results/vdd_identity \
|
| 130 |
-
OUTPUT_FPS=24 FP16=1 bash infer_vdd_identity.sh
|
| 131 |
```
|
| 132 |
|
| 133 |
-
|
| 134 |
|
| 135 |
-
##
|
| 136 |
|
| 137 |
-
|
| 138 |
|
| 139 |
-
|
| 140 |
|
| 141 |
-
##
|
| 142 |
|
| 143 |
-
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
- video-refocusing
|
| 7 |
- video-diffusion
|
| 8 |
- lora
|
|
|
|
| 9 |
license: other
|
| 10 |
license_name: stable-video-diffusion-community
|
| 11 |
license_link: https://huggingface.co/nickchiu/Refocusing-Any-Video/blob/main/LICENSE-SVD.txt
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# Refocusing Any Video: Temporally Consistent Video Refocusing for Dynamic Focal Planes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
**SIGGRAPH Asia 2026**
|
| 17 |
|
| 18 |
+
Chee Kim Gan, [Pin-Yen Chiu](https://itsnickchiu.github.io/), I-Sheng Fang, Jun-Cheng Chen
|
| 19 |
+
Research Center for Information Technology Innovation, Academia Sinica
|
| 20 |
|
| 21 |
+
Inference checkpoints for Refocusing Any Video (RAV). **Video Defocus Deblurring (VDD)** recovers an all-in-focus video; **Video Bokeh Rendering (VBR)** refocuses it using depth and a chosen focal plane. Optional identity adapters guide face restoration.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
[Source code and inference instructions](https://github.com/aiiu-lab/Refocusing-Any-Video)
|
| 24 |
|
| 25 |
+
## Release status
|
| 26 |
|
| 27 |
+
- [x] Inference code and pretrained checkpoints
|
| 28 |
+
- [ ] Training code — being prepared for a future release
|
| 29 |
|
| 30 |
+
## Checkpoints
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
| Folder | Contents |
|
| 33 |
+
| --- | --- |
|
| 34 |
+
| `vdd_weights/checkpoint-90000/` | VDD LoRA weights |
|
| 35 |
+
| `vbr_weights/checkpoint-100000/` | VBR LoRA weights and required input convolution |
|
| 36 |
+
| `identity_adapter/` | Identity Adapter |
|
| 37 |
+
| `identity_adapter_track4gen/` | Identity Adapter with Track4Gen Refiner |
|
| 38 |
+
| `facenet/` | MTCNN face detector weights |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
## Download and inference
|
| 41 |
|
| 42 |
+
After setting up the [code environment](https://github.com/aiiu-lab/Refocusing-Any-Video#environment), run from the cloned code repository root:
|
| 43 |
|
| 44 |
```bash
|
| 45 |
+
python tools/checkpoints/transfer_checkpoints.py download \
|
| 46 |
+
--repo-id nickchiu/Refocusing-Any-Video --local-dir ./checkpoints
|
|
|
|
|
|
|
|
|
|
| 47 |
```
|
| 48 |
|
| 49 |
+
Download SVD, Video Depth Anything, and the auxiliary face models separately using the [checkpoint guide](https://github.com/aiiu-lab/Refocusing-Any-Video/blob/main/checkpoints/README.md), then follow the [inference example](https://github.com/aiiu-lab/Refocusing-Any-Video#inference). These adapters require the code and SVD base model. Generated details may differ from the original scene.
|
| 50 |
|
| 51 |
+
## Models and licenses
|
| 52 |
|
| 53 |
+
RAV uses Stable Video Diffusion (SVD), Video Depth Anything, FaRL, ArcFace, OpenAI CLIP, and facenet-pytorch.
|
| 54 |
|
| 55 |
+
SVD and applicable derivatives are subject to the [SVD license](LICENSE-SVD.txt) and [NOTICE](NOTICE.txt). **Powered by Stability AI** (attribution required by the SVD license). MTCNN retains its [MIT license](facenet/LICENSE.md); other models follow their providers' terms. An additional project-specific license has not yet been specified.
|
| 56 |
|
| 57 |
+
## Citation
|
| 58 |
|
| 59 |
+
If you use this work, please cite:
|
| 60 |
|
| 61 |
+
```bibtex
|
| 62 |
+
@misc{gan2026refocusinganyvideo,
|
| 63 |
+
title = {Refocusing Any Video: Temporally Consistent Video Refocusing for Dynamic Focal Planes},
|
| 64 |
+
author = {Gan, Chee Kim and Chiu, Pin-Yen and Fang, I-Sheng and Chen, Jun-Cheng},
|
| 65 |
+
year = {2026},
|
| 66 |
+
note = {SIGGRAPH Asia 2026},
|
| 67 |
+
url = {https://github.com/aiiu-lab/Refocusing-Any-Video}
|
| 68 |
+
}
|
| 69 |
+
```
|