Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ruixv committed Nov 23, 2021
0 parents commit 2018f57
Show file tree
Hide file tree
Showing 127 changed files with 3,694 additions and 0 deletions.
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2020

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file added pic/NLOS-OT.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pic/generalization.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pic/generalization_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pic/problem_statement.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pic/results_specific.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
192 changes: 192 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# NLOS-OT

Official implementation of NLOS-OT: Passive Non-Line-of-Sight Imaging Using Optimal Transport (IEEE TIP, accepted)

> Ruixu Geng, Yang Hu, Zhi Lu, Cong Yu, Houqiang Li, Hengyu Zhang and Yan Chen, “Passive Non-Line-of-Sight Imaging Using Optimal Transport,” IEEE Transactions on Image Processing, 2021
```
@article{nlosot,
title = {Passive Non-Line-of-Sight Imaging Using Optimal Transport},
journal = {IEEE Transactions on Image Processing},
author = {Geng, Ruixu and Hu, Yang and Lu, Zhi and Yu, Cong and Li, Houqiang and Zhang, Hengyu and Chen, Yan},
year = {2021}
}
```

## Description

In this repository, we release the ``NLOS-OT`` code in Pytorch as well as the passive NLOS imaging dataset ``NLOS-Passive``.

- Problem statement: Passive NLOS imaging
<p align="center"><img width="90%" src="pic/problem_statement.jpg" /></p>

- NLOS-OT architecture
<p align="center"><img width="90%" src="pic/NLOS-OT.jpg" /></p>

- The reconstruction results of NLOS-OT trained by specific dataset without partial occluder
<p align="center"><img width="90%" src="pic/results_specific.jpg" /></p>

- The generalization results of NLOS-OT trained by dataset only from [STL-10](https://cs.stanford.edu/~acoates/stl10/) with unknown partial occluder
<p align="center"><img width="90%" src="pic/generalization.jpg" /></p>
<p align="center"><img width="90%" src="pic/generalization_2.jpg" /></p>

## Installation

1. install required packages

2. clone the repo


## Prepare Data

1. Download dataset

You can download each group in NLOS-Passive through the link below. Please note that a compressed package (.zip or .z01+.zip) represents a group of measured data.

link:https://pan.baidu.com/s/19Q48BWm1aJQhIt6BF9z-uQ

code:j3p2

If the link fails, please feel free to contact me.

> In the following content, we will take the partially occluded dataset on STL-10 (i.e., NLOS_Passive/STL-10/stl10_dark_1_d100_occluder.zip) as an example to illustrate the training and testing process. The dataset also contains test data from other data (MNIST, supermodel faces and real scenes), which can be used to evaluate the generalization ability of NLOS-OT.
>> Similarly, you can also use other datasets to complete training and testing according to the content below.
2. Organize the files structure of the dataset

+ Unzip the dataset

The size of a group projection dataset on STL-10 is about 30GB, which exceeds the maximum limit of Baiduyun. Therefore, we divided each group of data into two compressed packages (.z01 and .zip). You can decompress with

```bash
cd /pathtodataset/
zip -s 0 stl10_dark_1_d100_occluder.zip --out stl10_dark_1_d100_occluder_single.zip
unzip stl10_dark_1_d100_occluder_single.zip
# delete temp zip
rm -rf ./stl10_dark_1_d100_occluder_single.zip
# rename the folder
mkdir ./C_dark_1_d100_occluder/
mv ./pro ./C_dark_1_d100_occluder/train
```

The GT folder can be obtained by
```bash
# Download gt zip. e.g., GT_stl10_allimages.zip
# unzip and rename
unzip GT_stl10_allimages.zip
```

+ Organize the dataset (rename and move)

We recommend organizing the data files according to the following structure:

```
.
├── B
│   └── train
│   └── 1.png
│   ...
├── C_dark_1_d100_wall
│   └── train
│   └── 1.png
│   ...
├── C_dark_2_d100_wall
│   └── train
│   └── 1.png
│   ...
└── test
├── C_dark_1_d100_wall_test
│   └── 2.png
│   ...
├── C_dark_1_d100_wall_val
│   └── 3.png
│   ...
├── C_dark_2_d100_wall_test
│   └── 2.png
│   ...
├── C_dark_2_d100_wall_val
│   └── 3.png
│   ...
├── gt_test
│   └── 2.png
│   ...
└── gt_val
    └── 3.png
   ...
```

In our paper, we organize the data files using the following commands:

+ For STL-10 (including real-world images)

+ For supermodel faces

```bash
# gt

# projection images
mkdir ./test/C_dark_1_d100_wall_test
mkdir ./test/C_dark_1_d100_wall_val

mv ./C_dark_1_d100_wall/train/5* ./test/C_dark_1_d100_wall_val

mv ./test/C_dark_1_d100_wall_val/51* ./test/C_dark_1_d100_wall_test
mv ./test/C_dark_1_d100_wall_val/55* ./test/C_dark_1_d100_wall_test
mv ./test/C_dark_1_d100_wall_val/59* ./test/C_dark_1_d100_wall_test
```

The above structure can be applied to the training command we provided. You can also customize your own file structure and modify the corresponding parameters (--datarootTarget, --datarootData, --datarootValTarget, --datarootValData) in the command.

## Demo / Evaluate

Before that, you should have installed the required packages and organized the data set according to the appropriate file structure.

1. Download pretrained pth

2. run the test.py


## Train

Before that, you should have installed the required packages and organized the data set according to the appropriate file structure.


## Citation
- Feel free to use the dataset / code, but please cite:

- Ruixu Geng, Yang Hu, Zhi Lu, Cong Yu, Houqiang Li, Hengyu Zhang and Yan Chen, “Passive Non-Line-of-Sight Imaging Using Optimal Transport,” IEEE Transactions on Image Processing, 2021

```
@article{nlosot,
title = {Passive Non-Line-of-Sight Imaging Using Optimal Transport},
journal = {IEEE Transactions on Image Processing},
author = {Geng, Ruixu and Hu, Yang and Lu, Zhi and Yu, Cong and Li, Houqiang and Zhang, Hengyu and Chen, Yan},
year = {2021}
}
```

- You may also be interested in our review article:

- Ruixu Geng, Yang Hu, and Yan Chen, “Recent Advances on Non-Line-of-Sight Imaging: Conventional Physical Models, Deep Learning, and New Scenes,” APSIPA Transactions on Signal and Information Processing, 2021


If you think it is helpful, please consider citing

```
@article{RecentAdvancesNLOS,
author = {Geng, Ruixu and Hu, Yang and Chen, Yan},
title = {Recent Advances on Non-Line-of-Sight Imaging: Conventional Physical Models, Deep Learning, and New Scenes},
journal = {APSIPA Transactions on Signal and Information Processing},
year = {2021}
}
```


- We thank the following great works:

- [DeblurGAN](https://github.com/KupynOrest/DeblurGAN), [pix2pix](https://github.com/phillipi/pix2pix): Our code is based on the framework provided by the two repos.

- [IntroVAE](https://proceedings.neurips.cc/paper/2018/hash/093f65e080a295f8076b1c5722a46aa2-Abstract.html): The encoder and decoder in NLOS-OT are based on IntroVAE.

- [AE-OT](https://openreview.net/forum?id=HkldyTNYwH), [AEOT-GAN](https://arxiv.org/abs/2001.03698): The idea of using OT to complete passive NLOS imaging tasks in NLOS-OT comes from the two works.
1 change: 1 addition & 0 deletions step1/INstructor.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conda activate pytorch17; CUDA_VISIBLE_DEVICES=7 pytnon train.py --datarootTarget '/share2/data/AONLOS/STL10/B/' --datarootData '/share2/data/AONLOS/STL10/B/' --datarootValTarget '/share2/data/AONLOS/STL10/test/gt_val/' --datarootValData '/share2/data/AONLOS/STL10/test/gt_val/' --learn_residual --gpu_ids='0' --batchSize=16 --name='NEWRight_transformer_stl10_batch_Tanh' --niter=100 --niter_decay=300 --which_model_netG transformer --display_port=9099 --norm 'batch'
58 changes: 58 additions & 0 deletions step1/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Copyright (c) 2017, Jun-Yan Zhu and Taesung Park
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------- LICENSE FOR pix2pix --------------------------------
BSD License

For pix2pix software
Copyright (c) 2016, Phillip Isola and Jun-Yan Zhu
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

----------------------------- LICENSE FOR DCGAN --------------------------------
BSD License

For dcgan.torch software

Copyright (c) 2015, Facebook, Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name Facebook nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Empty file added step1/data/__init__.py
Empty file.
Binary file added step1/data/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file not shown.
Binary file added step1/data/__pycache__/base_dataset.cpython-36.pyc
Binary file not shown.
Binary file not shown.
Binary file added step1/data/__pycache__/data_loader.cpython-36.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions step1/data/base_data_loader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

class BaseDataLoader():
def __init__(self):
pass

def initialize(self, opt):
self.opt = opt
pass

def load_data():
return None



15 changes: 15 additions & 0 deletions step1/data/base_dataset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import torch.utils.data as data
from PIL import Image
import torchvision.transforms as transforms
import pdb

class BaseDataset(data.Dataset):
def __init__(self):
super(BaseDataset, self).__init__()

def name(self):
return 'BaseDataset'

def initialize(self, opt):
pass

37 changes: 37 additions & 0 deletions step1/data/custom_dataset_data_loader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import torch.utils.data
from data.base_data_loader import BaseDataLoader
import pdb

def CreateDataset(opt):
dataset = None
if opt.dataset_mode == 'single': # yes
from data.single_dataset import SingleDataset
dataset = SingleDataset()
elif (opt.dataset_mode == 'aligned') or (opt.dataset_mode == 'aligned'):
raise ValueError('In NLOS-OT, we only support dataset in single mode.')
else:
raise ValueError("Dataset [%s] not recognized." % opt.dataset_mode)

print("dataset [%s] was created" % (dataset.name()))
dataset.initialize(opt)
return dataset


class CustomDatasetDataLoader(BaseDataLoader):
def name(self):
return 'CustomDatasetDataLoader'

def initialize(self, opt):
BaseDataLoader.initialize(self, opt)
self.dataset = CreateDataset(opt)
self.dataloader = torch.utils.data.DataLoader(
self.dataset,
batch_size=opt.batchSize,
shuffle=not opt.serial_batches,
num_workers=int(opt.nThreads))

def load_data(self):
return self.dataloader

def __len__(self):
return min(len(self.dataset), self.opt.max_dataset_size)
7 changes: 7 additions & 0 deletions step1/data/data_loader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

def CreateDataLoader(opt):
from data.custom_dataset_data_loader import CustomDatasetDataLoader
data_loader = CustomDatasetDataLoader()
print(data_loader.name())
data_loader.initialize(opt)
return data_loader
Loading

0 comments on commit 2018f57

Please sign in to comment.