Image Editing
Instruction-driven editing rewrites photos from plain commands like make it sunset, changing pixels through language instead of masks and brushes.
Why Does This Exist?
Masks are tedious and imprecise for global edits. Asking for sunset over a lake should not require painting the sky pixel by pixel, yet classical inpainting demands exactly that kind of selection. Language already describes the change, so the editor should accept the sentence.
Instruction editing trains on triplets of original photo, written command, and edited result, generated at scale from paired captioning plus image models. At inference the photo and the command condition the denoiser jointly, and two guidance strengths balance obedience to each. The mask-based machinery behind selections is taught separately under image editing and inpainting, and the generative backbone it edits with belongs to image generation.
Think of It Like This
A retoucher who takes dictation
A photographer dictates to a retoucher: same portrait, golden-hour light. The retoucher holds the original under one hand and the instruction in mind, changing only what the sentence requires. No masks, no selections, just understanding of both inputs at once.
The two guidance strengths are how loudly each input speaks. The sitting fails on contradictory dictation, change nothing but change everything, and the retoucher must pick a middle the photographer never wanted.
How It Actually Works
The denoiser sees the noisy latent plus the encoded original photo concatenated as extra channels, and the command text through cross-attention. Sampling uses dual classifier-free guidance with separate scales for image and text:
Here is the unconditional estimate, is the photo-conditioned estimate, and is the fully conditioned estimate. Typical values are holding the photo and pushing the command. Training triplets come from prompting a language model for edit commands plus a text-to-image model for before-after pairs, filtered for consistency.
Worked example
Daylight lake, command make it sunset. Plug one scalar step through the formula with , , : the image term contributes and the text term contributes , so . The command pull dominates the photo pull fifteen to one, which is why skies burn orange while the dock geometry holds. Drop toward and the dock drifts into a generic pier; push past and the scene oversaturates into kitsch. The two-knob balance is the entire craft of the method.
Code
Dual guidance blending, the two-knob update inside each step. Pure standard library.
def dual_guidance(e_uncond: float, e_img: float, e_full: float, s_i: float = 1.5, s_t: float = 7.5) -> float: """Combine photo obedience with command obedience.""" return e_uncond + s_i * (e_img - e_uncond) + s_t * (e_full - e_uncond)
print(round(dual_guidance(0.1, 0.2, 0.4), 3)) # -> 2.5 strong command pullWatch Out For
Identity drift on faces at high text strength
Commands like make him smile at reshape identity along with expression: jawlines shift, moles vanish. Face edits need lower text strength plus identity checks, because likeness lives in details the command never mentions.
Pin faces with near and verify with face similarity, not eyeballing. What reads as a good smile may be a different person.
Training-triplet artefacts inherited wholesale
Synthetic triplets carry their generator's biases: same skies, same skin smoothing. The editor learns the triplet factory's house style on top of real edits.
Filter triplets for diversity and mix real edit pairs where available. Audit outputs for repeated stylistic tics across unrelated commands.
The Quick Version
- Instruction editing rewrites photos from commands, no masks required.
- The denoiser conditions on the photo plus the command with dual guidance scales.
- Typical balance is for the photo and for the command.
- Our worked step pulls to under strong command pressure.
- Faces drift at high text strength, and synthetic triplets inject house styles.