Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting YOLOV3-Tiny #3

Open
sleebapaul opened this issue Jul 26, 2018 · 4 comments
Open

Converting YOLOV3-Tiny #3

sleebapaul opened this issue Jul 26, 2018 · 4 comments

Comments

@sleebapaul
Copy link

I was able to successfully convert YoloV3. But what about YoloV3-Tiny? How should I change the convert.py?

@sleebapaul
Copy link
Author

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.".

@benkelaci
Copy link

Any progress with this? Where is this error coming from?

@sleebapaul
Copy link
Author

@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.

@benkelaci
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants