def infer(data, rescale=RESCALE, resize_factor=RESIZE): ## test mode ##### DO NOT CHANGE ORDER OF TEST DATA ##### X = [] for i, d in enumerate(data): X.append(image_preprocessing(d, rescale, resize_factor)) X = np.array(X) p1 = m1.predict(X) X2 = [] for i, d in enumerate(data): X2.append(image_preprocessing2(d, rescale, resize_factor)) X2 = np.array(X2) p2 = m2.predict(X2) # X3 = [] # for i, d in enumerate(data): # X3.append(image_preprocessing3(d, rescale, resize_factor)) # X3 = np.array(X3) # p3 = m3.predict(X3) # X4 = [] # for i, d in enumerate(data): # X4.append(image_preprocessing4(d, rescale, resize_factor)) # X4 = np.array(X4) # p4 = m4.predict(X4) pp1 = [] for p in p1: p = new_softmax(p) pp1.append(p) pp2 = [] for p in p2: p = new_softmax(p) pp2.append(p) # pp3 = [] # for p in p3: # p = new_softmax(p) # pp3.append(p) # pp4 = [] # for p in p4: # p = new_softmax(p) # pp4.append(p) pp1 = np.array(pp1) pp2 = np.array(pp2) # pp3 = np.array(pp3) # pp4 = np.array(pp4) # X = (pp1 + pp2 + pp3 + pp4) / 4 X = (pp1 + pp2) / 2 pred = np.argmax(X, axis=-1) print('Prediction done!\n Saving the result...') return pred
def infer(data, rescale=RESCALE, resize_factor=RESIZE): ## test mode ##### DO NOT CHANGE ORDER OF TEST DATA ##### X = [] for i, d in enumerate(data): X.append(image_preprocessing(d, rescale, resize_factor)) X = np.array(X) pred = model.predict(X) print('Prediction done!\n Saving the result...') return pred
def infer(data, rescale=RESCALE, resize_factor=RESIZE): ## test mode ##### DO NOT CHANGE ORDER OF TEST DATA ##### X = [] for i, d in enumerate(data): # test 데이터를 training 데이터와 같이 전처리 하기 X.append(image_preprocessing(d, rescale, resize_factor)) X = np.array(X) pred = model.predict(X) # 모델 예측 결과: 0-3 pred = np.argmax(pred, axis=1) print('Prediction done!\n Saving the result...') return pred
def infer( data, target_resolution=TARGET_RESOLUTION, ): ## test mode ##### DO NOT CHANGE ORDER OF TEST DATA ##### X = [] for i, d in enumerate(data): # test 데이터를 training 데이터와 같이 전처리 하기 X.append(image_preprocessing(d, target_resolution, normalize=True)) X = np.array(X) pred = model.predict(X) pred = np.argmax(pred, axis=1) # 모델 예측 결과: 0-3 print('Prediction done!\n Saving the result...') return pred
def infer(data, rescale=RESCALE, resize_factor=RESIZE): ## test mode ##### DO NOT CHANGE ORDER OF TEST DATA ##### X = [] for i, d in enumerate(data): # test 데이터를 training 데이터와 같이 전처리 하기 X.append(image_preprocessing(d, rescale, resize_factor)) X = np.array(X) inception_pred = inception_model.predict(X) efficient_pred = efficient_model.predict(X) # mobilenet_pred = mobilenet_model.predict(X) # resnet_pred = resnet_model.predict(X) # densenet_pred = densenet_model.predict(X) pred = (inception_pred * inception_ratio + efficient_pred * efficient_ratio) # pred += (mobilenet_pred * mobilenet_ratio) # pred += (resnet_pred * resnet_ratio + densenet_pred * densenet_ratio) pred = np.argmax(pred, axis=1) print('Prediction done!\n Saving the result...') return pred