This thesis presents visual-tcav, an open-source Python package that implements Visual- TCAV [4] in PyTorch. Visual-TCAV is a post-hoc Explainable AI (XAI) method for convolutional neural networks (CNNs). Given a test image and a human-understandable concept, for example “stripes”, the method produces a concept map showing where the concept is detected in the image. It also produces an attribution score that quantifies how much the concept influenced the model’s prediction. The original Visual-TCAV implementation is written in TensorFlow 2 and is not dis- tributed as an installable package. This work addresses that gap. It reimplements the method in PyTorch, starting from the reference implementation, structures the code as a distributable package and publishes it on the Python Package Index (PyPI). The work follows established software engineering principles. These principles include separation of concerns, the Strategy Pattern, the Principle of Least Surprise, and the API conventions of scikit-learn, HuggingFace Transformers and Captum. The result is a package that is installable, extensible and research-oriented. The package implements both local explanation, for single images, and global explanation, for statistical analysis over a class of images. It integrates the Text-to-Concept extension by Di Santi [5] and includes a command-line interface (CLI) for use on remote computing infrastructure. The package was validated through a suite of 104 automated tests with 83% line coverage. It follows the conventions of established research packages such as Captum and scikit-learn.

Questa tesi presenta visual-tcav, un package Python open-source che implementa Visual- TCAV [4] in PyTorch. Visual-TCAV è un metodo di Explainable AI (XAI) post-hoc per reti neurali convoluzionali (CNN). Questo metodo, data un’immagine di test e un concetto comprensibile all’uomo, ad esempio “strisce”, produce una concept map che mostra dove il concetto viene rilevato nell’immagine. Inoltre, genera un attribution score che quantifica quanto il concetto abbia influenzato la predizione del modello. L’implementazione originale di Visual-TCAV è scritta in TensorFlow 2 e non è distribuita come package installabile. Questo lavoro risolve questa mancanza. Reimplementa il metodo in PyTorch partendo dall’implementazione di riferimento, struttura il codice come package distribuibile e lo pubblica sul Python Package Index (PyPI). Il lavoro segue prin- cipi consolidati di ingegneria del software. Questi principi includono la separazione delle responsabilità, lo Strategy Pattern, il Principle of Least Surprise e le convenzioni API di scikit-learn, HuggingFace Transformers e Captum. Si ottiene così un package installabile, estensibile e orientato alla ricerca. Il package implementa sia la spiegazione locale, per singole immagini, sia la spiegazione globale, per un’analisi statistica su una classe di immagini. Integra l’estensione Text- to-Concept di Di Santi [5] e include un’interfaccia a riga di comando (CLI) per l’uso su infrastrutture di calcolo remoto. Il package è stato validato tramite una suite di 104 test automatici con una copertura di riga dell’83%. Segue le convenzioni dei package di ricerca consolidati come Captum e scikit-learn.

Visual-tcav: a Python package for concept-based explainability of deep learning image classifiers

CAVALLINI, SARA
2025/2026

Abstract

This thesis presents visual-tcav, an open-source Python package that implements Visual- TCAV [4] in PyTorch. Visual-TCAV is a post-hoc Explainable AI (XAI) method for convolutional neural networks (CNNs). Given a test image and a human-understandable concept, for example “stripes”, the method produces a concept map showing where the concept is detected in the image. It also produces an attribution score that quantifies how much the concept influenced the model’s prediction. The original Visual-TCAV implementation is written in TensorFlow 2 and is not dis- tributed as an installable package. This work addresses that gap. It reimplements the method in PyTorch, starting from the reference implementation, structures the code as a distributable package and publishes it on the Python Package Index (PyPI). The work follows established software engineering principles. These principles include separation of concerns, the Strategy Pattern, the Principle of Least Surprise, and the API conventions of scikit-learn, HuggingFace Transformers and Captum. The result is a package that is installable, extensible and research-oriented. The package implements both local explanation, for single images, and global explanation, for statistical analysis over a class of images. It integrates the Text-to-Concept extension by Di Santi [5] and includes a command-line interface (CLI) for use on remote computing infrastructure. The package was validated through a suite of 104 automated tests with 83% line coverage. It follows the conventions of established research packages such as Captum and scikit-learn.
ING - Scuola di Ingegneria Industriale e dell'Informazione
21-ott-2026
2025/2026
Questa tesi presenta visual-tcav, un package Python open-source che implementa Visual- TCAV [4] in PyTorch. Visual-TCAV è un metodo di Explainable AI (XAI) post-hoc per reti neurali convoluzionali (CNN). Questo metodo, data un’immagine di test e un concetto comprensibile all’uomo, ad esempio “strisce”, produce una concept map che mostra dove il concetto viene rilevato nell’immagine. Inoltre, genera un attribution score che quantifica quanto il concetto abbia influenzato la predizione del modello. L’implementazione originale di Visual-TCAV è scritta in TensorFlow 2 e non è distribuita come package installabile. Questo lavoro risolve questa mancanza. Reimplementa il metodo in PyTorch partendo dall’implementazione di riferimento, struttura il codice come package distribuibile e lo pubblica sul Python Package Index (PyPI). Il lavoro segue prin- cipi consolidati di ingegneria del software. Questi principi includono la separazione delle responsabilità, lo Strategy Pattern, il Principle of Least Surprise e le convenzioni API di scikit-learn, HuggingFace Transformers e Captum. Si ottiene così un package installabile, estensibile e orientato alla ricerca. Il package implementa sia la spiegazione locale, per singole immagini, sia la spiegazione globale, per un’analisi statistica su una classe di immagini. Integra l’estensione Text- to-Concept di Di Santi [5] e include un’interfaccia a riga di comando (CLI) per l’uso su infrastrutture di calcolo remoto. Il package è stato validato tramite una suite di 104 test automatici con una copertura di riga dell’83%. Segue le convenzioni dei package di ricerca consolidati come Captum e scikit-learn.
File allegati
File Dimensione Formato  
2026_10_Cavallini.pdf

accessibile in internet solo dagli utenti autorizzati

Descrizione: testo della tesi
Dimensione 1.27 MB
Formato Adobe PDF
1.27 MB Adobe PDF   Visualizza/Apri

I documenti in POLITesi sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/10589/267220