john000z commited on
Commit
fcd2a9f
·
1 Parent(s): 07ca9b5
Files changed (1) hide show
  1. utools.py +21 -0
utools.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tflite_runtime.interpreter as tflite
2
+ import tflite_runtime
3
+ import numpy as np
4
+ ROWS_PER_FRAME=543
5
+ def load_relevant_data_subset(df):
6
+ data_columns = ['x', 'y', 'z']
7
+ data=df[data_columns]
8
+ n_frames = int(len(data) / ROWS_PER_FRAME)#单个文件的总帧数
9
+ data = data.values.reshape(n_frames, ROWS_PER_FRAME, len(data_columns))
10
+ return data.astype(np.float32)
11
+
12
+ def mark_pred(model_path_1,aa):
13
+ interpreter = tflite.Interpreter(model_path_1)
14
+ found_signatures = list(interpreter.get_signature_list().keys())
15
+ prediction_fn = interpreter.get_signature_runner("serving_default")
16
+ output_1 = prediction_fn(inputs=aa)
17
+ return output_1
18
+
19
+ def softmax(x, axis=None):
20
+ x_exp = np.exp(x - np.max(x, axis=axis, keepdims=True))
21
+ return x_exp / np.sum(x_exp, axis=axis, keepdims=True)