def parallel_testing(test_image, test_label, codebook, svm, scaler, pca): gray = io.load_grayscale_image(test_image) kpt, des = feature_extraction.dense(gray) labels = np.array([test_label] * des.shape[0]) ind = np.array([0] * des.shape[0]) vis_word, _ = bovw.visual_words(des, labels, ind, codebook) prediction_prob = classification.predict_svm(vis_word, svm, std_scaler=scaler, pca=pca) predicted_class = lin_svm.classes_[np.argmax(prediction_prob)] return predicted_class == test_label, predicted_class, np.ravel(prediction_prob)
def parallel_testing(test_image, test_label, codebook, svm, scaler, pca): gray = io.load_grayscale_image(test_image) kpt, des = feature_extraction.dense(gray) kpt_pos = np.array([kpt[i].pt for i in range(0, len(kpt))], dtype=np.float64) labels = np.array([test_label] * des.shape[0]) ind = np.array([0] * des.shape[0]) vis_word, _ = bovw.visual_words(des, labels, ind, codebook, spatial_pyramid=True) prediction_prob = classification.predict_svm(vis_word, svm, std_scaler=scaler, pca=pca) predicted_class = svm.classes_[np.argmax(prediction_prob)] return predicted_class == test_label, predicted_class, np.ravel(prediction_prob)
def parallel_testing(test_image, test_label, svm, scaler, gmm): gray = io.load_grayscale_image(test_image) kpt, des = feature_extraction.dense(gray) labels = np.array([test_label] * des.shape[0]) ind = np.array([0] * des.shape[0]) fisher, _ = bovw.fisher_vectors(des, labels, ind, gmm) prediction_prob = classification.predict_svm(fisher, svm, std_scaler=scaler) predicted_class = svm.classes_[np.argmax(prediction_prob)] return predicted_class == test_label, predicted_class, np.ravel(prediction_prob)