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

[Deformable DETR] RuntimeError: tensorflow/lite/kernels/gather.cc:132 indices_has_only_positive_elements was not true.gather index out of boundsNode number 5885 (GATHER) failed to invoke. #275

Closed
On-JungWoan opened this issue Mar 30, 2023 · 11 comments
Labels
Bug bug OP:Gather OP:Gather OP:GridSample OP:GridSample OP:Slice OP:Slice

Comments

@On-JungWoan
Copy link
Contributor

On-JungWoan commented Mar 30, 2023

Issue Type

Others

onnx2tf version number

1.8.3

onnx version number

1.13.1

tensorflow version number

2.12.0rc0

Download URL for ONNX

https://drive.google.com/file/d/1vPjV012QsZXt72VySjXG4hbeEnzdUHi7/view?usp=sharing

Parameter Replacement JSON

replace.json
{
  "format_version": 1,
  "operations": [
    {
      "op_name": "Reshape_2075",
      "param_target": "outputs",
      "param_name": "value",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Split_2150",
      "param_target": "attributes",
      "param_name": "axis",
      "values": 3
    },
    {
      "op_name": "Split_2150",
      "param_target": "inputs",
      "param_name": "split",
      "values": [8352, 2088, 522, 135]
    },

    {
      "op_name": "Reshape_2294",
      "param_target": "outputs",
      "param_name": "value_l_.11",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_2255",
      "param_target": "outputs",
      "param_name": "value_l_.7",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_2216",
      "param_target": "outputs",
      "param_name": "value_l_.3",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_2177",
      "param_target": "outputs",
      "param_name": "value_l_",
      "post_process_transpose_perm": [0,2,3,1]
    },


    {
      "op_name": "Reshape_2421",
      "param_target": "outputs",
      "param_name": "value.3",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Split_2500",
      "param_target": "attributes",
      "param_name": "axis",
      "values": 3
    },
    {
      "op_name": "Split_2500",
      "param_target": "inputs",
      "param_name": "split",
      "values": [8352, 2088, 522, 135]
    },

    {
      "op_name": "Reshape_2640",
      "param_target": "outputs",
      "param_name": "value_l_.27",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_2602",
      "param_target": "outputs",
      "param_name": "value_l_.23",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_2564",
      "param_target": "outputs",
      "param_name": "value_l_.19",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_2526",
      "param_target": "outputs",
      "param_name": "value_l_.15",
      "post_process_transpose_perm": [0,2,3,1]
    },


    {
      "op_name": "Reshape_2765",
      "param_target": "outputs",
      "param_name": "value.7",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Split_2844",
      "param_target": "attributes",
      "param_name": "axis",
      "values": 3
    },
    {
      "op_name": "Split_2844",
      "param_target": "inputs",
      "param_name": "split",
      "values": [8352, 2088, 522, 135]
    },

    {
      "op_name": "Reshape_2984",
      "param_target": "outputs",
      "param_name": "value_l_.43",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_2946",
      "param_target": "outputs",
      "param_name": "value_l_.39",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_2908",
      "param_target": "outputs",
      "param_name": "value_l_.35",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_2870",
      "param_target": "outputs",
      "param_name": "value_l_.31",
      "post_process_transpose_perm": [0,2,3,1]
    },

    {
      "op_name": "Reshape_3109",
      "param_target": "outputs",
      "param_name": "value.11",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Split_3188",
      "param_target": "attributes",
      "param_name": "axis",
      "values": 3
    },
    {
      "op_name": "Split_3188",
      "param_target": "inputs",
      "param_name": "split",
      "values": [8352, 2088, 522, 135]
    },

    {
      "op_name": "Reshape_3328",
      "param_target": "outputs",
      "param_name": "value_l_.59",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_3290",
      "param_target": "outputs",
      "param_name": "value_l_.55",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_3252",
      "param_target": "outputs",
      "param_name": "value_l_.51",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_3214",
      "param_target": "outputs",
      "param_name": "value_l_.47",
      "post_process_transpose_perm": [0,2,3,1]
    },


    {
      "op_name": "Reshape_3453",
      "param_target": "outputs",
      "param_name": "value.15",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Split_3532",
      "param_target": "attributes",
      "param_name": "axis",
      "values": 3
    },
    {
      "op_name": "Split_3532",
      "param_target": "inputs",
      "param_name": "split",
      "values": [8352, 2088, 522, 135]
    },

    {
      "op_name": "Reshape_3672",
      "param_target": "outputs",
      "param_name": "value_l_.75",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_3634",
      "param_target": "outputs",
      "param_name": "value_l_.71",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_3596",
      "param_target": "outputs",
      "param_name": "value_l_.67",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_3558",
      "param_target": "outputs",
      "param_name": "value_l_.63",
      "post_process_transpose_perm": [0,2,3,1]
    },


    {
      "op_name": "Reshape_3797",
      "param_target": "outputs",
      "param_name": "value.19",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Split_3876",
      "param_target": "attributes",
      "param_name": "axis",
      "values": 3
    },
    {
      "op_name": "Split_3876",
      "param_target": "inputs",
      "param_name": "split",
      "values": [8352, 2088, 522, 135]
    },

    {
      "op_name": "Reshape_4016",
      "param_target": "outputs",
      "param_name": "value_l_.91",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_3978",
      "param_target": "outputs",
      "param_name": "value_l_.87",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_3940",
      "param_target": "outputs",
      "param_name": "value_l_.83",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_3902",
      "param_target": "outputs",
      "param_name": "value_l_.79",
      "post_process_transpose_perm": [0,2,3,1]
    },


    {
      "op_name": "Reshape_4332",
      "param_target": "outputs",
      "param_name": "value.27",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Split_4411",
      "param_target": "attributes",
      "param_name": "axis",
      "values": 3
    },
    {
      "op_name": "Split_4411",
      "param_target": "inputs",
      "param_name": "split",
      "values": [8352, 2088, 522, 135]
    },

    {
      "op_name": "Reshape_4551",
      "param_target": "outputs",
      "param_name": "value_l_.107",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_4513",
      "param_target": "outputs",
      "param_name": "value_l_.103",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_4475",
      "param_target": "outputs",
      "param_name": "value_l_.99",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_4437",
      "param_target": "outputs",
      "param_name": "value_l_.95",
      "post_process_transpose_perm": [0,2,3,1]
    },


    {
      "op_name": "Reshape_4930",
      "param_target": "outputs",
      "param_name": "value.35",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Split_5026",
      "param_target": "attributes",
      "param_name": "axis",
      "values": 3
    },
    {
      "op_name": "Split_5026",
      "param_target": "inputs",
      "param_name": "split",
      "values": [8352, 2088, 522, 135]
    },

    {
      "op_name": "Reshape_5166",
      "param_target": "outputs",
      "param_name": "value_l_.123",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_5128",
      "param_target": "outputs",
      "param_name": "value_l_.119",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_5090",
      "param_target": "outputs",
      "param_name": "value_l_.115",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_5052",
      "param_target": "outputs",
      "param_name": "value_l_.111",
      "post_process_transpose_perm": [0,2,3,1]
    },


    {
      "op_name": "Reshape_4930",
      "param_target": "outputs",
      "param_name": "value.35",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Split_5026",
      "param_target": "attributes",
      "param_name": "axis",
      "values": 3
    },
    {
      "op_name": "Split_5026",
      "param_target": "inputs",
      "param_name": "split",
      "values": [8352, 2088, 522, 135]
    },

    {
      "op_name": "Reshape_5166",
      "param_target": "outputs",
      "param_name": "value_l_.123",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_5128",
      "param_target": "outputs",
      "param_name": "value_l_.119",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_5090",
      "param_target": "outputs",
      "param_name": "value_l_.115",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_5052",
      "param_target": "outputs",
      "param_name": "value_l_.111",
      "post_process_transpose_perm": [0,2,3,1]
    },


    {
      "op_name": "Reshape_5464",
      "param_target": "outputs",
      "param_name": "value.43",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Split_5560",
      "param_target": "attributes",
      "param_name": "axis",
      "values": 3
    },
    {
      "op_name": "Split_5560",
      "param_target": "inputs",
      "param_name": "split",
      "values": [8352, 2088, 522, 135]
    },

    {
      "op_name": "Reshape_5700",
      "param_target": "outputs",
      "param_name": "value_l_.139",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_5662",
      "param_target": "outputs",
      "param_name": "value_l_.135",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_5624",
      "param_target": "outputs",
      "param_name": "value_l_.131",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_5586",
      "param_target": "outputs",
      "param_name": "value_l_.127",
      "post_process_transpose_perm": [0,2,3,1]
    },


    {
      "op_name": "Reshape_5998",
      "param_target": "outputs",
      "param_name": "value.51",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Split_6094",
      "param_target": "attributes",
      "param_name": "axis",
      "values": 3
    },
    {
      "op_name": "Split_6094",
      "param_target": "inputs",
      "param_name": "split",
      "values": [8352, 2088, 522, 135]
    },

    {
      "op_name": "Reshape_6234",
      "param_target": "outputs",
      "param_name": "value_l_.155",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_6196",
      "param_target": "outputs",
      "param_name": "value_l_.151",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_6158",
      "param_target": "outputs",
      "param_name": "value_l_.147",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_6120",
      "param_target": "outputs",
      "param_name": "value_l_.143",
      "post_process_transpose_perm": [0,2,3,1]
    },


    {
      "op_name": "Reshape_6532",
      "param_target": "outputs",
      "param_name": "value.59",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Split_6628",
      "param_target": "attributes",
      "param_name": "axis",
      "values": 3
    },
    {
      "op_name": "Split_6628",
      "param_target": "inputs",
      "param_name": "split",
      "values": [8352, 2088, 522, 135]
    },

    {
      "op_name": "Reshape_6768",
      "param_target": "outputs",
      "param_name": "value_l_.171",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_6730",
      "param_target": "outputs",
      "param_name": "value_l_.167",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_6692",
      "param_target": "outputs",
      "param_name": "value_l_.163",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_6654",
      "param_target": "outputs",
      "param_name": "value_l_.159",
      "post_process_transpose_perm": [0,2,3,1]
    },

    {
      "op_name": "Reshape_7066",
      "param_target": "outputs",
      "param_name": "value.67",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Split_7162",
      "param_target": "attributes",
      "param_name": "axis",
      "values": 3
    },
    {
      "op_name": "Split_7162",
      "param_target": "inputs",
      "param_name": "split",
      "values": [8352, 2088, 522, 135]
    },

    {
      "op_name": "Reshape_7302",
      "param_target": "outputs",
      "param_name": "value_l_.187",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_7264",
      "param_target": "outputs",
      "param_name": "value_l_.183",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_7226",
      "param_target": "outputs",
      "param_name": "value_l_.179",
      "post_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Reshape_7188",
      "param_target": "outputs",
      "param_name": "value_l_.175",
      "post_process_transpose_perm": [0,2,3,1]
    },


    {
      "op_name": "Slice_4661",
      "param_target": "outputs",
      "param_name": "onnx::Add_5249",
      "post_process_transpose_perm": [0,2,1]
    },
    {
      "op_name": "Add_4679",
      "param_target": "outputs",
      "param_name": "onnx::Expand_5269",
      "post_process_transpose_perm": [0,2,1]
    },

    {
      "op_name": "Mul_4762",
      "param_target": "inputs",
      "param_name": "onnx::Mul_5348",
      "pre_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Mul_5003",
      "param_target": "inputs",
      "param_name": "onnx::Mul_5583",
      "pre_process_transpose_perm": [0,2,3,4,5,1]
    },


    {
      "op_name": "Mul_5296",
      "param_target": "inputs",
      "param_name": "onnx::Mul_5887",
      "pre_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Mul_5537",
      "param_target": "inputs",
      "param_name": "onnx::Mul_6122",
      "pre_process_transpose_perm": [0,2,3,4,5,1]
    },


    {
      "op_name": "Mul_5830",
      "param_target": "inputs",
      "param_name": "onnx::Mul_6426",
      "pre_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Mul_6071",
      "param_target": "inputs",
      "param_name": "onnx::Mul_6661",
      "pre_process_transpose_perm": [0,2,3,4,5,1]
    },

    {
      "op_name": "Mul_6364",
      "param_target": "inputs",
      "param_name": "onnx::Mul_6965",
      "pre_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Mul_6605",
      "param_target": "inputs",
      "param_name": "onnx::Mul_7200",
      "pre_process_transpose_perm": [0,2,3,4,5,1]
    },

    {
      "op_name": "Mul_6898",
      "param_target": "inputs",
      "param_name": "onnx::Mul_7504",
      "pre_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Mul_7139",
      "param_target": "inputs",
      "param_name": "onnx::Mul_7739",
      "pre_process_transpose_perm": [0,2,3,4,5,1]
    },


    {
      "op_name": "Mul_7432",
      "param_target": "inputs",
      "param_name": "onnx::Mul_8043",
      "pre_process_transpose_perm": [0,2,3,1]
    },
    {
      "op_name": "Mul_7673",
      "param_target": "inputs",
      "param_name": "onnx::Mul_8278",
      "pre_process_transpose_perm": [0,2,3,4,5,1]
    },




    {
      "op_name": "Slice_7492",
      "param_target": "outputs",
      "param_name": "onnx::Add_8109",
      "post_process_transpose_perm": [0,2,1]
    },
    {
      "op_name": "Add_7493",
      "param_target": "outputs",
      "param_name": "onnx::Expand_8110",
      "post_process_transpose_perm": [0,2,1]
    },

    {
      "op_name": "Reshape_6756",
      "param_target": "inputs",
      "param_name": "4216",
      "values": [2,135,256]
    },
    {
      "op_name": "Reshape_6768",
      "param_target": "inputs",
      "param_name": "4218",
      "values": [16,32,9,15]
    }
  ]
}

Description

HI, @PINTO0309. I am a researcher at a Korean IT company, and I have been working on converting Deformable DETR into a TFLite model for product development purposes. After many attempts, I was finally able to generate the TFLite model. Unfortunately, I have run into an error while trying to perform inference with the model.

onnx2tf -i one_input_simple.onnx -prf replace_split.json

For this model, the following fails:

problem

1-1) the error I get

I believe that the error may have originated from tensorflow/lite/kernels/gather.cc, as it seems to occur when the index value of the gather op with number 5885 is below 0.

Exception has occurred: RuntimeError
tensorflow/lite/kernels/gather.cc:132 indices_has_only_positive_elements was not true.gather index out of boundsNode number 5885 (GATHER) failed to invoke.
  File "/data/ojw/convert/inference_tflite.py", line 195, in main
    interpreter.invoke()
  File "/data/ojw/convert/inference_tflite.py", line 232, in <module>
    main(args)
RuntimeError: tensorflow/lite/kernels/gather.cc:132 indices_has_only_positive_elements was not true.gather index out of boundsNode number 5885 (GATHER) failed to invoke.

1-2) tensorflow/lite/kernels/gather.cc

image


1-3) op name

image


1-4) log

Upon examining the log, it appears that only the shape parameter of the reshape op has an index value lower than zero.

download link : https://drive.google.com/file/d/1XwE8r7l5Jgfr3UufYOMC8WpUmurQIODf/view?usp=sharing

  • In reshape op

    image

    and so on...


1-5) Attempt

I am attempting the following method, but I am unable to resolve the error.

    { 
      "op_name": "Reshape_6756",
      "param_target": "inputs",
      "param_name": "4216",
      "values": [2,135,256]
    },
    {
      "op_name": "Reshape_6768",
      "param_target": "inputs",
      "param_name": "4218",
      "values": [16,32,9,15]
    }

1-6) Script

import torch
import tensorflow as tf

TFLITE_PATH = '/data/ojw/convert/conversion/tf_tflite/tflite/test2.tflite'

# Load the TFLite model and allocate tensors.
interpreter = tf.lite.Interpreter(model_path=TFLITE_PATH)
interpreter.allocate_tensors()
# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()        

interpreter.set_tensor(
    input_details[0]['index'],
    torch.randn(input_details[0]['shape'].tolist())
)
interpreter.invoke()


I'm experiencing some trouble with an error that has been persisting since March. I was wondering if you could kindly assist me with this issue? I would be very grateful for your help in resolving this matter.

@PINTO0309 PINTO0309 added OP:Gather OP:Gather OP:GridSample OP:GridSample Bug bug labels Mar 30, 2023
@PINTO0309
Copy link
Owner

PINTO0309 commented Mar 30, 2023

First, I know that there is a bug in the GridSample conversion in the issue posted just before. This is 5 hours before you posted this issue. In order to identify the problem area, we need to fix the bug in GridSample first.

[GridSample] GridSample operation gives different outputs between onnx and tflite models #274

image

The model is too large and it will take time to fix the bugs. Once we break ONNX down into smaller components, it may be faster to investigate. (You don't have to do anything in particular, but it is going to take me a very long time to do my research.)

@PINTO0309
Copy link
Owner

PINTO0309 commented Mar 31, 2023

  • Gather
    • Improved Gather to disable negative indexes as much as possible
    • Before
      image
    • After
      image

image

@PINTO0309
Copy link
Owner

image

@PINTO0309
Copy link
Owner

Fixes: https://github.com/PINTO0309/onnx2tf/releases/tag/1.8.7

@On-JungWoan
Copy link
Contributor Author

Hi, @PINTO0309. I sincerely appreciate your assistance. Thanks to your guidance, I was able to successfully match the output of ONNX and TFLite. However, I am currently facing an error while performing inference using the TFLite model.

the error that I encountered:

image

Inference script:

TFLITE_PATH = 'one_input_simple_float16.tflite'

interpreter = tf.lite.Interpreter(model_path=TFLITE_PATH)
interpreter.allocate_tensors() ## This is the point where the error occurs. ##

input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()    

input = torch.randn(input_details[0]['shape'].tolist())        

interpreter.set_tensor(
    input_details[0]['index'],
    input
)
interpreter.invoke()

Could you please advise me on how to solve this issue? I apologize for bothering you.

@PINTO0309
Copy link
Owner

PINTO0309 commented Mar 31, 2023

The error message indicates how to deal with the problem. It is not an onnx2tf issue. Do not enter a 6-dimensional tensor in StridedSlice.

  • Slice_5002, Slice_4991
    image

  • tflite
    image

@PINTO0309
Copy link
Owner

  • Step.1
    • Enhancements to prevent Slice with more than 6 dimensions from being converted to FlexStridedSlice.
    • Implement only the simplest Flex avoidance workaround.
    • Compress only dimensions of size 1 before Slice.
  • Before
    image
  • After
    image

@PINTO0309
Copy link
Owner

Fixes: https://github.com/PINTO0309/onnx2tf/releases/tag/1.8.10

@On-JungWoan
Copy link
Contributor Author

I am pleased to inform you that I have successfully completed the conversion process. Your assistance has been invaluable to me, and I cannot thank you enough for your help. Thank you so much.

@On-JungWoan
Copy link
Contributor Author

On-JungWoan commented Apr 3, 2023

Hi @PINTO0309! I could see that all outputs matched when I used -cotof -cotoa 1e-4. However, when I visualized the output of the TFLite model(in real image&mask input), I noticed that it differed from the ONNX output.

aa_480

How can I solve this problem?

Below is my inference scripts:

import torch
import numpy as np
import tensorflow as tf

TFLITE_PATH = '/data/ojw/_/one_input_simple_float32.tflite'


# Load the TFLite model and allocate tensors.
interpreter = tf.lite.Interpreter(model_path=TFLITE_PATH)
interpreter.allocate_tensors()
# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()    


input = my_input        

interpreter.set_tensor(
    input_details[0]['index'],
    np.transpose(input.cpu(), (0,2,3,1)).numpy()
)

interpreter.invoke()

print(
    'max_score : ', torch.Tensor(interpreter.get_tensor(output_details[0]['index'])).cuda().sigmoid().max()
)

# postprocess
tmp = []
for i in range(12):
    tmp.append(torch.Tensor(interpreter.get_tensor(output_details[i]['index'])).cuda())

I'm so sorry to bothring you.

@PINTO0309
Copy link
Owner

I would like to see a separate issue for a topic that differs from the original issue. Mixing multiple topics in a closed issue is confusing to other engineers.

Repository owner locked as resolved and limited conversation to collaborators Apr 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug bug OP:Gather OP:Gather OP:GridSample OP:GridSample OP:Slice OP:Slice
Projects
None yet
Development

No branches or pull requests

2 participants