# IoT OS Platform: Software Infrastructure for Next-Gen Industrial IoT
## 4 Implementation Case Study
### Implementation
#### 4.2.3 Algorithm Management  
In the requirements, it is clearly stated that there is a need for dynamic loading and unloading of algorithms, which coincides with our view on the industrial Internet of Things mentioned earlier. Therefore, we have designed a management function for the algorithm in the system according to the five stages of the algorithm lifecycle mentioned earlier:  
Development:In this case, since almost all requirements are object detection, we choose PyTorch and YOLO [53] framework to develop the algorithms. Operation:We have developed a user interface that offers interactive capabilities, allowing users to visually upload and modify algorithms and configure related settings, such as detection thresholds and areas, as shown in Figures 14 and 15. Verification and Maintenance:Using the user interface mentioned above, we can deploy any algorithm dynamically and easily. Also, we use container to provide running environment, omitting the process of environment configuration. With these two methods, it is possible to achieve algorithm iteration and upgrades. Analysis:We have developed a false positive management system, which facilitates the manual labeling of misclassified images. This feature aids in the collection of false positive data, enabling the refinement of algorithms that are currently in deployment. In addition, during the construction process, we often encounter various algorithm recognition requirements with unique business characteristics, such as unsafe behaviors such as smoking and not wearing helmets in monitoring scenarios. In such special needs, using naive object detection algorithms can easily lead to frequent recognition errors. Taking smoking behavior as an example, detecting only cigarette can easily generate false positives as shown in Figure 16. \begin{table}
\begin{tabular}{l l l l l} \hline \hline
**Algorithm Name** & **Inference Cost (ms)** & **Transmission Cost (ms)** & **Total Cost (ms)** & **Transmission Cost Percentage (\%)** \\ \hline Working at Heights & 97.35 & 74.23 & 171.58 & 43.26 \\ \hline Hot Work & 98.57 & 70.75 & 169.50 & 41.74 \\ \hline Lifting Operations & 98.05 & 72.15 & 170.20 & 42.39 \\ \hline Loitering Detection & 65.53 & 73.43 & 138.96 & 52.84 \\ \hline Fatigue Work & 36.68 & 77.21 & 113.89 & 67.79 \\ \hline Personnel Fall & 121.04 & 84.00 & 205.04 & 40.97 \\ \hline Wearing of Safe Helmet & 71.79 & 72.45 & 144.24 & 50.23 \\ \hline Wearing Long Sleeves & 97.08 & 78.22 & 175.30 & 44.62 \\ \hline Using Mobile Phones & 67.19 & 80.82 & 148.01 & 54.60 \\ \hline Smoking Detection & 96.69 & 80.92 & 177.61 & 45.56 \\ \hline Sleeping on Duty & 35.86 & 76.81 & 112.67 & 68.17 \\ \hline Cross Border Invasion & 70.97 & 75.36 & 141.33 & 49.78 \\ \hline Facial Attendance & 106.83 & 72.36 & 179.19 & 40.38 \\ \hline Personnel Flow Count & 70.15 & 70.64 & 140.79 & 50.17 \\ \hline Flames Identification & 66.90 & 70.85 & 137.75 & 51.43 \\ \hline \hline \end{tabular}
\end{table} 
Table 8: Time cost of system. Figure 14: Algorithm management function. It enables the integration of various algorithms within the platform, significantly simplifying the management costs associated with multiple algorithms. Figure 15: Algorithm settings. We have extracted the common key configurations of the algorithms. Through these configurations, it is possible to dynamically adjust various parameters of the algorithms, based on their requirements in different scenarios. To address this issue, we leveraged the design advantages of IoT OS Platform by sending single-frame data to multiple algorithm execution entities for parallel processing, and then summarized the results. Taking smoking behavior as an example, we sent the same frame image to two algorithm execution bodies for personnel detection and cigarette detection, and then took the intersection of the recognition of the head and the recognition of cigarettes in the results. The process is shown in Figure 17. By adopting this approach, we reduced the false alarm rate by more than half. Figure 16: False positive of smoking.