inaiur / Yolo_v2_to_CoreML

Darknet Tiny YOLO v2 to CoreML converter
2 stars 0 forks source link

Error when converting #1

Open temsa opened 6 years ago

temsa commented 6 years ago

Hi @inaiur, and thanks for creating this tool !

I'm having a fatal error when trying to convert my tiny-YoLo retrained on 1 class with a few hundred photos:

Loading weights.
Parsing Darknet config ../darknet/tiny-yolo-voc-1class.cfg
Creating CoreML model.
Parsing section net_0
Parsing section convolutional_0
Parsing section maxpool_0
Parsing section convolutional_1
Parsing section maxpool_1
Parsing section convolutional_2
Parsing section maxpool_2
Parsing section convolutional_3
Parsing section maxpool_3
Parsing section convolutional_4
Parsing section maxpool_4
Parsing section convolutional_5
Parsing section maxpool_5
Parsing section convolutional_6
Parsing section convolutional_7
Parsing section convolutional_8
Parsing section region_0
anchors=1.08,1.19,  3.42,4.41,  6.63,11.38,  9.42,5.11,  16.62,10.52
Main config: image_width=416, image_height=416, channels=3
Adding layer conv2D_2:416x416x16
Adding layer batch_normalization_2:416x416x16
Adding layer leaky_2
Adding layer maxpool_0
Adding layer conv2D_4:208x208x32
Adding layer batch_normalization_4:208x208x32
Adding layer leaky_4
Adding layer maxpool_1
Adding layer conv2D_6:104x104x64
Adding layer batch_normalization_6:104x104x64
Adding layer leaky_6
Adding layer maxpool_2
Adding layer conv2D_8:52x52x128
Adding layer batch_normalization_8:52x52x128
Adding layer leaky_8
Adding layer maxpool_3
Adding layer conv2D_10:26x26x256
Adding layer batch_normalization_10:26x26x256
Adding layer leaky_10
Adding layer maxpool_4
Adding layer conv2D_12:13x13x512
Adding layer batch_normalization_12:13x13x512
Adding layer leaky_12
Adding layer maxpool_5
Adding layer conv2D_14:13x13x1024
Adding layer batch_normalization_14:13x13x1024
Adding layer leaky_14
Adding layer conv2D_15:13x13x1024
Adding layer batch_normalization_15:13x13x1024
Adding layer leaky_15
Adding layer conv2D_16:13x13x30
Adding layer linear_16
Traceback (most recent call last):
  File "yolo_to_coreml.py", line 408, in <module>
    _main(parser.parse_args())
  File "yolo_to_coreml.py", line 341, in _main
    params=section['alpha'])
  File "/home/temsa/dev/waime/Yolo_v2_to_CoreML/yoloml/lib/python2.7/site-packages/coremltools/models/neural_network.py", line 642, in add_activation
    alpha, beta = params[0], params[1]
IndexError: list index out of range

Do you have an idea of what is wrong and how I can debug this error ?

inaiur commented 6 years ago

Hi @temsa, Looks like linear activation function requires 2 parameters - alpha and beta and I do not provide them. As a temporary fix you can set a default value act_param = [1.0, 0.0] and add it to the yolo_to_coreml.py at line 100, here:

if activation == 'leaky':
   act_fn = 'LEAKYRELU'
   act_param = [0.1]
elif activation == 'linear':
   act_param = [1.0, 0.0]
   act_fn = 'LINEAR'
else:
temsa commented 6 years ago

It fixed that issue, but I encountered another after that. TBH I have changed my way to do this transform for now at least, using darkflow: it required a bit of copy/pasting of python, but worked