tensor data is null. run allocate_tensors() first
일반 데스크탑 x86환경에서는
output_data = interpreter.get_tensor(output_details[0]['index'])
하면 최종 결과값나오고
output_data = interpreter.get_tensor(output_details[0]['index']-1)
하면 이전 레이어 feature 값 나오지만 arm환경에서는 안됌
h5 -> tflite로 변환하기전에 미리 잘라서 변환하면 해결
from tensorflow import keras
import tensorflow as tf
from tensorflow.keras.models import Model
model = keras.models.load_model('*.h5', compile=False)
print(model.summary())
model = Model(inputs=model.input, outputs=model.get_layer('flatten_12').output)
model.save('save', save_format="tf")
saved_model_dir = './save'
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS,
tf.lite.OpsSet.SELECT_TF_OPS]
tflite_model = converter.convert()
open('tflite/nose.tflite', 'wb').write(tflite_model)
tensor data is null. run allocate_tensors() first
(IP보기클릭)106.101.***.***
존나 지성이 느껴지는 글이다 너 유게이가 아니구나!
(IP보기클릭)49.161.***.***
나중에 까먹으면 다시 보려고 블로그에도 올리는데 유게에 올리고 막 몇달뒤에보면 조회수 많이 늘어있길래 유게에도올림 | 23.02.07 18:26 | | |