## 3 Proposed Method
### Interactive Fuzzy Search Data Augmentation Algorithm  
The lack of a universal dataset for industrial product packaging bag defect samples in the industrial sector poses a significant challenge. Creating a custom dataset is a crucial step in applying object detection models for defect detection in industrial product packaging bags. However, in practical industrial scenarios, the overwhelming majority of samples on the assembly line are normal, while defect samples are extremely rare. This results in a long-tailed distribution of data, which is highly unfavorable for model training and optimization. To address these issues, this paper introduces an interactive defect fuzzy search algorithm that generates a large quantity of high-quality simulated defect data. This approach effectively addresses the problem of insufficient defect detection capabilities due to the scarcity of defect samples.  
The experimental dataset consists of real-world sample data collected from actual industrial assembly systems. Based on this, a significant amount of the simulated defect dataset is generated offline. According to Equations (1)-(3), the following steps are taken to obtain a batch of simulated defect data: Initially, we identify a point center proximate to the defect's centroid on the labeled sample and establish a 3 \(\times\) 3 pixel search neighborhood \(U(i,j)\) centered on this point.  
Modeled as follows:  
\[U(i,j)=\{(x,y)|x_{c}-1\leq x\leq x_{c}+1,y_{c}-1\leq y\leq y_{c}+1\} \tag{1}\]  
\(U(i,j)\) is the pixel search neighborhood, \((x,y)\) is the point where the marked sample is close to the center of the defect.  
Subsequently, we assess the similarity S of each point \(X(i,j)\) within \(U(i,j)\) by analyzing the grayscale values and documenting the corresponding positional coordinates. This enables the identification of image regions exhibiting black spots and aluminum foil damage on the industrial products' packaging bags, as outlined in Equation (2).  
Modeled as follows:\[S(i,j)=\frac{1}{N}\sum_{k,l\in U(i,j)}\left|G(k,l)-G_{avg}\right| \tag{2}\]  
\(S(i,j)\) is the similarity of each point calculated from the gray value of each pixel, and \(G(k,l)\) is the gray value of a single pixel in the neighborhood. \(G_{avg}\) is the average gray value of its neighborhood, and \(N\) is the number of pixels in the neighborhood \(U(i,j)\). This process can eliminate the influence of neighborhood size and make similarity measures comparable.  
Finally, we extract the pertinent defective subimage regions from the original image and manipulate them through operations such as flipping and scaling. These manipulated defective sub-images are then seamlessly integrated into random locations on normal samples, generating a substantial quantity of defective samples for industrial product packaging bags, as specified in Equation (3).  
Modeled as follows:  
\[F(x,y)=\alpha\cdot D(x,y)+(1-\alpha)\cdot N(x,y) \tag{3}\]  
\(F(x,y)\) is the pixel value at the corresponding coordinates of the final generated industrial product packaging bag sample containing defects, \(D(x,y)\) is the pixel value of the original defect sub-image at the corresponding coordinates, \(N(x,y)\) is the pixel value of the normal sample at the corresponding coordinates, and \(\alpha\) is a mixing coefficient between 0 and 1, used to control the relative contributions of the original defect sub-image \(D(x,y)\) and the normal sample \(N(x,y)\) when generating a new sample \(F(x,y)\), as illustrated in Figure 1. If industrial product packaging encounters different color varieties during production, the grayscale image collection and detection method shown in Figure 1 can be generalized to adapt to various types of varieties.