Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ilo #74

Open
wants to merge 202 commits into
base: main
Choose a base branch
from
Open

Ilo #74

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
202 commits
Select commit Hold shift + click to select a range
1abb1da
notes.txt to test the branches
Apr 25, 2023
f4e3935
masks folder, notebook to test FlatCam
Apr 25, 2023
a45cff3
added dimensions to simulate PSF
Apr 26, 2023
8df7426
MURA masks with different sizes
Apr 26, 2023
c139660
psf simulation notebook
Apr 26, 2023
5a95094
inverted colormaps for MURA
Apr 26, 2023
2dcd242
new masks with inverted colormap
Apr 26, 2023
81e1980
minor changes
Apr 27, 2023
e73b565
PhlatCam notebooks and masks creation
Apr 27, 2023
d684709
FZA notebooks and masks creation
Apr 27, 2023
2ea368a
PNG masks for the website
May 1, 2023
e71de45
PNG masks for the website
May 1, 2023
48615b6
fixed blank images
May 1, 2023
4681b8f
change MLS sequence
May 1, 2023
2eb2d0d
testing new MLS sequence generator
May 1, 2023
b6663c1
edge detection
May 1, 2023
59617c9
testing new MLS sequence generator
May 1, 2023
ba7e8f0
inp
May 2, 2023
7b20178
folders for MURA masks and MLS masks
May 2, 2023
07ec4dd
removed axis on MLS
May 2, 2023
8c45427
captioning
May 2, 2023
c259566
rectangular shape
May 2, 2023
18a01de
deleting images
May 2, 2023
63c3dc3
higher dimension mask
May 2, 2023
6bd6da1
different sizes and periods
May 2, 2023
478ce3f
iterative phase retrieval notebook
May 2, 2023
beb99cd
bigger plot titles
May 3, 2023
ff3cfb5
iterative phase retrieval attempt
May 3, 2023
9da780e
near-fresnel phase retrieval
May 10, 2023
f4bf5bf
testing fresnel on fza
May 11, 2023
ac5cc3d
print shapes
May 11, 2023
ecf975b
mask class py file
May 11, 2023
cfa4bda
change edges shape
May 11, 2023
b577e53
mask generation test
May 11, 2023
65929b6
mask_class rename
May 11, 2023
72a2c17
removed settings file
May 15, 2023
95872cd
answering pull request
May 15, 2023
bceb10b
Merge branch 'main' into masks
May 15, 2023
7d2ac90
testing phase retrieval
May 15, 2023
bedbae0
added to gitignore
May 15, 2023
62dfafa
add psf computation
May 15, 2023
64e2a69
added notebooks to gitignore
May 16, 2023
b9b3aa0
removed notebooks from tracking
May 16, 2023
3dd8dd7
removed from tracking
May 16, 2023
9c21a9f
add IPYNB, PNG and NPY
May 16, 2023
2e7df4e
removed simulated PSF images
May 16, 2023
eda68f4
2nd pull request comments
May 16, 2023
210ce26
mapping values from [-π,π] to [0,2π]
May 17, 2023
b267cce
corrected PhaseContour
May 17, 2023
95c988d
adding forward propagation coherence test
May 17, 2023
1cee06b
added formasks folders
May 23, 2023
b69e82d
added celeba_mini dataset
May 24, 2023
5ec2868
Fix simulation examples for 3D.
ebezzam May 24, 2023
5b0890c
merge with LCAV/fix_simulation_examples
May 24, 2023
7cb34f3
Fix single file example.
ebezzam May 24, 2023
538fe6f
Add function to set initial estimate.
ebezzam May 24, 2023
c3c2521
Add message if reset=False
ebezzam May 24, 2023
f2e2450
Update CHANGELOG
ebezzam May 24, 2023
15fda8b
Merge remote-tracking branch 'upstream/fix_simulation_examples' into …
May 25, 2023
6a3ead2
scripts/sim/test_single_file.py
May 25, 2023
5e791ba
added scripts/sim/test_dataset.py
May 26, 2023
956db17
added CodedAperture upscaling
May 31, 2023
ea65341
corrected CodedAperture rows and columns
May 31, 2023
42068a7
testing upscaling
May 31, 2023
3fd0769
added roundint to have 0s and 1s in upscaled MLS mask
Jun 6, 2023
2c045bb
squared amplitude PSF
Jun 8, 2023
b7a588d
making FZA mask binary
Jun 8, 2023
27bda12
making FZA mask binary
Jun 8, 2023
ebeb0ff
3D PSF
Jun 8, 2023
2eedf40
simplified phase contour
Jun 12, 2023
5d97f40
changing upscaled coded aperture mask into int
Jun 15, 2023
e145931
added cloned flatcam repo by tanjasper
Jun 15, 2023
9c059ab
inverted dimensions for FZA
Jun 20, 2023
820e54a
Merge branch 'main' into masks
Jun 27, 2023
5ae52f0
from_sensor class method
Jun 28, 2023
65a4d19
testing from_sensor class method
Jun 28, 2023
4ff7f1d
fixed PhaseContour broadcast error
Jun 28, 2023
31d8d39
fixed first 3 tests
Jun 28, 2023
c538bf7
added from_sensor tests for phase contour and FZA
Jun 29, 2023
ec1d9bf
upscaling for phase contour, removed default args from from_sensor, c…
Jun 29, 2023
33771b3
removed simulation-related files
Jul 4, 2023
acf8e76
Merge branch 'main' of https://github.com/AF-55/LenslessPiCam into masks
Jul 4, 2023
252deb0
placing mask.py in hardware module
Jul 4, 2023
bc7dfd7
corrected import
Jul 4, 2023
9f29d9d
add requirements for mask tests
Jul 4, 2023
23ee16c
removed 4 channel requirement
Jul 4, 2023
70f862d
added warnings about feature size for PhaseContour
Jul 4, 2023
3b8bd2a
sensor_dict copy in from_name
Jul 4, 2023
44b7abc
copies of sensor attributes in from_sensor
Jul 4, 2023
9508a65
no global variables, if main condition
Jul 4, 2023
c1ffa07
Fix overwriting of sensor parameters.
ebezzam Jul 7, 2023
fcf8a2b
Refactor names, compute PSF over different wv.
ebezzam Jul 7, 2023
bef7ca9
Update tests and requirements.
ebezzam Jul 7, 2023
085f5ca
Update CHANGELOG.
ebezzam Jul 7, 2023
fa0e9e0
Added header, corrected docstrings
Jul 7, 2023
6770fca
removed useless requirements
Jul 7, 2023
e802bb7
added mask
Jul 7, 2023
3cb2cc3
created mask rst file
Jul 7, 2023
b63385a
FIx documentation config to render mask module.
ebezzam Jul 7, 2023
11146e1
Update mask docstrings.
ebezzam Jul 7, 2023
4c1d8a0
added Phase Contour and FZA
Jul 7, 2023
73f6b9f
corrected docstring
Jul 11, 2023
4ff5d25
corrected docstring
Jul 11, 2023
7b9aab3
Fix docstrings.
ebezzam Jul 11, 2023
50557ca
Add target_psf docstring.
ebezzam Jul 11, 2023
06e4482
Changed the FZA radius from px to meters
Jul 13, 2023
365ed56
Merge branch 'masks' of https://github.com/AF-55/LenslessPiCam into m…
Jul 13, 2023
1425663
Changed FZA radius from pixels to meters
Jul 13, 2023
c699ae5
Added FlatCam authors' data for simulation
Jul 14, 2023
c71a29c
Replaced scipy.ndimage.zoom by lensless.utils.image.resize for uscpaling
Jul 14, 2023
b002820
minor changes
Jul 17, 2023
107121f
FlatCam recon and sim file
Jul 17, 2023
cea6019
deletion (replaced by tikhonov
Jul 18, 2023
320e4ca
Corrected docstrings
Jul 18, 2023
ef582e8
fixed bayer2rgb
Jul 18, 2023
9f0956f
Created reconstruction class, adapter rgb2bayer to different patterns
Jul 18, 2023
c874a90
Docstrings
Jul 19, 2023
62dbe37
Added conversions between RGB and 4d Bayer
Jul 19, 2023
2d0455c
removed image-related functions
Jul 19, 2023
19e1804
changed default noise period for PhaseContour
Jul 19, 2023
6a392b7
added custom P and Q matrices
Jul 20, 2023
491cc3b
removed resize import
Jul 20, 2023
8e976ff
added .upper() to coded aperture methods
Jul 20, 2023
e3454dc
fixed assertions
Jul 20, 2023
712990d
single file simulation with custom masks (Tikhonov method included)
Jul 20, 2023
6604f9c
Edit docstrings.
ebezzam Jul 20, 2023
f584b05
Merge branch 'masks' of https://github.com/AF-55/LenslessPiCam into m…
ebezzam Jul 20, 2023
4ebc364
Clean up mask example script.
ebezzam Jul 20, 2023
bf5d315
Update gitignore.
ebezzam Jul 20, 2023
074919d
Fix comment.
ebezzam Jul 20, 2023
4b466df
Update comments.
ebezzam Jul 20, 2023
8089c4f
Fix settings for FZA.
ebezzam Jul 21, 2023
91fda9f
changed default ADMM n_iter to 20
Jul 21, 2023
7ad591e
separated P & Q computation function
Jul 21, 2023
36c6c8b
changed default ADMM iter to 20
Jul 21, 2023
4e1606f
Merge branch 'masks' of https://github.com/AF-55/LenslessPiCam into m…
Jul 21, 2023
307ab49
Changed default FZA radius
Jul 25, 2023
b6304bd
Change file name
Jul 25, 2023
66dad51
name change
Jul 25, 2023
a1c0318
name change
Jul 25, 2023
c9e6aa5
Custom mask dataset simulation
Jul 25, 2023
b9e4acc
fixed MLS issue, removed comments
Jul 25, 2023
459b924
added reconstruction normalization
Jul 25, 2023
925a4b3
changed docstrings and config name
Jul 26, 2023
0f92ea6
change default flatcam parameter to false
Jul 26, 2023
0f7c51e
Merge with main.
ebezzam Jul 28, 2023
3622a9f
Add line for formatting.
ebezzam Jul 28, 2023
69a2e3a
Add support for float-valued feature_size.
ebezzam Jul 28, 2023
847a426
Refactor.
ebezzam Jul 28, 2023
8a6e9bc
Clean up mask simulation and tikhonov recon.
ebezzam Jul 28, 2023
9582a5d
Formatting.
ebezzam Jul 28, 2023
e0b6752
Formatting
ebezzam Jul 28, 2023
17f9b37
Add docs for coded aperture reconstruction.
ebezzam Jul 28, 2023
7601b87
ILO single image simulation files
Jul 31, 2023
e6178bd
added face alignment for ILO
Jul 31, 2023
08e3b0c
minor changes
Jul 31, 2023
498f2ce
minor changes (plots, docstring, etc)
Jul 31, 2023
71db09d
minor changes (plots, docstring, etc)
Jul 31, 2023
572e71a
implemented tikhonov reconstruction
Jul 31, 2023
443719a
Merge branch 'main' into masks
ebezzam Jul 31, 2023
599aa1f
FIx mask parsing.
ebezzam Jul 31, 2023
25eb4d8
Inherit from single file config, add torch support
ebezzam Jul 31, 2023
dc2331b
Update changelog
ebezzam Jul 31, 2023
0d78725
Update changelog.
ebezzam Jul 31, 2023
c14e2f8
Add punctuation.
ebezzam Jul 31, 2023
ad3eb2b
pull from masks
Aug 2, 2023
4917a05
separated to avoid conflicts
Aug 2, 2023
e41b2f4
Merge branch 'LCAV:main' into ilo
AF-55 Aug 2, 2023
8352bee
adapted to modified mask class
Aug 2, 2023
16b5dca
normalize psf
Aug 2, 2023
7c424b5
Merge branch 'masks' of https://github.com/AF-55/LenslessPiCam into ilo
Aug 2, 2023
e3b1c84
minor fixes + plots
Aug 2, 2023
7f6d057
minor fixes + plots
Aug 2, 2023
aac401c
clean code to remove ticks
Aug 2, 2023
f28c9dd
Merge branch 'masks' of https://github.com/AF-55/LenslessPiCam into ilo
Aug 2, 2023
2530987
Dirty dump of ILO reconstruction files.
ebezzam Aug 3, 2023
89cfd8d
refactor
ebezzam Aug 3, 2023
d0ab93c
rearranging
Aug 8, 2023
028dd7b
added numpy array PSF adaptation
Aug 8, 2023
a67ae1d
adapter to remote server (/scratch/...)
Aug 9, 2023
7074025
added dlib for ILO
AF-55 Aug 9, 2023
7815d17
File to test LatentOptimizer import
AF-55 Aug 15, 2023
ec23cda
Removed download, added predictor_path argument
AF-55 Aug 16, 2023
bcb4091
testing data imports
AF-55 Aug 16, 2023
2a1d251
added proper environment for ILO
AF-55 Aug 16, 2023
d9a93e6
minor modifications
AF-55 Aug 16, 2023
4ec2f6c
testing
AF-55 Aug 16, 2023
69dd5e6
Minor changes (align face)
AF-55 Aug 16, 2023
6025eba
Changed forward model
AF-55 Aug 16, 2023
21a7fab
Add face aligner download if needed.
ebezzam Aug 21, 2023
37a707e
Fix parsing of StyleGAN files.
ebezzam Aug 21, 2023
1d787f8
Added Ninja
AF-55 Aug 22, 2023
fa21a75
Changed paths and dirs
AF-55 Aug 22, 2023
f7260ae
Removed lambda in forward model definition
AF-55 Aug 22, 2023
153bf10
New file for ILO dataset simulation
AF-55 Aug 22, 2023
048d0ee
started to adapt code to single file
AF-55 Aug 22, 2023
5174b33
Clean up file paths.
ebezzam Aug 22, 2023
a893602
added psf argument
AF-55 Aug 22, 2023
63694c7
Fix forward model configuration.
ebezzam Aug 22, 2023
97eaa68
Use newer waveprop.
ebezzam Aug 22, 2023
160c03f
plotting ILO result
AF-55 Aug 22, 2023
dc3bfc7
Trying different hyperparameters.
ebezzam Aug 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 182 additions & 0 deletions configs/ilo_single_file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
hydra:
job:
chdir: True # change to output folder

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

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




# COPIED FROM HERE: https://github.com/ebezzam/ilo_lensless/blob/ilo_lensless/configs/config_default.yaml
# TODO PRUNE
# Inputs/Outputs directories and files
files:
original_fp: data/celeba_mini/000019.jpg
psf: data/psf/tape_rgb.png

#preprocess_dir: files/demo/preprocessed/
preprocess_dir: data/celeba_mini_aligned/
#psf_dir: files/demo/psf/
output_dir: ./output/
files_ext: '.png'
#pandas_file: ./metrics.pkl

face_aligner: 'models/ilo/shape_predictor_68_face_landmarks.dat'

mask:
type: "tape" # "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

lensless_imaging:
bool: false
psf_path: data/psf/tape_rgb.png # if simulated false

# PSF parameters (TODO consistent with simulation)
scene2mask: 40e-2 #m
mask2sensor: 4e-3 #m
object_height: 0.45 #m, TODO: made big to fit entire region
sensor: 'rpi_hq'
psf_size: [3040, 4056]
downsample: 8
image_format: RGB

# Simulation parameters
simulated:
bool: False
gaussian_noise: True
snr: 40.0
max_val: 255
flatcam: False

# Preprocessing actions
preprocessing:
align:
bool: False
resize:
bool: True
image_size: [1024, 1024]
grayscale: # TODO : works but PSF grayscale? how to do ?
bool: False
mask:
bool: False
bounding_box:
horizontal:
- 200
- 400
vertical:
- 200
- 400
noise:
bool: False
mode: gaussian #pepper #s&p #poisson #salt
mean: 0
var: 0.01
amount: 0.05
salt_vs_pepper: 0.5

# Tasks to perform
task:
grayscale:
bool: False # TODO

# Model configuration
# only StyleGAN is supported for now.
model:
type: 'stylegan2'
checkpoint: models/ilo/stylegan2-ffhq-config-f.pt
mapping: models/ilo/gaussian_fit.pt

# Optimization parameters
opti_params:
seed: 42
device: cuda

# batchsizes
batchsize_process : 1
batchsize_preprocess : 50

# Range of layers to optimize (no need to touch it)
start_layer: 0
end_layer: 8

# steps per layer -> define which layer is optimized
# if you want to skip optimization in some layers, just use 0 to the corresponding indices of steps.
# steps: [50, 50, 50, 50, 50, 50, 50, 50, 50] # up to 9, but need to extend max_radius_*
steps: [50, 50, 50, 50, 50, 50]

# learning rate per layer
lr: [0.1, 0.08, 0.06, 0.04, 0.02, 0.01, 0.01, 0.01, 0.01]

# whether to schedule per layer or in total
lr_same_pace: False

# project latents to unit ball
project: False
# project: True

# projections (decent results with false, toilsome to fine-tune)
do_project_latent: False
do_project_noises: False
do_project_gen_out: False

max_radius_latent: [300, 500, 1000, 2000, 4000, 8000, 8000, 8000, 8000]
max_radius_noises: [300, 2000, 2000, 4000, 6000, 8000, 8000, 8000, 8000]
max_radius_gen_out: [0, 500, 1000, 2000, 4000, 8000, 8000, 8000, 8000]
# note: first value of max_radius_gen_out is not used


# Loss parameters
loss_params:
## weights of different losses
geocross: 0.01
mse: [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
pe: [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
dead_zone_linear: [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
# tolerance of dead zone linear function
dead_zone_linear_alpha: 0.05
# LPIPS method
lpips_method: 'default'


logs:
# Save of logs
# if true, intermediate frames from optimization are saved.
save_gif: False
# determines how often we save intermediate frames in each steps. Activated only if save_gif=True.
save_every: 50

# Forward of generated images
# if true, save it
save_forward: True
# dir of forward save
forward_dir: ./output_forward/

2 changes: 2 additions & 0 deletions ilo_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dlib>==19.24.2
ninja==1.10.2.3
Loading