Skip to content

Commit

Permalink
add lvis example
Browse files Browse the repository at this point in the history
  • Loading branch information
MiXaiLL76 committed Jun 19, 2024
1 parent 7dff204 commit de79b57
Showing 1 changed file with 187 additions and 51 deletions.
238 changes: 187 additions & 51 deletions examples/lvis_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"metadata": {},
"outputs": [],
"source": [
"iouType = \"segm\""
"iouType = \"bbox\""
]
},
{
Expand All @@ -50,40 +50,22 @@
"metadata": {},
"outputs": [
{
"name": "stdout",
"name": "stderr",
"output_type": "stream",
"text": [
"Evaluate annotation type *segm*\n",
"COCOeval_opt.evaluate() finished...\n",
"DONE (t=1.43s).\n",
"Accumulating evaluation results...\n",
"COCOeval_opt.accumulate() finished...\n",
"DONE (t=0.39s).\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds=all] = 0.132\n",
" Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=300 catIds=all] = 0.373\n",
" Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=300 catIds=all] = 0.069\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=300 catIds=all] = 0.090\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=300 catIds=all] = 0.144\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=300 catIds=all] = 0.204\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= r] = 0.000\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= c] = 0.127\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= f] = 0.134\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds=all] = 0.164\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=300 catIds=all] = 0.109\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=300 catIds=all] = 0.176\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=300 catIds=all] = 0.249\n",
" Average Recall (AR) @[ IoU=0.50 | area= all | maxDets=300 catIds=all] = 0.449\n",
" Average Recall (AR) @[ IoU=0.75 | area= all | maxDets=300 catIds=all] = 0.092\n"
"INFO:lvis.lvis:Loading annotations.\n",
"INFO:lvis.lvis:Creating index.\n",
"INFO:lvis.lvis:Index created.\n",
"INFO:lvis.results:Loading and preparing results.\n",
"INFO:lvis.results:Creating index.\n",
"INFO:lvis.results:Index created.\n"
]
}
],
"source": [
"cocoGt = COCO(prepared_coco_in_dict)\n",
"cocoDt = cocoGt.loadRes(prepared_anns)\n",
"from lvis import LVISEval\n",
"\n",
"cocoEval = COCOeval_faster(cocoGt, cocoDt, iouType, lvis_style=True, print_function=print)\n",
"cocoEval.params.maxDets = [300]\n",
"cocoEval.run()"
"lvis_eval = LVISEval(\"../tests/lvis_dataset/lvis_val_100.json\", \"../tests/lvis_dataset/lvis_results_100.json\", iouType)"
]
},
{
Expand All @@ -95,44 +77,198 @@
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:lvis.lvis:Loading annotations.\n",
"INFO:lvis.lvis:Creating index.\n",
"INFO:lvis.lvis:Index created.\n",
"INFO:lvis.results:Loading and preparing results.\n",
"INFO:lvis.results:Creating index.\n",
"INFO:lvis.results:Index created.\n",
"INFO:lvis.eval:Running per image evaluation.\n",
"INFO:lvis.eval:Evaluate annotation type *segm*\n",
"INFO:lvis.eval:Evaluate annotation type *bbox*\n",
"INFO:lvis.eval:COCOeval_opt._prepare() finished...\n",
"INFO:lvis.eval:DONE (t=0.01s).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 766 ms, sys: 32 ms, total: 798 ms\n",
"Wall time: 794 ms\n"
]
}
],
"source": [
"%%time\n",
"\n",
"lvis_eval.evaluate()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:lvis.eval:Accumulating evaluation results.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds=all] = 0.132\n",
" Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=300 catIds=all] = 0.373\n",
" Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=300 catIds=all] = 0.069\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= s | maxDets=300 catIds=all] = 0.090\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= m | maxDets=300 catIds=all] = 0.144\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= l | maxDets=300 catIds=all] = 0.204\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= r] = 0.000\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= c] = 0.127\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= f] = 0.134\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds=all] = 0.164\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= s | maxDets=300 catIds=all] = 0.109\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= m | maxDets=300 catIds=all] = 0.176\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= l | maxDets=300 catIds=all] = 0.249\n"
"CPU times: user 111 ms, sys: 2.12 ms, total: 114 ms\n",
"Wall time: 113 ms\n"
]
}
],
"source": [
"from lvis import LVISEval\n",
"%%time\n",
"\n",
"lvis_eval = LVISEval(\"../tests/lvis_dataset/lvis_val_100.json\", \"../tests/lvis_dataset/lvis_results_100.json\", \"segm\")\n",
"lvis_eval.run()\n",
"lvis_eval.accumulate()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 22.5 ms, sys: 21.4 ms, total: 43.8 ms\n",
"Wall time: 42.8 ms\n"
]
}
],
"source": [
"%%time\n",
"\n",
"lvis_eval.summarize()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds=all] = 0.368\n",
" Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=300 catIds=all] = 0.626\n",
" Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=300 catIds=all] = 0.384\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= s | maxDets=300 catIds=all] = 0.301\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= m | maxDets=300 catIds=all] = 0.438\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= l | maxDets=300 catIds=all] = 0.447\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= r] = 0.000\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= c] = 0.274\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= f] = 0.388\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds=all] = 0.430\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= s | maxDets=300 catIds=all] = 0.345\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= m | maxDets=300 catIds=all] = 0.488\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= l | maxDets=300 catIds=all] = 0.515\n"
]
}
],
"source": [
"lvis_eval.print_results()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"cocoGt = COCO(prepared_coco_in_dict)\n",
"cocoDt = cocoGt.loadRes(prepared_anns)\n",
"\n",
"cocoEval = COCOeval_faster(cocoGt, cocoDt, iouType, lvis_style=True, print_function=print)\n",
"cocoEval.params.maxDets = [300]"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Evaluate annotation type *bbox*\n",
"COCOeval_opt._prepare() finished...\n",
"DONE (t=0.01s).\n",
"COCOeval_opt.evaluate() finished...\n",
"DONE (t=0.63s).\n",
"CPU times: user 581 ms, sys: 53.2 ms, total: 634 ms\n",
"Wall time: 631 ms\n"
]
}
],
"source": [
"%%time\n",
"\n",
"cocoEval.evaluate()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Accumulating evaluation results...\n",
"COCOeval_opt.accumulate() finished...\n",
"DONE (t=0.00s).\n",
"CPU times: user 42 µs, sys: 20 µs, total: 62 µs\n",
"Wall time: 59.6 µs\n"
]
}
],
"source": [
"%%time\n",
"\n",
"cocoEval.accumulate()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds=all] = 0.368\n",
" Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=300 catIds=all] = 0.626\n",
" Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=300 catIds=all] = 0.384\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=300 catIds=all] = 0.301\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=300 catIds=all] = 0.438\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=300 catIds=all] = 0.447\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= r] = 0.000\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= c] = 0.274\n",
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= f] = 0.388\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds=all] = 0.430\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=300 catIds=all] = 0.345\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=300 catIds=all] = 0.488\n",
" Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=300 catIds=all] = 0.515\n",
" Average Recall (AR) @[ IoU=0.50 | area= all | maxDets=300 catIds=all] = 0.720\n",
" Average Recall (AR) @[ IoU=0.75 | area= all | maxDets=300 catIds=all] = 0.445\n",
"CPU times: user 31.7 ms, sys: 8.7 ms, total: 40.4 ms\n",
"Wall time: 39.5 ms\n"
]
}
],
"source": [
"%%time\n",
"\n",
"cocoEval.summarize()"
]
}
],
"metadata": {
Expand Down

0 comments on commit de79b57

Please sign in to comment.