nickchiu commited on
Commit
3a7e4d1
·
verified ·
1 Parent(s): c10a006

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +36 -116
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
- # Refocus Any Video: inference checkpoints
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
- Checkpoint step numbers above are the source directory labels. They do not independently establish dataset size, number of epochs, or training duration. Optimizer, scheduler, and random-state snapshots and large full-UNet experiment snapshots are excluded; this is an inference release rather than an exact training-resume bundle. `bundle_manifest.json` records repository-relative file paths, sizes, and SHA-256 checksums for the distributed assets.
59
 
60
- ## Download
 
61
 
62
- From the source repository root, install and activate the environment described in its README, then run:
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
- The download writes `checkpoints/vdd_weights/`, `checkpoints/vbr_weights/`, and the other folders shown above.
78
 
79
- ## Base and auxiliary models
80
 
81
- Obtain these models separately from their providers. Their weights and licenses are separate from the authors' RAV assets.
 
82
 
83
- | Model | Source | Local path from source repository root |
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
- The provided `python tools/checkpoints/download_svd_weights.py` helper downloads SVD to `checkpoints/svdh/`. Retain the SVD VAE and UNet `fp16` weight variants: the inference loaders request these files even when inference precision is changed. Follow each provider's authentication/access instructions when required.
92
-
93
- The shared VDD wrapper constructs ArcFace, FaRL, and MTCNN even when identity conditioning is disabled, so baseline VDD also requires these auxiliary models and the CLIP cache. Optional keypoint preprocessing, facial landmark extraction, and training/data generation have additional external model requirements documented in the code repository; these are not needed for the basic VDD → VBR example below.
94
-
95
- ## Inference
96
-
97
- Run from the source repository root after completing the environment and all checkpoint setup. Put the input video at `inputs/input.mp4`.
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
- The final video is `results/vbr/output.mp4`. Keep RGB and depth frame counts, order, and framing aligned. `FOCAL_PLANE` uses normalized disparity in `[0, 1]`, with larger values focusing nearer. `COC` controls the defocus scale. The launchers save at the requested integer playback FPS without resampling and do not preserve audio. See the source README for environment setup, dry runs, time-varying focal planes, resolution controls, and troubleshooting.
122
 
123
- For optional identity-guided VDD, provide a clear reference face image and select the matching adapter:
124
 
125
  ```bash
126
- MODE=single INPUT_VIDEO=./inputs/input.mp4 \
127
- REFERENCE_IMAGE=./inputs/reference_face.jpg KEYPOINT_VIDEO="" \
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
- For Track4Gen, use `infer_vdd_identity_track4gen.sh` and `IP_ADAPTER_PATH=./checkpoints/identity_adapter_track4gen/ip_adapter.bin`. Both use `checkpoints/vdd_weights/checkpoint-90000` by default. Missing adapter files can cause the current implementation to continue with initialized weights; supply the matching trained file for meaningful results.
134
 
135
- ## Training and evaluation information
136
 
137
- The source distribution includes training runners, historical experiment configuration templates, losses, renderers, and dataset split identifiers. This release does not provide an independently verified, checkpoint-specific training-data description, complete training logs, or benchmark metrics. No quantitative performance claims are made here.
138
 
139
- The release preparation checked file inventory and source hashes, adapter configuration and stored tensor keys/headers, Python/shell syntax, and transfer previews. A full GPU end-to-end inference or training run was not performed during release preparation. These checks do not establish reconstruction quality, temporal consistency, or identity fidelity.
140
 
141
- ## Intended use and limitations
142
 
143
- Use the implementation to explore video defocus deblurring, depth-guided refocusing, and reference-conditioned face restoration. Recovered details are model predictions and may differ from the original scene or identity. Depth errors, severe blur, motion, occlusions, or mismatched references can affect results. Hardware requirements and usable resolution depend on the input and available GPU memory; no measured minimum-memory guarantee is provided.
144
 
145
- ## Licensing and third-party attribution
146
-
147
- No additional license for the authors' project-specific model weights was supplied in the source material; this card does not assign one. Stable Video Diffusion and any applicable derivatives remain subject to the base model's terms. The base SVD weights are downloaded separately from the provider. Refer to the retained `LICENSE-SVD.txt`, `NOTICE.txt`, and the provider's model page.
148
-
149
- MTCNN assets are redistributed with their upstream MIT notice, copyright © 2019 Timothy Esler, in `facenet/LICENSE.md`; that notice applies to those assets rather than to the complete RAV bundle. Other auxiliary models are obtained separately under their respective providers' terms.
 
 
 
 
 
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
+ ```