-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for dataset with measured background and reconstruction appro…
…aches that use it (#142) * Now supports a dataset that also has background images * -Fixed PR -TODO: find alignement factor * Remove HFDataset inheritance from DualDataset. * Fix get item. * Update alignment parameters. * Reformat. * Add flag for direct background subtraction. * Add flag for learned background subtraction. * Fix missing default. * Add background subtraction network creation. * Add integrated subtraction, and concat background to UNetRes input. * Make background subtraction backward compatible. * Fix downsample factor. * Clamp image after subtraction. * Add option to remove background for benchmarking. * Add background support to benchmark/eval. * Update upload config. * Clamp after background subtraction. * Update changelog. --------- Co-authored-by: Eric Bezzam <[email protected]>
- Loading branch information
1 parent
96b292f
commit 3ea395f
Showing
24 changed files
with
1,125 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# python scripts/eval/benchmark_recon.py -cn benchmark_multilens_mirflickr_ambient | ||
defaults: | ||
- benchmark | ||
- _self_ | ||
|
||
dataset: HFDataset | ||
batchsize: 8 | ||
device: "cuda:0" | ||
|
||
huggingface: | ||
repo: Lensless/MultiLens-Mirflickr-Ambient | ||
cache_dir: /dev/shm | ||
psf: psf.png | ||
image_res: [600, 600] # used during measurement | ||
rotate: False # if measurement is upside-down | ||
alignment: | ||
top_left: [118, 220] # height, width | ||
height: 123 | ||
use_background: True | ||
|
||
## -- reconstructions trained with same dataset/system | ||
algorithms: [ | ||
"ADMM", | ||
"hf:multilens:mirflickr_ambient:U5+Unet8M", | ||
"hf:multilens:mirflickr_ambient:U5+Unet8M_direct_sub", | ||
"hf:multilens:mirflickr_ambient:U5+Unet8M_learned_sub", | ||
"hf:multilens:mirflickr_ambient:Unet4M+U5+Unet4M", | ||
"hf:multilens:mirflickr_ambient:Unet4M+U5+Unet4M_direct_sub", | ||
"hf:multilens:mirflickr_ambient:Unet4M+U5+Unet4M_learned_sub", | ||
"hf:multilens:mirflickr_ambient:Unet4M+U5+Unet4M_concat", | ||
"hf:multilens:mirflickr_ambient:TrainInv+Unet8M", | ||
"hf:multilens:mirflickr_ambient:TrainInv+Unet8M_learned_sub", | ||
"hf:multilens:mirflickr_ambient:Unet4M+TrainInv+Unet4M", | ||
"hf:multilens:mirflickr_ambient:Unet4M+TrainInv+Unet4M_learned_sub", | ||
"hf:multilens:mirflickr_ambient:Unet4M+TrainInv+Unet4M_concat", | ||
"hf:multilens:mirflickr_ambient:TrainInv+Unet8M_direct_sub", | ||
"hf:multilens:mirflickr_ambient:Unet4M+TrainInv+Unet4M_direct_sub", | ||
] | ||
|
||
save_idx: [ | ||
1, 2, 4, 5, 9, 64, # bottom right | ||
2141, 2155, 2162, 2225, 2502, 2602, # top right (door, flower, cookies, wolf, plush, sky) | ||
3262, 3304, 3438, 3451, 3644, 3667 # bottom left (pancakes, flower, grapes, pencils, bird, sign) | ||
] | ||
n_iter_range: [100] # for ADMM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# python scripts/recon/multilens_ambient_mirflickr.py | ||
defaults: | ||
- defaults_recon | ||
- _self_ | ||
|
||
cache_dir: /dev/shm | ||
|
||
## - Uncomment to reconstruct from dataset (screen capture) | ||
idx: 1 # index from test set to reconstruct | ||
fn: null # if not null, set local path or download this file from https://huggingface.co/datasets/Lensless/MultiLens-Mirflickr-Ambient/tree/main | ||
background_fn: null | ||
|
||
## - Uncomment to reconstruct plush parrot (direct capture) | ||
# fn: parrot_raw.png | ||
# background_fn: parrot_background.png | ||
# rotate: False | ||
# alignment: | ||
# dim: [160, 160] | ||
# top_left: [110, 200] | ||
|
||
## - Uncomment to reconstruct plush monkey (direct capture) | ||
# fn: monkey_raw.png | ||
# background_fn: monkey_background.png | ||
# rotate: False | ||
# alignment: | ||
# dim: [123, 123] | ||
# top_left: [118, 220] | ||
|
||
## - Uncomment to reconstruct plant (direct capture) | ||
# fn: plant_raw.png | ||
# background_fn: plant_background.png | ||
# rotate: False | ||
# alignment: | ||
# dim: [200, 200] | ||
# top_left: [60, 186] | ||
|
||
## Reconstruction | ||
background_sub: True # whether to subtract background | ||
|
||
# -- for learning-based methods (uncommment one line) | ||
model: Unet4M+U5+Unet4M_concat | ||
# model: U5+Unet8M | ||
# model: Unet4M+U5+Unet4M_learned_sub | ||
|
||
# # -- for ADMM with fixed parameters (uncomment and comment learning-based methods) | ||
# model: admm | ||
# n_iter: 100 | ||
|
||
device: cuda:0 | ||
n_trials: 1 # to get average inference time | ||
save: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# python scripts/recon/train_learning_based.py -cn train_mirflickr_multilens_ambient | ||
defaults: | ||
- train_mirflickr_tape | ||
- _self_ | ||
|
||
wandb_project: multilens_ambient | ||
|
||
# Dataset | ||
files: | ||
dataset: Lensless/MultiLens-Mirflickr-Ambient | ||
cache_dir: /dev/shm | ||
image_res: [600, 600] | ||
|
||
reconstruction: | ||
direct_background_subtraction: True | ||
|
||
alignment: | ||
# when there is no downsampling | ||
top_left: [118, 220] # height, width | ||
height: 123 | ||
|
||
optimizer: | ||
type: AdamW | ||
cosine_decay_warmup: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# python scripts/recon/train_learning_based.py -cn train_mirflickr_tape_ambient | ||
defaults: | ||
- train_mirflickr_tape | ||
- _self_ | ||
|
||
wandb_project: tapecam_ambient | ||
device_ids: | ||
|
||
# Dataset | ||
files: | ||
dataset: Lensless/TapeCam-Mirflickr-Ambient | ||
image_res: [600, 600] | ||
|
||
reconstruction: | ||
direct_background_subtraction: True | ||
|
||
alignment: | ||
# when there is no downsampling | ||
top_left: [85, 185] # height, width | ||
height: 178 | ||
|
||
optimizer: | ||
type: AdamW | ||
cosine_decay_warmup: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# python scripts/recon/train_learning_based.py -cn train_mirflickr_tape_ambient_integrated_sub | ||
defaults: | ||
- train_mirflickr_tape | ||
- _self_ | ||
|
||
wandb_project: tapecam_ambient | ||
device_ids: [0, 1, 2, 3] | ||
torch_device: cuda:0 | ||
|
||
# Dataset | ||
files: | ||
dataset: Lensless/TapeCam-Mirflickr-Ambient # 16K examples | ||
cache_dir: /dev/shm | ||
#dataset: Lensless/TapeCam-Mirflickr-Ambient-100 # 100 examples | ||
image_res: [600, 600] | ||
|
||
reconstruction: | ||
# one or the other | ||
direct_background_subtraction: False | ||
learned_background_subtraction: False | ||
integrated_background_subtraction: [32, 64, 128, 210, 210] | ||
down_subtraction: False | ||
pre_process: | ||
network: null # TODO assert null when integrated_background_subtraction is not False | ||
|
||
alignment: | ||
# when there is no downsampling | ||
top_left: [85, 185] # height, width | ||
height: 178 | ||
|
||
optimizer: | ||
type: AdamW | ||
cosine_decay_warmup: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# python scripts/recon/train_learning_based.py -cn train_mirflickr_tape_ambient_learned_sub | ||
defaults: | ||
- train_mirflickr_tape | ||
- _self_ | ||
|
||
wandb_project: tapecam_ambient | ||
device_ids: [0, 1 ,2, 3] | ||
torch_device: cuda:0 | ||
|
||
# Dataset | ||
files: | ||
#n_files: 10 | ||
dataset: Lensless/TapeCam-Mirflickr-Ambient # 16K examples | ||
#dataset: Lensless/TapeCam-Mirflickr-Ambient-100 # 100 examples | ||
cache_dir: /dev/shm | ||
image_res: [600, 600] | ||
|
||
reconstruction: | ||
# one or the other | ||
direct_background_subtraction: False | ||
learned_background_subtraction: [4, 8, 16, 32] # 127740 parameters, False to turn off | ||
integrated_background_subtraction: False | ||
|
||
pre_process: ## Targeting 3923428 parameters | ||
network : UnetRes # UnetRes or DruNet or null | ||
depth : 4 # depth of each up/downsampling layer. Ignore if network is DruNet | ||
nc: [32,64,112,128] | ||
|
||
alignment: | ||
# when there is no downsampling | ||
top_left: [85, 185] # height, width | ||
height: 178 | ||
|
||
optimizer: | ||
type: AdamW | ||
cosine_decay_warmup: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.