ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.16k stars 3.44k forks source link

Problem with shape with running detect.py example #843

Closed Dominux closed 4 years ago

Dominux commented 4 years ago

I cloned repo and ran:

python detect.py --cfg cfg/yolov3-spp.cfg --weights yolov3-spp.weights

And got that:

Namespace(agnostic_nms=False, cfg='cfg/yolov3-spp.cfg', classes=None, conf_thres=0.3, device='', fourcc='mp4v', half=False, img_size=416, iou_thres=0.5, names='data/coco.names', output='output', save_txt=False, source='data/samples', view_img=False, weights='yolov3-spp.weights')
Using CUDA device0 _CudaDeviceProperties(name='GeForce MX230', total_memory=2048MB)

Traceback (most recent call last):
  File "detect.py", line 179, in <module>
    detect()
  File "detect.py", line 28, in detect
    load_darknet_weights(model, weights)
  File "d:\My_scripts\Fashion is my profession\Projects versions\D\yolov3\models.py", line 363, in load_darknet_weights
    conv_w = torch.from_numpy(weights[ptr:ptr + num_w]).view_as(conv_layer.weight)
RuntimeError: shape '[32, 3, 3, 3]' is invalid for input of size 255

I have:

Any idea?

glenn-jocher commented 4 years ago

@Dominux that’s odd. Can you try the same command with the pytorch weights instead: yolov3-spp.pt

Dominux commented 4 years ago

python detect.py --cfg cfg/yolov3.cfg --weights yolov3.weights

Namespace(agnostic_nms=False, cfg='cfg/yolov3.cfg', classes=None, conf_thres=0.3, device='', fourcc='mp4v', half=False, img_size=416, iou_thres=0.5, 
names='data/coco.names', output='output', save_txt=False, source='data/samples', view_img=False, weights='yolov3.weights')
Using CUDA device0 _CudaDeviceProperties(name='GeForce MX230', total_memory=2048MB)

Traceback (most recent call last):
  File "detect.py", line 179, in <module>
    detect()
  File "detect.py", line 28, in detect
    load_darknet_weights(model, weights)
  File "D:\My_scripts\Fashion is my profession\Projects versions\D\yolov3\models.py", line 363, in load_darknet_weights
    conv_w = torch.from_numpy(weights[ptr:ptr + num_w]).view_as(conv_layer.weight)
RuntimeError: shape '[32, 3, 3, 3]' is invalid for input of size 255
glenn-jocher commented 4 years ago

@Dominux the .weights are darknet weights. .pt are pytorch weights. You might try re-running with pytorch weights, or running your code in a working envorionment:

Screen Shot 2020-02-12 at 12 17 10 PM
FranciscoReveriano commented 4 years ago

you might want to try "weights/yolov3-spp.weights"

Dominux commented 4 years ago

you might want to try "weights/yolov3-spp.weights"

It doesn't work

glenn-jocher commented 4 years ago

@Dominux it may just be a windows-related issue then. We routinely validate the code on MacOS and Linux, but our most recent Windows validation was several months ago. It's possible the changes since then may cause a problem on Windows.

Unfortunately we don't have a current Windows machine to test on, nor time to spin up a Windows VM, but if you discover the source of the issue please let us know.

Dominux commented 4 years ago

@glenn-jocher do u know if I can run it from windows subsystem for linux?

glenn-jocher commented 4 years ago

@Dominux I'm not sure, but we do have various working linux environments available you can use and access from windows, many free. We will try to validate on windows at some point soon, but in general we highly recommend you try to develop under linux, even moreso for PyTorch CUDA and GPU accessibility and operability. https://docs.ultralytics.com/yolov5/tutorials/train_custom_data

Reproduce Our Environment

To access an up-to-date working environment (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled), consider a:

glenn-jocher commented 4 years ago

I'll close this issue for now as the original issue appears to have been resolved, and/or no activity has been seen for some time. Feel free to comment if this is not the case.