@@ -403,9 +403,15 @@ def call_tflite(inp):
403
403
with open (onnx_name , "rb" ) as f :
404
404
model_onnx = onnx .load (f )
405
405
406
- call_tflite (imgs [0 ])
406
+ interpreter_details = tf .lite .Interpreter (tname , experimental_preserve_all_tensors = True )
407
+ input_details = interpreter_details .get_input_details ()
408
+ index_in = input_details [0 ]['index' ]
409
+ interpreter_details .allocate_tensors ()
410
+ interpreter_details .set_tensor (index_in , imgs [0 ])
411
+ interpreter_details .invoke ()
412
+ details = interpreter_details .get_tensor_details ()
413
+
407
414
inputs = {input_name : imgs [0 ]}
408
- details = interpreter .get_tensor_details ()
409
415
names_index = {}
410
416
for tt in details :
411
417
names_index [tt ['name' ]] = (tt ['index' ], tt ['quantization' ], tt ['quantization_parameters' ])
@@ -414,7 +420,7 @@ def call_tflite(inp):
414
420
for name_tfl , name_ort in names :
415
421
index = names_index [name_tfl ]
416
422
417
- tfl_value = interpreter .get_tensor (index [0 ])
423
+ tfl_value = interpreter_details .get_tensor (index [0 ])
418
424
419
425
new_name = onnx_name + ".%s.onnx" % name_ort .replace (":" , "_" ).replace (";" , "_" ).replace ("/" , "_" )
420
426
if not os .path .exists (new_name ):
0 commit comments