Skip to content

Format mismatch in dummy onnx inference #929

Description

@harikrishnan-kp

Issue Type

Others

OS

Linux

onnx2tf version number

2.4.0

onnx version number

1.20.1

onnxruntime version number

1.24.3

onnxsim (onnx_simplifier) version number

0.6.3

tensorflow version number

2.21.0

Download URL for ONNX

Repository: https://github.com/motokimura/yolox-ti-lite_tflite
ONNX export script used for conversion: https://github.com/motokimura/yolox-ti-lite_tflite/blob/main/tools/export_onnx.py
Model variant used: nano

Parameter Replacement JSON

NA

Description

I was trying to export a YOLOX-TI-Lite Nano ONNX model from motokimura/yolox-ti-lite_tflite to TFLite with full integer quantization using the following command:

onnx2tf -i yolox-ti-lite_nano.onnx -o saved_model -tb tf_converter -oiqt -cind images calib_data_500x416x416.npy "[[[[0,0,0]]]]" "[[[[1,1,1]]]]"

However, during conversion I received the following warning logs:

INFO: input_op_name: images shape: [1, 3, 416, 416] dtype: float32
onnxruntime output memmap enabled. Outputs: 201, Path: /tmp/onnx2tf_ort_mm_kspra4k8
WARNING: The optimization process for shape estimation is skipped because it contains OPs that cannot be inferred by the standard onnxruntime.
WARNING: Error in execution: Got invalid dimensions for input: images for the following indices
 index: 1 Got: 416 Expected: 3
 index: 3 Got: 3 Expected: 416
 Please fix either the inputs/outputs or the model.

The generated TFLite model also contains additional Transpose operations before and after Concat layers, whereas the original ONNX model does not contain these transpose nodes.

I would like clarification on the following:

  • Are the inserted Transpose operations added by onnx2tf to handle layout conversion internally?
  • Could the invalid dimension warning be the reason for the extra transpose operations being inserted around concatenation layers?
  • Is this behavior indicate an incorrect conversion/export pipeline?
Image

I also need some clarification regarding calibration data generation for PTQ. According to the onnx2tf CLI paramter documentation https://github.com/PINTO0309/onnx2tf#cli-parameter , the calibration images should be pre-normalized to the 0–1 range. However, when I perform PTQ using normalized calibration data, the exported TFLite model produces incorrect objectness/confidence outputs, resulting in near-zero detection scores during postprocessing. On the other hand, using non-normalized calibration data (original image range) appears to work correctly. Which preprocessing approach should be followed in this case?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions