Skip to content

Commit

Permalink
Merge branch 'main' of github.com:LCAV/LenslessPiCam into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ebezzam committed Aug 1, 2023
2 parents 1e404ca + 53c6113 commit 24a147a
Show file tree
Hide file tree
Showing 23 changed files with 1,597 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/python_no_pycsou.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ jobs:
run: |
pip install -U pytest
pip install -r recon_requirements.txt
pip install -r mask_requirements.txt
pytest
1 change: 1 addition & 0 deletions .github/workflows/python_pycsou.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ jobs:
run: |
pip install -U pytest
pip install -r recon_requirements.txt
pip install -r mask_requirements.txt
pip install git+https://github.com/matthieumeo/pycsou.git@v2-dev
pytest
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
scripts/recon/outputs/
.idea/

*_sol.py
scripts/admm_*
scripts/gd_*
Expand Down Expand Up @@ -97,6 +95,17 @@ target/

# Jupyter Notebook
.ipynb_checkpoints
*.ipynb

# Images and NPY files
*.png
*.npy

# Datasets
data/celeba_mini

# FlatCam reconstruction
masks/FlatCam/flatcam-authors

# IPython
profile_default/
Expand Down Expand Up @@ -152,3 +161,4 @@ dmypy.json

# Pyre type checker
.pyre/

5 changes: 4 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ Added
- Link and citation for JOSS.
- Authors at top of source code files.
- Add paramiko as dependency for remote capture and display.
- Mask module, for CodedAperture (FlatCam), PhaseContour (PhlatCam), and FresnelZoneAperture.
- Script for measuring arbitrary dataset (from Raspberry Pi).
- Support for preprocessing and postprocessing, such as denoising, in ``TrainableReconstructionAlgorithm``. Both trainable and fix postprocessing can be used.
- Utilities to load a trained DruNet model for use as postprocessing in ``TrainableReconstructionAlgorithm``.
- Support for unrolled loading and inference in the script ``admm.py``.
- Tikhonov reconstruction for coded aperture measurements (MLS / MURA).


Changed
Expand All @@ -36,7 +38,8 @@ Changed
Bugfix
~~~~~~

- Displaying 3D reconstructions by summing values along axis would produce un-normalized values.
- Fix overwriting of sensor parameters when downsampling.
- Displaying 3D reconstructions by summing values along axis would produce un-normalized values.

1.0.4 - (2023-06-14)
--------------------
Expand Down
31 changes: 31 additions & 0 deletions configs/mask_sim_dataset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
defaults:
- mask_sim_single
- _self_

seed: 0
save: True

files:
dataset: data/celeba_mini
image_ext: jpg
n_files: 10 # null to use all

simulation:
object_height: [0.25, 0.3] # range for random height, or scalar
random_shift: False
grayscale: False

# torch for reconstruction
torch: False
torch_device: 'cuda:0'

recon:

algo: "tikhonov" # "tikhonov" or "admm" or None to skip

tikhonov:
reg: 3e-4

admm:
# Recommend to not display, ok for small number of files, otherwise many windows will pop up!
disp_iter: null
61 changes: 61 additions & 0 deletions configs/mask_sim_single.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
hydra:
job:
chdir: True # change to output folder


files:
original: data/celeba_mini/000019.jpg
#original: data/original/mnist_3.png

save: True

simulation:
object_height: 0.3
# these distance parameters are typically fixed for a given PSF
scene2mask: 40e-2
mask2sensor: 4e-3
# see waveprop.devices
sensor: "rpi_hq"
snr_db: 20
# Downsampling for PSF
downsample: 8

# max val in simulated measured (quantized 8 bits)
max_val: 230

image_format: rgb # rgb, grayscale, bayer_rggb, bayer_bggr, bayer_grbg, bayer_gbrg

flatcam: False # only supported if mask.type is "MURA" or "MLS"


mask:
type: "MLS" # "MURA", "MLS", "FZA", "PhaseContour"

# Coded Aperture (MURA or MLS)
#flatcam_method: 'MLS'
n_bits: 8 # e.g. 8 for MLS, 99 for MURA

# Phase Contour
noise_period: [16, 16]
refractive_index: 1.2
phase_mask_iter: 10

# Fresnel Zone Aperture
radius: 0.32e-3


recon:

algo: "admm" # tikhonov or admm

tikhonov:
reg: 3e-4

admm:
n_iter: 20
disp_iter: 2
# Hyperparameters
mu1: 1e-6
mu2: 1e-5
mu3: 4e-5
tau: 0.0001
9 changes: 8 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

MOCK_MODULES = [
"scipy",
"scipy.signal",
"scipy.linalg",
"pycsou",
"matplotlib",
"matplotlib.pyplot",
Expand All @@ -28,7 +30,12 @@
"PIL",
"tqdm",
"paramiko",
"paramiko.ssh_exception"
"paramiko.ssh_exception",
"perlin_numpy",
"waveprop",
"waveprop.fresnel",
"waveprop.rs",
"waveprop.noise",
]
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = mock.Mock()
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Contents
measurement
reconstruction
evaluation
mask
sensor
utilities
demo
Expand Down
33 changes: 33 additions & 0 deletions docs/source/mask.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.. automodule:: lensless.hardware.mask


Abstract Mask Class
~~~~~~~~~~~~~~~~~~~

.. autoclass:: lensless.hardware.mask.Mask
:members:
:special-members: __init__


Coded Aperture (FlatCam)
~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: lensless.hardware.mask.CodedAperture
:members:
:special-members: __init__


Phase Contour (PhlatCam)
~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: lensless.hardware.mask.PhaseContour
:members:
:special-members: __init__


Fresnel Zone Aperture
~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: lensless.hardware.mask.FresnelZoneAperture
:members:
:special-members: __init__
8 changes: 8 additions & 0 deletions docs/source/reconstruction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@

.. autofunction:: lensless.recon.admm.finite_diff_gram


Tikhonov (Ridge Regression)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: lensless.CodedApertureReconstruction
:special-members: __init__, apply


Accelerated Proximal Gradient Descent (APGD)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
1 change: 1 addition & 0 deletions lensless/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
FISTA,
GradientDescentUpdate,
)
from .recon.tikhonov import CodedApertureReconstruction
from .hardware.sensor import VirtualSensor, SensorOptions

try:
Expand Down
Loading

0 comments on commit 24a147a

Please sign in to comment.