Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
disable NCHW option
Browse files Browse the repository at this point in the history
  • Loading branch information
PINTO0309 committed Feb 7, 2022
1 parent 07c97fe commit ad2146f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ usage: tflite2tensorflow
[--onnx_opset ONNX_OPSET]
[--onnx_extra_opset ONNX_EXTRA_OPSET]
[--disable_onnx_optimization]
[--disable_onnx_optimization]

This comment has been minimized.

Copy link
@PINTO0309

PINTO0309 Feb 7, 2022

Author Owner

It has been resolved in the next commit. It is reflected in the release.
00d714d

[--output_openvino_and_myriad]
[--vpu_number_of_shaves VPU_NUMBER_OF_SHAVES]
[--vpu_number_of_cmx_slices VPU_NUMBER_OF_CMX_SLICES]
Expand Down Expand Up @@ -419,6 +420,8 @@ optional arguments:
The name of the onnx 'extra_opset' to enable.
Default: ''
'com.microsoft:1' or 'ai.onnx.contrib:1' or 'ai.onnx.ml:1'
--disable_onnx_nchw_conversion
Disable onnx NCHW conversion
--disable_onnx_optimization
Disable onnx optimization
--output_openvino_and_myriad
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
setup(
name="tflite2tensorflow",
scripts=scripts,
version="1.18.3",
version="1.18.4",
description="Generate saved_model, tfjs, tf-trt, EdgeTPU, CoreML, quantized tflite, ONNX, OpenVINO, Myriad Inference Engine blob and .pb from .tflite.",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
12 changes: 10 additions & 2 deletions tflite2tensorflow/tflite2tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5553,6 +5553,7 @@ def main():
parser.add_argument('--output_onnx', action='store_true', help='onnx model output switch')
parser.add_argument('--onnx_opset', type=int, default=13, help='onnx opset version number')
parser.add_argument('--onnx_extra_opset', type=str, default='', help='The name of the onnx extra_opset to enable. Default: \'\'. "com.microsoft:1" or "ai.onnx.contrib:1" or "ai.onnx.ml:1"')
parser.add_argument('--disable_onnx_nchw_conversion', action='store_true', help='Disable onnx NCHW conversion.')
parser.add_argument('--disable_onnx_optimization', action='store_true', help='Disable onnx optimization.')
parser.add_argument('--output_openvino_and_myriad', action='store_true', help='openvino model and myriad inference engine blob output switch')
parser.add_argument('--vpu_number_of_shaves', type=int, default=4, help='vpu number of shaves. Default: 4')
Expand Down Expand Up @@ -5600,6 +5601,7 @@ def main():
output_onnx = args.output_onnx
onnx_opset = args.onnx_opset
onnx_extra_opset = args.onnx_extra_opset
use_onnx_nchw_conversion = not args.disable_onnx_nchw_conversion
use_onnx_optimization = not args.disable_onnx_optimization
output_openvino_and_myriad = args.output_openvino_and_myriad
vpu_number_of_shaves = args.vpu_number_of_shaves
Expand Down Expand Up @@ -6279,8 +6281,11 @@ def input_fn():
'--saved-model', model_output_path,
'--opset', str(onnx_opset),
'--output', f'{model_output_path}/model_float32.onnx',
'--inputs-as-nchw', f'{inputs}'
]
if use_onnx_nchw_conversion:
onnx_convert_command.append(
'--inputs-as-nchw', f'{inputs}'
)
else:
onnx_convert_command = \
[
Expand All @@ -6290,8 +6295,11 @@ def input_fn():
'--opset', str(onnx_opset),
'--output', f'{model_output_path}/model_float32.onnx',
'--extra_opset', onnx_extra_opset,
'--inputs-as-nchw', f'{inputs}'
]
if use_onnx_nchw_conversion:
onnx_convert_command.append(
'--inputs-as-nchw', f'{inputs}'
)
result = subprocess.check_output(
onnx_convert_command,
stderr=subprocess.PIPE
Expand Down

0 comments on commit ad2146f

Please sign in to comment.