@@ -0,0 +1,1243 @@
+#!/usr/bin/env python%0A# -*- coding: utf-8 -*-%0A%0Aimport argparse%0Aimport cPickle as pickle%0Aimport gzip%0Aimport sys%0A%0Aimport cv2%0Afrom imagesift import get_sift_keypoints%0Aimport numpy as np%0Afrom sklearn.datasets import load_files%0Afrom sklearn.metrics import accuracy_score, classification_report%0Afrom sklearn.preprocessing import normalize%0A%0A%0Aparser = argparse.ArgumentParser()%0Aparser.add_argument('container_path')%0Aparser.add_argument('bof_path')%0Aparser.add_argument('clf_path')%0Aargs = parser.parse_args()%0A%0Acontainer_path = args.container_path%0Abof_path = args.bof_path%0Aclf_path = args.clf_path%0A%0Abunch_files = load_files(container_path=container_path,%0A                         description='images',%0A                         shuffle=False,%0A                         load_content=False)%0A%0Awith gzip.open(bof_path, 'rb') as f:%0A    bof = pickle.load(f)%0A%0Awith gzip.open(clf_path, 'rb') as f:%0A    clf = pickle.load(f)%0A%0Adescs = %5B%5D%0Afor fname in bunch_files.filenames:%0A    img = cv2.imread(fname, 0)%0A    _, desc = get_sift_keypoints(img)%0A    descs.append(desc)%0AX = bof.transform(descs)%0Anormalize(X, copy=False)%0Ay_pred = clf.predict(X)%0A%0Ay = bunch_files.target%0Aprint accuracy_score(y, y_pred)%0Aprint classification_report(y, y_pred, target_names=clf.target_names_)%0A

Add bof object recognition test script