This work was carried out by Suparnojit Sarkar, during his Machine Learning Engineer Internship at Glance under the mentorship of Vajra Ganesh.

Introduction

Text-to-image diffusion models have revolutionized image generation. Given a prompt such as “a person wearing a red jacket standing on a beach,” they can synthesize photorealistic images from pure noise.

Image editing, however, poses a different challenge. Rather than generating a new image, the goal is to modify only the requested attribute while preserving everything else. For example, changing a red jacket to a black shirt should leave the person’s identity, pose, lighting, composition, and background untouched.

Conventional text-to-image models are not designed for this task. Since they are trained to generate images from scratch, every inference starts from random noise and follows a denoising trajectory toward an image matching the prompt. They have no inherent mechanism to preserve the contents of an existing image, so naïvely prompting them with an editing instruction often produces an entirely new image instead of a faithful edit.

Can we transform a text-to-image model into an image editor without retraining it?

In this article, we answer the above question by showing how a pre-trained text-to-image model can be repurposed as an image editor entirely at inference time. Rather than fine-tuning the model or introducing additional trainable components, we leverage inference-time techniques — FlowEdit and FlowAlign — to guide the latent generation trajectory. This enables instruction-guided image editing while preserving the source image, all without modifying the underlying Z-Image model.

To understand how this works, we’ll first look at how Z-Image generates images and why direct editing approaches often fail. We’ll then see how FlowEdit and FlowAlign overcome these limitations, enabling high-fidelity, instruction-guided image editing without any additional training.

Understanding Z-Image

Z-Image Architecture. Image taken from [3]

How Z-Image Generates Images

At a high level, Z-Image consists of three components:

From Text to Image

Given a prompt such as “A person wearing a red jacket standing on a beach,” Qwen3–4B first produces contextual text embeddings that condition the image generation process.

Unlike autoregressive language models, Z-Image generates directly in the Flux VAE latent space. Since there is no input image during inference, generation begins from a randomly sampled Gaussian noise latent. This latent, together with the text embeddings, is then fed into S3-DiT.

Flow Matching

Z-Image is trained using Flow Matching, where the model predicts a velocity — the direction in which the current latent should move — rather than the noise itself. Starting from random noise, S3-DiT repeatedly predicts these velocities, and a flow solver integrates them over multiple timesteps, gradually transforming the latent into one that matches the text prompt.

The final latent is then decoded by the Flux VAE decoder to produce the output image.

Our First Attempts at Image Editing

Having understood how Z-Image generates images, the next challenge was adapting it for image editing.

A natural first idea was to provide the model with the source image alongside the editing instruction — the image would specify what to preserve, while the text would specify what to change. Before modifying the generation process itself, we explored several conditioning strategies.

Attempt 1: Conditioning on the Reference Image

We first encoded the source image using SigLIP 2 [4], producing visual tokens that were concatenated with the text embeddings from Qwen3–4B before being passed to S3-DiT. Classifier-free guidance (CFG) was then used to encourage the requested edit.

[ Edit Instruction | Reference Image Features ]

While the model utilized both inputs, the results were inconsistent. Beyond the requested edit, it often altered the subject’s identity, pose, composition, or background. The core issue is that conditioning informs the model what information is available, but not what must remain unchanged. As a result, the image features and editing instruction compete during generation, and CFG can amplify unintended changes.

Attempt 2: Converting the Image into Text

Next, we described the source image using Qwen3-VL [5] and conditioned Z-Image on both the generated caption and the editing instruction.

[ Edit Instruction | Source Image Caption ]

Although this unified both inputs into a single modality, captions are inherently lossy. They capture high-level semantics but omit fine-grained details such as facial identity, pose, spatial layout, lighting, and texture. Consequently, the generated images preserved the overall scene but failed to faithfully reproduce the source image.

Attempt 3: Image-Guided Generation

Finally, we removed the editing instruction entirely and conditioned the model only on the SigLIP 2 image features, while still starting generation from random noise.

The model produced plausible variations of the reference image, preserving its overall subject and style, but the pose, viewpoint, and composition frequently changed. It could generate similar images, but not controlled edits.

The Common Failure

Despite their differences, all three approaches relied on the same assumption: better conditioning should lead to better editing.

In practice, the bottleneck was not the conditioning but the generation trajectory. Once generation begins from random noise, nothing constrains the latent to remain close to the source image. Conditioning influences what the model should generate, but not how the latent evolves over time.

This shifts the problem from improving the input to controlling the generation process itself.

Can we directly modify the generation trajectory instead?

That question leads us to FlowEdit [1].

FlowEdit: Editing the Trajectory Instead of the Conditioning

Our earlier attempts all shared the same limitation: they improved the conditioning, but left the generation process unchanged. Although the model had access to the source image through image features or captions, the latent trajectory could still drift away once denoising began.

FlowEdit takes a different approach. Instead of providing more information to the model, it directly modifies how the latent evolves during generation.

Thinking in Terms of Velocities

Recall that Z-Image is trained using Flow Matching, where the model predicts a velocity at every timestep — the direction in which the current latent should move.

Consider two prompts describing the same scene:

At the same latent point, we query the model twice: once with the source prompt and once with the target prompt. The difference between the two predicted velocities represents the semantic edit direction — the change required to transform the source concept into the target one.

v_src = model(z_t, source prompt)
v_tgt = model(z_t, target prompt)

Steering the Trajectory

The updated velocity is computed as:

v_edit = v_src + α · (v_tgt - v_src)

Here, α controls the edit strength.

Small values of α keep the trajectory close to the source image, while larger values produce stronger edits. In our example, the source velocity preserves the person’s identity, pose, lighting, and background, while the velocity difference gradually replaces the black shirt with a red jacket.

Instead of regenerating the image, FlowEdit performs a sequence of small semantic updates throughout the denoising process.

Why This Works Better

FlowEdit shifts the focus from conditioning to trajectory control. Rather than relying on the model to infer what should be preserved, it explicitly edits the predicted velocity at every flow step, making the generation process itself editable.

Results:

From left to right: the input image, the source and target instruction, and the image edited with FlowEdit.
From left to right: the input image, the source and target instruction, and the image edited with FlowEdit.
From left to right: the input image, the source and target instruction, and the image edited with FlowEdit.

But One Problem Remains

Although FlowEdit greatly improves controllability, it does not fully prevent trajectory drift. Strong editing prompts can gradually pull the latent away from the source image, causing unintended changes such as altered facial identity, pose, or background.

In other words, FlowEdit provides the direction of the edit, but not an explicit mechanism to keep the edited trajectory close to the original one.

This motivates FlowAlign [2], which continuously anchors the edited trajectory to the source trajectory throughout generation.

FlowAlign: Anchoring the Trajectory to the Source Image

FlowAlign addresses the drawbacks of FlowEdit by continuously anchoring the edited trajectory to the source image throughout generation.

Constructing a Reference Trajectory

Recall that during editing we already have access to the source image. Unlike text-to-image generation, where inference begins from random noise, image editing begins with a known image that can be encoded into the same latent space used by Z-Image.

Let z_src be the clean source latent, x_t the current edited latent, σ the current noise level, and ε fresh noise.

q_t = (1 - σ) · z_src + σ · ε

q_t represents the noisy source latent at the current timestep.

The latent q_t can be thought of as the reference point for the source image at the current timestep. Instead of comparing the edited latent to the fully clean source image, FlowAlign compares two latents that exist at the same noise level, making the comparison meaningful throughout the denoising process.

Aligning the Edited Trajectory

The edited latent, denoted by x_t, may already have drifted away from the source trajectory due to the semantic edit introduced by FlowEdit.

Before computing velocity updates, FlowAlign first aligns the edited latent with the source trajectory as follows:

p_t = x_t + q_t - z_src

This simple transformation ensures that both trajectories are represented at a comparable point in the diffusion process before the model predicts their respective velocities.

Predicting Source and Target Velocities

FlowAlign then queries the transformer using both the source and target prompts.

Using the aligned latent p_t, the model predicts

Classifier-Free Guidance (CFG) combines these predictions to produce the final editing velocity:

v_pc = transformer(p_t, target prompt)
v_pn = transformer(p_t, source prompt)
v_p = v_pn + cfg_scale · (v_pc - v_pn)
v_q = transformer(q_t, source prompt)

At the same time, the transformer predicts another velocity v_q using the noisy source latent q_t and the original source prompt.

Intuitively,

Preventing Trajectory Drift

The final update contains two separate components.

The first is the familiar FlowEdit update, which moves the latent toward satisfying the editing instruction.

The second is an alignment term, which pulls the edited trajectory back toward the source trajectory whenever the two begin to diverge.

The complete update is:


x_t_new = x_t
+ (σ_next - σ) · (v_p - v_q)
+ λ · (q_t - σ · v_q - p_t + σ · v_p)

The parameter λ controls the strength of this alignment.

This creates a natural trade-off between edit strength and content preservation, allowing the user to adjust the behavior depending on the task.

Results:

From left to right: the input image, the editing instruction, and the image edited with FlowAlign.
From left to right: the input image, the editing instruction, and the image edited with FlowAlign.

Building Z-Image Edit

By combining FlowEdit and FlowAlign, Z-Image can be repurposed into a training-free image editor entirely at inference time. FlowEdit introduces the desired semantic change, while FlowAlign preserves the source image by anchoring the latent trajectory. The complete pipeline consists of four steps.

Step 1: Encode the Source Image

The source image is encoded by the Flux VAE into a latent representation, providing the starting point for editing.

Step 2: Define the Edit

The model receives two prompts: a source prompt describing the original image and a target prompt describing the desired edit.

Source: “A person wearing a black shirt standing on a beach.”

Target: “A person wearing a red jacket standing on a beach.”

Ideally, the prompts differ only in the attribute to be modified.

Step 3: Guided Flow Updates

At each flow timestep, Z-Image Edit:

  1. Reconstructs the noisy source latent for the current timestep.
  2. Predicts source and target velocities using S3-DiT.
  3. Applies FlowEdit to compute the semantic edit direction.
  4. Applies FlowAlign to keep the trajectory aligned with the source image.

The latent is therefore updated toward the target concept while remaining faithful to the original scene.

Step 4: Decode the Result

After the final flow step, the edited latent is decoded by the Flux VAE to produce the final image. Since all modifications occur during inference, no additional training or fine-tuning is required.

Controlling the Edit

Z-Image Edit exposes two key controls:

Together, these parameters balance edit strength and content preservation. Stronger alignment is generally preferred for localized edits (e.g., changing clothing color), while larger semantic changes may require stronger edit guidance.

Limitations

Although FlowEdit and FlowAlign enable training-free image editing with pre-trained Z-Image models, they have important limitations. FlowEdit can suffer from structural drift, identity loss, and poor source preservation, particularly for large semantic edits. FlowAlign mitigates these issues by anchoring the editing trajectory to the source image, but it requires multiple flow evaluations and careful hyperparameter tuning, increasing computational cost and reducing robustness across diverse editing tasks.

These challenges motivate a future dedicated image editing model trained from scratch on editing pairs, which could achieve higher edit fidelity, stronger instruction following, and better identity preservation than inference-time approaches.”

Conclusion

Transforming a text-to-image model into an image editor requires more than conditioning on a reference image. As we saw, conditioning alone cannot prevent the generation trajectory from drifting away from the source image.

Z-Image Edit addresses this by controlling the generation process itself. FlowEdit steers the latent toward the desired edit, while FlowAlign keeps the trajectory anchored to the source image, enabling high-quality, instruction-guided editing entirely at inference time — without retraining the underlying model.

The key insight is that effective image editing comes not from changing the model itself, but from controlling its latent generation trajectory.

References

[1] V. Kulikov, M. Kleiner, I. Huberman-Spiegelglas, and T. Michaeli, FlowEdit: Inversion-Free Text-Based Editing Using Pre-Trained Flow Models, Proc. IEEE/CVF International Conference on Computer Vision (ICCV), 2025, pp. 19721–19730.

[2] J. Kim, Y. Hong, J. Park, and J. C. Ye, FlowAlign: Trajectory-Regularized, Inversion-Free Flow-based Image Editing, International Conference on Learning Representations (ICLR), 2026.

[3] Z-Image Team, H. Cai, S. Cao, R. Du, P. Gao, S. Hoi, et al., Z-Image: An Efficient Image Generation Foundation Model with Single-Stream Diffusion Transformer, arXiv:2511.22699, 2025.

[4] Tschannen, M., Gritsenko, A., Wang, X., Naeem, M. F., Alabdulmohsin, I., Parthasarathy, N., … & Zhai, X. (2025). Siglip 2: Multilingual vision-language encoders with improved semantic understanding, localization, and dense features. arXiv preprint arXiv:2502.14786.

[5] Bai, S., Cai, Y., Chen, R., Chen, K., Chen, X., Cheng, Z., … & Zhu, K. (2025). Qwen3-vl technical report. arXiv preprint arXiv:2511.21631.

<hr><p>Repurposing Text-to-Image Models as Image Editing Models was originally published in Glance on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>