We condition text-to-image diffusion models on a defocus blur parameter, so the amount of bokeh can be set directly and changed without altering the scene. The method works with both Stable Diffusion and FLUX.
01Abstract
Recent advances in large-scale text-to-image models have revolutionized creative fields by generating visually captivating outputs from textual prompts; however, while traditional photography offers precise control over camera settings to shape visual aesthetics—such as depth-of-field via aperture—current diffusion models typically rely on prompt engineering to mimic such effects. This approach often results in crude approximations and inadvertently alters the scene content.
In this work, we propose Bokeh Diffusion, a scene-consistent bokeh control framework that explicitly conditions a diffusion model on a physical defocus blur parameter. To overcome the scarcity of paired real-world images captured under different camera settings, we introduce a hybrid training pipeline that aligns in-the-wild images with synthetic blur augmentations, providing diverse scenes and subjects as well as supervision to learn the separation of image content from lens blur. Central to our framework is our grounded self-attention mechanism, trained on image pairs with different bokeh levels of the same scene, which enables blur strength to be adjusted in both directions while preserving the underlying scene.
Extensive experiments demonstrate that our approach enables flexible, lens-like blur control, supports downstream applications such as real image editing via inversion, and generalizes effectively across both Stable Diffusion and FLUX architectures.
02Method
Two ingredients: a bokeh-conditioned denoiser that keeps the scene anchored while the blur changes, and a hybrid dataset that teaches the model to separate content from lens blur.
Architecture
Denoising network εθ
- Text cross-attention frozen
- Bokeh cross-attention trained, deeper layers
- Grounded self-attention trained
Text & Bokeh Cross-Attention
The blur level gets its own keys and values, next to the frozen text attention.
Grounded Self-Attention
The pivot fixes the layout; the target supplies the blur.
Training data
In-the-wild data collection
Real photos with authentic lens blur
-
1Collect
NIKON D3200
30 mm · 1/500 sPhotos with EXIF lens metadata
-
2Annotate
A countryside scene with cows in a lush green field…
Caption · Depth · Mask
-
3Filter
- Aperture
- Focal length
- Fg / Bg area
- Fg / Bg depth
Reliable lens info, clear subject
-
4Balance
Long-tail → uniform blur
Synthetic bokeh augmentation
One scene at several blur levels
-
1All-in-focus
Image, depth and mask
-
2Defocus map

Blur radius K ~ 𝒰
-
3Render
KSame scene, different K
03Direct Bokeh Control
Sample an image directly at the bokeh level you want. The number on each image is the bokeh condition, on a scale from 0 (all-in-focus) to 30.
12FLUX
1FLUX
21FLUX
30FLUX
29SD 1.5
2FLUX
30FLUX
0SD 1.5
18FLUX
0FLUX
28FLUX
18SD 1.5
29SD 1.5
22FLUX04Scene-Consistent Bokeh
Grounded self-attention keeps the scene fixed while the blur changes continuously. One dial drives every scene below. Click any scene to inspect it up close.
05Comparison with Non-generative Methods
Post-processing bokeh renderers depend on external depth estimation. Bokeh Diffusion instead leverages the generative prior of text-to-image models and our in-the-wild dataset to produce more natural bokeh in challenging areas, such as thin structures and translucent materials.

Drag across the image to compare.
Thin structures: depth-based rendering blurs the whiskers together with the background. Bokeh Diffusion keeps them sharp.
06Citation
@inproceedings{fortes2025bokeh,
title = {Bokeh Diffusion: Defocus Blur Control in Text-to-Image Diffusion Models},
author = {Fortes, Armando and Wei, Tianyi and Zhou, Shangchen and Pan, Xingang},
booktitle = {Proceedings of the SIGGRAPH Asia 2025 Conference Papers},
series = {SA Conference Papers '25},
publisher = {ACM},
articleno = {160},
pages = {1--11},
year = {2025},
doi = {10.1145/3757377.3763906}
}

