Tianxiaomo / pytorch-YOLOv4

PyTorch ,ONNX and TensorRT implementation of YOLOv4
Apache License 2.0
4.47k stars 1.49k forks source link

RuntimeError: view size is not compatible with input tensor's size and stride #553

Open mikel-brostrom opened 1 year ago

mikel-brostrom commented 1 year ago

Got this error:

File "train.py", line 211, in build_target
    pred_ious = bboxes_iou(pred[b].view(-1, 4), truth_box, xyxy=False)
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.

Solved it by changing view:

https://github.com/Tianxiaomo/pytorch-YOLOv4/blob/a65d219f9066bae4e12003bd7cdc04531860c672/train.py#L211

to reshape

J1ia commented 1 year ago

在view前面加.contiguous()