Skip to content

Commit

Permalink
Merge branch 'main' of github.com:LCAV/LenslessPiCam
Browse files Browse the repository at this point in the history
  • Loading branch information
ebezzam committed May 14, 2024
2 parents 49fa828 + e188645 commit d048629
Show file tree
Hide file tree
Showing 28 changed files with 292 additions and 141 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Changed
- For trainable masks, set trainable parameters inside the child class.
- ``distance_sensor`` optional for ``lensless.hardware.mask.Mask``, e.g. don't need for fabrication.
- More intuitive interface for MURA for coded aperture (``lensless.hardware.mask.CodedAperture``), i.e. directly pass prime number.
- ``is_torch`` to ``use_torch`` in ``lensless.hardware.mask.Mask``
- ``self.height_map`` as characterization of phase masks (instead of phase pattern which can change for each wavelength)


Bugfix
Expand Down
5 changes: 3 additions & 2 deletions configs/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ hydra:
chdir: True


dataset: DiffuserCam # DiffuserCam, DigiCamCelebA, DigiCamHF
dataset: DiffuserCam # DiffuserCam, DigiCamCelebA, HFDataset
seed: 0

huggingface:
repo: "bezzam/DigiCam-Mirflickr-MultiMask-25K"
image_res: [900, 1200] # used during measurement
rotate: True # if measurement is upside-down
alignment:
topright: [80, 100] # height, width
top_left: [80, 100] # height, width
height: 200
downsample: 1

Expand Down Expand Up @@ -88,6 +88,7 @@ simulation:
scene2mask: 0.25 # [m]
mask2sensor: 0.002 # [m]
# see waveprop.devices
use_waveprop: False # for PSF simulation
sensor: "rpi_hq"
snr_db: 10
# simulate different sensor resolution
Expand Down
4 changes: 2 additions & 2 deletions configs/train_digicam_multimask.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ files:
display_res: [900, 1200] # used during measurement
rotate: True # if measurement is upside-down
alignment:
topright: [80, 100] # height, width
top_left: [80, 100] # height, width
height: 200

# TODO: these parameters should be in the dataset?
alignment:
# when there is no downsampling
topright: [80, 100] # height, width
top_left: [80, 100] # height, width
height: 200

training:
Expand Down
4 changes: 2 additions & 2 deletions configs/train_digicam_singlemask.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ files:
display_res: [900, 1200] # used during measurement
rotate: True # if measurement is upside-down
alignment:
topright: [80, 100] # height, width
top_left: [80, 100] # height, width
height: 200

# TODO: these parameters should be in the dataset?
alignment:
# when there is no downsampling
topright: [80, 100] # height, width
top_left: [80, 100] # height, width
height: 200

training:
Expand Down
5 changes: 3 additions & 2 deletions configs/train_unrolledADMM.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ files:

# -- processing parameters
downsample: 2 # factor by which to downsample the PSF, note that for DiffuserCam the PSF has 4x the resolution
downsample_lensed: 2
downsample_lensed: 2 # only used if lensed if measured
input_snr: null # adding shot noise at input (for measured dataset) at this SNR in dB
vertical_shift: null
horizontal_shift: null
Expand All @@ -41,7 +41,7 @@ files:
extra_eval: null # dict of extra datasets to evaluate on

alignment: null
# topright: null # height, width
# top_left: null # height, width
# height: null

torch: True
Expand Down Expand Up @@ -129,6 +129,7 @@ simulation:
scene2mask: 10e-2 # scene2mask: 40e-2
mask2sensor: 9e-3 # mask2sensor: 4e-3
# see waveprop.devices
use_waveprop: False # for PSF simulation
sensor: "rpi_hq"
snr_db: 10
# simulate different sensor resolution
Expand Down
1 change: 1 addition & 0 deletions configs/upload_dataset_huggingface.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ lensless:
dir: null
ext: null # for example: .png, .jpg
eight_norm: False # save as 8-bit normalized image
downsample: null

lensed:
dir: null
Expand Down
19 changes: 8 additions & 11 deletions lensless/eval/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ def benchmark(
if not os.path.exists(output_dir):
os.mkdir(output_dir)

alignment = None
if hasattr(dataset, "alignment"):
alignment = dataset.alignment

if metrics is None:
metrics = {
"MSE": MSELoss().to(device),
Expand Down Expand Up @@ -156,13 +152,14 @@ def benchmark(
prediction = prediction.reshape(-1, *prediction.shape[-3:]).movedim(-1, -3)
lensed = lensed.reshape(-1, *lensed.shape[-3:]).movedim(-1, -3)

if alignment is not None:
prediction = prediction[
...,
alignment["topright"][0] : alignment["topright"][0] + alignment["height"],
alignment["topright"][1] : alignment["topright"][1] + alignment["width"],
]
# expected that lensed is also reshaped accordingly
if hasattr(dataset, "alignment"):
if dataset.alignment is not None:
prediction = dataset.extract_roi(prediction, axis=(-2, -1))
else:
prediction, lensed = dataset.extract_roi(
prediction, axis=(-2, -1), lensed=lensed
)
assert np.all(lensed.shape == prediction.shape)
elif crop is not None:
prediction = prediction[
...,
Expand Down
Loading

0 comments on commit d048629

Please sign in to comment.