ann12344323 commited on
Commit
d6223fb
·
verified ·
1 Parent(s): aa12345

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -1,272 +1,3 @@
1
- <div align="center">
2
-
3
- # RDVQ: Differentiable Vector Quantization for Rate-Distortion Optimization of Generative Image Compression
4
-
5
- ### CVPR 2026 Oral
6
-
7
- [![arXiv](https://img.shields.io/badge/arXiv-2604.10546-orange?style=flat-square)](https://arxiv.org/abs/2604.10546)
8
- [![CVPR 2026](https://img.shields.io/badge/CVPR-2026-blue?style=flat-square)](https://cvpr.thecvf.com/)
9
- [![Python 3.10+](https://img.shields.io/badge/Python-3.10+-blue?style=flat-square\&logo=python)](https://www.python.org/)
10
- [![PyTorch](https://img.shields.io/badge/PyTorch-2.1+-red?style=flat-square\&logo=pytorch)](https://pytorch.org/)
11
- [![License](https://img.shields.io/badge/License-CC--BY--4.0-lightgrey?style=flat-square)](LICENSE)
12
-
13
- [Shiyin Jiang](https://scholar.google.com/citations?user=yf748WAAAAAJ&hl=en) ·
14
- [Wei Long](https://scholar.google.com/citations?user=CsVTBJoAAAAJ&hl=en) ·
15
- Minghao Han ·
16
- [Zhenghao Chen](https://scholar.google.com/citations?user=BThVCu8AAAAJ&hl=en) ·
17
- [Ce Zhu](http://scholar.google.com/citations?hl=en&user=C7iZbYMAAAAJ) ·
18
- [Shuhang Gu](https://scholar.google.com/citations?user=-kSTt40AAAAJ&hl=en)
19
-
20
- **CVL Lab @ University of Electronic Science and Technology of China**
21
-
22
- <img src="assets/framework.jpg" width="85%">
23
-
24
- </div>
25
-
26
  ---
27
-
28
- ## 🔥 News
29
-
30
- * **Jun 12, 2026** — Training code and configurations are released.
31
-
32
  ---
33
-
34
- ## 🌟 Introduction
35
-
36
- **RDVQ** is a VQ-based generative image compression framework for **efficient and controllable ultra-low-bitrate image compression**.
37
-
38
- Conventional VQ-VAE learns powerful discrete representations, but its **non-differentiable nearest-neighbor lookup** decouples representation learning from probability modeling. The entropy model can only predict the resulting code indices, while its rate feedback cannot effectively optimize the encoder. This limits true joint rate-distortion optimization.
39
-
40
- RDVQ addresses this issue with a **simple relaxed lookup mechanism**, which builds a differentiable path between encoder features, discrete code indices, and the autoregressive entropy model. As a result, the rate loss can directly guide the encoder to learn more compressible representations, transforming **VQ-VAE from a representation learning framework into a practical learned image codec**.
41
-
42
- ### Key Features
43
-
44
- * **Differentiable VQ-based R-D optimization**
45
- Enables joint distortion and rate minimization through relaxed lookup.
46
-
47
- * **Multi-scale shared-codebook latents**
48
- Provide compact and expressive discrete representations across scales.
49
-
50
- * **Masked Transformer entropy model**
51
- Estimates accurate probabilities for effective entropy coding.
52
-
53
- * **Test-time rate control**
54
- Supports bitrate adjustment via prefix transmission and autoregressive completion.
55
-
56
- Despite its lightweight design, RDVQ achieves strong perceptual compression performance at ultra-low bitrates while requiring only a small fraction of the parameters used by large generative compression models.
57
-
58
- ---
59
-
60
- ## 🚀 Performance
61
-
62
- ### Model Efficiency
63
-
64
- <p align="center">
65
- <img src="assets/performance.png" width="60%">
66
- </p>
67
-
68
- ### Visual Comparison
69
-
70
- <p align="center">
71
- <img src="assets/visual.jpg" width="95%">
72
- </p>
73
-
74
- ### Rate-Distortion Curves
75
-
76
- <p align="center">
77
- <img src="assets/RD_curves.jpg" width="95%">
78
- </p>
79
-
80
- ---
81
-
82
- ## 🛠️ Environment Setup
83
-
84
- ```bash
85
- conda create -n RDVQ python=3.10 -y
86
- conda activate RDVQ
87
-
88
- git clone https://github.com/CVL-UESTC/RDVQ.git
89
- cd RDVQ
90
-
91
- pip install "torch>=2.1.0" torchvision --index-url https://download.pytorch.org/whl/cu121
92
- pip install -r requirements.txt
93
- ```
94
-
95
- > **Note:** The default real-bitstream path uses the causal top-k tensor-rANS codec and JIT-builds a small C++17 extension on first use. Please make sure a C++17 compiler is available when running `test_Real.sh`.
96
-
97
- ---
98
-
99
- ## 📂 Data Preparation
100
-
101
- RDVQ expects an **ImageFolder-style** directory where all images are directly placed under one folder:
102
-
103
- ```text
104
- /path/to/images/
105
- image_0001.png
106
- image_0002.jpg
107
- ...
108
- ```
109
-
110
- Nested subdirectories are not scanned by the testing scripts.
111
-
112
- ---
113
-
114
- ## 🧪 Testing
115
-
116
- RDVQ provides two testing scripts:
117
-
118
- | Script | Bitrate Type | Description |
119
- | -------------- | ---------------------- | ----------------------------------------------------- |
120
- | `test.sh` | Estimated bitrate | Reports entropy-estimated bitrate such as `cd_bpp`. |
121
- | `test_Real.sh` | Real bitstream bitrate | Reports actual payload bitrate such as `cd_bpp_real`. |
122
-
123
- By default, the evaluator reports:
124
-
125
- ```text
126
- bpp, lpips, dists, musiq, clipiqa, niqe, psnr, msssim
127
- ```
128
-
129
- You can override the metric list with `TEST_METRICS`.
130
-
131
- ### Quick Start: Estimated-Rate Evaluation
132
-
133
- ```bash
134
- TEST_CKPT_PATH=/path/to/checkpoint \
135
- TEST_IMAGE_DIR=/path/to/kodak \
136
- TEST_DATASET=kodak \
137
- bash test.sh
138
- ```
139
-
140
- ### Quick Start: Real-Bitstream Evaluation
141
-
142
- ```bash
143
- TEST_CKPT_PATH=/path/to/checkpoint \
144
- TEST_IMAGE_DIR=/path/to/kodak \
145
- TEST_DATASET=kodak \
146
- bash test_Real.sh
147
- ```
148
-
149
- ### DIV2K / CLIC Evaluation with FID and KID
150
-
151
- For DIV2K and CLIC, please provide `FID_REF_ROOT`:
152
-
153
- ```bash
154
- TEST_CKPT_PATH=/path/to/checkpoint \
155
- TEST_IMAGE_DIR=/path/to/DIV2K_valid_HR \
156
- TEST_DATASET=div2k \
157
- FID_REF_ROOT=/path/to/fid_refs \
158
- bash test.sh
159
- ```
160
-
161
- For CLIC:
162
-
163
- ```bash
164
- TEST_CKPT_PATH=/path/to/checkpoint \
165
- TEST_IMAGE_DIR=/path/to/CLIC_valid \
166
- TEST_DATASET=clic \
167
- FID_REF_ROOT=/path/to/fid_refs \
168
- bash test.sh
169
- ```
170
-
171
- The evaluator uses:
172
-
173
- ```text
174
- <FID_REF_ROOT>/<TEST_DATASET>_256teles
175
- ```
176
-
177
- If the reference directory is missing or empty, it will be generated automatically from the original images and reused in later runs.
178
-
179
- ### Test-Time Rate Control
180
-
181
- `test_Real.sh` supports test-time rate control through prefix transmission and autoregressive completion by changing `TEST_TRANSFER_SLICES`:
182
-
183
- ```bash
184
- TEST_CKPT_PATH=/path/to/checkpoint \
185
- TEST_IMAGE_DIR=/path/to/kodak \
186
- TEST_DATASET=kodak \
187
- TEST_TRANSFER_SLICES=4 \
188
- bash test_Real.sh
189
- ```
190
-
191
-
192
- ### Useful Debug Options
193
-
194
- ```bash
195
- TEST_MAX_IMAGES=1
196
- TEST_METRICS=bpp,psnr,msssim
197
- DISABLE_FID=1
198
- SAVE_IMAGES=0
199
- ```
200
-
201
- ### Main Environment Variables
202
-
203
- | Variable | Required | Description |
204
- | ---------------------- | -------------- | -------------------------------------------------------------------- |
205
- | `TEST_CKPT_PATH` | Yes | Path to the checkpoint. |
206
- | `TEST_IMAGE_DIR` | Yes | Image folder for evaluation. |
207
- | `TEST_DATASET` | Yes | Dataset label: `kodak`, `div2k`, or `clic`. |
208
- | `FID_REF_ROOT` | For DIV2K/CLIC | Root directory for FID/KID reference tiles. |
209
- | `FID_REF_DIR` | Optional | Manually specified reference tile directory. |
210
- | `TEST_METRICS` | Optional | Evaluation metric list. |
211
- | `TEST_TRANSFER_SLICES` | Optional | Number of transmitted latent slices for real-bitstream rate control. |
212
- | `TEST_TOPK` | Optional | Top-k/escape entropy width for `test_Real.sh`. Default: `1024`. |
213
- | `TEST_MAX_IMAGES` | Optional | Maximum number of images for debugging. |
214
- | `DISABLE_FID` | Optional | Disable FID/KID computation. |
215
- | `SAVE_IMAGES` | Optional | Whether to save reconstructed images. |
216
-
217
- ### Output Structure
218
-
219
- ```text
220
- <checkpoint_stem>/forward/<dataset_name>/
221
- <checkpoint_stem>/Real/transfer_slices_<N>/<dataset_name>/
222
- ```
223
-
224
- ---
225
-
226
- ## 🏋️ Training
227
-
228
- Training follows a multi-stage pipeline. Please refer to [TRAINING_STAGES.md](TRAINING_STAGES.md) for the full recipe.
229
-
230
- ### Stage 1: Tokenizer Training
231
-
232
- ```bash
233
- bash scripts/tokenizer/train_vq.sh \
234
- --data-path /path/to/train/images \
235
- --image-size 256 \
236
- --vq-model VQ-16-32-64_quant_once \
237
- --dataset openimage \
238
- --global-batch-size 32 \
239
- --results-dir ./results/s1_tokenizer \
240
- --codebook-size 4096 \
241
- --codebook-embed-dim 32 \
242
- --entropy-loss-ratio 0.0 \
243
- --lr 1e-4 \
244
- --disc-lr 1e-4 \
245
- --wo-attn
246
- ```
247
-
248
- ---
249
-
250
- ## 📖 Citation
251
-
252
- If you find RDVQ helpful for your research, please cite:
253
-
254
- ```bibtex
255
- @inproceedings{jiang2026rdvq,
256
- title = {Differentiable Vector Quantization for Rate-Distortion Optimization
257
- of Generative Image Compression},
258
- author = {Jiang, Shiyin and Long, Wei and Han, Minghao and Chen, Zhenghao
259
- and Zhu, Ce and Gu, Shuhang},
260
- booktitle = {CVPR},
261
- year = {2026},
262
- }
263
- ```
264
-
265
- ---
266
-
267
- ## 💬 Contact
268
-
269
- For questions or feedback, please contact:
270
-
271
- **Shiyin Jiang**
272
- 📧 **[shiyin.jsy@gmail.com](mailto:shiyin.jsy@gmail.com)**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: apache-2.0
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lam_0.8_tau_0.01.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3390ca00b793b3cae2eb0965fdcd046f686f6efadff06e4f39af72b1e0285c21
3
+ size 1007856746
lam_1.2_tau_0.01.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:31c09b2b403966d3baf0ef509c53ff6e6e4027f8a3205c1e5dfcee657d46a986
3
+ size 1007856746
lam_12_tau_0.1.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0c8b29e5310f2c096e046f7e415e14919135424949006a1fa3198ee6517c9861
3
+ size 1007855640
lam_4.8_tau_0.1.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:827aaab038626bb306fc30fac37634eece418dd02bd4617f88e65d8d19e92294
3
+ size 1007856193
lam_7.2_tau_0.1.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd5339ec47443bdbe996c7d524927cc6ef4a0ef7f32a07889dc2ba60b5d13ad8
3
+ size 1007856193