Skip to content

Commit

Permalink
[MAJOR UPDATE] cocoeval.py: adding python detection evaluation code
Browse files Browse the repository at this point in the history
  • Loading branch information
tylin committed Jul 8, 2015
1 parent ad455af commit 93e0a8e
Show file tree
Hide file tree
Showing 2 changed files with 409 additions and 0 deletions.
39 changes: 39 additions & 0 deletions PythonAPI/pycocoEvalDemo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
__author__ = 'tsungyi'

import os
import sys
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval
import numpy as np
import skimage.io as io
import matplotlib.pyplot as plt
import json
import mask

##Demo demonstrating the algorithm result formats for COCO
##select results type for demo (either bbox or segm)
annType = ['segm','bbox']
annType = annType[0] #specify type here
print 'Running demo for *%s* results.\n\n'%annType

##initialize COCO ground truth api
dataDir='../'
dataType='val2014'
annFile = '%s/annotations/instances_%s.json'%(dataDir,dataType)
cocoGt=COCO(annFile)

##initialize COCO detections api
resFile='%s/results/instances_%s_fake%s100_results.json'
resFile = resFile%(dataDir, dataType, annType)
cocoDt=cocoGt.loadRes(resFile)

##run Coco evaluation code (see CocoEval.m)
cocoEval = COCOeval(cocoGt,cocoDt)
imgIds = sorted(cocoGt.getImgIds())
imgIds = imgIds[0:100]
cocoEval.params.imgIds = imgIds
cocoEval.params.useSegm = (annType == 'segm')
cocoEval.params.useCats = True
cocoEval.evaluate()
cocoEval.accumulate()
print cocoEval
Loading

0 comments on commit 93e0a8e

Please sign in to comment.