We study Text-and-Image-to-Image (TI2I) flow matching methods for controllable image editing. In a broader generative modeling context, Classifier-Free Guidance (CFG) is established as a key component responsible for high quality outputs. However, we argue that its role in TI2I modeling is poorly understood. Specifically, we make the surprising observation that the CFG mechanism is implicitly harmful for editing in the noisy phase of flow modeling, hindering instruction following and controllability. We propose a simple correction in the early flow steps, enabling a richer alignment-preservation tradeoff at no extra cost. The effectiveness of our approach is demonstrated on both pixel-space and latent TI2I flows.
Figures & tables
Figure 1: We propose a simple modification in TI2I flows that substantially improves source preservation while maintaining text alignment. In the examples above, source images are on the left, baseline edits in the middle (we evaluate Qwen, FLUX.2 and PixelGen models) and editing with our correction on the right.
Figure 2: Visualization of two representative TI2I modeling scenarios with our PixelGen finetune. The first rows show the iterates xt . The second and third rows show the unconditional and conditional predictions of the network for the output edit image given xt , which can be derived given knowledge of the corresponding velocities. The last rows show the evolution of the differential velocity, equivalent to the difference of the second and third rows. Specifically, we visualize its magnitude as a heatmap that is normalized for each t . In both cases, the results of the last row concentrate on the edit regions near t=0 and become less localized and noisy as t→1 . Moreover, the failure in the right example is evident immediately at t=0 and we can intuitively attribute it to the unconditional prediction of the second row, where the field has been repainted.
Figure 3: Average localization gain ( ± the standard error) for our PixelGen finetune. We use SAM 3 ( Carion et al., 2026 ) for the oracle masks. Results labeled as ψt(⋅;⋅) correspond to using the analytical flow model, previously discussed in Section 2.1 .
Figure 4
Figure 6: We ablate the proposed correction on our PixelGen finetune with simple edit tasks, setting τ=0.05 . Of tested configurations, only the one corresponding to Equation 6 is successful.
Preservation
Alignment
Method
PSNR ↑
LPIPS ↓
DINOv2 ↑
CLIP ↑
PickScore ↑
HPSv3 ↑
1024×1024
Qwen-Image-Edit
13.06
0.4948
0.7082
0.2853
22.15
7.65
+ Classifier-free guidance ( ω=4.00 )
11.25
0.5616
0.5750
0.2905
22.03
6.88
+ Early correction ( τ=0.10 )
14.05
0.4159
0.6606
0.2946
22.28
7.97
FLUX.2 [klein] 4B Base
27.65
0.0516
0.9926
0.2389
21.63
7.92
+ Classifier-free guidance ( ω=4.00 )
20.22
0.1973
0.9163
0.2605
21.88
7.91
Table 1: Editing with Qwen, FLUX.2 and PixelGen. Without CFG we tend to observe strong preservation but insufficient alignment. That is, CFG is often essential for image editing. However, recommended weights, ω , tend to improve alignment while harming preservation. Early correction mitigates this tradeoff by largely improving preservation while maintaining strong alignment for Qwen-Image-Edit and PixelGen. For FLUX.2, found relatively conservative at 1024×1024 resolution, it recovers part of the distortion introduced by CFG while retaining its alignment gains. Moreover, our intervention is a key ingredient for unlocking robust masked guidance, i.e., removing it in the last row of the PixelGen experiments introduces severe distortion.
Figure 7: Alignment-preservation tradeoffs via PSNR and CLIP. We evaluate our PixelGen finetune, FLUX.2 and Qwen models. Curves form by varying ω , with faint colors given to small values. Our method redefines the Pareto front, enabling robust editing.
Figure 8: Qualitative analysis showing the effect of ω and τ at 1024×1024 resolution. On the left we show edits with Qwen-Image-Edit and on the right with FLUX.2 [klein] 4B Base. The first columns use τ=0 , i.e., no early correction. In both cases, τ=0 tends to give generic results at large ω that may disregard the source. That is, on the left the raccoon is changed to a cat and on the right, eventually, no elements from the source survive. The proposed correction, activated when τ>0 , produces edits that are more faithful to the source without compromising instruction-following ability. See Figure 11 in Appendix B for more examples.
Figure 9: We show DINOv2-HPSv3, Aesthetics tradeoffs for the PixelGen, FLUX.2 and Qwen models with different ω and τ . Curves represent fixed ω and form by varying τ , with faint colors given to small values. A positive τ often improves all metrics.
Figure 10: Compositions of our two editing benchmarks, with approximately 200 entries each. The panels pair two donuts, showing the distribution of source images on the left and of edit prompts on the right. The benchmark on the left panel targets single objects on plain backdrops with localized recolor and material edits, i.e., confined within a specific region of the image. The benchmark on the right targets complex, typically crowded scenes and was specifically designed as a stress-test of TI2I capabilities. Together, they cover the spectrum from precise local edits to scene-wide changes that must still preserve surrounding context.
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
Figure 11: Editing with FLUX.2, showing the effect of ω and τ at 512×512 resolution. Ours, with τ>0 , maintains the lemon shape (left), perspective (middle) and booth shape (right) while adhering to the text.
Classifier-free guidance (CFG) improves conditional generation in Flow Matching, but strong guidance can distort the generated distribution and reduce diversity. We provide a geometric account of this behavior by viewing Flow Matching as a time-varying gradient flow and characterizing how CFG reshapes its underlying potential. This view explains how stronger alignment can be accompanied by mean displacement and trajectory concentration, and motivates controlling guidance through the model-implied terminal posterior mean. We therefore propose Posterior-Mean-Capped CFG (PMC-CFG), a training-free, per-sample method that adaptively retains the strongest feasible guidance without additional network evaluations. Experiments on synthetic and large-scale image-generation benchmarks show that PMC-CFG limits guidance-induced distortion and concentration while improving the alignment--diversity trade-off, with particularly strong benefits when nominal guidance is large.
Jishen Peng, Zheng Ma
School of Mathematical Sciences, Shanghai Jiao Tong University, Shanghai, China · Institute of Natural Sciences, MOE-LSC, Shanghai Jiao Tong University, Shanghai, China · Qing Yuan Research Institute, Shanghai Jiao Tong University, Shanghai, China +1
Inference-time quality-enhancement methods are an effective and widely adopted means of improving diffusion models without expensive retraining. We study a family of training-free techniques conceptually rooted in Classifier-Free Guidance (CFG), most of which were originally proposed on older U-Net diffusion models and validated using metrics that assess image quality in isolation, without accounting for compositional alignment or semantic correspondence between the generated image and its associated text prompt. We re-evaluate eight such methods on two open-weight rectified-flow transformers under a fixed per-model protocol and three compositional-alignment benchmarks. No method consistently improves on CFG across the measured criteria. APG obtains several nominal best scores, but the corresponding gains often remain within the estimated evaluation uncertainty. Attention-perturbation methods provide isolated gains on SD3.5 Medium and more frequent degradations on FLUX.2 [klein] 4B Base, while CFG remains a competitive lower-cost baseline.
Classifier-free guidance (CFG) typically applies a shared scale to all latent tokens, although their velocity predictions evolve differently during sampling. We introduce Trajectory-Adaptive Classifier-Free Guidance (TrajCFG), a training-free method for flow-matching models that adapts token-wise guidance using historical changes in guided velocity direction. TrajCFG maps this feedback to bounded scales, assigning stronger guidance to larger directional changes and weaker guidance to more consistent directions. It combines adjacent-step and interval-normalized longer-span feedback, reusing standard CFG predictions without additional model evaluations. Controlled diagnostics and ablations examine the roles of directional feedback, token-wise allocation, and history-span fusion. Experiments on text-to-video, image-to-video, text-to-audio-video, text-to-image, and image-to-3D generation show improvements over base samplers across multiple backbones. For text-to-video generation, TrajCFG improves VBench Total scores by 0.30-0.75 points over the strongest evaluated baseline on each of three backbones. These results support historical directional feedback as a broadly applicable signal for fine-grained guidance allocation. The project page is available at https://jyliu-98.github.io/trajcfg-project-page/.
Jingyu Liu, Hao Jiang, Yikang Ding +6
Renmin University of China · Kling Team, Kuaishou Technology