Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views32 pages

Deep Learning

This document outlines a mini-project focused on developing a brain tumor detection application using deep learning techniques. The project utilizes the Streamlit framework, a Brain Tumor MRI dataset, and CNN with VGG16 transfer learning models. It includes detailed descriptions of the project stages, methodologies, and evaluation processes for the application.

Uploaded by

Safa Ben Othmen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views32 pages

Deep Learning

This document outlines a mini-project focused on developing a brain tumor detection application using deep learning techniques. The project utilizes the Streamlit framework, a Brain Tumor MRI dataset, and CNN with VGG16 transfer learning models. It includes detailed descriptions of the project stages, methodologies, and evaluation processes for the application.

Uploaded by

Safa Ben Othmen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

ECOLE SUPERIEIURE PRIVEE DES TECHNOLOGIES DE L’INFORMATION ET DE

MANAGEMENT DE NABEUL

Deep learning Project

Prepared by:
Safa BEN OTHMEN

Project Deep Learning


« Brain Tumor Detection »

Supervised by :

Mr. Ahmed Ben Taleb

2024 - 2025
RESUME

This work is part of our mini-project at ITBS for the 2024-2025 academic
year. The objective of this project is to develop a brain tumor detection
application. For its implementation, we have chosen to use the Streamlit
framework, the Brain Tumor MRI dataset, and CNN with VGG16 transfer
learning models. This document provides a detailed description of the
different stages of the project implementation.

Key words: CNN,DL,VGG16,Streamlit


Table des matières

General Introduction 1

1 Project Context 2

Project Context 2
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Proposed solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Working Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4.1 Proposed Methodology for Brain Tumor Classification . . . . . . . . . . . . 3
1.4.1.1 Dataset Selection . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4.1.2 Data Preprocessing . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4.1.3 Data Augmentation . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4.1.4 Transfer Learning and Model Evaluation . . . . . . . . . . . . . . 4
1.4.1.5 Model Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4.1.6 Classification and Outcome . . . . . . . . . . . . . . . . . . . . . 4
1.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 State of the Art 5


2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Learning Techniques Used in Our Platform . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Deep Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3.1 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3.2 Deep Learning algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3.2.1 Convolutional Neural Networks (CNN) . . . . . . . . . . . . . . . 6
2.3.2.2 Recurrent Neural Networks (RNN) . . . . . . . . . . . . . . . . . 6
2.3.2.3 Long short-term memory (LSTM) networks . . . . . . . . . . . . 6
2.3.3 algorithm used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3.4 Transfer Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3.4.1 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3.4.2 Differences Between Pre-Trained Models . . . . . . . . . . . . . . 9
2.3.4.3 VGG16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3.4.4 ResNet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3.4.5 MobileNet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3.4.6 Model Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

ii
3 Development 10
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2 Data Acquisition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2.1 Data Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2.2 Data splitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3 Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3.1 Basic CNN Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3.1.1 Architecture Description . . . . . . . . . . . . . . . . . . . . . . 12
3.3.2 Data Augmentation to Improve Generalization . . . . . . . . . . . . . . . . 13
3.3.3 Use of the Pretrained VGG16 Model . . . . . . . . . . . . . . . . . . . . . . 15
3.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

4 Evaluation and Deployment 17


4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2 Model Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2.1 Basic Model CNN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2.1.1 Loss Function Evolution . . . . . . . . . . . . . . . . . . . . . . . 17
4.2.1.2 Categorical Accuracy Progression . . . . . . . . . . . . . . . . . . 18
4.2.1.3 Accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2.2 Augmented CNN Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2.2.1 Loss Function Evolution . . . . . . . . . . . . . . . . . . . . . . . 19
4.2.2.2 Categorical Accuracy Progression . . . . . . . . . . . . . . . . . . 20
4.2.2.3 Final Accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.2.3 VGG16 Transfer Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.2.3.1 Loss Function Evolution . . . . . . . . . . . . . . . . . . . . . . . 21
4.2.3.2 Categorical Accuracy Progression . . . . . . . . . . . . . . . . . . 21
4.2.3.3 Final Accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3 Model Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3.1 deployment via Streamlit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3.1.1 Preparing the Model for Deployment . . . . . . . . . . . . . . . . 22
4.3.1.2 Building the Streamlit Application . . . . . . . . . . . . . . . . . 22
4.3.2 Cloud Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.3.2.1 Choice of Cloud Platform . . . . . . . . . . . . . . . . . . . . . . 24
4.3.2.2 Application Deployment . . . . . . . . . . . . . . . . . . . . . . 24
4.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

Conclusion 25

Bibliographie 26

iii
Table des figures

1.1 Workflow methodology for brain tumor classification . . . . . . . . . . . . . . . . . 3

2.1 Architecture of CNN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3.1 Data distribution of the dataset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11


3.2 Splitting the dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3 Convolutional Neural Network Architecture . . . . . . . . . . . . . . . . . . . . . . 13
3.4 Data Augmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.5 Pre-trained moel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.6 Pre-trained moel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

4.1 Model Loss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18


4.2 Accuracy Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.3 Accuracy-Basic CNN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.4 Loss Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.5 Augmented CNN Accuracy Progression . . . . . . . . . . . . . . . . . . . . . . . . 20
4.6 Accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.7 VGG16 Loss Evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.8 VGG16 Accuracy Progression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.9 VGG16 Performance Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.10 Model registration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.11 result interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

iv
Liste des tableaux

v
General Introduction

The accurate diagnosis of brain tumors from MRI scans is a critical yet time-
consuming challenge in clinical practice, requiring advanced expertise to interpret
complex imaging patterns. This research addresses the growing need for reliable
computer-aided diagnostic systems by developing deep learning models for automa-
ted tumor classification.
Using a dataset of 7,000 annotated MRI scans covering four tumor categories
(glioma, meningioma, pituitary, and no tumor), we implement and compare multiple
neural network architectures. The study begins with a custom-designed convolutio-
nal neural network (CNN) to establish baseline performance, then enhances model
robustness through systematic data augmentation techniques. We further optimize
detection accuracy by adapting the pre-trained VGG16 model via transfer learning,
demonstrating how existing architectures can be specialized for medical imaging
tasks
The structure of this project is organized into four main chapters as follows :

• Chapter 1 : Project Context


• Chapter 2 : State of the Art
• Chapter 3 : Model Implementation
• Chapter 4 : Evaluation and Deployment

1
Chapitre 1

Project Context

1.1 Introduction
The objective of this chapter is to present the problem that this project aims to
solve in the first section, then discuss the objectives we aim to achieve. Then, we
will propose solutions. Finally, we will outline the methodology chosen for the de-
velopment and deployment of our solution.

1.2 Problem Statement


Early detection of tumeurs cérébrales (brain tumors) is critical to improve pa-
tient survival rates, but current methods (e.g., manual analyse d’IRM) are time-
consuming, subjective, and error-prone. Existing AI-based solutions often lack ac-
curacy or fail to generalize across diverse datasets. This project aims to develop a
reliable, automated modèle d’IA (AI model) for détection et segmentation des tu-
meurs from images IRM (MRI scans), balancing speed and interpretability to assist
radiologues in diagnostics.

1.3 Proposed solution


The purpose of this project will be to create a convolutional neural network that
can classify a MRI of the brain . We will start with a baseline model. From there we
use data agumentation to add data. Then we will apply transfer learning to improve
the accuracy. The idea is that the accuracy will improve with each step.

1.4 Working Methodology


Given the specific objectives of this project, which involve the classification of
brain tumors from MRI images using deep learning techniques, a customized metho-

2
CHAPITRE 1. PROJECT CONTEXT 3

dology has been adopted to ensure an efficient and structured development process.
The proposed methodology follows a sequence of essential steps, starting from
data acquisition and ending with the final classification outcome. The different phases
are detailed below :

1.4.1 Proposed Methodology for Brain Tumor Classification


The workflow of the adopted methodology is illustrated in the figure below.

Figure 1.1 – Workflow methodology for brain tumor classification

1.4.1.1 Dataset Selection

The dataset used consists of brain MRI images, including four categories : glioma
tumor, pituitary tumor, meningioma tumor, and no tumor.

1.4.1.2 Data Preprocessing

Preprocessing involves preparing the MRI images by resizing them to a uniform


dimension, normalizing pixel values, and splitting the dataset into training (70%),
testing (15%), and validation (10%) sets to facilitate model evaluation.

1.4.1.3 Data Augmentation

To increase the diversity of the training set and prevent overfitting, data augmen-
tation techniques such as rotation, flipping, zooming, and shifting were applied. This
step helps the model generalize better to unseen data.
CHAPITRE 1. PROJECT CONTEXT 4

1.4.1.4 Transfer Learning and Model Evaluation

Given the limited size of the dataset, transfer learning was employed using pre-
trained convolutional neural networks (CNNs). The selected model was fine-tuned
and evaluated on the prepared dataset to leverage the pre-learned features and adapt
them to the specific task.

1.4.1.5 Model Phase

During this phase, the fine-tuned model is trained on the augmented dataset. Hy-
perparameters were optimized to improve the learning process, and model evaluation
was conducted iteratively to monitor progress and adjust parameters as needed.

1.4.1.6 Classification and Outcome

Finally, the trained model is used to classify new MRI images into one of the four
categories : glioma, pituitary tumor, meningioma tumor, or normal. The model’s per-
formance was assessed using appropriate metrics such as accuracy, precision, recall,
and F1-score.

1.5 Conclusion
In this chapter, we outlined the problem and the objective to be achieved for our
project, and proposed our solution. Finally, we presented the choice of the methodo-
logy we have adopted.
Chapitre 2

State of the Art

2.1 Introduction
Once the methodology is chosen,In this chapter, we present the different existing
techniques used for brain tumor detection from MRI image

2.2 Learning Techniques Used in Our Platform


Before delving into the details of the implementation of the chosen solution, it is
important to introduce some fundamental concepts related to our working context.
Since we decided to use deep learning techniques, it is essential to explain the basic
concepts of deep learning, its types, and the main existing models. This will help
justify the choice of the model used to detect brain tumors from MRI images in our
platform.

2.3 Deep Learning


2.3.1 Definition
Deep learning is one of the main technologies of Machine Learning . With Deep
Learning, we are talking about algorithms capable of mimicking the actions of the
human brain using artificial neural networks . The networks are composed of dozens
or even hundreds of ”layers” of neurons, each receiving and interpreting information
from the previous layer.

5
CHAPITRE 2. STATE OF THE ART 6

2.3.2 Deep Learning algorithms


2.3.2.1 Convolutional Neural Networks (CNN)

Also known as ConvNets, CNNs consist of a multitude of layers responsible for


processing and extracting features from data. Specifically, convolutional neural net-
works are used for object analysis and detection. They can therefore be used, for
example, to recognize satellite images , process medical images, detect anomalies or
predict time series

2.3.2.2 Recurrent Neural Networks (RNN)

Recurrent neural networks have connections that form directed cycles. This al-
lows the outputs of the LSTM to be used as inputs at the current phase. The output
of the LSTM becomes an input for the current phase. It can therefore remember
previous inputs using its internal memory. In practice, RNNs are used for image
captioning , natural language processing, and machine translation.

2.3.2.3 Long short-term memory (LSTM) networks

LSTMs are derivatives of RNNs. They can learn and memorize dependencies over
a long period of time. LSTMs thus retain memorized information over the long term.
They are particularly useful for predicting time series data because they remember
previous inputs. Besides this use case, LSTMs are also used for composing musical
notes and recognizing voices.

2.3.3 algorithm used


The learning algorithm adopted in our application is Convolutional Neural Net-
works (CNNs). Indeed, CNNs are equipped with an architecture widely used in
image and video recognition tasks.
CHAPITRE 2. STATE OF THE ART 7

Figure 2.1 – Architecture of CNN

The following are definitions of different layers shown in the above architecture :

Convolutional Layers
Convolutional layers operate by sliding a set of filters or kernels across the input data.
Each filter is designed to detect specific features or patterns, such as edges, corners,
or more complex shapes in deeper layers. As these filters move across the image,
they generate a feature map highlighting where particular features were detected.
In simple terms, convolutional layers are responsible for extracting features from
the input images.

Pooling Layers
Pooling layers follow convolutional layers and are used to reduce the spatial dimen-
sions (width and height) of the input. An image can be thought of as a grid of pixels ;
reducing spatial dimensions helps decrease the number of parameters and computa-
tion in the network.
Pooling layers help to prevent overfitting and enable the model to train faster and
more efficiently.

Fully Connected Layers


Fully connected layers (or dense layers) are layers where each neuron is connected
to every neuron in the previous layer. They are typically placed towards the end
of a Convolutional Neural Network (CNN). Their role is to combine the features
extracted by the convolutional and pooling layers to make final predictions, such as
classifying an input into specific categories.

Output Layer
CHAPITRE 2. STATE OF THE ART 8

The output layer in a CNN is crucial, as it produces the final output of the network,
either for classification or regression tasks.
• Transformation of Features to Final Output : The earlier layers extract and
abstract features from the input ; the output layer transforms these features into
a final, interpretable result.
• Task-Specific Formulation :
– For classification tasks, the output layer typically uses a softmax activa-
tion function to convert the features into a probability distribution over the
predefined classes, ensuring that the probabilities sum to 1.
– For regression tasks, the output layer usually consists of one or more neu-
rons with a linear (or no) activation function, producing continuous output
values.

2.3.4 Transfer Learning


After selecting a CNN architecture as the foundation of our solution, we imple-
mented a transfer learning approach to enhance performance given our limited data-
set

2.3.4.1 Definition

Transfer learning is a machine learning technique where a model trained on one


task is repurposed as the foundation for a second task. This approach is beneficial
when the second task is related to the first or when data for the second task is limited.
Transfer learning offer solutions to key challenges like :
1. Limited Data : Acquiring extensive labeled data is often challenging and costly.
Transfer learning enables us to use pre-trained models, reducing the dependency
on large datasets.
2. Enhanced Performance : Starting with a pre-trained model, which has already
learned from substantial data, allows for faster and more accurate results on new
tasks—ideal for applications needing high accuracy and efficiency.
3. Time and Cost Efficiency : Transfer learning shortens training time and conserves
resources by utilizing existing models, eliminating the need for training from
scratch.
4. Adaptability : Models trained on one task can be fine-tuned for related tasks,
making transfer learning versatile for various applications, from image recog-
nition to natural language processing.
CHAPITRE 2. STATE OF THE ART 9

2.3.4.2 Differences Between Pre-Trained Models

In the context of transfer learning, we compared several pre-trained models to


select the most appropriate one for brain tumor detection using MRI images.

2.3.4.3 VGG16

VGG16 is a deep Convolutional Neural Network (CNN) architecture consisting


of 16 layers, including 13 convolutional layers and 3 fully connected layers. The
network is characterized by its simplicity and uniform architecture, where small 3x3
convolution filters are stacked to increase the depth.

2.3.4.4 ResNet

ResNet introduit des blocs résiduels qui permettent d’avoir des réseaux très pro-
fonds tout en évitant le problème de gradient évanescent. ResNet peut avoir des
centaines, voire des milliers de couches.

2.3.4.5 MobileNet

MobileNet utilise des convolutions séparables en profondeur pour réduire le nombre


de paramètres et la complexité du calcul tout en maintenant une bonne précision. Ce
modèle est conçu pour être léger et rapide, ce qui le rend adapté aux appareils mo-
biles et aux applications en temps réel.

2.3.4.6 Model Selection

In our study, we observed that the architecture of VGG-16 proved to be the most
efficient for the medical image classification task, achieving high performance com-
pared to the architectures of VGG-19 and ResNet50. This was true across different
image contrast states, whether the images were in their normal state or enhanced by
the CLAHE technique

2.4 Conclusion
In this chapter, we provided an overview of deep learning, highlighting the lear-
ning techniques used in our application.
Chapitre 3

Development

3.1 Introduction
This chapter details the data processing and modeling approach for brain tumor
detection from MRI scans. We cover dataset preparation, CNN architecture design,
and performance enhancement techniques including data augmentation and transfer
learning with VGG16.

3.2 Data Acquisition


3.2.1 Data Collection
The dataset used for this project, the ”Brain tumor mri Database”, is publicly
available on Kaggle. You can access the dataset via the following link : Brain tu-
mor mri Database. This dataset consists of over 7,000 brain images, categorized as
shown in Figure . The images are organized into subfolders based on specific disease
categories and subfolders for healthy brains,

10
CHAPITRE 3. DEVELOPMENT 11

Figure 3.1 – Data distribution of the dataset.

3.2.2 Data splitting


To ensure a reliable evaluation of the model, the data was split into three distinct
sets :

• Training Set (Train) : Represents 70% of the data and is used to train the
model.
• Test Set (Test) : Consists of the remaining 20% and This subset is used to
evaluate the final performance of the model.
• Validation Set :Represents 10% ,This subset is further split from the training
data to tune the model’s hyperparameters and prevent overfitting.
CHAPITRE 3. DEVELOPMENT 12

Figure 3.2 – Splitting the dataset

3.3 Modeling
To accomplish the task of brain tumor detection from MRI images, several deep
learning models were developed and evaluated. Initially, a basic CNN model was
implemented to establish a baseline performance. Subsequently, data augmentation
techniques were applied to enhance the model’s robustness. Finally, a Transfer Lear-
ning approach was explored using the pre-trained VGG16 model

3.3.1 Basic CNN Model


3.3.1.1 Architecture Description

Once our data was prepared, it was time to present the architecture of our CNN
model.

• Input Layer : Accepts images of size (150 × 150 × 3).


• First Convolutional Block :
– A Conv2D layer with 32 filters of size (3 × 3), using ReLU activation.
– Followed by a MaxPooling2D layer with a (2 × 2) pooling window.
• Second Convolutional Block :
– A Conv2D layer with 64 filters of size (3 × 3), using ReLU activation.
– Followed by a MaxPooling2D layer with a (2 × 2) pooling window.
• Third Convolutional Block :
– A Conv2D layer with 128 filters of size (3 × 3), using ReLU activation.
– Followed by a MaxPooling2D layer with a (2 × 2) pooling window.
CHAPITRE 3. DEVELOPMENT 13

• Fourth Convolutional Block :


– A Conv2D layer with 128 filters of size (3 × 3), using ReLU activation.
– Followed by a MaxPooling2D layer with a (2 × 2) pooling window.
• Flattening Layer : Converts the 2D feature maps into a 1D feature vector.
• Fully Connected Layer :
– A Dense layer with 512 neurons and ReLU activation.
– A Dropout layer with a dropout rate of 0.5 to prevent overfitting.
• Output Layer :
– A Dense layer with a number of neurons equal to the number of categories,
using softmax activation for multi-class classification.

Figure 3.3 – Convolutional Neural Network Architecture

3.3.2 Data Augmentation to Improve Generalization


Once the basic CNN model was established, data augmentation techniques were
applied to enhance the model’s generalization ability. The goal of data augmentation
is to artificially increase the diversity of the training dataset by applying various
transformations to the input images.
CHAPITRE 3. DEVELOPMENT 14

Applied Transformations

• Rescaling : Normalization of pixel values to the range [0,1]


• Rotation : Random rotations within ±20◦ to introduce orientation variability
• Width Shift : Horizontal translations of up to 10% of image width
• Height Shift : Vertical translations of up to 10% of image height
• Shear Transformation : Shear intensity of 0.1 to simulate perspective distor-
tions
• Zoom : Random zooming within ±10% magnification
• Horizontal Flip : Random left-right flipping for orientation invariance
• Vertical Flip : Random up-down flipping for additional variability
• Fill Mode : Nearest-neighbor interpolation for generated pixels

Expected Impact :

Applying these transformations artificially increases the diversity of the training


data, encouraging the model to learn more robust and invariant features. This helps
reduce overfitting, improves generalization to unseen data, and ultimately leads to
better performance in real-world scenarios

Figure 3.4 – Data Augmentation


CHAPITRE 3. DEVELOPMENT 15

3.3.3 Use of the Pretrained VGG16 Model


Introduction to Transfer Learning

Transfer Learning refers to using a model that has been pretrained on a large
dataset to solve a similar problem with a new dataset. This approach helps reduce
training time and enhances performance, especially when working with a limited
amount of data.
In the context of brain tumor detection from medical images, the idea is to le-
verage a model already trained to classify general objects (like VGG16, which was
trained on ImageNet) and adapt it to detect brain tumors.
Why VGG16 ?
VGG16 is a deep convolutional neural network (CNN) model developed by the
Visual Geometry Group at the University of Oxford. It was trained on the ImageNet
dataset, which contains over 1 million images across 1000 categories. This model has
demonstrated an excellent ability to extract high-level features from images, making
it highly suitable for transfer learning.
In the case of brain tumor detection, we will adapt VGG16 so that it can identify
tumors from specific medical images

Steps for Adapting the VGG16 Model for Brain Tumor Detection :
1. Data Preparation Before adapting the VGG16 model, it is essential to properly
prepare the brain images. Here are the key steps involved in data preparation :

• Image Resizing : The images must be resized to the dimensions of 224x224


(the expected input size for VGG16).
• Data Normalization : The pixel values should be normalized to a scale of
0 to 1, which is commonly done by dividing the pixel values by 255.
• Image Labeling : The images should be labeled according to their respec-
tive categories.

2. Loading the Pre-trained VGG16 Model : VGG16 is available in popular li-


braries like Keras. We can load this model without the classification layers (i.e.,
without the top part, which is typically used for classifications on ImageNet),
as we will adapt it to our specific task.
CHAPITRE 3. DEVELOPMENT 16

Figure 3.5 – Pre-trained moel

3. Adding Additional Layers : After loading the pre-trained VGG16 model, we


need to add extra layers to adapt it for the brain tumor classification task. These
layers include :
(a) Flatten : This layer flattens the feature maps extracted by VGG16.
(b) Dense : The dense layer is used for classification.
(c) Dropout : A regularization layer to prevent overfitting.

Figure 3.6 – Pre-trained moel

3.4 Conclusion
We presented a complete pipeline for brain tumor classification, from data split-
ting to advanced modeling. The next chapter will evaluate these models’ perfor-
mance. The next step involves evaluating and comparing the performance of each
model.
Chapitre 4

Evaluation and Deployment

4.1 Introduction
Model evaluation in deep learning is essential for selecting optimal architectures
and ensuring clinical applicability. This chapter presents a comparative analysis of
our CNN models and their deployment

4.2 Model Evaluation


4.2.1 Basic Model CNN
4.2.1.1 Loss Function Evolution

this figure demonstrates the progressive decrease of cross-entropy loss during trai-
ning and validation, indicating stable learning :

17
CHAPITRE 4. EVALUATION AND DEPLOYMENT 18

Figure 4.1 – Model Loss

4.2.1.2 Categorical Accuracy Progression

This figure shows the model’s improving classification performance :

Figure 4.2 – Accuracy Model


CHAPITRE 4. EVALUATION AND DEPLOYMENT 19

4.2.1.3 Accuracy

Accuracy is a metric that measures how often a machine learning model correctly
predicts the outcome. Here are the accuracy results for the Basic CNN Model

Figure 4.3 – Accuracy-Basic CNN

4.2.2 Augmented CNN Model


4.2.2.1 Loss Function Evolution

Figure 4.4 – Loss Model


CHAPITRE 4. EVALUATION AND DEPLOYMENT 20

4.2.2.2 Categorical Accuracy Progression

Figure 4.5 – Augmented CNN Accuracy Progression

4.2.2.3 Final Accuracy

95.7% test accuracy

Figure 4.6 – Accuracy


CHAPITRE 4. EVALUATION AND DEPLOYMENT 21

4.2.3 VGG16 Transfer Learning


4.2.3.1 Loss Function Evolution

Figure 4.7 – VGG16 Loss Evolution

4.2.3.2 Categorical Accuracy Progression

Figure 4.8 – VGG16 Accuracy Progression


CHAPITRE 4. EVALUATION AND DEPLOYMENT 22

4.2.3.3 Final Accuracy

Figure 4.9 – VGG16 Performance Metrics

4.3 Model Deployment


Once the model is selected, it is important to deploy it so that it can be used in a
real-world environment.

4.3.1 deployment via Streamlit


Streamlit is an open-source Python framework for data scientists and AI/ML
engineers to deliver interactive data apps

4.3.1.1 Preparing the Model for Deployment

Before deploying the app,, we must first save the architecture of our model in a
format that can be loaded later to make predictions on new data.

Figure 4.10 – Model registration

4.3.1.2 Building the Streamlit Application

After preparing the model, we can move on to building the Streamlit application.
The application will include the following features :
User input : The user provides a brain image through the Streamlit interface.
Prediction display : The model predicts and displays the corresponding category.

This figure represents the Resultpage


CHAPITRE 4. EVALUATION AND DEPLOYMENT 23

Figure 4.11 – result interface

4.3.2 Cloud Deployment


Deploying the application to the cloud makes it accessible to all users via the
Internet, without the need for local infrastructure. This section outlines the steps
CHAPITRE 4. EVALUATION AND DEPLOYMENT 24

taken to deploy the application on the chosen platform and the tools used in the
process.

4.3.2.1 Choice of Cloud Platform

4.3.2.2 Application Deployment

4.4 Conclusion
This chapter presented the evaluation and deployment of our brain tumor detec-
tion system. After comparing multiple deep learning architectures, our custom CNN
achieved superior performance (95% accuracy) over pre-trained models like VGG16.
The model was successfully deployed as a Streamlit web application,
Conclusion

Diagnosing a disease in a healthy patient does not have the same consequences
as predicting the health of a sick individual. In the first case, unnecessary treatments
might be administered, or additional tests might be requested, leading to costs and
inconvenience. In contrast, in the second case, the lack of diagnosis and appropriate
treatment could lead to rapid and irreversible deterioration of the patient’s health.
This issue highlights the importance of the precision and reliability of prediction
models in medicine, especially for chronic diseases like diabetes. Therefore, to avoid
diagnostic errors, studying and applying data classification techniques in medicine is
crucial.
In the context of this project, we applied the CRISP-DM methodology, which al-
lowed us to follow a structured process, from understanding the application domain
(diabetes) to model deployment. This methodology guided each step of the project,
including data collection, cleaning, exploratory analysis, modeling, model perfor-
mance evaluation, and finally, deployment. Using an SVM (Support Vector Machine)
model, we were able to predict whether a person is likely to develop diabetes.

25
Bibliographie

26

You might also like