[Installation](#installation) | [Configuration](#configuration) | [Datasets](#datasets) | [Visualization](#visualization) | [Publications](#publications) | [License](#license)
Official [PyTorch](https://pytorch.org/) repository for some of TRI's latest publications, including self-supervised learning, multi-view geometry, and depth estimation.
Our goal is to provide a clean environment to reproduce our results and facilitate further research in this field.
This repository is an updated version of [PackNet-SfM](https://github.com/TRI-ML/packnet-sfm), our previous monocular depth estimation repository, featuring a different license.
## Models
(Experimental) For convenient inference, we provide a growing list of our models (ZeroDepth, PackNet, DeFiNe) model over torchhub without installation.
### (New!) ZeroDepth
```python
import torch
zerodepth_model = torch.hub.load("TRI-ML/vidar", "ZeroDepth", pretrained=True, trust_repo=True)
intrinsics = torch.tensor(np.load('examples/ddad_intrinsics.npy')).unsqueeze(0)
rgb = torch.tensor(imread('examples/ddad_sample.png')).permute(2,0,1).unsqueeze(0)/255.
depth_pred = zerodepth_model(rgb, intrinsics)
```
### PackNet
PackNet is a self-supervised monocular depth estimation model, to load a model trained on KITTI and run inference on an RGB image:
```python
import torch
packnet_model = torch.hub.load("TRI-ML/vidar", "PackNet", pretrained=True, trust_repo=True)
rgb = torch.tensor(imread('examples/ddad_sample.png')).permute(2,0,1).unsqueeze(0)/255.
depth_pred = model(rgb_image)
```
### DeFiNe
DeFiNe is a multi-view depth estimation model, to load a model trained on Scannet and run inference on multiple posed RGB images:
```python
import torch
define_model = torch.hub.load("TRI-ML/vidar", "DeFiNe", pretrained=True, trust_repo=True)
frames = {}
frames["rgb"] = # a list of frames as 13HW torch.tensors
frames["intrinsics"] = # a list of 133 torch.tensor intrinsics matrices (one for each image)
frames["pose"] = # a batch of 144 relative poses to reference frame (one will be identity)
depth_preds = define_model(frames) # list of depths, one for each frame
```
## Installation
We recommend using our provided dockerfile (see [nvidia-docker2](https://github.com/NVIDIA/nvidia-docker) instructions) to have a reproducible environment.
To set up the repository, type in a terminal (only tested in Ubuntu 18.04):
```bash
git clone --recurse-submodules https://github.com/TRI-ML/vidar.git # Clone repository with submodules
cd vidar # Move to repository folder
make docker-build # Build the docker image (recommended)
```
To start our docker container, simply type `make docker-interactive`. From inside the docker, you can run scripts with the following command pattern:
```bash
python scripts/launch.py
If you want to use features related to [AWS](https://aws.amazon.com/) (for dataset access) and [WandB](https://www.wandb.com/) (for experiment management), you can create associated accounts and configure your shell with the following environment variables:
```bash
export AWS_SECRET_ACCESS_KEY=something # AWS secret key
export AWS_ACCESS_KEY_ID=something # AWS access key
export AWS_DEFAULT_REGION=something # AWS default region
export WANDB_ENTITY=something # WANDB entity
export WANDB_API_KEY=something # WANDB API key
```
## Configuration
Configuration files (stored in the `configs` folder) are the entry points for training and inference.
The basic structure of a configuration file is:
```bash
wrapper: # Training parameters
## Publications
### [3D Packing for Self-Supervised Monocular Depth Estimation](https://arxiv.org/abs/1905.02693) (CVPR 2020, oral)
Vitor Guizilini, Rares Ambrus, Sudeep Pillai, Allan Raventos, Adrien Gaidon
**Abstract:** *Although cameras are ubiquitous, robotic platforms typically rely on active sensors like LiDAR for direct 3D perception.
In this work, we propose a novel self-supervised monocular depth estimation method combining geometry with a new deep network, PackNet, learned only from unlabeled monocular videos.
Our architecture leverages novel symmetrical packing and unpacking blocks to jointly learn to compress and decompress detail-preserving representations using 3D convolutions.
Although self-supervised, our method outperforms other self, semi, and fully supervised methods on the KITTI benchmark.
The 3D inductive bias in PackNet enables it to scale with input resolution and number of parameters without overfitting, generalizing better on out-of-domain data such as the NuScenes dataset.
Furthermore, it does not require large-scale supervised pretraining on ImageNet and can run in real-time.
Finally, we release DDAD (Dense Depth for Automated Driving), a new urban driving dataset with more challenging and accurate depth evaluation, thanks to longer-range and denser ground-truth depth generated from high-density LiDARs mounted on a fleet of self-driving cars operating world-wide.*
| GT depth | Abs.Rel. | Sq.Rel. | RMSE | RMSElog | SILog | d1.25 | d1.252 | d1.253 |
| ResNet18 | Self-Supervised | 192x640 | ImageNet → KITTI | ||||||||
| Original | 0.116 | 0.811 | 4.902 | 0.198 | 19.259 | 0.865 | 0.957 | 0.981 |
| Improved | 0.087 | 0.471 | 3.947 | 0.135 | 12.879 | 0.913 | 0.983 | 0.996 |
| PackNet | Self-Supervised | 192x640 | KITTI | ||||||||
| Original | 0.111 | 0.800 | 4.576 | 0.189 | 18.504 | 0.880 | 0.960 | 0.982 |
| Improved | 0.078 | 0.420 | 3.485 | 0.121 | 11.725 | 0.931 | 0.986 | 0.996 |
| GT depth | Frames | Abs.Rel. | Sq.Rel. | RMSE | RMSElog | SILog | d1.25 | d1.252 | d1.253 |
| DepthFormer | Self-Supervised | 192x640 | ImageNet → KITTI | |||||||||
| Original | Single (t) | 0.117 | 0.876 | 4.692 | 0.193 | 18.940 | 0.874 | 0.960 | 0.981 |
| Multi (t-1,t) | 0.090 | 0.661 | 4.149 | 0.175 | 17.260 | 0.905 | 0.963 | 0.982 | |
| Improved | Single (t) | 0.083 | 0.464 | 3.591 | 0.126 | 12.156 | 0.926 | 0.986 | 0.996 |
| Multi (t-1,t) | 0.055 | 0.271 | 2.917 | 0.095 | 9.160 | 0.955 | 0.991 | 0.998 | |
| Camera | Abs.Rel. | Sq.Rel. | RMSE | RMSElog | SILog | d1.25 | d1.252 | d1.253 |
| FSM | Self-Supervised | 384x640 | ImageNet → DDAD | ||||||||
| Front | 0.131 | 2.940 | 14.252 | 0.237 | 22.226 | 0.824 | 0.935 | 0.969 |
| Front Right | 0.205 | 3.349 | 13.677 | 0.353 | 30.777 | 0.667 | 0.852 | 0.922 |
| Back Right | 0.243 | 3.493 | 12.266 | 0.394 | 33.842 | 0.594 | 0.821 | 0.907 |
| Back | 0.194 | 3.743 | 16.436 | 0.348 | 29.901 | 0.669 | 0.850 | 0.926 |
| Back Left | 0.235 | 3.641 | 13.570 | 0.387 | 31.765 | 0.594 | 0.816 | 0.907 |
| Front Left | 0.226 | 3.861 | 12.957 | 0.378 | 32.795 | 0.652 | 0.836 | 0.909 |