aim-uofa / AdelaiDepth

This repo contains the projects: 'Virtual Normal', 'DiverseDepth', and '3D Scene Shape'. They aim to solve the monocular depth estimation, 3D scene reconstruction from single image problems.
Creative Commons Zero v1.0 Universal
1.07k stars 145 forks source link

RUNTIME Error: The size of tensor a (7) must match the size of tensor b (8) at non-singleton dimension 0 #43

Closed philleer closed 2 years ago

philleer commented 2 years ago

Hi, thanks for the great work.

I am trying to train the code on my machine but encountered the tensor size runtime error as shown in the title above.

Seems some data are filtered by the invalid depth threshold, while the gt_mean and gt_std are still computed from the original gt shown as the code INLR_loss.py.

        mask_maskbatch = mask[mask_batch]
        pred_maskbatch = pred[mask_batch]
        gt_maskbatch = gt[mask_batch]

        gt_mean, gt_std = self.transform(gt)
        gt_trans = (gt_maskbatch - gt_mean[:, None, None, None]) / (gt_std[:, None, None, None] + 1e-8)

Have anyone got such issue? Is it a bug? Or maybe I got some mistakes in my training?

Any suggestion will be appreciated, thank you in advance.

guangkaixu commented 2 years ago

@philleer Hi, thanks for pointing out the bug in our code. As you mentioned, the gt_mean and gt_std should be calculated after filtering the gt values. Also, please delete this line during training: https://github.com/aim-uofa/AdelaiDepth/blob/c5370f150c10fd17761c835fca9b5956c3bff9fe/LeReS/Train/lib/models/ILNR_loss.py#L23. We will double-check the training code recently and retrain our model to ensure the correctness of code.

philleer commented 2 years ago

Thank you for your reply. I'll try it.