from sklearn.externals import joblib from sklearn.model_selection import train_test_split import numpy as np import cv2 import pylab as pl path = u'testingData16.txt' data0 = np.loadtxt(path,dtype = str,delimiter = ' ') data = np.array( [[row[i] for i in range(0, 8) if i != 7] for row in data0] )#del the last col of the array x = data[:,(1,2,3,4,5,6)] y = data[:,0] x = np.uint8(x) y = np.uint8(y) x_train, x_test, y_train, y_test = train_test_split(x, y, random_state=1, train_size=0.6) #X = data[:,(1,2,3,4)] X = x clf = joblib.load("train_model_Adaboost.m") y_hat = clf.predict(X) print type(y_hat) print type(y_hat[2]) img = np.reshape(y_hat,(584,565)) cv2.imshow('img',img) cv2.waitKey(0)