This project was forked from rafaelpadilla/Object-Detection-Metrics.
Development of object_detection_metrics happens on GitHub: https://github.com/yfpeng/object_detection_metrics
The latest object_detection_metrics releases are available over pypi.
Getting started
Installing object_detection_metrics
$ pip install object_detection_metrics
Reading COCO file
from podm import coco_decoder
with open('tests/sample/groundtruths_coco.json') as fp:
gold_dataset = coco_decoder.load_true_object_detection_dataset(fp)
PASCAL VOC Metrics
from podm import coco_decoder
from podm.metrics import get_pascal_voc_metrics, MetricPerClass, get_bounding_boxes
with open('tests/sample/groundtruths_coco.json') as fp:
gold_dataset = coco_decoder.load_true_object_detection_dataset(fp)
with open('tests/sample/detections_coco.json') as fp:
pred_dataset = coco_decoder.load_pred_object_detection_dataset(fp, gold_dataset)
gt_BoundingBoxes = get_bounding_boxes(gold_dataset)
pd_BoundingBoxes = get_bounding_boxes(pred_dataset)
results = get_pascal_voc_metrics(gt_BoundingBoxes, pd_BoundingBoxes, .5)
ap, precision, recall, tp, fp, etc
for cls, metric in results.items():
label = metric.label
print('ap', metric.ap)
print('precision', metric.precision)
print('interpolated_recall', metric.interpolated_recall)
print('interpolated_precision', metric.interpolated_precision)
print('tp', metric.tp)
print('fp', metric.fp)
print('num_groundtruth', metric.num_groundtruth)
print('num_detection', metric.num_detection)
mAP
from podm.metrics import MetricPerClass
mAP = MetricPerClass.mAP(results)
IoU
from podm.box import Box, intersection_over_union
box1 = Box.of_box(0., 0., 10., 10.)
box2 = Box.of_box(1., 1., 11., 11.)
intersection_over_union(box1, box2)
Official COCO Eval
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval
coco_gld = COCO('tests/sample/groundtruths_coco.json')
coco_rst = coco_gld.loadRes('tests/sample/detections_coco.json')
cocoEval = COCOeval(coco_gld, coco_rst, iouType='bbox')
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()
Implemented metrics
- Intersection Over Union (IOU)
- TP and FP
- True Positive (TP): IOU ≥ IOU threshold (default: 0.5)
- False Positive (FP): IOU < IOU threshold (default: 0.5)
- Precision and Recall
- Average Precision
- 11-point AP
- all-point AP
- Official COCO Eval
License
Copyright BioNLP Lab at Weill Cornell Medicine, 2022.
Distributed under the terms of the MIT license, this is free and open source software.
Metadata
Release files for object-detection-metrics 0.4.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| object-detection-metrics-0.4.post1.tar.gz | 14.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| object_detection_metrics-0.4.post1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.2 kB
Release files / object-detection-metrics-0.4.post1.tar.gz
| Download URL | object-detection-metrics-0.4.post1.tar.gz |
|---|---|
| Size | 14.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
552ab6f737026c86ecb738400e533634a62d05e32f5f87e0112cbdcdc47e90e4
|
|
BLAKE2b-256 checksum How to use checksums |
e42b94e6f293ee1be8f81f1cf6a4019908c46127a4441c9bfb8302b21aed9624
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.49.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.3
|
Release files / object_detection_metrics-0.4.post1-py3-none-any.whl
| Download URL | object_detection_metrics-0.4.post1-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43737f372a99004b388c5af452dbe3b002063fe7458e9fc59a7350155768e2f1
|
|
BLAKE2b-256 checksum How to use checksums |
25ea20bfaa7eb74cbc7dcfa1dafafd32edce51eb52bf46121eb0944295fe5e78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.49.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.3
|