Cloth defect detection method and device, computer device and storage medium

CN116977258BActive Publication Date: 2026-09-04TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310254973.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-07
Publication Date
2026-09-04
Estimated Expiration
2043-03-07

AI Technical Summary

Technical Problem

在相关技术中,将待检测的布料图像和对应的无缺陷图像各自划分为多个图像块,将布料图像和无缺陷图像中对应图像块进行相似性比较,若相似性较低,则可以根据对应图像块确定布料图像中的缺陷区域,但是相似性较低可能是多种非缺陷的原因导致的,导致误检测的概率较高,缺陷检测的准确性较低

Benefits of technology

[0020]The aforementioned fabric defect detection method, apparatus, computer equipment, storage medium, and computer program product perform feature extraction on a first image group composed of a fabric image and a first template image, and also perform feature extraction on a second image group composed of a fabric image and a second template image. During feature extraction, intermediate features extracted from the first image group are interchanged with intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group. Since the first template image and the second template image are different, feature interchange ensures that the first feature map includes some features from the second template image, and vice versa. Through sufficient feature interaction, the detection accuracy is improved. The quality of the first and second feature maps, and the partial features of the second template image, participate in the classification process of the first feature map and the classification process of the second feature map, thus improving the accuracy of the prediction score of the detection box. By matching the prediction scores of each detection box in the detection box matching, the defect detection result of the fabric to be tested is determined. That is, by combining the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map, the defect detection result of the fabric to be tested is determined. Through the first and second template images, the first and second feature maps contain rich non-defect feature information, which can detect the real defects of the fabric to be tested, effectively reducing the probability of false detection and improving the accuracy of defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116977258B_ABST
    Figure CN116977258B_ABST
Patent Text Reader

Abstract

The application relates to a cloth defect detection method and device, computer equipment, a storage medium and a computer program product. The method can be applied to the field of artificial intelligence, such as a scenario of detecting cloth defects through an intelligent terminal. The method comprises the following steps: obtaining a cloth image of a cloth to be detected, a first template image and a second template image of template cloth; performing feature extraction on a first image group composed of the cloth image and the first template image, and performing feature extraction on a second image group composed of the cloth image and the second template image; in the process of feature extraction, the extracted part of the intermediate features are interchanged to obtain a first feature map and a second feature map; the first feature map and the second feature map are classified respectively to obtain a prediction score of each detection frame in a detection frame matching pair; and a defect detection result of the cloth to be detected is determined based on the prediction score of each detection frame in the detection frame matching pair. The method can improve the accuracy of defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer equipment, storage medium, and computer program product for detecting defects in fabric. Background Technology

[0002] Textile fabrics are essential items in daily life, and their quality is of great concern. In related technologies, the image of the fabric to be inspected and its corresponding defect-free image are each divided into multiple image blocks. The similarity of corresponding image blocks in the fabric image and the defect-free image is compared. If the similarity is low, the defect area in the fabric image can be determined based on the corresponding image block. However, low similarity can be caused by various non-defect-related reasons, leading to a higher probability of false detection and lower accuracy in defect detection. Summary of the Invention

[0003] Therefore, it is necessary to provide a method, apparatus, computer equipment, computer-readable storage medium, and computer program product for detecting defects in fabrics, which can improve the accuracy of defect detection, in order to address the above-mentioned technical problems.

[0004] Firstly, this application provides a method for detecting defects in the aforementioned fabric. The method includes:

[0005] Acquire the fabric image of the fabric to be tested, and the first and second template images of the template fabric;

[0006] Feature extraction is performed on a first image group consisting of a fabric image and a first template image, and feature extraction is also performed on a second image group consisting of a fabric image and a second template image. During the feature extraction process, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group.

[0007] The first feature map and the second feature map are classified separately to obtain the prediction score of each detection box in the detection box matching pair; the detection boxes in the detection box matching pair are the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map.

[0008] Based on the predicted scores of each detection box in the detection box matching pair, the defect detection result of the fabric to be tested is determined.

[0009] Secondly, this application also provides a defect detection device for fabric. The device includes:

[0010] The image acquisition module is used to acquire the fabric image of the fabric to be tested, and the first template image and the second template image of the template fabric;

[0011] The feature map determination module is used to extract features from a first image group consisting of a fabric image and a first template image, and to extract features from a second image group consisting of a fabric image and a second template image. During the feature extraction process, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group.

[0012] The detection box matching pair determination module is used to classify the first feature map and the second feature map respectively to obtain the prediction score of each detection box in the detection box matching pair; the detection boxes in the detection box matching pair are the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map respectively.

[0013] The defect detection module is used to determine the defect detection result of the fabric under test based on the predicted score of each detection box in the detection box matching pair.

[0014] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:

[0015] The process involves acquiring images of the fabric to be tested, a first template image, and a second template image of the template fabric. Feature extraction is performed on a first image group composed of the fabric image and the first template image, and on a second image group composed of the fabric image and the second template image. During feature extraction, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group. The first and second feature maps are then classified to obtain the prediction score of each detection box in the detection box matching pair. The detection boxes in the detection box matching pair are the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map. Based on the prediction scores of each detection box in the detection box matching pair, the defect detection result of the fabric to be tested is determined.

[0016] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:

[0017] The process involves acquiring images of the fabric to be tested, a first template image, and a second template image of the template fabric. Feature extraction is performed on a first image group composed of the fabric image and the first template image, and on a second image group composed of the fabric image and the second template image. During feature extraction, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group. The first and second feature maps are then classified to obtain the prediction score of each detection box in the detection box matching pair. The detection boxes in the detection box matching pair are the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map. Based on the prediction scores of each detection box in the detection box matching pair, the defect detection result of the fabric to be tested is determined.

[0018] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:

[0019] The process involves acquiring images of the fabric to be tested, a first template image, and a second template image of the template fabric. Feature extraction is performed on a first image group composed of the fabric image and the first template image, and on a second image group composed of the fabric image and the second template image. During feature extraction, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group. The first and second feature maps are then classified to obtain the prediction score of each detection box in the detection box matching pair. The detection boxes in the detection box matching pair are the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map. Based on the prediction scores of each detection box in the detection box matching pair, the defect detection result of the fabric to be tested is determined.

[0020] The aforementioned fabric defect detection method, apparatus, computer equipment, storage medium, and computer program product perform feature extraction on a first image group composed of a fabric image and a first template image, and also perform feature extraction on a second image group composed of a fabric image and a second template image. During feature extraction, intermediate features extracted from the first image group are interchanged with intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group. Since the first template image and the second template image are different, feature interchange ensures that the first feature map includes some features from the second template image, and vice versa. Through sufficient feature interaction, the detection accuracy is improved. The quality of the first and second feature maps, and the partial features of the second template image, participate in the classification process of the first feature map and the classification process of the second feature map, thus improving the accuracy of the prediction score of the detection box. By matching the prediction scores of each detection box in the detection box matching, the defect detection result of the fabric to be tested is determined. That is, by combining the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map, the defect detection result of the fabric to be tested is determined. Through the first and second template images, the first and second feature maps contain rich non-defect feature information, which can detect the real defects of the fabric to be tested, effectively reducing the probability of false detection and improving the accuracy of defect detection. Attached Figure Description

[0021] Figure 1 This is an application environment diagram of a fabric defect detection method in one embodiment;

[0022] Figure 2 This is a flowchart illustrating a method for detecting defects in fabric in one embodiment;

[0023] Figure 3 This is a schematic diagram of a fabric image, a first template image, and a second template image in one embodiment;

[0024] Figure 4 This is a schematic diagram of a fabric image, a first template image, and a second template image in another embodiment;

[0025] Figure 5 This is a schematic diagram illustrating the determination of a first intermediate feature map and a second intermediate feature map through a two-branch feature extraction sub-network in one embodiment.

[0026] Figure 6 This is a schematic diagram of the feature extraction network structure in one embodiment;

[0027] Figure 7 This is a schematic diagram of the feature extraction subnetwork extracting intermediate feature maps in one embodiment;

[0028] Figure 8 This is a schematic diagram illustrating the extraction of the first and second feature maps in one embodiment;

[0029] Figure 9 This is a schematic diagram illustrating feature interchange in one embodiment;

[0030] Figure 10 This is a schematic diagram illustrating the determination of a first detection image and a second detection image in one embodiment;

[0031] Figure 11 This is a schematic diagram of twin model training in one embodiment;

[0032] Figure 12 This is a schematic diagram of a fabric defect detection method in one scenario embodiment;

[0033] Figure 13 This is a flowchart illustrating a fabric defect detection method in another embodiment;

[0034] Figure 14 This is a structural block diagram of a fabric defect detection device in one embodiment;

[0035] Figure 15 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0036] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0037] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.

[0038] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning.

[0039] The fabric defect detection method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104, or it can be located in the cloud or on another network server.

[0040] Server 104 can acquire fabric images of the fabric to be tested, first template images and second template images of the template fabric from terminal 102; Server 104 can perform feature extraction on a first image group composed of the fabric image and the first template image, and perform feature extraction on a second image group composed of the fabric image and the second template image. During the feature extraction process, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group; Server 104 can perform classification processing on the first feature map and the second feature map respectively to obtain the prediction score of each detection box in the detection box matching pair; The detection boxes in the detection box matching pair are the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map; Server 104 can determine the defect detection result of the fabric to be tested based on the prediction score of each detection box in the detection box matching pair.

[0041] The terminal 102 can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, IoT device, or portable wearable device. IoT devices can include smart speakers, smart TVs, smart air conditioners, and smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted devices, etc.

[0042] Server 104 can be an independent physical server or a service node in a blockchain system. The service nodes in the blockchain system form a peer-to-peer (P2P) network. The P2P protocol is an application layer protocol that runs on top of the Transmission Control Protocol (TCP).

[0043] In addition, server 104 can also be a server cluster consisting of multiple physical servers, which can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.

[0044] Terminal 102 and server 104 can be connected via Bluetooth, USB (Universal Serial Bus) or network, etc., and this application does not impose any restrictions.

[0045] In some embodiments, such as Figure 2 As shown, a method for detecting defects in fabric is provided. This method consists of... Figure 1 It can be executed by a server or terminal in the system, or by... Figure 1 The server and terminal in the process work together to execute the method. Figure 1 Taking the server execution in [the context of the example] as an example, the steps include:

[0046] Step 202: Obtain the fabric image of the fabric to be tested, and the first template image and the second template image of the template fabric.

[0047] Among them, the fabric to be tested and the template fabric are fabrics with the same pattern, texture and size. The fabric image is obtained by taking a picture of the fabric to be tested. The template fabric is the fabric corresponding to the fabric to be tested and has no defects. The first template image and the second template image are both obtained by taking pictures of the template fabric. That is to say, the first template image and the second template image are both images of the fabric corresponding to the fabric to be tested and have no defects.

[0048] It should be noted that the shooting points and framing ranges corresponding to the fabric image, the first template image, and the second template image are the same. The fabric image may only include the image content of the fabric to be tested; similarly, the first template image and the second template image may only include the image content of the template fabric.

[0049] The difference between the first template image and the second template image could be due to differences in the flexibility and deformation of the template fabric, differences in the color parameters when photographing the template fabric, or a combination of both.

[0050] The different flexible deformations of the template fabric refer to the different folds of the template fabric; the color parameters when photographing the template fabric include, but are not limited to: brightness, contrast, color temperature, saturation, etc.; of course, the differences between the first template image and the second template image can be differences that are discernible to the naked eye.

[0051] The fabric to be tested may or may not have defects; the fabric to be tested may or may not have wrinkles.

[0052] For example, such as Figure 3 As shown, fabric image 301 is the image corresponding to the fabric to be tested having wrinkles 3011, first template image 302 is the image corresponding to the template fabric having no defects and wrinkles, and second template image 303 is the image corresponding to the template fabric having no defects and having wrinkles 3031.

[0053] like Figure 4 As shown, fabric image 401 is the image corresponding to the fabric under test having defect 4011, first template image 402 is the image corresponding to the template fabric having no defects and wrinkles, and second template image 403 is the image corresponding to the template fabric having no defects and having wrinkles 4031.

[0054] In some embodiments, the server acquires a fabric image of the fabric to be tested, determines the template fabric corresponding to the fabric to be tested, and acquires a first template image and a second template image of the template fabric. The correspondence between the fabric to be tested and the template fabric is pre-established. The correspondence between the fabric to be tested and the template fabric can be established using fabric coding. For example, the fabric number includes a prefix and a suffix. The prefix of the fabric number of the fabric to be tested and the corresponding template fabric are the same. The suffix of the fabric number of the fabric to be tested can indicate the generation sequence number of the fabric. The suffix of the fabric number of the template fabric can indicate that the fabric is a template fabric used for defect detection.

[0055] In some embodiments, the server obtains a first template image and a second template image of the template fabric when the color parameters are the same but the flexible deformation is different. For example, the upper left corner of the first template image has a wrinkle and the lower right corner of the second template image has a wrinkle; or, the upper left corner of the first template image has a wrinkle and the second template image does not have a wrinkle.

[0056] In some embodiments, the server acquires a first template image and a second template image of the template fabric when the flexible deformation is the same but the color parameters are different. For example, the first template image and the second template image have the same wrinkles and the brightness of the first template image and the second template image are different; or, neither the first template image nor the second template image has wrinkles and the contrast of the first template image and the second template image is different.

[0057] Step 204: Perform feature extraction on the first image group composed of the fabric image and the first template image, and perform feature extraction on the second image group composed of the fabric image and the second template image. During the feature extraction process, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain the first feature map corresponding to the first image group and the second feature map corresponding to the second image group.

[0058] The first image group includes a fabric image and a first template image, and the second image group includes a fabric image and a second template image.

[0059] In some embodiments, the server performs feature extraction on a first image group, including multi-scale feature extraction on the first image group to obtain first intermediate feature maps corresponding to each of the multi-scale features. The first intermediate feature maps can reflect the intermediate features extracted from the first image group. The server performs feature extraction on a second image group, including multi-scale feature extraction on the second image group to obtain second intermediate feature maps corresponding to each of the multi-scale features. The second intermediate feature maps can reflect the intermediate features extracted from the second image group.

[0060] For the first and second intermediate feature maps extracted at the same scale, the server can swap some features of the first intermediate feature map with some features of the second intermediate feature map, that is, swap some intermediate features extracted from the first image group with some intermediate features extracted from the second image group; then, feature extraction at subsequent scales is performed on the first and second intermediate feature maps after feature swapping.

[0061] It should be noted that after swapping the features of the first and second intermediate feature maps at the last scale, we obtain the first and second feature maps. It is not necessary to extract features from the feature maps after the feature swapping.

[0062] In some embodiments, the server can interchange partial features of a first intermediate feature map and a second intermediate feature map at at least one scale in multiple scales. Interchanging partial features of the first and second intermediate feature maps can be done by exchanging partial channel feature maps of the first and second intermediate feature maps; it can also involve determining a first average channel feature map of the partial channel feature maps of the first intermediate feature map, determining a second average channel feature map of the partial channel feature maps of the second intermediate feature map, and then exchanging the first and second average channel feature maps; alternatively, it can involve linearly processing partial channel feature maps of the first and second intermediate feature maps, and then exchanging the linearly processed partial channel feature maps.

[0063] Step 206: Classify the first feature map and the second feature map respectively to obtain the prediction score of each detection box in the detection box matching pair; the detection boxes in the detection box matching pair are the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map.

[0064] The detection box matching pair includes two detection boxes, namely the detection box corresponding to the first feature map and the detection box corresponding to the second feature map. For ease of explanation, the detection box corresponding to the first feature map is called the first detection box, and the detection box corresponding to the second feature map is called the second detection box.

[0065] The prediction score of the detection box reflects the probability that there is a defect in the area corresponding to the detection box. The higher the prediction score, the greater the probability that there is a defect in the area corresponding to the detection box, and the lower the prediction score, the smaller the probability that there is a defect in the area corresponding to the detection box.

[0066] In some embodiments, the server performs classification processing on the first feature map to obtain a first detection image, the first detection image including a first detection box and a prediction score of the first detection box; the server performs classification processing on the second feature map to obtain a second detection image, the second detection image including a second detection box and a prediction score of the second detection box; the server determines a detection box matching pair based on the first detection box in the first detection image and the second detection box in the second detection image, the detection box matching pair including the first detection box and the second detection box corresponding to the same area of ​​the fabric to be tested.

[0067] In some embodiments, the server uses two independent classification networks to classify the first feature map and the second feature map respectively, to obtain the first detection image and the second detection image.

[0068] In some embodiments, for a first detection box in a first detection image, a second detection box with the same corresponding region is determined in a second detection image based on the first detection box, and the first detection box and the second detection box form a detection box matching pair.

[0069] Step 208: Determine the defect detection result of the fabric to be tested based on the prediction score of each detection box in the detection box matching pair.

[0070] The defect detection results include the detection scores of the detection box matching pairs.

[0071] In some embodiments, the server determines the difference degree of the detection box matching pair based on the predicted scores of each detection box in the detection box matching pair. For a first detection box matching pair whose difference degree meets the difference condition, a first detection result of the first detection box matching pair is determined according to the predicted scores of each detection box in the first detection box matching pair. For a second detection box matching pair whose difference degree does not meet the difference condition, the first feature map and the second feature map are fused, and defect detection is performed on the fused feature map to obtain a second detection result of the second detection box matching pair. The first detection result includes the detection score of the first detection box matching pair, and the second detection result includes the detection score of the second detection box matching pair. The defect detection result of the fabric image is determined based on the first detection result and the second detection result.

[0072] In some embodiments, for a first detection box matching pair whose difference degree meets the difference condition, the detection score of the detection box matching pair is determined based on the prediction score of each detection box in the first detection box matching pair; for a second detection box matching pair whose difference degree does not meet the difference condition, the second detection box matching pair can be discarded, and the first detection result can be used as the defect detection result of the fabric image.

[0073] If the difference value of the detection box matching pair meets the difference condition, it means that the difference is small. That is, the difference between the predicted scores of each detection box in the detection box matching pair is small. In other words, for the region corresponding to the detection box matching pair, the predicted score obtained based on the fabric image and the first template image is similar to the predicted score obtained based on the fabric image and the second template image. Therefore, the accurate defect detection result of the fabric to be tested in the region can be obtained according to the predicted scores of each detection box in the detection box matching pair.

[0074] In some embodiments, for a second detection box matching pair whose difference does not meet the difference condition, the larger prediction score (the larger of the prediction scores of the two detection boxes included in the second detection box matching pair) corresponding to the second detection box matching pair can be used as the detection score of the second detection box matching pair; or, the smaller prediction score (the smaller of the prediction scores of the two detection boxes included in the second detection box matching pair) corresponding to the second detection box matching pair can be used as the detection score of the second detection box matching pair.

[0075] In some embodiments, when there are at least one detection box matching pair, if the difference between the detection box matching pair is less than a preset threshold, it is determined that the difference meets the difference condition; if the difference between the detection box matching pair is greater than or equal to the preset threshold, it is determined that the difference does not meet the difference condition. When there are at least two detection box matching pairs, it is determined that the difference of a preset number of detection box matching pairs with the smallest difference meets the difference condition, and the difference of the remaining detection box matching pairs does not meet the difference condition.

[0076] In some embodiments, when the detection score of the detection frame matching pair is greater than the defect detection threshold, it is determined that the fabric to be tested has a defect in the area corresponding to the detection frame matching pair; when the detection score of the detection frame matching pair is less than or equal to the defect detection threshold, it is determined that the fabric to be tested does not have a defect in the area corresponding to the detection frame matching pair.

[0077] In the aforementioned fabric defect detection method, feature extraction is performed on a first image group composed of a fabric image and a first template image, and feature extraction is also performed on a second image group composed of a fabric image and a second template image. During the feature extraction process, some intermediate features extracted from the first image group and some intermediate features extracted from the second image group are interchanged to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group. Since the first template image and the second template image are different, through feature interchange, the first feature map includes some features of the second template image, and the second feature map includes some features of the first template image. Through sufficient feature interaction, the first feature map and the second feature map are improved. The quality of the image is improved, and some features of the second template image participate in the classification process of the first feature image. The features of the first template image participate in the classification process of the second feature image, improving the accuracy of the prediction score of the detection box. By matching the prediction scores of each detection box in the detection box matching, the defect detection result of the fabric to be tested is determined. That is, by combining the detection boxes corresponding to the first feature image and the detection boxes corresponding to the second feature image, the defect detection result of the fabric to be tested is determined. Through the first template image and the second template image, the first feature image and the second feature image contain rich non-defect feature information, which can detect the real defects of the fabric to be tested, effectively reducing the probability of false detection and improving the accuracy of defect detection.

[0078] In some embodiments, feature extraction is performed on a first image group composed of a fabric image and a first template image, and feature extraction is also performed on a second image group composed of a fabric image and a second template image. During the feature extraction process, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group. This includes: performing feature extraction on the first image group composed of the fabric image and the first template image to obtain a first intermediate feature map; performing feature extraction on the second image group composed of the fabric image and the second template image to obtain a second intermediate feature map; the second intermediate feature map has the same scale as the first intermediate feature map; interchange some features of the first intermediate feature map with some features of the second intermediate feature map to obtain a first intermediate feature map and a second intermediate feature map with interchanged features; and performing feature extraction on the first intermediate feature map and the second intermediate feature map with interchanged features to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group.

[0079] The first intermediate feature map can be a feature map obtained by performing feature extraction on the first image group at at least one scale, and the second intermediate feature map can be a feature map obtained by performing feature extraction on the second image group at at least one scale.

[0080] For ease of explanation, the first intermediate feature map with interchanged features is referred to as the first interchanged feature map, and the second intermediate feature map with interchanged features is referred to as the second interchanged feature map.

[0081] The first feature map can be a feature map obtained by performing feature extraction on the first interchanged feature map at at least one scale, and the second feature map can be a feature map obtained by performing feature extraction on the second interchanged feature map at at least one scale.

[0082] In some embodiments, the server performs feature extraction at a first scale on a first image group to obtain a first intermediate feature map, and performs feature extraction at the first scale on a second image group to obtain a second intermediate feature map; the scale of the first intermediate feature map and the second intermediate feature map is the first scale; the server interchanges some features of the first intermediate feature map with some features of the second intermediate feature map to obtain a first interchanged feature map and a second interchanged feature map. The server performs feature extraction at a second scale on the first interchanged feature map to obtain a first feature map corresponding to the first image group, and performs feature extraction at a second scale on the second interchanged feature map to obtain a second feature map corresponding to the second image group.

[0083] In some embodiments, after performing second-scale feature extraction on the first and second interchanged feature maps, the extracted feature maps can be subjected to multiple feature interchanges and multi-scale feature extraction operations again to obtain deeper feature maps.

[0084] The server performs feature extraction at a second scale on the first interchanged feature map to obtain a third intermediate feature map. It then performs feature extraction at a second scale on the second interchanged feature map to obtain a fourth intermediate feature map. The scale of the third and fourth intermediate feature maps is the second scale. The server then interchanges some features of the third intermediate feature map with some features of the fourth intermediate feature map to obtain the third and fourth interchanged feature maps.

[0085] The server performs feature extraction at the third scale on the third interchanged feature map to obtain the fifth intermediate feature map, and performs feature extraction at the third scale on the fourth interchanged feature map to obtain the sixth intermediate feature map. The scale of the fifth and sixth intermediate feature maps is the third scale. The server then interchanges some features of the fifth intermediate feature map with some features of the sixth intermediate feature map to obtain the fifth and sixth interchanged feature maps.

[0086] The server performs feature extraction at the fourth scale on the fifth interchanged feature map to obtain the seventh intermediate feature map, and performs feature extraction at the fourth scale on the sixth interchanged feature map to obtain the eighth intermediate feature map. The scale of the seventh and eighth intermediate feature maps is the fourth scale. The server then interchanges some features of the seventh intermediate feature map with some features of the eighth intermediate feature map to obtain the seventh and eighth interchanged feature maps.

[0087] The server performs feature extraction at the fifth scale on the seventh interchanged feature map to obtain the ninth intermediate feature map, and performs feature extraction at the fifth scale on the eighth interchanged feature map to obtain the tenth intermediate feature map. The scale of the ninth and tenth intermediate feature maps is the fifth scale. The server interchanges some features of the ninth intermediate feature map with some features of the tenth intermediate feature map to obtain the first feature map corresponding to the first image group and the second feature map corresponding to the second image group.

[0088] In the above embodiments, the first intermediate feature map obtained by feature extraction from the first image group and the second intermediate feature map obtained by feature extraction from the second image group are partially interchanged to obtain the first intermediate feature map and the second intermediate feature map. This results in the first intermediate feature map including some features of the second template image and the second intermediate feature map including some features of the first template image. Through sufficient feature interaction, the quality of the first feature map and the second feature map is improved.

[0089] In some embodiments, feature extraction is performed on a first image group consisting of a fabric image and a first template image to obtain a first intermediate feature map; feature extraction is performed on a second image group consisting of a fabric image and a second template image to obtain a second intermediate feature map, including: performing feature extraction on the first image group consisting of a fabric image and a first template image through a feature extraction network on a first branch of a twin model to obtain a first intermediate feature map; and performing feature extraction on the second image group consisting of a fabric image and a second template image through a feature extraction network on a second branch of a twin model to obtain a second intermediate feature map.

[0090] The Siamese model includes feature extraction networks on both the first and second branches. The feature extraction networks on the first and second branches have identical network structures.

[0091] In some embodiments, the server inputs a first image group into a feature extraction network on a first branch of the Siamese model, and outputs a first intermediate feature map through a feature extraction subnetwork of the feature extraction network on the first branch; the server inputs a second image group into a feature extraction network on a second branch of the Siamese model, and outputs a second intermediate feature map through a feature extraction subnetwork of the feature extraction network on the second branch.

[0092] In some embodiments, the server stitches the fabric image and the first template image included in the first image group into a first input image according to channels, and the server stitches the fabric image and the second template image included in the second image group into a second input image according to channels. The server inputs the first input image to the feature extraction network on the first branch and the second input image to the feature extraction network on the second branch. Since the fabric image, the first template image, and the second template image are all 3-channel images, the stitched first input image and the second input image are both 6-channel images.

[0093] For example, such as Figure 5 As shown, the Siamese model includes a feature extraction network 501 on the first branch and a feature extraction network 502 on the second branch. The feature extraction network 501 on the first branch includes a feature extraction sub-network 5011, and the feature extraction network on the second branch includes a feature extraction sub-network 5021. Features are extracted from the first input image through the feature extraction sub-network 5011 to obtain a first intermediate feature map. Features are extracted from the second input image through the feature extraction sub-network 5021 to obtain a second intermediate feature map.

[0094] In some embodiments, the feature extraction network may be a ResNet50 (a 50-layer residual neural network). The ResNet50 includes: a first-scale feature extraction subnetwork, a second-scale feature extraction subnetwork, a third-scale feature extraction subnetwork, a fourth-scale feature extraction subnetwork, and a fifth-scale feature extraction subnetwork. The second to fifth-scale feature extraction subnetworks all include residual modules, which implement downsampling and feature transformation. Downsampling increases the network's receptive field and translation invariance. As the network depth increases, the number of channels in the feature map increases, thereby enabling the extraction of richer image features.

[0095] For example, such as Figure 6 As shown, the first-scale feature extraction subnetwork 601 includes: a convolutional layer with a kernel size of 7×7, a number of kernels of 64, and a stride of 2.

[0096] The second-scale feature extraction subnetwork 602 includes: a max pooling layer with a kernel size of 3×3 and a stride of 2, and three cascaded first residual modules. The first residual module includes: a first convolutional layer with a kernel size of 1×1 and a number of 64 kernels, a second convolutional layer with a kernel size of 3×3 and a number of 64 kernels, and a third convolutional layer with a kernel size of 1×1 and a number of 256 kernels.

[0097] The third-scale feature extraction subnetwork 603 includes four cascaded second residual modules, each comprising: a fourth convolutional layer with a kernel size of 1×1 and a kernel count of 128; a fifth convolutional layer with a kernel size of 3×3 and a kernel count of 128; and a sixth convolutional layer with a kernel size of 1×1 and a kernel count of 512.

[0098] The fourth-scale feature extraction subnetwork 604 includes six cascaded third residual modules, which include: a seventh convolutional layer with a kernel size of 1×1 and a kernel count of 256, an eighth convolutional layer with a kernel size of 3×3 and a kernel count of 256, and a ninth convolutional layer with a kernel size of 1×1 and a kernel count of 1024.

[0099] The fifth-scale feature extraction subnetwork 605 includes three cascaded fourth residual modules. The fourth residual module includes: a tenth convolutional layer with a kernel size of 1×1 and a kernel count of 512; an eleventh convolutional layer with a kernel size of 3×3 and a kernel count of 512; and a twelfth convolutional layer with a kernel size of 1×1 and a kernel count of 2048.

[0100] The following explanation uses a third-scale feature extraction subnetwork as an example. Figure 7 As shown, the third-scale feature extraction sub-network includes: the second residual module conv4-1, the second residual module conv4-2, the second residual module conv4-3, and the second residual module conv4-4. The intermediate feature map P1 input to conv4-1 has a scale of 256×56×56. Features are extracted from the intermediate feature map p1 through the fourth, fifth, and sixth convolutional layers included in conv4-1, resulting in an intermediate feature map P2 with a scale of 512×28×28. The intermediate feature map P1 is then processed by a convolutional layer with a kernel size of 1×1 and 512 kernels, resulting in an intermediate feature map P3 with a scale of 512×28×28. Finally, the intermediate feature maps P2 and P3 are added together to obtain the intermediate feature map. Figure P4; Feature extraction is performed on the intermediate feature map P4 using conv4-2 to obtain an intermediate feature map P5 with a scale of 512×28×28. The intermediate feature maps P4 and P5 are added together to obtain an intermediate feature map P6; Feature extraction is performed on the intermediate feature map P6 using conv4-3 to obtain an intermediate feature map P7 with a scale of 512×28×28. The intermediate feature maps P6 and P7 are added together to obtain an intermediate feature map P8; Feature extraction is performed on the intermediate feature map P8 using conv4-4 to obtain an intermediate feature map P9 with a scale of 512×28×28. The intermediate feature maps P8 and P9 are added together to obtain an intermediate feature map P10. The intermediate feature map P10 is the intermediate feature map obtained by the feature extraction sub-network of the third scale.

[0101] Since the input items of the feature extraction networks on the first branch and the second branch are both 6-channel images, when the feature extraction network is ResNet50, the input layer of ResNet50 (a convolutional layer with a kernel size of 7×7, a kernel number of 64, and a stride of 2 in the first-scale feature extraction sub-network) can receive 3-channel image input. In order to adapt ResNet50 to the first and second input images of this application embodiment, the dimension of the input layer of ResNet50 is expanded to 6 channels. During the training stage of ResNet50, the original 3-channel pre-trained weights of the input layer of ResNet50 are averaged along the channel dimension, and the average value is copied to 6 channels, so that the input layer of the trained ResNet50 can process 6-channel input images.

[0102] In the above embodiments, a first intermediate feature map of the first template image and the fabric image is extracted by a feature extraction network on the first branch of the twin model, and a second intermediate feature map of the second template image and the fabric image is extracted by a feature extraction network on the second branch of the twin model. By using the first template image and the second template image, the first intermediate feature map and the second intermediate feature map include rich non-defect feature information, thereby improving the quality of the first intermediate feature map and the second intermediate feature map.

[0103] In some embodiments, partial features of the first intermediate feature map and partial features of the second intermediate feature map include feature sub-maps of partial channels; exchanging partial features of the first intermediate feature map and partial features of the second intermediate feature map includes: exchanging feature sub-maps of partial channels in the first intermediate feature map with feature sub-maps of corresponding channels in the second intermediate feature map through a feature exchange sub-network in the Siamese model.

[0104] The first intermediate feature map includes feature sub-maps for each channel, and a portion of the features in the first intermediate feature map includes feature sub-maps for some channels within the first intermediate feature map. The second intermediate feature map includes feature sub-maps for each channel, and a portion of the features in the second intermediate feature map includes feature sub-maps for some channels within the second intermediate feature map. Since the first and second intermediate feature maps have the same scale, the number of channels and the size of the feature sub-map for each channel in the first intermediate feature map are the same as those in the second intermediate feature map.

[0105] The channel number of the feature sub-map of some channels in the first intermediate feature map is the same as the channel number of the feature sub-map of the corresponding channel in the second intermediate feature map.

[0106] In some embodiments, the server may sample the feature sub-images of each channel in the first intermediate feature image to obtain a first feature sub-image of a portion of the channel, and sample the feature sub-images of each channel in the second intermediate feature image in the same sampling method to obtain a second feature sub-image of a portion of the channel, and then swap the first feature sub-images of a portion of the channel with the second feature sub-images of a portion of the channel.

[0107] In some embodiments, the server may use the feature sub-image with odd channel numbers in the first intermediate feature image as the first feature sub-image of the sampled partial channels, and correspondingly, use the feature sub-image with odd channel numbers in the second intermediate feature image as the second feature sub-image of the sampled partial channels. Alternatively, the server may use the feature sub-image with even channel numbers in the first intermediate feature image as the first feature sub-image of the sampled partial channels, and correspondingly, use the feature sub-image with even channel numbers in the second intermediate feature image as the second feature sub-image of the sampled partial channels.

[0108] In some embodiments, when the feature extraction network is ResNet50, the Siamese model includes five feature exchange subnetworks: a first feature exchange subnetwork, a second feature exchange subnetwork, a third feature exchange subnetwork, a fourth feature exchange subnetwork, and a fifth feature exchange subnetwork. The first feature exchange subnetwork is used to exchange features between intermediate feature maps output by the first-scale feature extraction subnetworks on both branches of the Siamese model. The second feature exchange subnetwork is used to exchange features between intermediate feature maps output by the second-scale feature extraction subnetworks on both branches of the Siamese model. The third feature exchange subnetwork is used to exchange features between intermediate feature maps output by the third-scale feature extraction subnetworks on both branches of the Siamese model. The fourth feature exchange subnetwork is used to exchange features between intermediate feature maps output by the fourth-scale feature extraction subnetworks on both branches of the Siamese model. The fifth feature exchange subnetwork is used to exchange features between intermediate feature maps output by the fifth-scale feature extraction subnetworks on both branches of the Siamese model.

[0109] For example, such as Figure 8 As shown, the server inputs the first image group into the feature extraction network 801 on the first branch of the twin model, and inputs the second image group into the feature extraction network 802 on the second branch of the twin model. The first intermediate feature map is output through the first scale feature extraction submodule 8011 on the first branch, and the second intermediate feature map is output through the first scale feature extraction submodule 8021 on the second branch. The first feature exchange subnetwork 8031 ​​performs partial feature exchange on the first intermediate feature map and the second intermediate feature map to obtain the first exchanged feature map and the second exchanged feature map.

[0110] The third intermediate feature map is output through the feature extraction submodule 8012 of the second scale on the first branch, and the fourth intermediate feature map is output through the feature extraction submodule 8022 of the second scale on the second branch. The third intermediate feature map and the fourth intermediate feature map are partially interchanged through the second feature interchange subnetwork 8032 to obtain the third interchanged feature map and the fourth interchanged feature map.

[0111] The fifth intermediate feature map is output through the feature extraction submodule 8013 at the third scale on the first branch, and the sixth intermediate feature map is output through the feature extraction submodule 8023 at the third scale on the second branch. The fifth intermediate feature map and the sixth intermediate feature map are partially interchanged through the third feature interchange subnetwork 8033 to obtain the fifth interchanged feature map and the sixth interchanged feature map.

[0112] The seventh intermediate feature map is output through the fourth-scale feature extraction submodule 8014 on the first branch, and the eighth intermediate feature map is output through the fourth-scale feature extraction submodule 8024 on the second branch. The seventh intermediate feature map and the eighth intermediate feature map are partially interchanged through the fourth feature interchange subnetwork 8034 to obtain the seventh interchanged feature map and the eighth interchanged feature map.

[0113] The fifth-scale feature extraction submodule 8015 on the first branch outputs the ninth intermediate feature map, and the fifth-scale feature extraction submodule 8025 on the second branch outputs the tenth intermediate feature map. The fifth feature exchange subnetwork 8035 performs partial feature exchange on the ninth and tenth intermediate feature maps to obtain the first feature map corresponding to the first image group and the second feature map corresponding to the second image group.

[0114] In some embodiments, for the intermediate feature map output by the feature extraction submodule at scale m, if m is even, the feature submap with an even channel number in the intermediate feature map output by the feature extraction submodule at scale m on the first branch is swapped with the feature submap with an even channel number in the intermediate feature map output by the feature extraction submodule at scale m on the second branch; if m is odd, the feature submap with an odd channel number in the intermediate feature map output by the feature extraction submodule at scale m on the first branch is swapped with the feature submap with an odd channel number in the intermediate feature map output by the feature extraction submodule at scale m on the second branch.

[0115] For example, the first feature swapping subnetwork can swap the features of the feature submap with odd channel numbers in the first intermediate feature map with the feature submap with odd channel numbers in the second intermediate feature map, and the second feature swapping subnetwork can swap the features of the feature submap with even channel numbers in the third intermediate feature map with the feature submap with even channel numbers in the fourth intermediate feature map. Figure 9As shown, the feature sub-image 901 with channel number 2 in the third intermediate feature image is swapped with the feature sub-image 902 with channel number 2 in the fourth intermediate feature image to obtain the third swapped feature image and the fourth swapped feature image.

[0116] In the above embodiments, the first intermediate feature map and the second intermediate feature map are partially interchanged by the feature interchange subnetwork in the Siamese model to obtain the first intermediate feature map and the second intermediate feature map. This results in the first intermediate feature map including some features of the second template image and the second intermediate feature map including some features of the first template image. Through sufficient feature interaction, the quality of the first feature map and the second feature map is improved.

[0117] In some embodiments, the first feature map and the second feature map are classified to obtain the prediction scores of each detection box in the detection box matching pair, including: classifying the first feature map through a classification network on the first branch of the Siamese model to obtain a first detection image including the first detection box and the corresponding prediction score; classifying the second feature map through a classification network on the second branch of the Siamese model to obtain a second detection image including the second detection box and the corresponding prediction score; and determining the detection box matching pair and the prediction score of each detection box in the detection box matching pair based on the position information of the first detection box in the first detection image and the position information of the second detection box in the second detection image; wherein the first detection box and the second detection box are detection boxes in the detection box matching pair.

[0118] The classification network on the first branch has the same network structure as the classification network on the second branch.

[0119] The detection box matching pair includes a first detection box and a second detection box. The first detection box is the detection box corresponding to the first feature map, and the second detection box is the detection box corresponding to the second feature map. The position information of the first detection box in the first detection image can be the pixel coordinates of the four corner points of the first detection box in the first detection image. Similarly, the position information of the second detection box in the second detection image can be the pixel coordinates of the four corner points of the second detection box in the second detection image.

[0120] In some embodiments, the classification networks on the first branch and the second branch of the Siamese model each possess independent defect detection capabilities. The server inputs a first feature map into the classification network on the first branch of the Siamese model and a second feature map into the classification network on the second branch of the Siamese model. A first detection image is output through the classification network on the first branch, and a second detection image is output through the classification network on the second branch. Based on the position information of the first detection box in the first detection image, a corresponding second detection box is determined in the second detection image. The first detection box and the second detection box form a detection box matching pair. The position information of the first detection box in the first detection image is the same as the position information of the second detection box in the second detection image.

[0121] In the above embodiments, the first feature map is classified by the classification network on the first branch to obtain a first detection image including a first detection box and a corresponding prediction score. The second feature map is classified by the classification network on the second branch to obtain a second detection image including a second detection box and a corresponding prediction score. Since the first feature map includes some features of the second template image and the second feature map includes some features of the first template image, some features of the second template image participate in the classification process of the first feature map and some features of the first template image participate in the classification process of the second feature map, thereby improving the accuracy of the prediction score of the detection box.

[0122] In some embodiments, the classification network on the first branch includes a first classification sub-network and a second classification sub-network, and the classification network on the second branch includes a third classification sub-network and a fourth classification sub-network; the first feature map is classified using the classification network on the first branch of the Siamese model to obtain a first detection image including a first detection box and a corresponding prediction score; the second feature map is classified using the classification network on the second branch of the Siamese model to obtain a second detection image including a second detection box and a corresponding prediction score, including:

[0123] The first feature map is classified using a first classification sub-network to obtain a first candidate image including candidate detection boxes; the second feature map is classified using a third classification sub-network to obtain a second candidate image including candidate detection boxes; the candidate detection boxes of the first and second candidate images are merged to obtain a target merged image; the target merged image is classified using a second classification sub-network to obtain a first detection image including the first detection box and the corresponding prediction score; the target merged image is classified using a fourth classification sub-network to obtain a second detection image including the second detection box and the corresponding prediction score.

[0124] The first and third classification subnetworks have the same network structure, as do the second and fourth classification subnetworks. In practical applications, the first, second, third, and fourth classification subnetworks can be Faster R-CNN, a type of object detection network.

[0125] In some embodiments, the server inputs a first feature map into a first classification sub-network and outputs a first candidate image including candidate detection boxes through the first classification sub-network. The server inputs a second feature map into a third classification sub-network and outputs a second candidate image including candidate detection boxes through the third classification sub-network. The server merges the candidate detection boxes in the second candidate image into the first candidate image to obtain an initial merged image. The server removes duplicate candidate boxes in the initial merged image by using a non-maximum suppression value to obtain a target merged image.

[0126] The server inputs the target merged image into the second classification sub-network, and determines the prediction score corresponding to each candidate detection box in the target merged image through the second classification sub-network, to obtain a first detection image including the first detection box and the corresponding prediction score; the server inputs the target merged image into the fourth classification sub-network, and determines the prediction score corresponding to each candidate detection box in the target merged image through the fourth classification sub-network, to obtain a second detection image including the second detection box and the corresponding prediction score.

[0127] For example, such as Figure 10 As shown, the server inputs the first feature map into the first classification sub-network 1011 on the first branch of the Siamese model to obtain the first candidate image, inputs the second feature map into the third classification sub-network 1021 on the second branch of the Siamese model to obtain the second candidate image, merges the first candidate image and the second candidate image to obtain the target merged image, inputs the target merged image into the second classification sub-network 1012 on the first branch of the Siamese model to obtain the first detection image, and inputs the target merged image into the fourth classification sub-network 1022 on the second branch of the Siamese model to obtain the second detection image.

[0128] In the above embodiments, the server merges the candidate detection boxes of the first candidate image and the second candidate image to obtain a target merged image, such that the target merged image includes all non-overlapping candidate boxes in the first and second candidate images. The target merged image is then input into the second classification sub-network and the fourth classification sub-network, respectively, so that the candidate boxes input into the second classification sub-network and the fourth classification sub-network are consistent. As a result, each first detection box included in the first detection image has a corresponding second detection box in the second detection image.

[0129] In some embodiments, the defect detection result includes a first defect detection result and a second defect detection result; determining the defect detection result of the fabric to be tested based on the prediction score of each detection box in the detection box matching pair includes: determining a first detection box matching pair that meets the difference condition and a second detection box matching pair that does not meet the difference condition based on the prediction score of each detection box in the detection box matching pair; determining a first defect detection result corresponding to the first detection box matching pair based on the prediction score of each detection box in the first detection box matching pair; and determining a second defect detection result corresponding to the second detection box matching pair based on the first feature map and the second feature map.

[0130] In the first detection box matching pair, the difference between the predicted scores of each detection box satisfies the difference condition, while the difference between the predicted scores of each detection box in the second detection box matching pair does not satisfy the difference condition; the difference between the predicted scores of each detection box in the first detection box matching pair is less than the difference between the predicted scores of each detection box in the second detection box matching pair.

[0131] The first defect detection result reflects the defect detection result of the first bounding box matching pair at the corresponding position in the fabric image. The second defect detection result reflects the defect detection result of the second bounding box matching pair at the corresponding position in the fabric image.

[0132] In some embodiments, the server determines the dissimilarity of a detection box pair based on the predicted scores of each detection box in the pair, and then determines a first detection box pair whose dissimilarity meets the dissimilarity condition, and a second detection box pair whose dissimilarity does not meet the dissimilarity condition. For the first detection box pair, the server determines the first defect detection result corresponding to the first detection box pair based on the predicted scores of the detection boxes included in the first detection box pair; for the second detection box pair, the server fuses the first feature map and the second feature map to obtain a fused feature map, and then performs classification processing on the fused feature map to obtain the second defect detection result corresponding to the second detection box pair.

[0133] In the above embodiments, the detection box matching pair includes detection boxes obtained by a classification network with two branches. The first detection box matching pair that meets the difference condition and the second detection box matching pair that does not meet the difference condition are determined by the prediction scores of the detection boxes obtained by the classification network with two branches. The first defect detection result corresponding to the first detection box matching pair and the second defect detection result corresponding to the second detection box matching pair are determined by different methods, thereby improving the accuracy of defect detection results.

[0134] In some embodiments, determining a first detection box matching pair that meets the difference condition and a second detection box matching pair that does not meet the difference condition based on the prediction scores of each detection box in the detection box matching pair includes: determining the difference degree of the detection box matching pair based on the prediction scores of each detection box in the detection box matching pair; determining the first detection box matching pair that meets the difference condition and the second detection box matching pair that does not meet the difference condition based on the difference degree; wherein the difference degree of the first detection box matching pair is less than the difference degree of the second detection box matching pair.

[0135] The difference score reflects the difference between the predicted scores of each detection box in the detection box matching pair. The larger the difference score, the greater the difference between the predicted scores of each detection box in the detection box matching pair; the smaller the difference score, the smaller the difference between the predicted scores of each detection box in the detection box matching pair.

[0136] The difference criteria include: the difference between the predicted scores of each detection box in the detection box matching pair is the difference of the top preset proportion of the difference in the difference sequence; the difference sequence is a sequence obtained by arranging the detection box matching pairs in ascending order of difference. Obviously, the difference of the top preset proportion of the difference in the difference sequence is less than the difference of the remaining pairs, that is, the difference that satisfies the difference criteria is less than the difference that does not satisfy the difference criteria.

[0137] In some embodiments, for a detection box matching pair, the divergence between the predicted scores of the two detection boxes in the pair is determined to obtain the dissimilarity of the pair. The server arranges the dissimilarity of each detection box matching pair in ascending order to obtain a dissimilarity sequence. If the dissimilarity of a detection box matching pair ranks among the top preset proportions in the dissimilarity sequence, the pair is determined to meet the dissimilarity condition and is thus designated as the first detection box matching pair. If the dissimilarity of a detection box matching pair does not rank among the top preset proportions in the dissimilarity sequence, the pair is determined not to meet the dissimilarity condition and is thus designated as the second detection box matching pair. The preset proportion can be set according to actual needs, and this embodiment does not limit it.

[0138] For example, the preset ratio can be 2 / 3, and there are 6 detection box matching pairs, namely c1, c2, c3, c4, c5 and c6. The difference of each difference box matching pair is sorted in ascending order to obtain the difference sequence: c1, c3, c4, c5, c2 and c6. Among them, the difference of c1, c3, c4 and c5 is in the first 2 / 3 of the difference sequence, thus determining that c1, c3, c4 and c5 are the first detection box matching pairs, and c2 and c6 are the second detection box matching pairs.

[0139] For example, the divergence between the predicted scores of two detection boxes in a detection box matching pair is determined to obtain the difference of the detection box matching pair, as shown in Formula (1).

[0140]

[0141] Where KL(p||q) is the difference between the detection box matching pairs, p(x) is the prediction score of the detection box corresponding to the first feature map in the detection box matching pair, and q(x) is the prediction score of the detection box corresponding to the second feature map in the detection box matching pair.

[0142] In the above embodiments, the difference degree of the detection box matching pairs is determined by the predicted scores of the detection boxes obtained by the classification network on the two branches, and then the first detection box matching pair that meets the difference condition and the second detection box matching pair that does not meet the difference condition are determined. The first detection box matching pair and the second detection box matching pair are determined by combining the predicted scores of the detection boxes obtained by the classification network on the two branches. This makes it easier to determine the first defect detection result corresponding to the first detection box matching pair and the second defect detection result corresponding to the second detection box matching pair in different ways, thereby improving the accuracy of the defect detection results.

[0143] In some embodiments, determining the second defect detection result corresponding to the second detection box matching pair based on the first feature map and the second feature map includes: fusing the first feature map and the second feature map to obtain a fused feature map; and classifying the fused feature map through a fusion classification network in a Siamese model to obtain the second defect detection result corresponding to the second detection box matching pair.

[0144] In some embodiments, the server fuses the first feature map and the second feature map to obtain a fused feature map. This fused feature map is then input into a fusion classification network within the Siamese model. The fusion classification network generates a fused detection result, which includes each fused detection box and its corresponding fusion detection score. Within each fused detection box, a target detection box corresponding to a second detection box match is determined. A second defect detection result is then determined based on the target detection box and its corresponding fusion detection score. The location information corresponding to the second detection box match is identical to the location information corresponding to the target detection box.

[0145] In some embodiments, the first feature map and the second feature map can be concatenated along the channel dimension, or they can be added together. In some embodiments, the fusion classification network can be Faster R-CNN.

[0146] In the above embodiments, for second detection box matching pairs whose difference does not meet the difference condition, the first feature map and the second feature map are fused together, and the features extracted from the two branches are combined to improve the accuracy of the second defect detection result corresponding to the second detection box matching pair.

[0147] In some embodiments, the fabric defect detection method further includes: acquiring fabric sample images, a first template sample image, and a second template sample image of the training fabric; performing feature extraction on a first sample image group composed of the fabric sample image and the first template sample image through an initial Siamese model, and performing feature extraction on a second sample image group composed of the fabric sample image and the second template sample image, wherein during the feature extraction process, some intermediate training features extracted from the first sample image group are interchanged with some intermediate training features extracted from the second sample image group to obtain a first training feature map corresponding to the first sample image group and a second training feature map corresponding to the second sample image group; through an initial Siamese model... The model classifies the first and second training feature maps to obtain the first and second training detection images, respectively. Based on the first and second training detection images, the training score of each training detection box in the training detection box matching pair is determined. The training detection boxes in the training detection box matching pair are the training detection boxes corresponding to the first and second training feature maps, respectively. Based on the training scores of each training detection box in the training detection box matching pair, the target training result of the fabric sample image is determined. Based on the defect labels of the fabric sample image and the target training result, the loss value is determined, and the initial Siamese model is adjusted by the loss value to obtain the Siamese model.

[0148] The first template sample image and the second template sample image are images taken when the training fabric is free of defects. The fabric sample image can be an image taken when the training fabric has defects or when it is free of defects.

[0149] The difference between the first template sample image and the second template sample image could be due to differences in the flexibility and deformation of the training fabric, differences in the color parameters when photographing the training fabric, or a combination of both.

[0150] The first sample image group includes a fabric sample image and a first template sample image, and the second sample image group includes a fabric sample image and a second template sample image.

[0151] The initial Siamese model has the same model structure as the Siamese model, and includes an initial feature extraction network and an initial classification network on two branches.

[0152] In some embodiments, the server acquires a sample image of the training fabric, a first template sample image, and a second template sample image. The first sample image group, including the fabric sample image and the first template sample image, is input into the initial feature extraction network on the first branch of the initial twin model for feature extraction. The second sample image group, including the fabric sample image and the second template sample image, is input into the initial feature extraction network on the second branch of the initial twin model for feature extraction. During the feature extraction process, some intermediate training features extracted from the first sample image group are interchanged with some intermediate training features extracted from the second sample image group to obtain a first training feature map and a second training feature map.

[0153] The server inputs the first training feature map into the initial classification network on the first branch of the initial Siamese model to classify the first training feature map and obtain the first training detection image. The server then inputs the second training feature map into the initial classification network on the second branch of the initial Siamese model to classify the second training feature map and obtain the second training detection image.

[0154] The first training detection image includes a first training detection box and its corresponding training score, and the second training detection image includes a second training detection box and its corresponding training score. The server determines training detection box matching pairs based on the position information of the first training detection box in the first training detection image and the position information of the second training detection box in the second training detection image, and obtains the training score of each training detection box in the matching pair. The position information corresponding to the first training detection box in the matching pair is the same as the position information corresponding to the second training detection box in the matching pair.

[0155] The server determines the training result corresponding to each training detection box pair based on the training score of each training detection box pair. Based on the training result corresponding to each training detection box pair, the server determines the target training result of the fabric sample image. The server determines the loss value based on the defect label of the fabric sample image and the target training result. The server adjusts the parameters of the initial twin model based on the loss value until the initial twin model meets the training conditions, thus obtaining the twin model.

[0156] In some embodiments, determining the training result corresponding to each training detection box pair based on the training scores of each training detection box in the training detection box pair includes: determining a first training detection box pair that meets the difference condition and a second training detection box pair that does not meet the difference condition based on the training scores of each training detection box in the training detection box pair; for the first training detection box pair, determining the average value of the training scores of each training detection box in the first training detection box pair, and determining the training result of the first training detection box pair based on the average value; for the second training detection box pair, the server fuses the first training feature map and the second training feature map, performs defect detection on the fused training feature map, and obtains the training result of the second training detection box pair.

[0157] In some embodiments, for a second training detection box matching pair, the server determines the training result of the second training detection box matching pair based on the higher training score in the second training detection box matching pair; in some embodiments, the server removes second training detection box matching pairs that do not meet the difference condition and determines the target training result of the fabric sample image based on the training result of the first detection box matching pair.

[0158] In the above embodiments, the initial twin model performs feature extraction on a first sample image group composed of a fabric sample image and a first template sample image, and performs feature extraction on a second sample image group composed of a fabric sample image and a second template sample image. Some intermediate training features extracted from the first sample image group and some intermediate training features extracted from the second sample image group are interchanged to obtain a first training feature map corresponding to the first sample image group and a second training feature map corresponding to the second sample image group. Since the first template sample image and the second template sample image are different, through feature interchange, the first training feature map includes features of the second template sample image, and the second training feature map includes features of the first template sample image. Therefore, some features of the second template sample image participate in the classification process of the first training feature map, and some features of the first template sample image participate in the classification process of the second training feature map. This allows the trained twin model to detect real defect areas, improving the quality of the twin model. Furthermore, in this embodiment, by using two different template sample images, the initial twin model can learn rich non-defect feature information during training. A twin model with higher accuracy can be trained with fewer defect labels, making it suitable for application scenarios lacking defect labels.

[0159] In some embodiments, the initial Siamese model includes an initial fusion classification network; the target training result includes a first training result and a second training result; determining the target training result of the fabric sample image based on the training scores of each training detection box in the training detection box matching pair includes: determining a first training detection box matching pair that meets the difference condition and a second training detection box matching pair that does not meet the difference condition based on the training scores of each training detection box in the training detection box matching pair; determining a first training result corresponding to the first training detection box matching pair based on the training scores of each training detection box in the first training detection box matching pair; fusing the first training feature map and the second training feature map to obtain a training fusion feature map; and classifying the training fusion feature map through the initial fusion classification network to obtain a second training result corresponding to the second training detection box matching pair.

[0160] In the first training detection box matching pair, the difference between the training scores of each training detection box satisfies the difference condition, while in the second training detection box matching pair, the difference between the training scores of each training detection box does not satisfy the difference condition; the difference between the training scores of each training detection box in the first training detection box matching pair is less than the difference between the training scores of each training detection box in the second training detection box matching pair.

[0161] The first training result reflects the training results of the first training bounding box matching pair at the corresponding position in the fabric sample image. The second training result reflects the training results of the second training bounding box matching pair at the corresponding position in the fabric sample image.

[0162] In this embodiment, the specific process by which the server determines the first training result corresponding to the first training detection box matching pair and the second training result corresponding to the second training detection box matching pair is the same as the process by which the server determines the first defect detection result corresponding to the first detection box matching pair and the second defect detection result corresponding to the second detection box matching pair in the above embodiments. Therefore, the specific process by which the server determines the first training result corresponding to the first training detection box matching pair and the second training result corresponding to the second training detection box matching pair can be referred to the specific description of the server determining the first defect detection result corresponding to the first detection box matching pair and the second defect detection result corresponding to the second detection box matching pair in the above embodiments.

[0163] In the above embodiments, the training detection box matching pair includes training detection boxes obtained from two branches of the classification network. Based on the prediction scores of the training detection boxes obtained from the two branches of the classification network, a first training detection box matching pair that meets the difference condition and a second training detection box matching pair that does not meet the difference condition are determined. The first training result corresponding to the first training detection box matching pair and the second training result corresponding to the second training detection box matching pair are determined in different ways. During the training process, the differences between a certain region in the fabric sample image and the corresponding region in the two template sample images are better learned. By combining the differences between the same regions in the two template sample images, the accuracy of defect detection of the twin model is improved.

[0164] In some embodiments, the initial Siamese model further includes an initial feature extraction network and an initial classification network on a first branch, and an initial feature extraction network and an initial classification network on a second branch; determining a loss value based on the defect labels and target training results of the fabric sample image, and adjusting the initial Siamese model using the loss value to obtain the Siamese model, includes: determining a first loss value based on the defect labels and a first training detection image of the fabric sample image; determining a second loss value based on the defect labels and a second training detection image; determining a third loss value based on the second training result and the training label corresponding to the second training result in the defect label; adjusting the parameters of the initial feature extraction network and the initial classification network on the first branch based on the first loss value, adjusting the parameters of the initial feature extraction network and the initial classification network on the second branch based on the second loss value, and adjusting the parameters of the initial fusion classification network based on the third loss value to obtain the Siamese model.

[0165] In some embodiments, the server determines a first loss value based on the defect label of the fabric sample image and the first training detection image using a preset loss function; the server determines a second loss value based on the defect label and the second training detection image using a preset loss function; and the server determines a third loss value based on the second training result and the training label corresponding to the second training result in the defect label using a preset loss function.

[0166] In some embodiments, the server determines the training score and location information of the first training detection box in the first training detection image, determines the true score and true location information corresponding to the first training detection box in the defect label, determines a first classification loss based on the training score and the corresponding true score of the first training detection box, determines a first localization loss based on the location information and the corresponding true location information of the first training detection box, and determines a first loss value based on the first classification loss and the first localization loss.

[0167] Similarly, the server determines the training score and location information of the second training detection box in the second training image, determines the real score and real location information corresponding to the second training detection box in the defect label, determines the second classification loss based on the training score and the corresponding real score of the second training detection box, determines the second localization loss based on the location information and the corresponding real location information of the second training detection box, and determines the second loss value based on the second classification loss and the second localization loss.

[0168] The server determines the training score and location information of the training detection boxes in the second training result, determines the real score and location information of the training detection boxes in the second training result in the defect label, determines the third classification loss based on the training score and the corresponding real score of the training detection boxes in the second training result, determines the third localization loss based on the location information of the training detection boxes in the second training result and the corresponding real location information, and determines the third loss value based on the third classification loss and the third localization loss.

[0169] By adjusting the parameters of the initial fusion classification network using the second training result and the corresponding training label in the defect label, the trained fusion classification network can detect defects in areas where the first branch and the second branch are difficult to distinguish.

[0170] In some embodiments, the server obtains a batch set, which includes multiple training groups consisting of fabric sample images, first template sample images, and second template sample images. Based on the defect labels, first training detection images, second training detection images, and second training results corresponding to each training group in the batch set, the server determines the first loss value, second loss value, and third loss value corresponding to the batch set through a preset loss function. Then, based on the first loss value, the parameters of the initial feature extraction network and the initial classification network on the first branch are adjusted; based on the second loss value, the parameters of the initial feature extraction network and the initial classification network on the second branch are adjusted; and based on the third loss value, the parameters of the initial fusion classification network are adjusted to obtain the Siamese model.

[0171] For example, the first loss value corresponding to the batch set is determined by a preset loss function based on the defect labels and the first training detection images corresponding to each training group. The preset loss function is shown in formula (2).

[0172]

[0173] Among them, L1(p i ,t i ) is the first loss value corresponding to the batch set, N cls p is the number of first training detection boxes in the first training detection image. i It is the training score of the first training detection box i. λ is the true training score corresponding to the first training detection box i in the defect label, λ is a preset parameter, and N is the true training score. cls t is the number of location information points in the first training detection box. i It is the position information of the first training detection box. It is the actual location information corresponding to the first training detection box in the defect label.

[0174] For example, such as Figure 11 As shown, the training process of the Siamese model includes: the server extracts features from the first template sample image and the fabric sample image through the initial feature extraction network on the first branch 1101 to obtain a first training feature map; the server extracts features from the second template sample image and the fabric sample image through the initial feature extraction network on the second branch 1102 to obtain a second training feature map; the server classifies the first training feature map through the initial classification network on the first branch 1101 to obtain a first training detection image; the server classifies the second training feature map through the initial classification network on the second branch 1102 to obtain a second training detection image; for second training detection box matching pairs with large differences between the first training detection image and the second training detection image, the server fuses the first training feature map and the second training feature map to obtain a training fused feature map; the server classifies the training fused feature map through the initial fusion classification network to obtain the second training result corresponding to the second training detection box matching pair.

[0175] Based on the defect labels and the first training detection image, a first loss value is determined. Based on the defect labels and the second training detection image, a second loss value is determined. Based on the second training result and the training label corresponding to the second training result in the defect label, a third loss value is determined. Based on the first loss value, the parameters of the initial feature extraction network and the initial classification network on the first branch 1101 are adjusted. Based on the second loss value, the parameters of the initial feature extraction network and the initial classification network on the second branch 1102 are adjusted. Based on the third loss value, the parameters of the initial fusion classification network are adjusted to obtain the Siamese model.

[0176] In the above embodiments, the parameters of the initial feature extraction network and the initial classification network on the first branch are adjusted using a first loss value, the parameters of the initial feature extraction network and the initial classification network on the second branch are adjusted using a second loss value, and the parameters of the initial fusion classification network are adjusted using a third loss value. This allows the initial feature extraction network and the initial classification network on the first branch, the initial feature extraction network and the initial classification network on the second branch, and the initial fusion classification network to be trained independently. As a result, the feature extraction network and the classification network on the first branch, as well as the feature extraction network and the classification network on the second branch, in the Siamese twin model all have independent defect detection capabilities. The fusion classification network in the Siamese twin model can detect defects in regions with large differences, thereby improving the accuracy of the Siamese twin model.

[0177] In some embodiments, the fabric defect detection method can be applied to, for example... Figure 12 In the scenario shown, the server acquires fabric image 1201 taken from the fabric to be tested on the fabric production line. The server determines the template fabric corresponding to the fabric image and acquires a first template image 1202 and a second template image 1203 of the template fabric. Neither the first template image 1202 nor the second template image 1203 contains defects. The first template image 1202 is acquired when the template fabric has wrinkles. The server inputs the first image group, composed of fabric image 1201 and the first template image 1202, into the feature extraction network 1211 on the first branch of the twin model. The server inputs the second image group, composed of fabric image 1201 and the second template image 1203, into the feature extraction network 1221 on the second branch of the twin model. During feature extraction, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group.

[0178] The server inputs the first feature map into the classification network 1212 on the first branch of the Siamese model and inputs the second feature map into the classification network 1222 on the second branch of the Siamese model to obtain a first detection image including a first detection box and a corresponding prediction score, and a second detection image including a second detection box and a corresponding prediction score.

[0179] The server determines the detection box matching pair based on the first detection image and the second detection image. Based on the prediction scores of each detection box in the detection box matching pair, it determines the first detection box matching pair that meets the difference condition and the second detection box matching pair that does not meet the difference condition. Based on the prediction scores of each detection box in the first detection box matching pair, it determines the first defect detection result corresponding to the first detection box matching pair.

[0180] The first feature map and the second feature map are fused to obtain a fused feature map. The fused feature map is then classified using the fusion classification network 1231 of the Siamese model to obtain the second defect detection result corresponding to the second detection box matching pair. The defect detection result of the fabric to be tested is determined based on the first defect detection result and the second defect detection result. The defect detection result includes the detection box corresponding to the defect area in the fabric to be tested.

[0181] After obtaining the defect detection results, the defect detection results can also be visualized through the corresponding heat map 1204. In the heat map 1204, the defect area is red (the darkest area in 1204).

[0182] In some embodiments, such as Figure 13 As shown, the methods for detecting fabric defects include:

[0183] Step 1301: The server obtains the fabric image of the fabric to be tested, and the first template image and the second template image of the template fabric;

[0184] Step 1302: The server extracts features from the first image group consisting of the fabric image and the first template image through the feature extraction network on the first branch of the twin model to obtain a first intermediate feature map; and extracts features from the second image group consisting of the fabric image and the second template image through the feature extraction network on the second branch of the twin model to obtain a second intermediate feature map.

[0185] Step 1303: The server swaps the feature sub-maps of some channels in the first intermediate feature map with the feature sub-maps of corresponding channels in the second intermediate feature map through the feature swapping sub-network in the twin model, to obtain the first intermediate feature map and the second intermediate feature map with swapped features.

[0186] Step 1304: The server extracts features from the first intermediate feature map and the second intermediate feature map that have swapped features, respectively, to obtain the first feature map corresponding to the first image group and the second feature map corresponding to the second image group.

[0187] Step 1305: The server classifies the first feature map through the first classification sub-network to obtain a first candidate image including candidate detection boxes; it classifies the second feature map through the third classification sub-network to obtain a second candidate image including candidate detection boxes; the candidate detection boxes of the first candidate image and the candidate detection boxes of the second candidate image are merged to obtain the target merged image.

[0188] Step 1306: The server classifies the merged target image through the second classification sub-network to obtain a first detection image including a first detection box and a corresponding prediction score; and classifies the merged target image through the fourth classification sub-network to obtain a second detection image including a second detection box and a corresponding prediction score.

[0189] Step 1307: The server determines the detection box matching pair and the prediction score of each detection box in the detection box matching pair based on the position information of the first detection box in the first detection image and the position information of the second detection box in the second detection image; wherein, the first detection box and the second detection box are the detection boxes in the detection box matching pair.

[0190] Step 1308: The server determines the difference degree of the detection box matching pair based on the prediction scores of each detection box in the detection box matching pair; based on the difference degree, it determines the first detection box matching pair that meets the difference condition and the second detection box matching pair that does not meet the difference condition; the difference degree of the first detection box matching pair is less than the difference degree of the second detection box matching pair.

[0191] Step 1309: The server determines the first defect detection result corresponding to the first detection box matching pair based on the predicted scores of each detection box in the first detection box matching pair.

[0192] Step 1310: The server fuses the first feature map and the second feature map to obtain a fused feature map; the fused feature map is classified by the fusion classification network in the Siamese model to obtain the second defect detection result corresponding to the second detection box matching pair; the defect detection result of the fabric to be tested includes the first defect detection result and the second defect detection result.

[0193] In the aforementioned fabric defect detection method, feature extraction is performed on a first image group composed of a fabric image and a first template image, and feature extraction is also performed on a second image group composed of a fabric image and a second template image. During the feature extraction process, some intermediate features extracted from the first image group and some intermediate features extracted from the second image group are interchanged to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group. Since the first template image and the second template image are different, through feature interchange, the first feature map includes some features of the second template image, and the second feature map includes some features of the first template image. Through sufficient feature interaction, the first feature map and the second feature map are improved. The quality of the image is improved, and some features of the second template image participate in the classification process of the first feature image. The features of the first template image participate in the classification process of the second feature image, improving the accuracy of the prediction score of the detection box. By matching the prediction scores of each detection box in the detection box matching, the defect detection result of the fabric to be tested is determined. That is, by combining the detection boxes corresponding to the first feature image and the detection boxes corresponding to the second feature image, the defect detection result of the fabric to be tested is determined. Through the first template image and the second template image, the first feature image and the second feature image contain rich non-defect feature information, which can detect the real defects of the fabric to be tested, effectively reducing the probability of false detection and improving the accuracy of defect detection.

[0194] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0195] Based on the same inventive concept, this application also provides a fabric defect detection device for implementing the fabric defect detection method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations of one or more fabric defect detection device embodiments provided below can be found in the limitations of the fabric defect detection method described above, and will not be repeated here.

[0196] In some embodiments, such as Figure 14 As shown, a fabric defect detection device is provided, comprising: an image acquisition module 1401, a feature map determination module 1402, a detection box matching pair determination module 1403, and a defect detection module 1404, wherein:

[0197] The image acquisition module 1401 is used to acquire the fabric image of the fabric to be tested, and the first template image and the second template image of the template fabric;

[0198] The feature map determination module 1402 is used to extract features from a first image group consisting of a fabric image and a first template image, and to extract features from a second image group consisting of a fabric image and a second template image. During the feature extraction process, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group.

[0199] The detection box matching pair determination module 1403 is used to classify the first feature map and the second feature map respectively to obtain the prediction score of each detection box in the detection box matching pair; the detection boxes in the detection box matching pair are the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map respectively.

[0200] The defect detection module 1404 is used to determine the defect detection result of the fabric to be tested based on the prediction score of each detection box in the detection box matching pair.

[0201] In some embodiments, the feature map determination module 1402 includes:

[0202] The intermediate feature map determination unit is used to extract features from a first image group consisting of a fabric image and a first template image to obtain a first intermediate feature map; and to extract features from a second image group consisting of a fabric image and a second template image to obtain a second intermediate feature map; the second intermediate feature map has the same scale as the first intermediate feature map;

[0203] The feature swapping unit is used to swap some features of the first intermediate feature map with some features of the second intermediate feature map to obtain a first intermediate feature map and a second intermediate feature map with swapped features.

[0204] The feature map determination unit is used to extract features from the first intermediate feature map and the second intermediate feature map that exchange features, respectively, to obtain the first feature map corresponding to the first image group and the second feature map corresponding to the second image group.

[0205] In some embodiments, the intermediate feature map determination unit is specifically used to extract features from a first image group consisting of a fabric image and a first template image through a feature extraction network on a first branch of the twin model to obtain a first intermediate feature map; and to extract features from a second image group consisting of a fabric image and a second template image through a feature extraction network on a second branch of the twin model to obtain a second intermediate feature map.

[0206] In some embodiments, the feature swapping unit is specifically used to swap feature sub-maps of some channels in the first intermediate feature map with feature sub-maps of corresponding channels in the second intermediate feature map through the feature swapping sub-network in the Siamese model.

[0207] In some embodiments, the detection box matching pair determination module 1403 includes:

[0208] The detection image determination unit is used to classify the first feature map through the classification network on the first branch of the Siamese model to obtain a first detection image including a first detection box and a corresponding prediction score; and to classify the second feature map through the classification network on the second branch of the Siamese model to obtain a second detection image including a second detection box and a corresponding prediction score.

[0209] The detection box matching pair determination unit is used to determine the detection box matching pair and the prediction score of each detection box in the detection box matching pair based on the position information of the first detection box in the first detection image and the position information of the second detection box in the second detection image; wherein, the first detection box and the second detection image are the detection boxes in the detection box matching pair.

[0210] In some embodiments, the detection image determination unit is specifically configured to: classify the first feature map through a first classification sub-network to obtain a first candidate image including candidate detection boxes; classify the second feature map through a third classification sub-network to obtain a second candidate image including candidate detection boxes; merge the candidate detection boxes of the first candidate image and the candidate detection boxes of the second candidate image to obtain a target merged image; classify the target merged image through a second classification sub-network to obtain a first detection image including the first detection box and the corresponding prediction score; and classify the target merged image through a fourth classification sub-network to obtain a second detection image including the second detection box and the corresponding prediction score.

[0211] In some embodiments, the defect detection result includes a first defect detection result and a second defect detection result; the defect detection module 1404 includes:

[0212] The difference condition determination unit is used to determine the first detection box matching pair that meets the difference condition and the second detection box matching pair that does not meet the difference condition based on the prediction scores of each detection box in the detection box matching pair.

[0213] The first defect detection result determination unit is used to determine the first defect detection result corresponding to the first detection box matching pair based on the prediction score of each detection box in the first detection box matching pair.

[0214] The second defect detection result determination unit is used to determine the second defect detection result corresponding to the second detection box matching pair based on the first feature map and the second feature map.

[0215] In some embodiments, the difference condition determination unit is specifically used to determine the difference degree of the detection box matching pair based on the prediction score of each detection box in the detection box matching pair; and to determine a first detection box matching pair that meets the difference condition and a second detection box matching pair that does not meet the difference condition based on the difference degree; the difference degree of the first detection box matching pair is less than the difference degree of the second detection box matching pair.

[0216] In some embodiments, the second defect detection result determination unit is specifically used to perform fusion processing on the first feature map and the second feature map to obtain a fused feature map; and to perform classification processing on the fused feature map through the fusion classification network in the Siamese model to obtain the second defect detection result corresponding to the second detection box matching pair.

[0217] In some embodiments, the fabric defect detection device further includes:

[0218] The twin model training module is used to acquire fabric sample images, a first template sample image, and a second template sample image for training fabric. Through an initial twin model, feature extraction is performed on the first sample image group composed of the fabric sample image and the first template sample image, and feature extraction is also performed on the second sample image group composed of the fabric sample image and the second template sample image. During the feature extraction process, some intermediate training features extracted from the first sample image group are interchanged with some intermediate training features extracted from the second sample image group, resulting in a first training feature map corresponding to the first sample image group and a second training feature map corresponding to the second sample image group. Through the initial twin model, [the module further analyzes and analyzes the process]. The first and second training feature maps are classified separately to obtain the first and second training detection images. Based on the first and second training detection images, the training score of each training detection box in the training detection box matching pair is determined. The training detection boxes in the training detection box matching pair are the training detection boxes corresponding to the first and second training feature maps, respectively. Based on the training scores of each training detection box in the training detection box matching pair, the target training result of the fabric sample image is determined. Based on the defect label of the fabric sample image and the target training result, the loss value is determined, and the initial Siamese model is adjusted through the loss value to obtain the Siamese model.

[0219] In some embodiments, the target training result includes a first training result and a second training result, and the Siamese twin model training module includes:

[0220] The target training result determination unit is used to determine, based on the training scores of each training detection box in the training detection box matching pair, a first training detection box matching pair that meets the difference condition and a second training detection box matching pair that does not meet the difference condition; based on the training scores of each training detection box in the first training detection box matching pair, determine the first training result corresponding to the first training detection box matching pair; fuse the first training feature map and the second training feature map to obtain a training fused feature map; and perform classification processing on the training fused feature map through an initial fusion classification network to obtain the second training result corresponding to the second training detection box matching pair.

[0221] In some embodiments, the twin model training module includes:

[0222] The parameter adjustment unit is used to determine a first loss value based on the defect label of the fabric sample image and the first training detection image; determine a second loss value based on the defect label and the second training detection image; determine a third loss value based on the second training result and the training label corresponding to the second training result in the defect label; adjust the parameters of the initial feature extraction network and the initial classification network on the first branch based on the first loss value; adjust the parameters of the initial feature extraction network and the initial classification network on the second branch based on the second loss value; and adjust the parameters of the initial fusion classification network based on the third loss value to obtain the Siamese model.

[0223] Each module in the aforementioned fabric defect detection device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the computer device's memory as software, so that the processor can call and execute the corresponding operations of each module.

[0224] In some embodiments, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 15 As shown, the computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data for a first template image, a second template image, and a twin model. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When executed by the processor, the computer program implements a method for detecting defects in fabric.

[0225] Those skilled in the art will understand that Figure 15 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0226] In some embodiments, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0227] Acquire the fabric image of the fabric to be tested, and the first and second template images of the template fabric;

[0228] Feature extraction is performed on a first image group consisting of a fabric image and a first template image, and feature extraction is also performed on a second image group consisting of a fabric image and a second template image. During the feature extraction process, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group.

[0229] The first feature map and the second feature map are classified separately to obtain the prediction score of each detection box in the detection box matching pair; the detection boxes in the detection box matching pair are the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map.

[0230] Based on the predicted scores of each detection box in the detection box matching pair, the defect detection result of the fabric to be tested is determined.

[0231] In some embodiments, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, performs the following steps:

[0232] Acquire the fabric image of the fabric to be tested, and the first and second template images of the template fabric;

[0233] Feature extraction is performed on a first image group consisting of a fabric image and a first template image, and feature extraction is also performed on a second image group consisting of a fabric image and a second template image. During the feature extraction process, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group.

[0234] The first feature map and the second feature map are classified separately to obtain the prediction score of each detection box in the detection box matching pair; the detection boxes in the detection box matching pair are the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map.

[0235] Based on the predicted scores of each detection box in the detection box matching pair, the defect detection result of the fabric to be tested is determined.

[0236] In some embodiments, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0237] Acquire the fabric image of the fabric to be tested, and the first and second template images of the template fabric;

[0238] Feature extraction is performed on a first image group consisting of a fabric image and a first template image, and feature extraction is also performed on a second image group consisting of a fabric image and a second template image. During the feature extraction process, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group.

[0239] The first feature map and the second feature map are classified separately to obtain the prediction score of each detection box in the detection box matching pair; the detection boxes in the detection box matching pair are the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map.

[0240] Based on the predicted scores of each detection box in the detection box matching pair, the defect detection result of the fabric to be tested is determined.

[0241] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0242] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0243] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0244] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for detecting defects in fabric, characterized in that, The method includes: Acquire the fabric image of the fabric to be tested, and the first and second template images without defects; Feature extraction is performed on a first image group consisting of the fabric image and the first template image, and feature extraction is performed on a second image group consisting of the fabric image and the second template image. During the feature extraction process, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group. The first feature map and the second feature map are classified separately to obtain the prediction score of each detection box in the detection box matching pair; the detection boxes in the detection box matching pair are the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map, and the detection box matching pair includes the matching pair determined based on the first detection box in the first detection image and the second detection box in the second detection image. The first detection box and the second detection box correspond to the same area of ​​the fabric to be tested. The first detection image and the second detection image are obtained by classifying the first feature map and the second feature map respectively. Based on the prediction scores of each detection box in the detection box matching pair, the defect detection result of the fabric to be tested is determined.

2. The method according to claim 1, characterized in that, The step of extracting features from a first image group composed of the fabric image and the first template image, and from a second image group composed of the fabric image and the second template image, and exchanging some intermediate features extracted from the first image group with some intermediate features extracted from the second image group during the feature extraction process, to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group, includes: Feature extraction is performed on the first image group composed of the fabric image and the first template image to obtain a first intermediate feature map; Feature extraction is performed on the second image group composed of the fabric image and the second template image to obtain a second intermediate feature map; the second intermediate feature map has the same scale as the first intermediate feature map; By swapping some features of the first intermediate feature map with some features of the second intermediate feature map, a first intermediate feature map and a second intermediate feature map with the swapped features are obtained. Feature extraction is performed on the first intermediate feature map and the second intermediate feature map that exchange the aforementioned partial features, respectively, to obtain the first feature map corresponding to the first image group and the second feature map corresponding to the second image group.

3. The method according to claim 2, characterized in that, The first image group composed of the fabric image and the first template image is subjected to feature extraction to obtain a first intermediate feature map; Feature extraction is performed on the second image group composed of the fabric image and the second template image to obtain a second intermediate feature map, including: The first intermediate feature map is obtained by extracting features from the first image group composed of the fabric image and the first template image through the feature extraction network on the first branch of the twin model. The second intermediate feature map is obtained by extracting features from the second image group composed of the fabric image and the second template image through the feature extraction network on the second branch of the twin model.

4. The method according to claim 2, characterized in that, The first intermediate feature map contains some features, and the second intermediate feature map contains some features, including feature sub-maps of some channels; The step of swapping some features of the first intermediate feature map with some features of the second intermediate feature map includes: The feature sub-network in the Siamese model is used to swap the feature sub-maps of some channels in the first intermediate feature map with the feature sub-maps of the corresponding channels in the second intermediate feature map.

5. The method according to claim 1, characterized in that, The step of classifying the first feature map and the second feature map respectively to obtain the prediction score of each detection box in the detection box matching pair includes: The first feature map is classified by the classification network on the first branch of the Siamese model to obtain a first detection image including a first detection box and the corresponding prediction score; The second feature map is classified by the classification network on the second branch of the twin model to obtain a second detection image including a second detection box and the corresponding prediction score. Based on the position information of the first detection box in the first detection image and the position information of the second detection box in the second detection image, a detection box matching pair and the prediction score of each detection box in the detection box matching pair are determined; wherein, the first detection box and the second detection box are detection boxes in the detection box matching pair.

6. The method according to claim 5, characterized in that, The classification network on the first branch includes a first classification subnetwork and a second classification subnetwork, and the classification network on the second branch includes a third classification subnetwork and a fourth classification subnetwork. The process of classifying the first feature map using a classification network on the first branch of the Siamese model to obtain a first detection image including a first detection box and a corresponding prediction score; and classifying the second feature map using a classification network on the second branch of the Siamese model to obtain a second detection image including a second detection box and a corresponding prediction score, includes: The first feature map is classified by the first classification sub-network to obtain a first candidate image including candidate detection boxes; The second feature map is classified by the third classification sub-network to obtain a second candidate image including candidate detection boxes; The candidate detection boxes of the first candidate image and the candidate detection boxes of the second candidate image are merged to obtain the target merged image; The target merged image is classified by the second classification sub-network to obtain a first detection image including a first detection box and a corresponding prediction score; The target merged image is classified by the fourth classification sub-network to obtain a second detection image including a second detection box and the corresponding prediction score.

7. The method according to claim 1, characterized in that, The defect detection results include a first defect detection result and a second defect detection result; determining the defect detection result of the fabric to be tested based on the prediction scores of each detection box in the detection box matching pair includes: Based on the predicted scores of each detection box in the detection box matching pair, a first detection box matching pair that meets the difference condition and a second detection box matching pair that does not meet the difference condition are determined. Based on the predicted scores of each detection box in the first detection box matching pair, the first defect detection result corresponding to the first detection box matching pair is determined; Based on the first feature map and the second feature map, the second defect detection result corresponding to the second detection box matching pair is determined.

8. The method according to claim 7, characterized in that, The step of determining a first detection box matching pair that meets the difference condition and a second detection box matching pair that does not meet the difference condition based on the prediction scores of each detection box in the detection box matching pair includes: Based on the prediction scores of each detection box in the detection box matching pair, the difference degree of the detection box matching pair is determined; Based on the difference degree, a first detection box matching pair that meets the difference condition and a second detection box matching pair that does not meet the difference condition are determined; the difference degree of the first detection box matching pair is less than the difference degree of the second detection box matching pair.

9. The method according to claim 7, characterized in that, The step of determining the second defect detection result corresponding to the second detection box matching pair based on the first feature map and the second feature map includes: The first feature map and the second feature map are fused to obtain a fused feature map. The fused feature map is classified by the fusion classification network in the Siamese model to obtain the second defect detection result corresponding to the second detection box matching pair.

10. The method according to any one of claims 3-6 and 9, characterized in that, The method further includes: Obtain the fabric sample image, the first template sample image, and the second template sample image of the training fabric; Using an initial Siamese model, feature extraction is performed on a first sample image group consisting of the fabric sample image and the first template sample image, and feature extraction is performed on a second sample image group consisting of the fabric sample image and the second template sample image. During the feature extraction process, some intermediate training features extracted from the first sample image group are interchanged with some intermediate training features extracted from the second sample image group to obtain a first training feature map corresponding to the first sample image group and a second training feature map corresponding to the second sample image group. Using the initial twin model, the first training feature map and the second training feature map are classified respectively to obtain the first training detection image and the second training detection image. Based on the first training detection image and the second training detection image, the training score of each training detection box in the training detection box matching pair is determined; the training detection boxes in the training detection box matching pair are the training detection boxes corresponding to the first training feature map and the training detection boxes corresponding to the second training feature map. Based on the training scores of each training detection box in the training detection box matching pair, the target training result of the fabric sample image is determined. The loss value is determined based on the defect labels of the fabric sample images and the target training results, and the initial twin model is adjusted using the loss value to obtain the twin model.

11. The method according to claim 10, characterized in that, The initial Siamese model includes an initial fusion classification network; the target training result includes a first training result and a second training result. The step of determining the target training result of the fabric sample image based on the training scores of each training detection box in the training detection box matching pair includes: Based on the training scores of each training detection box in the training detection box matching pair, a first training detection box matching pair that meets the difference condition and a second training detection box matching pair that does not meet the difference condition are determined. Based on the training scores of each training detection box in the first training detection box matching pair, the first training result corresponding to the first training detection box matching pair is determined. The first training feature map and the second training feature map are fused to obtain a training fused feature map; The training fusion feature map is classified by the initial fusion classification network to obtain the second training result corresponding to the second training detection box matching pair.

12. The method according to claim 11, characterized in that, The initial twin model also includes an initial feature extraction network and an initial classification network on the first branch, as well as an initial feature extraction network and an initial classification network on the second branch; The process of determining a loss value based on the defect labels of the fabric sample image and the target training result, and adjusting the initial Siamese model using the loss value to obtain the Siamese model, includes: Based on the defect labels of the fabric sample images and the first training detection images, a first loss value is determined; Based on the defect label and the second training detection image, a second loss value is determined; Based on the second training result and the training label corresponding to the second training result in the defect label, a third loss value is determined; The parameters of the initial feature extraction network and the initial classification network on the first branch are adjusted based on the first loss value, the parameters of the initial feature extraction network and the initial classification network on the second branch are adjusted based on the second loss value, and the parameters of the initial fusion classification network are adjusted based on the third loss value to obtain the Siamese model.

13. A defect detection device for fabric, characterized in that, The device includes: The image acquisition module is used to acquire the fabric image of the fabric to be tested, the first template image without defects, and the second template image. The feature map determination module is used to extract features from a first image group composed of the fabric image and the first template image, and to extract features from a second image group composed of the fabric image and the second template image. During the feature extraction process, some intermediate features extracted from the first image group are interchanged with some intermediate features extracted from the second image group to obtain a first feature map corresponding to the first image group and a second feature map corresponding to the second image group. The detection box matching pair determination module is used to classify the first feature map and the second feature map respectively to obtain the prediction score of each detection box in the detection box matching pair; the detection boxes in the detection box matching pair are the detection boxes corresponding to the first feature map and the detection boxes corresponding to the second feature map, and the detection box matching pair includes matching pairs determined based on the first detection box in the first detection image and the second detection box in the second detection image, the first detection box and the second detection box correspond to the same area of ​​the fabric to be tested, and the first detection image and the second detection image are obtained by classifying the first feature map and the second feature map respectively; The defect detection module is used to determine the defect detection result of the fabric to be tested based on the prediction score of each detection box in the detection box matching pair.

14. The apparatus according to claim 13, characterized in that, The feature map determination module includes: The intermediate feature map determination unit is used to extract features from a first image group composed of the fabric image and the first template image to obtain a first intermediate feature map; and to extract features from a second image group composed of the fabric image and the second template image to obtain a second intermediate feature map; the second intermediate feature map has the same scale as the first intermediate feature map; A feature swapping unit is used to swap some features of the first intermediate feature map with some features of the second intermediate feature map to obtain a first intermediate feature map and a second intermediate feature map with swapped features. The feature map determination unit is used to extract features from the first intermediate feature map and the second intermediate feature map that have swapped some of the features, respectively, to obtain the first feature map corresponding to the first image group and the second feature map corresponding to the second image group.

15. The apparatus according to claim 14, characterized in that, The intermediate feature map determination unit is further configured to extract features from the first image group composed of the fabric image and the first template image through the feature extraction network on the first branch of the twin model to obtain the first intermediate feature map. The second intermediate feature map is obtained by extracting features from the second image group composed of the fabric image and the second template image through the feature extraction network on the second branch of the twin model.

16. The apparatus according to claim 14, characterized in that, The first intermediate feature map contains some features, and the second intermediate feature map contains some features, including feature sub-maps of some channels; The feature swapping unit is further configured to swap feature sub-maps of some channels in the first intermediate feature map with feature sub-maps of corresponding channels in the second intermediate feature map through the feature swapping sub-network in the twin model.

17. The apparatus according to claim 13, characterized in that, The detection box matching and determination module includes: The detection image determination unit is used to classify the first feature map through a classification network on the first branch of the Siamese model to obtain a first detection image including a first detection box and a corresponding prediction score; and to classify the second feature map through a classification network on the second branch of the Siamese model to obtain a second detection image including a second detection box and a corresponding prediction score. The detection box matching pair determination unit is used to determine the detection box matching pair and the prediction score of each detection box in the detection box matching pair based on the position information of the first detection box in the first detection image and the position information of the second detection box in the second detection image; wherein, the first detection box and the second detection box are the detection boxes in the detection box matching pair.

18. The apparatus according to claim 17, characterized in that, The classification network on the first branch includes a first classification subnetwork and a second classification subnetwork, and the classification network on the second branch includes a third classification subnetwork and a fourth classification subnetwork. The detection image determination unit is further configured to classify the first feature map through the first classification sub-network to obtain a first candidate image including candidate detection boxes; and to classify the second feature map through the third classification sub-network to obtain a second candidate image including candidate detection boxes. The candidate detection boxes of the first candidate image and the candidate detection boxes of the second candidate image are merged to obtain the target merged image; The target merged image is classified by the second classification sub-network to obtain a first detection image including a first detection box and a corresponding prediction score; the target merged image is classified by the fourth classification sub-network to obtain a second detection image including a second detection box and a corresponding prediction score.

19. The apparatus according to claim 13, characterized in that, The defect detection results include the first defect detection result and the second defect detection result; The defect detection module includes: The difference condition determination unit is used to determine, based on the prediction scores of each detection box in the detection box matching pair, a first detection box matching pair that meets the difference condition and a second detection box matching pair that does not meet the difference condition; The first defect detection result determination unit is used to determine the first defect detection result corresponding to the first detection box matching pair based on the prediction score of each detection box in the first detection box matching pair. The second defect detection result determination unit is used to determine the second defect detection result corresponding to the second detection box matching pair based on the first feature map and the second feature map.

20. The apparatus according to claim 19, characterized in that, The difference condition determination unit is further configured to determine the difference degree of the detection box matching pair based on the prediction score of each detection box in the detection box matching pair; and to determine a first detection box matching pair that meets the difference condition and a second detection box matching pair that does not meet the difference condition based on the difference degree. The difference between the first detection box matching pair is less than the difference between the second detection box matching pair.

21. The apparatus according to claim 19, characterized in that, The second defect detection result determination unit is further configured to perform fusion processing on the first feature map and the second feature map to obtain a fused feature map; and to perform classification processing on the fused feature map through the fusion classification network in the Siamese model to obtain the second defect detection result corresponding to the second detection box matching pair.

22. The apparatus according to any one of claims 15-18, 21, characterized in that, The device further includes: The twin model training module is used to acquire fabric sample images, a first template sample image, and a second template sample image of the training fabric. Through an initial twin model, it performs feature extraction on a first sample image group composed of the fabric sample image and the first template sample image, and also performs feature extraction on a second sample image group composed of the fabric sample image and the second template sample image. During the feature extraction process, some intermediate training features extracted from the first sample image group are interchanged with some intermediate training features extracted from the second sample image group, resulting in a first training feature map corresponding to the first sample image group and a second training feature map corresponding to the second sample image group. Through the initial twin model, the first training feature map is then processed... The first training detection image and the second training feature image are classified to obtain a first training detection image and a second training detection image. Based on the first training detection image and the second training detection image, the training score of each training detection box in the training detection box matching pair is determined. The training detection boxes in the training detection box matching pair are the training detection boxes corresponding to the first training feature image and the training detection boxes corresponding to the second training feature image, respectively. Based on the training scores of each training detection box in the training detection box matching pair, the target training result of the fabric sample image is determined. Based on the defect label of the fabric sample image and the target training result, a loss value is determined, and the initial Siamese model is adjusted using the loss value to obtain the Siamese model.

23. The apparatus according to claim 22, characterized in that, The initial twin model includes an initial fusion classification network; The target training result includes a first training result and a second training result; The twin model training module includes: The target training result determination unit is used to determine, based on the training scores of each training detection box in the training detection box matching pair, a first training detection box matching pair that meets the difference condition and a second training detection box matching pair that does not meet the difference condition; based on the training scores of each training detection box in the first training detection box matching pair, determine the first training result corresponding to the first training detection box matching pair; fuse the first training feature map and the second training feature map to obtain a training fusion feature map; and perform classification processing on the training fusion feature map through the initial fusion classification network to obtain the second training result corresponding to the second training detection box matching pair.

24. The apparatus according to claim 23, characterized in that, The initial twin model also includes an initial feature extraction network and an initial classification network on the first branch, as well as an initial feature extraction network and an initial classification network on the second branch; The twin model training module includes: The parameter adjustment unit is used to determine a first loss value based on the defect label of the fabric sample image and the first training detection image; determine a second loss value based on the defect label and the second training detection image; determine a third loss value based on the second training result and the training label corresponding to the second training result in the defect label; adjust the parameters of the initial feature extraction network and the initial classification network on the first branch based on the first loss value; adjust the parameters of the initial feature extraction network and the initial classification network on the second branch based on the second loss value; and adjust the parameters of the initial fusion classification network based on the third loss value to obtain the Siamese model.

25. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 12.

26. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 12.

27. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Defect detection model training method, defect detection method and related device

    CN111814867A

  • Target object defect detection method and device, target object model training method and device, equipment and medium

    CN115131283A