Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import coremltools
- def convert_lambda(layer):
- # Only convert this Lambda layer if it is for our swish function.
- if layer.function == ctc_lambda_func:
- params = NeuralNetwork_pb2.CustomLayerParams()
- # The name of the Swift or Obj-C class that implements this layer.
- params.className = "x"
- # The desciption is shown in Xcode's mlmodel viewer.
- params.description = "A fancy new loss"
- return params
- else:
- return None
- print("nConverting the model:")
- # Convert the model to Core ML.
- coreml_model = coremltools.converters.keras.convert(
- model,
- # 'weightswithoutstnlrchangedbackend.best.hdf5',
- input_names="image",
- image_input_names="image",
- output_names="output",
- add_custom_layers=True,
- custom_conversion_functions={"Lambda": convert_lambda},
- )
- Converting the model:
- Traceback (most recent call last):
- File "/home/sgnbx/Downloads/projects/CRNN-with-STN-master/CRNN_with_STN.py", line 201, in <module>
- custom_conversion_functions={"Lambda": convert_lambda},
- File "/home/sgnbx/anaconda3/envs/tf_gpu/lib/python3.6/site-packages/coremltools/converters/keras/_keras_converter.py", line 760, in convert
- custom_conversion_functions=custom_conversion_functions)
- File "/home/sgnbx/anaconda3/envs/tf_gpu/lib/python3.6/site-packages/coremltools/converters/keras/_keras_converter.py", line 556, in convertToSpec
- custom_objects=custom_objects)
- File "/home/sgnbx/anaconda3/envs/tf_gpu/lib/python3.6/site-packages/coremltools/converters/keras/_keras2_converter.py", line 255, in _convert
- if input_names[idx] in input_name_shape_dict:
- IndexError: list index out of range
- Input name length mismatch
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement