VOSR: Vision-Only Super-Resolution Framework

repository·main·Indexed 40 days ago

https://github.com/cswry/vosr

A 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.

Tokens
1.8K
Snippets
5
Records
9
Agent score
6%

What's inside VOSR

  1. License information

    main
    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.
  2. Fine-tune Multi-step Inference Parameters

    main

    When 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.5 to 2, with 0.5 being 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 is 0.1.
    • --infer_steps: Number of sampling steps (default 25).

    Benchmark Presets:

    • For RealSR: Use --cfg_scale -0.5.
    • For ScreenSR: Use --cfg_scale 0.5.
  3. Configure VOSR Model Weights

    main

    Download 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) model

    Note 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/
  4. Run VOSR Inference

    main

    Inference is performed on a single GPU. Use inference_vosr.py for multi-step models and inference_vosr_onestep.py for 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 4

    Multi-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 4

    One-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 4
  5. Perform Tiled Inference for Large Images

    main

    To 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 (default 0 = disabled).
    • --vae_tile_size <pixels>: Sets the VAE encoder/decoder tile size (default 0 = 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 1024
  6. Install VOSR

    main

    To 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.txt
  7. Configure VOSR Training Data

    main

    VOSR supports two data loading modes via the dataset_type key in your YAML configuration:

    1. txt mode: Each folder contains individual image files (.png / .jpg). You must provide a text configuration file that lists folders with sampling weights.
    2. webdataset mode: Each folder contains .tar shards. This uses the same text configuration format as txt mode 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, 1

    Higher weights result in more frequent sampling.

  8. Train VOSR Models (Multi-step and One-step)

    main

    Training is performed using torchrun. By default, experiment tracking is disabled (report_to: none). To use Weights & Biases, run wandb login and set report_to: wandb in your YAML config.

    Multi-step Training

    Use train_vosr.py with 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.yml

    One-step Distillation

    Requires a trained multi-step teacher checkpoint. Set teacher_ckpt and pretrained_ckpt in your YAML config and use train_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.yml
  9. Cite VOSR in research

    main

    If 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}
    }