Skip to main content

This package provides means of explainable classification of images with LLM-generated text descriptions, that are then analyzed using the Self Model Entities Related (SMER) explanation technique.

Project description

SMERVisual

SMERVisual is a Python package designed for explainable machine learning using the SMER method. It provides an intuitive interface for analyzing image classification models by highlighting key features and generating bounding boxes around important words in source images.

The package supports both OpenAI API models and local language models, offering flexibility in model selection.


Installation

Install SMERVisual using pip:

pip install smer-visual

Features

ImageClassifier

The ImageClassifier class performs logistic regression-based classification on image datasets while computing LIME and SMER values for explainability. Key features include:

  • Classification of image datasets using pre-trained language models
  • Computation of LIME and SMER scores for each word in the dataset
  • Visualization of most important words for explainability

BoundingBoxGenerator

The BoundingBoxGenerator class enhances model interpretability by overlaying bounding boxes on images, highlighting critical words identified in classification. It:

  • Uses ImageClassifier output to detect significant words
  • Supports vision models from OpenAI and open-source alternatives
  • Enables zero-shot object detection for explainable AI

Usage Example

Here's a simple way to use SMERVisual for explainable image classification:

from smer_visual import ImageClassifier, BoundingBoxGenerator

# Initialize and train the classifier
classifier = ImageClassifier(model="openai", dataset="path/to/dataset")
classifier()
influential_words = classifier.get_top_words()

# Generate bounding boxes for top words
bbox_generator = BoundingBoxGenerator(data='path/to/dataset', top_words = influential_words, 
                                      local_model_path='path/to/local/model')
bbox_generator("path/to/image.jpg")

Why Use SMERVisual?

  • Explainable AI – Provides insight into model decision-making
  • Model-Agnostic – Compatible with OpenAI APIs and open-source models
  • Zero-Shot Detection – No additional training data required
  • Easy Integration – Simple API for seamless use with existing machine learning workflows

Contributing

Contributions are welcome. If you’d like to contribute, follow these steps:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature-branch)
  3. Commit changes (git commit -m "Add new feature")
  4. Push to the branch (git push origin feature-branch)
  5. Open a pull request

License

SMERVisual is released under the MIT License.


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

smer_visual-0.0.2.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

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

smer_visual-0.0.2-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file smer_visual-0.0.2.tar.gz.

File metadata

  • Download URL: smer_visual-0.0.2.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for smer_visual-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2453aa5d63da08efa8503822fdd6ee4528b711c559d0c89017df3518ccb7dc64
MD5 4673a271aec042f6dc5a9f884921a1a8
BLAKE2b-256 b7cba8b828ad18d6b7d6e3cc7e71cceb5cdca5ec4b5e717f3006948d70067213

See more details on using hashes here.

File details

Details for the file smer_visual-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: smer_visual-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for smer_visual-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d0e4e7ee721d2de2ec9a6df1d934aab04b0773a2c6193793e7a3f3ea61db8b47
MD5 5194acbe1cfa82063edb0f2958b4543f
BLAKE2b-256 db183767bb04df8ee630d59d5bd029c8d1b62c10146f9d4ec3ab6bb80a07bdcb

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