Skip to content

TFLite Conversion Issue: Missing "builtin_options_type" and Correct Conversion Method #6

@songzhibo1

Description

@songzhibo1

I am currently working with a PyTorch model and converting it to TFLite. However, when I input the resulting TFLite model into ModelObfuscator, an error arises. The JSON file generated for the converted TFLite model contains many operators that lack the "builtin_options_type" field. This leads to issues during the conversion process, as I cannot locate the "builtin_options_type" for the operators. I have observed the same issue with the SqueezeNet model. However, the provided SqueezeNet TFLite file includes the "builtin_options_type" for each operator, while the TFLite model I converted does not.

  1. Could you kindly clarify where the TFLite file in your code is sourced from?
  2. What would be the correct approach for converting a TFLite file from PyTorch?

Traceback (most recent call last):
File "/Code275/obfuscation.py", line 109, in
jsontext = lib_generator(model_json, interpreter, inout_list)
File "/Code275/model_parser.py", line 508, in lib_generator
kwargs = get_attributes_params(op, interpreter)
File "/Code275/model_parser.py", line 69, in get_attributes_params
if op['builtin_options_type'] == 'Conv2DOptions' or op['builtin_options_type'] == 'DepthwiseConv2DOptions':
KeyError: 'builtin_options_type'

"operators": [
{
"inputs": [
0,
53
],
"outputs": [
56
]
},
{
"opcode_index": 1,
"inputs": [
56,
52,
18
],
"outputs": [
57
],
"builtin_options_type": "Conv2DOptions",
"builtin_options": {
"padding": "VALID",
"stride_w": 2,
"stride_h": 2,
"fused_activation_function": "RELU"
}
},

I would appreciate your guidance on this matter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions