Giter Club home page Giter Club logo

segmentation-metrics's Introduction

Image Segmentation Metrics

A small python library to help you calculate pixel accurate:

  • TP (true positives)
  • TN (true negatives)
  • FP (false positives)
  • FN (false negatives)
  • Jaccard Similarity Index (IoU)
  • Threshold Jaccard Index
  • Dice Coefficient
  • Sensitivity
  • Specificity
  • Accuracy

for a binary segmentation task.

Example

import cv2
import segmentation_metrics as sm

mask = cv2.imread("mask.png", cv2.IMREAD_GRAYSCALE)
predicted_mask = cv2.imread("predicted_mask.png", cv2.IMREAD_GRAYSCALE)

metrics = sm.calculate(
    masks=[mask],
    predicted_masks=[predicted_mask],
    jaccard_threshold=0.65
)

print(metrics)

Example Output:

{
    'n_images': 300,
    'n_true_positives': 3086436,
    'n_true_positives_%': 0.9052690301820284,
    'n_true_negatives': 11023919,
    'n_true_negatives_%': 0.9724538771281737,
    'n_false_positives': 312268,
    'n_false_negatives': 322977,
    'threshold_jaccard_index': 0.7551666249674276,
    'jaccard_similarity_index_(iou_score)': 0.8186671808348286,
    'dice_coefficient': 0.8902348083199045,
    'sensitivity': 0.9189991951163548,
    'specificity': 0.9669434672587298,
    'accuracy': 0.9569196912977429
}

Future Work

  • Add support for multiclass segmentation metrics

segmentation-metrics's People

Contributors

jhabr avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.