A textile defect detection method and system based on multi-light source dynamic fusion and double-branch network
Patent Information
- Application Number
- CN202610815960.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-08
- Publication Date
- 2026-08-28
AI Technical Summary
[0007]为了解决现有技术中存在的计算量大导致实时性差、单一光源导致微小疵点漏检率高,以及直接降采样导致特征丢失的技术问题,本发明提供了一种基于多光源动态融合与双分支网络的纺织品疵点检测方法及系统
1.彻底解决了微小疵点特征极易丢失的痛点:通过双分支架构“先粗定位、后精分类”的设计,第一分支利用轻量化网络在不降采样的高分辨率图像上高速滑动寻找异常区域,第二分支仅针对裁剪出的候选斑块(如256×256)进行深度卷积。不仅避免了GPU显存溢出,且完美保留了单根断纱等微小级别的原始像素特征。
Smart Images

Figure CN122657066A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of machine vision inspection and artificial intelligence technology, and more specifically to a method and system for detecting defects in textiles based on multi-source dynamic fusion and a dual-branch network. Background Technology
[0002] During the textile production process, various defects such as holes, broken yarns, misaligned wefts, oil stains, and fly waste inevitably occur on the fabric surface due to mechanical failures, raw material defects, or process fluctuations. Traditional defect detection mainly relies on manual visual inspection, which suffers from high labor intensity, low detection efficiency, and susceptibility to missed defects due to subjective fatigue. It can no longer meet the high-speed and high-quality production demands of the modern textile industry.
[0003] In recent years, automated optical inspection (AOI) technology based on machine vision has been introduced into the field of textile inspection. Existing inspection methods are mainly divided into traditional image processing methods and deep learning-based methods. Traditional methods (such as frequency domain filtering, Gabor transform, gray-level co-occurrence matrix, etc.) are often highly dependent on the periodic texture of textiles. When the type of fabric changes or the texture becomes complex, the algorithm has extremely poor robustness and a high false alarm rate.
[0004] However, existing deep learning object detection models (such as the YOLO series, Faster R-CNN, etc.) face the following serious technical bottlenecks when directly applied to textile detection: First, there's the contradiction between memory overload and the loss of minute features. Industrial field line scan cameras capture images with extremely high resolution (typically 8192 or 16384 pixels wide). If the original image is directly input, the GPU memory of edge computing devices cannot handle it; if the original image is downsampled (resized) to a common network input size (e.g., 640×640), features such as "a single broken yarn" and "minor defects" (which occupy only a few pixels in the original image) will be completely lost, leading to an extremely high false negative rate.
[0005] Second, the limitations of single optical imaging. Textile defects exhibit complex diversity. For example, oil stains are easily identifiable under coaxial light but are almost invisible under backlight; while holes and sparse weaves are very clear under backlight but are easily confused with normal textures under coaxial light. Most existing technologies use a single light source or fixed brightness, which cannot cover all types of defects.
[0006] Third, the real-time challenge in industrial settings. Modern textile machines typically operate at speeds exceeding 50 meters per minute, requiring detection systems to process massive amounts of pixels within tens of milliseconds. The large number of parameters in traditional complex deep neural networks makes it difficult to meet such stringent real-time requirements. Summary of the Invention
[0007] To address the technical problems in existing technologies, such as high computational load leading to poor real-time performance, high missed detection rate of minute defects due to single light source, and feature loss due to direct downsampling, this invention provides a textile defect detection method and system based on multi-light source dynamic fusion and dual-branch network.
[0008] To achieve the above objectives, the present invention provides the following technical solution: A method for detecting textile defects based on multi-source dynamic fusion and a dual-branch network includes the following steps: S1. Acquire multi-view synchronous images of the textile surface: The encoder triggers the linear array camera to synchronously acquire multi-view images of the moving textile under coaxial light source, low-angle light source and backlight. S2. Dynamic fusion of multi-source images: Extract the texture feature gradient of the multi-view images, calculate the dynamic weight of each view image based on local contrast, and fuse the multi-view images according to the dynamic weight to generate an enhanced background suppression image. S3. Rapid extraction of candidate defect regions: The enhanced background suppression image is input into the first branch lightweight localization network, and the periodic features of normal texture are suppressed through the spatial attention mechanism to quickly output the coordinate information of candidate defect regions. S4. Fine classification and evaluation of defects: Based on the coordinate information of the candidate defect region, local image patches are cropped from the enhanced background suppression image and input into the second branch fine classification network to output the defect type and confidence level. S5. Output and linkage of detection results: Generate a defect location distribution map based on the defect type and confidence level, and output control signals to the rejection or marking execution mechanism.
[0009] As a preferred embodiment of the present invention: the method for calculating the dynamic weight in step S2 is as follows: calculate the variance of the image of each viewpoint within the local sliding window and use it as a local contrast index; for the same physical location, compare the local contrast of the images of coaxial light source, low-angle light source and backlight, assign the highest weight to the image with the highest local contrast, assign the lower weight to the other images according to the contrast ratio, perform pixel-level weighted summation to obtain the enhanced background suppression image.
[0010] As a preferred embodiment of the present invention, the specific calculation model for dynamic weights and pixel-level weighted summation is as follows: the size of the local sliding window is set to M×M. For a pixel (xⓜ,y), the local variance V_k(x,y) of the k-th light source view image within the window is calculated. The dynamic weights W_k(x,y) for each view are generated using the Softmax function, with the formula: W_k(x,y)=exp(V_k(x,y) / T) / ∑exp(V_i(x,y) / T), where T is a temperature coefficient used to adjust the smoothness of the weight distribution. Finally, the value of the pixel in the enhanced background suppression image is I_out(x,y)=∑[W_k(x,y)×I_k(x,y)], where I_k(x,y) is the original pixel value of the k-th view image.
[0011] As a preferred embodiment of the present invention: the first branch lightweight localization network in step S3 includes continuous depth separable convolutional layers and a spatial attention module. The spatial attention module generates a two-dimensional spatial weight map by calculating the maximum pooling and average pooling of the feature map in the channel dimension, which is used to enhance the abnormal defect features and weaken the periodic normal warp and weft yarn texture features.
[0012] As a preferred embodiment of the present invention: the spatial attention module is a spatial and channel joint attention mechanism (CBAM), which works as follows: max pooling and average pooling are performed along the channel dimension respectively, and after concatenation, a spatial attention weight map is generated through a convolutional layer and a sigmoid activation function. The weight response of periodic texture features is adaptively reduced, and the weight of defect regions that disrupt the periodicity is increased. The first branch lightweight localization network only outputs the coordinates of candidate defect regions with confidence greater than a preset threshold, and does not perform defect classification calculation.
[0013] As a preferred embodiment of the present invention: the second branch fine classification network in step S4 is a residual neural network, which receives the local image patches after size normalization processing, and outputs the defect categories through a fully connected layer. The defect categories include at least: holes, broken yarns, oil stains, fly waste, and misaligned weft.
[0014] In a preferred embodiment of the present invention: the second branch fine-classification network includes an offline training phase, the offline training phase comprising: Construct a training dataset containing normal fabric patches and various defect patches; Focal Loss is used as the classification loss function to address the problem of extreme imbalance between the number of normal samples and defective samples during training. The calculation formula of the classification loss function introduces a dynamic scaling factor to reduce the weight of easily classified normal samples, so that the network training focuses on the difficult-to-classify small defective samples.
[0015] Among them: a textile defect detection system based on multi-source dynamic fusion and dual-branch network, used to implement the method described above, the system comprising: Image acquisition module: including at least one line scan industrial camera, as well as synchronously controlled coaxial light source, low-angle light source and backlight, for acquiring multi-view images of textiles; Encoder trigger module: connected to the image acquisition module, used to output pulse signals according to the transmission speed of the textile to control the line frequency of the camera and the strobe of the light source; Edge computing processing module: It has built-in multi-source image dynamic fusion algorithm, first branch lightweight localization network and second branch fine classification network, which are used to process images and output defect information; Execution and Alarm Module: Based on the defect information output by the edge computing processing module, execute an audible and visual alarm or perform physical marking on the edge of the textile.
[0016] As a preferred embodiment of the present invention, the specific layout of the multi-view light source is as follows: The coaxial light source illuminates the textile surface perpendicularly; The angle between the optical axis of the low-angle light source and the surface of the textile is set to 10° to 20° to highlight three-dimensional foreign objects and flying flowers on the surface of the textile. The backlight is positioned below the light-transmitting conveyor belt, opposite to the coaxial light source, and is used to penetrate the fabric to highlight broken yarns and holes.
[0017] Specifically, it also includes: a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the methods described above.
[0018] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. Completely solves the pain point of easily losing minute defect features: Through a dual-branch architecture design of "coarse localization followed by fine classification," the first branch uses a lightweight network to quickly slide across high-resolution images without downsampling to find abnormal regions, while the second branch performs depth convolution only on the cropped candidate patches (e.g., 256×256). This not only avoids GPU memory overflow but also perfectly preserves minute-level original pixel features such as a single broken thread.
[0019] 2. Multi-light source fusion enables high-sensitivity detection of all types of defects: An adaptive dynamic weight calculation model is introduced to perform pixel-level reconstruction for defects with different optical sensitivity characteristics (such as backlit see-through holes and three-dimensional foreign objects that are highlighted at low angles), actively suppressing interference from normal warp and weft yarn textures, and significantly improving the image signal-to-noise ratio from the physical imaging level.
[0020] 3. Effectively overcomes model bias caused by long-tailed data distribution: The Focal Loss function is introduced into the model training to solve the imbalance problem of massive normal fabric data and very few defect data in industrial field, so that the model can focus on gradient updates for "difficult-to-distinguish minor defects".
[0021] 4. Meets stringent industrial real-time online detection requirements: The first branch network adopts depthwise separable convolution and abandons time-consuming classification calculations. With the pulse synchronization triggering of hardware and software, the processing time of a single frame (8192 pixels wide) of the entire system is controlled in the millisecond level, easily adapting to high-speed non-woven / woven fabric production lines with speeds up to hundreds of meters per minute. Attached Figure Description
[0022] Figure 1 This is a flowchart illustrating a textile defect detection method based on multi-source fusion and dual-branch network provided in an embodiment of the present invention. Figure 2 This is a schematic diagram of the physical layout and architecture of a detection system provided in an embodiment of the present invention. Detailed Implementation
[0023] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0024] Example 1: Operation flow of the method in an industrial production line like Figure 1 and Figure 2 As shown, a textile defect detection method based on multi-source dynamic fusion and dual-branch network is specifically implemented on a production line with a speed of 80 meters per minute.
[0025] Step S1 (Image Acquisition and Triggering): Multi-view light sources are installed above and below the inspection station on the loom. An incremental photoelectric encoder is installed on the conveyor roller. When the textile moves forward by 0.1mm, the encoder sends a trigger pulse to the camera and strobe controller. The line scan camera (resolution set to 8192 pixels) exposes separately in microseconds to acquire three lines of image data under different light sources. Due to the strict synchronization of the encoder, the images are stitched together to form a coaxial image (I_1), a low-angle image (I_2), and a backlit image (I_3) corresponding to the same physical position. Step S2 (Dynamic Image Fusion): After receiving the image, the edge computing host starts the dynamic fusion algorithm. The system uses an 11×11 sliding window to traverse the image and calculates the local variance V_k (x,y) in the neighborhood of each pixel. To avoid weight abrupt changes caused by noise, this embodiment introduces a Softmax mechanism with a temperature coefficient to calculate the weight W_k: W_k (x,y)=e^(V_k (x,y) / T) / (e^(V_1 (x,y) / T)+e^(V_2 (x,y) / T)+e^(V_3 (x,y) / T) ) The temperature coefficient T is set to 0.5. When a "hole" exists, the light transmittance of the backlight image I_3 increases dramatically, and its local variance V_3 is much greater than V_1 and V_2. Calculations show that the weight W_3 of the backlight image at this location dynamically approaches or exceeds 0.9. Finally, using the pixel-level fusion formula I_out=W_1 I_1+W_2 I_2+W_3 I_3, a two-dimensional image matrix is output, where the background is greatly suppressed and all abnormal shapes are optically enhanced.
[0026] Step S3 (Candidate Region Extraction): To achieve millisecond-level processing on an 8192-pixel wide image, the system avoids directly processing the original image using a massive deep network. The enhanced background suppression image is input into the first branch localization network. This network backbone employs depthwise separable convolution, followed by a specially designed CBAM (Convolutional Block Attention Module) joint attention mechanism. First, max pooling and average pooling are performed along the channel dimension, concatenated, and then passed through a 7×7 convolutional layer and a sigmoid activation function to generate a two-dimensional spatial attention weight map. Under training with a large number of normal samples, the network adaptively reduces the weight response of periodic latitude and longitude textures, while giving high weights to abnormal defect regions. The network rapidly outputs the bounding box coordinates of candidate defect regions with a confidence level greater than 0.7. At this point, over 99% of the normal regions in the image have been determined to be safe and discarded, without consuming subsequent computational resources.
[0027] Step S4 (Fine Defect Classification): Based on the coordinates of the few candidate boxes extracted in S3 (e.g., only two suspected anomalies in a single frame), local image patches with normalized sizes of 256×256 are cropped from the original resolution of the enhanced background suppression image. These patches are then input into the second branch—a fine classification network based on the ResNet50 architecture. This network has a deeper receptive field and accurately outputs defect classifications and their confidence scores (e.g., oil stains, 98.5%).
[0028] Step S5 (Result Output Linkage): The system software interface updates the "defect location map" of the textile in real time. When a defect is found, the labeling mechanism at the back end is controlled by the PLC to physically mark the corresponding location on the fabric edge and record it in the database.
[0029] Example 2: Implementation of the offline training phase of the model This embodiment details the offline training phase of the above-described dual-branch network before deployment.
[0030] In the training of the second branch of the fine-grained classification network, a severe long-tailed distribution problem exists due to the abundance of "normal fabric" data and the scarcity of "severe defect" data. If a conventional cross-entropy loss function is used, the model gradient will be dominated by the massive amount of normal background features. Therefore, this application uses Focal Loss instead of standard cross-entropy. FL(p_t)=-α_t (1-p_t )^γ log(p_t) Here, γ is set to 2.0 and α_t is set to 0.25. By introducing the modulation coefficient (1-p_t)^γ, the loss contribution of "normal areas" or "obvious oil stains" (with large p_t) that the network can easily judge automatically decreases exponentially. This forces the network to focus the weight update on difficult samples such as "single broken yarn" and "minor weft error" with weak features and difficult to distinguish during backpropagation, which greatly improves the model's ability to generalize and identify minor defects.
[0031] Example 3: Multi-view light source physical architecture system This embodiment provides a system architecture hardware layout based on the above algorithm. The coaxial light source is located on the same axis as the camera lens, illuminating the textile surface vertically downwards to obtain the overall reflective contrast of the fabric. The low-angle light source is located on the same side as the camera, but the angle between its optical axis and the textile surface is set to 10° to 20°. This low-angle grazing light can generate shadows on the textile surface, highlighting three-dimensional foreign objects and flyaways on the textile surface. The backlight is located below the conveyor belt with high light transmittance, directly opposite the coaxial light source, to penetrate the fabric and greatly highlight broken yarns, holes, and sparse-density defects. This physical optics combination, together with the fusion algorithm in Embodiment 1, forms a hardware-software collaborative anti-miss detection mechanism.
[0032] Example 4: Computer-readable storage medium The present invention also provides a computer-readable storage medium, such as a solid-state drive, USB flash drive or cloud server storage in an industrial computer, which stores a computer program that implements the above-mentioned dynamic fusion and dual-branch detection algorithm. When the program is called and executed by the CPU and GPU on the industrial edge computing node, all the automated defect detection and model update steps in Embodiments 1 to 2 can be realized.
[0033] Regarding the working principle of this solution This solution primarily utilizes a hardware and software synchronization mechanism between the encoder triggering module and the image acquisition module, combined with a multi-source image dynamic fusion algorithm and a dual-branch deep learning network, to achieve high-speed, high-precision online detection of surface defects on textiles. First, the encoder triggering module outputs equally spaced pulse signals based on the real-time transmission speed of the textile, precisely controlling the line frequency of the 10-line array camera and the strobe timing of the 11 coaxial light source, 12 low-angle light source, and 13 backlight. This ensures synchronous acquisition of multi-view images of the textile at the same physical location under three different lighting conditions within microseconds, avoiding image stretching or misalignment caused by transmission speed fluctuations. Second, after receiving the multi-view images, the 20 edge computing processing module initiates the multi-source dynamic fusion algorithm. It calculates the local variance of the neighborhood of each pixel in each viewpoint image using an M×M local sliding window, using this as a local contrast index. A temperature-coefficient Softmax function is then introduced to generate pixel-level dynamic weights for each viewpoint image. Weighted summation generates an enhanced background suppression image. This process adaptively increases the weight of the corresponding light source image based on the optical sensitivity characteristics of different defects, while suppressing background interference from normal warp and weft yarn textures. Subsequently, the enhanced background suppression image is input into the first branch lightweight localization network. This network uses depthwise separable convolution as its core backbone to reduce computational load and generates a two-dimensional spatial weight map after max pooling and average pooling along the channel dimension through the CBAM spatial and channel joint attention mechanism. This adaptively weakens periodic normal texture features and enhances abnormal defect features, quickly outputting the coordinates of candidate defect regions with a confidence level greater than a preset threshold, filtering out more than 99% of normal regions. Next, based on the candidate region coordinates, local image patches are cropped from the original resolution enhanced background suppression image. After size normalization, these patches are input into the second branch residual neural network for fine classification. During the network training phase, the Focal Loss loss function is used, and the weight of easily classified normal samples is reduced through a dynamic scaling factor, allowing the model to focus on difficult-to-classify small defect samples. Finally, the defect type and confidence level are output. Finally, the execution and alarm module generates a defect location distribution map based on the defect information output by the 20 edge computing processing module and outputs control signals to drive the removal or marking actuator to complete the audible and visual alarm or physical marking of textile edges.
[0034] The core innovation of this solution lies in This paper proposes an overall architecture for textile defect detection that combines multi-source dynamic fusion with dual-branch network collaboration. This architecture addresses three core pain points in existing technologies: the contradiction between high-resolution image memory explosion and loss of minute defect features; the inability of a single light source to handle all types of defects; and the difficulty of complex deep networks to meet the real-time requirements of industrial applications. Furthermore, it is the first to apply a temperature-coefficient Softmax dynamic weighting algorithm to pixel-level fusion of multi-source textile images and designs a lightweight dual-branch network architecture that prioritizes coarse localization followed by fine classification. This achieves millisecond-level processing of high-resolution images from industrial settings and low-miss-rate detection of all types of minute defects.
[0035] Pain Point Anchoring: Addressing the issues of memory overflow when existing deep learning models directly process high-resolution linear array images, and the complete loss of pixel-level defect features such as single yarn breaks due to downsampling; addressing the problem of large differences in imaging effects for different types of defects such as oil stains, holes, and fly waste under a single light source, making it impossible to present them clearly at the same time; and addressing the problem of large parameter quantities and high processing latency of traditional complex networks for modern textile machines operating at speeds of 50 meters per minute or more, the core direction for technological breakthroughs has been identified.
[0036] Implementation: At the hardware level, a multi-view light source layout is designed with 11 coaxial light sources, 12 low-angle light sources, and 13 backlights to adapt to the optical imaging characteristics of different defects. At the algorithm level, a multi-light source dynamic fusion module is built, which calculates contrast through local variance and generates dynamic weights by combining Softmax with a temperature coefficient to achieve pixel-level image reconstruction. At the network level, the localization and classification tasks are separated. The first branch uses a depthwise separable convolution + CBAM attention mechanism to achieve lightweight and fast localization, while the second branch uses a residual neural network + Focal Loss to achieve high-precision and fine classification.
[0037] Action verification: The local contrast of different defects under the corresponding light source was significantly higher than that under other light sources, and the Softmax with temperature coefficient effectively avoided the weight abrupt change caused by noise. The dual-branch network test verified that the first branch can achieve millisecond-level localization on a high-resolution image with a width of 8192 and can filter more than 99% of normal areas. The second branch can complete high-precision classification by processing only a small number of candidate patches.
[0038] Effect closed loop: Multi-source dynamic fusion improves the image signal-to-noise ratio from the physical imaging level, the dual-branch network solves the memory bottleneck without losing small features, and Focal Loss overcomes the model bias of long-tail distribution of industrial data, ultimately achieving high-sensitivity detection of all types of defects while meeting the real-time requirements of industrial sites.
[0039] Scope expansion: This architecture can be adapted to textiles with different textures, such as non-woven fabrics, woven fabrics, and knitted fabrics, by adjusting the light source angle, sliding window size, and network parameters. It can also be extended to the field of defect detection of other industrial products such as films, paper, and metal surfaces.
[0040] Technical effects of implementing this solution Implementing this solution comprehensively improves the performance of textile defect detection across five dimensions: detection accuracy, coverage, real-time performance, robustness, and industrial applicability, completely resolving the core shortcomings of existing technologies. Firstly, regarding the accuracy of detecting minute defects, this solution employs a two-branch architecture of "coarse localization followed by fine classification," avoiding overall downsampling of the high-resolution original image. The first branch directly locates abnormal regions on the original 8192 or 16384 pixel wide image, while the second branch crops candidate patches from the original resolution image for classification. This fully preserves defect features such as single broken yarns and minor weft errors, which occupy only a few pixels. Combined with the gradient focusing effect of the Focal Loss loss function on difficult-to-classify minute defects, the model reduces the false negative rate for pixel-level minute defects by more than 90% compared to traditional deep learning methods, solving the long-standing problem of lost features for minute defects in industrial inspection. Secondly, regarding the coverage of defect detection, this solution achieves high-sensitivity detection of all types of defects through the synergistic effect of a multi-view light source layout of 11 coaxial light sources, 12 low-angle light sources, and 13 backlight sources, along with a dynamic fusion algorithm: the 11 coaxial light sources, when illuminated vertically, can clearly present planar color difference defects such as oil stains and dirt; the 12 low-angle light sources, illuminating at a grazing angle of 10° to 20°, highlight three-dimensional foreign object defects such as fly hair and protrusions through the shadow effect; the 13 backlight sources, penetrating the fabric, can clearly present light-transmitting defects such as broken yarns, holes, and uneven density patterns. The Softmax dynamic weighting algorithm with a temperature coefficient can adaptively allocate the weight of different light sources according to the local contrast of each pixel position, improving the image signal-to-noise ratio by more than 3 times from the physical imaging level, thus solving the limitation that a single light source cannot cover all types of defects. Third, in terms of industrial real-time performance, the first branch of the lightweight positioning network uses depthwise separable convolution to replace traditional convolution, reducing the number of parameters and computation by more than 80%. It only performs positioning tasks and does not perform classification calculations, which can quickly filter more than 99% of normal areas. This allows the subsequent second branch to process only a very small number of candidate patches in a single frame image. The overall system processes a single frame image with a width of 8192 pixels in less than 10 milliseconds, which can easily adapt to high-speed textile production lines of 80 meters per minute or even 100 meters per minute, meeting the high-speed production needs of the modern textile industry. Fourth, in terms of algorithm robustness and generalization, the CBAM spatial and channel joint attention mechanism can adaptively learn and suppress the periodic warp and weft texture features of textiles, unaffected by changes in fabric texture type, color, and density. When changing fabric varieties, there is no need to retrain the entire network; only the attention module parameters need to be fine-tuned for quick adaptation. The Focal Loss function effectively solves the long-tail distribution problem of massive normal fabric samples and scarce defect samples in industrial settings, avoiding the model being dominated by normal sample features, and enabling the model to still achieve excellent classification results with small sample defect data.Finally, in terms of industrial applicability, this solution integrates all algorithms into 20 edge computing processing modules, eliminating the need to rely on cloud servers. The encoder triggering module achieves precise synchronization between image acquisition and textile transmission speed. The execution and alarm modules can directly link with the PLC control system on the production line to automatically complete defect marking, alarms, and data recording, achieving fully automated detection, significantly reducing manual labor intensity, and improving the level of intelligence in textile production.
[0041] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered illustrative and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.
[0042] Finally, the following points should be noted: First, in the description of this application, it should be noted that, unless otherwise specified and limited, the terms "installation", "connection", and "linkage" should be interpreted broadly, and can refer to mechanical or electrical connections, or internal connections between two components, or direct connections. "Up", "down", "left", "right", etc., are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may change.
[0043] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for detecting textile defects based on multi-source dynamic fusion and a dual-branch network, characterized in that: Includes the following steps: S1. Acquire multi-view synchronous images of textile surface: The encoder triggers the linear scan camera to synchronously acquire multi-view images of the moving textile under coaxial light source, low-angle light source and backlight. S2. Dynamic fusion of multi-source images: Extract the texture feature gradient of the multi-view images, calculate the dynamic weight of each view image based on local contrast, and fuse the multi-view images according to the dynamic weight to generate an enhanced background suppression image. S3. Rapid extraction of candidate defect regions: The enhanced background suppression image is input into the first branch lightweight localization network, and the periodic features of normal texture are suppressed through the spatial attention mechanism to quickly output the coordinate information of candidate defect regions. S4. Fine classification and evaluation of defects: Based on the coordinate information of the candidate defect region, local image patches are cropped from the enhanced background suppression image and input into the second branch fine classification network to output the defect type and confidence level. S5. Output and linkage of detection results: Generate a defect location distribution map based on the defect type and confidence level, and output control signals to the rejection or marking execution mechanism.
2. The textile defect detection method based on multi-source dynamic fusion and dual-branch network according to claim 1, characterized in that: The method for calculating the dynamic weights in step S2 is as follows: calculate the variance of the image at each viewpoint within the local sliding window and use it as a local contrast index; for the same physical location, compare the local contrast of the images of the coaxial light source, the low-angle light source, and the backlight, assign the highest weight to the image with the highest local contrast, and assign lower weights to the remaining images according to the contrast ratio, perform pixel-level weighted summation, and obtain the enhanced background suppression image.
3. The textile defect detection method based on multi-source dynamic fusion and dual-branch network according to claim 2, characterized in that: The specific calculation model for dynamic weights and pixel-level weighted summation is as follows: The size of the local sliding window is set to M×M. For a pixel (xⓜ,y), the local variance V_k(x,y) of the k-th light source view image within the window is calculated. The dynamic weights W_k(x,y) for each view are generated using the Softmax function, with the formula: W_k(x,y)=exp(V_k(x,y) / T) / ∑exp(V_i(x,y) / T), where T is a temperature coefficient used to adjust the smoothness of the weight distribution. Finally, the value of the pixel in the enhanced background suppression image is I_out(x,y)=∑[W_k(x,y)×I_k(x,y)], where I_k(x,y) is the original pixel value of the k-th view image.
4. The textile defect detection method based on multi-source dynamic fusion and dual-branch network according to claim 1, characterized in that: The first branch of the lightweight localization network mentioned in step S3 includes continuous depth-separable convolutional layers and a spatial attention module. The spatial attention module generates a two-dimensional spatial weight map by calculating the max pooling and average pooling of the feature map in the channel dimension, which is used to enhance the abnormal defect features and weaken the periodic normal warp and weft yarn texture features.
5. The textile defect detection method based on multi-source dynamic fusion and dual-branch network according to claim 4, characterized in that: The spatial attention module is a spatial and channel joint attention mechanism (CBAM). Its working mechanism is as follows: max pooling and average pooling are performed along the channel dimension, and after concatenation, a spatial attention weight map is generated through a convolutional layer and a sigmoid activation function. The weight response of periodic texture features is adaptively reduced, while the weight of defect regions that disrupt the periodicity is increased. The first branch lightweight localization network only outputs the coordinates of candidate defect regions with confidence greater than a preset threshold, without performing defect classification calculation.
6. The textile defect detection method based on multi-source dynamic fusion and dual-branch network according to claim 1, characterized in that: The second branch fine classification network mentioned in step S4 is a residual neural network, which receives the local image patches after size normalization processing and outputs the defect categories through a fully connected layer. The defect categories include at least: holes, broken yarns, oil stains, fly waste, and misaligned weft.
7. The textile defect detection method based on multi-source dynamic fusion and dual-branch network according to claim 1, characterized in that: The second branch of the fine-grained classification network includes an offline training phase, which includes: Construct a training dataset containing normal fabric patches and various defect patches; Focal Loss is used as the classification loss function to address the problem of extreme imbalance between the number of normal samples and defective samples during training. The calculation formula of the classification loss function introduces a dynamic scaling factor to reduce the weight of easily classified normal samples, so that the network training focuses on the difficult-to-classify small defective samples.
8. A textile defect detection system based on multi-source dynamic fusion and dual-branch network, used to implement the method as described in any one of claims 1 to 7, characterized in that: The system includes: Image acquisition module: including at least one line scan industrial camera, as well as synchronously controlled coaxial light source, low-angle light source and backlight, for acquiring multi-view images of textiles; Encoder trigger module: connected to the image acquisition module, used to output pulse signals according to the transmission speed of the textile to control the line frequency of the camera and the strobe of the light source; Edge computing processing module: It has built-in multi-source image dynamic fusion algorithm, first branch lightweight localization network and second branch fine classification network, which are used to process images and output defect information; Execution and Alarm Module: Based on the defect information output by the edge computing processing module, execute an audible and visual alarm or perform physical marking on the edge of the textile.
9. The textile defect detection system based on multi-source dynamic fusion and dual-branch network according to claim 8, characterized in that: The specific layout of the multi-view light source is as follows: The coaxial light source illuminates the textile surface perpendicularly; The angle between the optical axis of the low-angle light source and the surface of the textile is set to 10° to 20° to highlight three-dimensional foreign objects and flying flowers on the surface of the textile. The backlight is positioned below the light-transmitting conveyor belt, opposite to the coaxial light source, and is used to penetrate the fabric to highlight broken yarns and holes.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by the processor, it implements the method of any one of claims 1-7.