TL;DR
This paper introduces a novel text-to-image diffusion model that allows for precise, interactive control over image defocus blur by leveraging camera EXIF data, specifically aperture settings. Unlike previous methods that struggle with scene consistency, this approach decouples image generation from blur simulation, enabling users to adjust blur levels without altering the underlying scene content.
What Problem Does This Paper Address?
Modern text-to-image diffusion models are incredibly powerful at generating diverse and high-quality images. However, they lack the nuanced control that photographers have when capturing real-world scenes. Specifically, they struggle to mimic the effect of adjusting camera aperture and focus distance to selectively blur backgrounds or foregrounds, a common technique for directing viewer attention and enhancing aesthetic appeal. Existing methods often fail to maintain scene integrity when attempting to control blur, leading to unrealistic artifacts or entirely altered compositions. This paper aims to bridge this gap by enabling fine-grained, content-preserving defocus blur control directly within the generative process, guided by camera metadata.
Methods
The core of the proposed method is a novel text-to-image diffusion framework that integrates a differentiable lens model. The pipeline works as follows:
- All-in-Focus Image Generation: A fast, few-step generator (distilled from SDXL using DMD2) first produces an all-in-focus image based on a text prompt.
- Depth Estimation: A pre-trained monocular depth estimation model (Metric3Dv2) predicts the depth map for the generated all-in-focus image.
- Focus Distance Prediction: A novel "focus distance transformer" (adapted from a Visual Saliency Transformer) takes the all-in-focus image and its depth map as input. It predicts a plausible focus distance and a scale factor. This component is weakly supervised, learning from shallow depth-of-field images.
- Differentiable Lens Model: A physically-inspired thin lens blur model (TAF Lens) is used to apply spatially varying blur. This model is parameterized by focal length, the predicted focus distance, and the user-specified aperture. Crucially, this lens model is differentiable, allowing gradients to flow back through the entire pipeline.
- End-to-End Training: The entire pipeline, including the generator and the focus distance model, is trained end-to-end using unsupervised losses derived from Distribution Matching Distillation (DMD2) on deep and shallow depth-of-field datasets.
At inference time, the framework allows for swapping the lens model, demonstrating compatibility with other renderers like Dr.Bokeh for potentially higher-quality results.
Datasets
- Deep Depth-of-Field (DoF) Dataset: Constructed from a large pool of uncurated images, used for pre-training the all-in-focus generator.
- Shallow Depth-of-Field (DoF) Dataset: Also constructed from uncurated images, used for fine-tuning the entire pipeline, including the focus distance prediction and lens model.
- Stock Photography Dataset: Approximately 1.5 million samples were extracted for training the deep and shallow DoF datasets.
No new benchmarks were introduced; the focus was on leveraging existing datasets and models.
Key Insights and Ideas
- Decoupling Generation and Blur: The most significant insight is the successful decoupling of the image content generation from the blur simulation process. This allows for independent control over both aspects, leading to more realistic and controllable defocus effects.
- Weak Supervision for Focus Distance: The paper demonstrates that focus distance, often missing or unreliable in EXIF, can be effectively predicted using weak supervision derived from shallow depth-of-field images. This is a crucial step for enabling EXIF-based control without requiring perfectly annotated data.
- Differentiable Lens Model for End-to-End Training: Integrating a differentiable lens model is key to enabling end-to-end training of the entire pipeline. This allows the generator to learn how to produce images that are suitable for realistic blur simulation, and the focus distance predictor to learn how to guide the blur application.
- Flexibility in Lens Model Choice: The framework's ability to swap lens models at inference time (e.g., using Dr.Bokeh) highlights its modularity and potential for integrating with state-of-the-art rendering techniques.
Key Results
- Superior Blur Control: The proposed method achieves significantly higher "Blur Monotonicity" scores (e.g., 93.91 with TAF Lens, 96.89 with Dr.Bokeh) compared to baselines, indicating a strong ability to increase blur as aperture decreases.
- Excellent Content Consistency: The model also achieves high "Content Consistency" scores (e.g., 92.34 with TAF Lens, 91.42 with Dr.Bokeh), demonstrating its effectiveness in preserving scene content across different blur levels.
- Improved Image Quality: The model achieves competitive FID scores for both deep (13.24 with TAF Lens) and shallow (16.69 with TAF Lens) depth-of-field images, suggesting good overall image quality.
- Qualitative Improvements: Visual comparisons show that the proposed method produces more realistic defocus effects and better preserves scene content compared to baselines like SDXL with Dr.Bokeh and Camera Settings as Tokens, especially across varying aperture settings.
Limitations and Future Work
- Background Blur in Generator: The authors note that due to strong priors in the distilled SDXL model, the all-in-focus generator can occasionally produce slight background blur, limiting the achievable "in-focus" quality. This could potentially be mitigated by increasing the deep DoF dataset size.
- Focus Distance Scale Supervision: The focus distance scale is learned from weak signals without direct supervision, which can sometimes lead to imperfect focal planes.
- Disc-Shaped Bokeh: The current implementation primarily generates disc-shaped bokeh. Future work could explore incorporating other bokeh shapes (e.g., hexagons, hearts) by swapping the lens model.
- Supervised Learning with Metric Depth: For future work, the authors suggest exploring supervised learning by capturing RGBD photos with precise metric depth measurements, which could potentially improve focus distance prediction.
- High-Frequency Details: Some high-frequency details (e.g., dog fur) can still appear blurry due to depth map resolution limitations, suggesting the use of more advanced depth estimators.
Summary updated