onnx / onnx-tensorflow

Tensorflow Backend for ONNX
Other
1.28k stars 296 forks source link

Resize error #1009

Open HemanthSingh opened 2 years ago

HemanthSingh commented 2 years ago

When I export onnx model to tensorflow using the following code:

import onnx
from onnx_tf.backend import prepare

onnx_model = onnx.load("PtMaskRCNN-leaves.onnx")
tf_rep = prepare(onnx_model)
tf_rep.export_graph("model.pb")

following run time error occurs:

File "C:\darknet\data\temp.py", line 18, in tf_rep.export_graph("model.pb")

File "C:\ProgramData\Anaconda3\lib\site-packages\onnx_tf\backend_rep.py", line 132, in export_graph signatures=self.tf_module.call.get_concrete_function(

File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\def_function.py", line 1264, in get_concrete_function concrete = self._get_concrete_function_garbage_collected(*args, **kwargs)

File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\def_function.py", line 1244, in _get_concrete_function_garbage_collected self._initialize(args, kwargs, add_initializers_to=initializers)

File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\def_function.py", line 785, in _initialize self._stateful_fn._get_concrete_function_internal_garbage_collected( # pylint: disable=protected-access

File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\function.py", line 2983, in _get_concrete_function_internal_garbage_collected graphfunction, = self._maybe_define_function(args, kwargs)

File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\function.py", line 3292, in _maybe_define_function graph_function = self._create_graph_function(args, kwargs)

File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\function.py", line 3130, in _create_graph_function func_graph_module.func_graph_from_py_func(

File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\func_graph.py", line 1161, in func_graph_from_py_func func_outputs = python_func(*func_args, **func_kwargs)

File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\def_function.py", line 677, in wrapped_fn out = weak_wrapped_fn().wrapped(*args, **kwds)

File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\function.py", line 3831, in bound_method_wrapper return wrapped_fn(*args, **kwargs)

File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\func_graph.py", line 1147, in autograph_handler raise e.ag_error_metadata.to_exception(e)

RuntimeError: in user code:

File "C:\ProgramData\Anaconda3\lib\site-packages\onnx_tf\backend_tf_module.py", line 99, in __call__  *
    output_ops = self.backend._onnx_node_to_tensorflow_op(onnx_node,
File "C:\ProgramData\Anaconda3\lib\site-packages\onnx_tf\backend.py", line 333, in _onnx_node_to_tensorflow_op  *
    return handler.handle(node, tensor_dict=tensor_dict, strict=strict)
File "C:\ProgramData\Anaconda3\lib\site-packages\onnx_tf\handlers\handler.py", line 58, in handle  *
    cls.args_check(node, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\onnx_tf\handlers\backend\resize.py", line 125, in args_check  *
    exception.OP_UNSUPPORTED_EXCEPT(
File "C:\ProgramData\Anaconda3\lib\site-packages\onnx_tf\common\exception.py", line 50, in __call__  *
    raise self._func(self.get_message(op, framework))

RuntimeError: Resize coordinate_transformation_mode=pytorch_half_pixel is not supported in Tensorflow.

Version info:

Python version:
3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)]
ONNX version:
1.11.0
ONNX-TF version:
1.9.0
Tensorflow version:
2.8.0
chinhuang007 commented 2 years ago

There is no mapping for coordinate_transformation_mode=pytorch_half_pixel therefore a known limitation in converting Resize operator.

putizi-super commented 2 years ago

How can I resolve this problem? I can't do it.

MohamedAliRashad commented 2 years ago

Is there any solution for this bug ?

FabioRomagnolo commented 2 years ago

This is an old problem I've already solved. Fix here: https://github.com/onnx/onnx-tensorflow/issues/632

amarese commented 2 years ago

This is an old problem I've already solved. Fix here: #632

can I get onnx_utils.py. from your repo ?

FabioRomagnolo commented 2 years ago

This is an old problem I've already solved. Fix here: #632

can I get onnx_utils.py. from your repo ?

You can get it here. I know, it's a lot of code and maybe the conversion to int_32 is also bugged, but take just the functions you need.