Original Source Here
Corona Detection AI model using chest X-Rays
Artificial intelligence has evolved enough to detect different kind of anomalies in Chest X-Rays. Today Chest X-rays is the most basic and common way to detect Corona infections. We can develop an AI model to classify the available X-rays images into different classes like Normal X-rays and Corona X-rays. Since we are getting a lot of Corona cases in India and time has become a very crucial element in treating Corona patients, we can simply use an AI model to look at the X-Ray images and find out if the image is Corona infected or not.
We can probably automate this algorithm to minimize the role of radiologists so that they can focus on some other pressing things to save lives.
We have used the below steps to develop this AI model to detect Corona infections in X-ray images –
- Reading and understanding the data
I have used the data with 2 classes covid and nofinding. Class Covid has 3000 X-rays of different Corona infected patients and class nofinding has 3000 X-rays of normal people
without any lung infections with size of 299X299. As a very first step we read the data from different classes and try to find out if all the images are of same size and forms and they do not need any Morphological transformations.
2. Data Pre-processing and Normalization
Data normalization is very necessary to standardize that data across all the data points. In Image processing it deals with 2 major problems we usually come across:
B. Gradient Propagation
Sometimes, in our dataset the images should ideally scaled between 0–255 but that is not always true, which introduce the problem of contrast in your image dataset. Similarly, if the images are not properly distributing between 0–1, it can be a major problem in gradient backpropagation in our deep learning models. So, standardizing the data is very important before building the model.
3. Building the model: RESNET18
Residual Network or RESNET basically uses SKIP connection mechanism which enable the training of very deep networks. We have passed channel parameter as 1, and image rows and columns parameters are 299 and 299 for our deep network model.
4. Ablation Run
The first step of model-training is to conduct an ablation experiment. It is done by running your model on small chunk of data first to check whether your code is actually working as expected. Then we systematically modify certain parts of the input, in order to observe the equivalent changes in the output. By ablation testing, a few things that we check in our model is that whether it can overfit on the training data i.e. the training loss consistently reduces along epochs. During training, you may also get NaN as a loss instead
of a finite number. This denotes that the output value predicted by the model is very high, which results in high loss value. This causes exploding gradient problem. We can also play with some of the initialization techniques like Xavier initialization, He initialization etc. and change the architecture of the network if the problem does not get solved.
5. Final Run and making prediction
After doing the ablation testing and solving all the problems in pour model finally we run our model in entire dataset. we are running 10 epochs in our final run. We are using the method called checkpointing in which we are saving the model weights only when there is an increase in ‘validation accuracy’. In our model the validation AUC has significantly increased from 0.92 to 0.98. Finally, we use our model to predict if some random X-ray image is infected by Corona virus or not from the available sample and found that it can successfully classify the Corona and non Corona X-ray images with 97.7% probability.
This model can be further improved and a few more classes can be added for flu and Pneumonia to make the model more accurate. I was facing many errors and learned a lot of things during the creation of this model and hope that some of you guys may benefits and get motivated to understand the basic concepts of deep learning models and of course we can use this model as a basic building block to create a better Corona Detection model. Cheers!!
Trending AI/ML Article Identified & Digested via Granola by Ramsey Elbasheer; a Machine-Driven RSS Bot