A system and method for detecting cosmetic defects in a VCM motor manufacturing process

The VCM motor manufacturing process appearance defect detection system, which utilizes image acquisition, feature encoding, and dynamic multi-template attention calculation, solves the problems of insufficient model generalization ability and poor multi-template detection flexibility in existing technologies, and achieves high-precision defect detection and quality control.

CN122175895APending Publication Date: 2026-06-09GUANGDONG UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGDONG UNIV OF TECH
Filing Date
2026-03-02
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing defect detection methods in VCM motor manufacturing processes suffer from high dependence on the number and type of defect samples, insufficient model generalization ability, difficulty in adapting to changes in production batches and lighting conditions, and poor flexibility of multi-template detection models, leading to misjudgment and missed detection problems.

Method used

The image acquisition module acquires images of the VCM motor surface, the feature extraction module performs unified feature encoding, and the dynamic multi-template attention module performs multi-template matching and attention calculation to generate fused features. Finally, the defect segmentation module performs accurate segmentation and outputs defect detection results.

Benefits of technology

It achieves high-precision and robust appearance defect detection, improves the level of inspection automation and production quality control capabilities, reduces false detections and missed detections, and adapts to defect characterization under complex working conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122175895A_ABST
    Figure CN122175895A_ABST
Patent Text Reader

Abstract

This application relates to the field of image processing technology, and in particular to a system and method for detecting appearance defects in the manufacturing process of VCM motors. The system acquires surface image data of the VCM motor through an image acquisition module, and uses a feature extraction module to encode features of the image to be detected and a normal VCM motor template image to obtain current image features and template features. Then, a dynamic multi-template attention module performs multi-template matching and attention calculation on the two types of features to generate fused features to highlight defect areas. Subsequently, a defect segmentation module segments the appearance abnormal areas corresponding to the fused features. Finally, a detection output module integrates the segmentation results and outputs the appearance defect detection results of the VCM motor, realizing automated defect identification and judgment in the manufacturing process. This invention achieves high-precision and robust automatic detection of appearance defects in the manufacturing process of VCM motors, thereby effectively reducing the false detection and missed detection rates and improving the level of production quality control.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a system and method for detecting appearance defects in the manufacturing process of a VCM motor. Background Technology

[0002] In related technologies, with the rapid development of smart terminal devices, vehicle camera systems, and other products, the VCM (Voice Coil Motor), as a key actuator in camera modules, has a significant impact on imaging performance, focusing accuracy, and product reliability due to its manufacturing quality. VCM motors are typically characterized by their small size, precise structure, and complex surface features. During their manufacturing process, scratches, foreign object adhesion, and slight deformation can easily occur on the surfaces of the housing, magnetic components, and assembly structures. To ensure product consistency and yield, existing technologies typically employ machine vision-based appearance inspection systems to detect and assess the appearance of VCM motors during the manufacturing process.

[0003] However, existing methods for detecting appearance defects in VCM motor manufacturing processes still face significant technical challenges in practical applications. On the one hand, some supervised learning-based defect detection methods are highly dependent on the number and type of defect samples. In VCM motor manufacturing, defect samples are often limited in number and unevenly distributed, especially during the introduction of new products or processes, making it difficult to obtain sufficient labeled samples and resulting in insufficient model generalization ability. On the other hand, while some unsupervised anomaly detection or template comparison methods are less dependent on defect samples, they typically use a single or fixed number of templates as normal references. This makes it difficult to adapt to normal appearance differences caused by variations in production batches, lighting conditions, and surface texture, easily misclassifying normal variations as defects. Furthermore, existing multi-template detection models lack flexibility in template number configuration. After model training, it is difficult to dynamically adjust the number of templates according to the actual detection scenario, limiting the system's adaptability in complex industrial environments.

[0004] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the Invention

[0005] The main objective of this application is to propose a system and method for detecting appearance defects in the manufacturing process of VCM motors, so as to achieve high-precision and robust automatic identification and location of appearance defects in the manufacturing process of VCM motors, thereby effectively improving the accuracy of defect detection and the level of production quality control.

[0006] To achieve the above objectives, one aspect of this application proposes a visual defect detection system for VCM motor manufacturing processes, the system comprising: The image acquisition module is used to acquire surface images of the VCM motor to be inspected during the VCM motor manufacturing process and obtain the image data to be inspected. The feature extraction module is used to perform feature encoding processing on the image data to be detected and at least one normal VCM motor template image to obtain the corresponding current image features and template features; A dynamic multi-template attention module is used to perform multi-template matching and attention calculation based on the current image features and the template features to generate fusion features for enhancing the expression of defective regions; The defect segmentation module is used to segment the appearance abnormality region in the image to be detected based on the fusion features and output the corresponding defect region segmentation result. The detection output module is used to determine the appearance defect information of the VCM motor based on the defect area segmentation result, and output the defect detection result.

[0007] In some embodiments, the feature extraction module includes: The feature encoding unit is used to perform multi-layer feature encoding processing on the image data to be detected and extract the current image features used to characterize the surface structure information of the VCM motor. The template feature extraction unit is used to perform feature encoding processing on the at least one normal VCM motor template image, extract the corresponding template features, and ensure that the template features and the current image features are in the same feature space. The feature output unit is used to output the current image features and the template features.

[0008] In some embodiments, the step of performing multi-layer feature encoding processing on the image data to be detected to extract current image features for characterizing the surface structure information of the VCM motor includes: The image data to be detected is normalized and size aligned, and the processed image is input into a preset encoder network; The image data to be detected is subjected to layer-by-layer downsampling and feature extraction processing through the multi-level coding structure in the encoder network; The multi-scale feature maps containing different spatial resolutions and semantic levels are obtained through the multi-level coding structure, and feature alignment and mapping processing are performed on the multi-scale feature maps at each level to generate the current image features in a unified feature space.

[0009] In some embodiments, the multi-level coding structure includes a deep convolutional layer and a pointwise convolutional layer; The deep convolutional layer is used to extract local spatial structural features of the VCM motor surface; The pointwise convolutional layer is used to perform cross-channel feature fusion and channel number adjustment on the features processed by the deep convolutional layer to form high-dimensional semantic features that characterize the overall structural information of the VCM motor surface.

[0010] In some embodiments, the step of performing multi-template matching and attention calculation based on the current image features and the template features to generate fusion features for enhancing the expression of defective regions includes: The current image features and the template features are projected to generate query features and key features in a unified feature space; Pixel-level similarity calculation is performed based on the query features and the key features to obtain the matching degree information between the current image features and each of the template features; The matching degree information corresponding to multiple template features is fused to generate a global matching weight map that represents the normal consistency of the current image, and the number of template features can be dynamically configured. The current image features are weighted based on the global matching weight map and then fused with the current image features to generate the fused features.

[0011] In some embodiments, the step of performing pixel-level similarity calculation based on the query features and the key features to obtain matching degree information between the current image features and each of the template features includes: The query features and each of the key features are flattened in the spatial dimension to form a pixel-level feature representation; Matrix multiplication is performed based on the pixel-level feature representation, and pixel-level similarity response is calculated in combination with a preset attention scaling factor; Extract the matching response value for the corresponding pixel position from the similarity response; The matching response value is restored to a matching degree feature map with the same feature space resolution as the current image, thereby obtaining the matching degree information between the current image features and each of the template features.

[0012] In some embodiments, the step of weighting the current image features based on the global matching weight map and fusing them with the current image features to generate the fused features includes: Based on the global matching weight map, a weighted operation is performed on the feature values ​​of corresponding pixel positions in the current image features to obtain weighted features; Perform residual fusion processing on the weighted features and the current image features; The features obtained through the residual fusion process are output as the fused features.

[0013] In some embodiments, the step of segmenting the appearance abnormality region in the image to be detected based on the fusion features and outputting the corresponding defect region segmentation result includes: The fused features are input into the decoder network, and transposed convolution processing is performed on the fused features; During the transposed convolution process, the upsampled features are skipped and connected to the features output from the corresponding layer in the feature extraction module, and feature fusion processing is performed. Based on the features after multi-level upsampling and feature fusion processing, a segmentation feature map with the same spatial resolution as the image to be detected is generated. Pixel-level classification processing is performed on the segmentation feature map to output the defect region segmentation result.

[0014] In some embodiments, the calculation formula for the transposed convolution process is as follows: ; in, This indicates the spatial location of the output feature map obtained by transpose convolution. Eigenvalues ​​at; represents the input feature map before transpose convolution; i and j represent the spatial index positions of the upsampled feature map in the row and column directions, respectively; m and n represent the offset index of the upsampled convolution kernel in the spatial dimension; k represents the size of the upsampled convolution kernel. Indicates the corresponding position during the transpose convolution process. The weighting coefficients; s represents the upsampling step size; Indicates the transposed convolution kernel; This indicates the floor function.

[0015] To achieve the above objectives, another aspect of this application proposes a method for detecting appearance defects in the manufacturing process of a VCM motor, the method comprising the following steps: Acquire surface images of the VCM motor to be inspected, and obtain the image data to be inspected; The image data to be detected and at least one normal VCM motor template image are subjected to feature encoding processing to obtain the corresponding current image features and template features; Based on the current image features and the template features, perform multi-template matching and attention calculation to generate fusion features for enhancing the expression of defective regions; Based on the fusion features, the abnormal appearance regions in the image to be detected are segmented, and the corresponding defect region segmentation results are output. Based on the defect region segmentation results, the appearance defect information of the VCM motor is determined, and the defect detection results are output.

[0016] To achieve the above objectives, another aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the system described above.

[0017] To achieve the above objectives, another aspect of the embodiments of this application proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the system described above.

[0018] To achieve the above objectives, another aspect of the embodiments of this application proposes a computer program product, including a computer program that, when executed by a processor, implements the system described above.

[0019] The embodiments of this application include at least the following beneficial effects: This application provides a VCM motor manufacturing process appearance defect detection system and method. This solution introduces an image acquisition module into the manufacturing process to achieve online, non-contact acquisition of the VCM motor surface state, avoiding the problems of low efficiency and poor consistency caused by manual sampling inspection. The feature extraction module performs unified feature encoding on the image to be detected and the normal VCM motor template image, so that the detection process uses normal appearance features as a reference, effectively suppressing the influence of illumination changes, material differences and background noise on the detection results. Furthermore, the dynamic multi-template attention module matches and calculates attention between the current image features and multi-template features, which can adaptively highlight the regional features that are significantly different from the normal template, thereby enhancing the expressive ability of small defects and hidden defects in the feature space and improving the stability and distinguishability of defect characterization under complex working conditions. On this basis, the defect segmentation module accurately segments the abnormal appearance area based on the fused features, which can directly obtain the spatial location and morphological information of the defect, avoiding false detection and missed detection caused by relying solely on overall discrimination. Finally, the detection output module outputs clear defect detection information based on the segmentation results, which facilitates subsequent quality judgment and process traceability. In summary, this invention enables high-precision and robust appearance defect detection during VCM motor manufacturing, significantly improving the level of automation in inspection and production quality control, and has good engineering application value. Attached Figure Description

[0020] Figure 1 This is a schematic diagram of a VCM motor manufacturing process appearance defect detection system provided in an embodiment of this application; Figure 2 This is a flowchart illustrating the construction steps of the dynamic multi-template attention module provided in the embodiments of this application; Figure 3 This is a schematic diagram of the VCM motor appearance defect detection network structure provided in an embodiment of this application; Figure 4 This is a schematic diagram of the original surface image of the VCM motor to be tested, provided in the embodiments of this application. Figure 5 This is a schematic diagram of the appearance defect detection results of the VCM motor provided in the embodiments of this application; Figure 6 This is a flowchart illustrating a method for detecting appearance defects in the manufacturing process of a VCM motor, as provided in an embodiment of this application. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit it. In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with those of this application; they are merely examples of apparatuses and methods consistent with some aspects of the embodiments of this application as detailed in the appended claims.

[0022] It is understood that the terms “first,” “second,” etc., used in this application may be used herein to describe various concepts, but unless otherwise stated, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the embodiments of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the words “if,” “when,” or “in response to a determination” as used herein may be interpreted as “when…” or “when…” or “in response to a determination.”

[0023] As used in this application, the terms "at least one", "multiple", "each", "any", etc., "at least one" includes one, two or more, "multiple" includes two or more, "each" refers to each of the corresponding multiples, and "any" refers to any one of the multiples.

[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0025] This application provides a system and method for detecting appearance defects in the manufacturing process of VCM motors. This solution introduces an image acquisition module during manufacturing to achieve online, non-contact acquisition of the VCM motor's surface condition, avoiding the low efficiency and poor consistency issues associated with manual sampling. A feature extraction module performs unified feature encoding on the image to be detected and a normal VCM motor template image, ensuring the detection process uses normal appearance features as a reference, effectively suppressing the influence of lighting changes, material differences, and background noise on the detection results. Furthermore, a dynamic multi-template attention module matches and calculates attention between the current image features and multi-template features, adaptively highlighting regions significantly different from the normal template, thereby enhancing the representation of minute and hidden defects in the feature space and improving the stability and discriminability of defect characterization under complex working conditions. Based on this, a defect segmentation module accurately segments abnormal appearance areas based on fused features, directly obtaining the spatial location and morphological information of the defects, avoiding false detections and missed detections caused by relying solely on overall discrimination. Finally, the detection output module outputs clear defect detection information based on the segmentation results, facilitating subsequent quality judgment and process traceability. In summary, this invention enables high-precision and robust appearance defect detection during VCM motor manufacturing, significantly improving the level of automation in inspection and production quality control, and has good engineering application value.

[0026] This application provides a VCM motor manufacturing process appearance defect detection system, relating to the field of image processing technology. This VCM motor manufacturing process appearance defect detection system can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, or vehicle terminal, but is not limited to these. The server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network. The software can be an application implementing the VCM motor manufacturing process appearance defect detection system, but is not limited to the above forms.

[0027] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics devices, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0028] Figure 1 This is a schematic diagram of an optional module of a VCM motor manufacturing process appearance defect detection system provided in an embodiment of this application. Figure 1 The system may include, but is not limited to: The image acquisition module is used to acquire surface images of the VCM motor to be inspected during the VCM motor manufacturing process and obtain the image data to be inspected. In this embodiment, the image acquisition module is installed at the automated inspection station of the VCM motor manufacturing line. It is used to acquire stable and repeatable surface images of VCM motors during the manufacturing process without affecting the production line's cycle time. The VCM motor to be inspected is conveyed to the inspection position via a conveyor belt and placed in a dedicated VCM carrier. Positional constraints in the X and Y directions are achieved through a positioning pin structure, and the VCM motor is fixed to the carrier surface using a vacuum adsorption device. This prevents imaging deviations caused by vibration or displacement during the imaging process, thereby ensuring the consistency of different VCM motor samples in the image space.

[0029] The image acquisition module further includes a high-precision three-axis motion platform, which consists of linear modules along the X, Y, and Z axes. The X and Y axes drive the imaging module to perform planar positioning and movement above the VCM carrier, while the Z axis is used for fine-tuning the imaging height. During actual shooting, based on the pre-calibrated coordinates of the key detection areas of the VCM motor, the three-axis motion platform is controlled to move the imaging module to the corresponding shooting position. Fine-tuning along the Z axis ensures that the focal plane of the industrial camera maintains the optimal imaging distance with the surface of the VCM motor, thereby ensuring that clear, out-of-focus images are obtained for surface areas at different locations and heights.

[0030] After the position adjustment is completed, the image acquisition module triggers the industrial camera to take pictures under unified scheduling. Simultaneously, the coaxial light source is activated to create a uniform and stable lighting environment on the VCM motor surface, reducing the impact of shadows, reflections, and ambient light variations on image quality. The VCM motor surface image acquired by the industrial camera is transmitted to the industrial control computer in real time as a digital signal. This image is then input as the image data to be inspected into the subsequent feature extraction module for processing to detect appearance defects. This provides a high-quality image foundation for subsequent defect analysis based on a dynamic multi-template attention mechanism.

[0031] The feature extraction module is used to perform feature encoding processing on the image data to be detected and at least one normal VCM motor template image to obtain the corresponding current image features and template features; The feature extraction module includes: The feature encoding unit is used to perform multi-layer feature encoding processing on the image data to be detected and extract the current image features used to characterize the surface structure information of the VCM motor. The template feature extraction unit is used to perform feature encoding processing on at least one normal VCM motor template image, extract the corresponding template features, and ensure that the template features and the current image features are in the same feature space. The feature output unit is used to output the current image features and template features.

[0032] In this embodiment, the feature extraction module is used to perform feature encoding processing on the acquired surface image data of the VCM motor to be detected and at least one normal VCM motor template image. This module adopts a shared parameter feature encoding network structure, performing the same feature extraction process on the image to be detected and the template image, thereby ensuring that both are encoded under the same feature representation system. This makes the output current image features and template features in a unified feature space, providing a comparable feature foundation for subsequent template-based defect detection processing.

[0033] Specifically, the feature encoding unit in the feature extraction module performs multi-layer feature encoding processing on the image to be detected. Through layer-by-layer convolution and downsampling operations, it extracts multi-scale feature information such as edge contours, structural morphology, and texture distribution of the VCM motor surface at each level, so that the obtained current image features simultaneously contain global structural features and local detail features. This multi-layer encoding method can effectively suppress the influence of illumination changes and individual differences on feature representation, and enhance the ability to represent appearance abnormalities such as fine scratches, foreign object adhesion, and surface unevenness.

[0034] Simultaneously, the template feature extraction unit performs the same feature encoding process as the image to be detected on at least one normal VCM motor template image to obtain the corresponding template features, ensuring that the template features are consistent with the current image features in terms of feature dimension, semantic level, and distribution. The feature output unit outputs the current image features and template features to the subsequent processing module to support defect region analysis based on multi-template matching and attention enhancement, thereby improving the accuracy and stability of VCM motor appearance defect detection.

[0035] Multi-layer feature encoding is performed on the image data to be detected to extract current image features that characterize the surface structure information of the VCM motor, including: The image data to be detected is normalized and size aligned, and the processed image is input into a preset encoder network; The multi-level coding structure in the encoder network is used to perform layer-by-layer downsampling and feature extraction on the image data to be detected. A multi-scale feature map containing different spatial resolutions and semantic levels is obtained through a multi-level coding structure. Feature alignment and mapping processing are performed on the multi-scale feature maps at each level to generate the current image features in a unified feature space.

[0036] Specifically, the multi-level coding structure includes depthwise convolutional layers and pointwise convolutional layers; Among them, the deep convolutional layer is used to extract the local spatial structure features of the VCM motor surface; Pointwise convolutional layers are used to perform cross-channel feature fusion and channel number adjustment on features processed by deep convolutional layers to form high-dimensional semantic features that characterize the overall structural information of the VCM motor surface.

[0037] In this embodiment, before performing multi-layer feature encoding processing on the image data to be detected, the acquired VCM motor surface image is first normalized and size aligned to ensure that images acquired under different operating conditions and batches maintain consistency in brightness distribution and spatial scale. The preprocessed image is then input into a preset encoder network as input data for multi-layer feature encoding processing, thereby providing a unified and stable image foundation for subsequent feature extraction.

[0038] Subsequently, the encoder network performs layer-by-layer downsampling and feature extraction processing on the image to be detected through its internal multi-level coding structure. Each level of the coding structure includes deep convolutional layers and pointwise convolutional layers. The deep convolutional layers are used to extract local spatial structural features of the VCM motor surface, effectively capturing surface texture changes, edge contours, and local anomaly information. The pointwise convolutional layers are used to perform cross-channel feature fusion and channel number adjustment on the features processed by the deep convolutional layers to form high-dimensional semantic features with stronger representation capabilities of the overall structure of the VCM motor surface. As the coding levels gradually deepen, the spatial resolution of the features gradually decreases while the semantic expressive power continuously increases.

[0039] After completing multi-level encoding, the encoder network obtains multi-scale feature maps containing different spatial resolutions and semantic levels. For each level of multi-scale feature map, feature alignment and mapping are performed to map them to a unified feature space in terms of spatial size and channel dimension. The aligned multi-scale features are then integrated to generate current image features representing the surface structure information of the VCM motor. Through this method, the generated current image features simultaneously fuse local detail features and overall semantic features, providing stable and reliable feature input for subsequent defect detection processing.

[0040] Specifically, this embodiment uses EfficientNet-B3 as the network backbone. The core of EfficientNet-B3 is the MBConv (Mobile Inverted Residual Conv) block, which achieves multi-scale feature extraction through width scaling factor (w=1.2), depth scaling factor (d=1.4), and resolution scaling factor (r=1.5). It extracts features through an encoder network, as described in detail below: The encoder employs serially cascaded MBConv blocks, achieving 5 downsampling operations through stride control. The input image size is 512×512×3 (RGB image), and the output is a 5-level multi-scale feature map (denoted as F1-F5, corresponding to different resolutions and semantic information). Downsampling at each stage is achieved by setting the stride of the first-layer depthwise convolution of the MBConv block to 2. The depthwise separable convolution is divided into depthwise convolution (channel-wise convolution, preserving spatial information) + pointwise convolution (cross-channel fusion, adjusting the number of channels), which achieves downsampling while controlling the computational load.

[0041] The formula for calculating depthwise convolution is as follows: ; In the formula, This indicates that after depthwise convolution, the spatial location... The output feature value obtained at the point; i and j represent the spatial index positions of the feature map in the row and column directions, respectively; m and n represent the offset index of the convolution kernel in the spatial dimension; k represents the size of the depthwise convolution kernel; Indicates the depthwise convolution kernel at the offset position The corresponding convolution weight parameters are indicated at the specified location. This indicates that the input feature map is at the current spatial location. Centered on, offset via the convolution kernel The feature values ​​at the corresponding positions after mapping are used to provide local neighborhood feature information for participating in depthwise convolution operations; where the input feature map is the single-channel feature map output by the previous layer of the network in the encoder stage.

[0042] The formula for calculating pointwise convolution is as follows: ; In the formula, This indicates that after pointwise convolution, the spatial position... The output feature value obtained at the location; Indicates the spatial location of the input feature map , No. The feature values ​​on each input channel; the input feature map is the feature result after depthwise convolution, used to provide local feature information for each channel; This represents the number of channels in the input feature map, i.e., the total number of input channels participating in the pointwise convolution operation; This indicates the corresponding point in pointwise convolution. Weight parameters for each input channel.

[0043] The dynamic multi-template attention module is used to perform multi-template matching and attention calculation based on the current image features and template features, and generate fusion features to enhance the expression of defective regions; Specifically, multi-template matching and attention calculation are performed based on current image features and template features to generate fusion features for enhancing the representation of defective regions, including: The current image features and template features are projected to generate query features and key features in a unified feature space; Pixel-level similarity calculation is performed based on query features and key features to obtain matching information between the current image features and each template feature; The matching degree information corresponding to multiple template features is fused to generate a global matching weight map that represents the normal consistency of the current image, and the number of template features can be dynamically configured. The current image features are weighted based on the global matching weight map and then fused with the current image features to generate fused features.

[0044] Specifically, pixel-level similarity calculation is performed based on query features and key features to obtain matching information between the current image features and each template feature, including: The query features and each key feature are flattened in the spatial dimension to form a pixel-level feature representation; Matrix multiplication is performed based on pixel-level feature representations, and pixel-level similarity responses are calculated in conjunction with a preset attention scaling factor. Extract the matching response value for the corresponding pixel position from the similarity response; The matching response value is restored to a matching degree feature map with the same feature space resolution as the current image, thus obtaining the matching degree information between the current image features and each template feature.

[0045] Specifically, the current image features are weighted based on the global matching weight map and then fused with the current image features to generate fused features, including: Based on the global matching weight map, a weighted operation is performed on the feature values ​​of corresponding pixel positions in the current image features to obtain the weighted features; Perform residual fusion processing on the weighted features and the current image features; The features obtained through residual fusion processing are output as fused features.

[0046] In this embodiment, the dynamic multi-template attention module performs multi-template matching and attention calculation based on the current image features and template features corresponding to at least one normal VCM motor template image to generate fusion features for enhancing the representation of defect regions. This module introduces a multi-template reference mechanism, enabling the current image to be detected to be compared with multiple normal surface patterns. This maintains the stability of normal regions while significantly highlighting potential defect regions that differ from normal templates. Furthermore, the number of template features can be dynamically configured according to actual detection needs.

[0047] Specifically, feature projection processing is first performed on the current image features and the features of each template. Through feature mapping, the two are transformed into query features and key features in a unified feature space. At the same time, corresponding value features are generated for the current image features. The feature projection process adopts a shared parameter approach to ensure that the feature distribution of different template features remains consistent after mapping. This allows subsequent matching calculations to be performed in a unified feature semantic space and avoids introducing additional structural adjustments due to changes in the number of templates.

[0048] Subsequently, pixel-level similarity calculations are performed based on the query features and each key feature to obtain the matching degree information between the current image features and each template feature. In this process, the query features and key features are first flattened in the spatial dimension to form pixel-level feature representations. Then, similarity calculations are performed based on these pixel-level feature representations to obtain similarity responses reflecting the degree of similarity between each pixel position in the current image and the corresponding position in the template. Afterward, the matching response values ​​for the corresponding pixel positions are extracted from the similarity responses and restored to a matching degree feature map with the same spatial resolution as the current image features, thereby obtaining the one-to-one matching degree information between the current image features and each template feature.

[0049] After obtaining matching degree information corresponding to multiple templates, the matching degree information is fused to generate a global matching weight map that characterizes the normal consistency of the current image. Specifically, the matching degree feature maps corresponding to each template are combined, and the matching results of different templates are integrated through a fusion operation. Regions that show consistency in most templates are identified as normal regions, while regions that show inconsistency in multiple templates are highlighted. In this way, the global matching weight map can stably reflect the degree of consistency between each region of the current image and the normal template distribution, and maintains good adaptability when the number of templates changes.

[0050] Finally, the current image features are weighted based on the global matching weight map and fused with the current image features to generate the final fused features. Specifically, the feature values ​​of corresponding pixel positions in the current image features are weighted according to the global matching weight map to suppress the feature responses in regions with high normal consistency and enhance the feature responses in regions with low normal consistency. Subsequently, the weighted features are residually fused with the original current image features, so that the output features highlight the expression of the defect region while still retaining the original semantic feature information, thus obtaining the fused features for subsequent defect segmentation processing.

[0051] Specifically, refer to Figure 2 As shown, Figure 2 A flowchart illustrating the construction steps of a dynamic multi-template attention module; The dynamic multi-template attention module achieves dynamic adaptation to any number of templates through steps such as feature projection, pixel-level similarity calculation, multi-template matching degree fusion, defect region weighted enhancement, and residual fusion. Values ​​are taken from the current image to avoid dilution of defective features by normal template features. The final output features are fused with attention weights and used for subsequent decoder segmentation. The specific steps are as follows: Feature projection (generation) Three independent 1×1 convolutional layers are used to linearly project the features of the current image and the template image respectively. Only the weight distribution of the feature channels is adjusted, without changing the spatial dimension or the flexibility of the number of templates. Current image features Through the projection layer Generate query features Through the projection layer Generated value characteristics Features of each template image By sharing the projection layer Generate key features Projection layer parameter sharing ensures consistency in the feature space of different templates and supports dynamic addition or removal of the number of templates. That is, ; ; ; In the formula, This represents the convolution operation. For N template images, after projection... , dimension .

[0052] Pixel-level similarity calculation (generating template matching degree). First, ... Flattened into a pixel sequence (reducing spatial dimensions) Convert to one-dimensional pixel count Then, pixel-level similarity between the current image and each template image is calculated using matrix multiplication. From a spatial dimension Flattened ,pass and The similarity is calculated by multiplying the transpose of the matrix, and then multiplied by a scaling factor. To avoid gradient vanishing caused by excessively high feature dimensions, a similarity matrix is ​​obtained. The diagonal elements correspond to the matching degree (normality) of the same pixel position. This is described using the following formula.

[0053] First, perform the flattening operation: ; ; ; In the formula, , and These respectively represent query features Value characteristics Bond features The feature matrix obtained after flattening the spatial dimension; Calculate the similarity matrix again: ; In the formula, for The transpose of, with dimension After matrix multiplication Dimensions The single-pixel matching degree is obtained by taking the diagonal elements: ; In the formula, Represents from the similarity matrix Extract and map to spatial location The similarity value; H and W represent the height and width of the feature map in the spatial dimension, respectively.

[0054] After restoring the spatial dimensions, a single-template matching degree map is obtained. : ; Multi-template matching degree fusion (adapting to dynamic N). A lightweight 3×3 convolutional layer is used to fuse the matching degree maps of N templates, outputting a global matching degree map without binding to the number of templates. The matching degree maps of N templates are then... Concatenate according to channel dimension (dimension is...) The matching graph is fused by reducing the maximum value of the channel dimension, and then the fusion result is normalized to the [0,1] interval by the Sigmoid function to obtain the global matching degree graph. The closer the value is to 1, the higher the matching degree between the current image pixels and the normal pixels of the template (no defects); the closer the value is to 0, the lower the matching degree (potential defects). The specific formula is as follows.

[0055] ; ; in, Dimensions After fusion Dimensions ,and .

[0056] Defect region weighting enhancement (generating attention features). The global matching degree map is inverted to obtain the defect weights, which are then compared with... Features are weighted at the pixel level to amplify the features of the defect area. Because... A higher value indicates that the pixels are more normal, therefore... Obtain the defect weight map (normal areas have weights close to 0, and defect areas have weights close to 1), and compare this weight map with the value characteristics of the current map. Pixel-level multiplication is performed to amplify defect features and suppress normal features, preserving detailed information about small defects. ; in, This represents pixel-level element-wise multiplication. Through broadcasting mechanism and Perform multiplication. This is a weighted feature enhancement for defects.

[0057] Residual fusion (outputting final features). To avoid feature degradation caused by the attention module, the weighted features are residually concatenated with the original current map features. Features of the original current graph Element-wise addition is performed to retain both the defect features filtered by the attention module and the original semantic features extracted by the encoder, thereby improving the model's stability and generalization ability, and ultimately outputting fused features. The input is fed into the decoder for subsequent upsampling and segmentation, i.e.: ; Among them, the output Dimensions It has the same output dimension as the encoder and can be directly input into the decoder stage.

[0058] The defect segmentation module is used to segment abnormal regions in the image to be detected based on fused features and output the corresponding defect region segmentation results. Specifically, based on fusion features, the abnormal appearance regions in the image to be detected are segmented, and the corresponding defect region segmentation results are output, including: The fused features are input into the decoder network, and transposed convolution processing is performed on the fused features; During the transposed convolution process, the upsampled features are skipped and connected to the features output from the corresponding layer in the feature extraction module, and feature fusion processing is performed. Based on the features after multi-level upsampling and feature fusion processing, a segmentation feature map with the same spatial resolution as the image to be detected is generated. In this embodiment, the defect segmentation module is positioned after the dynamic multi-template attention module. It performs step-by-step decoding of the fused features output by the dynamic multi-template attention module, thereby achieving accurate segmentation of abnormal areas on the surface of the VCM motor. The defect segmentation module employs a decoder network structure. Its input is the fused features, and its output is the defect region segmentation result with the same spatial resolution as the original image to be detected. By introducing a multi-level upsampling and feature fusion mechanism, the segmentation result maintains high-level semantic consistency while possessing good spatial localization accuracy, making it suitable for detecting minute and edge defects.

[0059] Specifically, the fused features are first input into the decoder network, and transposed convolutions are performed on the fused features to progressively restore the spatial resolution of the feature maps. During each decoding stage, the transposed convolutions are used to upsample the low-resolution features, gradually bringing the feature map size closer to the original size of the image to be detected, while preserving the defect-enhancing semantic information contained in the fused features. This progressive upsampling method achieves a smooth transition from high-level semantic features to high-resolution spatial representation.

[0060] During the transposed convolution upsampling process, the upsampled features are skip-connected with the corresponding layer's output features from the feature extraction module, and feature fusion processing is then performed. Skip connections are used to introduce shallow feature information retained from the encoding stage, enabling the decoder to supplement edge contours, local textures, and other detailed information while restoring spatial resolution, thereby effectively improving the accuracy of defect boundary localization. Through the fusion processing of upsampled features and corresponding layer features, the segmentation features simultaneously contain high-level semantic information and low-level spatial detail information.

[0061] After completing multi-level upsampling and feature fusion processing, the decoder network generates a segmentation feature map with the same spatial resolution as the image to be detected. This segmentation feature map characterizes the feature response of each pixel location within an abnormal or normal appearance region, and can be further used to obtain the final defect region segmentation result through thresholding or category mapping. Through these methods, the defect segmentation module can achieve stable and accurate segmentation of abnormal appearance regions of VCM motors under conditions of complex surface textures and subtle structural differences, providing a reliable basis for subsequent defect judgment and result output.

[0062] Specifically, the calculation formula for transposed convolution is as follows: ; in, This indicates the spatial location of the output feature map obtained by transpose convolution. Eigenvalues ​​at; represents the input feature map before transpose convolution; i and j represent the spatial index positions of the upsampled feature map in the row and column directions, respectively; m and n represent the offset index of the upsampled convolution kernel in the spatial dimension; k represents the size of the upsampled convolution kernel. Indicates the corresponding position during the transpose convolution process. The weighting coefficients; s represents the upsampling step size; Indicates the transposed convolution kernel; This indicates the floor function.

[0063] The detection output module is used to determine the appearance defect information of the VCM motor based on the defect area segmentation results and output the defect detection results.

[0064] In this embodiment, the detection output module is used to parse and structure the defect region segmentation results output by the defect segmentation module to determine the appearance defect information of the VCM motor and output the final detection result. The defect region segmentation result is a defect mask map with the same spatial resolution as the image to be detected, where different pixel positions are used to characterize whether there are appearance abnormalities in the corresponding region. The detection output module first performs connected component analysis on the defect mask map to distinguish different defect instances, and extracts basic geometric information such as spatial location, region contour, and pixel coverage for each defect region.

[0065] In further processing, the detection output module calculates the relative positional relationship of each defect region on the VCM motor surface based on the geometric information of the defect region. It then combines this with the detection area number, workstation information, and VCM motor structural layout associated with the image acquisition stage to perform localization mapping of the defect regions. Through this mapping, pixel-level defect regions can be converted into defect location descriptions corresponding to the actual workpiece surface. The module also determines the size, quantity distribution, and whether the defect regions are located in critical structural areas, thus forming complete defect feature description information.

[0066] After completing the defect information analysis, the inspection output module comprehensively judges the appearance status of the VCM motor according to preset judgment rules and generates corresponding inspection output results. The inspection output results may include pass / fail judgment indicators, defect area annotation images, and corresponding defect parameter information, and can be further transmitted to the upper control system or manufacturing execution system for recording and traceability. Through this method, standardized output of VCM motor appearance defects is achieved, supporting production line applications and providing a reliable basis for subsequent quality control and process optimization.

[0067] refer to Figure 3 As shown, Figure 3 This diagram illustrates the network structure for VCM motor appearance defect detection based on a dynamic multi-template attention mechanism in this invention. The left side of the diagram shows a multi-input structure, corresponding to the current image of the VCM motor to be detected and at least one template image of a normal VCM motor. Each input image undergoes multi-layer feature encoding processing through a feature encoding network with identical structure and shared parameters to extract deep features that characterize the surface structure and texture information of the VCM motor. By sharing the encoding structure, the features of the current image and the template features are ensured to be in a unified feature space, providing a consistent feature foundation for subsequent feature matching and fusion.

[0068] The area marked with a dashed box in the center of the figure represents the dynamic multi-template attention process, corresponding to the dynamic multi-template attention module in the claims. In this module, current image features and multiple template features are simultaneously introduced. Through feature projection and pixel-level matching mechanisms, the matching relationship between each location in the current image and different templates is calculated. The multi-template matching results are then fused to generate a global matching weight reflecting the consistency between each region of the current image and the normal template. This weight is used to distinguish between normal regions and potentially abnormal regions, thereby significantly enhancing defective regions at the feature level. Simultaneously, the number of template inputs can be dynamically configured according to actual detection needs.

[0069] The right side of the figure shows the decoding and segmentation output structure, corresponding to the defect segmentation module. The fused features, enhanced by the dynamic multi-template attention module, are input to the decoder network. Spatial resolution is gradually restored through multi-level upsampling and skip connections, and shallow structural features from the encoding stage are fused to ultimately generate a defect segmentation result with spatial resolution consistent with the original image to be detected. The output results represent the location and extent of abnormal areas on the VCM motor surface in the form of a heatmap or segmentation map, providing an intuitive and reliable basis for subsequent defect judgment and detection result output.

[0070] refer to Figure 4 and Figure 5 As shown, Figure 4 This is a schematic diagram of the original surface image of the VCM motor to be inspected. Figure 5 The image shows the defect detection results obtained based on the method of this invention.

[0071] exist Figure 4 In the original image, red circles mark areas of visual abnormality on the surface of the VCM motor. These abnormal areas include minute defects located at the edges of the housing, at local structural joints, and in areas of surface texture, serving as a visual indication of the actual location of the defects. Due to the complex surface structure and uneven texture distribution of the VCM motor, some defects have low contrast in the original image, making them difficult to identify accurately and consistently by visual inspection.

[0072] Figure 5 The detection result image shows the segmentation result obtained after dynamic multi-template attention and defect segmentation processing based on the present invention. The green-filled area represents the defect pixel region automatically identified by the algorithm. It can be seen that the green-filled area has good consistency with the defect location indicated by the red circle in the original image on the left in terms of spatial position and shape, accurately covering the real defect area and effectively suppressing false detections of normal areas.

[0073] The above comparison demonstrates that by matching and fusing current image features with multi-template features, and performing fine segmentation processing on the fused features in the defect segmentation module, this invention can accurately locate and segment defects in the appearance of VCM motors under complex backgrounds and minor structural changes, thereby improving the reliability and practicality of defect detection.

[0074] Please see Figure 6 This application also provides a method for detecting appearance defects in the manufacturing process of a VCM motor, the method comprising the following steps: S1: Acquire a surface image of the VCM motor to be inspected and obtain the image data to be inspected; S2: Perform feature encoding processing on the image data to be detected and at least one normal VCM motor template image to obtain the corresponding current image features and template features; S3: Perform multi-template matching and attention calculation based on the current image features and template features to generate fusion features for enhancing the expression of defective regions; S4: Based on the fusion features, segment the abnormal appearance regions in the image to be detected and output the corresponding defect region segmentation results; S5: Determine the appearance defect information of the VCM motor based on the defect area segmentation results, and output the defect detection results.

[0075] It is understood that the content of the above system embodiments is applicable to this method embodiment. The specific functions implemented in this method embodiment are the same as those in the above system embodiments, and the beneficial effects achieved are also the same as those achieved in the above system embodiments.

[0076] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the system described above. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.

[0077] It is understood that the content of the above system embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above system embodiments, and the beneficial effects achieved are also the same as those achieved by the above system embodiments.

[0078] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the system described above.

[0079] It is understood that the content of the above system embodiments is applicable to this storage medium embodiment. The specific functions implemented by this storage medium embodiment are the same as those of the above system embodiments, and the beneficial effects achieved are also the same as those achieved by the above system embodiments.

[0080] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the system described above.

[0081] It is understood that the content of the above system embodiments is applicable to the present program product embodiments. The specific functions implemented by the present program product embodiments are the same as those of the above system embodiments, and the beneficial effects achieved are also the same as those achieved by the above system embodiments.

[0082] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0083] This application provides a system and method for detecting appearance defects in the manufacturing process of VCM motors. This solution introduces an image acquisition module during manufacturing to achieve online, non-contact acquisition of the VCM motor's surface condition, avoiding the low efficiency and poor consistency issues associated with manual sampling. A feature extraction module performs unified feature encoding on the image to be detected and a normal VCM motor template image, ensuring the detection process uses normal appearance features as a reference, effectively suppressing the influence of lighting changes, material differences, and background noise on the detection results. Furthermore, a dynamic multi-template attention module matches and calculates attention between the current image features and multi-template features, adaptively highlighting regions significantly different from the normal template, thereby enhancing the representation of minute and hidden defects in the feature space and improving the stability and discriminability of defect characterization under complex working conditions. Based on this, a defect segmentation module accurately segments abnormal appearance areas based on fused features, directly obtaining the spatial location and morphological information of the defects, avoiding false detections and missed detections caused by relying solely on overall discrimination. Finally, the detection output module outputs clear defect detection information based on the segmentation results, facilitating subsequent quality judgment and process traceability. In summary, this invention enables high-precision and robust appearance defect detection during VCM motor manufacturing, significantly improving the level of automation in inspection and production quality control, and has good engineering application value.

[0084] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

[0085] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.

[0086] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0087] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0088] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.

Claims

1. A visual defect detection system for VCM motor manufacturing process, characterized in that, The system includes: The image acquisition module is used to acquire surface images of the VCM motor to be inspected during the VCM motor manufacturing process and obtain the image data to be inspected. The feature extraction module is used to perform feature encoding processing on the image data to be detected and at least one normal VCM motor template image to obtain the corresponding current image features and template features; A dynamic multi-template attention module is used to perform multi-template matching and attention calculation based on the current image features and the template features to generate fusion features for enhancing the expression of defective regions; The defect segmentation module is used to segment the appearance abnormality region in the image to be detected based on the fusion features and output the corresponding defect region segmentation result. The detection output module is used to determine the appearance defect information of the VCM motor based on the defect area segmentation result, and output the defect detection result.

2. The system according to claim 1, characterized in that, The feature extraction module includes: The feature encoding unit is used to perform multi-layer feature encoding processing on the image data to be detected and extract the current image features used to characterize the surface structure information of the VCM motor. The template feature extraction unit is used to perform feature encoding processing on the at least one normal VCM motor template image, extract the corresponding template features, and ensure that the template features and the current image features are in the same feature space. The feature output unit is used to output the current image features and the template features.

3. The system according to claim 2, characterized in that, The step of performing multi-layer feature encoding processing on the image data to be detected to extract current image features used to characterize the surface structure information of the VCM motor includes: The image data to be detected is normalized and size aligned, and the processed image is input into a preset encoder network; The image data to be detected is subjected to layer-by-layer downsampling and feature extraction processing through the multi-level coding structure in the encoder network; The multi-scale feature maps containing different spatial resolutions and semantic levels are obtained through the multi-level coding structure, and feature alignment and mapping processing are performed on the multi-scale feature maps at each level to generate the current image features in a unified feature space.

4. The system according to claim 3, characterized in that, The multi-level coding structure includes a depthwise convolutional layer and a pointwise convolutional layer; The deep convolutional layer is used to extract local spatial structural features of the VCM motor surface; The pointwise convolutional layer is used to perform cross-channel feature fusion and channel number adjustment on the features processed by the deep convolutional layer to form high-dimensional semantic features that characterize the overall structural information of the VCM motor surface.

5. The system according to claim 1, characterized in that, The step of performing multi-template matching and attention calculation based on the current image features and the template features to generate fusion features for enhancing the expression of defective regions includes: The current image features and the template features are projected to generate query features and key features in a unified feature space; Pixel-level similarity calculation is performed based on the query features and the key features to obtain the matching degree information between the current image features and each of the template features; The matching degree information corresponding to multiple template features is fused to generate a global matching weight map that represents the normal consistency of the current image, and the number of template features can be dynamically configured. The current image features are weighted based on the global matching weight map and then fused with the current image features to generate the fused features.

6. The system according to claim 5, characterized in that, The step of performing pixel-level similarity calculation based on the query features and the key features to obtain matching information between the current image features and each of the template features includes: The query features and each of the key features are flattened in the spatial dimension to form a pixel-level feature representation; Matrix multiplication is performed based on the pixel-level feature representation, and pixel-level similarity response is calculated in combination with a preset attention scaling factor; Extract the matching response value for the corresponding pixel position from the similarity response; The matching response value is restored to a matching degree feature map with the same feature space resolution as the current image, thereby obtaining the matching degree information between the current image features and each of the template features.

7. The system according to claim 5, characterized in that, The step of weighting the current image features based on the global matching weight map and fusing them with the current image features to generate the fused features includes: Based on the global matching weight map, a weighted operation is performed on the feature values ​​of corresponding pixel positions in the current image features to obtain weighted features; Perform residual fusion processing on the weighted features and the current image features; The features obtained through the residual fusion process are output as the fused features.

8. The system according to claim 1, characterized in that, The step of segmenting the abnormal appearance regions in the image to be detected based on the fused features and outputting the corresponding defect region segmentation results includes: The fused features are input into the decoder network, and transposed convolution processing is performed on the fused features; During the transposed convolution process, the upsampled features are skipped and connected to the features output from the corresponding layer in the feature extraction module, and feature fusion processing is performed. Based on the features after multi-level upsampling and feature fusion processing, a segmentation feature map with the same spatial resolution as the image to be detected is generated. Pixel-level classification processing is performed on the segmentation feature map to output the defect region segmentation result.

9. The system according to claim 8, characterized in that, The calculation formula for the transposed convolution process is as follows: ; in, This indicates the spatial location of the output feature map obtained by transpose convolution. Eigenvalues ​​at; represents the input feature map before transpose convolution; i and j represent the spatial index positions of the upsampled feature map in the row and column directions, respectively; m and n represent the offset index of the upsampled convolution kernel in the spatial dimension; k represents the size of the upsampled convolution kernel. Indicates the corresponding position during the transpose convolution process. The weighting coefficients; s represents the upsampling step size; Indicates the transposed convolution kernel; This indicates the floor function.

10. A method for detecting appearance defects in the manufacturing process of a VCM motor, characterized in that, The method includes the following steps: Acquire surface images of the VCM motor to be inspected, and obtain the image data to be inspected; The image data to be detected and at least one normal VCM motor template image are subjected to feature encoding processing to obtain the corresponding current image features and template features; Based on the current image features and the template features, perform multi-template matching and attention calculation to generate fusion features for enhancing the expression of defective regions; Based on the fusion features, the abnormal appearance regions in the image to be detected are segmented, and the corresponding defect region segmentation results are output. Based on the defect region segmentation results, the appearance defect information of the VCM motor is determined, and the defect detection results are output.