Applications of Convolutional Neural Networks to medical images have recently produced efficient solutions for a vast variety of medical problems, such as segmentation of lung nodules in computed tomography (CT) scans [13] , lesions detection in mammography images [1] , segmentation of brain gliomas from MRI images [4] and others [26, 30] . One of the greatest challenges for using deep learning methods in medicine is the lack of large annotated datasets, especially with pixel-level labeled data. Creating such datasets is often very expensive and time consuming. For instance, Lin et al. [20] calculated that collecting bounding boxes for each class is about 15 times faster than producing a ground-truth pixel-wise segmentation mask; getting image-level labels is even easier. Moreover, domain expertise is required to label medical data, which poses another challenge as the doctor's time is costly and could more effectively be used for a patient's diagnosis and disease treatment. Working with image-level annotations also decreases the probability of disagreement between experts, since pixel-wise annotations tend to have more noise and vary among labelers.
To decrease the resources spent on labeling while preserving its quality, we propose a novel weakly-supervised approach to image segmentation that uses only image-level labels. Our method is domain-independent; we have tested it on several distant datasets, including popular PASCAL VOC 2012 [11] , and a medical dataset, SIIM-ACR Pneumothorax [28] . We achieve 64.6 mean intersectionover union (mIoU) score on PASCAL VOC 2012 [11] validation set. Our method is capable of segmenting medical images with limited supervision achieving 76.77 mIoU score on the test set of SIIM-ACR Pneumothorax dataset [28] . The automatic approach to finding Pneumothorax could be used to triage chest radiographs requiring priority interpretation, to rapidly identify critical cases, and also provide a second-opinion for radiologists to make a more confident disease diagnosis.
The objective of weakly-supervised segmentation is to create models capable of pixel-wise segmentation based on image-level labels. The existing approaches can be categorized by their methodologies into four groups: Expectation-Maximization, Multiple Instance Learning, Self-Supervised Learning, and Object Proposal Class Inference [6] . In this paper, we follow the self-supervised paradigm, which suggests training a fully supervised segmentation model on the created pseudopixel-level annotations, also known as Class Activation Maps (CAM) [33] , which are extracted from the classification network. This paradigm is the most challenging one as it leads to the least informative form of weak supervision providing no location information for the objects. However, judging from the quantitative performance on PASCAL VOC 2012 [11] validation set, the top five methods of weakly-supervised segmentation use the self-supervised learning approach [6] .
Many methods of self-supervised learning for semantic segmentation have been recently suggested. Kolesnikov et al. [18] propose Seed Expand Constrain (SEC) method, which trains a CNN, applies CAM to produce pseudo-groundtruth segments, and then trains a Fully Convolutional Network (FCN) optimizing three losses: one for the generated seeds, another for the image-level label, and, finally, a constraint loss against the maps processed by Conditional Ran-dom Fields (CRF). Huang et al. [16] introduce Deep Seeded Region Growing (DSRG), which propagates class activations from high-confidence regions to adjacent regions with a similar visual appearance by applying a region-growing algorithm on the generated CAM. Lee et al. [19] present FickleNet, which trains a CNN at the image level with a regularization step represented as a centerfixed spatial dropout in the later convolutional layers, and then runs Grad-CAM [27] multiple times to generate a thresholded pseudo-labels for a segmentation step. Another approach, proposed by Ahn et al. [3] , suggests using IRNet [3] , which takes the random walk from low-displacement field centroids in the CAM up until the class boundaries as the pseudo-ground-truths for training an FCN. Ahn et al. [3] focus on the segmentation of the individual instances estimating two types of features in addition to CAM: a class-agnostic instance map and pairwise semantic affinities.
The weakly-supervised semantic segmentation on medical datasets has been explored in [22, 2, 10, 5, 25] . On the other hand, Ouyang et al. [23] combine the weakly-annotated data with well-annotated cases to segment Pneumothorax in chest X-rays. In our approach, we do not use any form of supervision besides image-level labels. We focus on developing a standardized method, which is efficient for various data types, especially for medical images.
Our method can be split into three consecutive steps: Class Activation Maps generation, map enhancement with Inter-pixel Relation Network, and segmentation. After each step, we also add one or more post-processing techniques such as CRF, thresholding, noise filtering (small regions with low confidence).
Step 1. CAM generation First, we train fully-supervised classification models on image-level labels. The two tested architectures for this step were ResNet50 [14] and VGG16 [29] with additional three convolutional layers followed by ReLU activation. We also replace stride with dilation [32] in the last convolutional layers to increase the size of the final feature map while decreasing the output stride from 32 to 8. We improve the classification performance by including a regularization term, inspired by FickleNet [19] . For this, we use DropBlock [12] -a dropout technique, which to our best knowledge has not been tried in previous works on weakly-supervised segmentation. The trained models are then used to retrieve activation maps by applying the Grad-CAM++ [7] method. The resulting maps serve as pseudo labels for segmentation task.
Step 2. IRNet On the second step, IRNet [3] takes the generated CAM and trains two output branches that predict a displacement vector field and a class boundary map, correspondingly. They take feature maps from all the five levels of the same shared ResNet50 [14] backbone. The main advantage of IRNet [3] is its ability to improve boundaries between different object classes. We train it on the generated maps, thus no extra supervision is required. This step allows us to obtain better pseudo-labels before proceeding to segmentation. To our best knowledge, this approach has not been used in the medical imaging domain before.
Step 3. Segmentation For the segmentation step, we train DeepLabv3+ [9] and U-Net [26] models with different backbones, which have proven to produce reliable results in fully supervised semantic segmentation on medical images [30, 26] . The used backbones include ResNet50 [14] and SEResNeXt50 [15] . We modify the binary cross-entropy (BCE) loss during segmentation by adding weights to a positive class to prevent overfitting towards normal cases.
PyTorch [24] was used for implementing and training all steps of our approach: extracting localization maps via the classification networks, improving obtained maps with IRNet [3] and segmenting the image during segmentation task. All the experiments were performed on four Nvidia Tesla K80 GPUs.
We conduct experiments on two datasets: PASCAL VOC 2012 [11] and SIIM-ACR Pneumothorax [28] . We evaluate the quality of our pseudo-ground-truth and the performance of the segmentation model trained on them using mIoU. PASCAL VOC 2012 [11] is an image segmentation benchmark dataset containing 20 object classes, and a background class. As in other works on weaklysupervised segmentation, we train our models using augmented 10,582 training images with image-level labels. We report mIoU for 1,449 validation images.
SIIM-ACR Pneumothorax [28] is a competition that provides an open dataset of chest X-ray images with pixel-wise annotation for regions affected by Pneumothorax: a collapsed lung, where an abnormal volume of air is formed in the pleural space between the lung and the chest wall. This dataset was formed from a subset of ChestX-ray14 dataset [31] , but relabeled by professional radiologists, and additionally annotated on a pixel level. The specified competition has two stages; ground truth labels are provided only for the first, the second is evaluated on the competition website. Thus, we divided images from the first stage into three sets: train, validation and test. Totally, 12,047 frontal-view chest X-ray cases are in the dataset. We use 2,379 positive and 8,296 negative images for training, 145 and 541 for validation, 145 and 541 for the test.
SIIM-ACR Pneumothorax [28] dataset has a severe class imbalance problem. The number of normal cases exceeds approximately 4 times the number of positive ones. In order to prevent overfitting towards healthy patients we use various augmentation techniques such as scaling, rotation, blur, brightness adjustment, and horizontal flipping. We also add sampling in our data loader during training, which selects the constant ratio between negative and positive class. Another challenge in this dataset is the size of regions of interest. Pneumothorax usually affects a very small area of lungs resulting in a high disbalance among the image pixels. We solve this problem by adding weights for positive class to binary crossentropy loss. Due to these data challenges we evaluate the performance of our method on SIIM-ACR Pneumothorax not only for all images in validation and test sets, but also separately for positive cases, see Table 3 .
Step 1. CAM generation For classification we implement ResNet50, and VGG16. As suggested in previous work [17] , we added three convolutional layers on the top of the fully-convolutional backbone, each of which is followed by a ReLU. The conducted experiments show that adding DropBlock regularization to our classification models improves their performance, see Table 1 . For both datasets, the best classification results were achieved using VGG16, which was, thus, selected as the final model for this task. We test two methods for generating pseudo-annotations: Grad-CAM [27] , and Grad-CAM++ [7] . Our experiments show that Grad-CAM++ [7] , which utilizes a regularization that Grad-CAM is lacking of, provides better object localization through visual explanations of model predictions; cf. Table 2 .
Step 2. IRNet For both datasets as post-processing of maps produced at Step 1, we use thresholding and then refine the pseudo-maps by dense CRF to better capture object shapes. The resulting annotations are used to train IRNet.
Step 3. Segmentation The obtained maps after IRNet step are used as the pseudo-labels for segmentation. We implement three networks to complete this task: U-Net [26] , DeepLabv3 [8] , and DeepLabv3+ [9] . We report results on PAS-CAL VOC 2012 produced by DeepLabv3+, as it shows better performance than DeepLabv3 with the same ResNet50 backbone. For SIIM-ACR Pneumothorax, however, U-Net with SEResNeXt50 [15] backbone shows the best results.
For all the models, three optimization methods are examined: SGD, Adam and RAdam [21] . For Pneumothorax segmentation, SGD optimizer is applied with the learning rate initiated as 6e-5 and gradually decreasing each epoch, whereas momentum is set to 0.9, and weight decay to 1e-6. The size of network inputs is 512x512, the batch is 48, and it is balanced according to class distribution using augmentations to increase the sample of positive cases.
The comparison of segmentation methods using the same chest X-ray datasets is not simple due to the challenge of finding public medical data. Moreover, this work is the first to present the results of weakly-supervised segmentation methods on SIIM-ACR Pneumothorax [28] data. However, the performance of our models is comparable to Ouyang et al. [23] , who reported their scores on a collected closed dataset of Pneumothorax. These authors train their method with different combinations of well-and weakly-annotated data, whereas our method uses only image-level labels. In Table 3 we show how the results improve with each step of our approach; the result of Ouyang et al. [23] model trained on 400 weakly-annotated and 400 well-annotated cases is specified too. We present method's explainability via disease localization regions; cf. Figure  1 . We provide qualitative results of segmentation on validation images from both datasets in Figure 2 and Figure 3 . We show the resulting maps at each step of our method; the figures demonstrate how the performance improves after each step. We achieve comparable results to state-of-the-art method on PASCAL VOC 2012; cf. Table 4 . We evaluate our method on the second stage test set on the competition server [28] to compare it against a fully-supervised upper-performance limit. We achieve 0.769 Dice score while the first place solution got 0.868 using pixel-level labels for training. Our method proves the capability of using only image-level annotations for semantic segmentation on chest X-rays, nevertheless, attaining as good or even better results than those produced by fully supervised networks is still a challenge for weakly-supervised approaches. 
During diagnosing procedure the final decision maker is a doctor, while AIpowered decision support systems can assist by detecting regions of interest and presenting the data in a convenient format that doctors can use. With an automatic image segmentation solution, the healthcare provider can reach higher efficiency by saving doctors' time spent on the primary analysis of images. At the same time it will increase diagnosis accuracy by providing the second opinion. The major problem in building such a solution is the lack of large amounts of pixel-wise labeled data that are extremely costly in terms of the expert time required for their annotation. With our approach, which requires only image-level annotations, the costs can be reduced dramatically. In the long run, it allows the cheaper implementation of segmentation models, also facilitating research in the area by overcoming the problem of collecting datasets with pixel-wise annotations. Saving doctors' time on diagnosis is especially important during the disease widespread such as COVID-19, when large number of people are affected by a disease and the amount of required screening procedures grows exponentially. Using our method for medical images can automate parts of the radiology workflow cutting operational costs for the hospitals. The proposed approach was designed to be general and applicable to other medical purposes; for example detection of various thoracic diseases.
We present a novel method of weakly-supervised semantic segmentation that demonstrated its efficiency for detecting anomalous regions on chest X-ray images. In particular, we propose a three-step approach to weakly-supervised semantic segmentation, which uses only image-level labels as supervision. Next, we customize and expand the previous works by including supplementary steps such as regularization, IRNet, and various post-processing techniques. Also, the method is general, domain independent and explainable via localization maps at each step. We evaluated it on two datasets of different nature; however, it can also be implemented in other medical problems. 
For the evaluation we use mIoU (mean intersection over union), Dice score and F 1-score. The mIoU metric was used to compare our result to already existing approaches. For all images and k classes is defined as follows:
where T P , F P , F N are numbers of true positive, false positive and false negative pixels respectively. The Dice score was used to compare our results of weakly-supervised model to the first place solution with fully-supervised approach on SIIM-ACR Pneumothorax [28] . The metric is defined as follows: Dice = 2 × T P (T P + F P ) + (T P + F N ) where T P , F P , F N are numbers of true positive, false positive and false negative pixels respectively. If all pixels are true negative, prediction is considered correct and metric equals 1.
The F 1-score was used to compare approaches on a first step step of our pipeline -classification. The metric is defined as follows:
where precission = T P T P +F P , recall = T P T P +F N , and T P , F P , F N are true positive, false positive and false negative rates respectively.