X-PATHOLOGY
AgenticEra Systems · AI-Assisted Oncology Screening

About X-Pathology

The Engineering Journey
From Single Model to Multi-Specialist Platform

Building a reliable medical AI requires rigorous iteration. X-Pathology has evolved through four major architectural versions — from a binary VGG16 baseline to a multi-specialist platform with temperature-calibrated CNN models for both colorectal histopathology and brain tumor MRI classification, each with Grad-CAM explainability and Gemini-powered dual-persona reporting.

0
Specialist Models
0
Total Classes
0.0%
Colon Internal Acc
0.0%
Colon External Acc
0.0%
Brain Holdout Acc
Architecture Evolution
Deprecated

Version 1.0: Establishing the Baseline (VGG16)

Our initial proof-of-concept utilized a heavyweight VGG16 architecture focused on a binary classification task (Colon Adenocarcinoma vs. Normal). While this 150MB+ model successfully established our foundational Grad-CAM explainability pipeline and achieved high baseline accuracy, it exhibited a common deep learning phenomenon: network overconfidence.

The massive parameter count acting on a simple binary sigmoid output led to mathematical saturation, resulting in "100% confidence" predictions even on out-of-distribution data. In a clinical setting, nuance is critical. We needed a scalpel, not a sledgehammer.

Superseded

Version 2.0: The Multi-Organ Experiment (MobileNetV2)

We transitioned to a lightweight MobileNetV2 backbone (8.6 MB) and expanded to a 5-class multi-organ model covering both Colon and Lung histopathology. This achieved ~98% accuracy and eliminated the binary overconfidence issue.

However, a critical problem emerged: although the model detected cancer accurately, it sometimes produced organ-mismatched reports — classifying colon tissue with a lung report and vice versa. This cross-organ confusion made the multi-organ approach unreliable for clinical-grade screening and motivated a fundamental rethinking of the model scope.

Cancer detection accurate
17× smaller than VGG16
⚠️ Organ confusion in reports
Foundation

Version 3.0: The Colon Specialist (EfficientNetB1)

To solve the organ-confusion problem, we adopted a single-organ specialist strategy. The EfficientNetB1 backbone trained exclusively on NCT-CRC-HE-100K and validated on the independent CRC-VAL-HE-7K holdout set — achieving 99.1% internal and 92.7% external accuracy across 9 colorectal tissue types with post-training temperature calibration (T=0.5576).

9-class colorectal classification
Temperature-calibrated confidence
External holdout validated
Current

Version 4.0: Multi-Specialist Platform (Colon + Brain)

V4 transforms X-Pathology from a single-model tool into a multi-specialist diagnostic platform. A new EfficientNetB0 Brain Tumor MRI Specialist joins the Colon Specialist, classifying brain MRI scans into 4 tumor categories. The backend now uses a dynamic specialist routing architecture, loading and dispatching to the correct model based on user selection — proving that the specialist-per-organ paradigm scales cleanly to new medical domains.

Milestone 01

Multi-Specialist Router

A dynamic backend architecture loads multiple specialist CNNs at startup, each with its own temperature calibration, class labels, and Grad-CAM target layers. The /api/analyze endpoint routes to the correct specialist via a simple parameter.

Milestone 02

Brain Tumor MRI Specialist

EfficientNetB0 trained on the Brain Tumor MRI Dataset classifies glioma, meningioma, pituitary tumor, and no-tumor. Temperature-calibrated (T=0.7867) with 96.2% holdout accuracy on 1,600 unseen images.

Milestone 03

Anatomical Plausibility Check

For brain MRI, the system validates that Grad-CAM activation centroids align with expected anatomical locations — flagging potential misclassifications when heatmaps highlight implausible regions.

Milestone 04

Domain-Adapted Prompts

Gemini receives specialist-specific prompts: pathology terminology for colon analysis, radiology terminology for brain MRI. Each domain gets appropriately tailored clinical and patient-facing report sections.

Model Spotlight — Brain Tumor MRI Specialist

The XPathology Brain Tumor MRI Specialist is a fine-tuned EfficientNetB0 CNN trained to classify T1-weighted axial brain MRI scans into 4 diagnostic categories: glioma, meningioma, pituitary tumor, and no tumor. Trained on the Brain Tumor MRI Dataset (Masoud Nickparvar, Kaggle), it uses the dataset's standard Training/Testing split with a 1,600-image holdout set that was never seen during training.

🏗️
ArchitectureEfficientNetB0 (ImageNet)
📐
Input Size224 × 224 × 3 (RGB)
🎯
Output4-class softmax
🌡️
TemperatureT = 0.7867
📊
Holdout Accuracy96.2% (1,600 images)
Training HardwareKaggle T4 (single GPU)

The model uses a two-phase training strategy: a 10-epoch warm-up with a frozen backbone (LR=1e-3), followed by fine-tuning with the top 20% of layers unfrozen (LR=1e-5). MRI-specific augmentations include horizontal flips (brain symmetry), ±15° rotation, brightness/contrast variation — but no vertical flip or hue/saturation changes, as these are anatomically invalid for MRI.

Known limitation: Glioma recall is ~78%, consistent with a dataset-level ceiling confirmed across 4 training runs. The glioma↔meningioma overlap is inherent to 2D T1-weighted MRI without multi-modal or 3D volumetric context. This is a single-slice classifier — clinical diagnosis uses full 3D volumes.
🤗 View on Hugging Face📓 Training Notebook
How It Works
🧠
Step 01

Select Specialist & Upload

Choose the specialist model — Colon (H&E histopathology patch) or Brain (T1-weighted MRI scan). Upload via drag-and-drop, file picker, or the pre-loaded sample gallery.

🧪
Step 02

Specialist CNN Inference

The selected specialist model processes the image: EfficientNetB1 for 9-class colorectal tissue classification (240×240) or EfficientNetB0 for 4-class brain tumor classification (224×224).

🌡️
Step 03

Temperature-Calibrated Confidence

Post-training temperature scaling converts raw logits into calibrated probabilities. Colon uses T=0.5576, Brain uses T=0.7867 — each tuned on its holdout set.

🔥
Step 04

Grad-CAM XAI Heatmap

Gradient-weighted Class Activation Mapping targets specialist-specific layers — block7a_project_bn for Colon, top_conv for Brain — generating visual explanations of what the CNN focused on.

Step 05

Gemini 3.1 Flash Lite LLM Analysis

Both the original image and Grad-CAM overlay are sent to Gemini with domain-adapted prompts — pathology terminology for colon, radiology terminology for brain MRI. A dual-persona report is generated.

📋
Step 06

Dual-Persona Report

The final dashboard displays: the original image, Grad-CAM overlay, full probability breakdown, a Clinical/Radiology Report for professionals, and a compassionate Patient-Facing Summary.

Tech Stack
🧪

TensorFlow / Keras

Deep learning backbone powering the EfficientNetB1 Colon Specialist (9-class) and EfficientNetB0 Brain Specialist (4-class) with temperature-calibrated inference.

FastAPI

High-performance async Python backend with dynamic multi-specialist model routing, Grad-CAM generation, and calibrated probability computation.

⚛️

Next.js 16

React-based frontend with App Router, specialist selection UI, interactive sample galleries, and a premium clinical-grade dark theme.

💎

Gemini 3.1 Flash Lite

Google's multimodal LLM receives domain-adapted prompts per specialist, visually verifying heatmaps and generating dual-persona clinical reports.

🔬

Grad-CAM

Explainable AI technique generating visual heatmaps via specialist-specific convolutional layers — block7a_project_bn for colon, top_conv for brain.

🤗

Hugging Face Hub

Cloud-based model hosting for both specialists — Xpathology-Colon-Specialist and xpathology-brain-specialist — with versioned weights and calibration assets.

The Team
Syed Muhammad Hassan

Syed Muhammad Hassan

Lead AI Engineer & Full-Stack Developer

Co-Founder, AgenticEra Systems

A passionate programmer, expert in Deep Learning and Neural Networking. Driving the core AI pipeline — from model architecture to full-stack deployment.

Supercharged by Gemini 3.1 & Antigravity as my AI coding partners.

Built By

AgenticEra Systems

Pioneering the intersection of agentic AI and real-world applications. From intelligent code assistants to medical diagnostics — we build AI systems that augment human expertise with precision and responsibility.

Follow on LinkedIn
Colon Specialist — 9-Class Tissue Classification

The EfficientNetB1 Colon Specialistclassifies H&E-stained colorectal tissue patches into 9 distinct tissue categories. Only the TUM class is considered clinically neoplastic (malignant).

ADI · Benign

Adipose Tissue

Fat tissue surrounding the colon
BACK · Benign

Background

Non-tissue background regions
DEB · Benign

Debris / Necrosis

Cellular debris and necrotic tissue
LYM · Benign

Lymphocytes

Immune cell aggregates and infiltrates
MUC · Benign

Mucus

Mucinous secretions and pools
MUS · Benign

Smooth Muscle

Muscularis propria / muscularis mucosae
NORM · Benign

Normal Colon Mucosa

Healthy epithelial glandular tissue
STR · Benign

Cancer-Associated Stroma

Desmoplastic stromal reaction tissue
TUM · Malignant

Colorectal Adenocarcinoma

Tumour epithelium — neoplastic
Brain Specialist — 4-Class MRI Tumor Classification

The EfficientNetB0 Brain Specialist classifies T1-weighted axial brain MRI scans into 4 diagnostic categories. Glioma is flagged as high concern, while meningioma and pituitary tumors are flagged as moderate concern.

glioma · High Concern

Glioma

Most aggressive primary brain tumor — morphologically heterogeneous across MRI slices
meningioma · Moderate Concern

Meningioma

Typically benign, arises from meninges — can overlap with glioma on 2D slices
pituitary · Moderate Concern

Pituitary Tumor

Tumor of the pituitary gland in the sella turcica — lower-centre brain region
notumor · Clear

No Tumor Detected

Normal brain MRI scan — no abnormal mass identified
Note on glioma recall (~78%): Glioma is the most morphologically heterogeneous class. The glioma↔meningioma confusion is consistent with published benchmarks on this dataset — both tumor types can present with overlapping MRI signal characteristics at 2D slice level. This was confirmed across four systematic training runs, confirming a dataset-level ceiling rather than a training failure.