Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Add env variable UPSAMPLE_COORDINATE_TRANSFORMATION_MODE #663

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 6 additions & 0 deletions keras2onnx/ke2onnx/upsample.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Licensed under the MIT License. See License.txt in the project root for
# license information.
###############################################################################
import os
import collections
from ..common.onnx_ops import apply_transpose, apply_upsample
from .common import get_permutation_config
Expand Down Expand Up @@ -70,6 +71,11 @@ def convert_keras_upsample(scope, operator, container, n_dims):
if coordinate_transformation_mode is None:
coordinate_transformation_mode = 'asymmetric'

# tflite uses 'asymmetric' mode not 'half_pixel', use the env variable as an option.
mode_env = os.environ.get('UPSAMPLE_COORDINATE_TRANSFORMATION_MODE', None)
if mode_env == 'asymmetric':
coordinate_transformation_mode = mode_env

if no_permutation_required:
apply_upsample(scope, input_tensor_name, operator.outputs[0].full_name, container,
mode=mode, coordinate_transformation_mode=coordinate_transformation_mode, scales=scales)
Expand Down