Abstract
Standard diffusion models are typically restricted to rectilinear projections, leading to artifacts and resolution loss when simulating wide-angle or non-standard lenses via post-processing. We present AnyLens, a framework that integrates geometric control directly into the diffusion process. By conditioning on per-pixel coordinates and local metric tensors, and employing a density-aware attention mechanism, AnyLens generates high-fidelity images with precise optical geometry, including panoramic and spherical projections.
Introduction
Current state-of-the-art text-to-image models, such as Stable Diffusion, assume a "flat" rectilinear camera model. While users can prompt for effects like "fish-eye," the resulting images are often geometric approximations rather than accurate optical simulations. Traditional methods for achieving specific lens effects involve warping standard outputs, which causes significant resolution degradation in expanded regions and leaves "holes" in the image frame. AnyLens addresses these issues by allowing the model to "paint" natively within the target geometry.
Methodology
AnyLens introduces three core technical innovations to enable geometric flexibility:
Per-Pixel Coordinate Conditioning
The model is provided with a two-channel "warping field" that maps each output pixel to its corresponding location in an undistorted reference space. This allows the model to maintain spatial consistency across various lens types.
Density-Aware Self-Attention
Geometric warping creates variations in local pixel density. Standard self-attention layers, unaware of these distortions, often produce structural artifacts. AnyLens reweights attention scores based on the logarithm of local pixel density, ensuring that the model's focus is distributed appropriately across stretched or compressed regions.
Metric Tensor Conditioning
To support complex, non-planar geometries such as spheres, AnyLens utilizes a metric tensor ($g_{ij}$). This mathematical representation of local curvature allows the model to generate seamless textures for 3D objects, ensuring that patterns remain consistent regardless of the underlying surface geometry.
Experimental Results
AnyLens was evaluated by fine-tuning a Latent Diffusion Model on the WebLI dataset, using synthetic distortions for training.
Image Quality and Fidelity
Quantitative testing on the MS-COCO dataset showed that AnyLens maintains an FID score of 17.5, identical to the base model. This demonstrates that geometric control can be added without sacrificing the aesthetic quality of the generated images.
Geometric Accuracy
Vanishing point analysis confirmed the physical accuracy of the generated lenses. When fish-eye images produced by AnyLens are mathematically "unwarped," parallel lines in the scene become straight, proving that the model has learned the underlying physics of the lens rather than just a stylistic filter. In human preference studies, AnyLens's spherical texturing was preferred 58% of the time over baseline methods.
Conclusion
AnyLens provides a robust framework for generating images with arbitrary rendering lenses. By integrating geometry into the core generative loop, it achieves a level of fidelity and control previously unattainable with post-processing. Future research will focus on expanding these controls to include depth-of-field and more complex optical systems.
Summary updated