GithubHelp home page GithubHelp logo

alexhock / object-detection-metrics Goto Github PK

View Code? Open in Web Editor NEW
31.0 3.0 7.0 107 KB

Python code for analysing object detection metrics

License: MIT License

Python 53.24% Jupyter Notebook 46.76%
object-detection pytorch tensorflow frcnn retinanet efficientdet coco

object-detection-metrics's Introduction

Object Detection Metrics and Analysis in Python

Creating evaluation metrics for projects involving object detection takes a surprising amount of time. This repo contains code we've found useful to speed up the results analysis for object detection projects. It provides:

  1. Easy creation of a pandas inference dataframe enabling detailed analysis.
  2. Summary statistics for easy plotting.
  3. Calculation of coco metrics using the same pandas dataframe. (uses pycocotools).

To see a quick example of the functionality have a look at the starter notebook.

Installation

pip install git+https://github.com/alexhock/object-detection-metrics

Imports:

from objdetecteval.metrics import (
    image_metrics as im,
    coco_metrics as cm
)

Example usage

Take predictions in a pandas dataframe and similar labels dataframe (same columns except for score) and calculate an 'inference' dataframe:

Predictions

infer_df = im.get_inference_metrics_from_df(preds_df, labels_df)
infer_df.head()

The inference dataframe enables easy analysis of the results for example:

  1. IoU stats by class and failure category
  2. Highest scoring false positive predictions
  3. Comparison of bounding box distributions for FP and TP
  4. ... etc. ..

Inference dataframe

class_summary_df = im.summarise_inference_metrics(infer_df)
class_summary_df

Summary dataframe

This makes it easy to plot:

figsize = (5, 5)
fontsize = 16

fig_confusion = (
    class_summary_df[["TP", "FP", "FN"]]
    .plot(kind="bar", figsize=figsize, width=1, align="center", fontsize=fontsize)
    .get_figure()
)

Confusion

fig_pr = (
    class_summary_df[["Precision", "Recall"]]
    .plot(kind="bar", figsize=figsize, width=1, align="center", fontsize=fontsize)
    .get_figure()
)

PR

Coco metrics are just as simple

Use the dataframes to calculate full coco metrics

res = cm.get_coco_from_dfs(preds_df, labels_df, False)
res

Coco

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.