Skip to content

Conversation

@pavansai018
Copy link

@pavansai018 pavansai018 commented Dec 15, 2025

Summary

This PR exposes lightweight, public get_* utility functions for computing image statistics (e.g. entropy, brightness, blurriness, aspect ratio) directly from in-memory PIL.Image objects.
These utilities internally reuse existing logic in image_property.py and do not duplicate any implementation.

Fixes: #210

Motivation

CleanVision currently computes image statistics only as part of dataset-wide issue detection (Imagelab + IssueManager). However, users may want to compute the same statistics:

  • for a single image
  • on in-memory images (e.g. API inputs, streaming data)
  • without creating a dataset or writing images to disk

This PR addresses that need by exposing a small, stable utility API, as discussed in #210.


What this PR does

  • Adds get_* helper functions (e.g. get_entropy, get_brightness, get_blurriness) to image_property.py
  • Each function is a thin wrapper around existing, tested internal methods
  • Exposes these functions via cleanvision.utils for easy access
  • Does not introduce new files or duplicate logic
  • Does not modify any existing dataset or issue-detection behavior

Example Usage

from cleanvision.utils import (
    get_entropy,
    get_brightness,
    get_blurriness,
    get_aspect_ratio,
)

entropy = get_entropy(image)          # PIL.Image
brightness = get_brightness(image)
blurriness = get_blurriness(image)
aspect_ratio = get_aspect_ratio(image)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose methods for calculating statistics on individual images for on the fly evaluation

1 participant