No project description provided
Project description
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)
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 incx-0.0.2.tar.gz.
File metadata
- Download URL: incx-0.0.2.tar.gz
- Upload date:
- Size: 30.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.13 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec1a8cc79b902fe1b465e544a73c71ecb41e569f819c6f52324da18eeee60c72
|
|
| MD5 |
2b85e2d49a7ba3edfb2a6e3347756cff
|
|
| BLAKE2b-256 |
4e67a891d80e280abf2bdd2b71e8f202f7652046508ab166e7fab0bc1670cbe2
|
File details
Details for the file incx-0.0.2-py3-none-any.whl.
File metadata
- Download URL: incx-0.0.2-py3-none-any.whl
- Upload date:
- Size: 44.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.13 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcbb6e605ca99b0f95dcc7157a63229bc9d6377317d180762090ef0749d96f6d
|
|
| MD5 |
88be283df3cdcb009bfe0d18dcc4a1d2
|
|
| BLAKE2b-256 |
b27f25af7b279d54ea508b3f46b63636c275525ff6d54e684a5d7063f93409a4
|