We provide here the code to reproduce the results reported in
JFJP Abascal, T Baudier, R Phan, A Repetti, N Ducros, "SPyRiT: an open source package for single-pixel imaging based on deep learning," Preprint (2024).
Preprint view (main PDF + supplemental document): https://hal.science/hal-04662876
Preprint download (main PDF): https://hal.science/hal-04662876/document
Contact: [email protected], CREATIS Laboratory, University of Lyon, France.
There are two options:
-
Clone the entire
spyrit-examples
repository, which contains code for some other papers.git clone https://github.com/openspyrit/spyrit-examples.git
-
Or use the
sparse-checkout
command to get only the code corresponding to this paper.git clone -n --depth=1 --filter=tree:0 https://github.com/openspyrit/spyrit-examples cd spyrit-examples git sparse-checkout set 2024_spyrit git checkout
-
Create a conda environment
conda create --name spyrit_2024 conda activate spyrit_2024
-
Install pytorch using conda. E.g.,
conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia
Visit https://pytorch.org/get-started/locally/ if you need a different installation.
-
Install SPyRiT and a few more packages (until release of v3, checkout the
spyrit_dev
branch):pip install spyrit pip install girder-client pip install scikit-image
Run the download_data.py
script from the 2024_spyrit
subfolder
cd spyrit-examples/2024_spyrit/
python download_data.py
The ImageNet (ILSVRC2012) test and validation sets can be downloaded from this url. They must saved in ./data/ILSVRC2012/test/all
and ./data/ILSVRC2012/val/all
.
If the images are already available on your computer, just create a symbolic link
-
Linux:
ln -s <imagenet folder> /data/ILSVRC2012/
-
Windows Powershell (run as Administrator):
New-Item -ItemType SymbolicLink -Name \data\ILSVRC2012\ -Target <imagenet folder>
The directory structure should be as follows:
|---spyrit-examples
| |---2024_spyrit
| | |---data
| | | |---ILSVRC2012
| | | | |---test
| | | | | |---all
| | | | | | |---ILSVRC2012_test_00000001.JPEG
| | | | | | |---
| | | | |---val
| | | | | |---all
| | | | | | |---ILSVRC2012_val_00000001.JPEG
| | | | | | |---
| | | |---tomato_slice_2_zoomx2_spectraldata.npz
| | | |---images
| | | |---
| | |---model
| | | |---
| | |---stat
| | | |---
| | |---recon
| | | |---
| | |---aux_functions.py
| | |---download_data.py
| | |---figure_2.py
| | |---figure_3.py
| | |---figure_4.py
| | |---supplemental_figure_S1.py
| | |---
| | |---table_1.py
| | |---train.py
| | |---utility_dpgd.py
-
To reproduce the sampling masks, acquisition matrices, measurements, and images in Figure 2, run
figure_2.py
. -
To reproduce the reconstructions in Figures 3 and 4, run
figure_3.py
andfigure_4.py
, respectively. All images will be saved in\2024_spyrit\recon\
-
Run
table_1.py
to reproduce the metrics in Table 1. -
Run
supplemental_figure_Sxx.py
forxx
in{1, ..., 8}
to reproduce all the figures in the supplemental document.