pangsu0613 / CLOCs

CLOCs: Camera-LiDAR Object Candidates Fusion for 3D Object Detection
MIT License
351 stars 68 forks source link

Add a column of data #71

Closed xuV2 closed 2 years ago

xuV2 commented 2 years ago

Hello! @pangsu0613 I read your paper(Fast-CLOCs), and I also added a column of data to your code, changing it from 1p4 to 1p5, but there is an error in my code( self.opt.step() in fastai_optim.py).RuntimeError: The size of tensor a (4) must match the size of tensor b (5) at non-singleton dimension 1.

pangsu0613 commented 2 years ago

Hello @xuV2 . If one needs to add more channels (or modify the number of channels), these places below need to be modified: (1)you also need to modify the build_stage2_training function below, add another colum in variable "overlaps". https://github.com/pangsu0613/CLOCs/blob/cad14fdc12392b9734d496e5d7782ae3ba200af5/second/utils/eval.py#L127 (2)change the hardcoded "4" channels into "5", from line 521-527 (or other number of channels if you want): https://github.com/pangsu0613/CLOCs/blob/cad14fdc12392b9734d496e5d7782ae3ba200af5/second/pytorch/models/voxelnet.py#L503 (3)change the hardcoded "4" into "5" in CLOCs model: https://github.com/pangsu0613/CLOCs/blob/cad14fdc12392b9734d496e5d7782ae3ba200af5/second/pytorch/models/fusion.py#L27

My apology to hardcoded these information. I'll update the repo later to remove these hardcoded value.

xuV2 commented 2 years ago

Hello! @pangsu0613 First of all, thank you for your prompt reply. But I have changed the code you mentioned, but when the code runs to train.py(line 279) during training, it will still make mistakes.When I delete 279 lines, the code can be trained. CLOCs/blob/master/second/pytorch/train.py 279 mixed_optimizer.step()

xuV2 commented 2 years ago

The reason for the error is RuntimeError: The size of tensor a (4) must match the size of tensor b (5) at non-singleton dimension 1

pangsu0613 commented 2 years ago

mixed_optimizer.step() should not be deleted. Could you show me the whole error message?

xuV2 commented 2 years ago

Traceback (most recent call last): File "./pytorch/train.py", line 985, in fire.Fire() File "/root/anaconda3/envs/CLOCs/lib/python3.6/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name) File "/root/anaconda3/envs/CLOCs/lib/python3.6/site-packages/fire/core.py", line 471, in _Fire
target=component.name) File "/root/anaconda3/envs/CLOCs/lib/python3.6/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace component = fn(*varargs, **kwargs) File "./pytorch/train.py", line 431, in train raise e File "./pytorch/train.py", line 336, in train mixed_optimizer.step() # 这句话有问题 # 通过梯度下降更新参数 File "/root/CLOCs/torchplus/train/fastai_optim.py", line 136, in step self.opt.step() # 有问题 File "/root/anaconda3/envs/CLOCs/lib/python3.6/site-packages/torch/optim/adam.py", line 93, in step expavg.mul(beta1).add_(1 - beta1, grad) RuntimeError: The size of tensor a (4) must match the size of tensor b (5) at non-singleton dimension 1

pangsu0613 commented 2 years ago

did you change the "4" at line 521 and line 524 in voxelnet.py?

xuV2 commented 2 years ago

iou_test_tensor = iou_test_tensor.reshape(1, 5, 1, 900000) # 原来是4

print(iou_test_tensor.shape) (1, 5, 1, 900000)

        tensor_index_tensor = tensor_index_tensor.reshape(-1, 2)
        if max_num == 0:  
            non_empty_iou_test_tensor = torch.zeros(1, 5, 1, 2)
            non_empty_iou_test_tensor[:, :, :, :] = -1
            non_empty_tensor_index_tensor = torch.zeros(2, 2)
            non_empty_tensor_index_tensor[:, :] = -1
        else:
            non_empty_iou_test_tensor = iou_test_tensor[:, :, :, :max_num]
            # print(non_empty_iou_test_tensor.shape) # torch.Size([1, 5, 1, 313987])
            non_empty_tensor_index_tensor = tensor_index_tensor[:max_num, :]
pangsu0613 commented 2 years ago

could you delete all the files in the working directory (including the adam_optimizer-xxxx.tckpt and other files)?

xuV2 commented 2 years ago

I'm sorry I don't have this ability. I'm just a novice.😭

pangsu0613 commented 2 years ago

when you run training in the terminal: python ./pytorch/train.py train --config_path=./configs/car.fhd.config --model_dir=/dir/to/your_model_dir you create a model directory (--model_dir=/dir/to/your_model_dir), just delete everything in that directory.

xuV2 commented 2 years ago

感谢您的建议,我已经成功解决了我的问题,真的非常感谢您的建议!