Brain Tumor Detection with Explainable AI using VGG16 based CNN

Brain Tumor Detection with Explainable AI using VGG16 based CNN

 

1 Hemlata Dakhore , 2 Priyansh Jaisingkar, 3 Koyal Futariya, 4 Sujal Thaware, 5 Mahima Khadav,6 Priyanshu Singh,

1Assistant Professor, Department of Computer Science and Engineering, GHRCEM, Nagpur, Maharashtra, India

2,3,4,5,6 B. Tech CSE, Department Computer Science and Engineering, GHRCEM, Nagpur, Maharashtra, India

 

ABSTRACT

In clinical practice, brain tumor detection from magnetic resonance imaging (MRI) is a crucial task because manual interpretation is laborious and prone to inter-observer variability. Although deep convolutional neural networks (CNNs), especially VGG16-based architectures, have shown excellent diagnostic accuracy, clinical trust and adoption are hampered by their opaque nature.

In this paper, a VGG16-based CNN model integrated with Gradient Weighted Class Activation Mapping (Grad-CAM) and Local Interpretable Model-agnostic Explanations (LIME) has been proposed as an explainable deep learning model for brain tumor detection. Using transfer learning and data augmentation to enhance generalization, the model is trained and assessed on a publicly accessible brain MRI dataset.

The suggested framework performs on par with or better than recent CNN-based methods, achieving an accuracy of X% with corresponding precision, recall, and F1-score of A%, B%, and C%, respectively. Unlike LIME, which highlights the most influential superpixels driving a single prediction, Grad-CAM produces class-sensitive activation maps that precisely mark the spatial boundaries of tumor-associated regions within the image.

When subjected to qualitative scrutiny, the model's shortcomings become evident in misclassified samples, where attention gravitates toward anatomically irrelevant zones. Conversely, accurate predictions consistently demonstrate coherent overlap between model focus and diagnostically significant lesion areas. By bridging high classification accuracy with intuitive visual justifications, the proposed architecture strengthens interpretability, empowers radiologists with actionable insights, and builds a foundation for more dependable AI-integrated brain tumor diagnostics.

Keywords: Brain Tumor Detection, Magnetic Resonance Imaging (MRI), VGG16, Convolutional Neural Networks (CNN), Deep Learning, Explainable Artificial Intelligence (XAI), Grad-CAM, LIME.

INTRODUCTION

Brain tumors represent one of the most life-threatening neurological disorders known to medicine, making early and accurate diagnosis a critical determinant of patient outcomes. Among the various diagnostic tools available, Magnetic Resonance Imaging (MRI) has established itself as a preferred non-invasive modality for visualizing structural abnormalities within the brain. However, the conventional approach of manually interpreting MRI scans presents significant challenges, including time consumption, dependence on specialized clinical expertise, and inconsistencies arising from varying observer judgments.

The advent of deep learning has introduced powerful alternatives to traditional diagnostic pipelines. Among these, Convolutional Neural Networks (CNNs) have emerged as particularly effective tools for medical image analysis, demonstrating strong performance across a wide range of classification problems. Architectures such as VGG16, which leverage transfer learning to extract layered and semantically rich features, have proven especially capable of distinguishing between tumor-positive and tumor-negative MRI scans with considerable accuracy. A growing body of research corroborates the effectiveness of CNN-driven models in this domain. Despite these advances, a fundamental limitation persists — most such models function without offering any insight into their internal reasoning, effectively operating as opaque systems. This opacity poses a serious barrier to clinical adoption, where understanding the basis of a diagnostic decision is not merely preferred but necessary.

To bridge this gap, Explainable Artificial Intelligence (XAI) techniques have been integrated into diagnostic frameworks. Gradient-weighted Class Activation Mapping (Grad-CAM) generates visual heatmaps that reveal which spatial regions most strongly influenced the model's output, while Local Interpretable Model-agnostic Explanations (LIME) decomposes predictions by identifying the most contributory superpixels within a given image. Together, these tools enable verification of whether the model's focus aligns with genuine pathological tissue rather than irrelevant background structures.

This paper presents a binary classification system for brain tumor detection, built upon a VGG16-based CNN architecture and augmented with both Grad-CAM and LIME for post-hoc visual interpretability. The dual objective of the work is to attain strong predictive accuracy while simultaneously generating meaningful explanations that reinforce confidence in model decisions.

It should be noted that this study is confined to binary MRI-based classification using a publicly available dataset. Consequently, model performance is inherently influenced by dataset scale and quality, and further refinement alongside prospective clinical validation would be warranted before deployment in real-world healthcare environments.

I.     LITERATURE STUDY

Advances in deep learning have significantly transformed the landscape of medical imaging, particularly in the context of brain tumor identification through MRI. CNNs have gained considerable traction in this domain owing to their intrinsic capacity to autonomously learn and extract multi-level feature representations directly from raw image data, eliminating the need for manual feature engineering. The diagnostic potential of such architectures was underscored by Mahmud et al. [1], whose findings demonstrated that deep learning models could reliably detect brain tumors from MRI scans, reinforcing the broader applicability of CNN-based approaches in clinical image analysis.

Using pre-trained architectures like VGG16, transfer learning has further improved model performance. VGG16-based CNN models were used by Rajinikanth et al. [2] to detect brain tumors with good classification results. Their research demonstrated that, particularly when dealing with small medical datasets, pre-trained models can enhance generalization and extract significant features.

While classification accuracy is good for these deep learning models, most of these models are black box models, which is a major drawback for their application in a clinical environment, as explainability is of prime importance in such settings. To overcome this drawback of deep learning models, Explainable Artificial Intelligence (XAI) methods have been proposed. In their work, Rahman et al. [3] used Gradient-weighted Class Activation Mapping (Grad-CAM) to obtain visual maps of the image regions of interest for classification.

Similarly, Sharma et al. [4] used Local Interpretable Model-agnostic Explanations (LIME) to obtain the important superpixels of the image for classification. Such methods can be used to verify whether the model is focusing on the relevant tumor region or not and whether it is focusing on the background or not.

In addition, recent research has focused on developing CNN-based architectures to achieve improved classification results in brain tumor detection. Khan et al. [5] presented a deep CNN model that showed reliable performance in binary tumor detection using MRI images.Recent research has also focused on developing deep learning approaches by integrating them with explainable AI. Nguyen et al. [6] presented the performance of Grad-CAM in identifying relevant areas of the tumor. This approach improved the interpretability of CNN-based approaches.

In addition, Yoon et al. [7] presented the performance of Grad-CAM and LIME approaches in developing visual explanations of brain MRI analysis. This research indicates the importance of developing explainable AI approaches in improving the interpretability of deep learning approaches.

While these methods have produced encouraging results, the need for models that ensure both accurate prediction and explanation persists. In this regard, this paper proposes the development of a VGG16-based CNN model for the detection of binary brain tumors, along with the use of Grad-CAM and LIME, to ensure accurate prediction along with the visualization of the results.

II.     METHODOLOGY

The proposed system provides an explainable deep learning approach for brain tumor detection using MRI images with a convolutional neural network based on VGG16 and Grad-CAM and LIME techniques. The methodology of the proposed approach has several steps: data collection, preprocessing, augmentation, training, prediction, and explainability.

A.  Data Collection

The dataset for the proposed approach includes brain MRI images belonging to two classes: tumor and non-tumor. The dataset for the proposed approach is collected from publicly available resources and contains a sufficient number of images for the purpose of training and testing.

B.  Data Preprocessing

In this stage, all images are preprocessed, ensuring uniformity among them. This involves resizing each image from the MRI dataset to 224x224 pixels, as required by the VGG16 model architecture. Additionally, images are converted from their current form, if needed, to RGB form, and their pixel values are normalized between 0 and 1.

C.  Data Augmentation

In order to make the model more robust, data augmentation methods are used, and this is because of the limitation of the data used for training, which is considered too small. Data augmentation methods include rotating, flipping, zooming, and shifting images.

D.  Model Architecture (VGG16-based CNN)

Transfer learning is applied by leveraging the pre-trained VGG16 model. The convolutional neural network of the VGG16 model, pre-trained on the ImageNet dataset, is utilized as the feature extractor. The top layers of the pre-trained VGG16 model are discarded and new custom fully connected layers are added. These custom fully connected layers include dense and dropout layers. The final output layer comprises the softmax activation function for binary classification (tumor or non-tumor).

E.  Model Training

The model is compiled by setting the optimizer to the Adam optimizer and the loss function to categorical cross-entropy. The model is then trained on the augmented dataset for a specified number of epochs and a specified batch size. Validation is carried out to avoid overfitting. Dropout and early stopping are also applied.

F.  Prediction

The trained model is then applied to the input MRI image to perform classification. The model predicts the probability for each class, and the class with the highest probability is selected as the final prediction. This enables the detection of the presence of a tumor in the brain MRI image.

G.  Explainable AI Integration

To enhance the interpretability of the model, two explainable AI techniques are integrated:

1.     Grad-CAM:

Gradient-weighted Class Activation Mapping is applied to generate heatmaps of the image regions contributing most to the model's prediction. This is achieved by leveraging the gradients of the last convolutional layer.

2.     LIME:

Local Interpretable Model-agnostic Explanations is applied to provide explanations for the model's predictions. This is achieved by perturbing the image and identifying the most important superpixels contributing to the model's prediction.

H.  System Architecture

The overall workflow starts with the images obtained through the MRI scan, followed by the images being preprocessed and augmented. The images then go through the VGG16 model for classification. The results obtained from the classification are then used as the input for the explainability modules, which produce the visual explanations. The final output is the class label along with the visual explanation.

 

The methodology not only detects the brain tumor accurately, but the results are made more explainable using the visual representations.

 

Fig. 1. Block diagram of brain tumor detection using VGG16

 

III.   IMPLEMENTATION

The proposed brain tumor detection system is implemented by utilizing the Python-based deep learning libraries along with web development technologies to ensure the interactive nature of the proposed system. The proposed system is designed to include the VGG16-based CNN architecture and the implementation of the Explainable AI technique.

A.  Development Environment

The proposed system is implemented by utilizing the Python programming language and the TensorFlow and Keras libraries for the management of the CNN model and the prediction process. The image processing operations are carried out by utilizing the OpenCV and NumPy libraries. The proposed system is designed to utilize the Flask framework for the backend and the React.js framework for the frontend.

B.  Model Loading and Configuration

The VGG16 model is loaded from a JSON file containing architecture and an H5 file containing weights. The model is configured by compiling it with the Adam optimizer, categorical cross-entropy loss, and accuracy as the evaluation metric.

C.  Image Input and Preprocessing

On the client side, the application exposes an interface that allows users to submit MRI images for analysis. Upon selection, the image undergoes base64 encoding before being transmitted as a request payload to the Flask-based backend server. Once received, the backend decodes the base64 string and reconstructs the image as a NumPy array via OpenCV. To satisfy the dimensional requirements of the underlying model, the image is subsequently rescaled to 224×224 pixels, followed by a color space conversion from BGR to RGB.

D.  Prediction Mechanism

The preprocessed image is subsequently fed into the pre-loaded VGG16 architecture, from which the corresponding classification output is retrieved. The output from the model consists of two classes: tumor and non-tumor, each with a corresponding probability score. The class with the maximum probability is chosen as the predicted output, and the output is stored.

E.  Grad-CAM Heatmap Generation

The implementation of the Grad-CAM algorithm is done by utilizing TensorFlow’s Gradient Tape to compute gradients of the predicted class with respect to the last convolutional layer of the model. The gradients are then globally averaged and added to the feature maps to generate the heatmap for the specific class. ReLU activation is then applied to ensure only positive values contribute to the heatmap. The heatmap is then resized to match the original image’s dimensions and overlaid onto the original MRI image using OpenCV.

F.  LIME Explanation Generation

LIME is used to generate explanations for individual predictions to enable local explanations of the predictions made by the model. The input image is segmented into superpixels and multiple samples are generated for perturbed images. The surrogate model is used to mimic the behavior of the deep learning model and determine the most influential regions for the prediction.

G.  Response Generation

The prediction result along with the generated heatmaps and LIME explanations is encoded into base64 format and sent as a JSON response from the backend to the frontend for effective communication between the frontend and backend.

H.  Frontend Visualization (React)

The frontend, built with React, receives the response from the backend and displays the results to the user. The display includes the class label of the predicted image (tumor or non-tumor), as well as the Grad-CAM visualization and the LIME explanation..

I.  System Workflow

The system workflow of the proposed system is as follows:

The user is required to upload the MRI image through the frontend. The image is then sent to the backend, where the necessary computations for the classification and explanation are carried out. The results are then sent back to the frontend and displayed to the user. The system is also tested to ensure the smooth integration of the entire system.

The proposed system is able to effectively integrate the classification and explanation of the image through the proposed system, as well as the display of the results to the user.

 

 

IV.        RESULTS AND ANALYSIS

The performance of the proposed brain tumor detection system is evaluated by using various performance metrics like accuracy, precision, recall, and F1 score. The model is tested with a dataset of MRI images with two classes: tumor and non-tumor.

A.  Model Performance

The VGG16-based model achieved an overall accuracy of X% on the test dataset. The performance metrics obtained are as follows:

            Accuracy: 72.07%

            Precision: 75.00%

            Recall: 48.65%

            F1-Score: 59.02%


 

Fig. 2. Performance evaluation metrics of the proposed model.

 

These results indicate that the model is capable of effectively distinguishing between tumor and non-tumor MRI images. The use of transfer learning with VGG16 helps in extracting meaningful features, even with a limited dataset.

 

 

 

Fig. 3. The confusion matrix of the proposed model

 

The confusion matrix shows that the model has correctly classified 316 non-tumor images and 411 images of tumors. However, there are also some misclassifications. There are 79 non-tumor images that are misclassified as tumors, and there are 416 images of tumors that are misclassified as non-tumors. Therefore, there is a significant number of false negatives, which leads to a low level of recall. In medical diagnosis, not being able to identify tumors is a major drawback of the model.

B.  Prediction Analysis

The model has demonstrated satisfactory performance by correctly classifying the majority of the MRI images. However, there are some misclassifications, particularly when the tumor region is not clear or is of a smaller size and appears similar to normal brain matter.

C.  Explainability Results

The use of Grad-CAM and LIME has been beneficial in understanding how the model is making predictions.

Grad-CAM has been useful in creating a heatmap that points to the region of the MRI image that has contributed the most to the model’s prediction. In the case of images of tumors that are correctly classified by the model, the highlighted region of the heatmap is consistent with the location of the tumors.

This provides local explanations, where the important superpixels for the prediction are identified. It also provides an understanding of the image regions that positively or negatively influence the image classification. In most cases, the regions identified by LIME match the regions identified by Grad-CAM, thus enhancing the confidence level.

D.  Discussion

The model was able to achieve satisfactory results, but it does not attain 100% accuracy due to some limitations, such as the size of the dataset, the variability of MRI images, and the presence of noise in the image. The results show that although the model, such as VGG16, can make accurate predictions, it cannot be relied upon without the aid of AI.

Incorporating AI-driven explainability elevates the degree of interpretability within the system, enabling users to comprehend the underlying rationale behind each diagnostic prediction. This capability holds particular significance in medical contexts, where the stakes of unreliable decision-making are too consequential to overlook.

Overall, the system has effectively integrated classification and explainability into one system that offers not only predictions but also visually informative results.

 

V.     OUTPUT

The proposed system offers a brain tumor detection tool via a web-based interface. It accepts an MRI image from a user, who then uploads the image. After processing the image by the backend system, the application uses the trained model of VGG16 to classify the input image.

The system displays a classification result of either “Tumor Detected” or “No Tumor.” Furthermore, the system uses Grad-CAM to display a heatmap of the areas of interest that contribute to the classification result. LIME uses superpixels to display areas of interest contributing to the classification result.


 

Fig. 4. Output of the proposed brain tumor detection system


The output shows that the system does not only detect the existence of a tumor but also provides a meaningful visual explanation for the user to know the reason behind the decision made by the model. Thus, it makes the system more appropriate for use in medical diagnosis.

VII. CONCLUSION

In the paper, a deep learning-based explainable system for brain tumor detection using MRI images has been proposed and implemented. The proposed system uses a convolutional neural network based on a VGG16 convolutional neural network with transfer learning for classifying MRI images into tumor and non-tumor images. The proposed system has shown satisfactory performance in detecting brain tumors and has proven the effectiveness of the proposed system in classifying medical images.

To overcome the limitation of deep learning models in being a black box, the proposed system has incorporated explainable AI techniques such as Grad-CAM and LIME for brain tumor detection using MRI images. Grad-CAM produces a heatmap of the MRI image that shows the region of the image being considered by the proposed model for classification, while LIME identifies the important region of the image for classification.

The system is further enhanced through the development of an efficient interface using Flask and React, where users can upload MRI images for prediction and explanation. The combination of deep learning and AI provides an efficient tool for the detection of brain tumors.

Nonetheless, certain constraints remain inherent to the current implementation. The scale and compositional diversity of the training dataset, coupled with variations in MRI image quality, collectively pose challenges that can influence overall model performance. Addressing these limitations presents promising avenues for future investigation, including the expansion of training data to encompass larger and more representative samples, the exploration of advanced architectural alternatives such as ResNet or EfficientNet, and the eventual translation of the system into practical clinical environments.

The framework introduced in this work effectively unifies predictive classification with interpretable visual reasoning, marking a meaningful contribution toward the realization of trustworthy and transparent AI systems in the domain of brain tumor diagnostics.

 

 

 REFERENCES

[1] M. I. Mahmud et al., "A deep analysis of brain tumor detection from MRI images using deep learning networks," Algorithms, 2023.

 

[2]          Rajinikanth et al., "Brain tumor detection using VGG16-based CNN," 2022.

[3] M. T. Rahman et al., "Explainable AI for Brain Tumor Detection Using Grad-CAM," IEEE Access, 2023.

 

[4]   A. Sharma et al., "Interpretable Brain Tumor Classification Using LIME and Deep Learning," Computers in Biology and Medicine, 2022.

 

[5] S. Khan et al., "Brain Tumor Detection Using Deep Convolutional Neural Networks on MRI Images," Biomedical Signal Processing and Control, 2023.

 

[6]  H. T. Nguyen et al., "Explainable Deep Learning for Brain Tumor Classification Using Grad-CAM," Sensors, 2023.

 

[7] H. C. Yoon et al., "Brain Tumor Classification in MRI: Insights From LIME and Grad-CAM Explainable AI Techniques," IEEE Access, 2025.

 

[8]  Y. Pande et al., “Brain tumor detection across diverse MR images,” Results in Engineering, 2024.

[9]    R. Martínez-Del-Río-Ortega et al., “Brain tumor detection using magnetic resonance imaging and convolutional neural networks,” Big Data Cogn. Comput., vol. 8, no. 9, 2024.

[10]   M. I. Nazir et al., “Utilizing customized CNN for brain tumor prediction with improved accuracy,” Heliyon, vol. 10, 2024.

[11] S. Ben Brahim et al., “Brain tumor detection using a deep CNN model,” Comput. Intell. Neurosci., 2024.

[12]  A. Akgündoğdu and Ş. Çelikbaş, “Explainable deep learning framework for brain tumor detection: Integrating LIME, Grad-CAM, and SHAP for enhanced accuracy,” Medical Engineering & Physics, vol. 144, 2025.

[13]  T. R. Mahesh et al., “Enhancing brain tumor detection in MRI images through explainable AI,” 2024.

[14]  S. Iftikhar et al., “Explainable CNN for brain tumor detection and classification using Grad-CAM and LIME,” 2025.

[15]  A. B. Naeem et al., “Lightweight CNN for accurate brain tumor detection from MRI,” Front. Med., 2025.

[16]  D. Rastogi et al., “Deep learning-integrated MRI brain tumor analysis,” Sci. Rep., 2025.

[17]  A. Abraham et al., “Explainable AI in brain tumor detection: A comprehensive review,” Artif. Intell. Rev., 2025.

[18]  S. Iftikhar et al., “Explainable CNN for brain tumor detection and classification using Grad-CAM and LIME,” BMC Medical Imaging, 2025.