Skip to main content

UNet segmentation metrics

WORK IN PROGRESS

Simple Python 3 tools to assess the performance of UNet segmentation networks (or any other segmentation method) by comparing the prediction to a ground truth image.

Use it to calculate:

  • Jaccard metric for object detection
  • Intersection over Union (IoU) for object segmentation accuracy
  • Localization (positional) error for estimating MOTP during tracking
  • Pixel identity

TODO:

  • Add strict matching with IoU threshold
  • Add confusion matrix for multi-label/classification type tasks

Single image usage

import umetrix
from skimage.io import imread

y_true = imread('true.tif')
y_pred = imread('pred.tif')


# can now make the calculation strict, by only considering objects that have
# an IoU above a theshold as being true positives
result = umetrix.calculate(
    y_true,
    y_pred,
    strict=True,
    iou_threshold=0.5
)

print(result.results)

returns:

============================
 Segmentation Metrics (n=1)
============================
Strict: True (IoU > 0.5)
n_true_labels: 354
n_pred_labels: 362
n_true_positives: 345
n_false_positives: 10
n_false_negatives: 0
IoU: 0.999
Jaccard: 0.972
pixel_identity: 0.998
localization_error: 0.010

Batch processing

import umetrix

# provide a list of file pairs ('true', 'prediction')
files = [
    ('true0.tif', 'pred0.tif'),
    ('true1.tif', 'pred1.tif'),
    ('true2.tif', 'pred2.tif')
]

batch_result = umetrix.batch(files)

Returns aggregate statistics over the batch. Jaccard index is calculated over all found objects, while other metrics are the average IoU etc.

Installation

  1. First clone the repo:
$ git clone https://github.com/quantumjot/unet_segmentation_metrics.git
  1. (Optional, but advised) Create a conda environment:
$ conda create -n umetrix python=3.9
$ conda activate umetrix
  1. Install the package
$ cd unet_segmentation_metrics
$ pip install .

Metadata

Release files for umetrix 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for umetrix 0.2.0
File Size Uploaded Provenance Actions
umetrix-0.2.0.tar.gz 226.9 kB Without provenance Details for umetrix-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for umetrix 0.2.0
File Interpreter ABI Platform Actions
umetrix-0.2.0-py3-none-any.whl Python 3 none any Details for umetrix-0.2.0-py3-none-any.whl

Total release size: 236.8 kB

Release files / umetrix-0.2.0.tar.gz

Download URL umetrix-0.2.0.tar.gz
Size 226.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b79e7812246e4a4c10cf13a77eeed607c8a52969cfb224d48c7a5f15e222234e
BLAKE2b-256 checksum
How to use checksums
335504ddda3f0c8bb8a296680006c489dea57563ad1b723c460babb363f08b84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / umetrix-0.2.0-py3-none-any.whl

Download URL umetrix-0.2.0-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0df225ea5a7ae0a77992b4234267299418d1bdacb76f492c84305e9e457d2de8
BLAKE2b-256 checksum
How to use checksums
b00095c2ca9bd7de92486a6ab384f07548e783b4f9ab317413df25c5cd08a4d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Security for umetrix 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page