Textile defect detection method and system, storage medium and electronic equipment
An automated defect detection method optimized by instance segmentation model and composite loss function solves the problems of subjectivity and low efficiency in manual inspection of textiles, and achieves high-precision and full-coverage defect detection, which is applicable to the identification and quantification of defects in various textiles.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- AITU (ZHEJIANG) INTELLIGENT SEWING TECHNOLOGY CO LTD
- Filing Date
- 2025-12-29
- Publication Date
- 2026-04-14
AI Technical Summary
Current textile quality inspection mainly relies on manual visual inspection, which has problems such as strong subjectivity, low efficiency, and high rate of missed detection, and is particularly difficult to detect minor defects.
An instance segmentation model is used for automated defect detection. Through image acquisition, preprocessing, and instance segmentation, the model identifies the location, type, and quantification parameters of defects. A composite loss function is used to optimize the model accuracy, adapting to the complex structure of textiles and various defect types.
It achieves high-precision, full-coverage automated detection of textile defects, reduces labor costs, and improves detection efficiency and accuracy. It is applicable to the identification and quantification of various textile defects.
Smart Images

Figure CN121860971A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of textile industry quality inspection technology, and relates to a method, system, storage medium and electronic equipment for detecting defects in textiles. Background Technology
[0002] Currently, the quality inspection of textiles in the textile industry still mainly relies on traditional manual visual inspection methods, which have many significant and unavoidable drawbacks:
[0003] First, it is highly subjective and lacks consistent standards. Inspection results rely entirely on the experience, focus, and mental state of the quality inspectors; different personnel have significantly different thresholds for judging defects and defining their severity. Second, it is inefficient and costly. Manual inspection cannot keep up with the production pace of modern high-speed overlock sewing machines, resulting in high labor costs. Third, it is prone to fatigue and missed detections, posing significant risks. Prolonged and repetitive visual screening easily leads to eye fatigue, causing distraction and missed detections. This is especially true for subtle defects in textiles, such as minor skipped stitches and fine frayed edges, which are small in size and have low contrast with the fabric background, making manual inspection extremely difficult.
[0004] Therefore, there is an urgent need for a high-precision, automated, and comprehensive textile defect detection technology. Summary of the Invention
[0005] This application provides a method, system, storage medium, and electronic device for detecting defects in textiles, which addresses the problems of existing detection schemes being highly subjective, inefficient, and having a high rate of missed detections.
[0006] In a first aspect, this application provides a method for detecting defects in textiles, comprising: acquiring an image of a textile, wherein the image's clarity and static state meet preset conditions; determining a key region in the image where the textile features are located; determining multiple sub-images corresponding to the key region; preprocessing the sub-images to obtain a target image; and determining the location information, type, and quantization parameters of the defects based on an instance segmentation model and the target image, wherein the quantization parameters are geometric morphology parameters reflecting the defect contour.
[0007] In one implementation of the first aspect, determining the location information, type, and quantization parameters of the defect based on the instance segmentation model and the target image includes: determining the location information, type, and contour parameters of the defect based on the detection head and segmentation head of the network structure in the instance segmentation model and the target image; and determining the corresponding quantization parameters based on the type of the defect and the contour parameters of the defect.
[0008] In one implementation of the first aspect, the loss function used during training of the instance segmentation model includes a detection task loss and a segmentation task loss.
[0009] In one implementation of the first aspect, acquiring the image of the textile includes: determining whether the image clarity meets the requirements of a first preset value; if it does, determining whether the image is in a static state; if it is in a static state, triggering the acquisition of the image of the overlock stitch.
[0010] In one implementation of the first aspect, the plurality of sub-images are a plurality of adjacent sub-images, the plurality of adjacent sub-images including overlapping regions, the extent of the overlapping regions being determined according to the number of sub-images; and the preprocessing includes image grayscale processing.
[0011] In one implementation of the first aspect, determining the quantization parameters of the defect based on the instance segmentation model and the target image includes: determining the contour parameters of the target image based on the instance segmentation model; if the quantization parameter is a defect area parameter, then performing pixel filling processing on the contour region based on the contour parameter; determining the area of the defect based on the filled contour region; if the quantization parameter is a defect height parameter, then performing pixel filling processing on the contour region based on the contour parameter; determining the area of the defect based on the filled contour region; and determining the height value of the defect based on the area of the defect.
[0012] In one implementation of the first aspect, the types of defects include skipped stitches, broken threads, arching, wavy lines, wrinkles, frayed edges, double-sided bends, and blemishes; the quantification parameter of the blemishes is the defect area parameter; and the quantification parameters of the double-sided bends and frayed edges are defect height parameters.
[0013] Secondly, this application provides a textile defect detection system, the system comprising: an image acquisition module for acquiring images of textiles, wherein the clarity and stillness of the images meet preset conditions; an image processing module for processing the images of textiles to obtain a target image; and a model calculation module for determining the location information, type, and quantization parameters of defects based on an instance segmentation model and the target image, wherein the quantization parameters are geometric morphology parameters reflecting the contour of the defects.
[0014] Thirdly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the textile defect detection method described in any of the implementations of the first aspect.
[0015] Fourthly, this application provides an electronic device, the electronic device comprising: a memory storing a computer program thereon; and a processor communicatively connected to the memory, which, when executing the computer program, implements the textile defect detection method described in any of the implementations of the first aspect.
[0016] As described above, the textile defect detection method, system, and equipment of this application have the following beneficial effects:
[0017] This application enables automatic and accurate identification and severity determination of various defects through instance segmentation model, reducing the cost and error of manual inspection. The system or equipment can work around the clock, reducing the burden on operators and improving the automation level and inspection efficiency of the production process.
[0018] The instance segmentation model in this application adopts an integrated training and inference framework of "data input, model self-learning, and result output". During model training, it learns directly from labeled data, without the need for complex post-processing or multi-stage algorithm design. This end-to-end training mode simplifies the data processing flow, significantly reduces development difficulty and manpower costs, avoids the problem of multi-stage error accumulation, shortens the model training cycle, and effectively adapts to the rapid deployment needs of industrial scenarios.
[0019] The instance segmentation model of this application can not only accurately separate textile defects from the background such as fabric and sewing table in an image, but also independently identify and delineate the contours of multiple targets in the same category (such as multiple point defects in a single stitch), outputting a unique binary mask and location information for each defect; it can accurately extract the complete contour of the defect through pixel-level segmentation, providing basic data for the quantitative calculation of geometric parameters such as defect area, height, and length, effectively solving the problem that traditional detection cannot accurately describe the morphology of defects, making the detection results more refined and intuitive, and thus providing a reliable basis for assessing the severity of stitch defects, determining their type, and prioritizing repairs, helping subsequent machine operators to match and output more accurate equipment parameters.
[0020] This application also supports the simultaneous identification and differentiation of multiple types of defects. It can simultaneously process various defects in textiles, such as skipped stitches, arching, and curling edges, and can independently mark the location and shape of each defect to avoid confusion.
[0021] The instance segmentation model of this application has strong robustness. By preprocessing the acquired images and learning the exclusive features of stitches and defects through deep learning models, it can effectively resist environmental interference such as fabric texture and lighting changes, accurately distinguish defects from normal stitch structures (such as the interval between skipped stitches and normal stitches, arching and natural fabric undulations), and achieve full-type, high-precision, and automated detection of overlock stitch defects.
[0022] This application has broad applicability and scalability, and can handle different types of textile defects. Whether it is a skipped stitch, a broken thread, or a complex form of defect such as buckling or wrinkling, this method can accurately detect them. This method is also applicable to defect detection in the textile production process. Attached Figure Description
[0023] Figure 1 The diagram shown is a flowchart of the textile defect detection method described in the embodiments of this application.
[0024] Figure 2 The diagram shown is a schematic representation of a defect outline as described in an embodiment of this application.
[0025] Figure 3 The diagram shows a point-type defect as described in the embodiments of this application.
[0026] Figure 4 The image shown is a mask of the point-type defect described in the embodiments of this application.
[0027] Figure 5 The image shown is a defect detection effect diagram with the quantification parameter being a height value, as described in the embodiments of this application.
[0028] Figure 6 The diagram shown is a structural schematic of the textile defect detection system described in an embodiment of this application.
[0029] Figure 7 The diagram shown is a structural schematic of the textile defect detection device described in the embodiments of this application.
[0030] Figure 8 The diagram shown is a structural schematic of an electronic device according to an embodiment of this disclosure.
[0031] Component designation explanation
[0032] 11 Detection box 31 Virtual edge defect outline area 12 Coordinate points of the defect contour on both sides 32 Coordinates of the outline of the virtual edge defect 13 Two-sided flaw outline area 33 First contour coordinate point 14 Filled out the blemish outline area on both sides 34 Second contour coordinate point 21 Defect contour coordinates of the point of impact 41 Image acquisition module 22 Imperfection contour area of the puncture point 42 Defect inspection workbench 23 The imperfection contour area after filling the puff points Detailed Implementation
[0033] The following specific examples illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be noted that, unless otherwise specified, the following embodiments and features in the embodiments can be combined with each other.
[0034] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this application. Therefore, the drawings only show the components related to this application and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0035] Overlock stitching is a core process in the production of textiles such as clothing and home textiles. The quality of the stitches directly determines the product's durability, longevity, and visual appeal, and is a crucial factor for companies to control after-sales costs. In modern high-speed textile production, overlock sewing machines can sew thousands of stitches per minute. If stitch defects are not detected in time, not only will a large number of substandard products enter the market, but it will also significantly increase rework costs and brand damage for companies. Therefore, achieving efficient, accurate, and comprehensive detection of overlock stitch defects is an essential requirement for the high-quality development of the textile industry. However, current detection solutions in the industry are unable to meet the actual needs of industrial production due to technological limitations. Contact sensors can only identify physical interruptions such as broken threads and cannot detect the specific morphological characteristics of defects; basic machine vision, lacking targeted algorithms and systematic design, has a high false alarm and false negative rate and struggles to simultaneously identify multiple core defects. Therefore, there is an urgent need to propose an efficient, accurate, comprehensive, and automated defect detection solution.
[0036] It's important to note that image segmentation algorithms refer to a class of methods that use image processing techniques to semantically divide an image into different regions. By labeling each pixel in the image with its category (e.g., target, background) through pixel-level semantic classification, they achieve separation of the target from the background. Their core function is to extract the overall region of the target in the image. Common classifications include semantic segmentation and instance segmentation. Instance segmentation algorithms, in particular, further distinguish different individual targets within the same category (e.g., different points in a line) by completing pixel-level semantic classification and instance-level differentiation. This algorithm not only achieves accurate pixel-level segmentation but also independently identifies instances, making it suitable for scenarios requiring precise localization of multiple similar targets, such as simultaneous detection of multiple defects.
[0037] It should also be noted that the instance segmentation model is the engineering implementation of the instance segmentation algorithm. This model uses a deep learning network as its core architecture, coupled with an adaptive loss function, to provide a complete technical solution that stably implements the functionality of the instance segmentation algorithm. The network structure is the functional framework of the model, typically consisting of a backbone network (responsible for extracting multi-scale image features), a feature fusion module (enhancing target feature responses), and a detection head and segmentation head (with dual branches outputting target category, location, and pixel-level mask), undertaking the entire process of feature extraction, target localization, and contour delineation. The loss function is the basis for optimizing the model's accuracy. By calculating the error between the model output and the ground truth annotations (such as bounding box localization error and mask contour error), it guides the network structure to adjust its internal parameters. Common types include regression loss for localization optimization, classification loss for category determination, and segmentation loss for contour accuracy optimization.
[0038] In the field of textile defect detection, existing instance segmentation models still have significant adaptation deficiencies and cannot be directly applied to stitch defect detection. This application designs a dedicated feature extraction logic for the network structure specifically for the unique three-dimensional complex structural defects of textiles. This logic can accurately and quantitatively capture subtle and complex defect features such as skipped stitches and arching. The loss function in this application is precisely adapted to the needs of stitch defect detection, and can also achieve accurate detection of defects with low contrast, small size, and complex morphological features, thus meeting the industrial needs of the textile industry for high-precision detection of all types of defects.
[0039] It should be noted that the textile defect detection method described in this application has broad applicability and is suitable for defect detection scenarios in various textiles, including but not limited to fabric weaving defects (such as broken threads, skipped stitches, and stains), sewing defects (such as skipped stitches, loose edges, and curled edges), and garment splicing defects (such as misalignment and missing seams). It is particularly well-suited to the core requirements of real-time, accurate, and industrially robust defect detection in high-speed mass production scenarios. Among these, the detection of defects in overlock stitches exhibits typical industrial characteristics such as complex stitch morphology, large differences in defect size, and fast production pace. The following will use this scenario as an example to provide a detailed description of the textile defect detection method in conjunction with the accompanying drawings.
[0040] like Figure 1 As shown, the following embodiments of this application provide a method for detecting textile defects, including: an image acquisition module acquiring an image of a textile (such as overlock stitches), wherein the image clarity and static state meet preset conditions; an image processing module determining the key region where the textile features (such as overlock stitches) are located in the image; the image processing module determining multiple sub-images corresponding to the key region; the image processing module preprocessing the sub-images to obtain a target image; and a model calculation module determining the location information, type, and quantization parameters of the defect based on an instance segmentation model and the target image, wherein the quantization parameters are geometric morphology parameters reflecting the defect contour.
[0041] It should be noted that the above-mentioned quantitative parameters include, but are not limited to, one or more of the following: length, height, area, diameter, and radius of the defect contour.
[0042] It should be understood that defects in overlock stitches include, but are not limited to, skipped stitches, broken threads, arching, wavy stitches, wrinkles, loose edges, flattened edges, raised spots, and curled edges. For defect types that are not suitable for quantification (such as curled edges), the degree of defect is difficult to define precisely using parameters such as area or height. In such cases, it is possible to determine only the type and location of the defect to assist quality inspectors in manual review or process fine-tuning, thus balancing inspection efficiency and quality control requirements.
[0043] In some specific embodiments, before acquiring the image of the overlock stitch in S1, the method may further include: placing the completed overlock stitch sample in the preset target detection area of the image detection module to ensure that the stitch is flat, wrinkle-free, and without deviation, and is completely in the standard detection position, so as to eliminate the interference of abnormal stitch shape on the clarity and detection accuracy of subsequent image acquisition, and provide accurate input data for subsequent defect detection.
[0044] Optionally, the overlock stitch sample can be fixed by a positioning mechanism (such as a sewing platform positioning frame) and a fixing mechanism (such as a flexible elastic pressure plate fixation) to ensure that the stitch remains stationary and without displacement during image acquisition without damaging the stitch structure.
[0045] In some specific embodiments, the above-mentioned S1 acquisition of the overlock stitch image specifically includes: when the image acquisition module detects the appearance of the stitch image in the target detection area, performing a sharpness analysis on the image to determine whether the image sharpness meets the requirements of a first preset value; if it meets the requirements, further determining whether the image is in a static state; if it is in a static state, automatically triggering the acquisition and saving of the overlock stitch image.
[0046] For example, the sharpness analysis of the image can be performed by: performing high-frequency information analysis on the image using the Laplacian operator. The calculation formula is shown in formula (1).
[0047] (1)
[0048] in, The second derivative operator represents the second-order pixel coordinates of the image, used to represent high-frequency detail information in the image. x and y are the two-dimensional pixel coordinate dimensions of the image. x represents the horizontal (column) pixel coordinates, corresponding to the left-to-right pixel arrangement dimension; y represents the vertical (row) pixel coordinates, corresponding to the top-to-bottom pixel arrangement dimension. The second-order partial derivative in the x-direction measures the rate of change of pixel grayscale values in the horizontal direction, mainly reflecting high-frequency details such as edges and textures in the horizontal direction. The second-order partial derivative in the y-direction measures the rate of change of pixel grayscale values in the vertical direction, mainly reflecting high-frequency details such as edges and textures in the vertical direction.
[0049] It should be noted that the Laplacian operator can be used to calculate the variance (the degree of data fluctuation) of the image. If the variance is greater than a first preset value, it indicates that the details in the image (such as stitch edges) are numerous and obvious, and the image clarity meets the requirements. If the variance is less than the first preset value, it indicates that the image is blurry (e.g., due to a dirty lens or poor lighting), and the image clarity does not meet the requirements. The image acquisition module will then re-acquire the image. This avoids the image itself being blurry, which could lead to misjudging "blurry fabric texture" as a defect during subsequent stitch defect detection, or missing subtle skipped stitches or blurred edges, thus improving the accuracy and stability of defect detection.
[0050] For example, the above method for determining whether an image is in a static state can be: determining whether the lines in the image are in a static state by the difference between adjacent frames of the image. Specifically, for example, it can be determined by the calculation formula shown in formula (2).
[0051] (2)
[0052] Among them, G t (x, y) represents the image pixels in the current frame (time t), G t-1 (x, y) represents the image pixels of the previous frame (time t-1), and D(x, y) represents the absolute value of the brightness difference between corresponding pixels in the two frames.
[0053] It should be noted that the sum of D(x,y) at all positions in the image represents the total pixel difference between the two frames. If the total difference is less than the second preset value (for example, the second preset value is 0), it indicates that the line in the image is in a static state. If the total difference is greater than the second preset value, it indicates that the line is not in a static state. You can continue to wait until the difference is less than the second preset value before officially acquiring and saving the image.
[0054] It should be understood that in this embodiment, if the image's clarity and stillness meet preset conditions, it means that the image simultaneously meets the requirements of the first preset value and the second preset value. The first preset value indicates the image's clarity, and the second preset value indicates the image's stillness. Only when both preset values are met will the image acquisition module formally acquire and save the image. This dual-guarantee mechanism, prioritizing clarity and then stillness, ensures that the acquired line stitch image is clear, free from motion blur, and free from mechanical jitter. This provides reliable detection data for subsequent detection of line stitch defects such as skipped stitches and arching, avoiding detection errors caused by poor image quality.
[0055] In some specific embodiments, the determination of the key region where the overlock stitches are located in the image by S2 includes: the image processing module performing basic processing on the entire acquired image and detecting the region of interest (ROI) where the overlock stitches are located in the image, i.e., the aforementioned key region, using relevant algorithms (such as edge detection, contour filtering, etc.).
[0056] For example, the basic processing of the above image includes, but is not limited to: performing noise reduction, contrast enhancement, distortion correction and other processing on the entire image of the acquired overlock stitch, eliminating environmental noise (such as reflections from the sewing table), and enhancing the feature differences between the stitch and the background.
[0057] It should be understood that the aforementioned ROI (or key area) refers to a specific area selected from the entire image of the overlock stitch using an image preprocessing algorithm. This area contains only the core features of the stitch and precisely pinpoints the core range of the stitch while excluding interference from irrelevant background information such as fabric edges, sewing table surfaces, and environmental debris.
[0058] In this embodiment, determining the ROI region of the acquired image serves several purposes. First, it reduces data processing volume, focuses on the core stitch area, and avoids the model performing ineffective calculations on irrelevant backgrounds, significantly improving image cropping efficiency and model inference speed, ensuring the detection process adapts to the high-speed production rhythm of the overlock sewing machine. Second, it enhances detection accuracy and robustness, effectively avoiding interference from background noise such as fabric texture, seam scratches, and light reflection, reducing the probability of the model misclassifying background impurities as defects. Simultaneously, it allows the model to focus on learning the specific features of stitches and defects, strengthening its ability to identify low-contrast defects such as minor skipped stitches and subtle frayed edges. Third, through ROI selection rules, it ensures that the core detection area of each image remains consistent in position and size, unifying the detection benchmark and avoiding inconsistencies in detection standards caused by stitch offsets or slight fluctuations in image acquisition angles. This provides a stable foundation for subsequent sub-image cropping and defect quantification, ensuring the consistency and reliability of stitch detection results in mass production.
[0059] In some specific embodiments, the above-described S3, which determines multiple sub-images corresponding to the key region, includes: cropping the extracted line trace ROI region into sub-images of equal size; while ensuring that there are overlapping areas between adjacent sub-images, the extent of which is determined based on the number of cropped sub-images. For example, the extracted line trace ROI region is cropped into 10 square sub-images of equal size, with at least 20% overlap between adjacent sub-images.
[0060] It should be noted that instance segmentation models typically require fixed-size image input, and cropping to the same size sub-image can adapt to the model's input requirements. For example, in the You Only Look Once (YOLO) instance segmentation model, inputting a square sub-image of the same size ensures that the model can stably read line features and avoids inference errors caused by inconsistent image sizes.
[0061] It should also be noted that overlapping areas between sub-images can prevent defects from being cut off and missed. Specifically, defects in overlock stitches (such as long skipped stitches or wavy stitches) may cross the boundaries of multiple sub-images. If the sub-images do not overlap, the defect will be cut into incomplete fragments, which may cause the model to fail to recognize it. Overlapping areas ensure that defects that cross boundaries appear completely in at least one sub-image, ensuring that the model can detect the complete defect shape, avoiding the problem of defect cutting, and further improving the accuracy of defect detection.
[0062] In some specific embodiments, the above S4 preprocessing of the sub-image to obtain the target image includes: converting the cropped line sub-image into a grayscale image format to obtain the input image (i.e., the target image) of the instance segmentation model.
[0063] For example, using the color space conversion method of the Open Source Computer Vision Library (OpenCV), the acquired three-channel blue-green-red (BGR) format color line pattern sub-image is converted into a single-channel grayscale image; then the single-channel grayscale image is converted into a three-channel BGR format image (the converted three-channel pixel values are the same as the original grayscale). Figure 1 (No new color information is added), thus adapting to the format requirements of the instance segmentation model for three-channel input images.
[0064] It should be understood that the above preprocessing, in addition to image grayscale processing, may also include basic image processing such as distortion correction, Gaussian filtering for noise reduction, and adaptive contrast enhancement.
[0065] It should be understood that the above grayscale processing can eliminate interference from fabric color. Specifically, stitch defects are morphological and structural flaws (such as skipped stitches or undulating arches), which are unrelated to fabric color. Processing them into grayscale images can strip away color information, avoiding interference from different fabric colors (such as white cotton and dark linen) on model recognition. This allows the model to focus on the morphological features of the stitches, further improving the accuracy and efficiency of defect detection.
[0066] In some specific embodiments, the above-mentioned S5, which determines the location information, type, and quantization parameters of the defect based on the instance segmentation model and the target image, includes: inputting the target image into the trained instance segmentation model, determining the coordinates (i.e., the location information of the defect), type, and contour parameters (such as contour coordinate points) of the defect through the detection head and segmentation head of the network structure in the instance segmentation model; and quantizing the defect based on the type and contour parameters of the defect to determine its corresponding quantization parameters.
[0067] It should be noted that the instance segmentation model prototypes that can be used in this application include, but are not limited to, the 8th generation YOLO instance segmentation (YOLOv8-seg) model, the 7th generation YOLO instance segmentation (YOLOv7-seg) model, the 6th generation YOLO instance segmentation (YOLOv6-seg) model, the Mask Region-based Convolutional Neural Network (Mask R-CNN) model, and the Segmenting Objects by Locations version 2 (SOLOv2) model.
[0068] It should be noted that the feature extraction and feature fusion stages of the instance segmentation model first extract the local texture and global morphological features of the line traces in the target image. Then, these features are simultaneously input into the detection head and the segmentation head. The detection head quickly completes the defect localization and category identification, and outputs the bounding box coordinates of the defect (locking in the approximate range of the defect in the sub-image), the defect type (such as skipped stitches or curled edges), and the confidence level (filtering out valid defects), providing the segmentation head with target range guidance and reducing the segmentation head's invalid calculations. Then, the segmentation head accurately completes the defect contour recognition and data quantization, and outputs the pixel-level mask of the defect (depicting the precise contour) within the bounding box range locked by the detection head.
[0069] For example, combined Figure 2 The specific process for determining the contour parameters can be as follows: For each detection box 11 in the network structure, perform matrix multiplication (i.e., weighted summation) of the 32-dimensional mask coefficients (basic contour template) and 32 prototype masks (weight parameters for each defect) to generate an initial mask (or coarse-grained mask); then, crop the mask according to the range of the detection box 11, upsample it to the original size of the detection box, and finally convert it into a "0 / 1 binary mask" (e.g., 0 represents the background, 1 represents the defect) through thresholding to obtain the precise contour parameters of the defect (fine mask). Figure 2 As shown, the defect type is, for example, a double-sided defect, and the defect outline region 13 is usually an irregular polygon composed of multiple defect outline coordinate points 12.
[0070] In this embodiment, the instance segmentation model first performs coarse-grained detection on the target image using a segmentation head, quickly marking the bounding boxes and categories of all suspected defects. The segmentation head then performs fine-grained segmentation on the region based on the bounding box range of the detection head, generating a precise mask that only covers the defects, providing a foundation for subsequent defect quantification. This method not only enables qualitative identification of defects (defect type) but also quantitative determination of defects (defect outline - defect shape and size), achieving accurate detection and severity determination of all types of stitch defects, providing reliable data for subsequent automatic adjustment of the overlock sewing machine.
[0071] It should be noted that when quantifying defects, different quantification dimensions can be used for different types of line defects. In other words, quantification parameters can include one or more geometric morphology parameters that reflect the defect outline, such as the length, height, area, diameter, and radius of the defect outline.
[0072] In one possible implementation, for defect types suitable for quantification using area parameters (such as cratering and sloping edges), pixel filling can be performed based on the defect's contour parameters (such as the contour coordinates of the defect). By counting the number of pixels in the defect area after filling, the area corresponding to the defect is calculated, and the severity of the defect is determined by quantifying the area size.
[0073] For example, taking defects of two-sided and puffy as examples, such as Figures 2 to 4 As shown, the specific process for quantifying and judging defects can be as follows: using the fill polygon method in OpenCV, the contour regions corresponding to the contour coordinate points of defects (such as the contour coordinate point 12 of defects with two sides and the contour coordinate point 21 of defects with a point) (such as the contour region 13 of defects with two sides and the contour region 22 of defects with a point) are filled with pixels to obtain the filled defect contour regions (such as the filled contour region 14 of defects with two sides and the filled contour region 23 of defects with a point). Figure 3 It is a mask image with a background of 0 (corresponding to pure black) and blemishes of non-0 pixels, where different blemish types correspond to different non-0 pixel values; then, the area corresponding to the blemish is determined based on the pixel values of the filled blemish outline area, and the severity of the blemish is judged by the area.
[0074] In another possible implementation, for defect types suitable for quantification using height parameters (such as droopy edges or dummy edges), the area corresponding to the defect can be determined first by the above-mentioned pixel filling and counting the number of pixels in the defect area after filling; then the width corresponding to the defect can be determined by the defect contour parameters; finally, the average height corresponding to the defect can be determined by the above-mentioned area and width, and the severity of the defect can be quantified by the height.
[0075] For example, such as Figure 5 As shown, taking a dummy edge type defect as an example, the specific process for quantifying and judging the defect can be as follows: First, determine the dummy edge defect outline region 31 based on the dummy edge defect outline coordinate point 32. Fill the outline region 31 with pixels and count the number of pixels in the defect region after filling to determine the area corresponding to the dummy edge defect. Obtain the leftmost bottom coordinate (i.e., the first outline coordinate point 33) and the rightmost bottom coordinate (i.e., the second outline coordinate point 34) of the dummy edge outline coordinate point 32, for example, by using the index of the minimum value (NumPy Argument of the Minimum, np.argmin) and the index of the maximum value (NumPy Argument of the Maximum, np.argmax) in the Numerical Python library (NumPy). Use the distance between these two coordinates as the width of the defect. Approximate the filled defect region as a rectangle and obtain the average height using the rectangle area calculation formula (i.e., area divided by width). Use the height to determine the severity of the defect. This height calculation method can effectively avoid the interference of local shape fluctuations in the line trace and is suitable for the height quantification requirements of shape defects such as sloping edges and dummy edges.
[0076] In this embodiment, categorizing and quantifying defects allows for precise matching of stitch defect quality standards. Specifically, different stitch defects have different severity dimensions. For example, punctures are regional defects; the larger the area, the more severe the impact on product quality, making area a suitable criterion for determining defect severity. Conversely, sloping edges and faint edges are morphological defects; the higher their height, the more severe the stitch irregularity, making height a suitable criterion for determining defect severity. This dimensional quantification accurately matches the stitch quality standards of the textile industry, making the judgment results more aligned with actual production needs.
[0077] It should be noted that before determining the location information, type, and quantization parameters of the defects based on the instance segmentation model and the target image, the method also includes: the model calculation module trains the model based on the loss function of the instance segmentation model to obtain the instance segmentation model that has been trained.
[0078] It should be noted that the loss function of this application includes detection task loss and segmentation task loss. The detection task loss includes, for example, bounding box regression loss, classification loss and distribution focal loss (DFL), while the segmentation task loss is, for example, mask loss. Each type of loss term is adapted to different needs such as "localization, classification and contour quantization" in the detection of stitch defects through targeted structural design.
[0079] In this embodiment, the instance segmentation model is trained using a composite total loss function to simultaneously optimize the accuracy of detection and segmentation tasks. For example, the formula for the total loss function is: Total Loss = λ box * L box +λ cls * L cls +λ seg * L seg , where λ box , λ cls , λ seg L represents the weighting coefficient for each loss term. box For bounding box regression loss, L cls For classification loss, L box and L cls To detect mission losses, L seg To divide the task losses.
[0080] Specifically, in the detection task loss, the bounding box regression loss is a regression loss that comprehensively considers the overlap of bounding boxes and the matching degree of geometric features. It is used to optimize the fit between the model's predicted bounding box and the real bounding box, and is the core loss term for achieving accurate defect localization. For example, for the characteristics of the blurred boundaries and irregular shape of stitch defects (such as arching and curling), this loss can simultaneously constrain the overlapping area, positional deviation and shape matching degree of the bounding box, avoid the positioning offset caused by the gradual change of the edge of the stitch defect, ensure that the bounding box accurately surrounds the defect area, and provide a stable range basis for subsequent segmentation tasks.
[0081] Classification loss is a type of classification loss designed for imbalanced samples. By reducing the weight of easily classified samples and increasing the weight of difficult-to-classify samples, it improves the model's recognition accuracy for minority class (defective) samples. It is particularly suitable for the class distribution characteristics of "high proportion of normal stitch samples and low proportion of defective samples" in overlock stitch detection. At the same time, it strengthens the model's ability to classify low-contrast and minor defects for special scenarios such as "the interval between slight skipped stitches and normal stitches, and the difference between false edges and uneven lighting", reducing the probability of misclassification of similar features.
[0082] DFL loss is a loss function that transforms bounding box coordinate prediction into distance distribution probability optimization. By learning the probability distribution of coordinates rather than directly regressing numerical values, it improves the stability of localization. Addressing issues such as boundary fluctuations and unclear edges caused by stitch imperfections (e.g., wrinkles), DFL loss can reduce localization fluctuations caused by stitch texture interference, further improving the stability of bounding box localization and ensuring the accuracy of subsequent segmentation tasks.
[0083] In segmentation task loss, segmentation loss (such as Mask loss) is a composite loss adapted to pixel-level segmentation tasks. It includes mask prototype loss and mask coefficient loss. This loss combines pixel-by-pixel classification constraints and contour overlap constraints to force the model to learn the precise shape, contour and internal structure of defects, thereby improving the accuracy of defect masks. It is the core loss term for subsequent defect quantization. At the same time, it accelerates the convergence of instance segmentation models, reduces the risk of gradient vanishing, and adapts to the requirements of industrial scenarios for model training efficiency.
[0084] For example, the segmentation task loss includes:
[0085] Mask prototype loss: Binary Cross-Entropy Loss (BCE Loss) is used, with the formula L. proto = BCE(Sigmoid(P), M g t), where P is the prototype mask, M g t represents the true mask. It enables pixel-by-pixel defect / background classification, ensuring that no minute defects are missed, especially for detecting small-sized defects in overlock stitches.
[0086] Mask coefficient loss: Also using binary cross-entropy loss, the formula is L mask = BCE(Sigmoid(C⊙P),M g t), where C is the mask coefficient output by the detection head, P is the prototype feature map, and ⊙ represents matrix multiplication. By weighted combination of mask coefficients and prototype feature maps, the model focuses on accurate matching of defect contours, enhances the model's ability to characterize the contours of irregular defects, and provides an accurate mask basis for subsequent defect quantification (calculation of parameters such as area and length).
[0087] This composite segmentation loss not only ensures the detection rate of minor defects, but also allows the model to accurately depict the irregular contours of defects, adapting to the morphological characteristics of overlock stitch defects.
[0088] During model training, the bounding box regression loss, classification loss, DFL loss, and segmentation loss in the loss function are jointly supervised by the bounding box coordinates and class labels output by the detection head and the mask contour output by the segmentation head. The deviation between these and the ground truth labels is quantified, and this deviation is converted into a backpropagable gradient signal to drive the iterative update of the network structure's learnable parameters (such as convolutional kernel weights and bias terms). Through multiple rounds of training and optimization, the model's accuracy in defect localization, classification accuracy, and pixel-level integrity and precision of the mask contour are continuously improved, laying the foundation for subsequent defect quantification based on mask contour parameters.
[0089] It should be understood that in the above embodiments, the loss function is responsible for optimizing the learnable parameters of the network (such as convolutional kernel weights) during the model training phase, continuously improving the feature extraction accuracy and output reliability of the network for defects in overlock stitches; the network structure (including the detection head and the segmentation head) is responsible for outputting basic detection results based on the trained and optimized parameters during the model inference phase. The detection head outputs the location information and type label of the defect, and the segmentation head outputs the pixel-level mask of the defect simultaneously; subsequently, by extracting contour features from the mask and combining it with preset quantization rules, the area, height, length and other quantization parameters of the defect can be further calculated, and finally the quantization judgment of the severity of the defect can be completed.
[0090] Therefore, in this embodiment, the combination and weight ratio of the above loss terms can be flexibly configured according to the needs of the actual detection scenario to achieve collaborative optimization of the detection task and the segmentation task. This satisfies the basic detection requirements of accurate defect location and correct category determination, while also adapting to the requirements of fine contour depiction and quantifiable defect parameters for stitch quality assessment, thereby improving the overall detection accuracy and robustness of the instance segmentation model for overlock stitch defects in industrial scenarios.
[0091] The scope of protection of the textile defect detection method described in this application is not limited to the order of steps listed in this embodiment. Any solution implemented by adding, subtracting, or replacing steps in the prior art based on the principles of this application is included within the scope of protection of this application.
[0092] This application also provides a textile defect detection system, which can implement the textile defect detection method described in this application. However, the implementation device of the textile defect detection method described in this application includes, but is not limited to, the structure of the textile defect detection system listed in this embodiment. All structural modifications and substitutions of the prior art made based on the principles of this application are included within the protection scope of this application.
[0093] like Figure 6 As shown, this embodiment provides a textile defect detection system, which includes: an image acquisition module for acquiring images of textiles, wherein the image clarity and static state meet preset conditions; an image processing module for processing the images of textiles to obtain a target image; and a model calculation module for determining the location information, type, and quantization parameters of defects based on an instance segmentation model and the target image, wherein the quantization parameters are geometric morphology parameters reflecting the defect contour.
[0094] like Figure 7As shown, this embodiment provides a textile defect detection device. The device employs a textile defect detection method as described in any of the above embodiments or is equipped with a textile defect detection system as described in any of the above embodiments. The image acquisition module 41 is used to acquire images of the textile, and the defect detection operating table 42 is used to place and detect the textile.
[0095] This application also provides a computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the textile defect detection method of any of the above embodiments. Those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing a processor. The program can be stored in a computer-readable storage medium, which is a non-transitory medium, such as random access memory, read-only memory, flash memory, hard disk, solid-state hard disk, magnetic tape, floppy disk, optical disk, and any combination thereof. The above storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disc (DVD)), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0096] Figure 8 The diagram shown is a structural schematic of an electronic device according to an embodiment of this disclosure. Figure 7 As shown, the electronic device provided in this embodiment includes a processor and a memory. The memory is configured to store an executable program. The processor is configured to execute the program to cause the electronic device to perform the textile defect detection method according to any of the above embodiments.
[0097] Preferably, the processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0098] This embodiment also includes one or more of the following: a multimedia component, an input / output (I / O) interface, and a communication component.
[0099] The multimedia component may include a screen and an audio component. The screen may be, for example, a touchscreen, and the audio component is configured to output and / or input audio signals. For example, the audio component may include a microphone configured to receive external audio signals. The received audio signals may be further stored in memory or transmitted via a communication component. The audio component also includes at least one speaker configured to output audio signals. The I / O interface provides an interface between the processor and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual or physical buttons. The communication component is configured to enable wired or wireless communication between the timer and other devices. Wireless communication may include Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination thereof; therefore, the corresponding communication component may include a Wi-Fi module, a Bluetooth module, or an NFC module.
[0100] This application provides a method, system storage medium, and electronic device for detecting defects in textiles, which have the following significant advantages and beneficial effects:
[0101] This application enables automatic and accurate identification and severity determination of various defects through instance segmentation model, reducing the cost and error of manual inspection. The system or equipment can work around the clock, reducing the burden on operators and improving the automation level and inspection efficiency of the production process.
[0102] The instance segmentation model in this application adopts an integrated training and inference framework of "data input, model self-learning, and result output". During model training, it learns directly from labeled data, without the need for complex post-processing or multi-stage algorithm design. This end-to-end training mode simplifies the data processing flow, significantly reduces development difficulty and manpower costs, avoids the problem of multi-stage error accumulation, shortens the model training cycle, and effectively adapts to the rapid deployment needs of industrial scenarios.
[0103] The instance segmentation model of this application can not only accurately separate textile defects from the background such as fabric and sewing table in an image, but also independently identify and delineate the contours of multiple targets in the same category (such as multiple point defects in a single stitch), outputting a unique binary mask and location information for each defect; it can accurately extract the complete contour of the defect through pixel-level segmentation, providing basic data for the quantitative calculation of geometric parameters such as defect area, height, and length, effectively solving the problem that traditional detection cannot accurately describe the morphology of defects, making the detection results more refined and intuitive, and thus providing a reliable basis for assessing the severity of stitch defects, determining their type, and prioritizing repairs, helping subsequent machine operators to match and output more accurate equipment parameters.
[0104] This application also supports the simultaneous identification and differentiation of multiple types of defects. It can simultaneously process various defects in textiles, such as skipped stitches, arching, and curling edges, and can independently mark the location and shape of each defect to avoid confusion.
[0105] The instance segmentation model of this application has strong robustness. By performing preprocessing on the acquired images (such as basic processing and preprocessing) and learning the exclusive features of stitches and defects through deep learning models, it can effectively resist environmental interference such as fabric texture and lighting changes, accurately distinguish defects from normal stitch structures (such as the interval between skipped stitches and normal stitches, arching and the natural undulation of the fabric), and achieve full-type, high-precision, and automated detection of overlock stitch defects.
[0106] This application has broad applicability and scalability, and can handle different types of textile defects. Whether it is a skipped stitch, a broken thread, or a complex form of defect such as buckling or wrinkling, this method can accurately detect them. This method is also applicable to defect detection in the textile production process.
[0107] In the embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, or methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules / units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or units may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of apparatuses or modules or units may be electrical, mechanical, or other forms.
[0108] The modules / units described as separate components may or may not be physically separate. The components shown as modules / units may or may not be physical modules; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules / units can be selected to achieve the objectives of the embodiments of this application, depending on actual needs. For example, the functional modules / units in the various embodiments of this application may be integrated into one processing module, or each module / unit may exist physically separately, or two or more modules / units may be integrated into one module / unit.
[0109] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0110] This application embodiment may also provide a computer program product comprising one or more computer instructions. When the computer instructions are loaded and executed on a computing device, all or part of the processes or functions described in this application embodiment are generated. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0111] When the computer program product is executed by a computer, the computer performs the method described in the foregoing method embodiments. The computer program product can be a software installation package; when the foregoing method is required, the computer program product can be downloaded and executed on the computer.
[0112] The descriptions of the processes or structures corresponding to the above figures each have their own emphasis. For parts of a process or structure that are not described in detail, please refer to the relevant descriptions of other processes or structures.
[0113] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in this application should still be covered by the claims of this application.
Claims
1. A method for detecting defects in textiles, characterized in that, include: Images of textiles are acquired, and the clarity and stillness of the images meet preset conditions. Identify the key regions in the image where the textile features are located; Determine multiple sub-graphs corresponding to the key region; The target image is obtained by preprocessing the sub-image; The location information, type, and quantization parameters of the defect are determined based on the instance segmentation model and the target image. The quantization parameters are geometric morphology parameters that reflect the contour of the defect.
2. The textile defect detection method according to claim 1, characterized in that, Determining the location information, type, and quantization parameters of defects based on the instance segmentation model and the target image includes: Based on the detection head and segmentation head of the network structure in the instance segmentation model, and the target image, determine the location information, type, and contour parameters of the defects; The corresponding quantization parameters are determined based on the type of defect and its contour parameters.
3. The textile defect detection method according to claim 1, characterized in that, The loss function used in training the instance segmentation model includes detection task loss and segmentation task loss.
4. The textile defect detection method according to claim 1, characterized in that, The images of the acquired textiles include: Determine whether the image sharpness meets the requirements of a first preset value; If the conditions are met, determine whether the image is in a static state. If it is in a static state, trigger the image acquisition of the overlock stitch.
5. The textile defect detection method according to claim 1, characterized in that, The plurality of sub-images are multiple adjacent sub-images, and the plurality of adjacent sub-images include overlapping regions, the extent of which is determined according to the number of sub-images; and the preprocessing includes image grayscale processing.
6. The textile defect detection method according to claim 1, characterized in that, Determining the quantization parameters of the defect based on the instance segmentation model and the target image includes: The contour parameters of the target image are determined based on the instance segmentation model. If the quantization parameter is a defect area parameter, then the contour region is filled with pixels according to the contour parameter; the area of the defect is determined according to the filled contour region. If the quantization parameter is a defect height parameter, then the contour region is filled with pixels according to the contour parameter; the area of the defect is determined according to the filled contour region; and the height value of the defect is determined by the area of the defect.
7. The textile defect detection method according to claim 6, characterized in that, The types of defects include skipped stitches, broken threads, arching, wavy lines, wrinkles, frayed edges, double-sided bends, and blemishes; the quantitative parameter for blemishes is the defect area parameter; the quantitative parameters for double-sided bends and frayed edges are the defect height parameters.
8. A textile defect detection system, characterized in that, The system includes: An image acquisition module is used to acquire images of textiles, wherein the image clarity and stillness meet preset conditions; An image processing module is used to process the image of the textile to obtain a target image; The model calculation module is used to determine the location information, type and quantization parameters of the defect based on the instance segmentation model and the target image. The quantization parameters are geometric morphology parameters that reflect the contour of the defect.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the textile defect detection method according to any one of claims 1 to 7.
10. An electronic device, characterized in that, The electronic device includes: A memory on which computer programs are stored; The processor, which is communicatively connected to the memory, executes the computer program to implement the textile defect detection method according to any one of claims 1 to 7.