Open kaonick opened 5 years ago
Hello. Can you show your model definition? I will implement more ONNX operations later, it takes some time.
I am using CRAFT-pytorch(https://github.com/clovaai/CRAFT-pytorch). and want to transfer keras.(pytorch>onnx>keras) Its architecture is VGG-16(backbone). The "Cast" opearator in ONNX(https://github.com/onnx/onnx/blob/master/docs/Operators.md#Cast)
Hi, you can delete this module, then clone this repo, install it from it's directory with "pip3 install -e", then go to onnx2keras/layers.py file, in AVAILABLECONVERTERS in strs 13-57 add " 'Cast': convertcast, " at any row, then add, for example in from .operation_layers import convert_clip, convert_exp, convert_reduce_sum, convert_reduce_mean, convert_log, convert_pow, convert_sqrt, convert_split , convert_cast then you should go to onnx2keras/operationlayers.py file and add there def convert_cast(node, params, layers, node_name, keras_name): """ """ if len(node.input) != 1: assert AttributeError('More than 1 input for log layer.')
input_0 = ensure_tf_type(layers[node.input[0]], name="%s_const" % keras_name)
dtype = params['to']
def target_layer(x):
import keras.backend as K
return K.cast(x, dtype)
lambda_layer = keras.layers.Lambda(target_layer, name=keras_name)
layers[node_name] = lambda_layer(input_0)
bingo!
Can you help increase the Cast operator? or Is there any way to increase the custome layer?