yrcong / STTran

Spatial-Temporal Transformer for Dynamic Scene Graph Generation, ICCV2021
MIT License
181 stars 34 forks source link

view size is not compatible with input tensor for sgdet #9

Closed Harryqu123 closed 2 years ago

Harryqu123 commented 2 years ago

Hi, thanks for your code and paper in advance. However, I have a small question. When I run the training code in predcls or sgcls mode, everything is fine but when I run the training code in sgdet mode, the error below shows:

File "/home/quhaoxuan/STTran/fasterRCNN/lib/model/rpn/rpn.py", line 50, in reshape x = x.view( RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

I understand that this function seems to be only triggered in sgdet setting. But can I ask is there any suggestions on any possible solutions to this error? Many thanks in advance

yrcong commented 2 years ago

Hi, i have never seen this before. Could you give some more information. Is this triggered in the training or test? How the Tensor x really look like? Which pytorch version are you using? If your pytorch=1.1.0, the issue may be not caused by view function, but somewhere else.

Harryqu123 commented 2 years ago

Thanks for your reply. It happens in the training process of sgdet and my pytorch version is 1.8.0 so I guess it is not the issue for pytorch 1.1.0 However, I find that if I simply change the view function there to reshape function in fasterRCNN/lib/model/rpn/rpn.py, and change the tensor in lib/object_detector.py in line 143 and 148 from CPU tensor to cuda tensor, I can run the code of sgdet. I am not sure whether this would affect the performance but I think I will close this comment first as I somehow solve the issue already. Many thanks