# Packaging Design Image Segmentation Based on Improved Full Convolutional Networks
## 3 Methods and Materials
### Model Lightweight Design Based on Edge Knowledge Distillation  
Finally, this paper proposes a model lightweight design method based on edge knowledge distillation to address the problem of excessive model parameters that make it difficult to meet practical application scenarios during deployment. The objective is to minimize the number of model parameters while ensuring the maintenance of accurate segmentation. The specific process of the lightweight design method is shown in Figure 6.  
Figure 5: Structure Diagram of Decoding Network.  
In Figure 6, the lightweight design method includes three key components. Firstly, adaptive multi-scale feature fusion module adjusts the fusion strategy of different hierarchical features adaptively. Secondly, this study integrates spatial and CA mechanisms to improve the attention model. Finally, there is the edge knowledge distillation module. The adaptive multi-scale feature fusion module first uses 3 \(\times\) 3 convolution to refine the output features during the processing and adjusts the number of channels through 1 \(\times\) 1 convolution to generate predicted segmentation results. Subsequently, the target boundary matrix and target subject matrix are calculated to facilitate discriminative weighting of features. In each stage feature, this paper uses an adaptive weighting strategy to fuse multi-level semantic information. Finally, this paper utilizes bilinear interpolation for upsampling to restore the feature map to its original input size, resulting in accurate pixel by pixel classification results. The existence of an adaptive multi-scale feature fusion module not only enhances the semantic expression ability of features but also preserves important spatial details, greatly improving the accuracy of ISS [27, 28].  
This paper decomposes spatial self-attention into independent column attention and row attention to avoid information loss during feature compression. In the calculation process, this paper utilizes 1 \(\times\) 1 convolution and Rectified Linear Unit (ReLU) to encode the similarity relationship between columns and rows, respectively, and generate attention weights. Subsequently, these weights are further fused through a fully connected layer to form a comprehensive SA matrix, which enhances key information in the feature map and suppresses unimportant regions. Its advantage lies in its ability to capture global contextual information without adding additional computational burden and to enhance the expressive power of features through adaptive weighting. Figure 7 illustrates the structure of the edge knowledge distillation module.  
Figure 6: Specific flow of lightweight Design Method.  
In Figure 7, the edge knowledge distillation enhances the edge segmentation ability of the student network. Firstly, this paper uses class probability matrices to identify and distinguish boundary points in teacher and student networks and then searches for the nearest candidate boundary point for each boundary pixel in the student network within its neighborhood. The candidate points are converted into one hot vector for easy use in the loss function [29]. In the process of knowledge distillation, this study designed an edge loss function to calculate the loss with the difference between the predicted results of the student network and the candidate boundary points. Simultaneously, it uses weighted cross entropy loss to increase the difference between the target pixel and its candidate boundary pixels and reduce the difference with non-candidate boundary pixels. Therefore, the edge information knowledge distillation module can control the updating of edge pixels through weight functions to ensure the light weight and efficiency of the model.