Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. import coremltools
  2.  
  3. def convert_lambda(layer):
  4. # Only convert this Lambda layer if it is for our swish function.
  5. if layer.function == ctc_lambda_func:
  6. params = NeuralNetwork_pb2.CustomLayerParams()
  7.  
  8. # The name of the Swift or Obj-C class that implements this layer.
  9. params.className = "x"
  10.  
  11. # The desciption is shown in Xcode's mlmodel viewer.
  12. params.description = "A fancy new loss"
  13.  
  14. return params
  15. else:
  16. return None
  17.  
  18.  
  19. print("nConverting the model:")
  20.  
  21. # Convert the model to Core ML.
  22. coreml_model = coremltools.converters.keras.convert(
  23. model,
  24. # 'weightswithoutstnlrchangedbackend.best.hdf5',
  25. input_names="image",
  26. image_input_names="image",
  27. output_names="output",
  28. add_custom_layers=True,
  29. custom_conversion_functions={"Lambda": convert_lambda},
  30. )
  31.  
  32. Converting the model:
  33. Traceback (most recent call last):
  34. File "/home/sgnbx/Downloads/projects/CRNN-with-STN-master/CRNN_with_STN.py", line 201, in <module>
  35. custom_conversion_functions={"Lambda": convert_lambda},
  36. File "/home/sgnbx/anaconda3/envs/tf_gpu/lib/python3.6/site-packages/coremltools/converters/keras/_keras_converter.py", line 760, in convert
  37. custom_conversion_functions=custom_conversion_functions)
  38. File "/home/sgnbx/anaconda3/envs/tf_gpu/lib/python3.6/site-packages/coremltools/converters/keras/_keras_converter.py", line 556, in convertToSpec
  39. custom_objects=custom_objects)
  40. File "/home/sgnbx/anaconda3/envs/tf_gpu/lib/python3.6/site-packages/coremltools/converters/keras/_keras2_converter.py", line 255, in _convert
  41. if input_names[idx] in input_name_shape_dict:
  42. IndexError: list index out of range
  43. Input name length mismatch
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement