Skip to main content

Object Detection Metrics

Project description

Build status Latest version on PyPI License Downloads Pythong version codecov Hits

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

Tutorial

  • 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

object-detection-metrics-0.4.post1.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file object-detection-metrics-0.4.post1.tar.gz.

File metadata

  • Download URL: object-detection-metrics-0.4.post1.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for object-detection-metrics-0.4.post1.tar.gz
Algorithm Hash digest
SHA256 552ab6f737026c86ecb738400e533634a62d05e32f5f87e0112cbdcdc47e90e4
MD5 cbae044c9e55927e34b444ed64783fe7
BLAKE2b-256 e42b94e6f293ee1be8f81f1cf6a4019908c46127a4441c9bfb8302b21aed9624

See more details on using hashes here.

File details

Details for the file object_detection_metrics-0.4.post1-py3-none-any.whl.

File metadata

  • Download URL: object_detection_metrics-0.4.post1-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for object_detection_metrics-0.4.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 43737f372a99004b388c5af452dbe3b002063fe7458e9fc59a7350155768e2f1
MD5 1e226e61ad51638a32883ca4bc34d19d
BLAKE2b-256 25ea20bfaa7eb74cbc7dcfa1dafafd32edce51eb52bf46121eb0944295fe5e78

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page