Geometrically regularized automatic differentiation framework for BCDI phase retrieval.
- Python ≥ 3.12
- NVIDIA GPU with CUDA ≥ 12 and compatible drivers
Note:
tensorflow[and-cuda]andtensorrtrequire NVIDIA hardware. Installation on CPU-only machines or non-NVIDIA GPUs is not supported.
python3.12 -m venv .venv
source .venv/bin/activate # on Windows: .venv\Scripts\activatepip install git+https://github.com/matteomasto/convex-ad.gitThis will install convex_ad and all its dependencies, including TensorFlow with CUDA support, and TensorRT.
If you want to develop or modify the code:
git clone https://github.com/matteomasto/convex-ad.git
cd convex-ad
pip install -e .import convex_ad
print(convex_ad.__version__) # should print 0.1.0| Package | Version | Source |
|---|---|---|
tensorflow[and-cuda] |
≥ 2.21.0 | PyPI |
tensorrt |
≥ 10.15.1.29 | PyPI |
scipy |
≥ 1.13 | PyPI |
scikit-image |
≥ 0.25 | PyPI |
matplotlib |
≥ 3.8 | PyPI |
hdf5plugin |
≥ 5.0.0 | PyPI |
colorcet |
≥ 3.1.0 | PyPI |
ipykernel |
≥ 7.2.0 | PyPI |
ipywidgets |
≥ 8.1.8 | PyPI |
See the examples/ folder and the notebooks/ folder for a full demo.
import numpy as np
import convex_ad
from convex_ad.core import PhaseRetrievalModel, train_step
from convex_ad.losses import total_loss
# Load your diffraction data
Iobs = np.load("data.npz")["I"].astype(np.float32)
# Build and train the phase retrieval model
model = PhaseRetrievalModel(Iobs, batch_size=4)
# ... see examples/run_reconstruction.py for a complete workflowSee LICENSE.