To achieve accurate detection of tiny defects on electrical commutators and address the data imbalance problem in actual production, this paper proposes the WG-YOLOv11 (Wavelet and Group-attention YOLOv11) model based on the YOLOv11 baseline.
The model improvements cover three dimensions: data processing, feature extraction, and loss function optimization. Firstly, at the data level, the Balanced Defect Synthesis (BDS) strategy is introduced to alleviate sample scarcity. Secondly, the WTConv module is integrated into the backbone network to preserve the high-frequency edge details of tiny cracks. Then, the Group CBAM Enhancer (GCE) module is embedded in the neck network to filter brushed and high-reflection background noise. Finally, the
-IoU loss function is utilized in the detection head to improve the bounding box alignment for tiny targets. The overall network architecture of the proposed WG-YOLOv11 model is illustrated in
Figure 1.
3.1. Data Augmentation Strategy Based on Balanced Defect Synthesis (BDS)
Inspired by the Simple Copy-Paste algorithm [
20], and addressing the scarcity of tiny defect morphologies in electrical commutators, this paper replaces traditional global pixel mixing approaches (such as Mixup or CutMix), which can disrupt industrial background textures, with an instance-level Balanced Defect Synthesis (BDS) data augmentation strategy.
Unlike the operation of directly migrating instances between random images, the BDS mechanism constructs a geometric transformation pipeline tailored for industrial defects. First, using annotation information, pixel-level defect patches () and their corresponding binarized instance masks (M) are extracted from the available positive sample images. Subsequently, to decouple the original defects from specific local backgrounds, geometric variations are applied to the extracted defect instances: full-angle random rotation from ∼ is introduced, combined with a Large Scale Jittering (LSJ) strategy. The scaling range of LSJ is set to ∼. This decoupled transformation of scale and angle simulates imaging distortions under varying industrial lighting and depth of field, while synthesizing the phenomenon of multi-scale defects appearing in the same frame.
In the instance fusion stage, the geometrically transformed defect instances are randomly anchored and fused onto defect-free background images (
). Regarding the treatment of fusion edges, prior research indicates that the gain of complex Gaussian blending or Alpha blending on instance segmentation accuracy is negligible [
20]. Therefore, to maintain data generation throughput and preserve the high-frequency edges of hairline cracks, this method omits additional edge smoothing operations and adopts a pixel-level linear combination to generate the augmented image
:
where
denote the pixel matrices of the generated augmented image, the extracted defect patch, and the normal background image, respectively, with their pixel intensity values normalized to the range of
.
represents the binarized instance mask, where the values are 1 for defect regions and 0 for the background; × denotes the Hadamard Product (element-wise multiplication with broadcasting).
Through this instance-level extraction and reorganization, the BDS mechanism migrates defect features to normal background canvases efficiently. This strategy encourages the network to learn the inherent texture features of the defects rather than overfitting to specific surrounding backgrounds, improving data efficiency in a few-shot environment. The complete flowchart of this instance-level BDS data augmentation is illustrated in
Figure 2.
3.2. Frequency-Domain Feature Preservation Module Based on WTConv
In the surface defect detection of electrical commutators, the visual features of tiny cracks are weak and dependent on high-frequency edge gradient information. Standard convolutional architectures typically use continuous strided convolutions or pooling for spatial downsampling to expand the receptive field. However, this spatial dimension compression attenuates high-frequency details of micro-cracks, potentially leading to the loss of morphological features.
To expand the receptive field while preserving high-frequency details, a Wavelet Transform Convolution (WTConv) module [
11] is integrated into the backbone network of WG-YOLOv11. WTConv utilizes the Discrete Wavelet Transform (DWT) to map features to the frequency domain for multi-band processing.
Specifically, this paper adopts the Haar wavelet basis. In the
i-th layer of the cascaded structure, DWT decomposes the low-frequency input
from the previous layer into a low-frequency macroscopic structure component
and three high-frequency edge detail components
, representing high-frequency gradients in the horizontal, vertical, and diagonal directions, respectively:
where
represents the input feature map. The decomposed low-frequency component
and the concatenated high-frequency components
both have their spatial dimensions halved and channel dimensions expanded, mapping into the domain
. The values of these feature elements are unconstrained real numbers (
).
After the frequency domain separation, WTConv uses small-scale depthwise separable convolutions
to perform independent feature extraction on the low-frequency and high-frequency components:
where
represents the learnable weight parameters of the depthwise separable convolution at the
i-th layer;
and
denote the output feature maps for the low-frequency and high-frequency domains, respectively.
Since DWT halves the spatial resolution of feature maps but expands the frequency channels, the same convolutional kernel can cover a larger receptive field on the original image in deeper layers. After
ℓ layers of cascaded extraction, WTConv uses the Inverse Wavelet Transform (IWT) to perform a bottom-up reconstruction:
where
is the low-frequency aggregated feature tensor passed back from the deeper
-th level; and
is the reconstructed spatial-domain feature map at the current
i-th layer.
Through this cascaded architecture, the receptive field grows with the number of layers ℓ, while the parameter count increases linearly, aligning with the requirements of lightweight deployment. Furthermore, by explicitly extracting high-frequency components in each layer, the edge information of micro-cracks is preserved and utilized in deeper networks, compensating for the limitations of standard convolutions.
3.3. Group CBAM Enhancer for Background Interference Suppression
Electrical commutators are processed from metal materials with complex brushed textures, which produce metal reflections under industrial lighting. In convolutional feature extraction, these structural noises often produce high activation responses, obscuring the signals of weak defects. Conventional global attention mechanisms can be dominated by high-reflection areas, causing local weak crack features to be averaged or suppressed during global pooling.
To separate defect features from complex background noise, a Group CBAM Enhancer (GCE) [
12] is introduced in the neck network. GCE utilizes channel grouping and weight re-calibration to suppress background noise from local subspaces.
As shown in
Figure 3, GCE first uniformly divides the input feature
into
g subgroups
along the channel dimension. A Convolutional Block Attention Module (CBAM) is then applied independently to each subgroup. The internal mechanism computes a 1D Channel Attention map (
) and a 2D Spatial Attention map (
) sequentially:
where
denotes the
i-th feature subgroup. MLP, AvgPool, and MaxPool represent the Multi-Layer Perceptron, Average Pooling, and Max Pooling layers, respectively.
denotes the Sigmoid activation function mapping values into the range
, ensuring that the elements of both
and
strictly fall in the interval
. ⊗ represents element-wise multiplication with broadcasting. The local attention weights
for the subgroup are formed by:
where the element values of the resultant tensor
are strictly bounded within
. This grouping strategy encourages the model to mine salient features within different channel subspaces, mitigating the risk of weak defect responses being suppressed by reflection noise during global pooling.
Following the local attention computation, GCE employs an adaptive weight readjusting mechanism instead of direct feature multiplication. For each subgroup, the internal weight mean
is calculated adaptively during the network’s forward pass. To emphasize salient features and suppress background noise, the ReWeight module truncates weight elements higher than the mean to 1, while retaining the original values for elements lower than the mean, generating re-calibrated weights
:
where
are the channel, width, and height indices of the tensor;
is the scalar mean value of the local weights. Consequently, the re-calibrated weight element
takes values in the range
.
The re-calibrated weights and the original features are combined via element-wise multiplication, and residual connections are added to generate the enhanced features of the group. Finally, all subgroups are concatenated along the channel dimension to output the final enhanced feature map :
The ReWeight module functions as a non-linear feature equalizer. For instance, high activation weights from large reflective regions (e.g., ) and moderate weights from hairline cracks (e.g., ) are both truncated to 1 if they exceed the mean . This truncation reduces the numerical gap, preventing structural noise from dominating the feature representation while preserving the local weights of weak defects.
3.4. Bounding Box Regression Optimization Based on -IoU
In the detection of surface defects on electrical commutators, defect targets account for a very low proportion of pixels in the image, making the bounding box regression sensitive to coordinate offsets. When the predicted box and the ground truth box have a displacement deviation of a few pixels, the Intersection over Union (IoU) metric drops significantly.
In the standard YOLOv11 architecture, bounding box regression relies on the Complete IoU (CIoU) loss. The standard CIoU evaluates the overlap area, central point distance, and aspect ratio simultaneously, formulated as:
where
is the intersection over union;
is the Euclidean distance between the center points of the predicted box
and the ground truth box
;
c is the diagonal length of the smallest enclosing box covering both boxes;
measures the consistency of the aspect ratio; and
is a positive trade-off parameter.
While standard CIoU performs well in general, as the overlap between predicted and ground truth boxes increases during the later stages of training (i.e., ), the gradient response of the linear IoU term flattens. This limits the model’s ability to achieve high-precision pixel-level alignment for tiny cracks.
To address this limitation, the
-IoU loss function [
13] is introduced to replace the default regression loss in WG-YOLOv11. This method constructs a gradient weighting mechanism by applying power transformations to the IoU term and its geometric penalties. The formulation of
-CIoU is defined as:
where
is a hyperparameter controlling the non-linear power transformation. The non-linear operation is introduced by raising the IoU term, the normalized central distance term
, and the aspect ratio penalty term
to the power of
simultaneously.
The partial derivative of the -IoU loss with respect to the IoU term is calculated as:
This partial derivative reflects the gradient magnitude backpropagated by the model during training. To achieve gradient up-weighting for high-IoU samples, is set strictly greater than 1. Since and , the gradient magnitude monotonically increases with the IoU value.
The exponential power term functions as an adaptive regulator for the gradient magnitude. For predicted boxes with high IoU, the non-linear transformation assigns higher gradient weights, generating stronger feedback signals during backpropagation. For commutator cracks, this non-linear weighting mitigates the gradient flattening issue, encouraging the network to focus on fine-tuning minor offsets and improving boundary alignment.