AI for Good: CNN for COVID-19 Detection, Diagnosis, and Personalized Treatment

Written by Muhammad Azeem1, Shumaila Javaid2, Hamza Fahim2, and Nasir Saeed3

The coronavirus disease (COVID-19) was first identified in Wuhan, China, in 2019.  It has since been spreading across the entire world and affecting both people’s daily lives and the global economy. According to the latest report of the World Health Organization (WHO), COVID-19 has infected more than 80 million people and has caused 1 million deaths around the globe. The COVID-19 pandemic has also exposed the vulnerability of current public health systems.

Scientific communities have put considerable efforts into finding the cure for this life-threatening disease.  So far, social distancing is considered as one of the most effective ways of containing its spread. Besides, timely detection has crucial importance for affected patient isolation and treatment to mitigate the spread of COVID-19. Therefore, substantial efforts are made toward advancing screening and detection methods for fast and accurate detection of COVID-19.

Currently, the most widely adopted screening method for COVID-19 detection is polymerase chain reaction (PCR) testing, which can detect the presence of SARS-CoV-2 pathogen from respiratory fluid samples.  While PCR testing is known to exhibit high sensitivity, it requires an extended time to yield a test result and entails a complicated manual process. An alternative screening process that is less commonly used is radiography examination, where a radiologist analyzes chest radiography images, like X-rays or computed tomography (CT), to look at the pictorial gauges related to SARS-CoV-2 viral infection. Since diagnostic communities can observe abnormalities in the chest, specifically in the lungs of COVID-19 patients, it is suggested that radiography examination can be used as a primary tool for detecting COVID-19 [1], especially under the current epidemic situation. Therefore, computer-aided diagnostic systems can help radiologists examine the X-ray or CT images quickly and accurately to spot COVID-19. However, identifying COVID-19 from the chest X-beam pictures is a difficult task – compared to PCR testing – that requires experienced radiologists and advanced methods for accurate diagnosis.


Figure 1: AI Applications in Healthcare


Therefore, digital technologies, especially artificial intelligence (AI), can play a crucial role in the accurate detection of COVID-19 [2-4]. In these challenging times, when the COVID-19 has jeopardized the ability to provide essential medical care due to limitation of healthcare resources, AI-based diagnostic techniques can improve diagnostic accuracy thereby enhancing the efficiency of healthcare resources when combating the COVID-19 pandemic. In addition, AI can be a promising tool for numerous other healthcare applications to advance computer-aided diagnostic and detection accuracy, as shown in Figure 1. For instance, AI-based X-ray screening can provide a better diagnosis and address radiologist's uncertainties due to the ambiguous appearance of the virus. Moreover, disease diagnostics and prognostics are improved with clinical imaging through the utilization of various AI tools [5].


For example, AI contributes to brain tumor detection using Fuzzy C-means, k-means clustering, and Otsu edge techniques [6, 7]. Additionally, Alzheimer’s disease detection and continuous remote sensing applications have also been improved with AI, explicitly using deep neural networks. Furthermore, recent literature shows various AI-based solutions that were designed to improve the diagnosis of the X-ray based screening process. In [8], the authors present a COVID-Net that improves the test accuracy by up to 92.4%. However, COVID-Net experiences limitations in Positive Predictive Value (PPV) and risk satisfaction. Moreover, Convolutional Neural Networks (CNN) and Support Vector Machines (SVM) also have a high potential for COVID-19 diagnosis automation [9], with the Decompose Transfer and Composes Model (DeTraC) achieving an accuracy of 95.12 % [10]. However, it only exhibits optimal results for small data sets. The detection accuracy is further improved in [11] to 96.1% by using pre-trained CNN.



Figure 2: Proposed CNN Architecture


Motivated by the importance of CNN in faster and more accurate detection of COVID-19, we have developed a four-layer CNN model for analyzing CT images. The first three layers have input sizes of (254, 254, 3), (127, 127, 3), and (124, 124, 3), respectively, with the Relu activation function running at each layer. The polling size of 2 x 2 is used at the first two layers, while the third layer has a filter size of 3 x 3. The proposed CNN model is also represented in Figure 2 to visually elaborate the system architecture. Table 1 highlights the configuration details of the proposed CNN model.

In our experiments, we used two datasets, collected from two different sources, to evaluate the model's performance. The first dataset is freely available at the Kaggle Images Dataset website that consists of 5,427 COVID images and 2,628 non-COVID images. The second dataset is obtained from GitHub Dataset Images, containing 349 COVID images and 397 non-COVID images.

We have used TensorFlow to implement the proposed CNN model and cross-validate via the K-Fold procedure [12]. We first divided the dataset into four groups of data samples (4-fold cross-validation) and used four metrics, i.e., accuracy, precision, F1-score, and confusion matrix, to evaluate the model's performance with the training set, validation set, and testing set of 80%, 10%, and 10% respectively. Moreover, with a K-fold of 4, the maximum accuracy of 99.73% is achieved. Table 2 and Table 3 further demonstrate the training and testing results, respectively. The confusion matrix is represented in Figure 3 is used to highlight the performance and accuracy of the proposed model.


Table 1: Configuration detail of proposed CNN model

Screen Shot 2021 07 22 at 11.19.21 AM


Table 2: 5-fold cross-validation training results

Table 2:  5-fold cross-validation training results


Table 3: 4-fold cross-validation testing results

Screen Shot 2021 07 22 at 11.23.13 AM




This study highlights the role of AI in the medical domain and demonstrates a deep convolutional neural network (CNN) model for chest radiography images to detect COVID-19. The proposed model is trained and tested on chest x-ray images and CT images, showing promising performance with a mean accuracy of 98.16% and a testing accuracy of 96.47%. The predictions of the proposed model can lead to insights about crucial factors associated with COVID-19 and may assist clinicians in improved screening when using computer-aided imaging.





  1. Rao, B. P., Doddavarapu, V. S., & Kande, G. B. (2021). Artificial Intelligence for the Detection of Coronavirus Disease (COVID-19) from Chest X-Ray Images. European Journal of Molecular & Clinical Medicine, 7(11), 2781-2790.
  2. Saeed, N., Bader, A., Al-Naffouri, T. Y., & Alouini, M. S. (2020). When wireless communication faces COVID-19: Combating the pandemic and saving the economy. Frontiers in Communications and Networks,
  3. Dlamini, Z., Francies, F. Z., Hull, R., & Marima, R. (2020). “Artificial intelligence (AI) and big data in cancer and precision oncology.” Computational and Structural Biotechnology Journal.
  4. Saba, T. (2020). “Recent advancement in cancer detection using machine learning: Systematic survey of decades, comparisons and challenges.” Journal of Infection and Public Health, 13(9), 1274-1289.
  5. Myszczynska, M. A., Ojamies, P. N., Lacoste, A. M., Neil, D., Saffari, A., Mead, R., ... & Ferraiuolo, L. (2020). “Applications of machine learning to diagnosis and treatment of neurodegenerative diseases.” Nature Reviews Neurology, 16(8), 440-456.
  6. Javaid, S., Wu, Z., Fahim, H., Mabrouk, I. B., Al-Hasan, M., & Rasheed, M. B. (2020). Feedforward Neural Network-Based Data Aggregation Scheme for Intrabody Area Nanonetworks. IEEE Systems Journal.
  7. Fahim, H., Li, W., Javaid, S., Sadiq Fareed, M. M., Ahmed, G., & Khattak, M. K. (2019). Fuzzy logic and bio-inspired firefly algorithm based routing scheme in intrabody nanonetworks. Sensors, 19(24), 5526.
  8. Wang, L. and A. Wong (2020). "COVID-Net: A Tailored Deep Convolutional Neural Network Design for Detection of COVID-19 Cases from Chest X-Ray Images." arXiv preprint arXiv:2003.09871.
  9. Fong, B., Fong, A. C. M., & Li, C. K. (2020). Telemedicine Technologies: Information Technologies in Medicine and Digital Health. John Wiley & Sons.
  10. Abbas, A., M. M. Abdelsamea, et al. (2020). "Classification of COVID-19 in chest X-ray images using DeTraC deep convolutional neural network." arXiv preprint arXiv:2003.13815.
  11. Hall, L. O., R. Paul, et al. (2020). "Finding covid-19 from chest x-rays using deep learning on a small dataset." arXiv preprint arXiv:2004.02060.
  12. Kuang, L., Zhao, H., Wang, L., Xuan, Z., & Pei, T. (2019). A novel approach based on point cut set to predict associations of diseases and LncRNAs. Current Bioinformatics, 14(4), 333-343. 



This article was edited by Bernard Fong

For a downloadable copy of the July 2021 eNewsletter which includes this article, please visit the IEEE Smart Cities Resource Center.

Muhammad Azeem received his B. S. degree in Information Technology from the University of Sargodha (UoS), Pakistan, in 2016. Currently, he is pursuing his M. S. degree in Computer Science from the University of Okara, Pakistan. His research interests include machine learning, deep learning, and wireless communication.
Shumaila Javaid did her Ph.D. in Computer Science from Shaanxi Normal University, China. She is working as an Assistant Professor at Ilma University Karachi, Pakistan, and she is also associated with Tongji University, Shanghai, China as a Postdoctoral researcher. She has received her M.S. degree in Telecommunication and Networking from Bahria University, Pakistan, in 2015. She completed her B.S. degree from COMSATS University (C.U.), Pakistan, in 2012. Her main research interests include Wireless Sensor and Wireless Multimedia Sensor Networks, Intrabody Nanonetworks, Robotic Communication, Information-Centric Networks, and Wireless Networking in general.
hamza fahim
Hamza Fahim is associated with Tongji University, Shanghai, China as a Postdoctoral researcher. He did his Ph.D. in Computer Science and Networks from Xi’an Jiaotong University, China. He is also associated with Ilma University Karachi, Pakistan, as Assistant Professor. He holds his B.S. and M.S. degrees from the computer science department, COMSATS University (C.U.), Pakistan, in 2012 and 2015. His current research interests include Intrabody Nanonetworks, Software Defined Networks, and Wireless Sensor Networks.
Nasir Saeed received the bachelor's degree in telecommunication from the University of Engineering and Technology, Peshawar, Pakistan, in 2009, the master's degree in satellite navigation from the Polito di Torino, Italy, in 2012, and the Ph.D. degree in electronics and communication engineering from Hanyang University, Seoul, South Korea, in 2015. He was an Assistant Professor with the Department of Electrical Engineering, Gandhara Institute of Science and IT, Peshawar, from August 2015 to September 2016. He has worked as an Assistant Professor with IQRA National University, Peshawar, from October 2016 to July 2017. From July 2017 to December 2020, he was a Postdoctoral Research Fellow with the Communication Theory Laboratory, King Abdullah University of Science and Technology (KAUST). He is currently an Associate Professor with the Department of Electrical Engineering, National University of Technology (NUTECH), Islamabad, Pakistan. His current research interests include cognitive radio networks, underwater wireless communications, aerial networks, dimensionality reduction, and localization.

Past Issues

To view archived articles, and issues, which deliver rich insight into the forces shaping the future of the smart cities, please visit the IEEE Smart Cities Resource Center.