vlm-occlusion
Find which image regions influence a Vision-Language Model claim through black-box occlusion testing.
Installation
pip install vlm-occlusion
Usage
from vlm_occlusion import analyze_occlusion
result = analyze_occlusion(
image="example.png",
predict_fn=describe_image,
score_fn=claim_score,
grid_size=(4, 4),
occlusion="blur",
output_path="heatmap.png",
)
print(result["most_influential_region"])
print(result["importance_scores"])
predict_fn receives a Pillow image and returns text or a number. score_fn turns that result into a numerical score for the claim you are testing. The package compares the original score with scores produced after occluding each grid cell.
It is model-agnostic and includes no VLM, model adapter, or network client. It measures black-box sensitivity to controlled perturbations; it does not inspect attention or reveal a model's internal reasoning.
Example
The included deterministic example tests the claim:
There is a red desk lamp in the upper-left area.
The mock predictor measures visible red evidence; no model, API key, or network connection is used. The 4×4 analysis identifies the left-side cell containing most of the lamp as the strongest influence.
| Input image | Most influential cell occluded | Importance heatmap |
|---|---|---|
The scene is an original generated illustration created for this repository. The occluded image and heatmap are produced locally by the example.
python examples/generate_example_images.py
python examples/basic_usage.py
The README assets are saved under docs/images/.
Features
- Model-agnostic callback API
- Grid-based black, white, mean, and blur occlusion
- Normalized regional importance scores
- Pillow-only visualization
- No network access required
Limitations
Occlusion sensitivity is an approximation. A perturbation may change a response for reasons unrelated to visual grounding, and results can vary with grid size and occlusion strategy. This package does not expose internal model attention.
Issues
Report issues at https://github.com/edujbarrios/vlm-occlusion/issues.
Author
Eduardo J. Barrios — edujbarrios@outlook.com
License
Mozilla Public License 2.0
Metadata
Release files for vlm-occlusion 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vlm_occlusion-0.1.0.tar.gz | 6.2 kB | Without provenance | Details for vlm_occlusion-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vlm_occlusion-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for vlm_occlusion-0.1.0-py3-none-any.whl |
Total release size: 11.8 kB
Release files / vlm_occlusion-0.1.0.tar.gz
| Download URL | vlm_occlusion-0.1.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4950ee87a7ccd5eab3553ac2f064deaf050658acef2cbaed39d5462cdf69ec12
|
|
BLAKE2b-256 checksum How to use checksums |
a861d42bcd57541254a5dec64e26e8d01b831d31cc9da217fdaee517ed1a6536
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Release files / vlm_occlusion-0.1.0-py3-none-any.whl
| Download URL | vlm_occlusion-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d59f4798be6b150319a3925516d823d1c24405aa83f973d3c9e3ae92247650f
|
|
BLAKE2b-256 checksum How to use checksums |
3b653f14f0b6692f7285a0ec0671f4fb3d3277a078c5c17745e65aa9f7ab6382
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Security for vlm-occlusion 0.1.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.