Pytorch Lightning Implementation of SC-Depth Methods.

Overview

SC_Depth_pl:

This is a pytorch lightning implementation of SC-Depth (V1, V2) for self-supervised learning of monocular depth from video.

In the V1 (IJCV 2021 & NeurIPS 2019), we propose (i) geometry consistency loss for scale-consistent depth prediction over video and (ii) self-discovered mask for detecting and removing dynamic regions during training towards higher accuracy. We also validate the predicted depth in the Visual SLAM scenario.

In the V2 (TPMAI 2022), we propose auto-recitify network (ARN) to remove relative image rotation in hand-held camera captured videos, e.g., some indoor datasets. We show that the proposed ARN, which is self-supervised trained in an end-to-end fashion, greatly eases the training and significantly boosts the performance.

Install

conda create -n sc_depth_env python=3.6
conda activate sc_depth_env
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.2 -c pytorch
pip install -r requirements.txt

Dataset

We preprocess all existing video datasets to the following general video format for training and testing:

Dataset
  -Training
    --Scene0000
      ---*.jpg (list of images)
      ---cam.txt (3x3 intrinsic)
      ---depth (a folder containing gt depths, optional for validation)
    --Scene0001
    ...
    train.txt (containing training scene names)
    val.txt (containing validation scene names)
  -Testing
    --color (containg testing images)
    --depth (containg ground truth depths)

You can convert it by yourself (on your own video data) or download our pre-processed standard datasets:

[kitti_raw] [nyu]

Training

We provide "scripts/run_train.sh", which shows how to train on kitti and nyu.

Testing

We provide "scripts/run_test.sh", which shows how test on kitti and nyu.

Inference

We provide "scripts/run_inference.sh", which shows how to save depths (.npy) and visualization results (.jpg).

Pretrained models

We provide pretrained models on kitti and nyu datasets. You need to uncompress it and put it into "ckpt" folder. If you run the "scripts/run_test.sh" with the pretrained model (fix the path before running), you should get the following results:

[kitti_scv1_model]:

Models Abs Rel Sq Rel Log10 RMSE RMSE(log) Acc.1 Acc.2 Acc.3
resnet18 0.119 0.878 0.053 4.987 0.196 0.859 0.956 0.981

[nyu_scv2_model]:

Models Abs Rel Sq Rel Log10 RMSE RMSE(log) Acc.1 Acc.2 Acc.3
resnet18 0.142 0.112 0.061 0.554 0.186 0.808 0.951 0.987

References

SC-DepthV1:

Unsupervised Scale-consistent Depth Learning from Video (IJCV 2021)
Jia-Wang Bian, Huangying Zhan, Naiyan Wang, Zhichao Li, Le Zhang, Chunhua Shen, Ming-Ming Cheng, Ian Reid [paper]

@article{bian2021ijcv, 
  title={Unsupervised Scale-consistent Depth Learning from Video}, 
  author={Bian, Jia-Wang and Zhan, Huangying and Wang, Naiyan and Li, Zhichao and Zhang, Le and Shen, Chunhua and Cheng, Ming-Ming and Reid, Ian}, 
  journal= {International Journal of Computer Vision (IJCV)}, 
  year={2021} 
}

which is an extension of previous conference version: Unsupervised Scale-consistent Depth and Ego-motion Learning from Monocular Video (NeurIPS 2019)
Jia-Wang Bian, Zhichao Li, Naiyan Wang, Huangying Zhan, Chunhua Shen, Ming-Ming Cheng, Ian Reid [paper]

@inproceedings{bian2019neurips,
  title={Unsupervised Scale-consistent Depth and Ego-motion Learning from Monocular Video},
  author={Bian, Jiawang and Li, Zhichao and Wang, Naiyan and Zhan, Huangying and Shen, Chunhua and Cheng, Ming-Ming and Reid, Ian},
  booktitle = {Advances in Neural Information Processing Systems (NeurIPS)},
  year={2019}
}

SC-DepthV2:

Auto-Rectify Network for Unsupervised Indoor Depth Estimation (TPAMI 2022)
Jia-Wang Bian, Huangying Zhan, Naiyan Wang, Tat-Jun Chin, Chunhua Shen, Ian Reid [paper]

@article{bian2021tpami, 
  title={Auto-Rectify Network for Unsupervised Indoor Depth Estimation}, 
  author={Bian, Jia-Wang and Zhan, Huangying and Wang, Naiyan and Chin, Tat-Jin and Shen, Chunhua and Reid, Ian}, 
  journal= {IEEE Transactions on Pattern Analysis and Machine Intelligence (TPAMI)}, 
  year={2021} 
}
Comments
  • How to train on my own datasets without ground truth?

    How to train on my own datasets without ground truth?

    Could you please tell me how to train on my own datasets without ground truth?

    "python train.py --config my_config --dataset_dir my_dataset"

    It tells me to provide "val.txt" and "my_dataset/depth". Isn't the depth optional for validation?

    opened by hzy995035849 13
  • what's the measurement unit of depth ?

    what's the measurement unit of depth ?

    Hi, @JiawangBian

    I tried my own data with V3, I found the output depths were like [20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44]. Actually I took the picturess with distance around 10cms, thus I wonder what's the measurment unit of the depth in output depth file? It seems neither mm nor cm.

    Thanks you so much!

    opened by wjlszhang 9
  • training loss

    training loss

    Hi, I trained the scv2 model by tum dataset, and I found that the loss could not converge to a low value after trained for 70 epochs,etc image Is there any skills in traning? And what should I pay attention to in training?

    opened by Be997398715 7
  • error  when I train my own data

    error when I train my own data

    Hi, @JiawangBian

    When I train my own data by V3 model, I get below issue, can you please guide me?

    (sc_depth_env) [admin@localhost sc_depth_pl]$ python train.py --dataset_dir zylds --config configs/v3/th.txt --val_mode photo /home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/torchvision/models/_utils.py:252: UserWarning: Accessing the model URLs via the internal dictionary of the module is deprecated since 0.13 and may be removed in the future. Please access them via the appropriate Weights Enum instead. warnings.warn( GPU available: True (cuda), used: True TPU available: False, using: 0 TPU cores IPU available: False, using: 0 IPUs HPU available: False, using: 0 HPUs 367 samples found for training 367 samples found for validation LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]

    | Name | Type | Params

    0 | depth_net | DepthNet | 14.8 M 1 | pose_net | PoseNet | 13.0 M

    27.9 M Trainable params 0 Non-trainable params 27.9 M Total params 111.417 Total estimated model params size (MB) Sanity Checking: 0it [00:00, ?it/s]/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/connectors/data_connector.py:225: PossibleUserWarning: The dataloader, val_dataloader 0, does not have many workers which may be a bottleneck. Consider increasing the value of the num_workers argument(try 72 which is the number of cpus on this machine) in theDataLoader` init to improve performance. rank_zero_warn( Sanity Checking DataLoader 0: 0%| | 0/5 [00:00<?, ?it/s]Traceback (most recent call last): File "train.py", line 60, in trainer.fit(system, dm) File "/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 696, in fit self._call_and_handle_interrupt( File "/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 650, in _call_and_handle_interrupt return trainer_fn(*args, **kwargs) File "/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 735, in _fit_impl results = self._run(model, ckpt_path=self.ckpt_path) File "/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1166, in _run results = self._run_stage() File "/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1252, in _run_stage return self._run_train() File "/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1274, in _run_train self._run_sanity_check() File "/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1343, in _run_sanity_check val_loop.run() File "/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 200, in run self.advance(*args, **kwargs) File "/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 155, in advance dl_outputs = self.epoch_loop.run(self._data_fetcher, dl_max_batches, kwargs) File "/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 200, in run self.advance(*args, **kwargs) File "/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 143, in advance output = self._evaluation_step(**kwargs) File "/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 240, in _evaluation_step output = self.trainer._call_strategy_hook(hook_name, *kwargs.values()) File "/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1704, in _call_strategy_hook output = fn(*args, **kwargs) File "/home/admin/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/strategies/strategy.py", line 370, in validation_step return self.model.validation_step(*args, **kwargs) File "/home/admin/sc_depth_pl/SC_DepthV3.py", line 88, in validation_step tgt_img, ref_imgs, intrinsics = batch ValueError: too many values to unpack (expected 3)

    opened by wjlszhang 6
  • AttributeError: module 'torch' has no attribute 'profiler'

    AttributeError: module 'torch' has no attribute 'profiler'

    Hi!

    Thanks for sharing this great work!

    When I run the code, it occurs:

    Traceback (most recent call last): File "../train.py", line 1, in from pytorch_lightning import Trainer File "/home/hzc/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/init.py", line 34, in from pytorch_lightning.callbacks import Callback # noqa: E402 File "/home/hzc/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/callbacks/init.py", line 14, in from pytorch_lightning.callbacks.callback import Callback File "/home/hzc/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/callbacks/callback.py", line 25, in from pytorch_lightning.utilities.types import STEP_OUTPUT File "/home/hzc/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/utilities/init.py", line 18, in from pytorch_lightning.utilities.apply_func import move_data_to_device # noqa: F401 File "/home/hzc/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/utilities/apply_func.py", line 29, in from pytorch_lightning.utilities.imports import _compare_version, _TORCHTEXT_LEGACY File "/home/hzc/anaconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/utilities/imports.py", line 146, in _KINETO_AVAILABLE = torch.profiler.kineto_available() AttributeError: module 'torch' has no attribute 'profiler'

    I install the env by requirements.txt. How can I solve this?

    opened by agenthong 6
  • Read GT depth

    Read GT depth

    Thank you for your great work! When I try to load gt depth, I have a question, what's the meaning of "/5000" and "/1000“ in the following comments? Where did they come from? By the way, when using LerEs to generating Pseudo-depth, what's the meaning of "*60000"? @JiawangBian Thank you very much!

    # load gt depth
                if args.dataset in ['nyu']:
                    gt_depths[i] = imread(gt_depths[i]).astype(np.float32) / 5000
                elif args.dataset in ['scannet', 'bonn', 'tum']:
                    gt_depths[i] = imread(gt_depths[i]).astype(np.float32) / 1000
                elif args.dataset == 'kitti':
                    gt_depths[i] = np.load(gt_depths[i])
    

    cv2.imwrite(os.path.join(image_dir_out, img_name[:-4]+'-depth_raw.png'), (pred_depth_ori/pred_depth_ori.max() * 60000).astype(np.uint16))

    opened by chunqizhang 5
  • Training error

    Training error

    Thanks for your great work! when I train the dataset on Colab like this, this is a problem:

    !python train.py --config configs/v3/ddad.txt --dataset_dir ddad --val_mode photo

    /usr/local/lib/python3.7/dist-packages/torchvision/models/_utils.py:253: UserWarning: Accessing the model URLs via the internal dictionary of the module is deprecated since 0.13 and will be removed in 0.15. Please access them via the appropriate Weights Enum instead. "Accessing the model URLs via the internal dictionary of the module is deprecated since 0.13 and will " GPU available: True (cuda), used: True TPU available: False, using: 0 TPU cores IPU available: False, using: 0 IPUs HPU available: False, using: 0 HPUs 22896 samples found for training 22896 samples found for validation LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]

    | Name | Type | Params

    0 | depth_net | DepthNet | 14.8 M 1 | pose_net | PoseNet | 13.0 M

    27.9 M Trainable params 0 Non-trainable params 27.9 M Total params 111.417 Total estimated model params size (MB) Sanity Checking: 0it [00:00, ?it/s]/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:566: UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary. cpuset_checked)) Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1163, in _try_get_data data = self._data_queue.get(timeout=timeout) File "/usr/lib/python3.7/queue.py", line 179, in get self.not_empty.wait(remaining) File "/usr/lib/python3.7/threading.py", line 300, in wait gotit = waiter.acquire(True, timeout) File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/signal_handling.py", line 66, in handler _error_if_any_worker_fails() RuntimeError: DataLoader worker (pid 782) is killed by signal: Killed.

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last): File "train.py", line 60, in trainer.fit(system, dm) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 697, in fit self._fit_impl, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 650, in _call_and_handle_interrupt return trainer_fn(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 735, in _fit_impl results = self._run(model, ckpt_path=self.ckpt_path) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1166, in _run results = self._run_stage() File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1252, in _run_stage return self._run_train() File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1274, in _run_train self._run_sanity_check() File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1343, in _run_sanity_check val_loop.run() File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/loop.py", line 200, in run self.advance(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 155, in advance dl_outputs = self.epoch_loop.run(self._data_fetcher, dl_max_batches, kwargs) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/loop.py", line 200, in run self.advance(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 127, in advance batch = next(data_fetcher) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/fetching.py", line 184, in next return self.fetching_function() File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/fetching.py", line 263, in fetching_function self._fetch_next_batch(self.dataloader_iter) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/fetching.py", line 277, in _fetch_next_batch batch = next(iterator) File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 681, in next data = self._next_data() File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1359, in _next_data idx, data = self._get_data() File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1315, in _get_data success, data = self._try_get_data() File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1176, in _try_get_data raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str)) from e RuntimeError: DataLoader worker (pid(s) 782) exited unexpectedly

    Since there is only one GPU, I set the num_worker=1( 0 the same error), then it comes to:

    /usr/local/lib/python3.7/dist-packages/torchvision/models/_utils.py:253: UserWarning: Accessing the model URLs via the internal dictionary of the module is deprecated since 0.13 and will be removed in 0.15. Please access them via the appropriate Weights Enum instead. "Accessing the model URLs via the internal dictionary of the module is deprecated since 0.13 and will " GPU available: True (cuda), used: True TPU available: False, using: 0 TPU cores IPU available: False, using: 0 IPUs HPU available: False, using: 0 HPUs 22896 samples found for training 22896 samples found for validation LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]

    | Name | Type | Params

    0 | depth_net | DepthNet | 14.8 M 1 | pose_net | PoseNet | 13.0 M

    27.9 M Trainable params 0 Non-trainable params 27.9 M Total params 111.417 Total estimated model params size (MB) Sanity Checking DataLoader 0: 0% 0/5 [00:00<?, ?it/s]Traceback (most recent call last): File "train.py", line 60, in trainer.fit(system, dm) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 697, in fit self._fit_impl, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 650, in _call_and_handle_interrupt return trainer_fn(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 735, in _fit_impl results = self._run(model, ckpt_path=self.ckpt_path) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1166, in _run results = self._run_stage() File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1252, in _run_stage return self._run_train() File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1274, in _run_train self._run_sanity_check() File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1343, in _run_sanity_check val_loop.run() File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/loop.py", line 200, in run self.advance(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 155, in advance dl_outputs = self.epoch_loop.run(self._data_fetcher, dl_max_batches, kwargs) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/loop.py", line 200, in run self.advance(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 143, in advance output = self._evaluation_step(**kwargs) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 240, in _evaluation_step output = self.trainer._call_strategy_hook(hook_name, *kwargs.values()) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1704, in _call_strategy_hook output = fn(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/strategies/strategy.py", line 370, in validation_step return self.model.validation_step(*args, **kwargs) File "/content/sc_depth_pl/SC_DepthV3.py", line 90, in validation_step tgt_depth = self.depth_net(tgt_img) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/content/sc_depth_pl/models/DepthNet.py", line 133, in forward features = self.encoder(x) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/content/sc_depth_pl/models/resnet_encoder.py", line 100, in forward x = self.encoder.conv1(x) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/conv.py", line 457, in forward return self._conv_forward(input, self.weight, self.bias) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/conv.py", line 454, in _conv_forward self.padding, self.dilation, self.groups) RuntimeError: Given groups=1, weight of size [64, 3, 7, 7], expected input[4, 320, 256, 320] to have 3 channels, but got 320 channels instead

    What should be changed? Thank you very much for your help!

    opened by chunqizhang 5
  • quat2mat

    quat2mat

    https://github.com/JiawangBian/sc_depth_pl/blob/2f76ce86524188c1ac04d0d1d4a9bd45eb3902e0/losses/inverse_warp.py#L63 if we use the quaternion coefficients as shown in image1 image according to the Rodriguez formula,We can deduce the rotation matrix,as shown in image2 image i find there are difference between formula and codes. Could you tell me the details of the changes you have made?

    opened by ZhiyiHe1997 5
  • photo_and_geometry_loss missing 1 required positional argument when val_mode = photo

    photo_and_geometry_loss missing 1 required positional argument when val_mode = photo

    I am training with my own dataset. I set the val_mode = photo because I do not have any ground truth images. I get the following error:

    File "sc_depth_pl/SC_Depth.py", line 158, in validation_step intrinsics, poses, poses_inv) TypeError: photo_and_geometry_loss() missing 1 required positional argument: 'hparams'

    It seems that the error occurs because this function takes 8 inputs by default but only 7 are given here. Is this intentional?

    opened by isht7 3
  • pseudo_depth in the data_modules.py

    pseudo_depth in the data_modules.py

    Dear Dr.Bian, I train on my dataset with --val_mode photo, but I find the with_pseudo_depth=False in the data_modules. If it is False, will the pseudo_depth generated by the Leres effect? Thank you very much for your patient reply!

    elif self.hparams.hparams.val_mode == 'photo':
                self.val_dataset = TrainFolder(
                    self.hparams.hparams.dataset_dir,
                    train=False,
                    transform=self.valid_transform,
                    sequence_length=self.hparams.hparams.sequence_length,
                    skip_frames=self.hparams.hparams.skip_frames,
                    use_frame_index=self.hparams.hparams.use_frame_index,
                    with_pseudo_depth=False
                )
    
    opened by chunqizhang 2
  • Training error with index_anchors variable

    Training error with index_anchors variable

    Hi, I am trying to train the network on my own dataset. I don't have ground-truth depth, but following the instructions I've generated pseudo-depth with LeReS. I am training with --val_mode photo. However, during training the following error arises (I've just pasted the most representing part of the stack trace):

    [...]
    File "/home/gabriele/development/sc_depth_pl/losses/normal_ranking_loss.py", line 286, in forward
        ) = edgeGuidedSampling(
      File "/home/gabriele/development/sc_depth_pl/losses/normal_ranking_loss.py", line 73, in edgeGuidedSampling
        index_anchors = torch.randint(
    RuntimeError: random_ expects 'from' to be less than 'to', but got from=0 >= to=0
    

    This happens either with or without the --use_frame_index flag. What am I doing wrong? Thank you!

    opened by gabrielebaris 2
  • Error training V3 with its own dataset

    Error training V3 with its own dataset

    Thank you for your excellent work. I built my dataset in your format, with gt, and also added pseudo-depth, all image sizes are 256*256. My dataset is a number of pictures of endoscopes, with 500 pictures in the validation set and 2000 pictures in the training set. like this picture: image_0001 Enter the command:CUDA_VISIBLE_DEVICES=0 python train.py --config /home/ubuntu/wl/sc_depth_pl-master/configs/v3/nyu.txt --dataset_dir /home/ubuntu/data0/dataset_endo_colon get error:/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/torchvision/models/_utils.py:252: UserWarning: Accessing the model URLs via the internal dictionary of the module is deprecated since 0.13 and will be removed in 0.15. Please access them via the appropriate Weights Enum instead. warnings.warn( GPU available: True (cuda), used: True TPU available: False, using: 0 TPU cores IPU available: False, using: 0 IPUs HPU available: False, using: 0 HPUs Trainer(limit_val_batches=1.0) was configured so 100% of the batches will be used.. 1998 samples found for training 500 samples found for validation LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]

    | Name | Type | Params

    0 | depth_net | DepthNet | 14.8 M 1 | pose_net | PoseNet | 13.0 M

    27.9 M Trainable params 0 Non-trainable params 27.9 M Total params 111.417 Total estimated model params size (MB) Sanity Checking DataLoader 0: 0%| | 0/5 [00:00<?, ?it/s]Traceback (most recent call last): File "train.py", line 60, in trainer.fit(system, dm) File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 696, in fit self._call_and_handle_interrupt( File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 650, in _call_and_handle_interrupt return trainer_fn(*args, **kwargs) File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 735, in _fit_impl results = self._run(model, ckpt_path=self.ckpt_path) File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1166, in _run results = self._run_stage() File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1252, in _run_stage return self._run_train() File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1274, in _run_train self._run_sanity_check() File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1343, in _run_sanity_check val_loop.run() File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 200, in run self.advance(*args, **kwargs) File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 155, in advance dl_outputs = self.epoch_loop.run(self._data_fetcher, dl_max_batches, kwargs) File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 200, in run self.advance(*args, **kwargs) File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 143, in advance output = self._evaluation_step(**kwargs) File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 240, in _evaluation_step output = self.trainer._call_strategy_hook(hook_name, *kwargs.values()) File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1704, in _call_strategy_hook output = fn(*args, **kwargs) File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/pytorch_lightning/strategies/strategy.py", line 370, in validation_step return self.model.validation_step(*args, **kwargs) File "/home/ubuntu/wl/sc_depth_pl-master/SC_DepthV3.py", line 82, in validation_step errs = LossF.compute_errors(gt_depth, tgt_depth, self.hparams.hparams.dataset_name) File "/home/ubuntu/miniconda3/envs/sc_depth_env/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(*args, **kwargs) File "/home/ubuntu/wl/sc_depth_pl-master/losses/loss_functions.py", line 193, in compute_errors batch_size, h, w = gt.size() ValueError: too many values to unpack (expected 3)

    I want to ask you a few questions,: Are 2000 training sets and 500 validation sets too few? Is sc-depth-V3 suitable for endoscopic Settings (like inside the large intestine)? In config, I can only choose bonn, ddad, kitti_raw, nyu, and tum, etc., but which one should I choose when I use my own data set? My own data set image size is 256*256. Should I modify my image size to fit one of the five options above? But I don't know the specific size of these five types of pictures. I guess the above error is caused by the mismatch between the size of my data set and the nyu data set. I am looking forward to your reply

    opened by countlesswu 0
  • Is it possible to get indoor depth without gt or retraining?

    Is it possible to get indoor depth without gt or retraining?

    I understand that I need a scaling factor to scale the model's predictions, but I don't have a GT depth map (I only want to do inference), so I can't get a median of the GT. I can however get the maximum depth inside a room, can I somehow use it to get the absolute distance in the frame? Let's say the wall of the room is 5 meters away from the camera, other objects (or people) are closer, but I don't know how much closer... will doing something like depth = (depth / depth.max()) * 5 # 5 meters.... work?

    opened by gozi1123 0
  • About static camera.

    About static camera.

    Hi, thank you for your gorgeous work. Recently I am trying to apply SC-DepthV3 on my own dataset. I note that before trainning, it is required to subsample video frames (to have sufficient motion) for training, which will filter out static-camera frames. However, my video are actually taken under a static camera, similar to a monitoring camera. I am wondering what will happen if I train on such dataset? Will the program crash?

    opened by 777-en 0
  • loss=nan

    loss=nan

    Hi,JiawangBian

    I constructed my own dataset, and since all the data did not have GT, I only generated pseudo-depth images. I trained the model on my own dataset and I got loss=nan in the first epoch, and it is still the same after reducing the learning rate. I would like to ask for your help to answer this question, I would appreciate it!

    opened by AbandonedWarlord 3
  • About Subsample video frames

    About Subsample video frames

    Hi, @JiawangBian

    I get my own data by a blender script, the basic idea is to take the pictures while the camera moves around the object, thus I get ~100 pics in each scense (take one pic when the camer moves center degrees). Before the training, I use below to generate valid frames

    python generate_valid_frame_index.py --dataset_dir $DATASET

    However, I only get 1 pic in each scense, something wrong when I take the pic?

    The pic looks like below:

    无标题

    opened by wjlszhang 2
  • kitti dataset

    kitti dataset

    I downloaded the kitti dataset you provided, do you know their timestamps? I want to test it under ORB-SLAM3, I downloaded the odometry data set (color, 65 GB) and can't find the correspondence. The folders inside are named by serial number, not date. ZCC6NKL6_4Y236(6 C0 2~5

    opened by sandstorm666 10
Owner
JiaWang Bian
PHD Student
JiaWang Bian
The implemention of Video Depth Estimation by Fusing Flow-to-Depth Proposals

Flow-to-depth (FDNet) video-depth-estimation This is the implementation of paper Video Depth Estimation by Fusing Flow-to-Depth Proposals Jiaxin Xie,

null 32 Jun 14, 2022
Monocular Depth Estimation Using Laplacian Pyramid-Based Depth Residuals

LapDepth-release This repository is a Pytorch implementation of the paper "Monocular Depth Estimation Using Laplacian Pyramid-Based Depth Residuals" M

Minsoo Song 205 Dec 30, 2022
Beyond Image to Depth: Improving Depth Prediction using Echoes (CVPR 2021)

Beyond Image to Depth: Improving Depth Prediction using Echoes (CVPR 2021) Kranti Kumar Parida, Siddharth Srivastava, Gaurav Sharma. We address the pr

Kranti Kumar Parida 33 Jun 27, 2022
Python script for performing depth completion from sparse depth and rgb images using the msg_chn_wacv20. model in ONNX

ONNX msg_chn_wacv20 depth completion Python script for performing depth completion from sparse depth and rgb images using the msg_chn_wacv20 model in

Ibai Gorordo 19 Oct 22, 2022
Python script for performing depth completion from sparse depth and rgb images using the msg_chn_wacv20. model in Tensorflow Lite.

TFLite-msg_chn_wacv20-depth-completion Python script for performing depth completion from sparse depth and rgb images using the msg_chn_wacv20. model

Ibai Gorordo 2 Oct 4, 2021
Light-weight network, depth estimation, knowledge distillation, real-time depth estimation, auxiliary data.

light-weight-depth-estimation Boosting Light-Weight Depth Estimation Via Knowledge Distillation, https://arxiv.org/abs/2105.06143 Junjie Hu, Chenyou F

Junjie Hu 13 Dec 10, 2022
Data-depth-inference - Data depth inference with python

Welcome! This readme will guide you through the use of the code in this reposito

Marco 3 Feb 8, 2022
(CVPR 2022 - oral) Multi-View Depth Estimation by Fusing Single-View Depth Probability with Multi-View Geometry

Multi-View Depth Estimation by Fusing Single-View Depth Probability with Multi-View Geometry Official implementation of the paper Multi-View Depth Est

Bae, Gwangbin 138 Dec 28, 2022
Implementation of temporal pooling methods studied in [ICIP'20] A Comparative Evaluation Of Temporal Pooling Methods For Blind Video Quality Assessment

Implementation of temporal pooling methods studied in [ICIP'20] A Comparative Evaluation Of Temporal Pooling Methods For Blind Video Quality Assessment

Zhengzhong Tu 5 Sep 16, 2022
Current state of supervised and unsupervised depth completion methods

Awesome Depth Completion Table of Contents About Sparse-to-Dense Depth Completion Current State of Depth Completion Unsupervised VOID Benchmark Superv

null 224 Dec 28, 2022
SimpleDepthEstimation - An unified codebase for NN-based monocular depth estimation methods

SimpleDepthEstimation Introduction This is an unified codebase for NN-based monocular depth estimation methods, the framework is based on detectron2 (

null 8 Dec 13, 2022
aka "Bayesian Methods for Hackers": An introduction to Bayesian methods + probabilistic programming with a computation/understanding-first, mathematics-second point of view. All in pure Python ;)

Bayesian Methods for Hackers Using Python and PyMC The Bayesian method is the natural approach to inference, yet it is hidden from readers behind chap

Cameron Davidson-Pilon 25.1k Jan 2, 2023
An essential implementation of BYOL in PyTorch + PyTorch Lightning

Essential BYOL A simple and complete implementation of Bootstrap your own latent: A new approach to self-supervised Learning in PyTorch + PyTorch Ligh

Enrico Fini 48 Sep 27, 2022
Generic template to bootstrap your PyTorch project with PyTorch Lightning, Hydra, W&B, and DVC.

NN Template Generic template to bootstrap your PyTorch project. Click on Use this Template and avoid writing boilerplate code for: PyTorch Lightning,

Luca Moschella 520 Dec 30, 2022
Pretrained SOTA Deep Learning models, callbacks and more for research and production with PyTorch Lightning and PyTorch

Pretrained SOTA Deep Learning models, callbacks and more for research and production with PyTorch Lightning and PyTorch

Pytorch Lightning 1.4k Jan 1, 2023
A general framework for deep learning experiments under PyTorch based on pytorch-lightning

torchx Torchx is a general framework for deep learning experiments under PyTorch based on pytorch-lightning. TODO list gan-like training wrapper text

Yingtian Liu 6 Mar 17, 2022
PyTorch Lightning implementation of Automatic Speech Recognition

lasr Lightening Automatic Speech Recognition An MIT License ASR research library, built on PyTorch-Lightning, for developing end-to-end ASR models. In

Soohwan Kim 40 Sep 19, 2022
Unofficial Pytorch Lightning implementation of Contrastive Syn-to-Real Generalization (ICLR, 2021)

Unofficial Pytorch Lightning implementation of Contrastive Syn-to-Real Generalization (ICLR, 2021)

Gyeongjae Choi 17 Sep 23, 2021
RGBD-Net - This repository contains a pytorch lightning implementation for the 3DV 2021 RGBD-Net paper.

[3DV 2021] We propose a new cascaded architecture for novel view synthesis, called RGBD-Net, which consists of two core components: a hierarchical depth regression network and a depth-aware generator network.

Phong Nguyen Ha 4 May 26, 2022