TFLite von Google Auto ML Edge Object Detection stürzt beim Aufrufen abPython

Python-Programme
Guest
 TFLite von Google Auto ML Edge Object Detection stürzt beim Aufrufen ab

Post by Guest »

Ich habe versucht, das von Google Auto ML Object Detection for Edge erhaltene Model TFLite zu verwenden. Mein Skript sieht so aus:

Code: Select all

import pandas as pd
import tensorflow as tf
import numpy as np

model_path = "model.tflite"

import tensorflow as tf

interpreter = tf.lite.Interpreter(model_path=model_path)
interpreter.allocate_tensors()
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
input_shape = input_details[0]["shape"]

image_path = "image.jpg"

with tf.io.gfile.GFile(image_path, "rb") as f:
content = f.read()
test_image = tf.io.decode_jpeg(content)

print("Test Image shape", test_image.shape) #The output was Test Image shape (1248, 936, 3)

test_image = tf.image.resize(test_image, (192, 192))
test_image = tf.cast(test_image, dtype=tf.uint8).numpy()
print("Test Image Shape New", test_image.shape, test_image.dtype) #The output was Test Image Shape New (192, 192, 3) uint8

data = np.expand_dims(test_image, axis=0)
interpreter.set_tensor(input_details[0]["index"], test_image)
interpreter.invoke() #Crash when Invoke
softmax = interpreter.get_tensor(output_details[0]["index"])
label = np.argmax(softmax)
Ich habe die Dokumentation hier befolgt, aber mein Notebook stürzt ab. Ich habe über Stackoverflow und Tensorflow Github gesucht, das Problem besteht immer noch.
Hier sind meine Eingabedetails:

Code: Select all

[{'name': 'normalized_input_image_tensor',
'index': 0,
'shape': array([  1, 192, 192,   3], dtype=int32),
'shape_signature': array([  1, 192, 192,   3], dtype=int32),
'dtype': numpy.uint8,
'quantization': (0.0078125, 128),
'quantization_parameters': {'scales': array([0.0078125], dtype=float32),
'zero_points': array([128], dtype=int32),
'quantized_dimension': 0},
'sparsity_parameters': {}}]
Und meine Ausgabedetails:

Code: Select all

[{'name': 'TFLite_Detection_PostProcess',
'index': 544,
'shape': array([  1, 107,   4], dtype=int32),
'shape_signature': array([  1, 107,   4], dtype=int32),
'dtype': numpy.float32,
'quantization': (0.0, 0),
'quantization_parameters': {'scales': array([], dtype=float32),
'zero_points': array([], dtype=int32),
'quantized_dimension': 0},
'sparsity_parameters': {}},
{'name': 'TFLite_Detection_PostProcess:1',
'index': 545,
'shape': array([  1, 107], dtype=int32),
'shape_signature': array([  1, 107], dtype=int32),
'dtype': numpy.float32,
'quantization': (0.0, 0),
'quantization_parameters': {'scales': array([], dtype=float32),
'zero_points': array([], dtype=int32),
'quantized_dimension': 0},
'sparsity_parameters': {}},
{'name': 'TFLite_Detection_PostProcess:2',
'index': 546,
'shape': array([  1, 107], dtype=int32),
'shape_signature': array([  1, 107], dtype=int32),
'dtype': numpy.float32,
'quantization': (0.0, 0),
'quantization_parameters': {'scales': array([], dtype=float32),
'zero_points': array([], dtype=int32),
'quantized_dimension': 0},
'sparsity_parameters': {}},
{'name': 'TFLite_Detection_PostProcess:3',
'index': 547,
'shape': array([1], dtype=int32),
'shape_signature': array([1], dtype=int32),
'dtype': numpy.float32,
'quantization': (0.0, 0),
'quantization_parameters': {'scales': array([], dtype=float32),
'zero_points': array([], dtype=int32),
'quantized_dimension': 0},
'sparsity_parameters': {}}]

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post