README.md 5.28 KB
Newer Older
1
2
3
![TensorFlow Requirement: 1.x](https://img.shields.io/badge/TensorFlow%20Requirement-1.x-brightgreen)
![TensorFlow 2 Not Supported](https://img.shields.io/badge/TensorFlow%202%20Not%20Supported-%E2%9C%95-red.svg)

Reza Mahjourian's avatar
Reza Mahjourian committed
4
5
6
7
8
9
10
11
# vid2depth

**Unsupervised Learning of Depth and Ego-Motion from Monocular Video Using 3D Geometric Constraints**

Reza Mahjourian, Martin Wicke, Anelia Angelova

CVPR 2018

Reza Mahjourian's avatar
Reza Mahjourian committed
12
Project website: [https://sites.google.com/view/vid2depth](https://sites.google.com/view/vid2depth)
Reza Mahjourian's avatar
Reza Mahjourian committed
13

Reza Mahjourian's avatar
Reza Mahjourian committed
14
ArXiv: [https://arxiv.org/pdf/1802.05522.pdf](https://arxiv.org/pdf/1802.05522.pdf)
Reza Mahjourian's avatar
Reza Mahjourian committed
15
16

<p align="center">
Reza Mahjourian's avatar
Reza Mahjourian committed
17
<a href="https://sites.google.com/view/vid2depth"><img src='https://storage.googleapis.com/vid2depth/media/sample_video_small.gif'></a>
Reza Mahjourian's avatar
Reza Mahjourian committed
18
19
20
</p>

<p align="center">
Reza Mahjourian's avatar
Reza Mahjourian committed
21
<a href="https://sites.google.com/view/vid2depth"><img src='https://storage.googleapis.com/vid2depth/media/approach.png' width=400></a>
Reza Mahjourian's avatar
Reza Mahjourian committed
22
23
</p>

24
25
26
27
28
## Update: TF2 version.

Please see [https://github.com/IAMAl/vid2depth_tf2](https://github.com/IAMAl/vid2depth_tf2)
for a TF2 implementation of vid2depth.

Reza Mahjourian's avatar
Reza Mahjourian committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
## 1. Installation

### Requirements

#### Python Packages

```shell
mkvirtualenv venv  # Optionally create a virtual environment.
pip install absl-py
pip install matplotlib
pip install numpy
pip install scipy
pip install tensorflow
```

### Download vid2depth

```shell
git clone --depth 1 https://github.com/tensorflow/models.git
```

## 2. Datasets

### Download KITTI dataset (174GB)

```shell
mkdir -p ~/vid2depth/kitti-raw-uncompressed
cd ~/vid2depth/kitti-raw-uncompressed
57
wget https://raw.githubusercontent.com/mrharicot/monodepth/master/utils/kitti_archives_to_download.txt
Reza Mahjourian's avatar
Reza Mahjourian committed
58
59
60
61
62
63
wget -i kitti_archives_to_download.txt
unzip "*.zip"
```

### Download Cityscapes dataset (110GB) (optional)

64
65
You will need to register in order to download the data.  Download the following
files:
Reza Mahjourian's avatar
Reza Mahjourian committed
66
67
68
69

* leftImg8bit_sequence_trainvaltest.zip
* camera_trainvaltest.zip

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
### Download Bike dataset (34GB) (optional)

Please see [https://research.google/tools/datasets/bike-video/](https://research.google/tools/datasets/bike-video/)
for info on the bike video dataset.

Special thanks to [Guangming Wang](https://guangmingw.github.io/) for helping us
restore this dataset after it was accidentally deleted.

```shell
mkdir -p ~/vid2depth/bike-uncompressed
cd ~/vid2depth/bike-uncompressed
wget https://storage.googleapis.com/vid2depth/dataset/BikeVideoDataset.tar
tar xvf BikeVideoDataset.tar
```

Reza Mahjourian's avatar
Reza Mahjourian committed
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
## 3. Inference

### Download trained model

```shell
mkdir -p ~/vid2depth/trained-model
cd ~/vid2depth/trained-model
wget https://storage.cloud.google.com/vid2depth/model/model-119496.zip
unzip model-119496.zip
```

### Run inference

```shell
cd tensorflow/models/research/vid2depth
python inference.py \
  --kitti_dir ~/vid2depth/kitti-raw-uncompressed \
  --output_dir ~/vid2depth/inference \
Burak's avatar
Burak committed
103
  --kitti_video 2011_09_26/2011_09_26_drive_0009_sync \
Reza Mahjourian's avatar
Reza Mahjourian committed
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
  --model_ckpt ~/vid2depth/trained-model/model-119496
```

## 4. Training

### Prepare KITTI training sequences

```shell
# Prepare training sequences.
cd tensorflow/models/research/vid2depth
python dataset/gen_data.py \
  --dataset_name kitti_raw_eigen \
  --dataset_dir ~/vid2depth/kitti-raw-uncompressed \
  --data_dir ~/vid2depth/data/kitti_raw_eigen \
  --seq_length 3
```

### Prepare Cityscapes training sequences (optional)

```shell
# Prepare training sequences.
cd tensorflow/models/research/vid2depth
python dataset/gen_data.py \
  --dataset_name cityscapes \
  --dataset_dir ~/vid2depth/cityscapes-uncompressed \
  --data_dir ~/vid2depth/data/cityscapes \
  --seq_length 3
```

133
### Prepare Bike training sequences (optional)
Reza Mahjourian's avatar
Reza Mahjourian committed
134
135

```shell
136
# Prepare training sequences.
Reza Mahjourian's avatar
Reza Mahjourian committed
137
cd tensorflow/models/research/vid2depth
138
139
140
141
142
python dataset/gen_data.py \
  --dataset_name bike \
  --dataset_dir ~/vid2depth/bike-uncompressed \
  --data_dir ~/vid2depth/data/bike \
  --seq_length 3
Reza Mahjourian's avatar
Reza Mahjourian committed
143
144
```

145
146
147
148
149
150
151
152
153
154
### Compile the ICP op

The pre-trained model is trained using the ICP loss.  It is possible to run
inference on this pre-trained model without compiling the ICP op.  It is also
possible to train a new model from scratch without compiling the ICP op by
setting the icp loss to zero.

If you would like to compile the op and run a new training job using it, please
use the CMakeLists.txt file at
[https://github.com/IAMAl/vid2depth_tf2/tree/master/ops](https://github.com/IAMAl/vid2depth_tf2/tree/master/ops).
Reza Mahjourian's avatar
Reza Mahjourian committed
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191

### Run training

```shell
# Train
cd tensorflow/models/research/vid2depth
python train.py \
  --data_dir ~/vid2depth/data/kitti_raw_eigen \
  --seq_length 3 \
  --reconstr_weight 0.85 \
  --smooth_weight 0.05 \
  --ssim_weight 0.15 \
  --icp_weight 0 \
  --checkpoint_dir ~/vid2depth/checkpoints
```

## Reference
If you find our work useful in your research please consider citing our paper:

```
@inproceedings{mahjourian2018unsupervised,
  title={Unsupervised Learning of Depth and Ego-Motion from Monocular Video Using 3D Geometric Constraints},
    author={Mahjourian, Reza and Wicke, Martin and Angelova, Anelia},
    booktitle = {CVPR},
    year={2018}
}
```

## Contact

To ask questions or report issues please open an issue on the tensorflow/models
[issues tracker](https://github.com/tensorflow/models/issues). Please assign
issues to [@rezama](https://github.com/rezama).

## Credits

This implementation is derived from [SfMLearner](https://github.com/tinghuiz/SfMLearner) by [Tinghui Zhou](https://github.com/tinghuiz).