11 "%matplotlib inline\n",
12 "import matplotlib.pyplot as plt\n",
13 "from pycocotools.coco import COCO\n",
14 "from pycocotools.cocoeval import COCOeval\n",
15 "import numpy as np\n",
16 "import skimage.io as io\n",
18 "pylab.rcParams['figure.figsize'] = (10.0, 8.0)"
30 "output_type": "stream",
32 "Running demo for *bbox* results.\n"
37 "annType = ['segm','bbox','keypoints']\n",
38 "annType = annType[1] #specify type here\n",
39 "prefix = 'person_keypoints' if annType=='keypoints' else 'instances'\n",
40 "print 'Running demo for *%s* results.'%(annType)"
52 "output_type": "stream",
54 "loading annotations into memory...\n",
56 "creating index...\n",
62 "#initialize COCO ground truth api\n",
64 "dataType='val2014'\n",
65 "annFile = '%s/annotations/%s_%s.json'%(dataDir,prefix,dataType)\n",
66 "cocoGt=COCO(annFile)"
78 "output_type": "stream",
80 "Loading and preparing results... \n",
82 "creating index...\n",
88 "#initialize COCO detections api\n",
89 "resFile='%s/results/%s_%s_fake%s100_results.json'\n",
90 "resFile = resFile%(dataDir, prefix, dataType, annType)\n",
91 "cocoDt=cocoGt.loadRes(resFile)"
102 "imgIds=sorted(cocoGt.getImgIds())\n",
103 "imgIds=imgIds[0:100]\n",
104 "imgId = imgIds[np.random.randint(100)]"
109 "execution_count": 6,
116 "output_type": "stream",
118 "Running per image evaluation... \n",
120 "Accumulating evaluation results... \n",
122 " Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.505\n",
123 " Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.697\n",
124 " Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.573\n",
125 " Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.586\n",
126 " Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.519\n",
127 " Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.501\n",
128 " Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.387\n",
129 " Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.594\n",
130 " Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.595\n",
131 " Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.640\n",
132 " Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.566\n",
133 " Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.564\n"
138 "# running evaluation\n",
139 "cocoEval = COCOeval(cocoGt,cocoDt,annType)\n",
140 "cocoEval.params.imgIds = imgIds\n",
141 "cocoEval.evaluate()\n",
142 "cocoEval.accumulate()\n",
143 "cocoEval.summarize()"
149 "display_name": "Python 2",
150 "language": "python",
158 "file_extension": ".py",
159 "mimetype": "text/x-python",
161 "nbconvert_exporter": "python",
162 "pygments_lexer": "ipython2",