Update load.py
Browse files
load.py
CHANGED
|
@@ -53,28 +53,27 @@ def load_model(fl,input):
|
|
| 53 |
model = torch.load("net_gb.pt")
|
| 54 |
print(fl)
|
| 55 |
print(input)
|
| 56 |
-
input = torch.from_numpy(input).to(torch.float32)
|
| 57 |
# model.eval()
|
| 58 |
with torch.no_grad():
|
| 59 |
# output = model(torch.tensor([0.0,0.0,87.0,5.0,36.9,81.0,33.0,138.0,62.0,0.0,0.0,2.0,2.0,2.0,0.0,0.0,0.0,0.0,0.0,2.0,1.0,0.0,0.0,1.0,2.0,2.0,2.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,2.0,2.0,1.0]))
|
| 60 |
output = model(torch.tensor(input))
|
| 61 |
print(output)
|
| 62 |
# print(len([0.0,0.0,87.0,5.0,36.9,81.0,33.0,138.0,62.0,0.0,0.0,2.0,2.0,2.0,0.0,0.0,0.0,0.0,0.0,2.0,1.0,0.0,0.0,1.0,2.0,2.0,2.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,2.0,2.0,1.0]))
|
| 63 |
-
pridect_h1_y = torch.max(output,dim=
|
| 64 |
-
|
| 65 |
pridect_h1_label = pridect_h1_y.data.numpy()
|
| 66 |
print(pridect_h1_y)
|
| 67 |
-
if int(pridect_h1_label
|
| 68 |
return "FL predict: Height."
|
| 69 |
else:
|
| 70 |
return "FL predict: Low."
|
| 71 |
-
else:
|
| 72 |
model_h1 = torch.load("net_h1.pt")
|
| 73 |
model_h2 = torch.load("net_h2.pt")
|
| 74 |
model_h3 = torch.load("net_h3.pt")
|
| 75 |
print(fl)
|
| 76 |
print(input)
|
| 77 |
-
input = torch.from_numpy(input).to(torch.float32)
|
| 78 |
model_h1.eval()
|
| 79 |
model_h2.eval()
|
| 80 |
model_h3.eval()
|
|
@@ -88,11 +87,11 @@ def load_model(fl,input):
|
|
| 88 |
print(output_h3)
|
| 89 |
# print(len([0.0,0.0,87.0,5.0,36.9,81.0,33.0,138.0,62.0,0.0,0.0,2.0,2.0,2.0,0.0,0.0,0.0,0.0,0.0,2.0,1.0,0.0,0.0,1.0,2.0,2.0,2.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,2.0,2.0,1.0]))
|
| 90 |
# print(len(output_h1))
|
| 91 |
-
pridect_h1_y = torch.max(output_h1,dim =
|
| 92 |
pridect_h1_label = pridect_h1_y.data.numpy()
|
| 93 |
-
pridect_h2_y = torch.max(output_h2,dim =
|
| 94 |
pridect_h2_label = pridect_h2_y.data.numpy()
|
| 95 |
-
pridect_h3_y = torch.max(output_h3,dim =
|
| 96 |
pridect_h3_label = pridect_h3_y.data.numpy()
|
| 97 |
|
| 98 |
# print(pridect_h1_y)
|
|
@@ -102,20 +101,20 @@ def load_model(fl,input):
|
|
| 102 |
print(pridect_h2_label)
|
| 103 |
print(pridect_h3_label)
|
| 104 |
output = ""
|
| 105 |
-
if int(pridect_h1_label
|
| 106 |
print("sick")
|
| 107 |
output +="H1 predict: Height.\n"
|
| 108 |
else:
|
| 109 |
print("no sick")
|
| 110 |
output += "H1 predict: Low.\n"
|
| 111 |
-
if int(pridect_h2_label
|
| 112 |
print("sick")
|
| 113 |
output += "H2 predict: Height.\n"
|
| 114 |
|
| 115 |
else:
|
| 116 |
print("no sick")
|
| 117 |
output += "H2 predict: Low.\n"
|
| 118 |
-
if int(pridect_h3_label
|
| 119 |
print("sick")
|
| 120 |
output += "H3 predict: Height.\n"
|
| 121 |
|
|
@@ -125,6 +124,86 @@ def load_model(fl,input):
|
|
| 125 |
return output
|
| 126 |
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
# print(data_test_h1.train_data[0])
|
| 130 |
# print(len(data_test_h1.train_data))
|
|
|
|
| 53 |
model = torch.load("net_gb.pt")
|
| 54 |
print(fl)
|
| 55 |
print(input)
|
| 56 |
+
# input = torch.from_numpy(input).to(torch.float32)
|
| 57 |
# model.eval()
|
| 58 |
with torch.no_grad():
|
| 59 |
# output = model(torch.tensor([0.0,0.0,87.0,5.0,36.9,81.0,33.0,138.0,62.0,0.0,0.0,2.0,2.0,2.0,0.0,0.0,0.0,0.0,0.0,2.0,1.0,0.0,0.0,1.0,2.0,2.0,2.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,2.0,2.0,1.0]))
|
| 60 |
output = model(torch.tensor(input))
|
| 61 |
print(output)
|
| 62 |
# print(len([0.0,0.0,87.0,5.0,36.9,81.0,33.0,138.0,62.0,0.0,0.0,2.0,2.0,2.0,0.0,0.0,0.0,0.0,0.0,2.0,1.0,0.0,0.0,1.0,2.0,2.0,2.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,2.0,2.0,1.0]))
|
| 63 |
+
pridect_h1_y = torch.max(output,dim=0)[1]
|
|
|
|
| 64 |
pridect_h1_label = pridect_h1_y.data.numpy()
|
| 65 |
print(pridect_h1_y)
|
| 66 |
+
if int(pridect_h1_label)==1:
|
| 67 |
return "FL predict: Height."
|
| 68 |
else:
|
| 69 |
return "FL predict: Low."
|
| 70 |
+
else:#55 60
|
| 71 |
model_h1 = torch.load("net_h1.pt")
|
| 72 |
model_h2 = torch.load("net_h2.pt")
|
| 73 |
model_h3 = torch.load("net_h3.pt")
|
| 74 |
print(fl)
|
| 75 |
print(input)
|
| 76 |
+
# input = torch.from_numpy(input).to(torch.float32)
|
| 77 |
model_h1.eval()
|
| 78 |
model_h2.eval()
|
| 79 |
model_h3.eval()
|
|
|
|
| 87 |
print(output_h3)
|
| 88 |
# print(len([0.0,0.0,87.0,5.0,36.9,81.0,33.0,138.0,62.0,0.0,0.0,2.0,2.0,2.0,0.0,0.0,0.0,0.0,0.0,2.0,1.0,0.0,0.0,1.0,2.0,2.0,2.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,2.0,2.0,1.0]))
|
| 89 |
# print(len(output_h1))
|
| 90 |
+
pridect_h1_y = torch.max(output_h1,dim = 0)[1]
|
| 91 |
pridect_h1_label = pridect_h1_y.data.numpy()
|
| 92 |
+
pridect_h2_y = torch.max(output_h2,dim = 0)[1]
|
| 93 |
pridect_h2_label = pridect_h2_y.data.numpy()
|
| 94 |
+
pridect_h3_y = torch.max(output_h3,dim = 0)[1]
|
| 95 |
pridect_h3_label = pridect_h3_y.data.numpy()
|
| 96 |
|
| 97 |
# print(pridect_h1_y)
|
|
|
|
| 101 |
print(pridect_h2_label)
|
| 102 |
print(pridect_h3_label)
|
| 103 |
output = ""
|
| 104 |
+
if int(pridect_h1_label) == 1:
|
| 105 |
print("sick")
|
| 106 |
output +="H1 predict: Height.\n"
|
| 107 |
else:
|
| 108 |
print("no sick")
|
| 109 |
output += "H1 predict: Low.\n"
|
| 110 |
+
if int(pridect_h2_label) == 1:
|
| 111 |
print("sick")
|
| 112 |
output += "H2 predict: Height.\n"
|
| 113 |
|
| 114 |
else:
|
| 115 |
print("no sick")
|
| 116 |
output += "H2 predict: Low.\n"
|
| 117 |
+
if int(pridect_h3_label) == 1:
|
| 118 |
print("sick")
|
| 119 |
output += "H3 predict: Height.\n"
|
| 120 |
|
|
|
|
| 124 |
return output
|
| 125 |
|
| 126 |
|
| 127 |
+
# def load_model(fl,input):
|
| 128 |
+
# # data_test_h1 = GetDataSet()
|
| 129 |
+
# # data_test_h1.test_data[0] = input
|
| 130 |
+
# # input = data_test_h1.test_data
|
| 131 |
+
# if fl == "Yes":
|
| 132 |
+
# model = torch.load("net_gb.pt")
|
| 133 |
+
# print(fl)
|
| 134 |
+
# print(input)
|
| 135 |
+
# input = torch.from_numpy(input).to(torch.float32)
|
| 136 |
+
# # model.eval()
|
| 137 |
+
# with torch.no_grad():
|
| 138 |
+
# # output = model(torch.tensor([0.0,0.0,87.0,5.0,36.9,81.0,33.0,138.0,62.0,0.0,0.0,2.0,2.0,2.0,0.0,0.0,0.0,0.0,0.0,2.0,1.0,0.0,0.0,1.0,2.0,2.0,2.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,2.0,2.0,1.0]))
|
| 139 |
+
# output = model(torch.tensor(input))
|
| 140 |
+
# print(output)
|
| 141 |
+
# # print(len([0.0,0.0,87.0,5.0,36.9,81.0,33.0,138.0,62.0,0.0,0.0,2.0,2.0,2.0,0.0,0.0,0.0,0.0,0.0,2.0,1.0,0.0,0.0,1.0,2.0,2.0,2.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,2.0,2.0,1.0]))
|
| 142 |
+
# pridect_h1_y = torch.max(output,dim=1)[1]
|
| 143 |
+
|
| 144 |
+
# pridect_h1_label = pridect_h1_y.data.numpy()
|
| 145 |
+
# print(pridect_h1_y)
|
| 146 |
+
# if int(pridect_h1_label[0])==1:
|
| 147 |
+
# return "FL predict: Height."
|
| 148 |
+
# else:
|
| 149 |
+
# return "FL predict: Low."
|
| 150 |
+
# else:
|
| 151 |
+
# model_h1 = torch.load("net_h1.pt")
|
| 152 |
+
# model_h2 = torch.load("net_h2.pt")
|
| 153 |
+
# model_h3 = torch.load("net_h3.pt")
|
| 154 |
+
# print(fl)
|
| 155 |
+
# print(input)
|
| 156 |
+
# input = torch.from_numpy(input).to(torch.float32)
|
| 157 |
+
# model_h1.eval()
|
| 158 |
+
# model_h2.eval()
|
| 159 |
+
# model_h3.eval()
|
| 160 |
+
# with torch.no_grad():
|
| 161 |
+
# # output = model(torch.tensor(1.0,1.0,64.0,2.0,37.1,98.0,20.0,120.0,70.0,3.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,2.0,1.0,0.0,1.0,2.0,2.0,1.0,2.0,0.0,2.0,0.0,2.0,2.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0))
|
| 162 |
+
# output_h1 = model_h1(torch.tensor(input))
|
| 163 |
+
# output_h2 = model_h2(torch.tensor(input))
|
| 164 |
+
# output_h3 = model_h3(torch.tensor(input))
|
| 165 |
+
# print(output_h1)
|
| 166 |
+
# print(output_h2)
|
| 167 |
+
# print(output_h3)
|
| 168 |
+
# # print(len([0.0,0.0,87.0,5.0,36.9,81.0,33.0,138.0,62.0,0.0,0.0,2.0,2.0,2.0,0.0,0.0,0.0,0.0,0.0,2.0,1.0,0.0,0.0,1.0,2.0,2.0,2.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,2.0,2.0,1.0]))
|
| 169 |
+
# # print(len(output_h1))
|
| 170 |
+
# pridect_h1_y = torch.max(output_h1,dim = 1)[1]
|
| 171 |
+
# pridect_h1_label = pridect_h1_y.data.numpy()
|
| 172 |
+
# pridect_h2_y = torch.max(output_h2,dim = 1)[1]
|
| 173 |
+
# pridect_h2_label = pridect_h2_y.data.numpy()
|
| 174 |
+
# pridect_h3_y = torch.max(output_h3,dim = 1)[1]
|
| 175 |
+
# pridect_h3_label = pridect_h3_y.data.numpy()
|
| 176 |
+
|
| 177 |
+
# # print(pridect_h1_y)
|
| 178 |
+
# # print(pridect_h2_y)
|
| 179 |
+
# # print(pridect_h3_y)
|
| 180 |
+
# print(pridect_h1_label)
|
| 181 |
+
# print(pridect_h2_label)
|
| 182 |
+
# print(pridect_h3_label)
|
| 183 |
+
# output = ""
|
| 184 |
+
# if int(pridect_h1_label[0]) == 1:
|
| 185 |
+
# print("sick")
|
| 186 |
+
# output +="H1 predict: Height.\n"
|
| 187 |
+
# else:
|
| 188 |
+
# print("no sick")
|
| 189 |
+
# output += "H1 predict: Low.\n"
|
| 190 |
+
# if int(pridect_h2_label[0]) == 1:
|
| 191 |
+
# print("sick")
|
| 192 |
+
# output += "H2 predict: Height.\n"
|
| 193 |
+
|
| 194 |
+
# else:
|
| 195 |
+
# print("no sick")
|
| 196 |
+
# output += "H2 predict: Low.\n"
|
| 197 |
+
# if int(pridect_h3_label[0]) == 1:
|
| 198 |
+
# print("sick")
|
| 199 |
+
# output += "H3 predict: Height.\n"
|
| 200 |
+
|
| 201 |
+
# else:
|
| 202 |
+
# print("no sick")
|
| 203 |
+
# output += "H3 predict: Low.\n"
|
| 204 |
+
# return output
|
| 205 |
+
|
| 206 |
+
|
| 207 |
|
| 208 |
# print(data_test_h1.train_data[0])
|
| 209 |
# print(len(data_test_h1.train_data))
|