Professional Documents
Culture Documents
i
SIR C R REDDY COLLEGE OF ENGINEERING
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
CERTIFICATE
This is to certify that the project report entitled “Pneumonia Detection from CT scan”
being submitted by
V. Eswar 20B81A05H6
V. Prasanthi 20B81A05H8
V. Dileep 20B81A05I0
in partial fulfillment for the award of the Degree of Bachelor of Technology in Computer
Science and Engineering to the Jawaharlal Nehru Technological University, Kakinada is a record
of bonafied work carried out under my guidance and supervision.
External Examiner
ii
DECLARATION
We here by declare that the Project entitled “Pneumonia Detection from CT scan” submitted
for the B. Tech Degree is my original work and the Project has not formed the basis for the
V. PRASANTHI - 20B81A05H8
V. DILEEP - 20B81A05I0
iii
ACKNOWLEDGEMENT
We express our sincere thanks to our principal Dr. K. VENKATESWARA RAO, for providing
We would like to thank Dr. A. YESU BABU, Head of the Department of CSE, for providing the
necessary facilities and his guidance in efficient way for completion of the project in the
specified successfully.
We express our deep-felt gratitude to Dr. S. KRISHNA RAO, Professor, Department of CSE,
for his valuable guidance and unstinting encouragement enabled us to accomplish our project
successfully in time.
We are extremely great full to my department staff members and friends who helped me in
successful completion of this project.
V. ESWAR - 20B81A05H6
V. PRASANTHI - 20B81A05H8
V. DILEEP - 20B81A05I0
iv
ABSTRACT
Pneumonia, a respiratory infection that inflames the air sacs in one or both lungs, has become
increasingly prevalent, particularly in contaminated, crowded, and densely populated areas. This
condition poses significant health risks due to its potential to cause severe breathing difficulties.
Traditionally, pneumonia is diagnosed through imaging techniques such as X-rays and CT scans.
X-rays serve as a primary method for identifying pneumonia, providing basic information on the
presence of lung abnormalities. However, CT scans offer more comprehensive and detailed
imaging, enabling a more accurate detection of pneumonia while minimizing radiation exposure.
Deep learning, a subset of artificial intelligence, has emerged as a powerful tool for developing
predictive models to detect pneumonia from CT scans. Convolutional Neural Networks (CNNs)
are a class of deep learning models that excel at image analysis tasks. By leveraging transfer
learning, where pre-trained models are adapted to new tasks, CNNs can effectively extract
relevant features from CT scan images.
These models employ convolutional layers to automatically learn and identify key patterns and
features from the input CT scan images. These extracted features are then fed into dense
networks for further processing and classification.
Ultimately, the output of these deep learning models is a classification decision indicating
whether the given CT scan exhibits signs of pneumonia or not. By leveraging advanced machine
learning techniques, healthcare professionals can improve the accuracy and efficiency of
pneumonia diagnosis, leading to better patient outcomes and more effective management of this
widespread respiratory illness.
v
TABLE OF CONTENTS
1. INTRODUCTION 1
7. IMPLEMENTATION 15-17
8. TESTING 18-20
10. CONCLUSION 22
11. REFERENCES 23
vi
LIST OF FIGURES
vii
LIST OF TABLES
viii
CHAPTER-1
INTRODUCTION
In recent years, the advent of Deep Learning has revolutionized medical diagnostics,
particularly in the realm of pneumonia detection. Leveraging Convolutional Neural Networks
(CNNs) and transfer learning techniques, researchers have developed robust predictive models
capable of analyzing CT scans with unprecedented efficiency. These models operate by
extracting salient features from CT images through convolutional layers, subsequently
employing dense networks for classification. The primary objective of these models is to
discern whether a given CT scan indicates the presence of pneumonia or not, thereby
facilitating prompt and accurate diagnosis.
In this context, this paper aims to explore the application of Deep Learning methodologies in
pneumonia detection from CT scans. Through the utilization of CNNs and transfer learning,
we endeavour to construct predictive models that exhibit superior performance in
distinguishing pneumonia-affected CT scans from healthy ones. By harnessing the power of
advanced computational techniques, we aspire to contribute to the advancement of medical
diagnostics, ultimately improving patient outcomes and mitigating the burden of pneumonia
on global healthcare systems.
1
CHAPTER-2
LITERATURE SURVEY
Pneumonia detection using chest X-ray images has been a subject of extensive research in
recent years, driven by the need for accurate and efficient diagnostic tools to combat this
prevalent respiratory infection. The literature survey on this topic encompasses various studies
focusing on different aspects of pneumonia detection, including image analysis techniques,
deep learning models, and ensemble methods. Some of key findings and approaches in the
existing literature are:
• Traditional image processing techniques have been utilized for pneumonia detection in
chest X-ray images, including thresholding, edge detection, and texture analysis.
However, these methods often lack robustness and may struggle to handle the
complexities and variations present in medical images.
• Transfer learning has been extensively employed to address the challenge of limited
training data in medical image analysis tasks. Pre-trained CNN models trained on large-
2
scale image datasets (e.g., ImageNet) are fine-tuned on pneumonia-specific datasets to
leverage learned features and improve model generalization.
• Ensemble methods combine predictions from multiple base models to achieve superior
performance compared to individual models. Studies have explored various ensemble
techniques, including simple averaging, weighted averaging, and stacking, to enhance
pneumonia detection accuracy.
• Weighted averaging, where the weights assigned to base models are determined based
on their performance, has shown promise in improving ensemble performance and
robustness.
Overall, the literature survey highlights the advancements in pneumonia detection using chest
X-ray images, with deep learning and ensemble techniques emerging as prominent approaches.
The proposed method by Rohit KunduI, Ritacheta DasI, Zong Woo GeemI, Gi-Tae HanI, Ram Sarkar
contributes to this body of research by introducing a novel ensemble approach with improved
performance and robustness, as demonstrated through extensive experimentation and
evaluation on publicly available datasets.
3
CHAPTER-3
EXISTING SYSTEM
(Pneumonia Detection from X-rays)
In this system, they developed a computer-aided diagnosis system for automatic pneumonia
detection using chest X-ray images. They employed deep transfer learning to handle the
scarcity of available data and designed an ensemble of three convolutional neural network
models: GoogLeNet, ResNet-18, and DenseNet-121. A weighted average ensemble technique
was adopted, where in the weights assigned to the base learners were determined using a novel
approach.
The scores of four standard evaluation metrics, precision, recall, f1-score, and the area under
the curve, are fused to form the weight vector, which in studies in the literature was frequently
set experimentally, a method that is prone to error. The existing approach was evaluated on two
publicly available pneumonia X-ray datasets, provided by Kermany et al. and the Radiological
Society of North America (RSNA), respectively, using a five-fold cross-validation scheme. The
existing system achieved accuracy rates of 98.81% and 86.85% and sensitivity rates of 98.80%
and 87.02% on the Kermany and RSNA datasets, respectively.
4
3.1. Advantages:
• Availability of Dataset: X-ray datasets are more widely available compared to datasets
obtained from other imaging modalities such as CT scans or MRI. This availability
stems from the routine use of X-rays in clinical practice for diagnosing various thoracic
conditions, including pneumonia Monitoring Progress: X-rays can be used to monitor
the progression of pneumonia and assess the effectiveness of treatment over time.
• Limited Radiation Exposure: X-rays involve lower radiation exposure compared to
other imaging techniques like CT scans. This reduced radiation makes X-rays safer,
especially for vulnerable populations such as children and pregnant women. Since
pneumonia is a condition that may require frequent monitoring and follow-up imaging,
using X-rays mitigates concerns regarding cumulative radiation exposure over multiple
scans.
• Cost-effectiveness: X-ray imaging is generally more cost-effective compared to other
modalities such as CT scans or MRI. This affordability makes X-rays accessible in
various healthcare settings, including resource-constrained environments where
advanced imaging modalities may not be readily available.
3.2. Disadvantages:
• Limited Sensitivity and Specificity: While X-rays can detect structural abnormalities
in the lungs, they may lack sensitivity and specificity in distinguishing between
different types of pulmonary conditions. This can lead to false positives or false
negatives in pneumonia diagnosis, potentially resulting in misdiagnosis or delayed
treatment.
• Radiation Exposure: X-ray imaging involves exposure to ionizing radiation, albeit at
relatively low levels. While the risk of radiation-induced harm from a single X-ray is
minimal, repeated exposure over time may increase the cumulative risk, particularly in
vulnerable populations such as children and pregnant women.
• False Positives and Negatives: Like any diagnostic tool, chest X-rays are not infallible.
False positives (indicating pneumonia when it is not present) and false negatives
(missing pneumonia when it is present) can occur. This highlights the importance of
considering clinical symptoms and other diagnostic information.
5
CHAPTER-4
PROPOSED SYSTEM
(Pneumonia Detection from CT scan)
Building a web application that takes CT scan images of lungs as input and predicts whether
pneumonia is present or not.
4.2. Objective:
To overcome the limitations of the existing system, in this study, we developed a computer-
aided diagnosis system for automatic pneumonia detection using CT scan images, we employed
deep transfer learning to handle the scarcity of available data and designed an ensemble of
three convolutional neural network models: EfficientNetV2B1, InceptionV3, VGG16,
DenseNet121, ResNet50V2, MobileNetV2, Custom Model.
The proposed model has taken the three CNN models that have higher accuracy than the
remaining CNN models and applied bagging technique for those three CNN models.
The proposed approach was evaluated on publicly available pneumonia CT scan dataset,
provided by Kaggle, because the availability of datasets is limited as the medical data of the
patients are not disclosed due to security reasons.
4.3. Models:
4.3.1 EfficientNetV2B1:
• EfficientNetV2 is an extension of the EfficientNet architecture, designed to achieve
improved performance with fewer parameters and computational resources.
6
• It introduces a compound scaling method that uniformly scales network width, depth,
and resolution with a set of fixed scaling coefficients.
4.3.2. InceptionV3:
• It is known for its Inception modules, which consist of multiple parallel convolutional
branches with different filter sizes.
4.3.3. VGG16:
4.3.4. DenseNet121:
4.3.5. ResNet50V2:
7
4.3.6. MobileNetV2:
8
CHAPTER-5
REQUIREMENT ANALYSIS
• Input Data Compatibility: The system should be capable of accepting CT scan images
in standard formats such as DICOM (Digital Imaging and Communications in
Medicine) or other common image formats.
• Feature Extraction: The system should employ convolutional neural network (CNN)
models for feature extraction from CT scan images. Transfer learning techniques should
be used to leverage pre-trained models for better performance.
• Classification: Extracted features should be fed into dense neural networks for
classification, distinguishing between pneumonia-affected and unaffected CT scans.
• Model Evaluation: The system should evaluate the performance of trained CNN
models using appropriate metrics such as accuracy, precision, recall, and F1 score to
assess their effectiveness in pneumonia detection.
9
5.2. NON-FUNCTIONAL REQUIREMENTS:
• Accuracy: The system should achieve a high level of accuracy in pneumonia detection
to minimize false positives and false negatives, ensuring reliable diagnosis.
• Security: The system should adhere to strict security standards to protect patient data
and ensure confidentiality, integrity, and availability.
• Usability: The system should have an intuitive user interface that is easy to navigate,
facilitating seamless interaction for healthcare professionals.
• Robustness: The system should be resilient to variations in input data quality, noise,
and artifacts commonly encountered in medical imaging.
• Compliance: The system should comply with relevant regulations and standards for
medical devices and software, ensuring legal and ethical compliance in healthcare
settings.
10
CHAPTER-6
• UML diagrams are visual representations used to design and model software systems.
• They are standardized diagrams used in software engineering to communicate design
decisions and system architecture.
• UML diagrams can help developers, stakeholders, and team members understand the
structure and behaviour of a system before it is implemented.
Use case diagrams to illustrate the interactions between users (actors) and a system to
accomplish specific tasks or goals. They help to identify and define the functional requirements
of a system from the user's perspective.
11
6.1.2. Sequence diagram:
Sequence diagrams visualize the interactions between objects in a particular scenario or use
case. They show the sequence of messages exchanged between objects over time, helping to
understand the dynamic behaviour of the system.
Activity diagrams represent the flow of control within a system, showing the sequence of
activities and decision points. They are useful for modeling business processes, workflow, and
the logic of complex operations.
12
Fig. 6.3. Activity diagram
Class diagrams depict the static structure of a system by showing classes, their attributes,
methods, and relationships between classes. They provide a blueprint for the implementation
of the system's objects and their interactions.
13
6.2. Methodology:
• Training: Train the CNN models on the preprocessed CT scan dataset using supervised
learning. Use techniques like cross-validation and hyperparameter tuning to optimize
model performance.
• Evaluation: Evaluate the trained models using metrics such as accuracy, precision,
recall, and F1-score on a separate test set. Perform error analysis to identify areas for
improvement.
• Deployment: Deploy the trained models in a clinical setting for pneumonia detection
from CT scans. Ensure seamless integration with existing healthcare systems and
compliance with regulatory standards.
14
CHAPTER-7
IMPLEMENTATION
• Then the 3-channel RGB images are converted to Gray Scale using cv2.
• After, the images are resized to 160,160 for transfer learning models.
• Original Images are in 512,512 and resized the images to 180,180 for custom model.
15
• (180,180,1) for
custom model
(512, 512, 3) to
• (160, 160, 1) for
transfer learning
models
7.1.3. Balancing:
As the data set is biased, we balanced the dataset by performing data augmentation on lower
samples class (Normal CT’s) and under sampling techniques on higher samples class
(Pneumonic CT’s)
Fig. 7.3.1 Class distribution diagram Fig. 7.3.2 Class distribution diagram
Before Oversampling and Down sampling After Oversampling and Down sampling
• The dataset is split to 4:1 ratio 80% data for training and 20% for validation.
16
• The test set is stored in separate directory with around 10% of train set.
Out of the all keras transfer learning models we have selected the 6 models with best accuracy
and reasonable no of parameters.
1. ResNet50v2
2. EfficientNetV2B1
3. VGG16
4. Densenet121
5. MobileNetv2
6. Inception V3
17
CHAPTER-8
TESTING
While training the model we have used 20% data from training set as validation to check the
model’s performance on unseen data.
Out of the seven modes Custom Model, ResNet50V2, EfficientNetV2B1 performed with
better accuracy.
8.1.1. Resnet50V2:
On model training the performance of the model on training (96%) and validation sets (98%).
18
8.1.2. EfficientNetV2B1:
the performance of EfficientNet model on training (97.41%) and on validation set (99%).
The custom model gave top performance with 99.3% training accuracy and 99.4% on
validation set.
19
8.2. Model evaluation:
Accuracy : 100.0
Precision : 100.0
Recall : 100.0
8.2.2. ResNet50V2:
Accuracy : 98.89
Precision : 97.5
Recall : 100.0
8.2.3. EfficientNetV2B1:
Accuracy : 94.44
Precision : 100.0
Recall : 87.18
20
CHAPTER-9
The user is provided with Interface to upload the CT Scan image of the lung to see the results.
The Interface is built using the Streamlit a popular python library used to build the web apps
for machine learning and deep learning applications. After the image of scan being uploaded
by the user the image will be passed to the three models Resnet, EfficientNet and Custom
model. The outputs generated by each of the models will be averaged for more robust prediction
of the disease.
21
CHAPTER-10
CONCLUSION
Early detection of pneumonia is crucial for determining the appropriate treatment of the disease
and preventing it from threatening the patient’s life. Chest CT scans are becoming the most
widely used tool for diagnosing pneumonia; however, they are subject to inter-class variability
and the diagnosis depends on the clinicians’ expertise in detecting early pneumonia traces. To
assist medical practitioners, an automated CAD system was developed in this study, which uses
deep transfer learning-based classification to classify CT scan images into two classes
“Pneumonia” and “Normal.” An ensemble framework was developed that considers the
decision scores obtained from seven CNN models, EfficientNetV2B1, InceptionV3, VGG16,
DenseNet121, ResNet50V2, MobileNetV2, Custom Model, to form a weighted average
ensemble. The weights assigned to the classifiers were calculated using a novel strategy
wherein four evaluation metrics, precision, recall, f1-score, and AUC, were fused using the
hyperbolic tangent function. The framework, evaluated on publicly available pneumonia CT
scan dataset, obtained an accuracy rate of 98.81%, a sensitivity rate of 98.80%, a precision rate
of 98.82%. Furthermore, the proposed ensemble model is domain-independent and thus can be
applied to a large variety of computer vision tasks.
22
CHAPTER-11
REFERENCES
• Rohit Kundu, Ritacheta Das, Zong Woo Geem, Gi-Tae Han, Ram Sarkar. “Pneumonia
detection in chest X-ray images using an ensemble of deep learning models”, PLOS
ONE, September 7, 2021.
• Daniel Joseph Alapat, Malavika Venu Menon, Sharmila Ashok. “Detection of
Pneumonia in Chest X-ray Images Using Neural Networks”, National center for
biometric information, December 1,2022.
• Shagun Sharma, Kalpna Guleria. “A Deep Learning based model for the Detection of
Pneumonia form Chest X-Ray Images using VGG-16 and Neural Networks”, Science
Direct, January 31, 2023.
23