YOLOv3-CoreML
YOLOv3-CoreML copied to clipboard
Converting YOLOV3-Tiny
I was able to successfully convert YoloV3. But what about YoloV3-Tiny? How should I change the convert.py?
Traceback (most recent call last):
File "coreml_convert.py", line 3, in <module>
coreml_model = coremltools.converters.keras.convert('yolov3-tiny.h5', input_names='input_1', image_input_names='input_1', output_names="leaky_re_lu_11", image_scale=1/255.)
File "/usr/local/lib/python3.6/site-packages/coremltools/converters/keras/_keras_converter.py", line 747, in convert
return _MLModel(spec)
File "/usr/local/lib/python3.6/site-packages/coremltools/models/model.py", line 153, in __init__
self.__proxy__ = _get_proxy_from_spec(filename)
File "/usr/local/lib/python3.6/site-packages/coremltools/models/model.py", line 77, in _get_proxy_from_spec
return _MLModelProxy(filename)
RuntimeError: Error compiling model: "Error reading protobuf spec. validator error: Interface specifies output 'leaky_re_lu_11' which is not produced by any layer in the neural network.".
Any progress with this? Where is this error coming from?
@benkelaci I've edited coreml-convert.py
and this worked for me.
import coremltools
coreml_model = coremltools.converters.keras.convert('yolov3-tiny.h5', input_names='image', image_input_names='image', image_scale=1/255.)
coreml_model.input_description['image'] = 'Input image'
coreml_model.author = 'Original paper: Joseph Redmon, Ali Farhadi'
coreml_model.license = 'Public Domain'
coreml_model.short_description = "The YOLOv3-tiny network from the paper 'YOLOv3: An Incremental Improvement'"
print("\n====================================================\n")
print(coreml_model)
print("\n====================================================\n")
coreml_model.save('yolov3-tiny.mlmodel')
On printing you'll understand the output of the network. There are multiple outputs and it's optional to name them.
Thanks, It seems worked. And now we are figuring out the parsing the output. We tried to cut the original YOLOv3 output (2 output array instead of 3), but no any good result. We changed the anchor boxes and numClasses (same as in our yolov3-tiny cfg), the output number (2), the for (line 67) number (to 2, it is fixed number instead of gridHeight length) in the yolo.swift. Do you have a clue what is the prediction output format/structure? It seems pretty complicated.