Method for detecting reflective metal parts based on frequency domain prior and channel attention mechanism
The method for detecting reflective metal parts by means of frequency domain prior and channel attention mechanism solves the problems of recognition accuracy and real-time performance of reflective metal sheets in complex assembly environments, realizes high-precision and intelligent assembly perception, and improves detection accuracy and environmental adaptability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SOUTH CHINA UNIV OF TECH
- Filing Date
- 2026-03-16
- Publication Date
- 2026-07-14
AI Technical Summary
Existing technologies lack sufficient accuracy in recognizing reflective metal sheets in complex assembly environments, struggle to balance real-time performance with algorithm complexity, and have limited environmental adaptability, making it difficult to meet the demands for high-precision and efficient sensing.
A method for detecting reflective metal parts based on frequency domain prior and channel attention mechanism is adopted. By constructing a target detection network model, a frequency domain reflectivity suppression attention module and a channel context attention transformation module are introduced to extract and fuse features, suppress reflectivity interference and enhance key features.
It significantly improves the accuracy and reliability of assembly component identification, enhances detection precision and real-time performance, and can accurately extract structural information and semantic features of assembly targets under complex lighting conditions, thereby enhancing the model's environmental adaptability.
Smart Images

Figure CN122391074A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of computer vision, specifically relating to a method for detecting reflective metal parts based on frequency domain priors and channel attention mechanisms. Background Technology
[0002] As the manufacturing industry accelerates its transformation towards high-end and intelligent manufacturing, the application of industrial robots in complex assembly tasks has become an important means to improve production efficiency, reduce production costs, and achieve flexible and personalized manufacturing. As a key production link that determines product quality and lifespan, the assembly process places more stringent demands on the robot's perception capabilities, operational precision, and environmental adaptability. Especially in discrete manufacturing fields such as home appliance production, the types of assembly objects are diverse, the processes are complex, and the precision requirements are high. Currently, a large amount of assembly work still relies on manual labor, and the proportion of automated robot assembly is low, urgently requiring the support of advanced intelligent sensing and control technologies.
[0003] For the identification and detection of reflective objects, existing technologies can be mainly divided into hardware-level polarization imaging methods and algorithm-level visual modeling and feature enhancement methods. In polarization imaging methods, polarizers are typically added to the front of the camera or multi-polarization imaging devices are used to reduce specular reflections on metal surfaces and enhance target contour information. However, this type of method has high requirements for light source direction, camera orientation, and installation environment, resulting in high system cost and deployment complexity, and limited applicability in space-constrained industrial assembly sites with frequently changing operating conditions. At the algorithm level, existing methods mainly employ deep learning, using neural networks for modeling to improve the ability to identify reflective areas. While this method reduces dependence on hardware, reflective areas are prone to feature saturation and texture loss, making it difficult to accurately represent the true boundaries of thin metal sheets. Furthermore, in complex assembly environments, different materials and surface conditions vary significantly, and existing algorithms still lack a balance between generalization and real-time performance, easily leading to false detections, missed detections, and positioning errors.
[0004] In summary, existing technologies suffer from problems such as high hardware dependence, high algorithm complexity, difficulty in balancing detection accuracy and real-time performance, and insufficient environmental adaptability, making it difficult to meet the actual needs of complex assembly tasks for stable, fast, and high-precision sensing. Summary of the Invention
[0005] The main objective of this invention is to overcome the problems of insufficient recognition accuracy of reflective metal sheets in complex assembly environments, difficulty in balancing real-time performance and algorithm complexity, and limited environmental adaptability in the prior art, and to provide a method for detecting reflective metal parts based on frequency domain prior and channel attention mechanism.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] One aspect of the present invention provides a method for detecting reflective metal components based on frequency domain priors and channel attention mechanisms, comprising the following steps:
[0008] Acquire a dataset of target images containing interference from complex lighting or specular reflections, and manually annotate it;
[0009] A target detection network model is constructed, including a backbone feature extraction network, a feature fusion network, and a detection head. The intermediate feature layer of the backbone feature extraction network introduces a frequency domain reflection suppression attention module, including a frequency domain reflection feature attention unit for characterizing highlight or specular reflection regions, and a spatial reflection suppression attention unit for generating spatial attention weights and suppressing reflection interference regions. The feature fusion network introduces a channel context attention transformation module for performing channel-dimensional global context modeling and dynamic weight adjustment.
[0010] The target detection network model is trained using the labeled target image dataset;
[0011] The trained object detection network model is used to perform object detection and spatial localization on the image to be detected.
[0012] As a preferred technical solution, the acquisition of the target image dataset containing interference from complex lighting or specular reflection specifically includes:
[0013] Set different camera shooting angles and distances to cover images of metal parts under different light intensities, surface roughness, and assembly conditions;
[0014] The images of the metal parts are manually screened to remove images that are excessively obscured or unrecognizable, and to retain clear images of the metal parts that have reflective interference characteristics, thus forming a target image dataset.
[0015] As a preferred technical solution, the frequency domain reflective feature attention unit performs a two-dimensional Fourier transform on the input features, as shown in the following equation:
[0016] F(u,v)= {X1(x,y)};
[0017] Where X1∈R B×C×H×W For the frequency domain reflection suppression attention module, (x,y) represents the spatial coordinates, R is the real tensor, B is the batch size, C is the number of image channels, H and W are the height and width of the image, (u,v) represents the frequency domain coordinates, and F(u,v) is the frequency domain feature. This represents the two-dimensional discrete Fourier transform operator.
[0018] The amplitude spectrum of the frequency domain feature F(u,v) is calculated and logarithmically mapped to characterize the reflected energy distribution, specifically as follows:
[0019] M(u,v)=log(|F(u,v)|+ε1);
[0020] Where M(u,v) is the frequency domain amplitude map after logarithmic mapping, and |F(u,v)| represents the complex modulo operation on the frequency domain feature F(u,v). 1. To prevent numerically unstable constants, log represents logarithmic operations;
[0021] The amplitude spectrum M(u,v) is input into the energy mapping unit, and the frequency domain reflective cue feature X is obtained through convolution mapping. f :
[0022] X f = (M(u,v));
[0023] in, This represents a lightweight mapping function consisting of 1×1 convolution, BacthNorm, and GELU.
[0024] As a preferred technical solution, the spatial reflection suppression attention unit uses the frequency domain reflection cue feature X output by the frequency domain reflection feature extraction unit. f Generate frequency domain-guided spatial reflective attention A s As shown in the following formula:
[0025] ;
[0026] Where AvgPool is the average pooling operation, F avg The spatial feature map is obtained by average pooling, and MaxPool is the max pooling operation. max S is the spatial feature map obtained by max pooling, Conv is the convolution operation, Concat is the feature concatenation operation, S is the feature map obtained by feature concatenation, and Sigmoid is the activation function.
[0027] Spatial Reflection Perception Attention A s To suppress reflections, specifically:
[0028] X s =X1 (1-A) s );
[0029] Where X1∈R B×C×H×W X is the input feature for the frequency domain reflection suppression attention module. s The output characteristics after reflection suppression This represents element-wise multiplication, 1 - As Indicates the weight for suppressing highlight areas
[0030] The feature map Y1 is output using a residual connection method.
[0031] As a preferred technical solution, the channel context attention transformation module performs the following steps:
[0032] The input features of the channel context attention transformation module are normalized along the channel dimension using an unbiased layer.
[0033] The query, key, and value are generated based on the features normalized by the unbiased layer, specifically as follows:
[0034] ;
[0035] ;
[0036] in, The features are normalized by the unbiased layer, where R is the real tensor, B is the batch size, C is the number of image channels, and H and W are the height and width of the image; Q, K, and V are the query feature matrix, key feature matrix, and value feature matrix, respectively; Conv 1×1 is a 1×1 convolution; DWConv is a depthwise separable convolution; Split means that the feature map is evenly divided into 3 parts in the channel dimension;
[0037] The Q, K, and V channels are rearranged using a multi-head channel approach, and the channel attention weights are calculated and attention features are fused. Specifically:
[0038] ;
[0039] ;
[0040] ;
[0041] Among them, Q h K h and V h H represents the query, key, and value after multi-head rearrangement. d C represents the number of attention heads. h This represents the number of channels assigned to each attention head, T represents the matrix transpose, and Softmax represents the normalization operation along the channel dimension;
[0042] The spatial structure of the features after channel attention aggregation is restored, and linear projection is performed to obtain the channel-enhanced output features, specifically:
[0043] ;
[0044] Where Z represents the channel-enhanced output feature, and reshape indicates adjusting the tensor dimension.
[0045] As a preferred technical solution, the input features of the channel context attention transformation module are standardized by channel, specifically as follows:
[0046] ;
[0047] Where, x (h,w) Let y represent the C-dimensional channel vector with input feature space location (h, w), ⊙ be the Hadamard product, γ be the learnable scaling parameter, σ be the variance of the input feature along the channel, and ε² be a non-zero constant to ensure numerical stability. (h,w) This is the normalized C-dimensional channel vector.
[0048] As a preferred technical solution, the channel-enhanced output feature Z is nonlinearly reconstructed through a feedforward network to obtain the output feature that integrates contextual information and channel attention:
[0049] Y2 = FFN(LN(Z+X2));
[0050] Where Y2 is the output feature of the channel context attention transformation module, X2 is the input feature of the channel context attention transformation module, LN is the LayerNorm operation, and FFN is a convolutional feedforward network.
[0051] As a preferred technical solution, the training effect of the object detection network model is verified by mean accuracy (mAP), precision, and recall.
[0052] The precision is calculated as follows:
[0053] ;
[0054] In the formula, TP represents the number of true positive samples, and FP represents the number of negative samples that were mistakenly identified as positive samples;
[0055] The recall rate is calculated as follows:
[0056] ;
[0057] In the formula, FN represents the number of positive samples that were not detected.
[0058] Another aspect of the present invention provides a reflective metal component detection system based on frequency domain prior and channel attention mechanism, applied to the above-mentioned reflective metal component detection method based on frequency domain prior and channel attention mechanism, including a data acquisition module, a target detection network model construction module, a model training module, and a model deployment module;
[0059] The data acquisition module is used to acquire a dataset of target images containing interference from complex lighting or specular reflections, and to perform manual annotation.
[0060] The target detection network model construction module is used to construct the target detection network model, including a backbone feature extraction network, a feature fusion network, and a detection head. The intermediate feature layer of the backbone feature extraction network introduces a frequency domain reflection suppression attention module, including a frequency domain reflection feature attention unit for characterizing highlight or specular reflection regions, and a spatial reflection suppression attention unit for generating spatial attention weights and suppressing reflection interference regions. The feature fusion network introduces a channel context attention transformation module for performing channel-dimensional global context modeling and dynamic weight adjustment.
[0061] The model training module is used to train the target detection network model using the labeled target image dataset;
[0062] The model deployment module is used to perform target detection and spatial localization on the image to be detected using the trained target detection network model.
[0063] In another aspect, the present invention also provides a storage medium storing a program that, when executed by a processor, implements the above-described method for detecting reflective metal components based on frequency domain priors and channel attention mechanisms.
[0064] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0065] (1) This invention introduces the SSAM attention mechanism module and the CCAT attention mechanism module in a coordinated manner to effectively suppress reflective interference and accurately enhance key assembly features. It can still accurately and completely extract the structural information and semantic features of the assembly target even in the presence of reflection, highly similar parts and complex backgrounds, significantly improving the accuracy and reliability of assembly parts recognition, and providing effective technical support for achieving high-precision and intelligent assembly perception. Compared with the original YOLOv8 model, it improves detection accuracy while ensuring real-time performance, and has good overall performance.
[0066] (2) This invention constructs a C2f_SSAM module to adaptively weight features in the spatial dimension. This allows for dynamic differentiation between real structural regions and pseudo-salient regions caused by reflections based on spatial saliency distribution. By strengthening stable spatial features such as key assembly locations, connection interfaces, and contour edges, the abnormal amplification effect of highlight regions in feature response is suppressed, thereby reducing the impact of reflections on assembly target localization and structural analysis. This mechanism enables the model to maintain stable focus on key assembly regions even under complex lighting conditions, effectively avoiding feature loss or structural breakage caused by local reflections.
[0067] (3) By constructing the CCAT module, this invention performs comprehensive analysis and adaptive weight adjustment of feature responses in different channels from the perspective of channel association and cross-feature interaction. By enhancing the joint modeling capability of multi-dimensional information such as structure, shape and semantics, it weakens the abnormal activation caused by reflection in a single channel, making it difficult for high-light noise to form a dominant feature in the channel dimension, thereby further improving the ability to distinguish and express the true assembly features. Attached Figure Description
[0068] Figure 1 This is a flowchart of the reflective metal component detection method based on frequency domain prior and channel attention mechanism according to an embodiment of the present invention;
[0069] Figure 2 This is a network structure diagram of the existing YOLOv8 object detection algorithm;
[0070] Figure 3 This is a schematic diagram of the structure of the improved YOLOv8-SC target detection algorithm network according to an embodiment of the present invention;
[0071] Figure 4 This is a schematic diagram of the SSAM module according to an embodiment of the present invention;
[0072] Figure 5 This is a schematic diagram of the structure of the C2f_SSAM module according to an embodiment of the present invention;
[0073] Figure 6 This is a schematic diagram of the CCAT module in an embodiment of the present invention.
[0074] Figure 7 This is a diagram showing the recognition results after training the improved YOLOv8-SC model according to an embodiment of the present invention. Detailed Implementation
[0075] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative effort are within the scope of protection of the present application.
[0076] This invention analyzes the potential problems in identifying reflective metal sheets with smooth surfaces during assembly production. Metal parts and precision components generally have strong reflective properties, and under varying lighting conditions, they easily form highlight and specular reflection areas in images, thus obscuring true structural features and interfering with the model's perception and judgment of key assembly information, leading to incomplete or misidentification. This invention introduces the SSAM attention mechanism module in synergy with the CCAT attention mechanism module to effectively suppress reflective interference and accurately enhance key assembly features. Compared to the original YOLOv8 model, it improves detection accuracy while maintaining real-time performance, demonstrating good overall performance. Specifically, the C2f_SSAM module adaptively weights features in the spatial dimension, dynamically distinguishing between true structural regions and pseudo-salient regions caused by reflection based on spatial saliency distribution. By strengthening stable spatial features such as key assembly locations, connection interfaces, and contour edges, it suppresses the abnormal amplification effect of highlight areas in feature response, thereby reducing the impact of reflection on assembly target localization and structural analysis. This mechanism enables the model to maintain stable focus on key assembly areas even under complex lighting conditions, effectively avoiding feature loss or structural breakage caused by localized reflections. Simultaneously, the CCAT module, from the perspective of channel association and cross-feature interaction, comprehensively analyzes and adaptively adjusts the feature responses in different channels. By enhancing the joint modeling capability of multi-dimensional information such as structure, shape, and semantics, it weakens aberrant activation caused by reflections in a single channel, making it difficult for specular noise to form a dominant feature in the channel dimension, thereby further improving the ability to discriminate and represent real assembly features. Experimental verification shows that the improved YOLOv8-SC model proposed in this invention can accurately and completely extract the structural information and semantic features of the assembly target even in the presence of reflections, highly similar parts, and complex backgrounds, significantly improving the accuracy and reliability of assembly component recognition, and providing effective technical support for achieving high-precision, intelligent assembly perception.
[0077] Example:
[0078] like Figure 1 As shown, this embodiment provides a method for detecting reflective metal components based on frequency domain priors and channel attention mechanisms, including the following steps:
[0079] Step (1) Construct a dataset of images of metal parts in a reflective assembly scene. During image acquisition, the camera shooting angle and distance are adjusted to cover images of metal parts under different lighting intensities, surface roughnesses, and assembly conditions, ensuring the diversity and representativeness of the data. The acquired raw images are manually screened to remove severely blurred, excessively occluded, or unrecognizable images, retaining clear samples with reflective interference characteristics, thus forming the original image dataset of reflective metal parts.
[0080] Step (2), Data Labeling and Dataset Construction. The above-mentioned reflective metal component image dataset was manually labeled using the Label Studio labeling tool. The labeling content included the category information of the metal components and their position information in the image. There were four categories: chip_A, chip_B, chip_C, and chip_D. After labeling, the labeling information was converted to YOLO format, including the target category number and the corresponding center point coordinates and aspect ratio parameters. All labeled data was divided into training and validation sets according to a preset ratio of 8:2, completing the construction of a standardized dataset suitable for improving model training.
[0081] Step (3) Construct the object detection network model (improved YOLOv8-SC model).
[0082] Based on the native YOLOv8 model, the SSAM reflection suppression module and the CCAT channel context attention mechanism module are introduced to construct a YOLOv8-SC model optimized for reflective scenes. The specific operation is as follows:
[0083] The YOLOv8 model (or the original YOLOv8 model) includes a Backbone, a Neck, and a Head. The Backbone is used for feature extraction, the Neck for feature fusion, and the Head for prediction. The YOLOv8 network structure is as follows: Figure 2As shown. The YOLOv8-SC model constructed in this embodiment is the same as the YOLOv8 model, also including a Backbone, Neck, and Head. The Backbone performs feature extraction, the Neck performs feature fusion, and the Head performs prediction. In the existing YOLOv8 network, the C2f module in the backbone network is replaced, and the Bottleneck module in the original C2f module is replaced with a Spectral-Spatial Attention Module (SSAM module), forming the C2f_SSAM module. Through frequency domain feature analysis and spatial inverse suppression mechanism, it weakens the abnormal high-frequency response caused by specular reflection and enhances the ability to express real structural features. The neck network incorporates a Channel-Wise Contextual Attention Transformer (CCAT module), which is responsible for multi-scale feature fusion. The channel self-attention mechanism models the contextual association of features at different scales, strengthens the channel association between real structural features, and avoids the further amplification of reflective noise in the channel dimension. The improved YOLO-SC network structure is as follows. Figure 3 As shown.
[0084] 1) Integrate the SSAM module on the Backbone side, with the module structure as follows: Figure 4 As shown:
[0085] While the backbone network of the native YOLOv8 model possesses strong feature extraction capabilities in conventional object detection tasks, industrial assembly environments often present challenges. Metal parts typically exhibit specular reflections, highlight areas, and strong light interference, leading to local feature saturation, texture loss, and blurred boundaries. Furthermore, the presence of small-sized components, complex backgrounds, and inter-component occlusion in assembly scenarios makes it difficult for traditional convolutional operations to effectively separate reflective interference from true structural information, resulting in decreased detection accuracy.
[0086] To address the aforementioned issues, this YOLOv8 Backbone introduces the SSAM module in its intermediate feature layer to replace the Bottleneck module in the C2f module, thus forming the C2f_SSAM module. The structure of this module is shown in the diagram below. Figure 5 As shown, this module can identify reflective areas through frequency domain feature analysis and suppress reflective interference by combining spatial attention, while preserving real structural information and enhancing the detection capability for small-sized and complex background components.
[0087] The SSAM module includes a frequency-domain reflectivity attention unit for characterizing specular or specular reflection regions, and a spatial reflectivity suppression attention unit for generating spatial attention weights and suppressing reflectivity interference regions. The specific implementation steps are as follows:
[0088] First, the feature map output from the intermediate layer of the YOLOv8 Backbone is used as the input to the SSAM module, denoted as X1∈R. B×C×H×W R is a real number, B is the batch size, C is the number of image channels, and H and W are the height and width of the image. This feature map contains spatial texture information extracted from the original image, but on the surface of reflective metal parts, there may be issues such as highlights, specular reflections, and texture saturation.
[0089] To identify reflective areas, a frequency-domain reflective feature attention unit is first used to process the input feature X1 through a two-dimensional fast Fourier transform (FFT). Mapped to the frequency domain:
[0090] F(u,v)= {X1(x,y)};
[0091] In the formula, F(u,v) represents the frequency domain feature. Let (u,v) represent the two-dimensional discrete Fourier transform operator, (x,y) represent the frequency domain coordinates, and (x,y) represent the spatial coordinates.
[0092] This operation maps spatial domain features to a frequency domain representation, where high-energy regions typically correspond to highlights or specular reflections in the image. Subsequently, the frequency domain amplitude |F(u,v)| is calculated and a logarithmic mapping is performed to enhance the discriminability of high-energy regions.
[0093] M(u,v)=log(|F(u,v)|+ε1);
[0094] In the formula, M(u,v) is the frequency domain amplitude map after logarithmic mapping, and |F(u,v)| represents the amplitude spectrum obtained by performing complex modulo operations on the frequency domain feature F(u,v). 1. To prevent small constants from having zero values, log represents the logarithmic operation. This frequency domain amplitude map M(u,v) can reflect the distribution of highlight regions in the image that may interfere with feature extraction.
[0095] Subsequently, the frequency domain amplitude map M(u,v) is input into a lightweight convolutional mapping network to obtain the frequency domain reflective cue features X. f :
[0096] X f = (M);
[0097] in, This represents a lightweight mapping network consisting of 1×1 convolutions, BacthNorm, and GELU.
[0098] The above mapping results remain consistent with the number of input feature channels, which facilitates subsequent spatial attention calculation. This step completes the extraction of frequency domain reflective features, providing clues for spatial suppression.
[0099] Then, spatial reflectivity suppression attention generation is performed: in the frequency domain reflectivity cue feature X f Based on this, a spatial reflection suppression attention unit is constructed to build a spatial reflection perception attention A. s To suppress specular interference. For X f Global average pooling and global max pooling are performed on the channel dimensions respectively to generate two spatial feature maps. The two pooled feature maps are concatenated along the channel dimension, and feature fusion and dimensionality reduction are performed through convolution. Finally, the result is normalized using the Sigmoid function to obtain the spatial reflectivity attention. :
[0100] ;
[0101] The specific operation of Ф is as follows:
[0102] ;
[0103] Where AvgPool is the average pooling operation, F avg The spatial feature map is obtained by average pooling, and MaxPool is the max pooling operation. max S represents the spatial feature map obtained by max pooling, Conv is the convolution operation, Concat is the feature concatenation operation, S is the feature map obtained by feature concatenation, and Sigmoid is the activation function.
[0104] The input features of the frequency domain reflection suppression attention module are subjected to reflection suppression and feature cleansing by element-wise multiplication.
[0105] X s =X1 (1-A) s );
[0106] Among them, X s The output characteristics after reflection suppression This represents element-wise multiplication, 1 - A s This represents the weights for suppressing highlight regions. To preserve the original structural information and texture, and to locally suppress highlight noise, a residual connection is used to output the feature map Y1, which can be used for subsequent YOLOv8 feature fusion and detection heads.
[0107] 2) Integrate the CCAT module into the Neck, with the module structure as follows: Figure 6 As shown:
[0108] In the Neck layer of YOLOv8, multi-scale feature fusion is achieved through an FPN / PAN structure. However, in the detection of reflective metal parts, traditional multi-scale fusion methods still suffer from semantic inconsistencies. Shallow features tend to emphasize texture and edge information, while deep features tend to emphasize semantic information, and there is a lack of effective channel alignment mechanisms during fusion. Some channel responses mainly come from the background or specular reflection areas, lacking discriminative significance. Under conditions of small targets or complex lighting, channels that truly contain structural information are masked by specular noise. After fusion in the Neck layer, abnormal responses in specular areas propagate across multiple scales, affecting the classification and regression prediction of the detection head. Therefore, a CCAT module is introduced at the Neck layer to perform global context modeling and adaptive reweighting of the channel dimensions of the fused multi-scale features. While maintaining the spatial resolution, this enhances key semantic channels and suppresses redundant reflective channels.
[0109] The specific implementation steps of the CCAT module are as follows:
[0110] First, the input features are normalized along the channel-unbiased layer to obtain the normalized output. The unbiased layer normalization of pixel spatial positions along the channel dimension is as follows:
[0111] ;
[0112] Where, x (h,w) Let y represent the C-dimensional channel vector with input feature space location (h, w), ⊙ be the Hadamard product, γ be the learnable scaling parameter, σ be the variance of the input feature along the channel, and ε² be a non-zero constant to ensure numerical stability. (h,w) The normalized C-dimensional channel vectors are processed by biasless layer normalization to improve the stability of channel attention calculation, reduce gradient oscillations caused by brightness abrupt changes, and provide stable input for subsequent channel dependency modeling.
[0113] Traditional channel attention methods such as SE or CBAM only generate single channel weights through global pooling, making it difficult to model complex dependencies between channels. CCAT adopts a multi-head channel self-attention mechanism based on the Transformer concept, performing global modeling at the channel level. First, it flattens the feature space and generates queries, keys, and values, then performs channel-level multi-head channel attention calculations.
[0114] ;
[0115] ;
[0116] in, Let Q, K, and V be the features after normalization by the unbiased layer, respectively, representing the query feature matrix, key feature matrix, and value feature matrix; Conv 1×1 is a 1×1 convolution; DWConv is a depthwise separable convolution; Split means that the feature map is evenly divided into 3 parts in the channel dimension.
[0117] The Q, K, and V channels are rearranged using a multi-head channel approach, and the channel attention weights are calculated and attention features are fused. Specifically:
[0118] ;
[0119] ;
[0120] ;
[0121] Among them, Q h K h and V h H represents the query, key, and value after multi-head rearrangement. d C represents the number of attention heads. h This represents the number of channels assigned to each attention head, T represents the matrix transpose, and Softmax represents the normalization operation along the channel dimension.
[0122] The spatial structure of the features after channel attention aggregation is restored, and linear projection is performed to obtain the channel-enhanced output features:
[0123] ;
[0124] Where Z represents the channel-enhanced output feature, and reshape indicates adjustment of the tensor dimension.
[0125] To further enhance the ability to express nonlinear relationships between channels, a feedforward network is introduced to nonlinearly reconstruct the channel-enhanced output feature Z, resulting in an output feature that integrates contextual information and channel attention.
[0126] Y2 = FFN(LN(Z+X2));
[0127] Where Y2 is the output feature of the CCAT module, X2 is the input feature of the CCAT module, LN is the LayerNorm operation, and FFN is a convolutional feedforward network.
[0128] The Channel Context Attention (CCAT) module introduced at the Neck end, through unbiased normalization, multi-head channel self-attention modeling, and feedforward enhancement network structures, achieves fine modeling and adaptive reweighting of the global dependencies of the channel dimension while maintaining the feature map spatial resolution. It can effectively identify and enhance high-value semantic channels that are discriminative to the target structural information, while suppressing redundant or noisy channel responses caused by specular reflection, high light saturation, and complex backgrounds, thereby significantly improving the semantic consistency and discriminative ability of multi-scale fused features.
[0129] Step (4): Train the YOLOv8-SC model.
[0130] The labeled dataset of reflective metal parts is input into the YOLOv8-SC model for training, resulting in the YOLOv8-SC.pt weight file, which in turn generates the YOLOv8-SC model. After training, the model is validated using a validation set.
[0131] Step (5): Use the YOLOv8-SC model to identify the workpiece in the image of a reflective metal part. The identification result is as follows: Figure 7 As shown.
[0132] The YOLOv8 model and the YOLOv8-SC model were trained and tested on the same dataset of 2500 images. The performance of the models was measured by the metrics of precision, recall, average precision (mAP@0.5), and mAP@[0.5:0.95].
[0133] Precision: Represents the proportion of samples predicted as positive that are actually positive. The formula is:
[0134] ;
[0135] Where TP represents the number of true positive samples and FP represents the number of negative samples that were mistakenly identified as positive samples.
[0136] Recall: Represents the proportion of true positive samples that are detected. The formula is:
[0137] ;
[0138] Where TP represents the number of true positive samples and FN represents the number of undetected positive samples.
[0139] Average accuracy mAP@0.5: This represents the average accuracy when the Intersection over Union (IoU) threshold is 0.5, reflecting the model's ability to identify targets.
[0140] Average accuracy mAP@[0.5:0.95]: This represents the average mAP value at 10 thresholds with an IoU threshold ranging from 0.5 to 0.95, at intervals of 0.05. This provides a more rigorous and comprehensive measure of the model's ability to accurately locate targets.
[0141] The experimental environment was completed under a unified hardware and software environment. Model training and testing were based on a single NVIDIA GeForce RTX 3090 graphics card with 24GB of video memory. The software environment was built on Python 3.8 and the PyTorch deep learning framework, using CUDA 12.2 and NVIDIA driver 535.183.06 to ensure stable compatibility with GPU acceleration.
[0142] Experiments showed that the average accuracy (mAP@0.5) of the original YOLOv8 model and the YOLOv8-SC model was 0.873 and 0.903, respectively. YOLOv8-SC improved by 3%, and its mAP@[0.5:0.95] performance improved by 2.7%, with precision increasing by 3.8% and recall by 2.8%. The improved model demonstrated stronger noise resistance, better feature cleansing and semantic fusion capabilities, and better robustness and generalization in the task of identifying metal parts with reflective interference.
[0143] In summary, this invention introduces a C2f_SSAM frequency domain reflection suppression module on the backbone and a CCAT channel context attention module on the neck, forming a dual optimization mechanism that works synergistically. Specifically, C2f_SSAM suppresses specular and specular reflections on metal surfaces in both the frequency and spatial domains, enhancing the real structure and texture information; CCAT models the global dependencies between channels during the multi-scale feature fusion stage, adaptively strengthening key semantic channels and suppressing redundant and reflective interference channels. Through the synergistic effect of these two modules, the detection accuracy and robustness of the model for metal parts in complex assembly reflective environments are effectively improved, achieving more accurate and complete recognition and localization.
[0144] In another embodiment of this application, a reflective metal component detection system based on frequency domain prior and channel attention mechanism is provided. The system includes a data acquisition module, a target detection network model construction module, a model training module, and a model deployment module.
[0145] The data acquisition module is used to acquire a dataset of target images containing interference from complex lighting or specular reflections, and to perform manual annotation.
[0146] The target detection network model construction module is used to construct the target detection network model, including a backbone feature extraction network, a feature fusion network, and a detection head. The intermediate feature layer of the backbone feature extraction network introduces a frequency domain reflection suppression attention module, including a frequency domain reflection feature extraction unit for extracting features representing highlight or specular reflection areas, and a spatial reflection suppression attention unit for generating spatial attention weights and suppressing reflection interference areas. The feature fusion network introduces a channel context attention transformation module for performing channel-dimensional global context modeling and adaptive reweighting.
[0147] The model training module is used to train the target detection network model using the labeled target image dataset;
[0148] The model deployment module is used to perform target detection and spatial localization on the image to be detected using the trained target detection network model.
[0149] It should be noted that the system provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure can be divided into different functional modules to complete all or part of the functions described above. The system is applied to the reflective metal component detection method based on frequency domain prior and channel attention mechanism in the above embodiments.
[0150] In another embodiment of this application, a storage medium is also provided, storing a program that, when executed by a processor, implements a method for detecting reflective metal components based on frequency domain priors and channel attention mechanisms, specifically:
[0151] Acquire a dataset of target images containing interference from complex lighting or specular reflections, and manually annotate it;
[0152] A target detection network model is constructed, including a backbone feature extraction network, a feature fusion network, and a detection head. The intermediate feature layer of the backbone feature extraction network introduces a frequency domain reflection suppression attention module, including a frequency domain reflection feature extraction unit for extracting features representing highlight or specular reflection areas, and a spatial reflection suppression attention unit for generating spatial attention weights and suppressing reflection interference areas. The feature fusion network introduces a channel context attention transformation module for performing channel-dimensional global context modeling and adaptive reweighting.
[0153] The target detection network model is trained using the labeled target image dataset;
[0154] The trained object detection network model is used to perform object detection and spatial localization on the image to be detected.
[0155] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0156] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.
Claims
1. A method for detecting reflective metal components based on frequency domain priors and channel attention mechanisms, characterized in that, Includes the following steps: Acquire a dataset of target images containing interference from complex lighting or specular reflections, and manually annotate it; A target detection network model is constructed, including a backbone feature extraction network, a feature fusion network, and a detection head. The intermediate feature layer of the backbone feature extraction network introduces a frequency domain reflection suppression attention module, including a frequency domain reflection feature attention unit for characterizing highlight or specular reflection regions, and a spatial reflection suppression attention unit for generating spatial attention weights and suppressing reflection interference regions. The feature fusion network introduces a channel context attention transformation module for performing channel-dimensional global context modeling and dynamic weight adjustment. The target detection network model is trained using the labeled target image dataset; The trained object detection network model is used to perform object detection and spatial localization on the image to be detected.
2. The method for detecting reflective metal components based on frequency domain prior and channel attention mechanism according to claim 1, characterized in that, The acquisition of the target image dataset containing interference from complex lighting or specular reflections specifically involves: Set different camera shooting angles and distances to cover images of metal parts under different light intensities, surface roughness, and assembly conditions; The images of the metal parts are manually screened to remove images that are excessively obscured or unrecognizable, and to retain clear images of the metal parts that have reflective interference characteristics, thus forming a target image dataset.
3. The method for detecting reflective metal components based on frequency domain prior and channel attention mechanism according to claim 1, characterized in that, The frequency domain reflective feature attention unit performs a two-dimensional Fourier transform on the input features, as shown in the following equation: F(u,v)= {X1(x,y)}; Where X1∈R B×C×H×W For the frequency domain reflection suppression attention module, (x,y) represents the spatial coordinates, R is the real tensor, B is the batch size, C is the number of image channels, H and W are the height and width of the image, (u,v) represents the frequency domain coordinates, and F(u,v) is the frequency domain feature. Represents the two-dimensional discrete Fourier transform operator; The amplitude spectrum of the frequency domain feature F(u,v) is calculated and logarithmically mapped to characterize the reflected energy distribution, specifically as follows: M(u,v)=log(|F(u,v)|+ε1); Where M(u,v) is the frequency domain amplitude map after logarithmic mapping, and |F(u,v)| represents the complex modulo operation on the frequency domain feature F(u,v).
1. To prevent numerically unstable constants, log represents logarithmic operations; The amplitude spectrum M(u,v) is input into the energy mapping unit, and the frequency domain reflective cue feature X is obtained through convolution mapping. f : X f = (M(u,v)); in, This represents a lightweight mapping function consisting of 1×1 convolution, BacthNorm, and GELU.
4. The method for detecting reflective metal components based on frequency domain prior and channel attention mechanism according to claim 1, characterized in that, The spatial reflection suppression attention unit uses the frequency domain reflection cue feature X output by the frequency domain reflection feature extraction unit. f Generate frequency domain-guided spatial reflective attention A s As shown in the following formula: ; Where AvgPool is the average pooling operation, F avg The spatial feature map is obtained by average pooling, and MaxPool is the max pooling operation. max S is the spatial feature map obtained by max pooling, Conv is the convolution operation, Concat is the feature concatenation operation, S is the feature map obtained by feature concatenation, and Sigmoid is the activation function. Spatial Reflection Perception Attention A s To suppress reflections, specifically: X s =X1 (1- A s ); Where X1∈R B×C×H×W X is the input feature for the frequency domain reflection suppression attention module. s The output characteristics after reflection suppression This represents element-wise multiplication, 1 - A s This indicates the weight for suppressing highlight areas; The feature map Y1 is output using a residual connection method.
5. The method for detecting reflective metal components based on frequency domain prior and channel attention mechanism according to claim 1, characterized in that, The channel context attention transformation module performs the following steps: The input features of the channel context attention transformation module are normalized along the channel dimension using an unbiased layer. The query, key, and value are generated based on the features normalized by the unbiased layer, specifically as follows: ; ; in, The features are normalized by the unbiased layer, where R is the real tensor, B is the batch size, C is the number of image channels, and H and W are the height and width of the image; Q, K, and V are the query feature matrix, key feature matrix, and value feature matrix, respectively; Conv 1×1 is a 1×1 convolution; DWConv is a depthwise separable convolution; Split means that the feature map is evenly divided into 3 parts in the channel dimension; The Q, K, and V channels are rearranged using a multi-head channel approach, and the channel attention weights are calculated and attention features are fused. Specifically: ; ; ; Among them, Q h K h and V h H represents the query, key, and value after multi-head rearrangement. d C represents the number of attention heads. h This represents the number of channels assigned to each attention head, T represents the matrix transpose, and Softmax represents the normalization operation along the channel dimension; The spatial structure of the features after channel attention aggregation is restored, and linear projection is performed to obtain the channel-enhanced output features, specifically: ; Where Z represents the channel-enhanced output feature, and reshape indicates adjusting the tensor dimension.
6. The method for detecting reflective metal components based on frequency domain prior and channel attention mechanism according to claim 5, characterized in that, The input features of the channel context attention transformation module are standardized by channel, specifically as follows: ; Where, x (h,w) Let y represent the C-dimensional channel vector with input feature space location (h, w), ⊙ be the Hadamard product, γ be the learnable scaling parameter, σ be the variance of the input feature along the channel, and ε² be a non-zero constant to ensure numerical stability. (h,w) This is the normalized C-dimensional channel vector.
7. The method for detecting reflective metal components based on frequency domain prior and channel attention mechanism according to claim 5, characterized in that, The channel-enhanced output feature Z is nonlinearly reconstructed through a feedforward network to obtain the output feature that integrates contextual information and channel attention: Y2 = FFN(LN(Z+X2)); Where Y2 is the output feature of the channel context attention transformation module, X2 is the input feature of the channel context attention transformation module, LN is the LayerNorm operation, and FFN is a convolutional feedforward network.
8. The method for detecting reflective metal components based on frequency domain prior and channel attention mechanism according to claim 1, characterized in that, The training performance of the object detection network model was verified using mean accuracy (mAP), precision, and recall. The precision is calculated as follows: ; In the formula, TP represents the number of true positive samples, and FP represents the number of negative samples that were mistakenly identified as positive samples; The recall rate is calculated as follows: ; In the formula, FN represents the number of positive samples that were not detected.
9. A system for detecting reflective metal components based on frequency domain priors and channel attention mechanisms, characterized in that, The method for detecting reflective metal parts based on frequency domain prior and channel attention mechanism, as described in any one of claims 1-8, includes a data acquisition module, a target detection network model construction module, a model training module, and a model deployment module; The data acquisition module is used to acquire a dataset of target images containing interference from complex lighting or specular reflections, and to perform manual annotation. The target detection network model construction module is used to construct the target detection network model, including a backbone feature extraction network, a feature fusion network, and a detection head. The intermediate feature layer of the backbone feature extraction network introduces a frequency domain reflection suppression attention module, including a frequency domain reflection feature attention unit for characterizing highlight or specular reflection regions, and a spatial reflection suppression attention unit for generating spatial attention weights and suppressing reflection interference regions. The feature fusion network introduces a channel context attention transformation module for performing channel-dimensional global context modeling and dynamic weight adjustment. The model training module is used to train the target detection network model using the labeled target image dataset; The model deployment module is used to perform target detection and spatial localization on the image to be detected using the trained target detection network model.
10. A storage medium storing a program, characterized in that: When the program is executed by the processor, it implements the method for detecting reflective metal parts based on frequency domain prior and channel attention mechanism as described in any one of claims 1-8.