Skip to main content

YOLOv8_Explainer

License: MIT Downloads

Simplify your understanding of YOLOv8 Results

This is a package with state of the art methods for Explainable AI for computer vision using YOLOv8. This can be used for diagnosing model predictions, either in production or while developing models. The aim is also to serve as a benchmark of algorithms and metrics for research of new explainability methods.

Install Environment & Dependencies

YOLOv8-Explainer can be seamlessly integrated into your projects with a straightforward installation process:

Installation as a Package

To incorporate YOLOv8-Explainer into your project as a dependency, execute the following command in your terminal:

pip install YOLOv8-Explainer

Features and Functionality

YOLOv8-Explainer can be used to deploy various different CAM models for cutting-edge XAI methodologies in YOLOv8 for images:

  • GradCAM : Weight the 2D activations by the average gradient
  • GradCAM + + : Like GradCAM but uses second order gradients
  • XGradCAM : Like GradCAM but scale the gradients by the normalized activations
  • EigenCAM : Takes the first principle component of the 2D Activations (no class discrimination, but seems to give great results)
  • HiResCAM : Like GradCAM but element-wise multiply the activations with the gradients; provably guaranteed faithfulness for certain models
  • LayerCAM : Spatially weight the activations by positive gradients. Works better especially in lower layers
  • EigenGradCAM : Like EigenCAM but with class discrimination: First principle component of Activations*Grad. Looks like GradCAM, but cleaner

Using from code as a library

from YOLOv8_Explainer import yolov8_heatmap, display_images

model = yolov8_heatmap(
    weight="/location/model.pt", 
        conf_threshold=0.4, 
        device = "cpu", 
        method = "EigenCAM", 
        layer=[10, 12, 14, 16, 18, -3],
        backward_type="all",
        ratio=0.02,
        show_box=True,
        renormalize=False,
)

imagelist = model(
    img_path="/location/image.jpg", 
    )

display_images(imagelist)

You can choose between the following CAM Models for version 0.0.2:

GradCAM , HiResCAM, GradCAMPlusPlus, XGradCAM , LayerCAM, EigenGradCAM and EigenCAM.

You can add a single image or a directory images to be used by the Module. The output will be a corresponding list of images (list contianing one PIL Image for a single image imput and list contining as many PIL images as Images in the input directory).

References

https://github.com/jacobgil/pytorch-grad-cam
PyTorch library for CAM methods Jacob Gildenblat and contributors

https://github.com/z1069614715/objectdetection_script
Object Detection Script Devil's Mask

https://arxiv.org/abs/1610.02391
Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization Ramprasaath R. Selvaraju, Michael Cogswell, Abhishek Das, Ramakrishna Vedantam, Devi Parikh, Dhruv Batra

https://arxiv.org/abs/2011.08891
Use HiResCAM instead of Grad-CAM for faithful explanations of convolutional neural networks Rachel L. Draelos, Lawrence Carin

https://arxiv.org/abs/1710.11063
Grad-CAM++: Improved Visual Explanations for Deep Convolutional Networks Aditya Chattopadhyay, Anirban Sarkar, Prantik Howlader, Vineeth N Balasubramanian

https://arxiv.org/abs/1910.01279
Score-CAM: Score-Weighted Visual Explanations for Convolutional Neural Networks Haofan Wang, Zifan Wang, Mengnan Du, Fan Yang, Zijian Zhang, Sirui Ding, Piotr Mardziel, Xia Hu

https://ieeexplore.ieee.org/abstract/document/9093360/
Ablation-cam: Visual explanations for deep convolutional network via gradient-free localization. Saurabh Desai and Harish G Ramaswamy. In WACV, pages 972–980, 2020

https://arxiv.org/abs/2008.02312
Axiom-based Grad-CAM: Towards Accurate Visualization and Explanation of CNNs Ruigang Fu, Qingyong Hu, Xiaohu Dong, Yulan Guo, Yinghui Gao, Biao Li

https://arxiv.org/abs/2008.00299
Eigen-CAM: Class Activation Map using Principal Components Mohammed Bany Muhammad, Mohammed Yeasin

http://mftp.mmcheng.net/Papers/21TIP_LayerCAM.pdf
LayerCAM: Exploring Hierarchical Class Activation Maps for Localization Peng-Tao Jiang; Chang-Bin Zhang; Qibin Hou; Ming-Ming Cheng; Yunchao Wei

https://arxiv.org/abs/1905.00780
Full-Gradient Representation for Neural Network Visualization Suraj Srinivas, Francois Fleuret

https://arxiv.org/abs/1806.10206
Deep Feature Factorization For Concept Discovery Edo Collins, Radhakrishna Achanta, Sabine Süsstrunk

Metadata

Release files for YOLOv8-Explainer 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for YOLOv8-Explainer 0.0.5
File Size Uploaded
YOLOv8_Explainer-0.0.5.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for YOLOv8-Explainer 0.0.5
File Interpreter ABI Platform
YOLOv8_Explainer-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 19.5 kB

Release files / YOLOv8_Explainer-0.0.5.tar.gz

Download URL YOLOv8_Explainer-0.0.5.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
04e6f15331b1a8f79dd94d3a967bb6762d4274a63f6e309e1e8d69e55bf27332
BLAKE2b-256 checksum
How to use checksums
885cf4220cb66f188811dd3cdda9e13df4ed0246ad1fc52899215c25da0fc230
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.18

Release files / YOLOv8_Explainer-0.0.5-py3-none-any.whl

Download URL YOLOv8_Explainer-0.0.5-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
969d17b0db234904e417bb96737e0ae2db42d64781dbb7806dd9c4f7bdc55b68
BLAKE2b-256 checksum
How to use checksums
7afbd503f49e8654693afe27a80e6d54351fe8fcdc3ada5ab32a30b3d52b19bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.18

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page