Skip to content

Commit

Permalink
Merge branch 'main' into measured_ambient
Browse files Browse the repository at this point in the history
  • Loading branch information
ebezzam committed Aug 22, 2024
2 parents 224d8d3 + 96b292f commit 1419484
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Changed
Bugfix
~~~~~~

- Wavelength input to ``compute_psf`` for Mask class.
- Computation of average metric in batches.
- Support for grayscale PSF for RealFFTConvolve2D.
- Calling model.eval() before inference, and model.train() before training.
Expand Down
2 changes: 1 addition & 1 deletion configs/analyze_dataset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ hydra:
chdir: True # change to output folder

dataset_path: null
desired_range: [150, 255]
desired_range: [10, 255]
saturation_percent: 0.05
delete_bad: False
n_files: null
Expand Down
20 changes: 20 additions & 0 deletions configs/upload_multilens_mirflickr_ambient.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# python scripts/data/upload_dataset_huggingface.py -cn upload_multilens_mirflickr_ambient
defaults:
- upload_dataset_huggingface
- _self_

repo_id: "Lensless/MultiLens-Mirflickr-Ambient"
n_files:
test_size: 0.15
lensless:
dir: /dev/shm/all_measured_20240813-183259
ambient: True
ext: ".png"

lensed:
dir: data/mirflickr/mirflickr
ext: ".jpg"

files:
psf: data/multilens_psf.png
measurement_config: data/collect_dataset_background_multilens.yaml
7 changes: 4 additions & 3 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ where the programmable is a low-cost LCD:
- `DigiCam: Single-Shot Lensless Sensing with a Low-Cost Programmable Mask <https://colab.research.google.com/drive/1t59uyZMMyCUYVHGXdqdlNlDlb--FL_3P#scrollTo=t9o50zTf3oUg>`__
- `Towards Scalable and Secure Lensless Imaging with a Programmable Mask <https://colab.research.google.com/drive/1YGfs9p4T4NefX8GemVWwtrw4aX8zH1qu#scrollTo=tipedTe4vGwD>`__

Reconstruction method
Reconstruction
---------------------

Learning-based reconstruction methods:

- `A Modular and Robust Physics-Based Approach for Lensless Image Reconstruction <https://colab.research.google.com/drive/1Wgt6ZMRZVuctLHaXxk7PEyPaBaUPvU33>`__
- `Aligning images for training <https://colab.research.google.com/drive/1c6kUbiB5JO1vro0-IMd-YDDP1g7NFXv3#scrollTo=MtN7GWCIrBKr>`__
- `Aligning images for training & background subtraction demo <https://drive.google.com/file/d/1oWy07xT_5-_Xki6g9TbOiBcxDv0bN-96/view?usp=drive_link>`__
- `Aligning images for training (DigiCam) <https://colab.research.google.com/drive/1c6kUbiB5JO1vro0-IMd-YDDP1g7NFXv3#scrollTo=MtN7GWCIrBKr>`__

Mask Design and fabrication
Mask Design and Fabrication
---------------------------

- `Multi-lens array design <https://drive.google.com/file/d/1IIGjdPUD5qqq4kWjDp50OWnIvHPVdvmp/view?usp=sharing>`__
Expand Down
2 changes: 1 addition & 1 deletion lensless/hardware/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def compute_psf(self, distance_sensor=None, wavelength=None, intensity=True):

if self.use_torch:
psf = torch.zeros(
tuple(self.resolution) + (len(self.psf_wavelength),),
tuple(self.resolution) + (len(wavelength),),
dtype=torch.complex64,
device=self.torch_device,
)
Expand Down
27 changes: 26 additions & 1 deletion scripts/measure/analyze_measured_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Check maximum pixel value of images and check for saturation / underexposure.
```
python scripts/measure/analyze_measured_dataset.py folder=PATH
python scripts/measure/analyze_measured_dataset.py dataset_path=PATH
```
"""

Expand Down Expand Up @@ -123,6 +123,31 @@ def analyze_dataset(config):
else:
print("Not deleting bad files")

# check for matching background file
files_bg = natural_sort(glob.glob(os.path.join(folder, "black_background*.png")))
# -- remove files_bg from files
files = [fn for fn in files if fn not in files_bg]

if len(files_bg) > 0:
print("Found {} background files".format(len(files_bg)))
# detect files that don't have background
files_no_bg = []
for fn in files:
bn = os.path.basename(fn).split(".")[0]
_bg_file = os.path.join(folder, "black_background{}.png".format(bn))
if _bg_file not in files_bg:
files_no_bg.append(fn)

print("Found {} files without background".format(len(files_no_bg)))
# ask to delete files without background
response = None
while response not in ["yes", "no"]:
response = input("Delete files without background: [yes|no] : ")
if response == "yes":
for _fn in files_no_bg:
if os.path.exists(_fn): # maybe already deleted before
os.remove(_fn)


if __name__ == "__main__":
analyze_dataset()

0 comments on commit 1419484

Please sign in to comment.