MMdnn
MMdnn copied to clipboard
[Slice of Caffe parser support] Error when converting DPN68 from caffe to IR
Hi,
This is my model: link
The error message showed up when I tried to convert my model from caffe to IR:
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 159, in <module>
_main()
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 154, in _main
ret = _convert(args)
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 9, in _convert
transformer = CaffeTransformer(args.network, args.weights, "tensorflow", args.inputShape, phase = args.caffePhase)
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/transformer.py", line 308, in __init__
graph = GraphBuilder(def_path, self.input_shape, self.is_train_proto, phase).build()
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/graph.py", line 444, in build
graph.compute_output_shapes(self.model)
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/graph.py", line 265, in compute_output_shapes
node.output_shape = TensorShape(*NodeKind.compute_output_shape(node))
File "/usr/local/lib/python2.7/dist-packages/mmdnn/conversion/caffe/graph.py", line 127, in compute_output_shape
raise ConversionError('Output shape computation not implemented for type: %s' % node.kind)
mmdnn.conversion.caffe.errors.ConversionError: Output shape computation not implemented for type: Slice
Can you check this out?
Thank you
Slice layer of Caffe parser is not implemented. We will inform you asap. Thanks.
any update on this one?
Any update?
Any update on this?
any update on this :)
any update on this :)
I have an immature solution in caffe to tensorflow:
in mmdnn/conversion/caffe/shape.py
add code:
def shape_slice(node):
print(node.parameters)
axis = node.parameters.axis
slices = len(node.parameters.slice_point) if len(node.parameters.slice_point) > 2 else 2
input_shape = node.get_only_parent()[0].output_shape
if axis == 1:
return TensorShape(input_shape.batch_size, input_shape.channels // slices, input_shape.height, input_shape.width)
elif axis == 2:
return TensorShape(input_shape.batch_size, input_shape.channels, input_shape.height // slices, input_shape.width)
elif axis == 3:
return TensorShape(input_shape.batch_size, input_shape.channels, input_shape.height, input_shape.width // slices)
return TensorShape(input_shape.batch_size, input_shape.channels // slices, input_shape.height, input_shape.width)
in mmdnn/conversion/caffe/graph.py
modify code:
...
'Split': shape_split,
'Slice': shape_slice,
'TanH': shape_identity,
...
in mmdnn/conversion/caffe/mapper.py
add code in class NodeMapper:
@classmethod
def map_slice(cls, node):
slices = len(node.parameters.slice_point) if len(node.parameters.slice_point) > 2 else 2
kwargs = {'axis': (2, 3, 1, 0)[node.parameters.axis], 'num_or_size_splits': slices}
cls._convert_output_shape(kwargs, node)
return Node.create('Split', **kwargs)
so you can run command:
mmtoir -f caffe -n ./models/model.prototxt -w ./models/model.caffemodel -o caffe_model_IR
mmtocode -f tensorflow --IRModelPath caffe_model_IR.pb --IRWeightPath caffe_model_IR.npy --dstModelPath tf_model_IR.py
It generates tensorflow model code: tf_model_IR.py
Now you can modify tf_model_IR.py
source file to correspond to caffe model
Note: This can only divide input tensor evenly.