Future Works & Improvements: Explainable AI (XAI)¶
As part of the continuous evolution of the Cervical Cytology AI pipeline, our next major milestone is integrating Explainable AI (XAI).
The primary goal is to enhance the trust and clinical utility of the AI system by visualizing why the MobileViT model classified a specific cell as High Risk (Dyskeratotic or Koilocytotic) using methodologies like SHAP (SHapley Additive exPlanations) or Grad-CAM.
๐ฏ Clinical Motivation¶
In medical diagnostics, "black-box" models often face resistance from clinical practitioners. By providing visual evidence of the neural network's attention map, cytologists can:
- Instantly verify if the AI is looking at the correct cellular structures (e.g., enlarged nuclei, irregular borders).
- Build confidence in the automated triage system.
- Catch potential model biases or artifacts.
Performance Considerations
Generating SHAP values or pixel-level gradients is computationally expensive. To maintain the pipeline's high throughput, we propose generating explanations only for High Risk cells (Dyskeratotic/Koilocytotic) that exceed a specific confidence threshold.
๐ Proposed Architectural Enhancements¶
To implement this without disrupting the current production pipeline, we plan to introduce a modular XAI engine.
1. New Explainability Module (src/explainable/)¶
We will create a new package to handle all interpretability logic, completely decoupled from the core inference engine.
-
src/explainable/engine.py:XAIEngine: A wrapper around the MobileViT inference model.- Uses
shap.GradientExplainerorshap.PartitionExplainer. - Output: Raw SHAP values and a PIL image overlay (heatmap).
-
src/explainable/vis.py:- Generates clinician-friendly visualizations.
- Example: A side-by-side view showing
[Original Crop] | [Attention Heatmap] | [Prototypical Example].
2. Pipeline Integration (src/pipeline.py)¶
The orchestration layer will be updated to seamlessly route high-risk crops to the XAI engine.
- Filter: After classification, isolate cells predicted as
DyskeratoticorKoilocytoticwith a confidence score > 0.80. - Explain: Pass these specific crops to the
XAIEngine. - Store: Save the resulting heatmap visualizations to a new directory (
data/reports/figures/). - Link: Enrich the cell's JSON metadata with the
explanation_pathfor downstream reporting.
๐ Reporting Layer Updates¶
The generated PDF report (handled by src/report_gen.py) will feature a new dedicated section.
๐ Section: AI Logic & Interpretability¶
- Content: Display the top 3 most critical high-risk cells alongside their generated SHAP heatmaps.
- Visual Legend: Include a caption explaining the heatmap gradient (e.g., "Warmer colors [Red/Pink] indicate regions the model identified as highly suspicious.").
๐งช Verification & Release Strategy¶
Before merging the XAI module into the main branch, the following validation steps will be required:
- Automated Unit Tests: Ensure
XAIEnginegenerates correctly dimensioned heatmaps without memory leaks. - Integration Tests: Run
src/pipeline.pyon a standard batch of SIPaKMeD test images to ensure thedata/reports/figures/directory populates correctly. - Clinical Review: Manually inspect the generated PDF reports to verify that the heatmaps accurately align with the biological structures of the cells and that the PDF layout remains professional and unbroken.