-
Notifications
You must be signed in to change notification settings - Fork 0
/
readSave2.py
executable file
·53 lines (47 loc) · 1.79 KB
/
readSave2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#from tensorflow import keras
import numpy as np
import keras
#from keras.datasets import imdb
#from keras.models import Sequential
#from keras.layers import LSTM
#from keras.layers.embeddings import Embedding
#from keras.preprocessing import sequence
from sklearn.metrics import confusion_matrix, precision_score
#from sklearn.model_selection import train_test_split
#from keras.layers import Dense,Dropout
#from keras.regularizers import l2
#import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
model = keras.models.load_model('modelSave2')
print(model.summary())
while True:
datafile = "testnew2"
x_data = pd.read_csv(datafile+"X.csv",names=['s1','s2','s3','s4','s5'])
# print(x_data)
# y_dataR = np.genfromtxt(datafile+"Y.csv",delimiter=',',dtype=int)
# num_classes = np.max(y_dataR) + 1
# y_data = keras.utils.to_categorical(y_dataR, num_classes)
#x_train, x_test, y_train, y_test = train_test_split(x_data,y_data, test_size=0.20, random_state=0)
#x_train = x_data[:880]
x_test = x_data[880:]
#y_train = y_data[:880]
# y_test = y_data[880:]
#x_train.shape,y_train.shape,x_test.shape,y_test.shape
#print('Training Accuracy : ' , np.mean(model.history["accuracy"]))
#print('Validation Accuracy : ' , np.mean(model.history["val_accuracy"]))
y_pred = model.predict(x_test)
#print(x_test)
#y_pred = model.predict(np.array([[400,400,400,400,400]]*50))
rounded = [np.argmax(x) for x in y_pred]
# y_testComp = [np.argmax(x) for x in y_test]
# print(confusion_matrix(y_testComp,rounded))
gestures = {
1: "relax",
2: "extend",
3: "fist",
4: "one",
5: "transition"
}
print(rounded[-1])
print("Gesture: "+gestures[rounded[-1]])