Skip to content

Commit

Permalink
Merge branch 'main' into torch_support
Browse files Browse the repository at this point in the history
  • Loading branch information
ebezzam committed Aug 29, 2023
2 parents f4535fe + f226b97 commit 448177b
Show file tree
Hide file tree
Showing 33 changed files with 1,986 additions and 51 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ data/*
models/*
*.png
*.jpg
*.npy

configs/telegram_demo_secret.yaml

Expand Down
9 changes: 9 additions & 0 deletions configs/adafruit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defaults:
- demo
- _self_

plot: True

capture:
exp: 5.0
awb_gains: [1, 1]
4 changes: 4 additions & 0 deletions configs/apgd_l1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ defaults:
- defaults_recon
- _self_

preprocess:
# Downsampling factor along X and Y
downsample: 8

apgd:
# Proximal prior / regularization: nonneg, l1, null
prox_penalty: l1
Expand Down
4 changes: 4 additions & 0 deletions configs/apgd_l2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ defaults:
- defaults_recon
- _self_

preprocess:
# Downsampling factor along X and Y
downsample: 8

apgd:
diff_penalty: l2
diff_lambda: 0.0001
Expand Down
1 change: 1 addition & 0 deletions configs/defaults_recon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ preprocess:
single_psf: False
# Whether to perform construction in grayscale.
gray: False
bg_pix: [5, 25] # null to skip


display:
Expand Down
2 changes: 2 additions & 0 deletions configs/demo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ display:
psf: null
# all black screen
black: False
# all white screen
white: False

capture:
gamma: null # for visualization
Expand Down
23 changes: 23 additions & 0 deletions configs/digicam.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
rpi:
username: null
hostname: null

device: adafruit
virtual: False
save: True

# pattern: data/psf/adafruit_random_pattern_20230719.npy
pattern: random
# pattern: rect
# pattern: circ
min_val: 0 # if pattern: random, min for range(0,1)
rect_shape: [20, 10] # if pattern: rect
radius: 20 # if pattern: circ
center: [0, 0]


aperture:
center: [59,76]
shape: [19,26]

z: 4 # mask to sensor distance
47 changes: 47 additions & 0 deletions configs/recon_dataset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# python scripts/recon/dataset.py
defaults:
- defaults_recon
- _self_

torch: True
torch_device: 'cuda:0'

input:
# https://drive.switch.ch/index.php/s/NdgHlcDeHVDH5ww?path=%2Fpsf
psf: data/psf/adafruit_random_2mm_20231907.png
# https://drive.switch.ch/index.php/s/m89D1tFEfktQueS
raw_data: data/celeba_adafruit_random_2mm_20230720_1K

n_files: 25 # null for all files
output_folder: data/celeba_adafruit_recon

# extraction region of interest
roi: null # top, left, bottom, right
# -- values for `data/celeba_adafruit_random_2mm_20230720_1K`
# roi: [10, 300, 560, 705] # down 4
# roi: [6, 200, 373, 470] # down 6
# roi: [5, 150, 280, 352] # down 8

preprocess:
flip: True
downsample: 6

# to have different data shape than PSF
data_dim: null
# data_dim: [48, 64] # down 64
# data_dim: [506, 676] # down 6

display:
disp: -1
plot: False

algo: admm # "admm", "apgd", "null" to just copy over (resized) raw data

apgd:
n_jobs: 1 # run in parallel as algo is slow
max_iter: 500

admm:
n_iter: 10

save: False
38 changes: 38 additions & 0 deletions configs/sim_digicam_psf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# python scripts/sim/digicam_psf.py
hydra:
job:
chdir: True # change to output folder

use_torch: False
dtype: float32
torch_device: cuda
requires_grad: True

digicam:

slm: adafruit
sensor: rpi_hq

# https://drive.switch.ch/index.php/s/NdgHlcDeHVDH5ww?path=%2Fpsf
pattern: data/psf/adafruit_random_pattern_20230719.npy
ap_center: [59, 76]
ap_shape: [19, 26]
rotate: -0.8 # rotation in degrees

# optionally provide measured PSF for side-by-side comparison
# https://drive.switch.ch/index.php/s/NdgHlcDeHVDH5ww?path=%2Fpsf
psf: data/psf/adafruit_random_2mm_20231907.png
gamma: 2 # for plotting measured

sim:

# whether SLM is fliped
flipud: True

# in practice found waveprop=True or False doesn't make difference
waveprop: False

# below are ignored if waveprop=False
scene2mask: 0.03 # [m]
mask2sensor: 0.002 # [m]

38 changes: 38 additions & 0 deletions configs/train_celeba_classifier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
hydra:
job:
chdir: True # change to output folder

seed: 0

data:
# -- path to original CelebA (parent directory)
original: /scratch/bezzam

output_dir: "./vit-celeba" # basename for model output

# -- raw
# https://drive.switch.ch/index.php/s/m89D1tFEfktQueS
measured: data/celeba_adafruit_random_2mm_20230720_10K
raw: True

# # -- reconstructed
# # run `python scripts/recon/dataset.py` to get a reconstructed dataset
# measured: null
# raw: False

n_files: null # null to use all in measured_folder
test_size: 0.15
attr: Male # "Male", "Smiling", etc

augmentation:

random_resize_crop: False
horizontal_flip: True # cannot be used with raw measurement!

train:

prev: null # path to previously trained model
n_epochs: 4
dropout: 0.1
batch_size: 16
learning_rate: 2e-4
1 change: 1 addition & 0 deletions digicam_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
slm_controller @ git+https://github.com/ebezzam/slm-controller.git
14 changes: 14 additions & 0 deletions docs/source/data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ use the correct PSF file for the data you're using!
input.psf=data/psf/tape_rgb.png
Measured CelebA Dataset
-----------------------

You can download 1K measurements of the CelebA dataset done with
our lensless camera and a random pattern on the Adafruit LCD
`here (1.2 GB) <https://drive.switch.ch/index.php/s/m89D1tFEfktQueS>`__,
and a dataset with 10K measurements
`here (13.1 GB) <https://drive.switch.ch/index.php/s/9NNGCJs3DoBDGlY>`__.
They both correspond to the PSF which can be found `here <https://drive.switch.ch/index.php/s/NdgHlcDeHVDH5ww?path=%2Fpsf>`__
(``adafruit_random_2mm_20231907.png`` which is the PSF of
``adafruit_random_pattern_20230719.npy`` measured with a mask to sensor
distance of 2 mm).


DiffuserCam Lensless Mirflickr Dataset (DLMD)
---------------------------------------------

Expand Down
Loading

0 comments on commit 448177b

Please sign in to comment.