Yolov3: RuntimeError: shape '[16]' is invalid for input of size 5 using yolov3-tiny.cfg

Created on 1 Aug 2019  路  6Comments  路  Source: ultralytics/yolov3

Describe the bug

Changing the default conf from cfg/yolov3.cfg to cfg/yolov3-tiny.cfg raises RuntimeError: shape '[16]' is invalid for input of size 5.

To Reproduce
Steps to reproduce the behavior:

  1. Clone the repo.
git clone https://github.com/ultralytics/yolov3
  1. Download COCO dataset:
bash yolov3/data/get_coco_dataset.sh
  1. Execute:
python3 train.py --cfg cfg/yolov3-tiny.cfg
  1. See error

Expected behavior

python3 train.py --cfg cfg/yolov3-tiny.cfg

Output:

Namespace(accumulate=2, batch_size=32, bucket='', cfg='cfg/yolov3-tiny.cfg', data='data/coco_64img.data', epochs=273, evolve=False, img_size=416, img_weights=False, multi_scale=False, nosave=False, notest=False, num_workers=4, rect=False, resume=False, transfer=False, xywh=False)
Using CPU

Traceback (most recent call last):
  File "train.py", line 363, in <module>
    accumulate=opt.accumulate)
  File "train.py", line 143, in train
    cutoff = load_darknet_weights(model, weights + 'yolov3-tiny.conv.15')
  File "/yolov3/models.py", line 307, in load_darknet_weights
    bn_rm = torch.from_numpy(weights[ptr:ptr + num_b]).view_as(bn_layer.running_mean)
RuntimeError: shape '[16]' is invalid for input of size 5

Desktop:

  • OS: Ubuntu
  • Version 18.04
bug

Most helpful comment

@ismaeIfm @FeatheryW to train with yolov3-tiny you need to download the backbone first from our Google Drive folder (its unavailable on the pjreddie server), or you can also start training from randomly initialized weights, though this will take a lot longer.

This error message occured because curl attempts to find the tiny backbone on the pjreddie server, and downloads instead the 404 file-not-found html message and saves it as the tiny backbone. We've updated the code to streamline this reporting in the future. If you git pull it will now direct you more clearly to download the missing file:
AssertionError: weights/yolov3-tiny.conv.15 missing, download from https://drive.google.com/drive/folders/1uxgUBemJVw9wZsdpboYbzUN4bcRhsuAI

So to fix the error, download the tiny backbone, place it in your /weights folder and then:

(yolov3) Glenns-iMac:yolov3 glennjocher$ python3 train.py --cfg cfg/yolov3-tiny.cfg
Namespace(accumulate=2, batch_size=32, bucket='', cfg='cfg/yolov3-tiny.cfg', data='data/coco.data', epochs=273, evolve=False, img_size=416, img_weights=False, multi_scale=False, nosave=False, notest=False, num_workers=4, rect=False, resume=False, transfer=False, xywh=False)
Using CPU

Model Summary: 37 layers, 8.85237e+06 parameters, 8.85237e+06 gradients

     Epoch   gpu_mem   GIoU/xy        wh       obj       cls     total   targets  img_size
     0/272        0G     0.994         0      7.16      8.83        17       222       416:   0%|      | 4/3665 [00:21<5:38:29,  5.55s/it]

All 6 comments

Also having this error on MacOS.

@ismaeIfm @FeatheryW to train with yolov3-tiny you need to download the backbone first from our Google Drive folder (its unavailable on the pjreddie server), or you can also start training from randomly initialized weights, though this will take a lot longer.

This error message occured because curl attempts to find the tiny backbone on the pjreddie server, and downloads instead the 404 file-not-found html message and saves it as the tiny backbone. We've updated the code to streamline this reporting in the future. If you git pull it will now direct you more clearly to download the missing file:
AssertionError: weights/yolov3-tiny.conv.15 missing, download from https://drive.google.com/drive/folders/1uxgUBemJVw9wZsdpboYbzUN4bcRhsuAI

So to fix the error, download the tiny backbone, place it in your /weights folder and then:

(yolov3) Glenns-iMac:yolov3 glennjocher$ python3 train.py --cfg cfg/yolov3-tiny.cfg
Namespace(accumulate=2, batch_size=32, bucket='', cfg='cfg/yolov3-tiny.cfg', data='data/coco.data', epochs=273, evolve=False, img_size=416, img_weights=False, multi_scale=False, nosave=False, notest=False, num_workers=4, rect=False, resume=False, transfer=False, xywh=False)
Using CPU

Model Summary: 37 layers, 8.85237e+06 parameters, 8.85237e+06 gradients

     Epoch   gpu_mem   GIoU/xy        wh       obj       cls     total   targets  img_size
     0/272        0G     0.994         0      7.16      8.83        17       222       416:   0%|      | 4/3665 [00:21<5:38:29,  5.55s/it]

I see, thanks for sharing!!!

@ismaeIfm how to train yolov3-tiny for 1 class?

it is showing RuntimeError: shape '[16, 3, 6, 13, 13]' is invalid for input of size 689520

@abhiksark I just followed the guide. Remember to change the number of filters to 18.

@ismaeIfm how to train yolov3-tiny for 1 class?

it is showing RuntimeError: shape '[16, 3, 6, 13, 13]' is invalid for input of size 689520

Hi, do you resolve this issue? I have the same error, help pls.

Was this page helpful?
0 / 5 - 0 ratings