XPathology-CNN is an Explainable AI (XAI) computer vision model designed for the binary classification of H&E-stained histopathology slides (Benign vs. Adenocarcinoma).
This model served as the core visual engine for the broader X-Pathology pipeline (but now upgraded to a better more accurate model), which pairs CNN-based feature extraction with Large Language Models (LLMs) to generate plain-English and clinical dual-persona diagnostic reports.
Output: Binary probability score (0 = Benign, 1 = Malignant)
📊 Performance & Training
The model exhibits highly stable convergence with minimal validation loss across 30 epochs, making its internal gradient structure highly optimal for feature extraction.
Metric
Value
Training Set
4,200 images
Validation Set
900 images
Validation Accuracy
1.00 (100%)
F1-Score
1.00 (Across both classes)
⚠️ Disclaimer!
The model is very accurate, but as it is trained on the architecture of VGG16 (which has 138 million trainable parameters) the data is pretty limited for its true capability, so the model has become a little overconfident!
Although it is very accurate on unseen data, but can be a little over-confident with the images that are not actually histo-reports 😂 (for example: If tested on the image of dog, it will accuse it as it is either Benign or Adenocarcinoma with 95%+ confidence)
🎯 Explainable AI (XAI) Integration
This model was explicitly fine-tuned to maintain stable gradients for Grad-CAM (Gradient-weighted Class Activation Mapping).
By targeting the final convolutional layer (block5_conv3), the model generates highly accurate heatmaps that highlight specific cellular structures—such as nuclear atypia or irregular glandular formations—that drive its diagnostic predictions. This transparency allows clinicians to verify the morphological basis of the AI's classification.
💻 How to Use
You can download and load this model directly into a TensorFlow/Keras environment using the huggingface_hub library.
1. Install Requirements
pip install tensorflow huggingface\_hub
2. Load the Model
bash
1import tensorflow as tf
2from tensorflow.keras import models, layers
3from tensorflow.keras.applications import VGG16
4from huggingface\_hub import hf\_hub\_download
56\# 1\. Download the weights from Hugging Face
7\# IMPORTANT: Replace 'YOUR\_USERNAME' with your actual Hugging Face handle
8model\_path \= hf\_hub\_download(repo\_id="YOUR\_USERNAME/XPathology-CNN", filename="C\_DA\_1.h5")910\# 2\. Reconstruct the architecture
11conv\_base \= VGG16(weights=None, include\_top=False, input\_shape=(256, 256, 3))12conv\_base.\_name \='vgg16\_base'1314cnn\_model \= models.Sequential(\[15 conv\_base,
16 layers.Flatten(name='flatten\_layer'),
17 layers.Dense(256, activation='relu', name='dense\_hidden'),
18 layers.Dense(1, activation='sigmoid', name='dense\_output')19\])2021\# 3\. Load the weights
22cnn\_model.load\_weights(model\_path)23print("XPathology Model Loaded Successfully\!")
⚠️ Disclaimer
This model is developed for educational, portfolio, and research purposes only. It is not intended for use in actual clinical diagnostics or patient care. All AI-assisted medical screenings must be reviewed by a certified human pathologist.