A Shiny-based web application that enables users to upload images and analyze how deep learning models make predictions. The app provides two interpretability techniques:
This project focuses on XAI (Explainable AI) techniques for deep learning with a clean, scalable architecture.
reticulatemodel-explainability/
βββ src/
β βββ python/ # Python explainability modules
β β βββ models/ # Model loading and management
β β βββ explainability/ # Grad-CAM and SHAP implementations
β β βββ utils/ # Utility functions
β β βββ explainability_api.py # Main API interface
β βββ shiny/ # R Shiny application components
β βββ ui.R # User interface
β βββ server.R # Server logic
β βββ modules/ # Modular Shiny components
βββ tests/
β βββ python/ # Python unit tests
β βββ r/ # R tests
βββ assets/
β βββ images/ # Sample images and test data
β βββ docs/ # Documentation and papers
βββ config/ # Configuration files
βββ outputs/ # Generated explanations (gitignored)
βββ requirements.txt # Python dependencies
βββ app.R # Main Shiny app entry point
βββ README.md
git clone https://github.com/rodrick-mpofu/model-explainability.git
cd model-explainability
pip install -r requirements.txt
# Install required R packages
install.packages(c("shiny", "shinydashboard", "shinythemes",
"shinycssloaders", "reticulate", "png"))
# In R, configure reticulate to use your Python environment
library(reticulate)
use_python("/path/to/your/python") # or use_virtualenv()
# Run the Shiny app
shiny::runApp("app.R")
You can also use the Python API directly:
from src.python.explainability_api import explain_image
# Generate Grad-CAM explanation
results = explain_image(
img_path="assets/images/dog.jpg",
model_name="vgg16",
technique="gradcam",
confidence_threshold=0.5
)
# Generate SHAP explanation
results = explain_image(
img_path="assets/images/dog.jpg",
model_name="resnet50",
technique="shap",
confidence_threshold=0.3
)
Run the test suite:
# Python tests
python -m pytest tests/python/
# R tests (if available)
Rscript -e "testthat::test_dir('tests/r')"
The new modular structure provides:
This project is available under the MIT License. See LICENSE file for details.