Jiaqi Xu1,2,* Β Β·Β Wenbo Li2,β Β Β·Β Haoze Sun2 Β Β·Β Fan Li2 Β Β·Β Zhixin Wang2 Β Β·Β Long Peng2 Β Β·Β Jingjing Ren3 Β Β·Β Haoran Yang1 Β Β·Β Xiaowei Hu4 Β Β·Β Renjing Pei2,β Β Β·Β Pheng-Ann Heng1
1The Chinese University of Hong Kong Β Β 2Huawei Noah's Ark Lab Β Β 3HKUST (GZ) Β Β 4South China University of Technology
FlowSR casts super-resolution as a consistency rectified flow from LR to HR, producing high-quality results in as few as one step.
Note
This repository is a minimal, inference-only third-party implementation based on the paper. It is an independent re-implementation provided for non-commercial research, not an official author release.
- Title: Fast Image Super-Resolution via Consistency Rectified Flow
- Venue: ICCV 2025
- Paper: openaccess.thecvf.com
- arXiv: https://arxiv.org/abs/2605.12377
- Citation: BibTeX below β
Both uv and conda are supported. Use whichever environment manager matches your workflow.
Using uv:
uv venv --python 3.12
source .venv/bin/activate
uv pip install -e .If your CUDA setup needs a specific PyTorch wheel, install the matching PyTorch build first, then install this package:
uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126
uv pip install -e .Using conda with a CUDA 12.6 PyTorch environment:
conda create -n flowsr python=3.12 -y
conda activate flowsr
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126
pip install -e .If your machine needs a different CUDA or CPU-only PyTorch build, install the matching PyTorch package first, then run pip install -e ..
Once the package is installed, FlowSR can be invoked two equivalent ways in either environment: the console scripts flowsr-infer / flowsr-metrics, or the module form python -m flowsr.infer / python -m flowsr.metrics. Activate your environment first β source .venv/bin/activate (uv) or conda activate flowsr (conda) β then run either form. The examples below use the module form; substitute the console script if you prefer.
Important
The default device is cuda; the model targets a GPU. CPU-only runs are not a supported path.
The FlowSR checkpoint is hosted on the Hugging Face Hub. Download it into checkpoints/:
uv pip install -U huggingface_hub # or: pip install -U huggingface_hub
hf download chunjie-spring/FlowSR flowsr.safetensors --local-dir checkpointsNote
The checkpoint is hosted at the Hugging Face repository chunjie-spring/FlowSR. After downloading, it must live at:
checkpoints/flowsr.safetensors
Validate it before running inference:
python -m flowsr.infer --checkpoint checkpoints/flowsr.safetensors --check-checkpoint-onlyThe default base model is Manojb/stable-diffusion-2-1-base, a drop-in re-upload of the
weights from the original stabilityai/stable-diffusion-2-1-base repository, which has been
removed from the Hugging Face Hub. Override it with --base-model if you host the weights elsewhere.
python -m flowsr.infer \
--input path/to/lr.png \
--output outputs \
--checkpoint checkpoints/flowsr.safetensors \
--base-model Manojb/stable-diffusion-2-1-base \
--flow-scheduler-model stabilityai/stable-diffusion-3-medium-diffuserspython -m flowsr.infer \
--input path/to/lr_folder \
--output outputs \
--checkpoint checkpoints/flowsr.safetensorsOutputs are written as PNG files in the output directory.
Useful options:
--scale: upsampling scale, default4--device: defaultcuda--dtype:fp16,bf16, orfp32, defaultbf16--num-inference-steps: default1--guidance-scale: default1.0--align-method:wavelet,adain, ornone, defaultwavelet
uv pip install -e ".[metrics]"With conda:
pip install -e ".[metrics]"python -m flowsr.metrics \
--sr outputs/StableSR-TestSets/RealSRVal_crop128 \
--gt data/StableSR-TestSets/StableSR_testsets/RealSRVal_crop128/test_HR \
--output-dir metrics \
--metrics psnr ssim lpips dists fid niqe musiq maniqa clipiqaThe metric script matches SR and GT images by filename stem, writes a timestamped log file, and saves a JSON summary to metrics/flowsr_metrics.json.
For public evaluation examples, use the StableSR test sets hosted on Hugging Face:
The dataset card lists DIV2K_Val, RealSR Val, DRealSR Val, and DPED Val, and is licensed under S-Lab License 1.0.
uv pip install -U huggingface_hub # or: pip install -U huggingface_hub
hf download Iceclear/StableSR-TestSets \
--repo-type dataset \
--local-dir data/StableSR-TestSetsAfter download, the local directory contains the dataset card and the zip archive:
data/StableSR-TestSets/
βββ README.md
βββ StableSR_testsets.zip
unzip data/StableSR-TestSets/StableSR_testsets.zip -d data/StableSR-TestSetsInspect the extracted layout before running inference:
find data/StableSR-TestSets -maxdepth 4 -type d | sort
find data/StableSR-TestSets -maxdepth 5 -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" \) | headThe extracted archive includes directories such as:
data/StableSR-TestSets/StableSR_testsets/
βββ DIV2K_V2_val
βββ DPEDiphoneValSet_crop128
βββ DrealSRVal_crop128
βββ RealSRVal_crop128
βββ StableSR_w0.5_results
This repository's examples focus on RealSRVal_crop128 and DrealSRVal_crop128. Each has paired low-resolution and high-resolution folders:
RealSRVal_crop128/
βββ test_HR
βββ test_LR
DrealSRVal_crop128/
βββ test_HR
βββ test_LR
The inference CLI expects --input to be one image file or one directory that directly contains low-quality images. Point it at the extracted test_LR folder for the split you want to process, not at the dataset root.
python -m flowsr.infer \
--input data/StableSR-TestSets/StableSR_testsets/RealSRVal_crop128/test_LR \
--output outputs/StableSR-TestSets/RealSRVal_crop128 \
--checkpoint checkpoints/flowsr.safetensorspython -m flowsr.infer \
--input data/StableSR-TestSets/StableSR_testsets/DrealSRVal_crop128/test_LR \
--output outputs/StableSR-TestSets/DrealSRVal_crop128 \
--checkpoint checkpoints/flowsr.safetensorspython -m flowsr.metrics \
--sr outputs/StableSR-TestSets/RealSRVal_crop128 \
--gt data/StableSR-TestSets/StableSR_testsets/RealSRVal_crop128/test_HR \
--output-dir metrics \
--metrics psnr ssim lpips dists fid niqe musiq maniqa clipiqapython -m flowsr.metrics \
--sr outputs/StableSR-TestSets/DrealSRVal_crop128 \
--gt data/StableSR-TestSets/StableSR_testsets/DrealSRVal_crop128/test_HR \
--output-dir metrics \
--metrics psnr ssim lpips dists fid niqe musiq maniqa clipiqaCould not load checkpoint: the checkpoint file is missing, truncated, or not a valid FlowSR safetensors checkpoint.- CUDA out of memory: try a smaller input image,
--dtype bf16, or reduce--latent-tile-size. - Hugging Face download failures: log in with
hf auth loginor pre-download the base model and scheduler to a local cache. - Commercial usage questions: this repository uses a non-commercial software license.
FlowSR/
βββ README.md # this file
βββ LICENSE # PolyForm Noncommercial 1.0.0
βββ pyproject.toml # package metadata, dependencies, console scripts
βββ assets/
β βββ teaser.jpg
βββ checkpoints/
β βββ .gitkeep # download flowsr.safetensors here
βββ flowsr/
β βββ __init__.py
β βββ defaults.py # shared inference defaults (base model, prompts)
β βββ infer.py # inference CLI + image I/O (flowsr-infer)
β βββ model.py # FlowSR pipeline: UNet / VAE / text encoder + LoRA
β βββ checkpoint.py # safetensors checkpoint loader
β βββ color.py # wavelet / adain color correction
β βββ metrics.py # optional pyiqa evaluation (flowsr-metrics)
βββ tests/
βββ test_cli_utils.py
βββ test_metrics_utils.py
The inference path is infer.py β model.py β checkpoint.py, with color.py applied
as post-processing. metrics.py is optional and only used with the [metrics] extra.
Included:
- Minimal inference code
- LoRA checkpoint loading
- Image and folder inference CLI
- Checkpoint validation CLI
- Optional image-quality metric evaluation script
- Public setup and usage documentation
Not included:
- Training code
- Dataset generation code
- Benchmark datasets
- Notebooks
- Metrics reports
- Internal experiment logs
This implementation builds on the excellent work of:
If you find this work useful, please cite the paper:
@inproceedings{xu2025fast,
title={Fast Image Super-Resolution via Consistency Rectified Flow},
author={Xu, Jiaqi and Li, Wenbo and Sun, Haoze and Li, Fan and Wang, Zhixin and Peng, Long and Ren, Jingjing and Yang, Haoran and Hu, Xiaowei and Pei, Renjing and others},
booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
pages={11755--11765},
year={2025}
}This repository is released under the PolyForm Noncommercial License 1.0.0. It is intended for non-commercial research use. For commercial use, please contact the repository owner.