图像数据处理分析,保存模型,后面加载预测报错

# 保存最优模型
import pickle
best_model_index =results_df.reset_index()['Accuracy'].argmax()
best_model = models.append(best_model_index)
save_model_path ='./predict_pjupyter.pkl'
with open(save_model_path, 'wb') as f:
    pickle.dump(best_model, f)

# 预测数据
# 加载保存的模型
with open(save_model_path, 'rb') as f:
    predictor = pickle.load(f)

# 进行预测

imdb_id = 2544
img_path = os.path.join(poster_path, str(imdb_id) + '.jpg')
poster_feat = extract_hist_feat(img_path, n_feat_dim)
pred_result = predictor.predict(poster_feat.reshape(1, -1))
pred_genre = lab_enc.inverse_transform(pred_result)
1524465360653.png

要回复问题请先登录注册