Tianxiaomo / pytorch-YOLOv4

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

demo.py issue with darknet weights #52

Closed vkrd closed 4 years ago

vkrd commented 4 years ago

I'm using weights I trained on the original darknet repo, and just updated the yolov3-tiny.cfg file with 3 classes (and changed the filters in the prior layer to 24), but I am getting a mismatched tensor error. I printed out x1 and x2 and I get the respective values: x1: torch.Size([1, 128, 30, 30]) x2: torch.Size([1, 256, 27, 27])

Any advice?

Traceback (most recent call last):
  File "demo.py", line 213, in <module>
    detect(cfgfile, weightfile,imgfile)
  File "demo.py", line 46, in detect
    boxes = do_detect(m, sized, 0.5, 0.4, use_cuda)
  File "/Users/vkrd/Documents/Projects/pytorch-YOLOv4/tool/utils.py", line 420, in do_detect
    list_boxes = model(img)
  File "/Users/vkrd/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/Users/vkrd/Documents/Projects/pytorch-YOLOv4/tool/darknet2pytorch.py", line 144, in forward
    x = torch.cat((x1, x2), 1)
RuntimeError: Sizes of tensors must match except in dimension 1. Got 30 and 27 in dimension 2
Tianxiaomo commented 4 years ago

fixed.

https://github.com/Tianxiaomo/pytorch-YOLOv4/commit/7111262a9ae1eebd5ff0ff347b9fe80e2971a56c#diff-da3124f3b0244e3b9e9843f20a611f04