<!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>Architectures: Use Case for Visual Person Counting</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Tiago Veiga</string-name>
          <email>tiago.veiga@ntnu.no</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Hafiz Areeb</string-name>
          <email>hafiz.a.asad@ntnu.no</email>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Trondheim</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Norway</string-name>
        </contrib>
        <contrib contrib-type="editor">
          <string-name>AI Deployment, Container-based deployment, IoT architectures</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Information Security and Communication Technology, Norwegian University of Science and Technology</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>and Kerstin Bach</institution>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2022</year>
      </pub-date>
      <abstract>
        <p>The design and deployment of combined Internet-of-Things (IoT) and Artificial Intelligence (AI) solutions present several challenges, some of which are handled by modular logical models for the flow of data and containerized architectures that provide virtualized environments to encapsulate diferent functionalities in a network. The combinations of containers result in reusable and general solutions, even leading to visual composition solutions with recent deployment platforms. General requirements for these solutions are the capability of handling data acquisition, maintenance, and model training from zero information. This paper studies the deployment process for a use case of visual person counting from cameras located in outdoor areas. We show how a containerized solution fulfills the particular requirements for the use case, illustrating how the design of the modular architecture, data pipelines, and exposed services contribute to enhancing adaptive behavior through learning based on the context of the environment.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        This paper studies the deployment process of a use case for person counting in outdoor areas
from camera images. We describe the prerequisites that a deployment architecture must support
for this case, which include reusability, learning, and forecasting functionalities. Then, we show
our deployment solution, which follows a containerized standard and follows the guidelines for
IoT/AI cognitive architectures. This case can be tied to other field applications, such as wildlife
monitoring [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], person counting [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], or analysis of trafic density [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. Use Case: Person Counting in Outdoor Areas</title>
      <p>The application in our case study is based on person counting on outdoor areas to estimate the
busyness in the observed areas. For the estimation, images from cameras deployed at several
locations in Norway are publicly available in real time1 and are updated at a fixed interval
of 10 minutes, from which we choose a subset of locations around Trondheim. The learning
process is intended to be fully autonomous and adapted to the local and changing environment,
therefore, no data is available before deployment. From acquired data, statistics and predictions
can either be used in a closed loop to improve the behavior of constrained-resourced devices or
conveyed to external users such as people planning to go outdoors and who can use a prediction
of movement to choose better when to go, or those responsible for the maintenance of tracks
who can better plan their work.</p>
      <p>We focus on translating the logical data flow, summarized in Figure 1, to a solution that can
be deployed. For that, we identify the following requirements that the solution should fulfill
and will then describe an implementation that follows them.</p>
      <p>• R1 The solution should be reusable and flexible to changes in its components, allowing
smooth updates of the global solution and transferability to similar scenarios.
• R2 The architecture should allow learning spatial and/or temporal attention maps such
that statistics for these trends can be provided based on historical data.
• R3 The architecture should allow forecasting models to estimate future observations,
such that it can support devices by planning their resources or providing information to
external users.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Deployment Implementation</title>
      <p>This section describes how we handle each requirement with a containerized solution.
1http://metnet.no/#kart_header (accessed on 30 May 2023)</p>
      <sec id="sec-3-1">
        <title>3.1. R1: Reusability</title>
        <p>
          Implementing an architecture for this use case follows a modular, containerized-based structure
[
          <xref ref-type="bibr" rid="ref5">5</xref>
          ], that splits functionalities into diferent containers. This enhances reusability in two ways:
ifrst, it is possible to update a specific functionality without the need to change the whole
architecture; second, it is compatible with recent AI deployment platforms, allows to reuse
of publicly available containers from public catalogs, and provides a solution which can be
transferred to other similar scenarios.
        </p>
      </sec>
      <sec id="sec-3-2">
        <title>3.2. R2: Learning Attention Maps</title>
        <p>Resource-constrained IoT devices can select to drop the transmission of parts of an image as a
mean to save energy, which is especially beneficial when areas that never contain any persons
are in the field of view of a camera (e.g., in Figure 1 part of the image captures the sky). Each
device manager container implements and maintains a visual attention map that can, by request,
be sent to a device as the base for a tile selection policy.</p>
        <p>
          The server receives the transmitted tiles, reassembles them with a background image received
earlier, and then performs the object detection on these reduced tile sets. The details of the
algorithms for the computation of the attention models and the policies are explained in [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ].
        </p>
        <p>Figure 3 shows an example of a spatial attention map for a camera, represented as a heatmap.
Whenever persons are detected in a newly received image, the heatmap is increased in the
respective image slices where bounding boxes are located. Cells in the heatmap with darker
coloring correspond to areas where the detection of persons is more likely. Similar attention
maps can be made for temporal maps, showing the periods during each day with more detections.</p>
      </sec>
      <sec id="sec-3-3">
        <title>3.3. R3: Forecasting</title>
        <p>
          This architecture includes a forecast module, which implements the functionalities for the
forecasting procedure. It exposes services for initialization, model training, and prediction. At
initialization, it receives configuration data such as the number of weeks included in the training
data. Then, whenever the manager calls for model training or requests a new prediction, the
forecast module receives the current timestamp, constructs the needed datasets with calls to
the database, and updates or runs predictions, respectively, with the stored trained model.
3.3.1. Data
To evaluate the method, we collected a dataset of detections for eight cameras between December
2021 and January 2023, some of which are co-located but with non-overlapping fields of view,
using the You only look once approach (YOLO) [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ] model as the detection algorithm. The output
is filtered to store only persons detected with a confidence threshold higher than 0.5, above
the default 0.25 value used in YOLO, to reduce the number of false positives. Additionally,
meteorological data is obtained through a public API from the Norwegian Meteorological
Institute 2. Figure 4 illustrates person counts for two sample periods, during winter and summer,
along with precipitation data. These are good examples of how weather influences the presence
of people in outdoor areas, such that fewer people are counted when there is more precipitation.
2https://frost.met.no/index.html (accessed on 30 May 2023)
3.3.2. Training Procedure
The procedure for training the forecast model follows a rolling window fashion, which is visually
illustrated in Figure 5. In this procedure, the forecast model is retrained weekly (specifically, we
selected training on Sundays at midnight). At this training point, data from the previous week
is collected and used for training a model that forecasts the next 24 hours. Then, a decision
step happens daily (every midnight) in the following week, in which the trained model is used
to forecast the next day. The procedure repeats weekly with a new training step, for which
we discard old data and incorporate the observations from the past week. The output of the
training step is a selection of the best model using a randomized search on hyperparameters.
3.3.3. Results
To evaluate this approach, we compare it with real measured detections using the root mean
squared error (RMSE). Additionally, we compare those results with a baseline which, for each
hour, computes the expected detections as the average of detections at the same hour and
weekday in the past four weeks, with a summary in Table 1. Despite being a dificult forecasting
problem, due to the imbalance in the dataset towards many zero detections and the 10 minute
interval between images, the error reduces when external features are included in the model.
        </p>
        <p>Camera
jervskogen1
jervskogen2
nilsbyen2
nilsbyen3</p>
        <p>skistua
ronningen1
ronningen2
meraker1</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusions</title>
      <p>We present a deployment solution for a use case of visual person counting from cameras in
outdoor areas, combining IoT devices and AI components. The implemented solution is a
reusable containerized architecture, allowing the inclusion of more devices after deployment.
Using a manager component allows centralized management of the data flow and keeps updated
attention maps. The separation of diferent functionalities in each container allows to add
services to the system, including a service to forecast observed phenomena.</p>
      <p>This implementation can contribute to the eficient operation of resource-constrained devices.
Our use case includes energy management for devices with a limited energy budget, which can
benefit from predictions on the busyness of the observed area for a more eficient use of energy
towards periods when more persons are expected.</p>
    </sec>
    <sec id="sec-5">
      <title>Acknowledgments</title>
      <p>This work has been partly funded by the SFI NorwAI, (Centre for Research-based Innovation,
309834) and by the European Union’s Horizon 2020 research and innovation project AI4EU,
grant agreement No 825619.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>J.</given-names>
            <surname>Zhang</surname>
          </string-name>
          , D. Tao,
          <article-title>Empowering things with intelligence: A survey of the progress, challenges, and opportunities in artificial intelligence of things</article-title>
          ,
          <source>IEEE Internet of Things Journal</source>
          <volume>8</volume>
          (
          <year>2021</year>
          )
          <fpage>7789</fpage>
          -
          <lpage>7817</lpage>
          .
          <source>doi:1 0 . 1 1 0 9 / j i o t . 2</source>
          <volume>0 2 0 . 3 0 3 9 3 5 9 .</volume>
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>A.</given-names>
            <surname>Paleyes</surname>
          </string-name>
          , R.-G. Urma,
          <string-name>
            <given-names>N. D.</given-names>
            <surname>Lawrence</surname>
          </string-name>
          ,
          <article-title>Challenges in deploying machine learning: A survey of case studies, ACM Comput</article-title>
          . Surv. (
          <year>2022</year>
          ).
          <source>doi:1 0 . 1 1</source>
          <volume>4 5 / 3 5 3 3 3 7 8 .</volume>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>P.</given-names>
            <surname>Schüller</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. P.</given-names>
            <surname>Costeira</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Crowley</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Grosinger</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Ingrand</surname>
          </string-name>
          ,
          <string-name>
            <given-names>U.</given-names>
            <surname>Köckemann</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Safiotti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Welss</surname>
          </string-name>
          ,
          <article-title>Composing complex and hybrid ai solutions</article-title>
          ,
          <source>2022. doi:1 0 . 4 8</source>
          <volume>5 5</volume>
          <fpage>0</fpage>
          <string-name>
            <surname>/ A R X I</surname>
          </string-name>
          <article-title>V . 2 2 0 2 . 1 2 5 6 6</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>A. E.</given-names>
            <surname>Braten</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F. A.</given-names>
            <surname>Kraemer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Palma</surname>
          </string-name>
          ,
          <article-title>Autonomous iot device management systems: Structured review and generalized cognitive model</article-title>
          ,
          <source>IEEE Internet of Things Journal</source>
          <volume>8</volume>
          (
          <year>2021</year>
          )
          <fpage>4275</fpage>
          -
          <lpage>4290</lpage>
          .
          <source>doi:1 0 . 1 1 0 9 / J I O T . 2</source>
          <volume>0 2 0 . 3 0 3 5 3 8 9 .</volume>
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>T.</given-names>
            <surname>Veiga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H. A.</given-names>
            <surname>Asad</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F. A.</given-names>
            <surname>Kraemer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Bach</surname>
          </string-name>
          ,
          <article-title>Towards containerized, reuse-oriented ai deployment platforms for cognitive iot applications</article-title>
          ,
          <source>Future Generation Computer Systems</source>
          <volume>142</volume>
          (
          <year>2023</year>
          )
          <fpage>4</fpage>
          -
          <lpage>13</lpage>
          . doi:h t t p s : / / d o i .
          <source>o r g / 1 0 . 1 0</source>
          <volume>1 6</volume>
          / j . f u t u r e .
          <source>2 0 2 2 . 1 2 . 0 2 9 .</source>
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>A. R.</given-names>
            <surname>Elias</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Golubovic</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Krintz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Wolski</surname>
          </string-name>
          ,
          <article-title>Where's the bear? automating wildlife image processing using iot and edge cloud systems</article-title>
          ,
          <source>in: Proceedings of the Second International Conference on Internet-of-Things Design and Implementation</source>
          , IoTDI '17,
          <string-name>
            <surname>Association</surname>
          </string-name>
          for Computing Machinery, New York, NY, USA,
          <year>2017</year>
          , p.
          <fpage>247</fpage>
          -
          <lpage>258</lpage>
          .
          <source>doi:1 0 . 1 1</source>
          <volume>4 5 / 3 0 5 4 9 7 7 . 3 0 5 4 9 8 6 .</volume>
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>A. B.</given-names>
            <surname>Chan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.-S. J.</given-names>
            <surname>Liang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Vasconcelos</surname>
          </string-name>
          ,
          <article-title>Privacy preserving crowd monitoring: Counting people without people models or tracking</article-title>
          ,
          <source>in: 2008 IEEE Conference on Computer Vision and Pattern Recognition</source>
          ,
          <year>2008</year>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>7</lpage>
          .
          <source>doi:1 0 . 1 1</source>
          0 9 / C V P R .
          <volume>2 0 0 8 . 4 5 8 7 5 6 9 .</volume>
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>L.</given-names>
            <surname>Ciampi</surname>
          </string-name>
          .,
          <string-name>
            <given-names>C.</given-names>
            <surname>Santiago</surname>
          </string-name>
          .,
          <string-name>
            <given-names>J. P.</given-names>
            <surname>Costeira.</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Gennaro</surname>
          </string-name>
          .,
          <string-name>
            <surname>G. Amato.</surname>
          </string-name>
          ,
          <article-title>Domain adaptation for trafic density estimation</article-title>
          ,
          <source>in: Proceedings of the 16th International Joint Conference on Computer Vision</source>
          , Imaging and Computer Graphics Theory and Applications - Volume
          <volume>5</volume>
          : VISAPP„ INSTICC, SciTePress,
          <year>2021</year>
          , pp.
          <fpage>185</fpage>
          -
          <lpage>195</lpage>
          .
          <source>doi:1 0 . 5 2</source>
          <volume>2 0 / 0 0 1 0 3 0 3 4 0 1 8 5 0 1 9 5 .</volume>
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>H. A.</given-names>
            <surname>Asad</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F. A.</given-names>
            <surname>Kraemer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Bach</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Renner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T. S.</given-names>
            <surname>Veiga</surname>
          </string-name>
          ,
          <article-title>Learning attention models for resource-constrained, self-adaptive visual sensing applications</article-title>
          ,
          <source>in: Proceedings of the Conference on Research in Adaptive and Convergent Systems</source>
          , RACS '22,
          <string-name>
            <surname>Association</surname>
          </string-name>
          for Computing Machinery, New York, NY, USA,
          <year>2022</year>
          , p.
          <fpage>165</fpage>
          -
          <lpage>171</lpage>
          .
          <source>doi:1 0 . 1 1</source>
          <volume>4 5 / 3 5 3 8 6 4 1 . 3 5 6 1 5 0 5 .</volume>
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>G.</given-names>
            <surname>Jocher</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Chaurasia</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Stoken</surname>
          </string-name>
          , J. Borovec, NanoCode012, Y. Kwon, TaoXie, J. Fang, imyhxy, K. Michael,
          <string-name>
            <surname>Lorna</surname>
          </string-name>
          , A. V,
          <string-name>
            <surname>D. Montes</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          <string-name>
            <surname>Nadar</surname>
            , Laughing, tkianai, yxNONG,
            <given-names>P.</given-names>
          </string-name>
          <string-name>
            <surname>Skalski</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          <string-name>
            <surname>Wang</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Hogan</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <string-name>
            <surname>Fati</surname>
            , L. Mammana, AlexWang1900,
            <given-names>D.</given-names>
          </string-name>
          <string-name>
            <surname>Patel</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          <string-name>
            <surname>Yiwei</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          <string-name>
            <surname>You</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          <string-name>
            <surname>Hajek</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          <string-name>
            <surname>Diaconu</surname>
          </string-name>
          , M. T. Minh, ultralytics/yolov5:
          <fpage>v6</fpage>
          .
          <fpage>1</fpage>
          - TensorRT,
          <source>TensorFlow Edge TPU and OpenVINO Export and Inference</source>
          ,
          <source>2022. doi:1 0 . 5 2 8 1 / z e n o d o . 6 2</source>
          <volume>2 2 9 3 6 .</volume>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>