This project implements a depth bokeh system and web demo. Given a single RGB image, we estimate a depth map and apply a depth-based blur to simulate camera aperture effects. The project also includes a small web demo and an evaluation script to compare results against different baselines.
# if you would like to use GPU
conda create -n depthbokeh python=3.10 -y
conda activate depthbokeh
pip install torch==2.3.0+cu121 torchvision==0.18.0+cu121 --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt
# if you are not using GPU
pip install -r requirements.txt
.
├── dataset/
│ ├── train/
│ │ ├── gt/ # unblut image
│ │ └── depth/ # generated depth maps (.npy)
│ └── val/
│ ├── baseline/ # ground truth images for evaluation
| ├── depth/ # generated depth maps (.npy)
│ ├── result/ # our method outputs (40r.jpg)
│ ├── google/ # google baseline outputs (40g.jpg)
| ├── gt/ # original RGB images without blur
│ └── gpt/ # gpt baseline outputs (40gpt.jpg)
│
├── model/
│ ├── blur.py # depth bokeh rendering
│ └── depth_generate.py # depth estimation (DepthPro / Depth-Anything)
│
├── src/
│ ├── utils.py # all helper
│ ├── gpt_gen.py # generate gpt images
│ └── evaluate.py # PSNR / SSIM / LPIPS evaluation
│
├── templates/
│ └── index.html # web to generate our result
│
├── server.py # Flask web demo
├── requirements.txt
├── evaluation.py
├── run_interactive.py
└── README.md
We support two pre-trained depth models:
- High quality: Apple DepthPro
- Low quality but faster: Depth-Anything V2
Depth maps will be saved as .npy files.
If you would like to generate a depth map you can:
# change the path!
python model/depth_generate.py
We have a small Flask server provides an interactive demo.
The features are:
- upload an image
- click to select focus point
- adjust aperture to control blur strength
Run the server:
python app.py
Open in your browser:
We evaluate results using:
- PSNR – pixel-level reconstruction accuracy
- SSIM – structural similarity
- LPIPS – perceptual similarity
The evaluation compares:
- our method (using our demo code)
- a Google phone editing
- a GPT-based generative baseline (Gpt5)
Expected file naming:
- GT: baseline/40.jpg
- ours: result/40r.jpg
- google: google/40g.jpg
- gpt: gpt/40gpt.jpg
Open src/evaluate.py set your base path Then run:
python src/evaluate.py
Average PSNR / SSIM / LPIPS values are printed to the terminal.