Ma-Dan / YOLOv3-CoreML

YOLOv3 for iOS implemented using CoreML.
MIT License
171 stars 46 forks source link

after training the pertrained model I am not able to convert it using your script. #15

Open JcbPrn opened 5 years ago

JcbPrn commented 5 years ago

hey! thanks! I successfully trained my first model, but after that I am not able to convert it using:

" import coremltools

coreml_model = coremltools.converters.keras.convert('model_data/trained_weights_final.h5', input_names='input1', image_input_names='input1', output_names=['output1', 'output2', 'output3'], image_scale=1/255.)

coreml_model.input_description['input1'] = 'Input image' coreml_model.output_description['output1'] = 'The 13x13 grid (Scale1)' coreml_model.output_description['output2'] = 'The 26x26 grid (Scale2)' coreml_model.output_description['output3'] = 'The 52x52 grid (Scale3)'

coreml_model.author = 'asdas' coreml_model.license = 'BlaBla' coreml_model.short_description = "erster YoloVersuch :D"

coreml_model.save('Yolov3.mlmodel') "

i am able to convert the pertrained model, but after training that model the converter says : " python3 converth5ToCoreML.py

Traceback (most recent call last):

File "converth5ToCoreML.py", line 3, in

coreml_model = coremltools.converters.keras.convert('/Users/robinsonhus0/Desktop/neuer/logs/000/trained_weights_final.h5', input_names='input1', image_input_names='input1', output_names=['output1', 'output2', 'output3'], image_scale=1/255.)

File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/coremltools/converters/keras/_keras_converter.py", line 793, in convert

respect_trainable=respect_trainable)

File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/coremltools/converters/keras/_keras_converter.py", line 579, in convertToSpec

respect_trainable=respect_trainable)

File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/coremltools/converters/keras/_keras2_converter.py", line 311, in _convert

model = _keras.models.load_model(model, custom_objects = custom_objects)

File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/keras/engine/saving.py", line 419, in load_model

model = _deserialize_model(f, custom_objects, compile)

File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/keras/engine/saving.py", line 221, in _deserialize_model

model_config = f['model_config']

File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/keras/utils/io_utils.py", line 302, in getitem

raise ValueError('Cannot create group in read only mode.')

ValueError: Cannot create group in read only mode."

any idea? thank you !

piyomatu commented 4 years ago

I was able to convert yolov2 into coreml.

yolov3 seems to be unable to convert coreML.

And here is yolov2 → .h conversion, here is .cfg Note.

If .h conversion can be done normally, coreML can be converted normally.

JcbPrn commented 4 years ago

Thank you, but I can’t see any Hyperlinks to your mentioned files.

JcbPrn commented 4 years ago

And the conversion of yolov3 works. It only doesn‘t work after training that model by myself. Did you train your weights file before converting it zu coreml?