Compare and audit image patches for VLM and computer vision workflows.
Project description
visual-patch-audit
Compare and audit image patches for VLM and computer vision workflows.
Installation
pip install visual-patch-audit
For local development:
pip install -e ".[dev]"
Usage
from visual_patch_audit import compare_patches
report = compare_patches(
reference_patches="reference_patches",
candidate_patches="candidate_patches",
)
print(report)
Visual example
This example compares a selected mountain/forest patch from one landscape image against a selected patch from another landscape image.
| Image | Patch | |
|---|---|---|
| Reference | ||
| Image to compare |
from visual_patch_audit import compare_patch
result = compare_patch(
"assets/readme/reference_patch.png",
"assets/readme/candidate_patch.png",
)
print(result)
Actual result:
{
"similarity": {
"histogram_similarity": 0.869569,
"brightness_similarity": 0.988622,
"contrast_similarity": 0.989545,
"texture_similarity": 0.999121,
"overall_similarity": 0.950974,
},
"issues": [],
}
The score is interpretable: the patches have similar brightness, contrast, texture, and color distribution.
Generate the README images and result again:
python examples/readme_visual_example.py
Output
{
"reference_count": 20,
"candidate_count": 5,
"score": 82,
"similarity": {
"mean_histogram_similarity": 0.86,
"mean_brightness_similarity": 0.91,
"mean_contrast_similarity": 0.77,
"mean_edge_density_similarity": 0.74,
"mean_texture_similarity": 0.79,
},
"issues": [
{
"patch": "candidate_patches/patch_04.png",
"type": "low_similarity",
"severity": "medium",
"message": "Patch is visually different from the reference set.",
}
],
}
Inspect one patch
from visual_patch_audit import inspect_patch
features = inspect_patch("patch.png")
print(features)
Compare two patches
from visual_patch_audit import compare_patch
result = compare_patch("reference.png", "candidate.png")
print(result)
Find outliers
from visual_patch_audit import find_outlier_patches
outliers = find_outlier_patches("patches")
print(outliers)
Overview
visual-patch-audit is a Python utility for comparing image patches using simple visual similarity metrics.
It is useful when building:
- VLM pipelines
- segmentation workflows
- object detection workflows
- visual dataset validation systems
- model output review tools
- image patch quality checks
- computer vision evaluation pipelines
Features
- Compares one patch against another
- Compares candidate patches against reference patches
- Extracts interpretable patch features
- Detects visually unusual patches
- Reports similarity metrics and potential issues
- Supports JPEG, PNG, WEBP, TIFF, and BMP images
- Uses Pillow and numpy
- Simple API
Limitations
visual-patch-audit uses deterministic visual similarity metrics. It does not determine semantic correctness, medical truth, diagnosis, object identity, or ground-truth validity. It does not replace expert review, model evaluation, annotation review, or safety-critical validation.
Use it as one inspection layer in a broader VLM or computer vision evaluation workflow. Outlier detection is intentionally simple and uses O(n^2) pairwise comparisons.
Issues
Report issues at: https://github.com/edujbarrios/visual-patch-audit
Author
Eduardo J. Barrios
edujbarrios@outlook.com
License
Mozilla Public License 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file visual_patch_audit-0.1.0.tar.gz.
File metadata
- Download URL: visual_patch_audit-0.1.0.tar.gz
- Upload date:
- Size: 221.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bcdef0cd53c01b67eed6d93bd407300537c86007262cf473f718976c2148609
|
|
| MD5 |
2ca507d7b972c8ac3e3eea0b54e2bf17
|
|
| BLAKE2b-256 |
de155ef36dc3de5dfa1bd60c7ec8a65092326d56183d8d50dbdcc0c8923f80f3
|
File details
Details for the file visual_patch_audit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: visual_patch_audit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9b6166f89cd58e91795c0ef447b27213cac95f65fc0ce3e862dea09834ab664
|
|
| MD5 |
1bfeb7452e0f3e6d4b407fb1b8fc719f
|
|
| BLAKE2b-256 |
564602a21587a8bc4ec3cff2d9251aef9d6f42fb108433d8bdb7d77e2c8d2973
|