예제 #1
0
import numpy as np

from sklearn.externals.joblib import Memory

from load import load_data
from descriptors import compute_boundary_desc, get_interest_points
from histograms import compute_visual_words
from retrieval import search, show_results

mem = Memory(cachedir='.')
postings = np.load('./data/postings.npy')
vocabulary = np.load('./data/vocabulary.npy')
image_names = np.load('./data/images.npy')

gen = load_data()
im, mask = gen.next()

interest_points = mem.cache(get_interest_points)(mask)
descriptors, _ = mem.cache(compute_boundary_desc)(im, mask, interest_points)
vw = compute_visual_words(descriptors, vocabulary)

results = search(vw, postings)

show_results(results, image_names)

# Awesome ! We're finding the the first image as best result !
예제 #2
0
파일: evaluate.py 프로젝트: NelleV/SORBB
    visual_words = compute_visual_words(desc, voc)
    if visual_words is None:
        continue

    #search_results = retrieval.search2(visual_words, postings, max_im=20)
    query_document, _ = np.histogram(visual_words,
                                     bins=np.arange(len(voc) + 1))
    search_results = retrieval2.search(query_document, max_im=20)
    #search_results2 = mem.cache(search2)(visual_words,postings,max_im=20)
    indices = search_results[:, 0].astype(int)
    search_file_names = all_names[indices]
    queries_total += 1

    ave_prec = average_precision(search_file_names, positive_file_names,
                                 ignore_file_names)
    mean_average_precision += ave_prec
    print "Prec: ", ave_prec
    if ave_prec > best_prec:
        best_query_file_name = query_file_name
        best_search_file_names = search_file_names
        best_prec = ave_prec
        best_results = search_results

mean_average_precision /= queries_total
retrieval.show_results(best_results,
                       best_search_file_names,
                       "%s (%f) mAP: %.2f" % (best_query_file_name,
                                              best_prec,
                                              mean_average_precision))
pass
예제 #3
0
파일: evaluate.py 프로젝트: SiChiTong/SORBB
    interest_points = mem.cache(get_interest_points)(mask)
    desc, coords = mem.cache(compute_boundary_desc)(im, mask, interest_points)
    visual_words = compute_visual_words(desc, voc)
    if visual_words is None:
        continue

    #search_results = retrieval.search2(visual_words, postings, max_im=20)
    query_document, _ = np.histogram(visual_words,
                                     bins=np.arange(len(voc) + 1))
    search_results = retrieval2.search(query_document, max_im=20)
    #search_results2 = mem.cache(search2)(visual_words,postings,max_im=20)
    indices = search_results[:, 0].astype(int)
    search_file_names = all_names[indices]
    queries_total += 1

    ave_prec = average_precision(search_file_names, positive_file_names,
                                 ignore_file_names)
    mean_average_precision += ave_prec
    print "Prec: ", ave_prec
    if ave_prec > best_prec:
        best_query_file_name = query_file_name
        best_search_file_names = search_file_names
        best_prec = ave_prec
        best_results = search_results

mean_average_precision /= queries_total
retrieval.show_results(
    best_results, best_search_file_names, "%s (%f) mAP: %.2f" %
    (best_query_file_name, best_prec, mean_average_precision))
pass