# EmbeddedPigDet--Fast and Accurate Pig Detection for Embedded Board Implementations
## 3 Proposed Method  
In this study, we selected TinyYOLO [58] as our base model and improved both of its execution speed and accuracy. As explained in Section 2, TinyYOLO is a tiny version of YOLO [58] which is a widely used single-shot object detector. Although TinyYOLO is targeted for embedded board implementations, its computational workload cannot satisfy the execution speed requirement for our target embedded board such as Jetson Nano [50]. Furthermore, it is well known that reducing the computational workload of tiny networks without degrading accuracy is much more difficult than that of larger networks [55].  
In order to reduce the computational workload of TinyYOLO, we first apply the filter clustering for each \(3\times 3\) convolutional layer of TinyYOLO and group them into a cluster having the maximum convolution value. In fact, the proposed filter clustering (FC) algorithm is a kind of filter pruning techniques [65] widely used for compressing deep networks. Unlike previous filter pruning techniques [65; 66; 67; 68; 69; 70; 71], however, the proposed FC algorithm can determine a pruning rate for each \(3\times 3\) convolutional layer separately and systematically. Then, we apply the bottleneck structuring (BS) algorithm to the result of the FC algorithm to obtain EmbeddedPigYOLO (i.e., light-weight version of TinyYOLO). For example, we apply the bottleneck structure [72] by replacing each \(3\times 3\times i\) convolutional filter with \(1\times 1\times i\)/\(4\), \(3\times 3\times i\)/\(4\) and \(1\times 1\times i\) convolutional filters, in order to reduce the computational workload of each \(3\times 3\times i\) convolutional filter further.  
After reducing the computational workload of TinyYOLO, we need to improve the accuracy of EmbeddedPigYOLO. Our idea is to use the otherwise-idle CPU to allow EmbeddedPigYOLO to focus on individual pigs with the image preprocessing (IP) module. That is, in order to recover the accuracy of EmbeddedPigYOLO which is executed on GPU, we use CPU to generate a three-channel composite image as an input image for EmbeddedPigYOLO. In this study, the composite image is generated for focusing on the possible pig regions in a pig room. That is, the three-channel composite image can give complementary information to EmbeddedPigDet (i.e., IP + EmbeddedPigYOLO) and thus let  
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Target** & **Data Size** & **No. of Pigs** & **Detection** & **Individual** & **Execution Time** & **Reference** \\
**Platform** & **Data Size** & **in a Pen** & **Technique** & **Detection of Pigs** & **(ms)** & **Reference** \\ \hline
1760 \(\times\) 1840 & Not Specified & Image Processing & Yes & Not Specified & [24] \\
1280 \(\times\) 720 & 23 & Image Processing & Yes & 971 (PC) & [25] \\ Not Specified & 2-12 & Image Processing & Yes & Not Specified & [26] \\
320 \(\times\) 240 & Not Specified & Image Processing & No & Not Specified & [27] \\
512 \(\times\) 424 & Not Specified & Image Processing & No & Not Specified & [28] \\  
EmbeddedPigDet focus on individual pigs. Note that the computing power of an embedded CPU in a Nano is lower than that of a CPU in a typical PC. Based on our previous studies, we carefully evaluate each image preprocessing step, in order to understand the execution speed-accuracy tradeoff in the IP module.  
Figure 2 shows the whole process of detecting individual pigs in embedded board environments. Note that the FC and BS algorithms are executed once during the training phase in order to determine the number of convolutional filters in EmbeddedPigYOLO and thus the IP module and EmbeddedPigYOLO are executed during the test phase.