in eval_copy_detection.py [0:0]
def eval_result(self, ids, distances):
j0 = 0
for i in range(self.nblocks):
j1 = j0 + self.q_block_sizes[i]
block_name = self.block_names[i]
I = ids[j0:j1] # block size
sum_AP = 0
if block_name != 'strong':
# 1:1 mapping of files to names
positives_per_query = [[i] for i in range(j1 - j0)]
else:
originals = self.get_block_filenames('original')
strongs = self.get_block_filenames('strong')
# check if prefixes match
positives_per_query = [
[j for j, bname in enumerate(originals)
if bname[:4] == qname[:4]]
for qname in strongs]
for qno, Iline in enumerate(I):
positives = positives_per_query[qno]
ranks = []
for rank, bno in enumerate(Iline):
if bno in positives:
ranks.append(rank)
sum_AP += score_ap_from_ranks_1(ranks, len(positives))
print("eval on %s mAP=%.3f" % (
block_name, sum_AP / (j1 - j0)))
j0 = j1