The coronavirus disease 2019 (COVID- 19) began as an outbreak in Wuhan, China and was declared a public health emergency of international concern by the World Health Organization (WHO) on January 30 [1] . COVID-19 has become a pandemic with more than 8 million confirmed cases and almost 500K deaths around 216 countries [2] . There have been many efforts to fight COVID-19 around the world such as research a vaccine against COVID-19, massive creation of ventilators as well as personal protective equipment (PPE), development of fast diagnosis systems from chest X-Ray and/or thoracic computer tomography (CT), among others in many different fields.
Artificial Intelligence (AI) can be applied in many different ways to fight COVID-19. As stated in [3] , between the most important applications of AI in COVID-19 pandemic are: early detection of the infection from medical imaging, monitoring and prediction of the spread of the virus and mortality rates, tracing the virus by identifying hot spots, and development of drugs and vaccines by helping in clinical trials. In São Paulo, Brazil, regional authorities in cooperation with telephone companies are employing the Social Isolation Index (SII) [4] , which is computed based on Geo-location data, to quantify the percentage of population that stays at home. Landing AI [5] developed a monitoring tool that issues an alert when anyone is less than the desired distance from another person, promoting social distancing in the streets due to its effectiveness to slow down the COVID-19 spread. On the other hand, machine learning methods have been applied to predict the number of active cases around the world [6] , for fast COVID-19 detection from CT [7] and X-Ray [8] , and to develop systems for detection of those who are not wearing facial masks [9] .
Currently, one of the most employed methods for COVID-19 diagnosis is the viral nucleic acid detection using real-time polymerase chain reaction (RT-PCR). However, testing this method in thousands of suspenseful patients it is very delayed. To address this drawback, efforts have been made using AI to detect patients with COVID-19 in a very fast time through medical imaging technologies like CT and X-Ray images. It is because, COVID-19 causes acute, highly lethal pneumonia with clinical symptoms similar to those reported for SARS-CoV and MERS-CoV [10, 11, 12] . The most common and widely available method using this type of technologies is by chest X-Ray images because it is available in ambulatory care facilities, handy with portable X-Ray systems, and enabling rapid classification (speeding up the disease screening). In contrast, CT scanners may not be available in many underdeveloped regions, disabling its use for quick diagnoses. Despite the advantages to detect COVID-19 by X-Ray, one of the main bottlenecks is the need of specialists (radiologists) to interpret the images. Taking this "specialists" expertise as a prior knowledge to build an AI system can help them for quick triage, especially as a tool to triage patients for radiologists with case overloads.
Related Works. Several AI-based approaches have been proposed to detect patients with COVID-19 using X-Ray images. Most of them use pre-trained models and data augmentation, mainly due to the lack of data. [8] create a free repository 1 of X-Ray image data collections to train machine learning approaches for COVID-19 classification. In addition, [13] published a survey on public medical imaging data resources (CT, X-Ray, MRT and others), which can be used to increase the number of X-Ray samples. Reviews of known deep learning models used to create an automatic detection of COVID-19 from X-Ray images are presented by [14] , [15] and [16] , which used VGG-19, MobileNetV2, Inception, Xception and ResNetV2 as pre-trained models. They used a small number of X-Ray samples with confirmed COVID-19 (224, 50 and 25 respectively). [17] collected more X-Ray samples to increase the training dataset and use pre-trained models followed by highlighting class-discriminating regions using gradient-guided class activation maps(Grad-CAM) [18] for better visualization.
In [19] was introduced a model called Decompose, Transfer and Compose (DeTracC) to classify between healthy, severe acute respiratory syndrome (SARS) and COVID-19 in X-Ray images. This network was built in tree stages: (i) features extraction, (ii) class decomposition, and (iii) classification. The authors used AlexNet and ResNet18, as pre-trained models, and Principal Component Analysis (PCA), as a decomposition class. The training was performed with 80 samples of normal X-Ray, 105 samples of COVID-19, and 11 samples of SARS, and data augmentation to increase the dataset to 1764 was employed. In [20] was presented a new model based on capsule networks called COVIDS-CAPS to classify between non-COVID-19 (normal, Bacterial and Viral) and COVID-19 using less number of trainable parameters compared with pre-trained models. Their results show that COVIDS-CAPS is able to predict X-Ray with COVID-19. Despite the fact that the network was trained with few X-Ray samples, which poses uncertainties regarding the network suitability for new samples.
Not only AI-based research was developed (several papers using deep learning to predict COVID-19 in X-Ray images), also software and services have been created. The startup "DarwinIA" developed the COVID-Net [21] , which can help to identify COVID-19 patients using chest X-Ray radiography. Also, they made a free Kubernetes Bundle for inferencing COVID-19 X-Rays images 2 . In addition, Seoul-based medical AI software company Lunit 3 released its AI-powered software for chest X-Ray analysis with a limitation of 20 uses per day per user.
Contributions. In this context, this work presents a free and open source system available as a web service 4 for fast detection of COVID-19 in chest X-Ray images using deep learning. This system employs deep learning models to detect COVID-19 effects on lungs from chest X-Ray, which can be used for classification, triage, and monitor COVID-19 cases.
The main contributions of this work can be summarized as follows: First, two deep learning models are presented, one to differentiate between X-Ray and non-X-Ray images based on Mobile-Net architecture, and another one to detect chest X-Ray images with characteristics of COVID-19 using a network bases on dense blocks and initialized from a pre-trained ImageNet. Second, we provide a free and open-source service with dedicated GPUs to make inferences in real-time. The source code is available at https://github.com/ICA-PUC/ServiceIA-COVID-19.
The remainder of the paper divides into four sections. Section 2 describes the methodology adopted for each part of the system. Section 3 presents the datasets employed to train the models for X-Ray images filter and the COVID-19 classifier. Section 4 shows the results obtained in our experiments for each model, and the web interface of the whole system. Finally, Section 5 summarizes the conclusions and next steps to be followed in the development of our system.
This section presents the methodologies adopted for each of three parts of the project, the X-Ray image filter, the COVID-19 classifier and the Web page description. Figure 1 summarizes the workflow of the system. The first box in Figure 1 , from left to right, illustrates the beginning of the detection process. It starts with a simple extension verification to check whether the uploaded file is an image (web interface). Next, the Backend (second box) sends and stores the input image to the GPU cluster (Server), which performs the network's inferences after the Backend verifies the correct uploading of the images to it. Finally, the last box shows how the web interface stores and displays the result of the inference.
In the following, it is described in detail the methodology employed for each constituted part of the system. Figure 2 : Description of the method followed in this work to classify X-Ray images for detection COVID-19. It is made of three Densenet Blocks, followed by a linea classifier.
Due to the input of our system to predict COVID-19 are X-Ray images from frontal AP and PA views, we first guarantee that the inputs present these characteristics to have a correct assessment. Therefore, we implement a neural network based on Mobile-Net architecture [22] to identify whether it is a valid image (pulmonary frontal X-Ray image) or a non-valid image (rotated pulmonary X-Ray images, colored or natural images, for instance). In other words, this network operates as a filter that passes to the next process, just frontal pulmonary X-ray images from valid views. Figure 2 illustrates the processing scheme followed in this work to classify COVID-19 X-Ray images. It receives as input an X-Ray image and delivers as outputs a vector of scores indicating the probability of the image is not presenting any issues (No Finding), with opacity in Lungs (Lung Opacity), or with characteristics of COVID-19. The core of this system is a classifier built on the DenseNet [23] network with weights initialized from a pre-trained ImageNet [24] model. We selected a DenseNet-based architecture due to it has demonstrated high capability for classifying X-Ray images [25, 26, 27, 28, 29] . It is because the utilization of Dense blocks helps to improve the gradient flow information through the network, allowing the optimization of deeper architectures [25] .
As described in Figure 2 , we use a DenseNet architecture made of three densely blocks connected in cascade, which are separated by downsampling blocks constituted of one convolution, and an average pooling layer. Finally, to the output of the last densely block, it is stacked a convolution followed by a global average pooling, and a softmax classification layer, which performs the final decision of the network.
For optimizing the network parameters, we split this process into two stages due to the scarcity of COVID-19 samples. At the first stage, we train the DenseNet to discern between No Finding and Lung Opacity images, and at the second one, the model was finetuned incorporating the COVID-19 class information. During the first stage, COVID-19 samples were considered as Lung Opacity because of existing correlation between COVID-19 and Pneumonia, and processed independently in the second stage. By adopting this stratified training, we take advantage of the number of samples per class in the first stage to guarantee the learning of representative features for identifying opacities in the Lungs. Then, in the second stage, these features are finetuned to classify whether the opacity was originated by COVID-19 or not.
The web page was created to display all the content of this research. Besides, health specialists may use the platform to support patients' classification. The web page is accessible worldwide, being available in two languages: Portuguese (original) and English. It also describes in detail information about the datasets, structure, technical details, and performance of classifiers. Also, there is an area on the web page where public users can experience the predicted classification using personal X-Ray images. At the end of the page, it is possible to view a 3D projection based on PCA analyses, which from a set of images samples, forms groups of images that most resemble each other.
Front-end and back-end interface -service architecture. Due to the web page was developed as a free service for providing a simple solution to perform image analysis, and that can be utilized by any user, it was necessary to combine different environments programming languages to make this possible. At follow, it is detailed the web site structure, as well as the environments employed for building this service.
The web page interface (called front-end) was developed in HyperText Markup Language (HTML), Cascading Style Sheets (CSS) and JavaScript (JS), which enabled its rapid implementation by using some libraries and frameworks like: jQuery, that facilitated the implementation of JS code on the site; Dropzone 5 , an open source library that provides drag-and-drop file uploads with image previews; and Bootstrap 4.0 6 , one of the world's most popular HTML, CSS and JS libraries to quickly customize responsive websites.
The implemented service that maintains the operation of the website, known as backend, was developed in Hypertext Preprocessor (PHP), Python, and Shell Command Language (Sh). The Deep Learning neural network models were implemented in Keras engine, using Tensorflow as backend. The server run over a Unix operating system, which controls the running process via Bourne-again shell (Bash).
Public data, collected from different places, was used for our implementations.
For filtering frontal X-Ray images, we selected three public groups of images:
• Frontal pulmonary X-Ray [30] .
• Frontal non-pulmonary X-Ray 7 .
• Other kind of images that are not X-Ray images: PASCAL VOC 8 and Computational Vision at CALTECH dataset 9 .
Taking into account that the performance of the classification system would be reduced if it process images inverted or rotated (90 • clockwise and counterclockwise), we created a group of images with these characteristics to be identified as non-valid by the X-Ray filter. Particularly, we randomly selected a set of images from the X-Ray dataset and applied rotations of 90 • , 180 • , and 270 • to each image. Next, we split the dataset randomly into three sets; for training, validating, and testing the model (see Table 1 ). Each set contains the same among of samples for each class: valid and non-valid image.
For detecting COVID-19 using X-Ray imagery, we selected four publicly available datasets, two associated with COVID-19 and the others with opacities in Lungs caused by different pathologies, like pneumonia, infiltration, consolidation, among others. Both COVID-19 datasets, Cohen [8] and Figure1-COVID 10 datasets, are community repositories updated regularly with X-Ray imagery from patients from different countries, already diagnosed or suspected of having COVID-19, and others pneumonia infections. At the date this paper was written, the Cohen dataset contained 438 X-Ray images from AP and PA views, 359 associated with COVID-19, and 79 with the others pathologies. The Figure1-COVID dataset is a smaller one comprising 40 images, where 35 are from patients confirmed with COVID-19, three with pneumonia caused by others infections, and two with no finding pathology. There is also a set of images from patients with symptoms not confirmed as positive of COVID-19 that were filtered out. We merged the Cohen and the Figure1-COVID dataset forming the COVID-19 dataset. In Table 2 is summarized the distribution of samples, and in Figure 3 is shown some examples of images from these datasets from patients diagnosed with COVID-19. The non-COVID-19 datasets are the Chest X-Ray Pneumonia [31] and the RSNA Pneumonia detection challenge [32] . The Chest X-Ray Pneumonia dataset contains a total of 5, 863 PA view X-Ray images, collected from pediatric patients from one to five years old. The dataset is distributed into two categories: Normal or Pneumonia, and it is already organized into training, validation, and testing sets. Additionally, it also reported whether the pneumonia was caused by a virus or bacterial. Figure 4 illustrates some examples of images registered as "Normal", "Virus Pneumonia", and "bacterial Pneumonia". From the RSNA dataset, we selected the images corresponding to the "No Finding" and "Lung Opacity" classes, filtering out the images rotated at (90 • -270 • ) approx using the X-Ray filter. Table 2 summarizes the final distribution of samples after performed this process. Examples of the "No Finding" and "Lung Opacity" classes are shown in Figure 5 .
In this work, we rename the images labeled as Normal and Pneumonia to the non-Finding and Lung opacity class to have the same nomenclature of RSNA dataset, which contains images of more general cases. 
This section presents the experimental protocol used for training and evaluating the neural networks. Afterward, it is shown and analyzed the results obtained for each of them.
Experimental Protocol. The images were resized to 224 × 224 × 1 and normalized between zero to one. Besides, the training samples were augmented by performing random rotations of 5 • and zooming up to 10%. The experiments were carried out in an NVIDIA GPU Tesla P100 of 16 GB of RAM and 3584 Cuda cores. Table 3 : Training configuration used in the filter network.
Result. The training time was 30 minutes approximately, running a total of 69 epochs, when the early-stopping was activated (see Table 3 ). Figures 6 and 7 shows the evolution of the loss and accuracy function over training. Notice that the network achieved the best performance at epoch 54, where the loss function was 0.0075, and the accuracy was 99.83% in the validation set. Similar classification rates were obtained by evaluating the trained network in the testing set, reaching an accuracy of 99.3%.
Experimental Protocol. We first split each dataset into three groups: training, validation, and testing sets, adopting different criteria for each dataset. In the COVID-19 datasets, we selected the samples according to the patient to avoid having samples from the same patient in training and validation/testing sets, respectively. Specifically, we selected a proportion of 80%, 10%, and 10% of patients for training, validation, and testing, respectively. In the RSNA dataset, the samples were split randomly following the same proportion of the COVID-19 datasets because there is no more than one image per patient. In the Chest X-Ray Pneumonia dataset was not necessary to perform this procedure as this distribution was already provided. Finally, the corresponding groups were merged to constitute the final sets.
All images were resized to 224 × 224 and normalized according to the mean and standard deviation of the ImageNet dataset. Due to the dataset imbalance, we both oversampled the COVID-19 images and weighted the cross-entropy loss to enhance the classification of COVID-19 imagery. We assigned the weights for each class using equation 1,
where N ci is the number of samples for class i, N cmax the majority class and C the number of classes.
Considering the presence of images potentially labeled incorrectly, it was also applied the label smoothing as a regularization technique, setting alpha to 0.1. It prevents the model from making predictions too confidently during training that can be reflected in poor generalization. Then, cross-entropy loss takes the form described in equation 2 L = y sof t * log(ŷ) * ω ci + (1 − y sof t ) * log(1 −ŷ) (2) where y sof t = (1 − α) * y + α/C, and y andŷ the true and predicted labels, respectively.
Besides, we also augmented the training and validation samples by performing random horizontal flipping, rotation, brightness, scaling, occlusions at top of the images, cropping, and resize transformations. This procedure was carried out to avoid the network learns to maximize the inter-class differences based on the distribution of the noise that characterizes each dataset. For instance, it can be observed among the datasets, annotations like letters, arrows, captions, etc., associated with the software used for capturing the images, or/and by analysis achieved by the specialist.
During training, we monitored the validation loss function applying early stopping when no improvements were observed throughout five consecutive epochs. Also, the learning rate was reduced by a factor of 0.5 after a plateau on the validation loss. We initiated the learning rate of Adam optimizer to 1e − 5, fixing the other parameters to default values.
Finally, we assessed the performance of the model quantitatively and qualitatively. The foremost was performed in terms of sensitivity and specificity metrics, which quantifies the classifier's ability to avoid false negatives and false positives, respectively. The sensitivity is defined as the ratio between the number of true positives and the sum of true positive and false negatives, and the specificity as the ratio between the true negatives and the sum of the true negatives and false positives. The qualitative assessment was performed by analyzing the generated Class Activation Maps (CAM), which indicates the regions that were more relevant in the classification of the evaluated image.
Results Tables 4 and 5 summarize the performance of the model in terms of the confusion matrix, and sensitivity and specificity metrics, respectively after executing the experimetens 50 times. Specifically, Table 4 reports the sum of all classification matrix, whereas Table 5 presents the mean and standard deviation statistics of corresponding specificity and sensitivity metrics. Results demonstrate the high capability of the model to discern between the assessed classes. In particular, it is observed that the classifier exhibits a lower rate of missclassification regarding the COVID-19 class, although the lower amount of samples. Notice the major confusion occurs between Lung Opacity and COVID-19 samples. These results are expected due to the high correlation between Lung Opacity and COVID-19 samples, where almost all patients with COVID-19 symptoms present manifestations of pneumonia.
These results are reflected in the sensitivity and specificity metrics, where the classification rates are above 84.4% in mean for all classes. However, it is necessary the collection of more COVID-19 images to improve the capability of the models for this task. For a real scenario, it is important to have a classifier with a lower rate of false positives to reduce the propagation of the virus, as well as with lower false positives to avoid classifying healthy persons. Table 4 : Sum of all Confusion Matrix/Normalized confusion matrix obtained by evaluating the classifier in the corresponding testing set after running the experiments 50 times.
No Finding Lung Opacity Covid-19 Sensitivity 92.6 ± 1.2% 91.2 ± 1.0% 84.4 ± 3.2%% Specificity 94.3 ± 0.5% 93.6 ± 1.0% 98.0 ± 0.7%% Table 5 : Results obtained by the classifier in terms of Sensitivity and Specificity metrics. It is reported the mean and standard desviations statistics. Figure 8 shows three examples per class of classification activation maps (CAMs) corresponding to images from the testing set. Specifically, it is shown a composition of the images and the associated CAM as heatmaps. By performing this analysis, it can be determined the most relevant regions considered by the network to make the final classification. In fact, it can be noticed the higher intensities on heatmaps are localized around the lungs as expected, and artifacts as rows or letters present on the images are ignored by the network to make the final prediction. These results indicate that the network is not making the final decision based on the noise characteristics of each dataset. As it is observed in the images of Figure 3 , there are artifacts that can easily be identified by the network to discern between images from the assessed classes. Regarding images belonging to Lung Opacity, it is remarked that the network was able to identify the regions where these opacities occur. Similar behavior can be observed in the COVID-19 images where the network also highlights the most whited regions. These results are expected considering the high correlation between COVID-19 image and Pneumonia, as COVID-19 causes Pneumonia. For the Non Finding class, the heatmaps are concentrated in the central part of the chest, between the Lungs. Finally, Figure 9 shows examples of images missclassified. It can be observed that images classified as COVID-19 being of n Lung Opacit, presents similar characteristics and vice-versa. This situation is expected to be common in patients with advanced degrees of pneumonia. This situation is expected to be common for patients with advanced stages of pneumonia independently the cause of it. 
The site is structured in three sections, being the first one, where the user can interact with the website to test owned X-Ray images or examples available on the website. The second one describes the motivation and objectives of the project, and the third one presents the proposed solution as well as the technical explanation of its implementation. Figure 10 displays a snip of the first section of the web site at its initial state, while Figure 11 shows examples of testing performed on it. In particular, it is illustrated in diagrams of bars the result obtained for the actual test, and a history of the last experiment carried out. Besides, for each test, it is shown a brief description of the results, indicating if the image evaluated is from a healthy person, with opacity in the Lungs, or with characteristics of COVID-19. Finally, the web page also shows an Embedding projector [33] 11 to visualize and interpret the features extracted from 294 X-Ray images from the dataset. For instance, Figure 12 presents this iterative tool visualizing a basic clustering using the PCA algorithm, where red and blue samples correspond to No Finding and COVID-19 images, respectively
In this work, a free web service for fast corona virus 2019 (COVID-19) classification using chest X-ray images is presented. The web service is handy and accessible, being possible to use it from desktop computer or mobile devices. It has dedicated GPUs for real-time inference and relies on two deep learning models: a model to differentiate between X-Ray and non-X-Ray images, and a model to detect COVID-19 characteristics in chest X-ray images.
The web service is composed of three main parts: a friendly web interface, an X-Ray image filter, and a COVID-19 classifier. The web interface allows the user to upload a chest X-Ray image for consultation and receive a classification, which can be Healthy, Characteristics of Pneumonia, or COVID-19. Moreover, a heatmap with the Class Activation Maps (CAM) is generated, which indicates the regions that were more relevant in the classification of the evaluated image.
An X-Ray image filter have been implemented to differentiate between valid images (pulmonary frontal X-Ray images), and non-valid images (rotated pulmonary X-Ray images, natural images, other kind of images). A pre-trained MobileNet architecture have been employed for this purpose, achieving an accuracy of 99.3%.
The COVID-19 Classifier was implemented by optimizing a pre-trained ImageNet DenseNet. Results demonstrated the capability of the model to discern between the assessed classes, recording values above 89% in terms of sensitivity and specificity metrics. Additionally, a qualitative evaluation, based on the analysis of the generated CAM, indicates that the trained network makes its decisions focuses on the regions of the image where the Lungs are located. This analysis shows that the strategy of augmenting the data and replicating the COVID-19 samples helped to mitigate the problem of overfitting considering the scarcity of COVID-19 samples.
Future works consider the assessment of the system in hospitals to have feedback from specialists. We will provide a platform to annotate samples to increase the dataset, and retrain the network to have a more accurate model.
Besides, we will extend our methodology to make classification in Computerized Tomography images where more COVID-19 images are available.