Improve model card: Add pipeline tag, paper link, GitHub link, and usage details
#1
by
nielsr
HF Staff
- opened
README.md
CHANGED
|
@@ -1,16 +1,34 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
| 3 |
---
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
```bash
|
| 8 |
cd OFTSR
|
| 9 |
huggingface-cli download Yuanzhi/OFTSR --local-dir ckpts
|
| 10 |
```
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
########################## FFHQ Generation ##########################
|
| 14 |
```bash
|
| 15 |
python sample_fm.py --opt configs/ir_fm_ffhq.yml \
|
| 16 |
--overrides \
|
|
@@ -21,9 +39,9 @@ python sample_fm.py --opt configs/ir_fm_ffhq.yml \
|
|
| 21 |
fm_model.use_cond=false
|
| 22 |
```
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
| 27 |
```bash
|
| 28 |
python sample_fm.py --opt configs/ir_fm_ffhq.yml \
|
| 29 |
--overrides \
|
|
@@ -35,7 +53,7 @@ python sample_fm.py --opt configs/ir_fm_ffhq.yml \
|
|
| 35 |
fm_model.use_cond=true
|
| 36 |
```
|
| 37 |
|
| 38 |
-
|
| 39 |
```bash
|
| 40 |
python sample_fm.py --opt configs/dis_fm_ffhq.yml \
|
| 41 |
--overrides \
|
|
@@ -44,13 +62,13 @@ python sample_fm.py --opt configs/dis_fm_ffhq.yml \
|
|
| 44 |
sample.num_sample=100 \
|
| 45 |
ir.sigma_y=0. \
|
| 46 |
ir.sigma_pertubation=0.1 \
|
| 47 |
-
fm_model.use_cond=true
|
| 48 |
sample.one_step_t=0.99
|
| 49 |
```
|
| 50 |
|
| 51 |
-
|
| 52 |
|
| 53 |
-
|
| 54 |
```bash
|
| 55 |
python sample_fm.py --opt configs/ir_fm_ffhq.yml \
|
| 56 |
--overrides \
|
|
@@ -62,7 +80,7 @@ python sample_fm.py --opt configs/ir_fm_ffhq.yml \
|
|
| 62 |
fm_model.use_cond=true
|
| 63 |
```
|
| 64 |
|
| 65 |
-
|
| 66 |
```bash
|
| 67 |
python sample_fm.py --opt configs/dis_fm_ffhq.yml \
|
| 68 |
--overrides \
|
|
@@ -71,13 +89,13 @@ python sample_fm.py --opt configs/dis_fm_ffhq.yml \
|
|
| 71 |
sample.num_sample=100 \
|
| 72 |
ir.sigma_y=0.05 \
|
| 73 |
ir.sigma_pertubation=0.5 \
|
| 74 |
-
fm_model.use_cond=true
|
| 75 |
sample.one_step_t=0.99
|
| 76 |
```
|
| 77 |
|
| 78 |
-
|
| 79 |
|
| 80 |
-
|
| 81 |
```bash
|
| 82 |
python sample_fm.py --opt configs/ir_fm_DIV2K.yml \
|
| 83 |
--overrides \
|
|
@@ -90,7 +108,7 @@ python sample_fm.py --opt configs/ir_fm_DIV2K.yml \
|
|
| 90 |
fm_model.use_cond=true
|
| 91 |
```
|
| 92 |
|
| 93 |
-
|
| 94 |
```bash
|
| 95 |
python sample_fm.py --opt configs/dis_fm_DIV2K.yml \
|
| 96 |
--overrides \
|
|
@@ -100,15 +118,13 @@ python sample_fm.py --opt configs/dis_fm_DIV2K.yml \
|
|
| 100 |
sample.psnr_batch_size=1 \
|
| 101 |
ir.sigma_y=0. \
|
| 102 |
ir.sigma_pertubation=0.2 \
|
| 103 |
-
fm_model.use_cond=true
|
| 104 |
sample.one_step_t=0.99
|
| 105 |
```
|
| 106 |
|
|
|
|
| 107 |
|
| 108 |
-
|
| 109 |
-
########################## ImageNet Noiseless Restoration ##########################
|
| 110 |
-
|
| 111 |
-
#--------------------- multi-step ---------------------
|
| 112 |
```bash
|
| 113 |
python sample_fm.py --opt configs/ir_fm_imagenet.yml \
|
| 114 |
--overrides \
|
|
@@ -120,7 +136,7 @@ python sample_fm.py --opt configs/ir_fm_imagenet.yml \
|
|
| 120 |
fm_model.use_cond=true
|
| 121 |
```
|
| 122 |
|
| 123 |
-
|
| 124 |
```bash
|
| 125 |
python sample_fm.py --opt configs/dis_fm_imagenet.yml \
|
| 126 |
--overrides \
|
|
@@ -129,6 +145,28 @@ python sample_fm.py --opt configs/dis_fm_imagenet.yml \
|
|
| 129 |
sample.num_sample=100 \
|
| 130 |
ir.sigma_y=0. \
|
| 131 |
ir.sigma_pertubation=0.2 \
|
| 132 |
-
fm_model.use_cond=true
|
| 133 |
sample.one_step_t=0.99
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
```
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
pipeline_tag: image-to-image
|
| 4 |
---
|
| 5 |
|
| 6 |
+
# OFTSR: One-Step Flow for Image Super-Resolution with Tunable Fidelity-Realism Trade-offs
|
| 7 |
+
|
| 8 |
+
This repository contains the official implementation and checkpoints for **OFTSR** (One-Step Flow for Image Super-Resolution with Tunable Fidelity-Realism Trade-offs).
|
| 9 |
+
|
| 10 |
+
OFTSR introduces a novel flow-based framework for one-step image super-resolution, capable of producing outputs with tunable levels of fidelity and realism. It achieves state-of-the-art performance for one-step image super-resolution by distilling a conditional flow-based teacher model, aligning its single-step predictions from initial states to match the teacher's predictions from a closer intermediate state. This approach significantly reduces computational overhead while offering flexibility in the fidelity-realism trade-off.
|
| 11 |
+
|
| 12 |
+
The model was presented in the paper:
|
| 13 |
+
[**OFTSR: One-Step Flow for Image Super-Resolution with Tunable Fidelity-Realism Trade-offs**](https://huggingface.co/papers/2412.09465)
|
| 14 |
+
|
| 15 |
+
For the official codebase and more details, visit the [GitHub repository](https://github.com/yuanzhi-zhu/OFTSR).
|
| 16 |
+
|
| 17 |
+
## Sample Usage
|
| 18 |
+
|
| 19 |
+
### Checkpoints and Setup
|
| 20 |
+
|
| 21 |
+
Checkpoints can be found here on Hugging Face: [Yuanzhi/OFTSR](https://huggingface.co/Yuanzhi/OFTSR).
|
| 22 |
+
To download these checkpoints and prepare your environment, follow these steps:
|
| 23 |
|
| 24 |
```bash
|
| 25 |
cd OFTSR
|
| 26 |
huggingface-cli download Yuanzhi/OFTSR --local-dir ckpts
|
| 27 |
```
|
| 28 |
+
Please ensure your validation data is placed at `./val_data`.
|
| 29 |
+
|
| 30 |
+
### FFHQ Generation
|
| 31 |
|
|
|
|
| 32 |
```bash
|
| 33 |
python sample_fm.py --opt configs/ir_fm_ffhq.yml \
|
| 34 |
--overrides \
|
|
|
|
| 39 |
fm_model.use_cond=false
|
| 40 |
```
|
| 41 |
|
| 42 |
+
### FFHQ Noiseless Restoration
|
| 43 |
|
| 44 |
+
**Multi-step:**
|
| 45 |
```bash
|
| 46 |
python sample_fm.py --opt configs/ir_fm_ffhq.yml \
|
| 47 |
--overrides \
|
|
|
|
| 53 |
fm_model.use_cond=true
|
| 54 |
```
|
| 55 |
|
| 56 |
+
**One-step:**
|
| 57 |
```bash
|
| 58 |
python sample_fm.py --opt configs/dis_fm_ffhq.yml \
|
| 59 |
--overrides \
|
|
|
|
| 62 |
sample.num_sample=100 \
|
| 63 |
ir.sigma_y=0. \
|
| 64 |
ir.sigma_pertubation=0.1 \
|
| 65 |
+
fm_model.use_cond=true \
|
| 66 |
sample.one_step_t=0.99
|
| 67 |
```
|
| 68 |
|
| 69 |
+
### FFHQ Noisy Restoration
|
| 70 |
|
| 71 |
+
**Multi-step:**
|
| 72 |
```bash
|
| 73 |
python sample_fm.py --opt configs/ir_fm_ffhq.yml \
|
| 74 |
--overrides \
|
|
|
|
| 80 |
fm_model.use_cond=true
|
| 81 |
```
|
| 82 |
|
| 83 |
+
**One-step:**
|
| 84 |
```bash
|
| 85 |
python sample_fm.py --opt configs/dis_fm_ffhq.yml \
|
| 86 |
--overrides \
|
|
|
|
| 89 |
sample.num_sample=100 \
|
| 90 |
ir.sigma_y=0.05 \
|
| 91 |
ir.sigma_pertubation=0.5 \
|
| 92 |
+
fm_model.use_cond=true \
|
| 93 |
sample.one_step_t=0.99
|
| 94 |
```
|
| 95 |
|
| 96 |
+
### DIV2K Noiseless Restoration
|
| 97 |
|
| 98 |
+
**Multi-step:**
|
| 99 |
```bash
|
| 100 |
python sample_fm.py --opt configs/ir_fm_DIV2K.yml \
|
| 101 |
--overrides \
|
|
|
|
| 108 |
fm_model.use_cond=true
|
| 109 |
```
|
| 110 |
|
| 111 |
+
**One-step:**
|
| 112 |
```bash
|
| 113 |
python sample_fm.py --opt configs/dis_fm_DIV2K.yml \
|
| 114 |
--overrides \
|
|
|
|
| 118 |
sample.psnr_batch_size=1 \
|
| 119 |
ir.sigma_y=0. \
|
| 120 |
ir.sigma_pertubation=0.2 \
|
| 121 |
+
fm_model.use_cond=true \
|
| 122 |
sample.one_step_t=0.99
|
| 123 |
```
|
| 124 |
|
| 125 |
+
### ImageNet Noiseless Restoration
|
| 126 |
|
| 127 |
+
**Multi-step:**
|
|
|
|
|
|
|
|
|
|
| 128 |
```bash
|
| 129 |
python sample_fm.py --opt configs/ir_fm_imagenet.yml \
|
| 130 |
--overrides \
|
|
|
|
| 136 |
fm_model.use_cond=true
|
| 137 |
```
|
| 138 |
|
| 139 |
+
**One-step:**
|
| 140 |
```bash
|
| 141 |
python sample_fm.py --opt configs/dis_fm_imagenet.yml \
|
| 142 |
--overrides \
|
|
|
|
| 145 |
sample.num_sample=100 \
|
| 146 |
ir.sigma_y=0. \
|
| 147 |
ir.sigma_pertubation=0.2 \
|
| 148 |
+
fm_model.use_cond=true \
|
| 149 |
sample.one_step_t=0.99
|
| 150 |
+
```
|
| 151 |
+
|
| 152 |
+
## Evaluation
|
| 153 |
+
|
| 154 |
+
To evaluate the model, use the following commands:
|
| 155 |
+
|
| 156 |
+
```bash
|
| 157 |
+
python evaluate.py --fdir1 hr_folder --fdir2 sr_folder
|
| 158 |
+
python fid.py --fdir1 hr_folder --fdir2 sr_folder
|
| 159 |
+
```
|
| 160 |
+
|
| 161 |
+
## Citation
|
| 162 |
+
|
| 163 |
+
If you find this repository helpful, please cite the paper:
|
| 164 |
+
|
| 165 |
+
```bibtex
|
| 166 |
+
@article{zhu2024oftsr,
|
| 167 |
+
title={OFTSR: One-Step Flow for Image Super-Resolution with Tunable Fidelity-Realism Trade-offs},
|
| 168 |
+
author={Zhu, Yuanzhi and Wang, Ruiqing and Lu, Shilin and Li, Junnan and Yan, Hanshu and Zhang, Kai},
|
| 169 |
+
journal={arXiv preprint arXiv:2412.09465},
|
| 170 |
+
year={2024}
|
| 171 |
+
}
|
| 172 |
```
|