# FlockAI: A Testing Suite for ML-Driven Drone Applications
## 4 Modeling and Implementation
### Drone Configuration
Table 2 presents a high-level overview of the experiment scenarios that will be run so that users may reproduce these scenarios by following the steps introduced by the flowchart in Figure 3. In brief, Scenario 1 examines the overhead of running an ML algorithm for crowd detection (sc. 1-B) vs. the same drone flying without an ML task configured (sc. 1-A). Scenario 2 examines the trade-off between performing in place (sc. 1-B) and remote ML inference (sc. 2), while Scenario 3 examines the overhead of performing in place inference for crowd detection when adopting two different ML algorithms (sc 3-A, 3-B). We clarify that the scope of this article is not on proposing a new and novel crowd detection algorithm nor on the parameterization of the algorithm (i.e., optimal safety distances). Rather, our goal is to showcase the ability of FlockAI to answer the four questions, introduced in Section 2, that are faced by ML practitioners when in need of testing their ML solutions. These questions will be answered by under-going three experiment scenarios and evaluating different performance measures collected by FlockAI during the experimentation so that one can truly understand the key advantages and pains of his/her designed solution. The experiment scenarios utilize the FlockAI blueprint for the DJI Mavic 2 Pro drone (truncated version shown in Listing 1). In turn, the experim

Figure 4: Example application of ML algorithm pinpointing potential crowded areas. the one showcased in Listing 2 and all are openly available in the FlockAI project github repository for reproducability purposes. ### Scenario 1: On-Board Inference

In this experiment scenario, just like in the one presented in Listing 2, the ML practitioner would like to evaluate the impact of his/her algorithm to the underlying drone resources. Hence, the ML algorithm is deployed on the drone and run during the flight. This means that when the camera captures a new image feed, this is passed to the _on-board_ inference algorithm for human detection and counting. We note that the ML algorithm used in this experiment is implemented in Python and adopts a pre-trained Convolutional Neural Network (CNN) developed on top of the C++ dlib engine and capable of identifying human faces even when given images with a moving viewpoint (e.g., drone camera feed) [30]. For testing data we use the open DroneFaces dataset which contains 20 camera sequences capturing 30 images each with the drone flying above humans in an urban environment [31]. Although the algorithm accuracy is not of interest in this experiment, for thoroughness, we note that it is 95%. Accuracy will be further investigated in Scenario 3. Moreover, only when a potential crowded region is detected by the on-board ML algorithm is the ground station notified so that operators can verify and take further action (i.e., send SMS for social distancing). In this case, the data payload exchanged between the drone and ground station includes the camera feed annotated with the crowded region(s) and drone positioning data. As a baseline for comparison purposes, we will consider the drone performing the same flight but without the deployment of the ML algorithm. Figure 5 depicts the energy consumption of the drone when undertaking the experiment flight without performing the ML task, while Figure 6 depicts the drones energy consumption with the ML task enabled. In these figures, the energy consumption is decomposed by FlockAI into the energy consumed by the motors, processing, and communication components of the drone. From both of these figures, we immediately observe that \(E_{motors}\) is the dominating energy consuming factor. In fact, without the ML task \(E_{motors}\) attributes to approximately 91% of the total energy. From the other two components, the majority of the processing overhead comes from the autopilot, while the modest communication overhead (3%) includes the health checks exchanged between the drone and the ground station.