File size: 4,456 Bytes
352cafd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"from pycocotools.coco import COCO\n",
"from pycocotools.cocoeval import COCOeval\n",
"import numpy as np\n",
"import skimage.io as io\n",
"import pylab\n",
"pylab.rcParams['figure.figsize'] = (10.0, 8.0)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running demo for *bbox* results.\n"
]
}
],
"source": [
"annType = ['segm','bbox','keypoints']\n",
"annType = annType[1] #specify type here\n",
"prefix = 'person_keypoints' if annType=='keypoints' else 'instances'\n",
"print 'Running demo for *%s* results.'%(annType)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"loading annotations into memory...\n",
"Done (t=8.01s)\n",
"creating index...\n",
"index created!\n"
]
}
],
"source": [
"#initialize COCO ground truth api\n",
"dataDir='../'\n",
"dataType='val2014'\n",
"annFile = '%s/annotations/%s_%s.json'%(dataDir,prefix,dataType)\n",
"cocoGt=COCO(annFile)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading and preparing results... \n",
"DONE (t=0.05s)\n",
"creating index...\n",
"index created!\n"
]
}
],
"source": [
"#initialize COCO detections api\n",
"resFile='%s/results/%s_%s_fake%s100_results.json'\n",
"resFile = resFile%(dataDir, prefix, dataType, annType)\n",
"cocoDt=cocoGt.loadRes(resFile)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"imgIds=sorted(cocoGt.getImgIds())\n",
"imgIds=imgIds[0:100]\n",
"imgId = imgIds[np.random.randint(100)]"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running per image evaluation... \n",
"DONE (t=0.46s).\n",
"Accumulating evaluation results... \n",
"DONE (t=0.38s).\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.505\n",
" Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.697\n",
" Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.573\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.586\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.519\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.501\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.387\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.594\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.595\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.640\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.566\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.564\n"
]
}
],
"source": [
"# running evaluation\n",
"cocoEval = COCOeval(cocoGt,cocoDt,annType)\n",
"cocoEval.params.imgIds = imgIds\n",
"cocoEval.evaluate()\n",
"cocoEval.accumulate()\n",
"cocoEval.summarize()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
|