Miao nationality clothing identification method and system based on YOLOv5s model
By using a YOLOv5s model-based method for recognizing Miao ethnic costumes, and through data distribution optimization and feature integration, combined with channel attention and variable convolution, efficient and accurate recognition of Miao ethnic costumes is achieved, solving the problems of insufficient feature extraction and strong data dependence in existing technologies.
Patent Information
- Application Number
- CN202510958826.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-11
- Publication Date
- 2025-11-21
AI Technical Summary
Existing technologies for identifying Miao ethnic costumes suffer from insufficient feature extraction and strong data dependence, making it difficult to meet the needs for accurate identification of Miao ethnic costumes.
A method for recognizing Miao ethnic costumes based on the YOLOv5s model is adopted. Enhanced images are generated through data distribution optimization processing. Anchor frame parameters are adjusted by combining geometric adaptation. Deformation adaptive feature maps are generated by using image downsampling and cross-stage feature integration, channel attention mechanism and variable convolution processing. Recognition results are output through multi-scale feature fusion and adaptive detection.
It significantly improves the accuracy and robustness of Miao costume recognition, enabling efficient and accurate Miao costume recognition under small sample conditions, including bounding box localization, branch classification, and cultural element labeling.
Smart Images

Figure CN120997471A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of clothing recognition technology, specifically relating to a method and system for recognizing Miao ethnic clothing based on the YOLOv5s model. Background Technology
[0002] Due to its numerous branches and geographically dispersed nature, Miao ethnic clothing exhibits a highly heterogeneous lineage, posing significant challenges to systematic identification and preservation. Traditional image recognition methods, primarily relying on manual classification or general object detection models (such as YOLOv5), while performing reasonably well on standard clothing datasets, exhibit significant shortcomings when processing Miao clothing. Fixed-structure convolutional kernels struggle to effectively capture the curved features of silver ornaments and the three-dimensional textures of embroidery, resulting in insufficient representation of cultural elements, especially with a significantly increased false negative rate in complex backgrounds or under occlusion. Furthermore, existing attention mechanisms (such as the SE module) typically employ a global embedding strategy, lacking targeted enhancement for key areas of the clothing, leading to unreasonable allocation of computational resources and difficulty in improving the recognition accuracy of cultural features such as patterns and decorations. While deformable convolutional networks (DCNs) can theoretically adapt to clothing deformation, existing methods lack prior modeling of the unique geometric patterns of Miao clothing (such as the arrangement of silver ornaments), resulting in a lack of semantic constraints in deformation prediction. Furthermore, deploying the entire network significantly increases the computational burden. At the same time, Miao clothing data is scarce and annotation costs are high. Traditional methods rely on large-scale training data, making it difficult to achieve good generalization under small sample conditions. Therefore, existing technologies suffer from insufficient feature extraction and strong data dependence, making it difficult to meet the needs of accurate Miao clothing recognition. Summary of the Invention
[0003] To address the shortcomings of existing technologies, the present invention aims to provide a method and system for recognizing Miao ethnic costumes based on the YOLOv5s model, which solves the problems of insufficient feature extraction and strong data dependence in existing technologies, making it difficult to meet the needs of accurate recognition of Miao ethnic costumes.
[0004] The objective of this invention can be achieved through the following technical solutions:
[0005] A method for recognizing Miao ethnic costumes based on the YOLOv5s model includes the following steps:
[0006] Input images of clothing, including Miao ethnic costumes;
[0007] The clothing image data is preprocessed, enhanced images are generated through data distribution optimization, and anchor frame parameters are output to adapt to the geometric features of Miao clothing through geometric adaptation.
[0008] Features in the enhanced image are extracted and generated by image downsampling and cross-stage feature integration;
[0009] The channel weights of the original feature map are dynamically calculated using a channel attention mechanism and then multiplied with the original feature map to generate a weighted feature map.
[0010] Variable convolution is used to process the weighted feature map, and a deformable adaptive feature map is generated by adaptive sampling point offset;
[0011] Based on the anchor frame parameters, the deformation adaptive feature map is processed through multi-scale feature fusion and adaptive detection to output the recognition result of Miao ethnic costumes.
[0012] The clothing image data is preprocessed, enhanced images are generated through data distribution optimization, and anchor box parameters are adjusted to fit the geometric features of Miao clothing through geometric adaptation. The specific steps include:
[0013] Data distribution optimization processing includes Mosaic data augmentation, which randomly stitches together multiple clothing images, randomly crops the stitched images, and then uniformly scales the cropped images to a set spatial resolution to generate an enhanced image.
[0014] Geometric adaptation adjustment includes adaptive anchor frame calculation, which optimizes the intersection-over-union ratio (IoU) between the anchor frame size and the real frame, and selects the candidate anchor frame size with the largest average IoU with the real frame as the final anchor frame parameter.
[0015] The process involves extracting features from the enhanced image through image downsampling and cross-stage feature integration to generate an original feature map. This includes the following steps:
[0016] The Focus operation is used to downsample the enhanced image, reduce the spatial resolution of the image by pixel recombination, and expand the channel dimension to preserve high-frequency texture features.
[0017] The downsampled features are input into a cross-stage local connection network, and the original feature map is generated by fusing the main branch convolution and branch features. The features of the main branch and the branch are merged in a cascade manner.
[0018] The clothing images are in RGB three-channel color image format. The four clothing images are randomly stitched together using Mosaic data enhancement, and they are arranged in a rectangular pattern when stitched together.
[0019] Set the spatial resolution to 640×640.
[0020] During downsampling, the spatial resolution of the input image is reduced to half that of the original image by 2×2 pixel grid reconstruction, while the channel dimension is expanded to 4 times the original number of channels.
[0021] The weights of each channel in the original feature map are dynamically calculated using a channel attention mechanism, and then multiplied with the original feature map to generate a weighted feature map. The specific steps include:
[0022] Based on the channel attention mechanism, a global average pooling operation is performed on the original feature map, compressing the original feature map into a 1×1×C shape, generating a channel descriptor vector Z, Z∈R. C The compression feature Z of the c-th channel c The calculation formula is as follows:
[0023]
[0024] In the formula, F sq This represents the Squeeze operation function, i.e., global average pooling; H and W represent the height and width of the image, respectively; i and j represent the values in the height and width directions, respectively; u c (i = j) represents the feature map U output from the c-th channel of the original feature map. c The value at position (i, j);
[0025] The channel descriptor vector Z is input into a weight learning network consisting of two fully connected layers;
[0026] The first fully connected layer compresses the dimension C of the channel descriptor vector Z and applies the ReLU activation function before inputting it into the second fully connected layer;
[0027] The second fully connected layer restores the channel dimension to C and applies the sigmoid activation function to generate the channel attention weight vector S. The channel attention weight vector S is calculated as follows:
[0028] s=σ(W2ReLU(W 1z ),W1∈R C / 16×c ,W2∈R C / 16×c
[0029] In the formula, W1∈R C / 16×C W2∈R C / 16×C These represent the weights of the first fully connected layer and the second fully connected layer, respectively; ReLU is defined as ReLU(x) = max(0, x);
[0030] The channel attention weight vector S is multiplied by the original feature map to generate a weighted feature map.
[0031] The weighted feature map is processed using variable convolution, and a deformable adaptive feature map is generated through adaptive sampling point offset. The specific steps include:
[0032] The variable convolution DCNv2 generates learnable offsets and modulation weights for each convolution sampling point;
[0033] The sampling points are adjusted according to the offset so that the sampling grid can adapt to the target deformation;
[0034] The sampled features are adaptively weighted by modulating the weights to enhance the features of the target region and suppress background interference;
[0035] The weighted features of each sampling point are aggregated to generate a deformation adaptive feature map.
[0036] Based on the anchor box parameters, the deformation adaptive feature map is processed through multi-scale feature fusion and adaptive detection to output the recognition result of Miao ethnic costumes. The specific steps include:
[0037] Multi-scale feature fusion processing is performed on the deformation adaptive feature map, specifically including:
[0038] The Feature Pyramid Network (FPN) is used to perform top-down feature fusion on the deformation adaptive feature map, which enhances the transmission of high-level semantic information to low-level features and improves the detection capability of fine local features of Miao costumes.
[0039] The Path Aggregation Network (PAN) is used to perform bottom-up feature fusion on the deformation adaptive feature map, which strengthens the transmission of low-level detail information to high-level features and improves the detection capability of the overall outline features of Miao costumes.
[0040] The feature fusion result is input into multiple detection heads with different receptive fields for adaptive detection processing. These detection heads are, in order, a first detection head, a second detection head, and a third detection head, where:
[0041] The first detection head is configured to detect fine, localized features of the clothing;
[0042] The second detection head is configured to detect component-level features of the garment;
[0043] The third detection head is configured to detect the overall outline features of the clothing;
[0044] Each detection head generates the position coordinates, confidence score, and category probability of the predicted bounding box based on the anchor frame parameters;
[0045] The detection results are optimized using a composite loss function, which includes bounding box localization loss, category classification loss, and target confidence loss. The localization loss improves localization accuracy by introducing a center point distance penalty term and aspect ratio consistency constraint, while a regularization term for the offset of deformable convolution DCNv2 is added to maintain feature stability.
[0046] The optimized detection results are subjected to non-maximum suppression processing to eliminate redundant detection boxes, retain the detection results with the highest confidence, and finally output the Miao ethnic costume recognition results.
[0047] Fine details include silver components and embroidered patterns;
[0048] Component-level features include sleeves and skirt hems;
[0049] The overall silhouette features include the complete shape of the garment and its spatial layout.
[0050] The identification results of Miao ethnic costumes include bounding box localization, branch classification, and cultural element marking.
[0051] A Miao ethnic costume recognition system based on the YOLOv5s model, employing the aforementioned Miao ethnic costume recognition method for identification, includes:
[0052] The preprocessing module receives clothing image data from the input system, generates enhanced images through data distribution optimization, and adjusts the output anchor frame parameters to adapt to the geometric features of Miao clothing through geometric adaptation.
[0053] The original feature extraction module receives the enhanced image as input and extracts features from the enhanced image by image downsampling and cross-stage feature integration to generate the original feature map.
[0054] The feature weighting module receives the original feature map, dynamically calculates the weight of each channel through the channel attention mechanism, and multiplies it with the original feature map to generate a weighted feature map.
[0055] The feature enhancement module receives the weighted feature map, processes it using variable convolution, and generates a deformable adaptive feature map through adaptive sampling point offset.
[0056] The multi-scale prediction module receives deformation adaptive feature maps and, in conjunction with anchor box parameters, outputs the recognition results of Miao ethnic costumes through multi-scale feature fusion and adaptive detection mechanisms.
[0057] The beneficial effects of this invention are:
[0058] The invention generates enhanced images through data distribution optimization and adjusts the anchor box parameters to fit the geometric features of Miao ethnic clothing through geometric adaptation, significantly improving data utilization efficiency. It extracts features from the enhanced images through image downsampling and cross-stage feature integration to generate original feature maps, and dynamically calculates the weights of each channel using a channel attention mechanism to generate weighted feature maps, effectively enhancing the representation of fine local features such as silver ornament components and embroidery patterns. It employs Variable Convolution DCNv2 to process the weighted feature maps and generates deformation-adaptive feature maps through adaptive sampling point offset, enabling the model to accurately adapt to the geometric deformation features of the clothing. Based on the anchor box parameters, the deformation-adaptive feature maps are processed through multi-scale feature fusion, using a Feature Pyramid Network (FPN) and a Path Aggregation Network (PAN) to achieve multi-scale feature fusion, enabling the model to simultaneously detect fine local features, component-level features, and overall contour features. The feature fusion results are input to multiple detection heads with different receptive fields for adaptive detection processing, combined with composite loss function optimization and non-maximum suppression processing. The final output of Miao ethnic clothing recognition results includes bounding box localization, branch classification, and cultural element labeling, significantly improving recognition accuracy and robustness while maintaining computational efficiency. Attached Figure Description
[0059] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0060] Figure 1 This is a schematic diagram of the overall process of the Miao ethnic costume identification method of the present invention. Detailed Implementation
[0061] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0062] like Figure 1 As shown, a method for recognizing Miao ethnic clothing based on the YOLOv5s model specifically includes the following steps:
[0063] Input images of clothing, including Miao ethnic costumes;
[0064] The clothing image data is preprocessed, enhanced images are generated through data distribution optimization, and anchor frame parameters are output to adapt to the geometric features of Miao clothing through geometric adaptation.
[0065] Features in the enhanced image are extracted and generated by image downsampling and cross-stage feature integration;
[0066] The channel weights of the original feature map are dynamically calculated using a channel attention mechanism and then multiplied with the original feature map to generate a weighted feature map.
[0067] Variable convolution is used to process the weighted feature map, and a deformable adaptive feature map is generated by adaptive sampling point offset;
[0068] Based on the anchor frame parameters, the deformation adaptive feature map is processed by multi-scale feature fusion and adaptive detection to output the recognition result of Miao costumes;
[0069] The clothing image data is preprocessed, enhanced images are generated through data distribution optimization, and anchor box parameters are adjusted to fit the geometric features of Miao clothing through geometric adaptation. The specific steps include:
[0070] Data distribution optimization processing includes Mosaic data augmentation, which randomly stitches together multiple clothing images, randomly crops the stitched images, and then uniformly scales the cropped images to a set spatial resolution to generate an enhanced image.
[0071] Geometric adaptation adjustment includes adaptive anchor frame calculation, which optimizes the intersection-union ratio (IUU) between the anchor frame size and the real frame, and selects the candidate anchor frame size with the largest average IUU with the real frame as the final anchor frame parameter;
[0072] Adaptive anchor box calculation is achieved using the following formula:
[0073]
[0074] In the formula, b i Represents a real bounding box; a k represents the anchor box; IoU is the intersection-union ratio; k represents the total number of preset candidate anchor boxes; N represents the number of ground truth boxes in an image.
[0075] The process involves extracting features from the enhanced image through image downsampling and cross-stage feature integration to generate an original feature map. This includes the following steps:
[0076] The Focus operation is used to downsample the enhanced image, reduce the spatial resolution of the image by pixel recombination, and expand the channel dimension to preserve high-frequency texture features.
[0077] The expression for the Focus operation is as follows:
[0078] F focus=Concat(I[::2,::2],I[1::2,::2],I[::2,1::2],I[1::2,1::2])
[0079] F focus This represents the features of the enhanced image after the Focus operation;
[0080] The downsampled features are input into a cross-stage local connection network, and the original feature map is generated by fusing the main branch convolution and branch features. The features of the main branch and the branch are merged in a cascade manner.
[0081] Preferably, the main convolutional path consists of three CBS modules (convolution + batch normalization + SiLU activation). The first CBS is mainly responsible for extracting low-level texture features such as embroidery patterns, the second CBS focuses on capturing local structures such as silver ornament components, and the third CBS begins to integrate component-level features such as sleeves and skirts. The branch paths consist of a single CBS, which focuses on understanding the overall outline and spatial layout of the clothing. This progressive feature extraction method enables the network to comprehensively grasp the multi-scale features of Miao clothing from micro to macro levels. Finally, the features of the two paths are concatenated in the channel dimension through the Concat operation to achieve the organic fusion of multi-scale features.
[0082] The clothing images are in RGB three-channel color image format. The four clothing images are randomly stitched together using Mosaic data enhancement, and they are arranged in a rectangular pattern when stitched together.
[0083] Preferably, randomly stitching four images can fully cover diverse clothing features while avoiding information sparsity or distortion caused by too many images. In addition, the four-grid layout and anchor box optimization are highly compatible, significantly improving the cross-union ratio and component-level detection accuracy, while enhancing the model's generalization ability under small sample conditions.
[0084] Mosaic data augmentation, which involves randomly stitching together four clothing images, can be represented as follows:
[0085] I mosaic =Crop(Concat(I1,I2,I3,I4))
[0086] In the formula, I1, I2, I3, and I4 are four random clothing images; Crop represents the cropping operation; Concat represents the stitching operation.
[0087] The spatial resolution is set to 640×640 to fit the default input size of the YOLOv5s model, ensuring computational efficiency and the completeness of feature extraction, while also improving the accuracy of small object detection and maintaining real-time inference data.
[0088] During downsampling, the principle of information conservation is followed: (H×W×C=(H / 2)×(W / 2)×4C);
[0089] That is, by recombining 2×2 pixel grids, the spatial resolution of the input image is reduced to half of the original image, while the channel dimension is expanded to four times the original number of channels, providing a richer representation space for subsequent feature extraction and attention mechanisms.
[0090] Suppose the original feature map of clothing image X is U, and the dimensions of U are H×W×C, where H and W represent the height and width in the image space, respectively, and C represents the number of channels. The mapping expression from clothing image to original feature map is as follows:
[0091]
[0092] In the formula, U c This represents the output feature map (with dimensions H×W) of the c-th channel; v c This represents the convolution kernel (filter) corresponding to the c-th output channel. Its dimension is usually k×k×C, where k is the spatial size of the convolution kernel and C is the number of input channels. X represents the weight slice of the c-th convolutional kernel on the s-th input channel; s This represents the s-th channel (with dimensions H×W) of the input image X;
[0093] The weights of each channel in the original feature map are dynamically calculated using a channel attention mechanism, and then multiplied with the original feature map to generate a weighted feature map. The specific steps include:
[0094] Based on the channel attention mechanism, a global average pooling operation is performed on the original feature map, compressing the original feature map into a 1×1×C shape, generating a channel descriptor vector Z, Z∈RC, where the compressed feature of the c-th channel is Zc. c The calculation formula is as follows:
[0095]
[0096] In the formula, F sq This represents the Squeeze operation function, i.e., global average pooling; H and W represent the height and width of the image, respectively; i and j represent the values in the height and width directions, respectively; u c (i = j) represents the feature map U output from the c-th channel of the original feature map. c The value at position (i, j);
[0097] The channel descriptor vector Z is input into a weight learning network consisting of two fully connected layers;
[0098] The first fully connected layer compresses the dimension C of the channel descriptor vector Z and applies the ReLU activation function before inputting it into the second fully connected layer;
[0099] The second fully connected layer restores the channel dimension to C and applies the sigmoid activation function to generate the channel attention weight vector s. The calculation formula for the channel attention weight vector s is as follows:
[0100] s=σ(W2ReLU(W 1z ),W1∈R C / 16×c ,W2∈R C / 16×c
[0101] In the formula, W1∈R C / 16×C W2∈R C / 16×C These represent the weights of the first fully connected layer and the second fully connected layer, respectively; ReLU is defined as ReLU(x) = max(0, x);
[0102] Multiply the channel attention weight vector s with the original feature map to generate a weighted feature map;
[0103] The weighted feature map is processed using variable convolution, and a deformable adaptive feature map is generated through adaptive sampling point offset. The specific steps include:
[0104] The variable convolution DCNv2 generates learnable offsets and modulation weights for each convolution sampling point;
[0105] The sampling points are adjusted according to the offset so that the sampling grid can adapt to the target deformation;
[0106] The sampled features are adaptively weighted by modulating the weights to enhance the features of the target region and suppress background interference;
[0107] The weighted features of each sampling point are aggregated to generate a deformation adaptive feature map;
[0108] The output Y of a regular convolution can be represented by the following formula:
[0109]
[0110] In the formula, p0 represents the current position coordinates on the output feature map;
[0111] p n This represents the offset coordinate of the nth sampling point within the convolution kernel relative to the center p0;
[0112] x(p0+p n ) indicates that the input feature map is at position p0+p n The pixel value or feature value at that location;
[0113] w(p n) indicates that the convolution kernel is at sampling point p n Weight parameters at the location;
[0114] After adding the offset ΔPn, the output Y can be expressed by the following formula:
[0115]
[0116] With the added offset, feature extraction is no longer limited to the traditional bounding box, but can more completely cover the entire object, thus better extracting features from irregular target objects. However, it may also introduce some regions irrelevant to the current task, interfering with feature extraction. Therefore, in Deformable Convolution DCNv2, in addition to using the offset ΔPn, a weight coefficient Δmk is added. Larger weights are assigned to regions of interest in the current task, while the smallest weight of 0 is assigned to regions irrelevant to the current task (i.e., the background). This allows the model to better distinguish between the target and the background in the current task. The output Y of Deformable Convolution DCNv2 can be represented by the following formula:
[0117]
[0118] Based on the anchor box parameters, the deformation adaptive feature map is processed through multi-scale feature fusion and adaptive detection to output the recognition result of Miao ethnic costumes. The specific steps include:
[0119] Multi-scale feature fusion processing is performed on the deformation adaptive feature map, specifically including:
[0120] The Feature Pyramid Network (FPN) is used to perform top-down feature fusion on the deformation adaptive feature map, which enhances the transmission of high-level semantic information to low-level features and improves the detection capability of fine local features of Miao costumes.
[0121] The Path Aggregation Network (PAN) is used to perform bottom-up feature fusion on the deformation adaptive feature map, which strengthens the transmission of low-level detail information to high-level features and improves the detection capability of the overall outline features of Miao costumes.
[0122] The expression for feature fusion is as follows:
[0123]
[0124] In the formula, This represents a high-level feature map (lower resolution, richer semantic information);
[0125] To represent higher-level (more abstract) feature maps, upsampling is required. Same resolution;
[0126] This represents a low-level feature map (high resolution, rich details);
[0127] This represents a higher-level feature map, which, after upsampling, is compared with... Integration;
[0128] The feature fusion result is input into multiple detection heads with different receptive fields for adaptive detection processing. These detection heads are, in order, a first detection head, a second detection head, and a third detection head, where:
[0129] The first detection head is configured to detect fine, localized features of the clothing;
[0130] The second detection head is configured to detect component-level features of the garment;
[0131] The third detection head is configured to detect the overall outline features of the clothing;
[0132] Each detection head generates the position coordinates, confidence score, and category probability of the predicted bounding box based on the anchor frame parameters;
[0133] Preferably, the resolutions of the first detection head, the second detection head, and the third detection head are 80×80, 40×40, and 20×20, respectively;
[0134] The adaptive detection process can be represented as:
[0135]
[0136] In the formula, Output t Conv represents the output prediction result of the t-th detector head; 1×1 This represents a 1×1 convolutional layer that maps the multi-channel features output by PAN to the output dimension (5+C) required for the detection task.
[0137] The output dimension is S×S×(5+C), and the output content is the predicted bounding box (x,y,w,h) of each grid, the confidence score, and the classification probability.
[0138] The detection results are optimized using a composite loss function, which includes bounding box localization loss, category classification loss, and target confidence loss. The localization loss improves localization accuracy by introducing a center point distance penalty term and aspect ratio consistency constraint, while a regularization term for the offset of deformable convolution DCNv2 is added to maintain feature stability.
[0139] Since traditional IoU cannot distinguish the positioning differences of overlapping boxes, a center point distance ρ is introduced to penalize the center offset between the predicted box and the ground truth box, and aspect ratio consistency υ is ensured by specifically optimizing the special proportions of Miao ethnic costumes. The specific formula is as follows:
[0140]
[0141] In the formula, α = 0.05; ρ(b,b gt The center point distance () represents the Euclidean distance between the centers of the two bounding boxes (in pixels); c represents the diagonal of the minimum closure region; v represents the aspect ratio consistency measure; w represents the width of the predicted bounding box; h represents the height of the predicted bounding box; w gt h is the width of the actual bounding box (annotation box). gt This is the height of the actual bounding box (annotation box);
[0142] The optimized detection results are processed by non-maximum suppression (NMS), which is a key step in the post-processing of target detection. Its core function is to eliminate redundant detection boxes and retain the detection results with the highest confidence by filtering through the intersection-over-union (IoU) threshold, and finally output the Miao ethnic costume recognition results.
[0143] The specific process is as follows: First, all predicted boxes are sorted in descending order of confidence score. The highest-scoring box is then added to the retention list, while adjacent boxes with an IoU exceeding a set threshold are removed, until all candidate boxes have been processed. In Miao ethnic clothing recognition, NMS effectively solves the problem of duplicate detection of cultural elements such as silver ornaments and embroidery (e.g., when multiple overlapping boxes are generated for the same silver ornament, only the most reliable result is retained), ensuring a concise and reliable output. This process can be represented as: inputting the predicted box coordinates (Boxes) and confidence scores (Scores), processing by the NMS algorithm, and outputting the retention index (Keep). Its effectiveness directly determines the accuracy and usability of the final recognition result, and its expression is:
[0144] Keep=NMS(Boxes, Scores, IoU thresh =0.5)
[0145] Fine details include silver components and embroidered patterns;
[0146] Component-level features include sleeves and skirt hems;
[0147] The overall silhouette features include the complete shape of the garment and its spatial layout.
[0148] The identification results of Miao ethnic costumes include bounding box localization, branch classification, and cultural element marking.
[0149] A Miao ethnic costume recognition system based on the YOLOv5s model, employing the aforementioned Miao ethnic costume recognition method for identification, includes:
[0150] The preprocessing module receives clothing image data from the input system, generates enhanced images through data distribution optimization, and adjusts the output anchor frame parameters to adapt to the geometric features of Miao clothing through geometric adaptation.
[0151] The original feature extraction module receives the enhanced image as input and extracts features from the enhanced image by image downsampling and cross-stage feature integration to generate the original feature map.
[0152] The feature weighting module receives the original feature map, dynamically calculates the weight of each channel through the channel attention mechanism, and multiplies it with the original feature map to generate a weighted feature map.
[0153] The feature enhancement module receives the weighted feature map, processes it using variable convolution, and generates a deformable adaptive feature map through adaptive sampling point offset.
[0154] The multi-scale prediction module receives deformation adaptive feature maps and, in conjunction with anchor box parameters, outputs the recognition results of Miao ethnic costumes through multi-scale feature fusion and adaptive detection mechanisms.
[0155] The invention generates enhanced images through data distribution optimization and adjusts the anchor box parameters to fit the geometric features of Miao ethnic clothing through geometric adaptation, significantly improving data utilization efficiency. It extracts features from the enhanced images through image downsampling and cross-stage feature integration to generate original feature maps, and dynamically calculates the weights of each channel using a channel attention mechanism to generate weighted feature maps, effectively enhancing the representation of fine local features such as silver ornament components and embroidery patterns. It employs Variable Convolution DCNv2 to process the weighted feature maps and generates deformation-adaptive feature maps through adaptive sampling point offset, enabling the model to accurately adapt to the geometric deformation features of the clothing. Based on the anchor box parameters, the deformation-adaptive feature maps are processed through multi-scale feature fusion, using a Feature Pyramid Network (FPN) and a Path Aggregation Network (PAN) to achieve multi-scale feature fusion, enabling the model to simultaneously detect fine local features, component-level features, and overall contour features. The feature fusion results are input to multiple detection heads with different receptive fields for adaptive detection processing, combined with composite loss function optimization and non-maximum suppression processing. The final output of Miao ethnic clothing recognition results includes bounding box localization, branch classification, and cultural element labeling, significantly improving recognition accuracy and robustness while maintaining computational efficiency.
[0156] In the description of this specification, references to terms such as "an embodiment," "example," "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0157] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the present invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention.
Claims
1. A method for recognizing Miao ethnic clothing based on the YOLOv5s model, characterized in that, Specifically, the following steps are included: Input images of clothing, including Miao ethnic costumes; The clothing image data is preprocessed, enhanced images are generated through data distribution optimization, and anchor frame parameters are output to adapt to the geometric features of Miao clothing through geometric adaptation. Features in the enhanced image are extracted and generated by image downsampling and cross-stage feature integration; The channel weights of the original feature map are dynamically calculated using a channel attention mechanism and then multiplied with the original feature map to generate a weighted feature map. Variable convolution is used to process the weighted feature map, and a deformable adaptive feature map is generated by adaptive sampling point offset; Based on the anchor frame parameters, the deformation adaptive feature map is processed through multi-scale feature fusion and adaptive detection to output the recognition result of Miao ethnic costumes.
2. The Miao ethnic costume recognition method based on the YOLOv5s model according to claim 1, characterized in that, The clothing image data is preprocessed, enhanced images are generated through data distribution optimization, and anchor box parameters are adjusted to fit the geometric features of Miao clothing through geometric adaptation. The specific steps include: Data distribution optimization processing includes Mosaic data augmentation, which randomly stitches together multiple clothing images, randomly crops the stitched images, and then uniformly scales the cropped images to a set spatial resolution to generate an enhanced image. Geometric adaptation adjustment includes adaptive anchor frame calculation, which optimizes the intersection-over-union ratio (IoU) between the anchor frame size and the real frame, and selects the candidate anchor frame size with the largest average IoU with the real frame as the final anchor frame parameter.
3. The Miao ethnic costume recognition method based on the YOLOv5s model according to claim 2, characterized in that, The process involves extracting features from the enhanced image through image downsampling and cross-stage feature integration to generate an original feature map. This includes the following steps: The Focus operation is used to downsample the enhanced image, reduce the spatial resolution of the image by pixel recombination, and expand the channel dimension to preserve high-frequency texture features. The downsampled features are input into a cross-stage local connection network, and the original feature map is generated by fusing the main branch convolution and branch features. The features of the main branch and the branch are merged in a cascade manner.
4. The Miao ethnic costume recognition method based on the YOLOv5s model according to claim 3, characterized in that, The clothing images are in RGB three-channel color image format. The four clothing images are randomly stitched together using Mosaic data enhancement, and they are arranged in a rectangular pattern when stitched together. Set the spatial resolution to 640×640. During downsampling, the spatial resolution of the input image is reduced to half that of the original image by 2×2 pixel grid reconstruction, while the channel dimension is expanded to 4 times the original number of channels.
5. The Miao ethnic costume recognition method based on the YOLOv5s model according to claim 4, characterized in that, The weights of each channel in the original feature map are dynamically calculated using a channel attention mechanism, and then multiplied with the original feature map to generate a weighted feature map. The specific steps include: Based on the channel attention mechanism, a global average pooling operation is performed on the original feature map, compressing the original feature map into a 1×1×C shape, generating a channel descriptor vector Z, Z∈R. C The compression feature Z of the c-th channel c The calculation formula is as follows: In the formula, F sq This represents the Squeeze operation function, i.e., global average pooling; H and W represent the height and width of the image, respectively; i and j represent the values in the height and width directions, respectively; u c (i = j) represents the feature map U output from the c-th channel of the original feature map. c The value at position (i, j); The channel descriptor vector Z is input into a weight learning network consisting of two fully connected layers; The first fully connected layer compresses the dimension C of the channel descriptor vector Z and applies the ReLU activation function before inputting it into the second fully connected layer; The second fully connected layer restores the channel dimension to C and applies the sigmoid activation function to generate the channel attention weight vector S. The channel attention weight vector S is calculated as follows: sσ(W2ReLU(W 1z )),W1∈R C / 16×c ,W2∈R C / 16×c In the formula, W1∈R C / 16×C W2∈R C / 16×C These represent the weights of the first fully connected layer and the second fully connected layer, respectively; ReLU is defined as ReLU(x) = max(0, x); The channel attention weight vector S is multiplied by the original feature map to generate a weighted feature map.
6. The Miao ethnic costume recognition method based on the YOLOv5s model according to claim 5, characterized in that, The weighted feature map is processed using variable convolution, and a deformable adaptive feature map is generated through adaptive sampling point offset. The specific steps include: The variable convolution DCNv2 generates learnable offsets and modulation weights for each convolution sampling point; The sampling points are adjusted according to the offset so that the sampling grid can adapt to the target deformation; The sampled features are adaptively weighted by modulating the weights to enhance the features of the target region and suppress background interference; The weighted features of each sampling point are aggregated to generate a deformation adaptive feature map.
7. The Miao ethnic costume recognition method based on the YOLOv5s model according to claim 6, characterized in that, Based on the anchor box parameters, the deformation adaptive feature map is processed through multi-scale feature fusion and adaptive detection to output the recognition result of Miao ethnic costumes. The specific steps include: Multi-scale feature fusion processing is performed on the deformation adaptive feature map, specifically including: The Feature Pyramid Network (FPN) is used to perform top-down feature fusion on the deformation adaptive feature map, which enhances the transmission of high-level semantic information to low-level features and improves the detection capability of fine local features of Miao costumes. The Path Aggregation Network (PAN) is used to perform bottom-up feature fusion on the deformation adaptive feature map, which strengthens the transmission of low-level detail information to high-level features and improves the detection capability of the overall outline features of Miao costumes. The feature fusion result is input into multiple detection heads with different receptive fields for adaptive detection processing. These detection heads are, in order, a first detection head, a second detection head, and a third detection head, where: The first detection head is configured to detect fine, localized features of the clothing; The second detection head is configured to detect component-level features of the garment; The third detection head is configured to detect the overall outline features of the clothing; Each detection head generates the position coordinates, confidence score, and category probability of the predicted bounding box based on the anchor frame parameters; The detection results are optimized using a composite loss function, which includes bounding box localization loss, category classification loss, and target confidence loss. The localization loss improves localization accuracy by introducing a center point distance penalty term and aspect ratio consistency constraint, while a regularization term for the offset of deformable convolution DCNv2 is added to maintain feature stability. The optimized detection results are subjected to non-maximum suppression processing to eliminate redundant detection boxes, retain the detection results with the highest confidence, and finally output the Miao ethnic costume recognition results.
8. The Miao ethnic costume recognition method based on the YOLOv5s model according to claim 7, characterized in that, Fine details include silver components and embroidered patterns; Component-level features include sleeves and skirt hems; The overall silhouette features include the complete shape of the garment and its spatial layout.
9. The Miao ethnic costume recognition method based on the YOLOv5s model according to claim 8, characterized in that, The identification results of Miao ethnic costumes include bounding box localization, branch classification, and cultural element marking.
10. A Miao ethnic costume recognition system based on the YOLOv5s model, which uses the aforementioned Miao ethnic costume recognition method for recognition, characterized in that... include: The preprocessing module receives clothing image data from the input system, generates enhanced images through data distribution optimization, and adjusts the output anchor frame parameters to adapt to the geometric features of Miao clothing through geometric adaptation. The original feature extraction module receives the enhanced image as input and extracts features from the enhanced image by image downsampling and cross-stage feature integration to generate the original feature map. The feature weighting module receives the original feature map, dynamically calculates the weight of each channel through the channel attention mechanism, and multiplies it with the original feature map to generate a weighted feature map. The feature enhancement module receives the weighted feature map, processes it using variable convolution, and generates a deformable adaptive feature map through adaptive sampling point offset. The multi-scale prediction module receives deformation adaptive feature maps and, in conjunction with anchor box parameters, outputs the recognition results of Miao ethnic costumes through multi-scale feature fusion and adaptive detection mechanisms.