# Monodepth2 - Reimplement the code
Github: https://github.com/nianticlabs/monodepth2
## **Environment**
#### **Create and start the new conda enviroment**
```
$ conda create -n 3d_monodepth2 python=3.6
$ conda activate 3d_monodepth2
```
#### **Load package**
```
$ conda install pytorch=0.4.1 torchvision=0.2.1 -c pytorch
$ pip install tensorboardX==1.4
$ conda install opencv=3.3.1
$ pip install scikit-image
$ pip install ipython
```
---
## **Load Data**
#### Prepare dataset
Download dataset and put into the monodepth2 file
```
$ cd monodepth2
$ wget -i splits/kitti_archives_to_download.txt -P kitti_data/
```

#### **Unzip**
* All file unzip
```
$ cd kitti_data
$ unzip "*.zip"
$ cd ..
```
* Specific file unzip
###### unzip only image_02 &image_03
```
$ cd kitti_data
$ find . -type f -name '*.zip' -exec sh -c 'unzip "{}" "*/image_02/*" "*/image_03/*" -d "$(dirname "{}")"' \;
```

* image_02 : Left camera image
* image_03 : Light camera image
* image_02 & image_03 Same quantity
---
## **Train**
Paper defaults require that you have converted the **png image to jpeg** using this command, Alternatively you can **train from raw png files** by adding the **- -png** flag when training, at the cost of slower loading times.
```
$ python train.py --model_name mono+stereo_model --frame_ids 0 -1 1 --use_stereo --png
```
#### **Error**
TypeError: 'tuple' object is not callable

#### [**Solve the error**](https://github.com/search?q=repo%3Anianticlabs%2Fmonodepth2+TypeError%3A+%27tuple%27+object+is+not+callable&type=issues)
Into **mono_dataset.py** change the code
```
color_aug = transforms.ColorJitter(
self.brightness, self.contrast, self.saturation, self.hue)
```

#### **Sucessful**

---
## Pred depth image
```
$ python test_simple.py --image_path assets/1711.jpg --model_name weights_19
```
#### **Error**

#### **Solve the error**
If you use the default values, you can **find the trained weight files** in the **/tmp** folder.
1. Copy weight
> Copy weights to **home/cluster/monodepth2/models**

2. Add the name into code
>Add the weight file name to **test_simple.py*
>

#### **Sucessful**

###### input

###### output (our training weight)

###### output (paper training weight)
