IncX
IncX (Incremental Explanations) is a method for generating saliency maps and explanations incrementally in real-time.
Getting Started
To set up and use this project, you will need pyenv for managing Python versions and poetry for handling dependencies. Follow these instructions to configure your environment.
Prerequisites
-
Install Pyenv
Pyenv allows you to manage multiple Python versions on your system. Select your operating system and follow the relevant installation instructions:- Linux and macOS: Refer to the guide on the pyenv GitHub repository.
- Windows: Use pyenv-win for installation instructions.
-
Install the Required Python Version
After installing pyenv, use it to install the Python version specified in the.python-versionfile located in the root directory of this project. Execute the following command:pyenv install -
Install Poetry
Install poetry by following the instructions on the poetry installation page. -
Configure Poetry
Set up poetry to create virtual environments within the project directory. This configuration helps manage isolated environments for different projects:poetry config virtualenvs.in-project true
-
Install Project Dependencies
Use poetry to install all required dependencies and create a virtual environment:poetry install
Running Experiments
To reproduce the experiments comparing D-RISE and IncX, follow these steps using the scripts located in the /experiments directory.
-
Generate Saliency Maps with D-RISE
Navigate to/experiments/d_riseand execute theget_saliency_maps.pyscript:python get_saliency_maps.pyIf you are using a high-performance computing (HPC) system, you can run these tasks in parallel by using
batch_experiment_gpu.shandmultiple_experiment_gpu.sh. -
Generate Saliency Maps with IncX
Move to/experiments/incxand runget_job_names.pyto create a list of jobs:python get_job_names.pyThen, execute
get_saliency_maps.pyto compute the saliency maps. For parallel execution on HPC systems, usebatch_experiment_gpu.shandmultiple_experiment_gpu.sh. -
Compare Saliency Maps
After generating the saliency maps from both methods, compare them by running:python get_blob_names.pyNext, obtain the comparison results with:
python get_similarity_comparison.pyOn HPC systems, expedite this process with
batch_similarity_comparison.shandmultiple_batch_similarity.sh. -
Compute Metrics
To calculate metrics such as insertion, deletion, EPG, and explanation size, start by running:python get_blob_names_metrics.pyThen, execute:
python get_metrics.pyFor HPC systems, speed up this process by using
batch_metrics.shandmultiple_batch_metrics.sh.
Running Unit Tests
To ensure that the code functions correctly and is thoroughly tested, run:
poetry run pytest
This command will execute all tests in the tests/ directory, providing feedback on code accuracy and test coverage.
Linting and Formatting
To maintain high code quality and consistency, use the following commands:
-
Linting
Runruffto identify and automatically fix code issues:poetry run ruff check . --fix
-
Formatting
Format your code according to style guidelines withruff:poetry run ruff format .
Installing the Package
The Incx package is available on PyPI. To install the latest version, execute:
pip install incx
Usage
The usage_examples.ipynb provides examples on how to use the python package. For instance, to explain a video the following code will suffice:
from incx import incx, yolo, rt_detr, faster_rcnn, d_rise
video_path = 'PATH_TO_YOUR_VIDEO'
# Choose the model you want to use
model = yolo.Yolo()
# model = rt_detr.RTDETR()
# model = faster_rcnn.FasterRcnn()
explainer = d_rise.DRise(model)
incX = incx.IncX(model, explainer)
frames = incX.explain_video(video_path)
Metadata
Release files for incx 0.0.2
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 |
|---|---|---|---|---|
| incx-0.0.2.tar.gz | 30.2 kB | Without provenance | Details for incx-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| incx-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for incx-0.0.2-py3-none-any.whl |
Total release size: 74.4 kB
Release files / incx-0.0.2.tar.gz
| Download URL | incx-0.0.2.tar.gz |
|---|---|
| Size | 30.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec1a8cc79b902fe1b465e544a73c71ecb41e569f819c6f52324da18eeee60c72
|
|
BLAKE2b-256 checksum How to use checksums |
4e67a891d80e280abf2bdd2b71e8f202f7652046508ab166e7fab0bc1670cbe2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.13 Windows/10
|
Release files / incx-0.0.2-py3-none-any.whl
| Download URL | incx-0.0.2-py3-none-any.whl |
|---|---|
| Size | 44.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bcbb6e605ca99b0f95dcc7157a63229bc9d6377317d180762090ef0749d96f6d
|
|
BLAKE2b-256 checksum How to use checksums |
b27f25af7b279d54ea508b3f46b63636c275525ff6d54e684a5d7063f93409a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.13 Windows/10
|
Security for incx 0.0.2
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.