Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions onnx2keras/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@
'Pad': convert_padding,
'Flatten': convert_flatten,
'Upsample': convert_upsample,
'Resize': convert_upsample
}
5 changes: 5 additions & 0 deletions onnx2keras/operation_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def convert_clip(node, params, layers, lambda_func, node_name, keras_name):

input_0 = ensure_tf_type(layers[node.input[0]], name="%s_const" % keras_name)

if 'min' not in params or 'max' not in params:
node_input_data = [layers[attr] for attr in node.input[1:]]
max_attr, min_attr = max(node_input_data), min(node_input_data)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If min only omitted - max will be replaced. Is ts correct behavior?

params["max"], params["min"] = max_attr, min_attr

if params['min'] == 0:
logger.debug("Using ReLU({0}) instead of clip".format(params['max']))
layer = keras.layers.ReLU(max_value=params['max'], name=keras_name)
Expand Down
3 changes: 2 additions & 1 deletion onnx2keras/upsampling_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def convert_upsample(node, params, layers, lambda_func, node_name, keras_name):
else:
# for opset version - 9+
# Upsample since opset version 9 uses input[1] as 'scales' instead of attributes.
scale = np.uint8(layers[node.input[1]][-2:])
#
scale = np.uint8(layers[node.input[2]][-2:])

if params['mode'].decode('utf-8') != 'nearest':
logger.error('Cannot convert non-nearest upsampling.')
Expand Down