VOSR: Vision-Only Super-Resolution Framework
repository·main·Indexed 40 days ago
https://github.com/cswry/vosrA vision-only generative framework for image super-resolution featuring multi-step and one-step (distilled) models ranging from 0.5B to 1.4B parameters. Designed for high-fidelity restoration in text-rich and complex scenes, VOSR supports tiled inference for large images and provides specialized configurations for RealSR and ScreenSR benchmarks.
What's inside VOSR
- The VOSR project is released under the Apache License 2.0. Note that downloadable model weights, benchmark data, and external assets may be subject to separate terms on their respective hosting pages.
Fine-tune Multi-step Inference Parameters
mainWhen using multi-step models, you can adjust the trade-off between faithfulness to the Low-Resolution (LR) input and generative detail using these parameters:
--cfg_scale: Controls fidelity to the condition. Higher values emphasize fidelity; lower values allow more generative freedom. A practical range is-0.5to2, with0.5being a common default.--weak_cond_strength_aelq: Controls how much the model follows the condition. Smaller values are more generative; larger values are more faithful. Default is0.1.--infer_steps: Number of sampling steps (default25).
Benchmark Presets:
- For RealSR: Use
--cfg_scale -0.5. - For ScreenSR: Use
--cfg_scale 0.5.
Configure VOSR Model Weights
mainDownload pretrained weights from ModelScope or Hugging Face and place them in the
preset/ckpts/directory. The directory must follow this specific structure:preset/ckpts/ |-- Qwen-Image-vae-2d/ # Qwen-Image VAE (2D, for 1.4B models) |-- stable-diffusion-2-1-base/ # SD2.1 VAE (for 0.5B models) |-- sd21_lwdecoder.pth # Lightweight decoder for SD2.1 VAE |-- torch_cache/ # DINOv2 pretrained weights |-- VOSR2/ # VOSR 2.0 one-step (1.4B) model |-- VOSR_0.5B_ms/ # 0.5B multi-step model |-- VOSR_0.5B_os/ # 0.5B one-step (distilled) model |-- VOSR_1.4B_ms/ # 1.4B multi-step model `-- VOSR_1.4B_os/ # 1.4B one-step (distilled) modelNote on VAEs:
- VOSR-0.5B uses
sd21_lwdecoder.pth(a lightweight replacement for the SD2.1 VAE decoder). - VOSR-1.4B uses the 16-channel
Qwen-Image-vae-2d(an image-only 2D variant) to preserve input fidelity.
preset/ckpts/ |-- Qwen-Image-vae-2d/ |-- stable-diffusion-2-1-base/ |-- sd21_lwdecoder.pth |-- torch_cache/ |-- VOSR2/ |-- VOSR_0.5B_ms/ |-- VOSR_0.5B_os/ |-- VOSR_1.4B_ms/ `-- VOSR_1.4B_os/- VOSR-0.5B uses
Run VOSR Inference
mainInference is performed on a single GPU. Use
inference_vosr.pyfor multi-step models andinference_vosr_onestep.pyfor one-step/distilled models.Common Arguments
-c: Checkpoint path-i: Input image or folder-o: Output directory (results are saved as PNGs)-u: Upscale factor
VOSR 2.0 (One-step, 1.4B DiT)
python inference_vosr_onestep.py \ -c preset/ckpts/VOSR2 \ -i preset/datasets/inp_data \ -o preset/results \ -u 4Multi-step Models
Multi-step sampling defaults to 25 steps (
--infer_steps).# VOSR-0.5B multi-step python inference_vosr.py \ -c preset/ckpts/VOSR_0.5B_ms \ -i preset/datasets/inp_data \ -o preset/results \ -u 4One-step Models
One-step models typically use
--infer_steps 1.# VOSR-1.4B one-step python inference_vosr_onestep.py \ -c preset/ckpts/VOSR_1.4B_os \ -i preset/datasets/inp_data \ -o preset/results \ -u 4Perform Tiled Inference for Large Images
mainTo prevent GPU memory exhaustion when processing large images, use tiling in the latent space. Overlapping tiles are blended using a Gaussian method.
--tile_size <pixels>: Sets the DiT tile size (default0= disabled).--vae_tile_size <pixels>: Sets the VAE encoder/decoder tile size (default0= full-image). Note that the Qwen VAE is memory-efficient and can handle up to ~8K inputs without tiling.--vae_tile_overlap: Sets the VAE tile overlap (defaults to the value of--tile_size).
Example (1.4B one-step with tiling):
python inference_vosr_onestep.py \ -c preset/ckpts/VOSR_1.4B_os \ -i large_input.png \ -o preset/results \ -u 4 --tile_size 512 --vae_tile_size 1024Install VOSR
mainTo set up the VOSR environment, clone the repository and create a Conda environment with Python 3.8 or higher. Then, install the required dependencies using
pip.## clone this repository git clone https://github.com/cswry/VOSR.git cd VOSR # create an environment with python >= 3.8 conda create -n vosr python=3.8 conda activate vosr pip install -r requirements.txtConfigure VOSR Training Data
mainVOSR supports two data loading modes via the
dataset_typekey in your YAML configuration:txtmode: Each folder contains individual image files (.png/.jpg). You must provide a text configuration file that lists folders with sampling weights.webdatasetmode: Each folder contains.tarshards. This uses the same text configuration format astxtmode but loads via WebDataset.
Dataset Config Format: Create a file (e.g.,
configs/train_txt/train_dataset_txt.txt) where each line follows the pattern:<folder_path>, <sampling_weight>Example:
/path/to/dataset_A, 2 /path/to/dataset_B, 1 /path/to/dataset_C, 1Higher weights result in more frequent sampling.
Train VOSR Models (Multi-step and One-step)
mainTraining is performed using
torchrun. By default, experiment tracking is disabled (report_to: none). To use Weights & Biases, runwandb loginand setreport_to: wandbin your YAML config.Multi-step Training
Use
train_vosr.pywith the appropriate model config.# VOSR-0.5B torchrun --nproc_per_node=8 train_vosr.py --config configs/train_yml/multi_step/VOSR_0.5B.yml # VOSR-1.4B torchrun --nproc_per_node=8 train_vosr.py --config configs/train_yml/multi_step/VOSR_1.4B.ymlOne-step Distillation
Requires a trained multi-step teacher checkpoint. Set
teacher_ckptandpretrained_ckptin your YAML config and usetrain_vosr_distill.py.# VOSR-0.5B one-step torchrun --nproc_per_node=8 train_vosr_distill.py --config configs/train_yml/one_step/VOSR_0.5B.yml # VOSR-1.4B one-step torchrun --nproc_per_node=8 train_vosr_distill.py --config configs/train_yml/one_step/VOSR_1.4B.ymlCite VOSR in research
mainIf you use VOSR in your research, please cite the following BibTeX entry:
@inproceedings{wu2026vosr, title = {VOSR: A Vision-Only Generative Model for Image Super-Resolution}, author = {Wu, Rongyuan and Sun, Lingchen and Zhang, Zhengqiang and Kong, Xiangtao and Zhao, Jixin and Wang, Shihao and Zhang, Lei}, booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition}, year = {2026} }