def SIFTPredictor(self, gray_img, SVMModel, km): gray_img = np.float32(gray_img) f, d = SIFTExtractor.extractSIFT(gray_img) if np.shape(f)[1] == 0: print("skipped") return (100, 0) # # plt.imshow(gray_img) # Xc = f[0,:] # Yc = f[1,:] # plt.scatter(x=Xc,y=Yc,c='r',s=40) # plt.show() tempvar = km.predict(np.transpose(d)) hist = (np.histogram(tempvar, range(1, km.n_clusters + 1))) testData = hist[0] predictedLabel = SVMModel.predict(testData) predictedProbabilities = SVMModel.predict_proba(testData) return (predictedLabel, predictedProbabilities)
def SIFTPredictor(self, gray_img, SVMModel, km): gray_img = np.float32(gray_img) f, d = SIFTExtractor.extractSIFT(gray_img) if np.shape(f)[1] == 0: print ("skipped") return (100, 0) # # plt.imshow(gray_img) # Xc = f[0,:] # Yc = f[1,:] # plt.scatter(x=Xc,y=Yc,c='r',s=40) # plt.show() tempvar = km.predict(np.transpose(d)) hist = np.histogram(tempvar, range(1, km.n_clusters + 1)) testData = hist[0] predictedLabel = SVMModel.predict(testData) predictedProbabilities = SVMModel.predict_proba(testData) return (predictedLabel, predictedProbabilities)
def testSIFT(gray_img, SVMModel, km): f, d = ex.extractSIFT(gray_img) if np.shape(f)[1] == 0: print("skipped") return (100, 0) plt.imshow(gray_img) Xc = f[0, :] Yc = f[1, :] plt.scatter(x=Xc, y=Yc, c='r', s=40) plt.show() tempvar = km.predict(np.transpose(d)) hist = (np.histogram(tempvar, range(1, km.n_clusters + 1))) testData = hist[0] predictedLabel = SVMModel.predict(testData) predictedProbabilities = SVMModel.predict_proba(testData) return (predictedLabel, predictedProbabilities)
def testSIFT(gray_img, SVMModel, km): f,d = ex.extractSIFT(gray_img) if np.shape(f)[1]==0: print("skipped") return (100,0) plt.imshow(gray_img) Xc = f[0,:] Yc = f[1,:] plt.scatter(x=Xc,y=Yc,c='r',s=40) plt.show() tempvar = km.predict(np.transpose(d)) hist = (np.histogram(tempvar,range(1,km.n_clusters+1))) testData = hist[0] predictedLabel = SVMModel.predict(testData) predictedProbabilities = SVMModel.predict_proba(testData) return (predictedLabel,predictedProbabilities)