Я пытался использовать модель 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
Сбой TFLite из Google Auto ML Edge Object Detection при вызове ⇐ Python
Программы на Python
-
Anonymous
1735894119
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': {}}]
Подробнее здесь: [url]https://stackoverflow.com/questions/79325929/tflite-from-google-auto-ml-edge-object-detection-crash-when-invoke[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия