1

I have a .caffemodel file, and I want to use it in my iOS application through Caffe2Kit, but instance init function parameters are 2 .pb files called "initNet" and "predictNet". I tried to use caffe_translator:

python -m caffe2.python.caffe_translator deploy_nodist.prototxt global_model.caffemodel

but I got an error message:

KeyError: 'No translator registered for layer: name: "Slice"\ntype: "Slice"\nbottom: "data_l_ab_mask"\ntop: "data_l"\ntop: "data_ab_mask"\nslice_param {\n  slice_point: 1\n  axis: 1\n}\n yet.'

Also I tried to convert this .caffemodel file to .mlmodel file with coremltools:

coreml_model = coremltools.converters.caffe.convert('global_model.caffemodel')

But I got this:

Layer 0: Type: 'TransformingFastHDF5Input', Name: 'img'. Output(s): 'img'.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda2/lib/python2.7/site-packages/coremltools/converters/caffe/_caffe_converter.py", line 191, in convert
    predicted_feature_name)
  File "/anaconda2/lib/python2.7/site-packages/coremltools/converters/caffe/_caffe_converter.py", line 255, in _export
    predicted_feature_name)
RuntimeError: Cannot convert caffe layer of type 'TransformingFastHDF5Input'.

How I can integrate this .caffemodel into my iOS application? Or maybe I need to use custom layers for mlmodel? But idk python.

Jim
  • 11
  • 1
  • What version of Caffe are you using? If it's not the standard Caffe but one with custom layers then you cannot use the converter from coremltools. – Matthijs Hollemans Aug 18 '18 at 13:42
  • @matthijs-hollemans I really don't know what of Caffe version used for create this file, but when I open it through https://lutzroeder.github.io/Netron/ , it show model format: "Caffe v2". – Jim Aug 19 '18 at 09:47
  • Since Caffe is written in C++, if you want to use a layer type that is not in standard Caffe, you need to fork the source code and implement that layer yourself. This is why there are many different versions of Caffe that are all incompatible with each other. Coremltools only supports the official version of Caffe. My guess is that `TransformingFastHDF5Input` is not a layer that is part of the original Caffe. – Matthijs Hollemans Aug 19 '18 at 14:14

0 Answers0