This repository contains code and models developed during my tenure as an Artificial Intelligence Intern at Code Clause from May 2024 to June 2024 . The primary objective of this project is to detect the presence or absence of pneumonia using chest X-ray images sourced from the Med MNIST dataset. Pneumonia is a serious condition that causes inflammation in one or both lungs, and early detection is crucial for effective treatment.
Below are the key steps involved:
- Data Loading
- Splitting of Data
- Data Cleaning
- Data Visualization
- Defining Functions for Model Creation
- Model Building
- Model Evaluation
- Prediction Using the Best Model
- Model Deployment
Each image is in grayscale and of size 28 x 28 pixels.
I have implemented a variety of models, both simple neural networks and convolutional neural networks and stored them in different functions, to determine the best-performing architecture. Here is a summary of the models created:
-
two_layers_softmax: Input and output layers, softmax activation.
-
two_layers_sigmoid: Input and output layers, sigmoid activation.
-
three_layers_softmax: Input, hidden, and output layers, softmax activation.
-
three_layers_sigmoid: Input, hidden, and output layers, sigmoid activation.
-
four_layer_softmax: Input, two hidden layers, output layer, softmax activation.
-
three_layer_softmax_SGD: Input, hidden, output layers, softmax activation, SGD optimizer.
-
four_layer_sigmoid: Input, two hidden layers, output layer, sigmoid activation.
-
five_layer_cnn_softmax: Convolution, max pooling, input, hidden, output layers, softmax activation.
-
five_layer_cnn_sigmoid: Convolution, max pooling, input, hidden, output layers, sigmoid activation.
-
seven_layer_cnn_softmax: Two convolution, two max pooling, input, hidden, output layers, softmax activation.
-
seven_layer_cnn_sigmoid: Two convolution, two max pooling, input, hidden, output layers, sigmoid activation.
-
five_layer_cnn_softmax_avg_pooling: Convolution, average pooling, input, hidden, output layers, softmax activation.
-
seven_layer_cnn_softmax_avg_pooling: Two convolution, two average pooling, input, hidden, output layers, softmax activation.
Among the 36 models created by varying epochs, Model 20 achieved the highest accuracy of 89.58%.
To facilitate predictions, the following functions were created:
-
image_preprocess: Resizes, converts to grayscale, and normalizes the image if the input is not of 28x28 pixels.
-
predict: Uses the preprocessed image, expands dimensions, and returns the predicted class.
Utilizing the Gradio library, I created a simple User Interface to deploy the model.
Here is the final result:
video.of.UI.mp4
If you find this project helpful, please ⭐ this repository!