# Lightweight Domestic Pig Behavior Detection Based on YOLOv8
## 3 Principles of Algorithms
### YOLOv8-PigLite
#### 3.2.2 GSConvSE Convolution Module  
The convolutional layer represents the principal source of computational and parametric requirements in the YOLOv8n model, while the convolutional operations in the YOLOv8n convolutional module utilize Standard Convolution, leading to excessive full-channel interactions on devices with constrained memory. The pig behavior dataset includes complex and varied surroundings, as well as a range of activities, such as crawling (one pig resting its forelimbs on another) and sleeping (lying on its side or stomach), which are clearly differentiated and easily recognizable. Specific actions, like walking and exploring, are shown by the pigs standing up, and they differ because the legs move when walking, while the head is used for sniffing when exploring; these details need careful observation of features, and understanding the overall context is important for telling different behaviors apart. The dataset's properties require that the model possess efficient computational abilities and robust feature extraction capabilities. Motivated by the MobileNet [22] and ShuffleNet [23] architectures, this paper presents a novel convolution module, GSConvSE, which diminishes the parameter count and computational load through Group Convolution. Simultaneously, it employs the SE mechanism to integrate global contextual information, addressing the inadequacy of information interaction among the Grouped Convolution units. Figure 4 illustrates its structure.  
Figure 3: The principle of Standard Convolution and DWConv. (**a**) Standard Convolution. (**b**) DWConv.  
Group Convolution employs the split-transform-merge paradigm [24], seen in Figure 5, which partitions the input into several groups, restricts information interchange across distinct groups, and ultimately amalgamates them, therefore diminishing the parameter count and computing burden. The computational and parameter quantities for a conventional convolution, when processing a feature map of dimensions H \(\times\) W \(\times\) C_in, are delineated in Equation (1). Grouped Convolution partitions the input channels into G groups, wherein the channels in each group convolve exclusively with the convolution kernels of that group, resulting in the associated output channels. Each segment of the input feature map comprises C_in/G channels, while the output feature map consists of C_out/G channels. The total number of groups of convolutional kernels is G; so, following the execution of Grouped Convolution, the parameters P3 and computing cost C3 may be determined using Equation (3). The formula indicates that the computational and parameter quantities of Grouped Convolution are only 1/G of those of conventional convolution.  
Grouped Convolution can significantly reduce the computation and number of parameters, but the lack of direct interaction between groups leads to a lack of global contextual information. The SE mechanism [25] compensates for the lack of inter-channel information interaction by introducing a global channel-dependent perspective to the output of the Grouped Convolution module through global average pooling (Squeeze) and channel weight learning (Excitation). At the same time, the computational overhead of SE is extremely low, much smaller than that of the fully connected layer, which is suitable for lightweight design.