Holistic-john / utools.py
john000z's picture
py
fcd2a9f
raw
history blame contribute delete
818 Bytes
import tflite_runtime.interpreter as tflite
import tflite_runtime
import numpy as np
ROWS_PER_FRAME=543
def load_relevant_data_subset(df):
data_columns = ['x', 'y', 'z']
data=df[data_columns]
n_frames = int(len(data) / ROWS_PER_FRAME)#单个文件的总帧数
data = data.values.reshape(n_frames, ROWS_PER_FRAME, len(data_columns))
return data.astype(np.float32)
def mark_pred(model_path_1,aa):
interpreter = tflite.Interpreter(model_path_1)
found_signatures = list(interpreter.get_signature_list().keys())
prediction_fn = interpreter.get_signature_runner("serving_default")
output_1 = prediction_fn(inputs=aa)
return output_1
def softmax(x, axis=None):
x_exp = np.exp(x - np.max(x, axis=axis, keepdims=True))
return x_exp / np.sum(x_exp, axis=axis, keepdims=True)