Skip to content

Commit

Permalink
calcuate average precision for each category
Browse files Browse the repository at this point in the history
  • Loading branch information
kimyoon-young committed Jun 4, 2019
1 parent 0eb570d commit 9bd5159
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tools/cocoeval.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,16 @@ def _summarize( ap=1, iouThr=None, areaRng='all', maxDets=100 ):
mean_s = -1
else:
mean_s = np.mean(s[s>-1])

#cacluate AP(average precision) for each category
num_classes = 80
avg_ap = 0.0
for i in range(0,80):
print('category : {0} : {1}'.format(i,np.mean(s[:,:,i,:])))
avg_ap +=np.mean(s[:,:,i,:])
print('mAP : {}'.format(avg_ap / 80))
if ap == 1:
for i in range(0, num_classes):
print('category : {0} : {1}'.format(i,np.mean(s[:,:,i,:])))
avg_ap +=np.mean(s[:,:,i,:])
print('(all categories) mAP : {}'.format(avg_ap / num_classes))

print(iStr.format(titleStr, typeStr, iouStr, areaRng, maxDets, mean_s))
return mean_s
def _summarizeDets():
Expand Down

0 comments on commit 9bd5159

Please sign in to comment.