Skip to content

Repository files navigation

Position-Blind Ptychography

This is the accompanying repository for the paper "Position-Blind Ptychography: Viability of image reconstruction via data-driven variational inference" [1]. Please use the citation provided at the end of this README if you use any of our code or research.

Setup

Requirements are listed in requirements.txt. First, set up a new Python 3.10 virtualenv (but Python >= 3.8 should generally work), install the Torch dependencies with the correct CUDA version, as instructed on the PyTorch website, e.g.:

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

and then install other dependencies in requirements.txt with pip:

pip3 install -r requirements.txt

Checkpoint download

Download our pretrained checkpoint for the score model by running

pip install gdown
gdown --fuzzy https://drive.google.com/file/d/1rgYMQIAiRqSUHWa9cUTrK4DGlKSy9aFi/view?usp=sharing

then unzip this file, and move the extracted files to some folder that works for you. You should pass the resulting path to the .ckpt file to --model-ckpt-path (see example reconstruction command below).

Reconstruction

As an example reconstruction with variational inference using a score-based surrogate prior, you can execute:

python reconstruct_vi.py \
    --gt-obj-path testobj0_innsbruck8.npy \
    --gt-probe-path probe_files/default_probe.npy \
    --meas-noise-stdev 0.005
    --model-ckpt-path runs/2uqqf40h/checkpoints/epoch=141-step=266392.ckpt \
    --model-config-path config_vp.yaml \
    --output "results/example_$(date +"%Y-%m-%d_%H-%M-%S").h5" \
    --gt-rk-spread 0.33 \
    --pad-by-probe True \
    --gt-rk-n 100 \
    --device 0 \
    --N-opt 10000 \
    --N-pos-opt 10 \
    --N-img-opt 1 \
    --bSDE-t-eps 0.01 \
    --img-lr-schedule cos_4000_6000 \
    --save-params-every 50 \
    --seed 0 \
    --bs 4

See python reconstruct_vi.py --help for help on all available options.

Probe generation

To generate other probe functions, you can use generate_probe.py.

Training

To train a score model you can run the following, which uses LightningCLI:

python main.py fit --config conf/acaiv2_256_vpsde.yaml

Citation

@article{welker2025position,
  title={Position-Blind Ptychography: Viability of image reconstruction via data-driven variational inference},
  author={Welker, Simon and Kuger, Lorenz and Roith, Tim and Feng, Berthy and Burger, Martin and Gerkmann, Timo and Chapman, Henry N.},
  journal={arXiv preprint arXiv:2509.25269},
  year={2025}
}

About

Position-blind ptychography with data- and model-driven variational inference

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages