Сбой TFLite из Google Auto ML Edge Object Detection при вызовеPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Сбой TFLite из Google Auto ML Edge Object Detection при вызове

Сообщение Anonymous »

Я пытался использовать модель TFLite, полученную из Google Auto ML Object Detection для Edge. Мой скрипт выглядит так:
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)

Я следил за документацией здесь, но у меня произошел сбой в работе ноутбука. Искал на github stackoverflow и tensorflow, проблема все еще есть.
Вот мои input_details:
[{'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': {}}]

И мои выходные_детали:
[{'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': {}}]


Подробнее здесь: https://stackoverflow.com/questions/793 ... hen-invoke
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»