Skip to main content

A tool to numerically analyze the health of a YOLO dataset.

Project description

yolo-health-checker

A Python tool to perform an in-depth analysis of YOLO-format datasets, providing both multidimensional and unidimensional metrics of dataset “health.” This package helps you quantify class distribution, spatial distribution, and other properties in a systematic and reproducible way.

Features

  • Class Distribution Analysis:

    • Calculate entropy, Gini index, and standard deviation of instance counts per class.
    • Inspect the number of instances per class and identify imbalances quickly.
  • Spatial Distribution Analysis:

    • Compute spatial entropy of bounding boxes to see how they are spread across images.
    • Measure standard deviation of bounding box centers, detecting if objects cluster in certain image regions.
    • Calculate average distance from image center, unveiling potential “center bias” in your dataset.
  • Rich Visual Outputs:

    • Automatically generates heatmaps of bounding box footprints and centers.
    • Visual bar charts showing the number of instances per class.
  • Comprehensive Logging:

    • Each analysis is logged into a log file, capturing potential warnings (e.g., missing annotations) and key statistics.
  • Modular:

    • Integrate directly into Python code, or run as a command-line script.
    • Produces CSV reports of class distribution and overall health metrics.

Installation

Install yolo-health-checker via pip:

pip install yolo-health-checker

Usage

There are two main ways to use this tool: as a command-line script or via Python import.

Command-Line

python -m yolo_health_checker.analyze_dataset /path/to/yolo_dataset --output_dir results --save_images --save_csv

  • dataset_path: The path to your YOLO-format dataset (containing data.yaml, train/, val/ folders).
  • --output_dir: Optional path to store the output artifacts (CSV, images, etc.).
  • --save_images: Save class distribution bar charts and heatmaps.
  • --save_csv: Save CSV files with class distributions and health metrics.
  • --log_file: Specify the log file name (default: main.log).
  • --log_level: Logging verbosity (default: INFO).

Python Import

You can also integrate yolo-health-checker within your Python code:

from yolo_health_checker import analyze_dataset

health_checker = analyze_dataset(
    dataset_path='/path/to/yolo_dataset',
    output_dir='results',
    save_images=True,
    save_csv=True,
    log_level='INFO',
    log_file='analysis.log'
)

# Once analysis is done, inspect the results
health_checker.show_health_metrics()

Motivations & Numeric Measurements

Why numeric measurements?
Numeric metrics allow us to systematically compare how well different YOLO versions handle dataset variations. By converting each characteristic into a measurable number, we make the research both reproducible and statistically testable.

Below we list the main “dataset health” metrics we measure. Each is numeric with a clear interpretation, making them suitable for statistical analyses. The overarching principle: if it cannot be expressed numerically, we cannot reliably correlate it with YOLO performance.

1. Class Distribution Metrics

1.1. Entropy of Class Distribution

  • Reason: Measures the uniformity of the distribution of objects across classes. A high entropy indicates a more balanced dataset.
  • Formula:
    H = - Σ pᵢ log(pᵢ)
    (where pᵢ is the proportion of class i)

1.2. Gini Index

  • Reason: Captures how unevenly instances are distributed among classes.
  • Formula:
    G = 1 - Σ (pᵢ)²
    (where pᵢ is the proportion of class i)

1.3. Standard Deviation of Instances per Class

  • Reason: Indicates the spread of counts across different classes.

2. Spatial Distribution Metrics

2.1. Entropy of Object Locations

  • Reason: Checks if bounding boxes are clustered in a few regions or spread evenly.
  • Procedure: A 10×10 grid is created, and bounding box counts per cell are transformed into probabilities for entropy calculation.

2.2. Standard Deviation of Object Centers

  • Reason: Measures how widely scattered the center points of bounding boxes are across the image.

2.3. Distance from Center of Mass

  • Reason: Quantifies how far bounding box centers lie from the image center, highlighting potential “center bias.”

Example

To run a sample analysis (outputting both CSV and images):

python -m yolo_health_checker.analyze_dataset /path/to/yolo_dataset --output_dir results --save_images --save_csv --log_file my_log.log

  • This will log the process in my_log.log, generate bar charts for class distribution, produce bounding box heatmaps, and create CSV reports with class counts and dataset health metrics in the results/health folder.

Contributing

Feel free to open an issue or a pull request if you spot bugs or want to contribute improvements. We welcome new ideas on metrics or enhancements to support more YOLO-format variations.

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

yolo_health_checker-0.1.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

yolo_health_checker-0.1.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file yolo_health_checker-0.1.1.tar.gz.

File metadata

  • Download URL: yolo_health_checker-0.1.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.0

File hashes

Hashes for yolo_health_checker-0.1.1.tar.gz
Algorithm Hash digest
SHA256 43dafe8e54eb8bf0cd6267586d55eb3496058600363c2b75b2675f419d8f62da
MD5 05205ec13e8618c0f57803a471ad71fc
BLAKE2b-256 159468e246f7c6de73615a8be8cbe0c7dc7337b4361afc261610d8ea36217798

See more details on using hashes here.

File details

Details for the file yolo_health_checker-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for yolo_health_checker-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c35d0a8854269d000ea90c907d3ac21f36ea5e8871c713b2e14a19502f5b5226
MD5 34d220ff583a79600fea5cfe7d7bac96
BLAKE2b-256 1b8922fec5d682c7ba598b0ad1d07baa586068f75c10f165c03545d9a263cf0b

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