Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TODO] Improvement of tflite's I/O OP name rewriting process and I/O order control process #228

Closed
PINTO0309 opened this issue Mar 5, 2023 · 1 comment
Labels
feature request feature request

Comments

@PINTO0309
Copy link
Owner

PINTO0309 commented Mar 5, 2023

Issue Type

Others

onnx2tf version number

1.7.17

onnx version number

1.13.1

tensorflow version number

1.12.0rc0

Download URL for ONNX

https://github.com/PINTO0309/onnx2tf/releases/download/1.1.28/version-RFB-640.onnx

Parameter Replacement JSON

N/A

Description

  1. Personal
  2. Improvement of tflite's I/O OP name rewriting process and I/O order control process
    • Writing input/output information to tflite as signature_defs.
    • Rewrite binaries so that input/output names match ONNX using concrete_function.
    • -coion / --copy_onnx_input_output_names_to_tflite output tflite with options so that the signature is embedded in the tflite by default.
      image
      image
      import numpy as np
      import tensorflow as tf
      
      interpreter = tf.lite.Interpreter(
          model_path="version-RFB-640_float32.tflite"
      )
      tf_lite_model = interpreter.get_signature_runner()
      test_data = tf.convert_to_tensor(
          value=np.ones(
              shape=[1,480,640,3],
              dtype=np.float32
          )
      )
      tt_lite_output = tf_lite_model(
          input=test_data,
      )
      print("[TFLite] Model Predictions:", tt_lite_output)
      [TFLite] Model Predictions:
      {'boxes': array([[[ 1.3372814e-04,  8.5677393e-04,  1.3687836e-02,  2.6055152e-02],
              [-2.9060002e-03, -1.7406903e-03,  1.7976686e-02,  4.0702272e-02],
              [-5.9925802e-03, -8.2277283e-03,  2.4591457e-02,  5.8303714e-02],
              ...,
              [ 8.6583459e-01,  8.3152449e-01,  1.0436372e+00,  1.0488608e+00],
              [ 8.2547259e-01,  7.7981573e-01,  1.0946229e+00,  1.1140716e+00],
              [ 7.7743149e-01,  7.2188163e-01,  1.1553301e+00,  1.1767489e+00]]],
            dtype=float32),
       'scores': array([[[0.9121739 , 0.08782604],
              [0.9121672 , 0.0878328 ],
              [0.9121579 , 0.08784208],
              ...,
              [0.9487316 , 0.05126836],
              [0.96191823, 0.03808172],
              [0.96088   , 0.03912005]]], dtype=float32)}
      
    • Ref: https://www.tensorflow.org/lite/guide/signatures
@PINTO0309 PINTO0309 added the feature request feature request label Mar 5, 2023
@PINTO0309 PINTO0309 changed the title Improvement of tflite's I/O OP name rewriting process and I/O order control process [TODO] Improvement of tflite's I/O OP name rewriting process and I/O order control process Mar 5, 2023
@PINTO0309
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request feature request
Projects
None yet
Development

No branches or pull requests

1 participant