Skip to content

Commit

Permalink
add comments for configs
Browse files Browse the repository at this point in the history
  • Loading branch information
AshkanGanj committed Jul 24, 2024
1 parent 246f8c9 commit f883e32
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 43 deletions.
43 changes: 27 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
<a href=''><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-yellow'></a>
</div>


This work presents HybridDepth. HybridDepth is a practical depth estimation solution based on focal stack images captured from a camera. This approach outperforms state-of-the-art models across several well-known datasets, including NYU V2, DDFF12, and ARKitScenes.
![teaser](assets/teaser.png)


## News

- **2024-07-23:** Model and Github repository is online.

## TODOs

- [ ] Add pre-trained models.
- [ ] Add Hugging Face model.
- [ ] Release Android Mobile Client for HybridDepth.
Expand Down Expand Up @@ -47,6 +47,7 @@ conda activate hybriddepth
Download the checkpoints listed [here](#pre-trained-models) and put them under the `checkpoints` directory.

### Using HybridDepth model for prediction

For inference you can run the provided notebook `test.ipynb` or use the following command:

```python
Expand All @@ -62,7 +63,6 @@ model = model.to('cuda')

After loading the model, you can use the following code to process the input images and get the depth map:


```python

from utils.io import prepare_input_image
Expand All @@ -85,13 +85,12 @@ First setup the configuration file `config.yaml` in the `configs` directory. We

```yaml
data:
class_path: dataloader.dataset.NYUDataModule
class_path: dataloader.dataset.NYUDataModule # Path to your dataloader Module in dataset.py
init_args:
nyuv2_data_root: 'path to the NYUv2 dataset'
img_size: [480, 640] # Adjust if your NYUDataModule expects a tuple for img_size
nyuv2_data_root: 'path to the NYUv2 dataset' # path to the specific dataset
img_size: [480, 640] # Adjust if your DataModule expects a tuple for img_size
remove_white_border: True
batch_size: 1
num_workers: 0 # due to the synthetic data, we don't need multiple workers
num_workers: 0 # if you are using synthetic data, you don't need multiple workers
use_labels: True
num_cluster: 5

Expand All @@ -100,7 +99,14 @@ model:

ckpt_path: checkpoints/hybrid_depth_nyu.pth
```
Then specify the configuration file in the `evaluate.sh` script. Finally, run the following command:
Then specify the configuration file in the `test.sh` script.

```bash
python cli_run.py test --config configs/config_file_name.yaml
```

Finally, run the following command:

```bash
cd scripts
Expand All @@ -117,25 +123,30 @@ For example, you can use the following configuration file for training on the NY
model:
invert_depth: True
# learning rate
lr: 3e-4
lr: 3e-4 # you can adjust this value
# weight decay
wd: 0.001
wd: 0.001 # you can adjust this value
data:
class_path: dataloader.dataset.NYUDataModule
class_path: dataloader.dataset.NYUDataModule # Path to your dataloader Module in dataset.py
init_args:
nyuv2_data_root: 'root to the NYUv2 dataset'
nyuv2_data_root: 'root to the NYUv2 dataset' # path to the specific dataset
img_size: [480, 640] # Adjust if your NYUDataModule expects a tuple for img_size
remove_white_border: True
batch_size: 24
num_workers: 0 # based on the synthetic data, we don't need multiple workers
batch_size: 24 # Adjust the batch size
num_workers: 0 # if you are using synthetic data, you don't need multiple workers
use_labels: True
num_cluster: 5
ckpt_path: null
```

Then specify the configuration file in the `train.sh` script.

```bash
python cli_run.py train --config configs/config_file_name.yaml
```

Then specify the configuration file in the `train.sh` script. Finally, run the following command:
Finally, run the following command:

```bash
cd scripts
Expand Down
10 changes: 5 additions & 5 deletions configs/config_fit_ARKitScenes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ model:
# weight decay
wd: 0.001
data:
class_path: dataloader.dataset.ARKitScenesDataModule
class_path: dataloader.dataset.ARKitScenesDataModule # Path to your dataloader Module in dataset.py
init_args:
arkitScenes_data_root: '/mnt/IRONWOLF1/ashkan/data/ARKitScenes/upsampling'
arkitScenes_data_root: '/mnt/IRONWOLF1/ashkan/data/ARKitScenes/upsampling' # Path to your dataset
img_size: [480, 640]
batch_size: 12
num_workers: 0 # Adjust based on your requirements
batch_size: 12 # Adjust batch size
num_workers: 0 # leave it as zero since we are using synthesizing method
num_cluster: 5

ckpt_path: /home/ashkanganj/workspace/PrecisionDepthFocus/checkpoints/NYUBestScaleInv5Full.ckpt
ckpt_path: null # checkpoints to continue the training.
9 changes: 4 additions & 5 deletions configs/config_fit_DDFF12.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ model:
# weight decay
wd: 0.001
data:
class_path: dataloader.dataset.DDFF12DataModule
class_path: dataloader.dataset.DDFF12DataModule # Path to your dataloader Module in dataset.py
init_args:
ddff12_data_root: '/home/ashka/data/my_ddff_trainVal.h5'
ddff12_data_root: '/home/ashka/data/my_ddff_trainVal.h5' # Path to your dataset
img_size: [224,224]
batch_size: 8
batch_size: 8 # Adjust batch size
num_workers: 0 # Adjust based on your requirements
num_cluster: 5
# ckpt_path: /home/ashkanganj/workspace/PrecisionDepthFocus/logs/lightning_logs/version_0/checkpoints/epoch=599-step=60000.ckpt
ckpt_path: null
ckpt_path: null # checkpoints to continue the training.
10 changes: 4 additions & 6 deletions configs/config_fit_NYU.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,11 @@ model:
data:
class_path: dataloader.dataset.NYUDataModule
init_args:
# nyuv2_data_root: '/home/ashka/data/nyu_depth_v2_labeled.mat'
nyuv2_data_root: '/home/ashka/data/nyu_depth_v2/official_splits/'
img_size: [480, 640] # Adjust if your NYUDataModule expects a tuple for img_size
remove_white_border: True
batch_size: 24
num_workers: 0 # Adjust based on your requirements
batch_size: 24 # Adjust batch size
num_workers: 0 # leave it as zero since we are using synthesizing method
use_labels: True
num_cluster: 5
# ckpt_path: /home/ashkanganj/workspace/PrecisionDepthFocus/logs/lightning_logs/version_0/checkpoints/epoch=599-step=60000.ckpt
ckpt_path: null
num_cluster: 5
ckpt_path: null # checkpoints to continue the training.
8 changes: 4 additions & 4 deletions configs/config_test_ARKitScenes.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# pytorch_lightning==2.1.0
data:
class_path: dataloader.dataset.ARKitScenesDataModule
class_path: dataloader.dataset.ARKitScenesDataModule # Path to your dataloader Module in dataset.py
init_args:
arkitScenes_data_root: '/mnt/IRONWOLF1/ashkan/data/ARKitScenes/upsampling'
arkitScenes_data_root: '/mnt/IRONWOLF1/ashkan/data/ARKitScenes/upsampling' # path to the dataset
img_size: [480, 640]
batch_size: 1
num_workers: 0 # Adjust based on your requirements
num_cluster: 5

model:
invert_depth: True
invert_depth: True

ckpt_path: /home/ashkanganj/workspace/2023-HybridDepth-DepthProject/checkpoints/scaleInvARKitScenes5.ckpt
ckpt_path: ./checkpoints/checkpoint.pth #path to the checkpoint
6 changes: 3 additions & 3 deletions configs/config_test_DDFF12.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# pytorch_lightning==2.1.0
data:
# For DDFF12DataModule
class_path: dataloader.dataset.DDFF12DataModule
class_path: dataloader.dataset.DDFF12DataModule # Path to your dataloader Module in dataset.py
init_args:
ddff12_data_root: '/home/ashkanganj/workspace/dataset/dff_trainVal.h5'
ddff12_data_root: '/home/ashkanganj/workspace/dataset/dff_trainVal.h5' # path to the specific dataset
img_size: [383, 552] # Adjust if your DDFF12DataModule expects a tuple for img_size
remove_white_border: True
batch_size: 1
Expand All @@ -13,4 +13,4 @@ data:
model:
invert_depth: False

ckpt_path: /home/ashkanganj/workspace/2023-HybridDepth-DepthProject/checkpoints/DDFF12BestScaleInv.ckpt
ckpt_path: ./checkpoints/checkpoint.pth #path to the checkpoint
7 changes: 3 additions & 4 deletions configs/config_test_NYU.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# pytorch_lightning==2.1.0
data:
class_path: dataloader.dataset.NYUDataModule
class_path: dataloader.dataset.NYUDataModule # Path to your dataloader Module in dataset.py
init_args:
nyuv2_data_root: '/home/ashkanganj/workspace/dataset/nyu_depth_v2/official_splits'
# nyuv2_data_root: '/home/ashka/data/nyu_depth_v2_labeled.mat'
nyuv2_data_root: '/home/ashkanganj/workspace/dataset/nyu_depth_v2/official_splits' # path to the specific dataset
img_size: [480, 640] # Adjust if your NYUDataModule expects a tuple for img_size
remove_white_border: True
batch_size: 1
Expand All @@ -14,4 +13,4 @@ data:
model:
invert_depth: True

ckpt_path: /home/ashkanganj/workspace/PrecisionDepthFocus/checkpoints/NYUBestScaleInv10Full.ckpt
ckpt_path: ./checkpoints/checkpoint.pth #path to checkpoint

0 comments on commit f883e32

Please sign in to comment.