pjreddie / darknet

Convolutional Neural Networks
http://pjreddie.com/darknet/
Other
25.66k stars 21.33k forks source link

convert yolov3-spp to onnx #2182

Open liguoyu666 opened 4 years ago

liguoyu666 commented 4 years ago

When I convert yolov3-spp to onnx, it reported: File "/home/lgy/PycharmProjects/TensorRT_yolo3_module/spp_weight_to_onnx.py", line 296, in _load_one_param_type buffer=self.weights_file.read(param_size * 4)) TypeError: buffer is too small for requested array

I am sure yolov3-spp.cfg and yolov3-spp.weights are matched.

could you help me?

liguoyu666 commented 4 years ago

I found that in the conversion process, `
param_size = np.product(np.array(param_shape))

    print(param_name, param_shape, param_size)

    if param_name == '110_convolutional_conv_weights':

        print(len(self.weights_file.read(param_size * 4)))

    param_data = np.ndarray(
        shape=param_shape,
        dtype='float32',
        buffer=self.weights_file.read(param_size * 4))

    print(param_data.shape)

    print('------')`

when converting layer ‘110_convolutional_conv_weights’, the weight was not enough

`110_convolutional_bn_var [256] 256 (256,)

110_convolutional_conv_weights [256, 128, 3, 3] 294912 661500 Traceback (most recent call last): File "spp_weight_to_onnx.py", line 726, in main(cfg='weights_spp_80/yolov3-spp.cfg', weights_file='weights_spp_80/yolov3-spp.weights', onnx_file='weights_spp_80/yolov3-spp.onnx') File "spp_weight_to_onnx.py", line 713, in main verbose=True) File "spp_weight_to_onnx.py", line 361, in build_onnx_graph conv_params) File "spp_weight_to_onnx.py", line 235, in load_conv_weights conv_params, 'conv', 'weights') File "spp_weight_to_onnx.py", line 264, in _create_param_tensors conv_params, param_category, suffix) File "spp_weight_to_onnx.py", line 297, in _load_one_param_type buffer=self.weights_file.read(param_size 4)) TypeError: buffer is too small for requested array ` 294912 4 > 661500