The Problem

Estimating depth from a single defocused image without ground‑truth supervision is still a research‑grade capability. Practitioners need a reproducible reference implementation that can evaluate the Zero‑Shot Depth from Defocus (ZEDD) benchmark and, eventually, train the FOSSA model on their own data.

What This Does

The repository provides the FOSSA model – a Vision‑Transformer‑style backbone (FOSSAModel/fossa/fossa.py) together with a motion‑module and a custom CUDA extension (powerexppsf/powerexppsfcuda.cpp/.cu). The codebase implements:

Inference / evaluation – entry point eval.py loads a trained checkpoint, builds the model, and runs the ZEDD benchmark (see zeddtest/ utilities). Dataset handling – dataset/ contains parsers for HAMMER, DDFF‑12, and the ZEDD dataset (dataset/hammer.py, dataset/ddff12val.py, dataset/zedd.py). Utility scripts – training scaffolding (util/train.py), validation (util/val.py), and rendering helpers (util/render.py).

All model components are pure Python except the defocus PSF operator, which must be compiled via powerexppsf/setup.py.

How To Use It

Environment conda create -n fossa python=3.8 conda activate fossa Dependencies (exact versions not locked) pip install -r requirements.txt Build the CUDA extension (required for both training and evaluation) cd powerexppsf python setup.py buildext --inplace Verify import python - <<'PY' import powerexppsfcuda print("CUDA extension loaded from", powerexppsfcuda.file) PY cd .. Make the extension importable export PYTHONPATH=$PWD/powerexppsf:$PYTHONPATH Download datasets (example for HAMMER) mkdir -p dataset/datasets && cd dataset/datasets wget https://huggingface.co/datasets/Ruicheng/monocular-geometry-evaluation/resolve/main/HAMMER.zip unzip HAMMER.zip && rm HAMMER.zip cd ../../.. Run evaluation on the ZEDD benchmark python eval.py --config config/val.py --ckpt path/to/fossacheckpoint.pth

Configuration: config/val.py contains the model hyper‑parameters and dataset paths used by eval.py. No additional environment variables are required beyond the PYTHONPATH tweak.

Training: When the training code is released (roadmap states April 2026), util/train.py will be the entry point; currently only evaluation is functional.

Real‑World Use

A robotics perception pipeline can call the model as a library:

from FOSSAModel.fossa.fossa import FOSSA import torch, powerexppsfcuda

model = FOSSA(pretrained='path/to/checkpoint.pth') model.eval() depth = model(singledefocusedimage.unsqueeze(0)) # Tensor, Bx1xHxW

The output depth map can be fused with SLAM or used for scene understanding without needing multi‑view data.

Code Health & Issues

Low – Missing lockfile – requirements.txt is not version‑pinned; reproducible builds depend on the current PyPI state. Medium – No CI/CD – No .github/, travis.yml, or other pipeline; tests (zedd_test/.py) are present but not automatically exercised. Low – Limited documentation – README covers installation but lacks API docs for FOSSAModel classes; developers must read source. Low – CUDA extension build assumes a compatible GPU/driver – No fallback or informative error handling if compilation fails. Low – License present – LICENSE is included, mitigating legal risk. Low – Test coverage – Only four test files; they validate format checking rather than model correctness.

Overall the code follows a standard PyTorch project layout, with clear separation between model (FOSSAModel/), data (dataset/), and utilities (util/). No obvious security secrets are stored.

The Bottom Line

FOSSA delivers a functional reference implementation for zero‑shot depth‑from‑defocus evaluation, with a clean modular structure and a working CUDA extension. The main drawbacks are the absence of reproducible dependency locking and an automated test pipeline. It is suitable for research teams that can manage their own CI and environment reproducibility, but not for production deployments without additional engineering effort.