YOLOv11n-based lightweight contactor assembly defect detection method
Through the lightweight contactor component defect detection method based on YOLOv11n, the problems of high error detection rate and slow inference speed in contactor component detection are solved, and real-time detection of contactor components with high precision and low latency are achieved, which is suitable for complex industrial scenarios.
Patent Information
- Application Number
- CN202510455874.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-11
- Publication Date
- 2025-08-08
AI Technical Summary
In the prior art In industrial automation detection, the defect detection of contactor components has high error detection rate and slow inference speed, which cannot meet the high accuracy and low latency requirements in complex industrial scenarios.
The defect detection method of lightweight contactor components based on YOLOv11n is adopted, and the detection accuracy and speed of the model are improved through data enhancement, optimization of loss functions, designing minimalist network modules and adaptive core convolution modules.
It realizes high-precision and low-latency detection of contactor components, is suitable for complex industrial scenarios, reduces model volume and parameter quantity, and improves recognition accuracy and real-timeness.
Smart Images

Figure CN120451052A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of industrial automation detection technology, and specifically to a lightweight contactor component defect detection method based on YOLOv11n, which is particularly suitable for real-time detection and deployment of high-precision, low-latency contactor components in complex industrial scenarios. Background Art
[0002] In the field of industrial automation inspection, contactors are critical electrical components. Accurately detecting surface defects (such as missing wires, incorrect wire order, missing wires, or misplaced protective plates) directly impacts equipment safety and production line yield. Traditional contactor inspection methods rely primarily on manual visual inspection or basic vision algorithms (such as template matching and edge detection).
[0003] Contactor defect detection in industrial scenarios mainly relies on traditional target detection algorithms and benchmark deep learning models. Typical solutions include: traditional image processing algorithms based on edge detection (Canny operator) and morphological operations, but are limited by metal reflections, light changes, and the similarity of wire and background colors, resulting in a false detection rate of over 25%; two-stage detection models generate candidate boxes through the region proposal network (RPN). Although this improves positioning accuracy, the inference speed is too low to meet the actual requirements of the production line, affecting the production speed of the production line. Summary of the Invention
[0004] The object of the present invention is to provide a lightweight contactor assembly defect detection method based on YOLOv11n, which can improve the detection accuracy and speed.
[0005] In order to achieve the above objectives, the present invention provides a lightweight contactor assembly defect detection method based on YOLOv11n, comprising:
[0006] S1: Obtain actual images of contactor components, perform geometric changes, color changes, mosaic data augmentation, and use labelimg for annotation to generate samples;
[0007] S2: Build an optimized YOLOv11n model. Based on the original YOLOv11n model, it uses the cohesive complete intersection-over-union loss function as the loss function and optimizes the addition of a triple attention mechanism module before the detection head.
[0008] S3: Design a minimalist network module to replace the original backbone extraction network, and use the adaptive kernel convolution module to optimize the original convolution module to further achieve model lightweighting;
[0009] S4: Use the training set and model file to train and obtain the trained YOLOv11n model;
[0010] S5: During detection, the real-time image of the contactor component is input into the trained YOLOv11n model to obtain the detection result of the contactor component.
[0011] Preferably, the step S1 specifically includes:
[0012] S11: Acquire actual images of contactor components in a factory as samples of an original sample dataset;
[0013] S12: Use LABELIMG software to annotate the original sample dataset to convert it into XML format; the annotation content includes image size information, annotated target object, target object type name, and target object bounding box coordinates;
[0014] S13: The original sample dataset is amplified by geometric changes, color changes, and mosaic data enhancement, and the labels are subjected to corresponding coordinate transformations during sample amplification to obtain the expanded sample dataset;
[0015] S14: Divide the expanded sample data set into training set, validation set, and test set;
[0016] Step S4 also includes using the validation set and the test set to test the model accuracy and the detection speed of the model.
[0017] Preferably, the step S2 specifically includes:
[0018] S21: Optimize and add a triple attention mechanism-based module to the three detection heads of the YOLOv11n model;
[0019] S22: Use the loss function based on the cohesive complete intersection-over-union ratio as the loss function to calculate the regression loss value of the bounding box to further optimize the regression ability of the bounding box;
[0020] S23: Modify the model configuration file, register the module based on the triple attention mechanism into the model file of the YOLOv11n model, and call the module based on the triple attention mechanism through the training code;
[0021] S24: Register the loss function based on the cohesive complete intersection-union ratio as a loss function module in the model file.
[0022] Preferably, the module based on the triple attention mechanism is composed of three parallel branches, including a channel-width interaction branch, a channel-height interaction branch and a spatial interaction branch; the channel-width interaction branch refers to the rotation of the input tensor around the height axis, converting the dimension from C×H×W to W×C×H, compressing the channel dimension through Z-Pool, and extracting the spatial attention weight by convolution; the channel-height interaction branch refers to the rotation of the input tensor around the width axis, converting it to H×C×W, compressing the channel dimension through Z-Pool, and extracting the spatial attention weight by convolution; the spatial interaction branch refers to directly calculating the spatial attention weight on the original input.
[0023] Preferably, the loss function based on the complete intersection-over-union ratio of cohesion is:
[0024]
[0025] Among them, ρ(b,b p ) is the center point b of the real box and the center point b of the anchor box p The distance between the two points, c represents the diagonal length of the minimum box covering the anchor box and the true box, α is a positive trade-off parameter, υ is the consistency of the measurement aspect ratio, in is the intersection area of the internal anchor box and the predicted bounding box, and union is the union area of the internal anchor box and the predicted bounding box;
[0026] The intersection area in of the internal anchor box and the predicted bounding box and the union area union of the internal anchor box and the predicted bounding box are:
[0027]
[0028]
[0029]
[0030]
[0031]
[0032] union=(w×h)×(ratio) 2 +(w p ×h p )×(ratio) 2 -in,
[0033] Among them, h is the height of the real box, w is the width of the real box, h p is the height of the anchor box, w p is the width of the anchor box, radio is the scaling factor; b is the center point of the real box, x c 、y care the horizontal and vertical coordinates of the center point of the real frame, b p is the center point of the anchor box, are the horizontal and vertical coordinates of the center point of the anchor box; b l 、b r 、b t 、b b Represent the left boundary of the predicted bounding box, the right boundary of the predicted bounding box, the top boundary of the predicted bounding box, and the bottom boundary of the predicted bounding box respectively; They respectively represent the left boundary coordinates of the internal anchor box, the right boundary coordinates of the internal anchor box, the upper boundary coordinates of the internal anchor box, and the lower boundary coordinates of the internal anchor box, which are used to describe the specific position and size of the anchor box in the image; in and union respectively represent the intersection area of the internal anchor box and the predicted bounding box, and the union area of the internal anchor box and the predicted bounding box.
[0034] Preferably, the step S3 specifically includes:
[0035] S31: Design a minimalist network module to replace the backbone extraction network of the YOLOv11n model;
[0036] S32: Use the adaptive kernel convolution module to optimize the original convolution module;
[0037] S33: Register the minimalist network module and the adaptive kernel convolution module into the model file, and modify the model configuration file so that the training code calls the minimalist network module and the adaptive kernel convolution module.
[0038] In step S12 , the annotated content includes the size information of the image, the annotated target object, the type name of the target object, and the bounding box coordinates of the target object.
[0039] In step S5, the detection results of the contactor assembly include whether the wires are leaking, whether the order of the wires is wrong, whether the wires are missing, whether the protective sheet is missing, and whether the protective sheet is incorrectly positioned; among them, whether the wires are leaking is determined based on whether the center points of the detection frames of the wires are at the same height and whether the center points of the detection frames of the wires are within a preset range; whether the order of the wires is wrong is determined based on whether the label order of the detection frames of multiple wires is consistent with the preset order; whether the wires are missing is determined based on whether the number of detection frames for the wires is less than a preset value; whether the protective sheet is missing is determined based on whether the detection frame of the protective sheet is missing; whether the position of the protective sheet is incorrect is determined based on whether the center position of the detection frame of the protective sheet is at a preset position.
[0040] The model used in the lightweight contactor component defect detection method based on YOLOv11n of the present invention is smaller in size than the existing YOLOv11n model, has fewer parameters than the original model, optimizes the loss function, has higher recognition accuracy, faster convergence speed, less training difficulty, and good real-time performance. It is particularly suitable for high-precision, low-latency real-time detection and deployment of contactors in complex industrial scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 4 is a flowchart of a lightweight contactor assembly defect detection method based on YOLOv11n according to an embodiment of the present invention.
[0042] Figure 2 This is the effect diagram after the original image of the contactor component is enhanced with Mosaic data in the present invention. Figure 2 The upper part is the geometric transformation, Figure 2 The lower part is the color change.
[0043] Figure 3 This is the effect diagram after Mosaic data enhancement is performed on the original image of the contactor component in the present invention.
[0044] Figure 4 2 is a schematic diagram of the network structure of a YOLOv11n model with an improved design based on a triple attention mechanism, which is adopted in a contactor assembly defect detection method based on YOLOv11n according to an embodiment of the present invention.
[0045] Figure 5 This is a schematic diagram of the principle of the module based on the triple attention mechanism.
[0046] Figure 6A and Figure 6B Schematic diagram of the principle of the loss function based on the cohesive complete intersection-over-union ratio when the scaling factor radio is less than 1 and greater than 1, respectively.
[0047] Figure 7 This is a schematic diagram of the network structure of an improved, optimized and lightweight YOLOv11n model adopted in a lightweight contactor assembly defect detection method based on an improved design of YOLOv11n according to an embodiment of the present invention, in which a minimalist network module (VanillaNet) is designed to replace the original backbone network.
[0048] Figure 8This is a schematic diagram of the network structure of an improved, optimized and lightweight YOLOv11n model adopted in a lightweight contactor assembly defect detection method based on YOLOv11n according to an embodiment of the present invention, in which a minimalist network module (VanillaNet) is designed to replace the original backbone network, and the original convolution module (Conv) is optimized and replaced with an adaptive kernel convolution module (Akconv).
[0049] Figure 9 Yes Figure 7 Schematic diagram of the structure of the minimalist network module of the improved and lightweight YOLOv11n model shown.
[0050] Figure 10 Yes Figure 8 Schematic diagram of the structure of the Akconv network of the improved and lightweight YOLOv11n model shown.
[0051] Figure 11 This is a visual comparison chart of the original YOLOv11n model (top) and the improved model of the present invention (bottom). DETAILED DESCRIPTION
[0052] The preferred embodiments of the present invention are given below in conjunction with the accompanying drawings and described in detail.
[0053] like Figure 1 As shown, the lightweight contactor assembly defect detection method based on YOLOv11n specifically includes:
[0054] Step S1: Obtain the actual image of the contactor component, perform geometric transformation, color transformation, mosaic data enhancement, and use labelimg for annotation to generate samples and improve the quantity and quality of samples;
[0055] Among them, the results of geometric transformation and color transformation are as follows Figure 2 As shown; the result of Mosaic data enhancement is as follows Figure 3 As shown in the figure, labelimg is used for annotation, and the annotation content includes the image size information, the labeled target object, the type name of the target object, and the bounding box coordinates of the target object.
[0056] The step S1 specifically includes:
[0057] Step S11: obtaining an actual image of a contactor assembly in a factory as a sample of an original sample data set;
[0058] Step S12: Use LABELIMG software to annotate the original sample data set to convert the original sample data set into XML format.
[0059] The annotation content includes the size information of the image, the annotated target object, the type name of the target object (such as wires of various colors, protective sheets, etc.), and the bounding box coordinates of the target object.
[0060] Specifically, the identification targets are the red, blue, yellow, and green wires and the protective sheet on the contactor assembly. We can determine if there are any missing welds by comparing the center points of the detection frames of the four wires to ensure they are at the same height and within the preset position. We can also determine if the order of the wires is incorrect by comparing the order of the detection frame labels of the various wires with the preset order. We can also determine if a wire is missing by comparing the number of detection frames for each wire with the preset number. We can also determine if a protective sheet is missing by checking whether a detection frame for the protective sheet is present. We can also determine if the protective sheet is in the correct position by comparing the center point of the detection frame for the protective sheet is within the preset range.
[0061] In the XML format file, the name field records the tag name, and the bndbox field records the coordinate information of the bounding box, including the upper left corner and the lower right corner;
[0062] Step S13: perform data enhancement; Figure 2 、 Figure 3 As shown in the figure, the original sample dataset is amplified by geometric changes (translation, rotation, or scaling), color changes (changing the brightness, color distribution, or saturation of the image), and mosaic data enhancement (randomly splicing 4 images). At the same time, the corresponding coordinate transformation of the label is performed to obtain the expanded sample dataset;
[0063] This improves the robustness of the model.
[0064] Step S14: Divide the expanded sample data set into a training set, a validation set, and a test set in a ratio of 7:2:1.
[0065] The step S14 also includes converting the file in xml format into a txt file in yolo format, keeping the txt file consistent with the configuration, and performing the next step of training.
[0066] Step S2: Construct an optimized YOLOv11n model. Based on the original YOLOv11n model, it uses the loss function based on the cohesive complete intersection-over-union ratio (Inner_CioU) as the loss function and optimizes the addition of a module based on the triple attention mechanism before the detection head to improve the detection accuracy of the model. As a result, it is more suitable for the problem of high recognition error caused by variable light, metal reflection, and similar color between wires and background in factory environments.
[0067] Among them, the original YOLOv11n model includes the detection head, detection neck and support backbone parts.
[0068] The step S2 specifically includes:
[0069] Step S21: Figure 4 As shown in the figure, a module based on the triplet attention mechanism is optimized and added to the three detection heads of the YOLOv11n model; this module based on the triplet attention mechanism is used to better focus on the key areas of the model, improve the feature extraction capability of the model, and better deal with the problem that the wires of the contactor components are similar to the background.
[0070] like Figure 5 As shown in the figure, the module based on the triplet attention mechanism is a lightweight attention mechanism that enhances feature expression through cross-dimensional interaction. Its core design captures the dependency between channel and spatial dimensions through a three-branch structure, significantly improving the model's ability to model complex scenarios. The following analysis is conducted from three aspects: design principle, technical implementation, and advantage comparison.
[0071] The module based on the triple attention mechanism consists of three parallel branches (Triplet Branch), which handle interactions of different dimensions respectively.
[0072] 1) Channel-width interaction branch: The input tensor is rotated around the height axis to convert the dimension from C×H×W to W×C×H. After compressing the channel dimension through the Z-Pool layer, convolution is used to extract the spatial attention weights.
[0073] 2) Channel-height interaction branch: The input tensor is rotated around the width axis and converted to H×C×W. After compressing the channel dimension through the Z-Pool layer, convolution is used to extract the spatial attention weights;
[0074] 3) Spatial interaction branch: directly calculates the spatial attention weights on the original input, similar to the spatial attention module of CBAM.
[0075] As a result, the module based on the triple attention mechanism achieves: cross-dimensional interaction, breaking the traditional attention mechanism's dependence on a single dimension through rotation operations, and establishing a direct association between channels and spatial dimensions; and no dimensionality reduction processing, that is, avoiding the information loss caused by traditional methods (such as SENet) through global pooling to compress dimensions, and retaining complete feature information.
[0076] Step S22: Use the loss function based on the inner complete intersection-over-union ratio (Inner_CIoU) as the loss function to calculate the regression loss value of the bounding box to further optimize the regression ability of the bounding box;
[0077] Figure 6A and Figure 6B The following are schematic diagrams of the principle of the loss function based on the cohesive complete intersection-over-union ratio when the scaling factor radio is less than 1 and greater than 1. Figure 6A and Figure 6B As shown, the formulas for the intersection area in of the internal anchor box and the predicted bounding box and the union area union of the internal anchor box and the predicted bounding box required by the loss function based on the cohesive complete intersection-union ratio are as follows:
[0078]
[0079]
[0080]
[0081]
[0082]
[0083] union=(w×h)×(ratio) 2 +(w p ×h p )×(ratio) 2 -in,
[0084] Among them, h is the height of the real box, w is the width of the real box, h p is the height of the anchor box, w p is the width of the anchor box, radio is the scaling factor; b is the center point of the real box, x c 、y c are the horizontal and vertical coordinates of the center point of the real frame, b p is the center point of the anchor box, are the horizontal and vertical coordinates of the center point of the anchor box; b l 、b r 、b t 、b b They represent the left boundary of the predicted bounding box, the right boundary of the predicted bounding box, the top boundary of the predicted bounding box, and the bottom boundary of the predicted bounding box respectively. The predicted bounding box (i.e., the inner real box) is based on the center point of the real box and is adjusted by width w, height h, and scaling factor radio. They respectively represent the left boundary coordinates of the internal anchor box (i.e., the inner anchor box), the right boundary coordinates of the internal anchor box, the upper boundary coordinates of the internal anchor box, and the lower boundary coordinates of the internal anchor box, which are used to describe the specific position and size of the anchor box in the image; in and union respectively represent the intersection area of the internal anchor box and the predicted bounding box, and the union area of the internal anchor box and the predicted bounding box.
[0085] The predicted bounding box (i.e., inner real box) and internal anchor box (i.e., inner anchor box) are the results of adjusting the real box and anchor box by the scale factor, h inner and w inner Indicates the height and width of the Inner real box, and Indicates the height and width of the inner anchor box.
[0086] The loss function based on the complete intersection-union ratio of cohesion is:
[0087]
[0088] Among them, ρ(b,b p ) is the center point b of the real box and the center point b of the anchor box p The distance between the two points, c represents the diagonal length of the minimum box covering the anchor box and the ground-truth box, α is a positive trade-off parameter, v is the consistency of the measurement aspect ratio, in is the intersection area of the internal anchor box and the predicted bounding box, and union is the union area of the internal anchor box and the predicted bounding box.
[0089] Step S23: Modify the model configuration file, register the module based on the triple attention mechanism into the model file of the YOLOv11n model, and call the module based on the triple attention mechanism through the training code;
[0090] Step S24: registering the loss function based on the cohesive complete intersection-union ratio as a loss function module in the model file.
[0091] Therefore, the loss function of the existing YOLOv11n model is modified, and the loss function is calculated through back propagation during training.
[0092] Step S3: Figure 4 and Figure 7 As shown in the figure, a minimalist network module (VanillaNet) is designed to replace the original backbone extraction network (i.e. Figure 4 Backbone part); such as Figure 7 and Figure 8As shown in the figure, the adaptive kernel convolution module (AkConv) is used to optimize the convolution module (Conv) of the original YOLOv11n model to further obtain a lightweight and improved YOLOv11n model to achieve model lightweighting.
[0093] The step S3 specifically includes:
[0094] Step S31: Design a minimalist network module to replace the original YOLOv11n model's backbone extraction network (i.e. Figure 4 Backbone part);
[0095] like Figure 9 The figure shows the model structure diagram of the minimalist network module. The number of parameters in its structure is reduced compared to the original one, while the feature extraction capability of the model remains the same.
[0096] Step S32: Use the adaptive kernel convolution module (Akconv module) to add the original convolution module (i.e. Figure 7 Optimization is achieved on the Conv module of
[0097] like Figure 10 As shown in the figure, the adaptive kernel convolution module has a simple structure and strong feature extraction capability, which further reduces the number of model parameters and improves the feature extraction capability of the model.
[0098] Step S33: Register the minimalist network module and the adaptive kernel convolution module into the model file, and modify the model configuration file so that the training code calls the minimalist network module and the adaptive kernel convolution module.
[0099] Step S4: Use the training set and model file to train and obtain the trained YOLOv11n model.
[0100] The step S4 also includes using the validation set and the test set to test the model accuracy and the detection speed of the model.
[0101] Therefore, by training the lightweight and improved model, the best weight parameters are obtained, and the inference speed is high compared with the original algorithm.
[0102] Step S5: During detection, the real-time image of the contactor assembly is input into the trained YOLOv11n model to obtain the detection result of the contactor assembly.
[0103] Wherein, in the step S5, the detection result of the contactor assembly includes whether the wires are leaking, whether the wire sequence is wrong, whether the wires are missing, whether the protective sheet is missing, and whether the protective sheet is in the wrong position;
[0104] Among them, whether the wires are leaking is determined by whether the center points of the wire detection frames are at the same height and whether the center points of the wire detection frames are within the preset range; whether the order of the wires is wrong is determined by whether the order of the detection frame labels of multiple wires is consistent with the preset order; whether the wires are missing is determined by whether the number of wire detection frames is less than the preset value; whether the protective sheet is missing is determined by whether the detection frame of the protective sheet is missing; whether the position of the protective sheet is incorrect is determined by whether the center position of the detection frame of the protective sheet is at the preset position.
[0105] like Figure 11 As shown in the figure, through the intuitive comparison between the original YOLOv11n model (top) and the improved model of the present invention (bottom), the following conclusions can be drawn: in the left column, the original YOLOv11n model misdetects the Yellow and Blue components due to inter-class feature confusion, while the improved model still achieves accurate classification by optimizing the feature decoupling mechanism; in the right column, the Ban component is missed due to drastic changes in illumination (brightness fluctuation amplitude), but the improved model still effectively captures the target features by enhancing the illumination robustness module. This proves the necessity and effectiveness of the present invention.
[0106] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of the present invention. Various modifications are possible. In other words, any simple, equivalent changes and modifications made in accordance with the claims and description of the present invention are within the scope of protection of the patent claims. Anything not fully described in this invention constitutes conventional technology.
Claims
1. A lightweight contactor assembly defect detection method based on YOLOv11n, characterized in that: include: Step S1: Obtain the actual image of the contactor component, perform geometric changes, color changes, mosaic data enhancement, and use labelimg for annotation to generate samples; Step S2: Build an optimized YOLOv11n model. Based on the original YOLOv11n model, it uses the cohesive complete intersection-over-union loss function as the loss function and optimizes the addition of a module based on the triple attention mechanism before the detection head to improve recognition accuracy. Step S3: Design a minimalist network module to replace the original backbone extraction network, and use the adaptive kernel convolution module to optimize the original convolution module to further achieve model lightweighting; Step S4: Use the training set and model file to train and obtain the trained YOLOv11n model; Step S5: During detection, the real-time image of the contactor assembly is input into the trained YOLOv11n model to obtain the detection result of the contactor assembly.
2. The lightweight contactor assembly defect detection method based on YOLOv11n according to claim 1 is characterized in that: The step S1 specifically includes: Step S11: obtaining an actual image of a contactor assembly in a factory as a sample of an original sample data set; Step S12: Use LABELIMG software to annotate the original sample dataset to convert the original sample dataset into XML format; the annotation content includes image size information, annotated target object, target object type name, and target object bounding box coordinates; Step S13: The original sample dataset is augmented by geometric changes, color changes, and mosaic data augmentation, and the labels are subjected to corresponding coordinate transformations during the sample augmentation process to obtain an augmented sample dataset; the geometric changes include translation, rotation, or scaling; the color changes include changing the brightness, color distribution, or saturation of the image; and the mosaic data augmentation includes randomly splicing four images. Step S14: Divide the expanded sample data set into a training set, a validation set, and a test set; The step S4 also includes using the validation set and the test set to test the model accuracy and the detection speed of the model.
3. The lightweight contactor assembly defect detection method based on YOLOv11n according to claim 1 is characterized in that: The step S2 specifically includes: Step S21: Optimize and add a module based on the triple attention mechanism to the three detection heads of the YOLOv11n model; Step S22: using the loss function based on the cohesive complete intersection-over-union ratio as the loss function to calculate the regression loss value of the bounding box, and further optimize the regression ability of the bounding box; Step S23: Modify the model configuration file, register the module based on the triple attention mechanism into the model file of the YOLOv11n model, and call the module based on the triple attention mechanism through the training code; Step S24: registering the loss function based on the cohesive complete intersection-union ratio as a loss function module in the model file.
4. The lightweight contactor assembly defect detection method based on YOLOv11n according to claim 3 is characterized in that: The triple attention mechanism-based module consists of three parallel branches, including a channel-width interaction branch, a channel-height interaction branch, and a spatial interaction branch. The channel-width interaction branch rotates the input tensor around the height axis, converting the dimension from C×H×W to W×C×H. After compressing the channel dimension through Z-Pool, convolution is used to extract the spatial attention weight. The channel-height interaction branch rotates the input tensor around the width axis and converts it to H×C×W. After compressing the channel dimension through Z-Pool, convolution is used to extract the spatial attention weight. The spatial interaction branch refers to directly calculating the spatial attention weights on the original input.
5. The lightweight contactor assembly defect detection method based on YOLOv11n according to claim 3 is characterized in that: The loss function based on the complete intersection-union ratio of cohesion is: Among them, ρ(b,b p ) is the center point b of the real box and the center point b of the anchor box p The distance between the two points, c represents the diagonal length of the minimum box covering the anchor box and the true box, α is a positive trade-off parameter, u is the consistency of the measurement aspect ratio, in is the intersection area of the internal anchor box and the predicted bounding box, and union is the union area of the internal anchor box and the predicted bounding box; The intersection area in of the internal anchor box and the predicted bounding box and the union area union of the internal anchor box and the predicted bounding box are: union=(w×h)×(ratio) 2 +(w p ×h p )×(ratio) 2 -in, Among them, h is the height of the real box, w is the width of the real box, h p is the height of the anchor box, w p is the width of the anchor box, radio is the scaling factor; b is the center point of the real box, x c 、y c are the horizontal and vertical coordinates of the center point of the real frame, b p is the center point of the anchor box, are the horizontal and vertical coordinates of the center point of the anchor box; b l 、b r 、b t 、b b Represent the left boundary of the predicted bounding box, the right boundary of the predicted bounding box, the top boundary of the predicted bounding box, and the bottom boundary of the predicted bounding box respectively; They respectively represent the left boundary coordinates of the internal anchor box, the right boundary coordinates of the internal anchor box, the upper boundary coordinates of the internal anchor box, and the lower boundary coordinates of the internal anchor box, which are used to describe the specific position and size of the anchor box in the image; in and union respectively represent the intersection area of the internal anchor box and the predicted bounding box, and the union area of the internal anchor box and the predicted bounding box.
6. The lightweight contactor assembly defect detection method based on YOLOv11n according to claim 1 is characterized in that: The step S3 specifically includes: Step S31: Design a minimalist network module to replace the backbone extraction network of the YOLOv11n model; Step S32: using the adaptive kernel convolution module to optimize the original convolution module; Step S33: Register the minimalist network module and the adaptive kernel convolution module into the model file, and modify the model configuration file so that the training code calls the minimalist network module and the adaptive kernel convolution module.
7. The lightweight contactor assembly defect detection method based on YOLOv11n according to claim 2 is characterized in that: In step S12 , the annotated content includes the size information of the image, the annotated target object, the type name of the target object, and the bounding box coordinates of the target object.
8. The lightweight contactor assembly defect detection method based on YOLOv11n according to claim 7 is characterized in that: In the step S12, the type names of the target objects include wires and protective sheets of various colors; In step S5, the detection results of the contactor assembly include whether the wires are leaking, whether the wire sequence is wrong, whether the wires are missing, whether the protective sheet is missing, and whether the protective sheet is in the wrong position; Among them, whether the wires are leaking is determined by whether the center points of the wire detection frames are at the same height and whether the center points of the wire detection frames are within the preset range; whether the order of the wires is wrong is determined by whether the order of the detection frame labels of multiple wires is consistent with the preset order; whether the wires are missing is determined by whether the number of wire detection frames is less than the preset value; whether the protective sheet is missing is determined by whether the detection frame of the protective sheet is missing; whether the position of the protective sheet is incorrect is determined by whether the center position of the detection frame of the protective sheet is within the preset position.