ChenYingpeng / darknet2caffe

Convert darknet weights to caffemodel
183 stars 88 forks source link

yolov4-tiny convert failed #18

Closed Softwaring closed 3 years ago

Softwaring commented 3 years ago

Thanks for your help.

unknow layer type yolo
Traceback (most recent call last):
  File "darknet2caffe.py", line 519, in <module>
    darknet2caffe(cfgfile, weightfile, protofile, caffemodel)
  File "darknet2caffe.py", line 61, in darknet2caffe
    start = load_conv_bn2caffe(buf, start, params[conv_layer_name], params[bn_layer_name], params[scale_layer_name])
  File "darknet2caffe.py", line 150, in load_conv_bn2caffe
    conv_param[0].data[...] = np.reshape(buf[start:start+conv_weight.size], conv_weight.shape); start = start + conv_weight.size
  File "/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 257, in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)
  File "/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 52, in _wrapfunc
    return getattr(obj, method)(*args, **kwds)
ValueError: cannot reshape array of size 695826 into shape (256,384,3,3)

yolov4-tiny.cfg

xs-trinity-lwei commented 3 years ago

I have the same problem as you,It seems that ‘weights buf’ is not enough to convert.

ChenYingpeng commented 3 years ago

Thanks for your help.

unknow layer type yolo
Traceback (most recent call last):
  File "darknet2caffe.py", line 519, in <module>
    darknet2caffe(cfgfile, weightfile, protofile, caffemodel)
  File "darknet2caffe.py", line 61, in darknet2caffe
    start = load_conv_bn2caffe(buf, start, params[conv_layer_name], params[bn_layer_name], params[scale_layer_name])
  File "darknet2caffe.py", line 150, in load_conv_bn2caffe
    conv_param[0].data[...] = np.reshape(buf[start:start+conv_weight.size], conv_weight.shape); start = start + conv_weight.size
  File "/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 257, in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)
  File "/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 52, in _wrapfunc
    return getattr(obj, method)(*args, **kwds)
ValueError: cannot reshape array of size 695826 into shape (256,384,3,3)

yolov4-tiny.cfg

Hi, Softwaring [route] layers=-1 groups=2 group_id=1 This layer output_size = input_size / groups, you should change concate layer in caffe.

xs-trinity-lwei commented 3 years ago

The yolov4(not tiny) has the same ‘route’ layer.Although the current tool can successfully convert yolov4 to caffe,Will there be some problems.

Softwaring commented 3 years ago

@ChenYingpeng Thanks for your reply!

hp-93 commented 3 years ago

so,I want to know how to solve this problem(groups and group_id)

lesterlee89 commented 3 years ago

@Softwaring @ChenYingpeng is there some tips to convert caffe without change the layers,thanks

Chalay commented 3 years ago

Thanks for your help.

unknow layer type yolo
Traceback (most recent call last):
  File "darknet2caffe.py", line 519, in <module>
    darknet2caffe(cfgfile, weightfile, protofile, caffemodel)
  File "darknet2caffe.py", line 61, in darknet2caffe
    start = load_conv_bn2caffe(buf, start, params[conv_layer_name], params[bn_layer_name], params[scale_layer_name])
  File "darknet2caffe.py", line 150, in load_conv_bn2caffe
    conv_param[0].data[...] = np.reshape(buf[start:start+conv_weight.size], conv_weight.shape); start = start + conv_weight.size
  File "/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 257, in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)
  File "/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 52, in _wrapfunc
    return getattr(obj, method)(*args, **kwds)
ValueError: cannot reshape array of size 695826 into shape (256,384,3,3)

yolov4-tiny.cfg

Hi, Softwaring [route] layers=-1 groups=2 group_id=1 This layer output_size = input_size / groups, you should change concate layer in caffe.

Hi,ChenYingpeng As well know, concate layer in caffe did not have parameter like dropout 50% to select the group id to the output, chould you point out how to motify the concate layer? I had train a networking and facing the same problem, now I delect the "groups" and "groups_id" parameter to sucessfully convert the model to caffemodel format.

Hoping Ur reply @.@

jerryho-quanta commented 3 years ago

Hello, @ChenYingpeng @Softwaring

I also meet ths same problem,

Traceback (most recent call last): File "darknet2caffe.py", line 569, in darknet2caffe(cfgfile, weightfile, protofile, caffemodel) File "darknet2caffe.py", line 65, in darknet2caffe start = load_conv_bn2caffe(buf, start, params[conv_layer_name], params[bn_layer_name], params[scale_layer_name],conv_layer_name) File "darknet2caffe.py", line 184, in load_conv_bn2caffe conv_param[0].data[...] = np.reshape(buf[start:start+conv_weight.size], conv_weight.shape); start = start + conv_weight.size File "<__array_function__ internals>", line 6, in reshape File "/home/jerry/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 301, in reshape return _wrapfunc(a, 'reshape', newshape, order=order) File "/home/jerry/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 61, in _wrapfunc return bound(*args, **kwds) ValueError: cannot reshape array of size 756735 into shape (256,384,3,3)

Could you share how to fix this problem?

Thanks,