<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Mask Classification-based method for Polyps Segmentation and Detection</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Mariia Kokshaikyna</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Yurii Yelisieiev</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Mariia Dobko</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>The Machine Learning Lab, Ukrainian Catholic University</institution>
          ,
          <addr-line>Lviv</addr-line>
          ,
          <country country="UA">Ukraine</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>We introduce a mask classification model with a transformer decoder for polyps segmentation in endoscopy images. Our novel approach combines custom data pre-processing, a modified mask classification network, test time augmentations, and connected-component analysis. We show the successful performance for polyp semantic segmentation and detection tasks in EndoCV 2022 challenge.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>classification baselines on natural scenes.</p>
      <p>
        We propose to use a mask classification-based method
Endoscopy is a widely used procedure for detecting and for polyp segmentation in endoscopy data. We are the
diagnosing multiple diseases. Computer-aided endo- first to test this model on endoscopic images to our best
scopic image analysis and decision support systems can knowledge. We also customize parts of MaskFormer [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]
help doctors with diagnosis and increase its efectiveness. architecture and show its successful performance for
Such systems are mainly used to detect, localize, and polyp detection.
segment cancer precursor lesions, also called “polyps.” To increase the robustness of our solution, we add
EndoCV challenge [
        <xref ref-type="bibr" rid="ref1 ref2 ref3 ref4">1, 2, 3, 4</xref>
        ] aims to tackle the gener- test time augmentations (TTA) and perform
connectedalizability aspect of such methods. In 2022, it has two component analysis (CCA).
sub-challenges (Endoscopy artefact detection) EAD 2.0 Our contribution can be summed up as follows:
and (Polyp generalization) PolypGen 2.0. Both tracks set
detection and segmentation tasks on a diverse population • Evaluated and showed the performance of mask
dataset. This work describes our solution to the EndoCV classification method - MaskFormer on
en2022 challenge on the polyp segmentation and detection doscopy data. Added custom modifications that
tracks. improve results of MaskFormer for polyp
segmen
      </p>
      <p>
        The dataset of EndoCV 2022 challenge [
        <xref ref-type="bibr" rid="ref1 ref2 ref3 ref4">1, 2, 3, 4</xref>
        ] tation.
is diverse and comprises images from various endo- • Presented a step-by-step pre-processing
mechascope types. This presents an additional dificulty to any nism for training and inference
computer-aided system. We decided to simplify the input • Tested the impact of diferent loss functions
by cropping out the uninformative part and generalizing • Added custom post-processing using test time
the input image at pre-processing step. augmentations and connected-component
analy
      </p>
      <p>
        Standardly, the semantic segmentation task is solved sis
as a per-pixel classification problem, applying a
classification loss to each output pixel. An alternative approach
is mask classification which, instead of classifying each 2. Data Pre-processing
pixel, predicts a set of binary masks, each associated
with a single class prediction. Authors of MaskFormer
[
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] proposed a modern approach last year by using mask
classification to solve both semantic- and instance-level
segmentation tasks in a unified manner. This model
predicts a set of binary masks corresponding to a single
global class label. MaskFormer [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] outperforms per-pixel
The PolypGen2.0 subchallenge dataset consists of 46
sequences with 3348 images with polyp labels. Diferent
endoscopes produced these images with various sizes
and artifacts - black section located at the left part of the
image, blue rectangle with endoscope position, text
artifacts, and others. Overall, we can distinguish 15 types of
images among these sequences. Statistics about diferent
types is shown on Fig 2.
      </p>
      <p>For train and validation set, we divided sequences
into groups using mannually labeled endoscope
image types. For validation set we selected sequences
seq1, seq1_endocv22, seq2_endocv22, seq3, seq3_endocv22,</p>
      <p>Automatic
Pre-processing
removing uninformative
regions</p>
      <p>Modifications to N of queries and</p>
      <p>embeddings
MaskFormer image from original paper</p>
      <p>TTA</p>
      <p>+
Connected
component</p>
      <p>analysis
Post-processing
n
o
it
c
i
d
e
r
p
l
a
n
i
F</p>
    </sec>
    <sec id="sec-2">
      <title>3. Method</title>
      <p>
        We chose MaskFormer [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] as the primary model for our
approach. MaskFormer approaches the problem of
semantic segmentation as a classification of masks. This
approach is an alternative to the per-pixel classification,
which predominates in semantic segmentation problems.
Instead of classifying each pixel separately, mask
classification approaches disjoins the process of semantic
segmentation into a division of the image into regions
and classification of these regions. Such an approach
is general enough to solve semantic and instance
segmentation problems. MaskFormer is divided into three
modules: pixel-level, transformer, and segmentation.
      </p>
      <sec id="sec-2-1">
        <title>3.1. Pixel-level module</title>
        <p>This module is an encoder-decoder architecture typically
used for the semantic segmentation task. The encoder
part (a backbone) generates a high-level feature
representation of the image. Further, we obtain pixel-level
embeddings by iteratively upsampling feature
representation from the encoder. Since this is a typical problem
setting for a per-pixel classification semantic
segmentation task, any model of this type can be plugged into this
module.
seq15, seq17, seq19_endocv22, seq21_endocv22, and
seq24_endocv22. Other sequences were used in training
set. Overall, our train set contains 3306 images and
validation set contains 649 images, which is 19,63% of total
image number.</p>
        <p>To bring all images to the same view and use the most
informative regions during training, we make simple pre- 3.2. Transformer module
processing and automatically crop images cutting black
areas on the left and right sides of the input. To do that,
we take the center row of the image, sum up values of
RGB channels in this row and use a threshold equal to
48. Continuous left and right parts under this threshold
are considered redundant and cut. Examples of cropped
images are shown in Fig 3. This cropping improves the
informativeness of images and model generalization.</p>
        <p>
          Transformer module generates  learnable positional
embeddings (i.e., queries) as in DETR[
          <xref ref-type="bibr" rid="ref6">6</xref>
          ], which encodes
global information about each segment of MaskFormer
prediction. This module architecture is adapted from
transformers[
          <xref ref-type="bibr" rid="ref7">7</xref>
          ], popular for sequence data. In contrast
to the standard transformer architecture, each object is
decoded in parallel. In Transformer module each output
is predicted in an autoregressive manner. The attention
mechanism encodes information about the relation of
zero, and the cross-entropy loss will rapidly converge to
zero. Therefore we changed cross-entropy loss to focal
loss to mitigate class imbalance in the classification. We
have experimented with Boundary loss, which showed
promising results in other medical imaging tasks. For
our results with this loss, refer to Section 5.2.
        </p>
      </sec>
      <sec id="sec-2-2">
        <title>3.5. Our modifications</title>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>4. Post-processing</title>
      <p>The segmentation module utilizes a linear classifier and a
softmax activation function to acquire class probabilities
from each query. Note that we have only two distinct
categories of object and no object in the case of the EndoCV
PolypGen subtask. An MLP with two hidden dimensions
converts queries into mask embeddings for further
conversion. The dot product between mask embeddings and
per-pixel embeddings is used to calculate mask
predictions.</p>
      <p>Test time augmentation is widely used to increase the
model’s robustness in deep learning. This procedure
makes the final prediction by averaging the predictions
after several separately performed augmentations. Our
TTA includes horizontal and vertical flips, rotations for
90 and 180 degrees, scaling the input from original size
down to 50% of the original size.
3.4. Model training Connected-component analysis We perform
We need one-to-one correspondence between ground connected-component analysis of predicted labels during
truth labels and predictions to calculate losses. This prob- inference. The algorithm divides the segmentation mask
lem is solved as in DETR via bipartite matching. Mask into components according to the given connectivity.
and class predictions are used instead of bounding boxes CCA can have 4 or 8-connected-neighborhood. We
to calculate costs. remove all smaller parts from the prediction based on</p>
      <p>Model training given matching is performed by utiliz- the largest connected component.
ing mask classification composed of cross-entropy
classiifcation loss and a binary mask loss.</p>
      <p>
        5. Experiments
 We compare our approach against CaraNet [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] which is
ℒmask-cls ︀( , gt)︀ = ∑︁ [︀ − log  () ︀( gt)︀ + (1) one of the state-of-the-art methods for polyp
segmen=1 tation. This model has proven to be efective on many
      </p>
      <p>
        endoscopy datasets including Kvasir-SEG [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. On this
1gt̸=∅ℒmask (︀  (), gt)︀ , challenge, however, CaraNet with default parameters
where mask loss is a linear combination of dice and focal shows a good Precision score of 0.6041, but much worse
loss as in MaskFormer. Dice than our proposed solution, refer to Table1. In our
      </p>
      <p>Since we exploited MaskFormer for binary segmenta- experiments MaskFormer is capable of capturing more
tion, most ground truth classes for each query will be cases of polyps presence.</p>
      <sec id="sec-3-1">
        <title>5.1. TTA and CCA impact</title>
        <p>TTA and CCA impact on result on our validation set is
provided in Table 1. We observe that TTA and CCA in
most cases help to decrease false positive regions. For
images where TTA and CCA improved predicted masks,
see Fig. 4.</p>
      </sec>
      <sec id="sec-3-2">
        <title>5.2. Boundary loss</title>
        <p>
          We use a combination of cross-entropy classification loss
and a binary mask loss for each predicted segment
during training. The binary loss is a linear combination of
focal, and dice losses [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]. We also experimented with
other losses. Boundary loss [
          <xref ref-type="bibr" rid="ref11">11</xref>
          ] was initially proposed
for highly unbalanced segmentation, for instance, when
the size of the target foreground region is several times
less than the background. It works as a distance metric on
the space of contours; computing active-contour flows
through a non-symmetric L2 distance on the space of
contours as a regional integral. This method has shown
remarkable results on medical images, for example, in the
task of white matter hyperintensities segmentation.
However, our experiments didn’t show any positive impact of
boundary loss for polyp segmentation. It decreased the
performance severely, refer to the comparison in Table 2.
        </p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>6. Discussion</title>
      <p>
        We assume that including sequence information as an
input to MaskFormer [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] can potentially improve the
results. Since the original MaskFormer architecture starts
with a regular convolution, one could combine sequences
into a volume and pass it as a separate channel for the
convolutional layer. Another option is to use a Mask2Former
[
        <xref ref-type="bibr" rid="ref12">12</xref>
        ] model, which was created for video segmentation
and inspired by MaskFormer. Mask2Former [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ] is based
on Masked-attention Mask Transformer for universal
image and video segmentation. It is possible to
incorporate their idea in combining the images from the same
sequence into a single input with additional dimension
responsible for time frames.
      </p>
    </sec>
    <sec id="sec-5">
      <title>7. Conclusion</title>
      <p>
        We are first to show the mask classification-based model
performance on endoscopy data. We use MaskFormer [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]
as the main component of our approach, adding
modifications to the number of queries, for instance, decreasing
the number as polyp segmentation is a binary
segmentation task. We also introduce a simple pre-processing
technique for endoscopy images, which helps to remove
redundant information from the input. This step
simpliifes the learning of meaningful features for the model.
Moreover, we add test time augmentation and
connectedcomponent analysis at post-processing. Combining all
these components achieves a 54.97 Dice score on round
2 validation in the EndoCV2022 challenge.
      </p>
      <p>
        In this work, we also experiment with boundary loss
for MaskFormer [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] and show that it doesn’t bring
improvements in the polyp segmentation task.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>S.</given-names>
            <surname>Ali</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Jha</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Ghatwary</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Realdon</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Cannizzaro</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O. E.</given-names>
            <surname>Salem</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Lamarque</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Daul</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K. V.</given-names>
            <surname>Anonsen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. A.</given-names>
            <surname>Riegler</surname>
          </string-name>
          , et al.,
          <article-title>Polypgen: A multi-center polyp detection and segmentation dataset for generalisability assessment</article-title>
          ,
          <source>arXiv preprint arXiv:2106.04463</source>
          (
          <year>2021</year>
          ). doi:
          <volume>10</volume>
          .48550/ arXiv.2106.04463.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>S.</given-names>
            <surname>Ali</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Dmitrieva</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Ghatwary</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Bano</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Polat</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Temizel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Krenzer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Hekalo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y. B.</given-names>
            <surname>Guo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Matuszewski</surname>
          </string-name>
          , et al.,
          <article-title>Deep learning for detection and segmentation of artefact and disease instances in gastrointestinal endoscopy</article-title>
          ,
          <source>Medical Image Analysis</source>
          <volume>70</volume>
          (
          <year>2021</year>
          )
          <article-title>102002</article-title>
          . URL: https://doi.org/10.1016/j. media.
          <year>2021</year>
          .
          <volume>102002</volume>
          . doi:
          <volume>10</volume>
          .1016/j.media.
          <year>2021</year>
          .
          <volume>102002</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>S.</given-names>
            <surname>Ali</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Zhou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Braden</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Bailey</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Yang</surname>
          </string-name>
          , G. Cheng, P. Zhang,
          <string-name>
            <given-names>X.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Kayser</surname>
          </string-name>
          , R. D.
          <string-name>
            <surname>Soberanis-Mukul</surname>
          </string-name>
          , et al.,
          <article-title>An objective comparison of detection and segmentation algorithms for artefacts in clinical endoscopy</article-title>
          ,
          <source>Scientific Reports</source>
          <volume>10</volume>
          (
          <year>2020</year>
          ). URL: https://doi.org/10.1038/s41598-020-59413-5. doi:
          <volume>10</volume>
          .1038/s41598-020-59413-5.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>S.</given-names>
            <surname>Ali</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Zhou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Bailey</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Braden</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. E.</given-names>
            <surname>East</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Lu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Rittscher</surname>
          </string-name>
          ,
          <article-title>A deep learning framework for quality assessment and restoration in video endoscopy</article-title>
          ,
          <source>Medical Image Analysis</source>
          <volume>68</volume>
          (
          <year>2021</year>
          )
          <article-title>101900</article-title>
          . URL: https://doi.org/10.1016/j.media.
          <year>2020</year>
          .
          <volume>101900</volume>
          . doi:
          <volume>10</volume>
          .1016/j.media.
          <year>2020</year>
          .
          <volume>101900</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>B.</given-names>
            <surname>Cheng</surname>
          </string-name>
          , et al.,
          <article-title>Per-pixel classification is not all you need for semantic segmentation</article-title>
          ,
          <year>2021</year>
          . URL: https: //arxiv.org/abs/2107.06278. doi:
          <volume>10</volume>
          .48550/ARXIV. 2107.06278.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>N.</given-names>
            <surname>Carion</surname>
          </string-name>
          , et al.,
          <article-title>End-to-end object detection with transformers</article-title>
          ,
          <source>in: European conference on computer vision</source>
          , Springer,
          <year>2020</year>
          , pp.
          <fpage>213</fpage>
          -
          <lpage>229</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>A.</given-names>
            <surname>Vaswani</surname>
          </string-name>
          , et al.,
          <article-title>Attention is all you need</article-title>
          ,
          <source>Advances in neural information processing systems</source>
          <volume>30</volume>
          (
          <year>2017</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>A.</given-names>
            <surname>Lou</surname>
          </string-name>
          , et al.,
          <article-title>Caranet: Context axial reverse attention network for segmentation of small medical objects</article-title>
          ,
          <source>arXiv preprint arXiv:2108.07368</source>
          (
          <year>2021</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>D.</given-names>
            <surname>Jha</surname>
          </string-name>
          , et al.,
          <string-name>
            <surname>Kvasir-SEG</surname>
          </string-name>
          :
          <article-title>A segmented polyp dataset</article-title>
          ,
          <source>in: MultiMedia Modeling</source>
          , Springer International Publishing,
          <year>2019</year>
          , pp.
          <fpage>451</fpage>
          -
          <lpage>462</lpage>
          . URL: https://doi.org/10.1007/978-3-
          <fpage>030</fpage>
          -37734-2_
          <fpage>37</fpage>
          . doi:
          <volume>10</volume>
          .1007/978-3-
          <fpage>030</fpage>
          -37734-2_
          <fpage>37</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <surname>T.-Y. Lin</surname>
          </string-name>
          , et al.,
          <source>Focal loss for dense object detection</source>
          ,
          <year>2017</year>
          . URL: https://arxiv.org/abs/1708.
          <year>02002</year>
          . doi:
          <volume>10</volume>
          . 48550/ARXIV.1708.
          <year>02002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>H.</given-names>
            <surname>Kervadec</surname>
          </string-name>
          , et al.,
          <article-title>Boundary loss for highly unbalanced segmentation</article-title>
          ,
          <source>Medical Image Analysis</source>
          <volume>67</volume>
          (
          <year>2021</year>
          )
          <article-title>101851</article-title>
          . URL: http://dx.doi.org/10.1016/j. media.
          <year>2020</year>
          .
          <volume>101851</volume>
          . doi:
          <volume>10</volume>
          .1016/j.media.
          <year>2020</year>
          .
          <volume>101851</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>B.</given-names>
            <surname>Cheng</surname>
          </string-name>
          , et al.,
          <article-title>Masked-attention mask transformer for universal image segmentation</article-title>
          ,
          <source>arXiv</source>
          (
          <year>2021</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>