<!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>Custom semantic segmentation neural network architecture in spirochaete detection application</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Michał Wieczorek</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Natalia Wojtas</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Faculty of Applied Mathematics, Silesian University of Technology</institution>
          ,
          <addr-line>Kaszubska 23, 44100 Gliwice</addr-line>
          ,
          <country country="PL">Poland</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Faculty of Veterinary Medicine, University of Life Sciences in Lublin</institution>
          ,
          <addr-line>Stanisława Leszczyńskiego 7, 20400 Lublin</addr-line>
          ,
          <country country="PL">Poland</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The kingdom of bacteria is a very diverse group of organisms characterized by high phenotypic variability. This feature is often used in clinical diagnosis. The spirochaetes are a microbes with a characteristic spiral shape of a flagella located within the periplasmic space. Nowadays, there is a high demand for creating a rapid and sensitive method for their detection as many of them performs a high pathogenic risk. Currently used methods lays on combination of clinical examination results, serologic and cultivation methods. There can be also used Polymerase Chain Reaction (PCR) method if needed. Unfortunately this combination can be very time consuming and require a lot of money. This research presents a novel, semantic segmentation neural network architecture designed to quickly create a classification mask, outputting information about the position, shape, and possible afiliation of detected elements. The evaluation method isbased on a light microscope imagery and was created to overcome above mentioned problems. Used abstract classes contains erythrocytes, spirochaete and background. The resulted mask can be later mapped to a human-readable form with the inclusion of colors, next to an original image. Such approach allows for semi-automatic recognition of unwanted objects, however still giving the final verdict to the specialist. Developed solution has achieved a high recognition accuracy, while the computer power requirements are kept at a minimum. The proposed solution can help reduce misclassification rates by providing additional data for the doctor and speed up the entire process with the early diagnosis made by a neural network.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Spirochaete</kwd>
        <kwd>detection</kwd>
        <kwd>mask</kwd>
        <kwd>semantic segmentation</kwd>
        <kwd>neural network</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>IVUS 2022: 27th International Conference on Information Technology
*Corresponding author.
† These authors contributed equally.
$ michal_wieczorek@hotmail.com (M. Wieczorek); natjia@wp.pl
(N. Wojtas)</p>
      <p>© 2022 Copyright for this paper by its authors. Use permitted under Creative Commons License in our paper we propose a quick and simple method of
CPWrEooUrckReshdoinpgs IhStpN:/c1e6u1r3-w-0s.o7r3g ACttEribUutRion W4.0oInrtekrnsahtioonpal (PCCroBYce4.0e).dings (CEUR-WS.org) evaluating the presence of spirochaete bacteria, that may
2 after each block. The internal signal addition within
the convolutional blocks contains several branches with
diferent layers count and combinations of batch
normalization layers. The final block output is combined using
concatenate and add layers for better signal fidelity.
Sample scheme is presented in Fig. 4. The training has been
optimized using NAdam algorithm with learning rate
of 0.0078 and the selected loss function was
Categorical Cross-entropy with custom class weights computed
before training to balance the training.</p>
      <sec id="sec-1-1">
        <title>2.1. NAdam algorithm</title>
        <p>To improve model’s performance in terms of final
accuracy performance and the training times the NAdam
training algorithm has been used. The formula can be
described as follows:
 = 1−1 + (1 − 1),</p>
        <p>2
 = 2−1 + (1 − 2) ,
where  parameters are constant hyper-parameters and 
is the current gradient value of an error function. Values
 and  are used later for computing the correlations
marked as ˆ and ˆ according to below equations:
ˆ = (1 − 1) + 1+1 
ˆ
 =</p>
        <p>1 − 2
.</p>
        <p>ˆ
 = −1 −  √2 +</p>
        <p>Finally, using previously calculated variables, the final
formula can be defined as:
speed up the diagnosis, give the doctors a valuable clue
and save money and health of the patient. This can be
especially valuable for busy, first contact clinics as a
primary method of evaluating the presence of spirochaete
microorganisms, whose presence can be predicted after
a basic physical examination, before some more detailed
and expensive tests.</p>
        <sec id="sec-1-1-1">
          <title>2. Proposed deep learning solution</title>
          <p>The concept of microbe detection can be approached
using different various techniques, however some of
the most accurate methods include visual classification.</p>
          <p>Normally such process is performed by a human
specialist and contains manual checking of hundreds of
objects within previously selected frames per patient.</p>
          <p>This process is extremely slow and requires full focus
of the doctor for the whole time in order to avoid
misclassification and oversight.</p>
          <p>As in the nature of such examination are high
repeatability and small amount of additional stimulus,
it is very difficult for any human being to maintain
the peak detection performance during the whole
process, especially considering some external factors
like tiredness, small amount of time, very little visual
differences between microbes or lack of special interest
in the field.</p>
          <p>Above mentioned problems lead to high average
detection error rate.</p>
          <p>More common deep learning techniques contain
rectangle masking, such as in [6] and [7], however for
this task the output needs to be more precise. Because
of that as a partial solution to this issue in this research
a custom semantic segmentation neural network
architecture has been created. It provides additional data,
in the form of a mask with initial elements classification,
to the doctor next to the original image for easy and
fast verification. Such approach can highly reduce error
rate by providing additional diagnosis and pointing
out suspicious elements, as well as speed-up the entire
diagnosis process by reducing the time needed to analyse
the image.</p>
          <p>Additionally, by choosing segmentation architecture
over the classical rectangle masking one, the
classification is made per-pixel and thus there is clarity and
accuracy improvement on images with higher amount
of overlapping objects.</p>
          <p>During the research phase the most suitable one,
containing masked images of the spirochaete
mi</p>
          <p>
            Final architecture is based on the U-Net shape and the croorganisms mixed with the red blood cells was the
final parameters were selected empirically. Final shape “Bacteria detection with darkfield microscopy” dataset
is presented in Fig. 3. The input layer has a shape of gathered and annotated as part of a bachelor thesis of
256x256 and is reduced by max-pooling by a factor of university Heilbronn, Germany. The dataset contains
(
            <xref ref-type="bibr" rid="ref1">1</xref>
            )
(
            <xref ref-type="bibr" rid="ref2">2</xref>
            )
(
            <xref ref-type="bibr" rid="ref3">3</xref>
            )
(
            <xref ref-type="bibr" rid="ref4">4</xref>
            )
(
            <xref ref-type="bibr" rid="ref5">5</xref>
            )
where  is a small, constant value and  is a learning
rate.
          </p>
        </sec>
        <sec id="sec-1-1-2">
          <title>3. Training dataset</title>
          <p>
            There were several factors needed to be taken into
consideration while searching for the dataset:
• The data have to contain microscopy imagery of
both microbes and healthy cells,
• The dataset has to be free for academical use,
• The images need to have appropriate masks.
Algorithm 1 NAdam training process
1: Generate random weights,
2: while global error value  &lt; _ do
3: Shufle the training dataset,
4: for each batch inside training dataset do
5: Compute gradient vector g on the batch,
6: Update vector  eq. (
            <xref ref-type="bibr" rid="ref1">1</xref>
            ),
7: Update vector  eq. (
            <xref ref-type="bibr" rid="ref2">2</xref>
            ),
8: Rescale vector ˆ eq. (
            <xref ref-type="bibr" rid="ref3">3</xref>
            ),
9: Rescale vector ˆ eq. (
            <xref ref-type="bibr" rid="ref4">4</xref>
            ),
10: Update variable ˆ eq. (
            <xref ref-type="bibr" rid="ref5">5</xref>
            ).
11: Step = Step + 1,
12: end for
13: Calculate global error ,
14: end while
able to update it fast enough and even when updating,
the costs needs to be small so most of the time there is
only a mediocre CPU with small amounts of RAM and
integrated GPU. Very often those computers are also
laptops.
          </p>
          <p>With that in mind some compromises has been made,
mainly on the training length side, however after the final
reduction the model consists of 7,921,534 parameters and
weights around 94MB. The evaluation times are below
0.1 second on the GPU and around 0.87 second on the
CPU per image.</p>
          <p>The training plots are presented in Fig. 1.</p>
        </sec>
        <sec id="sec-1-1-3">
          <title>5. Results visualization</title>
          <p>Although the data are high quality and each image
consists of many microbes and red blood cells, the number
of training examples is relatively small to train a highly
accurate model without the use of data augmentation.</p>
          <p>After several trials including variety of simple image
transforms, as well as state of the art methods based on
Generative Adversarial Networks (GAN), such as
Principal Component Resampling presented in [8], the best
combination in this case includes horizontal and vertical
flip, random image rotation and random zooming.</p>
          <p>The network originally outputs the data in a form of a
366 images from the darkfield microscopy with manually two dimensional matrix with sparse representation of
created masks labelling 3 abstract classes: background, classes using integer values. Such data are optimal for
spirochaete and erythrocytes. being stored and analyzed by the computer, however
presents no useful value for the non-technical user and
requires further processing to create an informative
3.1. Data augmentation image. That’s why, in order to make it readable, the
matrix has been expanded by 3 additional color channels
and integer values from the [0, 2] range has been mapped
to red, green and blue channels. Based on basic human
psychology blue has been chosen as a background,
green as harmless blood cells and red as dangerous
microbes. Such prepared mask is presented next to
the original image for fast and easy validation by the user.</p>
          <p>Other methods of visualization has been considered,
such as merging both original and mask into one image,
however the level of clarity has been highly reduced and
the validation became much more dificult as some of
the original data has been compromised.</p>
        </sec>
        <sec id="sec-1-1-4">
          <title>4. Model’s performance</title>
        </sec>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>4.1. Used hardware</title>
      <p>During this research all computations were made on a
PC with specification below:
• CPU: Ryzen Threadripper 2950X 16c/32t,
• RAM: 128GB,
• GPU: NVidia RTX 3090 24GB.</p>
      <sec id="sec-2-1">
        <title>4.2. Performance</title>
        <p>During this research one of the main goals was to
create not only an accurate model but also to reduce its
memory and power requirements to the bare minimum.
Such approach is crucial, as it helps to spread the use
of similar models in real-world applications. Although
computer hardware is becoming more powerful each
year, very little people, especially in smaller clinics are
Sample final results produced by the network can be
seen in Fig. 2.</p>
        <p>In the above examples there can be seen that, although
the network in some cases struggles to find t he exact
shape of the microbe or the red blood cell, it is still able to
perform really well in most cases, even the more extreme
ones where the image is not the highest quality, there
is high amount of overlapping elements, the contrast is
very low or the microbe is small relative to the whole
image.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>6. Conclusion</title>
      <p>This paper presents a novel solution for fast spirochaete
detection using a custom Semantic Segmentation Neural
Network. The output is presented in a clear and easy
to understand way, also allowing for quick validation if
(a) Accuracy Plot
(b) Loss Plot
needed. Although the training has been performed on
a powerful GPU, the evaluation could be also done on a
CPU from the budget level computer, making it accessible
for almost everyone. Presented solution is able to speed
up the detection time by providing additional data to
the original image, helping the human performing the
evaluation spot potential bacteria. This could not only
allow for testing more animals at the same time but also
drastically reduce the costs of such operation.</p>
      <sec id="sec-3-1">
        <title>7. Future possibilities</title>
        <p>In the future there are many paths of improvements both
in terms of functionality and accuracy performance. One
of them is expanding the current dataset with new images
captured on more diverse conditions, such as more noisy
backgrounds, diferent bacteria shapes, lower contrast
ratio between elements, etc. This approach would lead
to much higher accuracy on validation data as the
network will understand the wider context, thus the feature
extraction should work correctly on more cases than the
current model. Another way of improving the network
would be by not only adding more images to the training
set but also by expanding the number of abstract classes fit the potential new dataset some changes in the Deep
providing examples of other microbes. This would lead to Learning architecture could be necessary to further
better understanding of the world by the model but improve the accuracy.
could also reduce the misclassification rate. To better</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>E.</given-names>
            <surname>Jawetz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Melnick</surname>
          </string-name>
          , E. Adelberg, G. Brooks,
          <string-name>
            <given-names>J.</given-names>
            <surname>Butel</surname>
          </string-name>
          , L. Ornston,
          <article-title>Spirochetes and other spiral microorganisms, Medical microbiology</article-title>
          , 18th ed.
          <source>Appletion and Lange</source>
          , Norwalk, Conn (
          <year>1989</year>
          )
          <fpage>267</fpage>
          -
          <lpage>271</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>L.</given-names>
            <surname>Margulis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. B.</given-names>
            <surname>Ashen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Sole</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Guerrero</surname>
          </string-name>
          ,
          <article-title>Composite, large spirochetes from microbial mats: spirochete structure review</article-title>
          ,
          <source>Proceedings of the National Academy of Sciences</source>
          <volume>90</volume>
          (
          <year>1993</year>
          )
          <fpage>6966</fpage>
          -
          <lpage>6970</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>K. H.</given-names>
            <surname>Hougen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Birch-Andersen</surname>
          </string-name>
          ,
          <article-title>Electron microscopy of endoflagella and microtubules in treponema reiter</article-title>
          ,
          <source>Acta Pathologica Microbiologica Scandinavica Section B Microbiology and Immunology</source>
          <volume>79</volume>
          (
          <year>1971</year>
          )
          <fpage>37</fpage>
          -
          <lpage>50</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>M.</given-names>
            <surname>Madigan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Martinko</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Dunlap</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Clark</surname>
          </string-name>
          ,
          <article-title>Brock biology of microorganisms 12th edn</article-title>
          . microbiol.
          <year>2008</year>
          ;
          <volume>11</volume>
          :
          <fpage>65</fpage>
          -
          <lpage>73</lpage>
          ,
          <year>2019</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>D. C.</given-names>
            <surname>Alexander</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P. N.</given-names>
            <surname>Levett</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. Y.</given-names>
            <surname>Turenne</surname>
          </string-name>
          ,
          <article-title>Molecular taxonomy</article-title>
          , in: Molecular Medical Microbiology, Elsevier,
          <year>2015</year>
          , pp.
          <fpage>369</fpage>
          -
          <lpage>379</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>M.</given-names>
            <surname>Wieczorek</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Sika</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Wozniak</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Garg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Hassan</surname>
          </string-name>
          ,
          <article-title>Lightweight cnn model for human face detection in risk situations</article-title>
          ,
          <source>IEEE Transactions on Industrial Informatics</source>
          (
          <year>2021</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>M.</given-names>
            <surname>Woźniak</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Siłka</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Wieczorek</surname>
          </string-name>
          ,
          <article-title>Deep learning based crowd counting model for drone assisted systems</article-title>
          ,
          <source>in: Proceedings of the 4th ACM MobiCom Workshop on Drone Assisted Wireless Communications for 5G and Beyond</source>
          ,
          <year>2021</year>
          , pp.
          <fpage>31</fpage>
          -
          <lpage>36</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>O. O.</given-names>
            <surname>Abayomi-Alli</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Damaševičius</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Wieczorek</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Woźniak</surname>
          </string-name>
          ,
          <article-title>Data augmentation using principal component resampling for image recognition by deep learning</article-title>
          ,
          <source>in: International Conference on Artificial Intelligence and Soft Computing</source>
          , Springer,
          <year>2020</year>
          , pp.
          <fpage>39</fpage>
          -
          <lpage>48</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>