Skip to main content

Object Detection metrics.

Project description


License: MIT

A python library for Object Detection metrics.

Why OD-Metrics?

  • User-friendly: Designed for simplicity, allowing users to calculate metrics with minimal setup.
  • Highly Customizable: Offers flexibility by allowing users to set custom values for every parameter in metrics definitions.
  • COCOAPI Compatibility: Metrics are rigorously tested to ensure compatibility with COCOAPI, ensuring reliability and consistency.

Supported Metrics

Supported metrics include:

  • mAP (Mean Average Precision)
  • mAR (Mean Average Recall)
  • IoU (Intersection over Union).

For more information see Metrics documentation.

Documentation

For help, usage, API reference, and an overview of metrics formulas, please refer to Documentation.

Try live Demo

Try OD-Metrics samples Binder

Installation

Install from PyPI

pip install od-metrics

Install from Github

pip install git+https://github.com/EMalagoli92/OD-Metrics

Simple Example

from od_metrics import ODMetrics

# Ground truths
y_true = [
    { # image 1
     "boxes": [[25, 16, 38, 56], [129, 123, 41, 62]],
     "labels": [0, 1]
     },
    { # image 2
     "boxes": [[123, 11, 43, 55], [38, 132, 59, 45]],
     "labels": [0, 0]
     }
    ]

# Predictions
y_pred = [
    { # image 1
     "boxes": [[25, 27, 37, 54], [119, 111, 40, 67], [124, 9, 49, 67]],
     "labels": [0, 1, 1],
     "scores": [.88, .70, .80]
     },
    { # image 2
     "boxes": [[64, 111, 64, 58], [26, 140, 60, 47], [19, 18, 43, 35]],
     "labels": [0, 1, 0],
     "scores": [.71, .54, .74]
     }
    ]

metrics = ODMetrics()
output = metrics.compute(y_true, y_pred)
print(output)
"""
{
    "mAP@[.5 | all | 100]": 0.16831683168316827,
    "mAP@[.5:.95 | all | 100]": 0.06732673267326732,
    "mAP@[.5:.95 | large | 100]": -1.0,
    "mAP@[.5:.95 | medium | 100]": 0.06732673267326732,
    "mAP@[.5:.95 | small | 100]": -1.0,
    "mAP@[.75 | all | 100]": 0.0,
    "mAR@[.5 | all | 100]": 0.16666666666666666,
    "mAR@[.5:.95 | all | 100]": 0.06666666666666667,
    "mAR@[.5:.95 | all | 10]": 0.06666666666666667,
    "mAR@[.5:.95 | all | 1]": 0.06666666666666667,
    "mAR@[.5:.95 | large | 100]": -1.0,
    "mAR@[.5:.95 | medium | 100]": 0.06666666666666667,
    "mAR@[.5:.95 | small | 100]": -1.0,
    "mAR@[.75 | all | 100]": 0.0,
    "class_metrics": {
        "0": {
            "AP@[.5 | all | 100]": 0.33663366336633654,
            "AP@[.5:.95 | all | 100]": 0.13465346534653463,
            "AP@[.5:.95 | large | 100]": -1.0,
            "AP@[.5:.95 | medium | 100]": 0.13465346534653463,
            "AP@[.5:.95 | small | 100]": -1.0,
            "AP@[.75 | all | 100]": 0.0,
            "AR@[.5 | all | 100]": 0.3333333333333333,
            "AR@[.5:.95 | all | 100]": 0.13333333333333333,
            "AR@[.5:.95 | all | 10]": 0.13333333333333333,
            "AR@[.5:.95 | all | 1]": 0.13333333333333333,
            "AR@[.5:.95 | large | 100]": -1.0,
            "AR@[.5:.95 | medium | 100]": 0.13333333333333333,
            "AR@[.5:.95 | small | 100]": -1.0,
            "AR@[.75 | all | 100]": 0.0
        },
        "1": {
            "AP@[.5 | all | 100]": 0.0,
            "AP@[.5:.95 | all | 100]": 0.0,
            "AP@[.5:.95 | large | 100]": -1.0,
            "AP@[.5:.95 | medium | 100]": 0.0,
            "AP@[.5:.95 | small | 100]": -1.0,
            "AP@[.75 | all | 100]": 0.0,
            "AR@[.5 | all | 100]": 0.0,
            "AR@[.5:.95 | all | 100]": 0.0,
            "AR@[.5:.95 | all | 10]": 0.0,
            "AR@[.5:.95 | all | 1]": 0.0,
            "AR@[.5:.95 | large | 100]": -1.0,
            "AR@[.5:.95 | medium | 100]": 0.0,
            "AR@[.5:.95 | small | 100]": -1.0,
            "AR@[.75 | all | 100]": 0.0
        }
    },
    "classes": [
        0,
        1
    ],
    "n_images": 2
}
"""

Aknowledgment

License

This work is made available under the MIT License

Support

Found this helpful? ⭐ it on GitHub

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

od_metrics-2.1.0.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

od_metrics-2.1.0-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file od_metrics-2.1.0.tar.gz.

File metadata

  • Download URL: od_metrics-2.1.0.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for od_metrics-2.1.0.tar.gz
Algorithm Hash digest
SHA256 0dcb4bdd6ffb715d96601faf04397245e0e0717d5d3c75c4e03d5510e30fe5f4
MD5 66de18d9b4c217e5074c4c385343e55e
BLAKE2b-256 babd8c31a74bd46465d75d5fba68b6b135aadcf381d0cc2cdb23ba5043fc7acb

See more details on using hashes here.

File details

Details for the file od_metrics-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: od_metrics-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for od_metrics-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e62019140623559ab2f49fd4c96b7a82ef41178c86376ee39cf168de6ad24eb
MD5 aadb1cb995d5d4d18a32bed5741dd932
BLAKE2b-256 5ec939044d062cc397e7379717a0fad79ed8610c0a41713d421a793d3fd64626

See more details on using hashes here.

Supported by

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