result = classifier.predict(kyc_test_image)
kyc_training_set.class_indices
if result[0][0] == 1:
prediction = 'pan'
else:
prediction = 'driv'
kyc_model = classifier
import pickle
modelname = 'cnn_kyc'
outfile = open(modelname,'wb')
pickle.dump(kyc_model,outfile)
outfile.close()
TypeError Traceback (most recent call last)
<ipython-input-35-865fb4ce2e0b> in <module>
----> 1 pickle.dump(kyc_model,outfile)
2 outfile.close()
TypeError: can't pickle _thread._local objects
第二种方法
from sklearn.externals import joblib
joblib.dump(kyc_model, 'cnn_kyc.pkl')
cnn_from_joblib = joblib.load('cnn_kyc.pkl')
cnn_from_joblib.predict(kyc_test_image)
导入joblib#保存模型
path_name =“ ../../../”#一些路径
model_name ='model_name.sav'#我认为将其保存为sav格式可能会帮助y
joblib.dump(模型,路径名+模型名)
joblib.load(路径名+型号名)