AnyBokeh: Physics-Guided Any-to-Any Bokeh Editing with Optical Fingerprint Transfer
Paper • 2606.31959 • Published • 5
How to use itsmag11/AnyBokeh with Diffusers:
pip install -U diffusers transformers accelerate
import torch
from diffusers import DiffusionPipeline
from diffusers.utils import load_image
# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("itsmag11/AnyBokeh", dtype=torch.bfloat16, device_map="cuda")
prompt = "Turn this cat into a dog"
input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png")
image = pipe(image=input_image, prompt=prompt).images[0]Paper | Project Page | Code
AnyBokeh transforms an image from an arbitrary source optical state to a desired target focus and aperture setting. It consists of two LoRAs on top of FLUX.1-Fill-dev:
stage1/: estimates the circle-of-confusion (CoC) map and the disparity map of the input image.stage2/: re-renders the image with the target focus point and aperture.Each folder also contains the precomputed text embeddings of the stage prompt, so the text encoders are not needed at inference.
git clone https://github.com/itsmag11/AnyBokeh.git
cd AnyBokeh
python inference_full.py --image_path examples/127_f5.0.JPG --focus_x 904 --focus_y 613 --source_aperture 5.0 --target_aperture 2.8 --output_path outputs/127_f5.0_to_f2.8.jpg
The weights in this repo are downloaded automatically. See the GitHub repo for more details.
@inproceedings{hou2026anybokeh,
title = {AnyBokeh: Physics-Guided Any-to-Any Bokeh Editing with Optical Fingerprint Transfer},
author = {Hou, Xinyu and Li, Xiaoming and Yue, Zongsheng and Loy, Chen Change},
booktitle = {Advances in Neural Information Processing Systems (NeurIPS)},
year = {2026}
}
Base model
black-forest-labs/FLUX.1-Fill-dev