Official implementation for NeurIPS 2026.
VAGS is a training-free adaptive guidance scheduling framework for diffusion-based image editing. At each denoising step, it modulates the CFG scale based on the cosine similarity between source and target velocity fields — suppressing guidance in early noisy steps (where velocities are misaligned) and amplifying it in late semantic steps (where they agree).
conda create -n vags python=3.10 -y && conda activate vags
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
pip install diffusers transformers accelerate sentencepiece
pip install pillow numpy pandas scikit-image lpips open-clip-torchTested on NVIDIA H100/A100 80 GB with SD 3.5 Large (stabilityai/stable-diffusion-3.5-large).
python run_vags.py \
--src_image inputs/cat.jpg \
--src_prompt "a cat sitting on a red chair" \
--tgt_prompt "a dog sitting on a red chair" \
--output outputs/dog.pngpython run_vags.py \
--dataset pie_bench \
--outdir outputs/pie_bench \
--gpu 0python run_vags.py \
--dataset yaml \
--yaml_file Data/flowedit.yaml \
--images_root Data/ \
--outdir outputs/custom \
--gpu 0Key option: --kappa 0.9 (default) controls the modulation strength.
Three example images from the paper are included in data/. To run immediately:
python run_vags.py \
--dataset yaml \
--yaml_file data/edits.yaml \
--images_root . \
--outdir outputs/demo \
--gpu 0This edits the three pairs used in the trajectory figure of the paper (cat→tiger, tiger→crochet tiger, raspberries→strawberries).
PIE-Bench — Download from DirectInversion and place at:
Data/
└── PIE-Bench_v1/
├── annotation_images/
└── mapping_file.json
Custom pairs — Define source/target prompt pairs in a YAML file (see data/edits.yaml for the format).
After editing, compute metrics with:
# PIE-Bench (uses foreground masks)
python evaluate.py \
--annotation_mapping_file Data/PIE-Bench_v1/mapping_file.json \
--edited_images_dir outputs/pie_bench \
--tgt_methods flowedit_sd35_conflictaware_cosine \
--result_path outputs/pie_bench/results_vags.csv
# Custom YAML (full image, no mask)
python evaluate.py \
--yaml_file Data/flowedit.yaml \
--src_image_folder Data/ \
--edited_images_dir outputs/custom \
--tgt_methods flowedit_sd35_conflictaware_cosine \
--no_pie_mask \
--result_path outputs/custom/results_vags.csvThen aggregate:
python compute_all_metrics.py --result_csv outputs/pie_bench/results_vags.csvTo reproduce the full comparison table, use benchmark.py which runs all baselines and VAGS in parallel across GPUs:
# PIE-Bench — all methods
python benchmark.py \
--pie_bench \
--outdir outputs/pie_bench_full \
--methods 9 10 11 12 13 \
--gpu_map 0 1 2 3 4--methods index |
Method |
|---|---|
| 9 | FlowEdit (SD 3.5) |
| 10 | FlowEdit + Interval |
| 11 | FlowEdit + Monotone |
| 12 | FlowEdit + Zero-Init |
| 13 | FlowEdit + VAGS ← ours |
The core function is FlowEditSD3_ConflictAware_Cosine in FlowEdit_utils.py.
Adaptive target scale at active step
where
At early noisy steps (
Default hyperparameters:
| Parameter | Value | Description |
|---|---|---|
kappa_tar |
0.9 | Modulation strength κ |
src_guidance_scale |
3.5 | λ_src (fixed) |
tar_guidance_scale |
13.5 | λ_tar base value |
T_steps |
50 | Total denoising steps |
n_max |
33 | Active editing window |
| Method | Dist↓ | PSNR↑ | LPIPS↓ | MSE↓ | SSIM↑ | CLIP-I↑ |
|---|---|---|---|---|---|---|
| FlowEdit | 30.31 | 21.87 | 117.06 | 92.70 | 82.54 | 83.69 |
| + Interval | 29.82 | 21.93 | 114.14 | 91.72 | 82.88 | 84.03 |
| + Monotone | 15.91 | 25.43 | 69.87 | 43.47 | 87.67 | 84.73 |
| + Zero-Init | 194.67 | 11.69 | 354.57 | 867.59 | 57.64 | 75.28 |
| + VAGS (ours) | 13.84 | 26.38 | 70.38 | 34.86 | 87.68 | 87.44 |
| Method | Dist↓ | PSNR↑ | LPIPS↓ | MSE↓ | SSIM↑ |
|---|---|---|---|---|---|
| FlowEdit | 18.27 | 20.27 | 145.55 | 103.37 | 82.15 |
| + Monotone | 10.89 | 22.47 | 102.91 | 63.91 | 83.64 |
| + VAGS (ours) | 8.62 | 23.61 | 98.43 | 50.22 | 84.41 |
Included in methods/:
| Method | Reference |
|---|---|
| FlowEdit | kulikov2024flowedit |
| SplitFlow | yoon2025splitflow |
| RF-Inversion | rout2024rfinversion |
| RF-Solver | wang2024rfsolver |
| FireFlow | deng2024fireflow |
| FTEdit | xu2025ftedit |
| DDIM+P2P / DDIM+PnP | hertz2022prompt2prompt |
| Null-text Inversion | mokady2023nulltext |
| iRFDS | yang2025irfds |
Measured on a single NVIDIA RTX 6000 Ada (48GB) with SD 3.5 Large,
| Time per image | |
|---|---|
| FlowEdit (baseline) | ~13s (±0.5s) |
| FlowEdit + VAGS | ~13s (±0.5s) |
VAGS adds no overhead over standard FlowEdit: both perform the same number of model forward passes. The adaptive guidance reuses the raw transformer outputs from the single forward pass — no extra model call.
@inproceedings{vags2026,
title = {VAGS: Velocity Adaptive Guidance Scale Enhancing Generative Models},
booktitle = {Advances in Neural Information Processing Systems (NeurIPS)},
year = {2026}
}