oppo-us-research / PlaneMVS

Official PyTorch implementation of PlaneMVS ( https://arxiv.org/abs/2203.12082 ) , a 3D plane reconstruction framework leveraging multi-view geometry and slanted plane hypotheses.
MIT License
10 stars 0 forks source link

RuntimeError: Unknown layout #1

Open Okay0805 opened 5 days ago

Okay0805 commented 5 days ago

最近在复现PlaneMVS代码的过程中遇到了RuntimeError: Unknown layout的报错,不知道该如何解决 image 转换所有张量为float32,确保是连续的,指定到同一个设备,还是报Unknown layout的错,具体出问题的地方在test_net.py的result = model(images_tensor, targets)这一行: image 传入model的images和targets如下: image 配的环境: PyTorch version: 2.2.0+cu121, CUDA version available in PyTorch: 12.1, torchvision version: 0.17.0+cu121 服务器是3080Ti nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2024 NVIDIA Corporation Built on Wed_Aug_14_10:10:22_PDT_2024 Cuda compilation tools, release 12.6, V12.6.68 Build cuda_12.6.r12.6/compiler.34714021_0 恳请指点

ccj5351 commented 3 days ago

Seems like you are modifying our original code in your implementation.

You can find the information about how to adjust the input layout/shape at this file src/models/detector/planestereo.py, around line 294 for train mode and around line 389 for test mode.

The tensor images['ref_img'] obtained from the data loader should be channel first, i.e., [C, H, W], and when fed into the model as in Line 395 should be a 4D tensor in size of [B, C, H, W].

I tried to print out the input shape for the following lines of code

def _forward_test(self, images, targets):
        print_indebugmode (f"???? images['ref_img'] = {images['ref_img'].shape}")
        images['ref_img'] = to_image_list(images['ref_img'])
        ref_img_tensors = images['ref_img'].tensors.cuda()
        print_indebugmode (f"??? ref_img_tensors shape = {ref_img_tensors.shape}" + \
            f", {ref_img_tensors.dtype}, device= {ref_img_tensors.device}")
        sys.exit()

        images['src_img'] = to_image_list(images['src_img'])
        src_img_tensors = images['src_img'].tensors.cuda()

The print information is like:

[*** 4Debug] src/models/detector/planestereo.py:389 -  images['ref_img'] = torch.Size([3, 480, 640])
[*** 4Debug] src/models/detector/planestereo.py:392 -  ref_img_tensors shape = torch.Size([1, 3, 480, 640])

So I think the problem you met is due to the input image is not channel-first.

Okay0805 commented 3 days ago

感谢您指出images['ref_img']通道的问题,在打印输出打印出输入形状后发现我的通道数多了一个维度: image 经过修改之后通道数正确: _A`AIZZ_36X}`7$)W0QJ)LA 但是在调试的时候还是在result = model(images_tensor, targets)会进入到except Exception as e:,运行python test_net.py --config_file /hdata/wulijun/dmh/PlaneMVS_2/configs/plane_cfgs/planestereo.yaml --ckpt_file /hdata/wulijun/dmh/PlaneMVS_2/checkpoints_nfs/exp04-alldata-planemvs-epo10-bs16-dgx10/model_final.pth的时候在roi_align.py的output = _C.roi_align_forward(这一行报错RuntimeError: Unknown layout,不知道是哪里的问题,请指点,谢谢~ G96Z(_WREDQ4VK32U(0IJNA