Pedestrian clothing recognition method and device based on improved YOLOv8 model, equipment and storage medium
By improving the YOLOv8 model and combining it with the CSPDarknet53 architecture, PAN-FPN structure and detection head branch, the problem of insufficient accuracy of existing algorithms in pedestrian clothing recognition in complex scenarios is solved, and accurate recognition of clothing types, colors and styles is achieved, improving the recognition effect.
Patent Information
- Application Number
- CN202511151724.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-18
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2045-08-18
AI Technical Summary
The existing YOLOv3 and YOLOv5 algorithms are not sensitive enough to fine-grained clothing features in pedestrian clothing recognition, while YOLOv8 has limitations in processing multi-scale features, resulting in insufficient recognition capabilities in complex scenarios.
An improved YOLOv8 model is adopted, including a backbone network layer, a feature fusion layer and a detection head. The backbone network layer is composed of a CSPDarknet53 architecture, a coordinate attention module, an SCConv module and a Focus module. The feature fusion layer is composed of a PAN-FPN structure and a second C2f module. The detection head is divided into a classification branch and a regression branch, and color and style classification branches are added. The recognition accuracy is improved through multi-scale feature fusion and fine-grained recognition.
It improves the accuracy of pedestrian clothing recognition in complex scenarios, can accurately identify clothing types, colors and styles, and enhances adaptability and detection accuracy to features of different scales.
Smart Images

Figure CN120656043B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and particularly relates to a pedestrian clothing recognition method and device based on an improved YOLOv8 model, equipment and a storage medium. BACKGROUND
[0002] At present, pedestrian clothing recognition mainly adopts a target detection algorithm based on deep learning, such as a YOLO series algorithm. The existing YOLOv3 and YOLOv5 algorithms have achieved good results in traffic sign recognition and pedestrian detection, but the backbone network thereof is insufficiently sensitive to fine-grained clothing features (such as clothing patterns, colors, etc.), and the existing YOLOv8 has limitations in processing multi-scale features, and it is difficult to simultaneously effectively extract clothing features of different scales, resulting in insufficient recognition ability of clothing in complex scenes. Therefore, there is an urgent need for a pedestrian clothing recognition method to improve the accuracy of pedestrian clothing recognition in complex scenes. SUMMARY
[0003] The main purpose of the present application is to provide a pedestrian clothing recognition method and device based on an improved YOLOv8 model, equipment and a storage medium, aiming to solve the technical problem of how to improve the accuracy of pedestrian clothing recognition in complex scenes.
[0004] To achieve the above-mentioned purpose, the present application provides a pedestrian clothing recognition method based on an improved YOLOv8 model, comprising:
[0005] obtaining pedestrian image data;
[0006] preprocessing the image data to obtain processed image data;
[0007] Input the processed image data into a preset clothing recognition model for recognition to obtain a clothing recognition result, the preset clothing recognition model being an improved YOLOv8 model, the improved YOLOv8 model comprising a backbone network layer, a feature fusion layer and a detection head, the backbone network layer being composed of a CSPDarknet53 architecture, a coordinate attention module, an SCConv module and a Focus module, wherein the CSPDarknet53 architecture is composed of a first C2f module and a max pooling layer in series, the coordinate attention module is inserted into first, second and third preset sublayers of the backbone network layer, the first C2f module comprises two Bottleneck layers, each layer being composed of a first convolution and a second convolution, and the Focus module is composed of a third convolution; the feature fusion layer is composed of a PAN-FPN structure and a second C2f module, and the PAN-FPN structure and the second C2f module are both bidirectional cross-layer connections; the detection head is used for target detection and classification, the detection head is divided into a classification branch and a regression branch, the classification branch and the regression branch are both one-dimensional convolutions, and the classification branch further comprises a color classification branch and a style classification branch.
[0008] In an embodiment, the step of inputting the processed image data into a preset clothing recognition model for recognition to obtain a clothing recognition result comprises:
[0009] Feature extraction is performed on the processed image data by the backbone network layer to obtain clothing features;
[0010] Multi-scale fusion is performed on the clothing features by the feature fusion layer to obtain fused features;
[0011] Classification and regression are performed on the fused features by the detection head to obtain a clothing recognition result.
[0012] In an embodiment, the step of performing feature extraction on the processed image data by the backbone network layer to obtain clothing features comprises:
[0013] Slice operation is performed on the processed image data by a Focus module, and feature extraction is performed using a third convolution to obtain an initial feature map;
[0014] The initial feature map is input into a CSPDarknet53 architecture to perform feature extraction by a first Bottleneck layer of a first C2f module, to obtain a first intermediate feature map, wherein the first Bottleneck layer performs feature extraction by feature transformation in turn through a first convolution and a second convolution;
[0015] The first intermediate feature map is input into a coordinate attention module and is enhanced by a location-sensitive feature enhancement mechanism to obtain a second intermediate feature map.
[0016] The second intermediate feature map is input into a CSPDarknet53 architecture and is extracted by a second Bottleneck layer of a first C2f module to obtain a third intermediate feature map, wherein the second Bottleneck layer is sequentially subjected to feature transformation by a first convolution and a second convolution for feature extraction.
[0017] The third intermediate feature map is sequentially subjected to multi-scale feature fusion by a preset number of max-pooling layers to obtain a fourth intermediate feature map.
[0018] The fourth intermediate feature map is input into an SCConv module for fast spatial pyramid pooling processing to obtain a clothing feature.
[0019] In an embodiment, the step of performing multi-scale fusion on the clothing feature by the feature fusion layer to obtain a fusion feature includes:
[0020] The clothing feature is subjected to down-sampling processing by a first down-sampling path of a PAN-FPN structure to obtain a first down-sampled feature.
[0021] The first down-sampled feature is sequentially subjected to operations of a first convolution and a second convolution of a second C2f module to obtain a first cross-stage feature.
[0022] The first cross-stage feature is subjected to up-sampling processing by a first up-sampling path of the PAN-FPN structure using a nearest neighbor interpolation method to obtain a first up-sampled feature.
[0023] The first up-sampled feature is processed by a second cross-stage part of the second C2f module to obtain a second cross-stage feature.
[0024] The second cross-stage feature is subjected to down-sampling processing by a second down-sampling path of the PAN-FPN structure to obtain a second down-sampled feature.
[0025] The second down-sampled feature is spliced with the clothing feature to obtain a fusion feature.
[0026] In an embodiment, the step of classifying and regressing the fusion feature by the detection head to obtain a clothing recognition result includes:
[0027] The fusion feature is subjected to preliminary feature transformation by the detection head to obtain an initial detection feature.
[0028] Performing feature enhancement on the initial detection feature through a global attention mechanism module to obtain an enhanced detection feature;
[0029] The initial detection features are input into the classification branch and the regression branch respectively to obtain the category probability distribution and target position information, wherein the category probability distribution is obtained based on the color category and the style category:
[0030] fusing the category probability distribution and the target position information to obtain a clothing detection result;
[0031] The clothing detection result is processed by a non-maximum suppression algorithm to obtain a clothing recognition result.
[0032] In one embodiment, before the step of inputting the processed image data into a preset clothing recognition model for recognition to obtain a clothing recognition result, the step includes:
[0033] Acquire historical image data;
[0034] Annotating the historical image data to generate a training set and a test set;
[0035] Build an initial clothing recognition model;
[0036] The clothing recognition model is trained using the training set to obtain a preset clothing recognition model.
[0037] In one embodiment, the step of training the clothing recognition model using the training set to obtain a preset clothing recognition model includes:
[0038] Initializing weight and bias parameters of the initial clothing recognition model;
[0039] Inputting the image data in the training set into the initial clothing recognition model for calculation to obtain predicted position and category probability;
[0040] Calculating the error between the predicted position and the actual position according to a first loss function to obtain a distributed focus loss, wherein the actual position is calculated according to an external matrix;
[0041] Calculating the cross entropy loss of the class probability and the true class label according to a second loss function to obtain the class probability loss, wherein the true class label is obtained by a preset coding table;
[0042] Processing is performed according to the distribution focus loss and the category probability loss to obtain a total error value;
[0043] Obtaining the gradients of the weight and bias parameters by back propagation algorithm calculation;
[0044] According to the gradient, the weight and bias parameters are iteratively updated by an optimization algorithm until a maximum iteration number is reached or the total error value converges to a preset threshold, to obtain a preset clothing recognition model.
[0045] In addition, to achieve the above object, the application further provides a pedestrian clothing recognition device based on an improved YOLOv8 model.
[0046] The acquisition module is configured to acquire pedestrian image data.
[0047] The processing module is configured to pre-process the image data to obtain processed image data.
[0048] The result module is configured to input the processed image data into a preset clothing recognition model for recognition to obtain a clothing recognition result, wherein the preset clothing recognition model is an improved YOLOv8 model, and the improved YOLOv8 model comprises a backbone network layer, a feature fusion layer and a detection head.
[0049] In addition, to achieve the above object, the application further provides a storage medium, which is a computer readable storage medium, and a computer program is stored on the storage medium.
[0050] In addition, to achieve the above object, the application further provides a computer program product, which comprises a computer program.
[0051] The pedestrian image data is acquired and preprocessed, high-quality input data is generated through normalization. Then, an improved YOLOv8 model is used for recognition, which contains three core parts: the backbone network layer is responsible for feature extraction; the feature fusion layer is used for multi-scale feature fusion; the detection head is divided into classification branch and regression branch, and additional color and style classification branch is added, which realizes accurate identification of clothing type, color and style, and improves the accuracy of pedestrian clothing recognition in complex scenes. BRIEF DESCRIPTION OF DRAWINGS
[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, for those skilled in the art, other drawings can also be obtained without creative labor.
[0053] Figure 1 The flowchart of the first embodiment of the pedestrian clothing recognition method based on the improved YOLOv8 model of the present application is shown.
[0054] Figure 2 The improved YOLOv8 model structure diagram of the first embodiment of the pedestrian clothing recognition method based on the improved YOLOv8 model of the present application is shown.
[0055] Figure 3 The flowchart of the second embodiment of the pedestrian clothing recognition method based on the improved YOLOv8 model of the present application is shown.
[0056] Figure 4 The flowchart of the third embodiment of the pedestrian clothing recognition method based on the improved YOLOv8 model of the present application is shown.
[0057] Figure 5 The module structure diagram of the pedestrian clothing recognition device based on the improved YOLOv8 model of the present application is shown.
[0058] Figure 6 The device structure diagram of the hardware running environment involved in the pedestrian clothing recognition method based on the improved YOLOv8 model in the embodiments of the present application is shown.
[0059] The purpose of the present application, the functional characteristics and advantages will be further explained in conjunction with the embodiments and with reference to the drawings. DETAILED DESCRIPTION
[0060] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application, and are not used to limit the present application.
[0061] In order to better understand the technical solutions of the present application, the drawings in the specification and the specific embodiments will be described in detail.
[0062] In the rapidly developing field of public safety and technical monitoring today, there is an increasing demand for accurate identification of clothing worn by pedestrians. Whether it is to ensure the safety of public areas or to optimize the operational efficiency of intelligent traffic systems, accurate identification of clothing information plays a crucial role. However, existing YOLOv3 and YOLOv5 algorithms have achieved good results in traffic sign recognition and pedestrian detection, but their backbone networks lack sensitivity to fine-grained clothing features such as clothing patterns and colors. Existing YOLOv8 has limitations in handling multi-scale features, making it difficult to effectively extract clothing features of different scales simultaneously, resulting in insufficient recognition ability for clothing in complex scenes.
[0063] Therefore, the present application proposes a pedestrian clothing recognition method based on an improved YOLOv8 model to solve the above problems. The main solution of the embodiment of the present application is: obtaining pedestrian image data; preprocessing the image data to obtain processed image data; inputting the processed image data into a preset clothing recognition model for recognition to obtain a clothing recognition result, the preset clothing recognition model being an improved YOLOv8 model, the improved YOLOv8 model including a backbone network layer, a feature fusion layer, and a detection head, the backbone network layer being composed of a CSPDarknet53 architecture, a coordinate attention module, an SCConv module, and a Focus module, wherein the CSPDarknet53 architecture is composed of a first C2f module and a max pooling layer in series, the coordinate attention module is inserted into a first preset sublayer, a second preset sublayer, and a third preset sublayer of the backbone network layer, the first C2f module includes 2 Bottleneck layers, each layer being composed of a first convolution and a second convolution, and the Focus module is composed of a third convolution; the feature fusion layer is composed of a PAN-FPN structure and a second C2f module, both the PAN-FPN structure and the PAN-FPN structure are bidirectional cross-layer connections; the detection head is used for target detection and classification, the detection head is divided into a classification branch and a regression branch, both the classification branch and the regression branch are one-dimensional convolutions, and the classification branch further includes a color classification branch and a style classification branch.
[0064] Based on the above, the embodiment of the present application also provides a pedestrian clothing recognition method based on an improved YOLOv8 model, which is described with reference to Figure 1 , Figure 1 The flowchart of the first embodiment of the pedestrian clothing recognition method based on the improved YOLOv8 model of the present application is shown in the figure. In this embodiment, the pedestrian clothing recognition method based on the improved YOLOv8 model includes steps S10-S30:
[0065] Step S10, obtaining pedestrian image data.
[0066] It should be noted that the original pedestrian image data is first collected through cameras arranged in the card mouth, cell, public area, all-weather, multi-angle. These devices can cover various scenes in the city, from bustling commercial streets to residential areas, to traffic arteries, ensuring the diversity and representativeness of the data. When obtaining portrait image data, considering the interference of different environmental conditions such as light changes, weather conditions (rainy days, foggy days, etc.), and background complexity, image processing techniques need to be used to enhance the quality of the data. For example, using the DehazeNet pre-training model can effectively solve the influence of bad weather conditions such as fog and haze on image clarity, thereby improving the visibility of pedestrian features in the image.
[0067] Step S20, pre-processing the image data to obtain processed image data.
[0068] It should be noted that the original collected pedestrian image data contains noise, uneven lighting, scale changes and other problems. If these problems are not handled, they will interfere with the learning process of the model and reduce the recognition accuracy. Therefore, before training any deep learning model, a series of preprocessing operations need to be performed on these image data.
[0069] Further, step S20 further includes: performing preliminary noise reduction on the image data by median filtering to obtain first noise-reduced image data. Specifically, median filtering is an effective nonlinear noise reduction technique, especially suitable for removing randomly occurring black and white point noise in images. Its basic principle is to smooth the image by replacing the value of each pixel point with the median of all pixel values in its neighborhood, thereby effectively suppressing noise while preserving edge information. In specific implementation, for each pixel position, a window of appropriate size (such as 3x3 or 5x5) is selected to cover it, then the median of all pixel values in the window is calculated, and this median value is used to replace the original value of the central pixel. This method can effectively protect the boundaries and detail features of the image from being damaged, because median filtering will not blur the image edges like mean filtering. In addition, according to the different levels of image noise, the size of the filtering window can be flexibly adjusted to achieve the best noise reduction effect.
[0070] Next, the first denoised image data is subjected to secondary denoising through Gaussian filtering to obtain second denoised image data. Specifically, Gaussian filtering is a linear smoothing filtering technique based on Gaussian function, which can effectively remove Gaussian noise in the image while preserving important features and details of the image as much as possible. For each pixel position, the average value of all pixel values in its neighborhood is calculated according to the Gaussian distribution weighting, and this value is used to replace the original pixel value. In this way, not only can random noise in the image be effectively reduced, but also the artifacts or unnecessary edge roughness that may be introduced by the first median filtering can be alleviated to some extent. It is worth noting that reasonable adjustment of the parameters of Gaussian filtering is crucial, and too strong filtering may lead to loss of image details, while too weak filtering cannot achieve the desired denoising effect.
[0071] Then, the second denoised image data is subjected to normalization processing to obtain normalized image data. Normalization refers to scaling the image pixel values to a specific range (usually between 0 and 1), which helps to speed up the convergence speed of the neural network and improve the stability of the model training. Specifically, normalization processing involves linear transformation of the gray value or RGB channel value of each pixel point to adapt to the specified numerical range. For most deep learning frameworks, scaling the pixel value to the [0, 1] interval is a common practice, which can be achieved by simply dividing by 255 (assuming the original pixel value range is [0, 255]). In addition, in some cases, more complex normalization strategies may be used, such as standardization processing according to the mean and standard deviation of the entire data set, so that the input data has zero mean and unit variance. Normalized image data not only reduces the differences between different images caused by factors such as lighting conditions and shooting devices, but also helps to improve the YOLOv8 model to converge better, especially in tasks involving color feature extraction.
[0072] Finally, a region-of-interest (ROI) method is used to crop key regions from the normalized image data to obtain processed image data. The region-of-interest (ROI) method crops the most valuable portion of a person—in this case, the pedestrian and their clothing information—to reduce interference from background noise and other irrelevant information. Specifically, determining the region of interest (ROI) involves identifying and locating the area within the image where the pedestrian resides. This can be achieved through methods such as a pre-trained object detection model or simple threshold segmentation. Once the pedestrian's approximate location is determined, the selection can be further refined to ensure that the cropped region encompasses both the complete pedestrian outline and sufficient contextual information for more accurate clothing attribute recognition. For example, appropriately expanding the cropping boundary can ensure that as much relevant detail as possible is captured, even when the pedestrian is in motion or partially occluded. For each resulting ROI, additional preprocessing steps can be applied, such as resizing to meet model input requirements, contrast enhancement, or brightness adjustment, to further optimize data quality. It is worth noting that reasonable cropping and scaling not only helps improve computational efficiency, but also avoids unnecessary computational overhead, which is especially important when processing large-scale video streams or real-time monitoring data.
[0073] The processed image data obtained through the above processing has reduced background noise and focuses on the key features of pedestrian clothing, which makes it easy to obtain accurate output values for improving the YOLOv8 model.
[0074] In step S30 , the processed image data is input into a preset clothing recognition model for recognition to obtain a clothing recognition result.
[0075] It should be noted that if Figure 2As shown in the improved YOLOv8 model structure diagram, the improved YOLOv8 model comprises a backbone network layer, a feature fusion layer and a detection head. The backbone network layer is composed of a CSPDarknet53 architecture, a coordinate attention module, an SCConv module and a Focus module. The CSPDarknet53 architecture is composed of a first C2f module and a max pooling layer in series. The coordinate attention module is inserted into the first preset sublayer, the second preset sublayer and the third preset sublayer of the backbone network layer. In this embodiment, the coordinate attention module is inserted after the 3rd, 6th and 9th layers of the backbone network layer, which helps to enhance the position-sensitive features and further improve the capture effect of detailed features. The first C2f module comprises two Bottleneck layers, each of which is composed of a first convolution and a second convolution. Specifically, each layer is composed of a 1x1 convolution and a 3x3 convolution, and the activation function is a SiLU function. The Focus module is composed of a third convolution, specifically a 6x6 convolution. The SCConv module improves the extraction ability of color features, so that the model can more accurately identify the color information of the portrait clothing. Secondly, the feature fusion layer is composed of a PAN-FPN structure and a second C2f module. The PAN-FPN structure and the second C2f module are both bidirectional cross-layer connections. The PAN-FPN structure comprises a bidirectional cross-layer connection, the up-sampling uses nearest neighbor interpolation, and the down-sampling uses a 3x3 convolution (step 2), and the activation function is SiLU. This design can preserve multi-scale features while improving computational efficiency. The application of the second C2f module further enhances the feature fusion effect, especially in small-scale clothing detection. A lightweight SE attention module is added after the up-sampling path of the PAN-FPN, and an RFE (receptive field enhancement) module is added to the down-sampling path. These improvements improve the adaptability and detection accuracy of the model for different scale targets. Finally, the detection head is used for target detection and classification. The detection head is divided into a classification branch and a regression branch. Both the classification branch and the regression branch are one-dimensional convolutions. The classification branch also includes a color classification branch and a style classification branch. The detection head is divided into a classification branch and a regression branch, both of which are one-dimensional convolutions. The classification branch involves a 1x1 convolution and a Softmax operation, and is responsible for identifying the clothing category of the pedestrian; the regression branch is realized through a 1x1 convolution and a DFL loss, and is used for accurate positioning of the target position. In order to further refine the recognition result, the classification branch also includes a color classification branch (realized by three layers of MLP) and a style classification branch (realized by a double-path CNN). A GAM (global attention mechanism) module is inserted before the regression branch to optimize the positioning accuracy and ensure that the model can accurately identify and locate the specific details of the pedestrian and his clothing.
[0076] Specifically, the preprocessed image data is fed into the model to extract detailed information about the clothing worn by pedestrians. The improved YOLOv8 model can efficiently capture and analyze key features in images through its optimized backbone network layer, feature fusion layer, and detection head. First, the image data enters the backbone network layer, which enhances the extraction of clothing details and color features, obtaining clothing features. Then, in the feature fusion layer, the clothing features are combined with SE attention and RFE modules to further enhance the fusion of multi-scale features, obtaining fused features. Finally, the fused features reach the detection head part, which not only performs traditional classification and regression tasks, but also adds special color classification branches and style classification branches to ensure fine-grained identification of clothing types, colors, and styles. The clothing recognition results output by the model cover comprehensive information from basic clothing categories to specific colors and styles.
[0077] The embodiment obtains and preprocesses pedestrian image data to generate high-quality input data through preprocessing. Then, the improved YOLOv8 model is used for recognition, which includes three core parts: the backbone network layer is responsible for feature extraction; the feature fusion layer is used for multi-scale feature fusion; and the detection head is divided into classification branches and regression branches, with additional color and style classification branches, achieving accurate identification of clothing types, colors, and styles, and improving the accuracy of pedestrian clothing recognition in complex scenarios.
[0078] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as the above-mentioned first embodiment can be referred to the above introduction, and the following will not be repeated. On this basis, please refer to Figure 3 , the pedestrian clothing recognition method based on the improved YOLOv8 model further includes steps S201-S204 before step S30:
[0079] Step S201, obtaining historical image data.
[0080] It should be noted that historical image data can be obtained from various sources, such as traffic monitoring cameras, community security systems, public area monitoring, etc. First, a large number of past pedestrian images are collected through devices such as card mouth cameras, community cameras, and public area cameras. These images not only cover various pedestrians, but also are taken under different time, weather conditions, and lighting conditions, providing rich training materials for the model.
[0081] Step S202, labeling the historical image data to generate a training set and a test set.
[0082] It should be noted that a large number of historical images collected from various monitoring devices are meticulously labeled using professional labeling tools. The labeling process includes accurately circumscribing the clothing of pedestrians in each picture and assigning the correct label to each sign, and then after completing the labeling, the dataset is divided into training set and test set according to a certain proportion.
[0083] Specifically, this process is completed using professional software such as labelme, which allows users to intuitively mark the specific details of pedestrians and their clothing in each picture. During the labeling process, detailed records of the clothing information of pedestrians are required, including but not limited to the color (such as red, black), type (such as short sleeve, long sleeve), brand (such as Nike, Adidas) of the clothes, as well as related attributes of shoes and pants. In order to ensure the quality and diversity of the dataset, images under various environmental conditions should be covered, such as different weather conditions, lighting conditions, etc. After labeling, the dataset is divided into training set and test set according to a certain proportion, so as to be used for subsequent model training and verification. In this implementation, the proportion of the training set is 80%, and the proportion of the test set is 20%.
[0084] Step S203, constructing an initial clothing recognition model.
[0085] Step S204, training the initial clothing recognition model using the training set to obtain a preset clothing recognition model.
[0086] It should be noted that before starting the training, the prepared training set needs to be imported into the training environment. The training set contains image data that has been labeled, size transformed, denoised, and normalized. This process first involves inputting the labeled training set into the initial model based on the improved YOLOv8, and through a series of iterative optimization, the model learns to represent various features of pedestrian clothing.
[0087] Further, step S204 includes initializing the weight and bias parameters of the initial clothing recognition model. Then, the image data in the training set is input into the initial clothing recognition model for calculation to obtain a predicted bounding box and a category probability. Specifically, the input image is processed by the feature extraction network (such as MobileNetV3 inverse residual unit) of the model based on the image data to generate a series of feature maps. Then, the bounding box and the corresponding category probability are predicted using the feature maps. Specifically, each predicted bounding box consists of position information (x, y, w, h) and a confidence score, where (x, y) represents the position of the target center point, and (w, h) represents the width and height of the bounding box; the category probability is the predicted probability distribution of each possible style category or color category. Then, the loss of the predicted bounding box and the labeled box and the cross-entropy loss of the category probability and the real category label are calculated according to the loss function to obtain a total loss value, the labeled box is calculated by an external matrix, and the real category label is obtained by a preset encoding table. Specifically, in order to evaluate the quality of the model prediction results, a suitable loss function needs to be defined. Here, two parts of the loss are involved: one is the loss between the predicted bounding box and the labeled box, and the other is the cross-entropy loss between the predicted category probability and the real category label. The loss of the predicted bounding box is usually measured by mean square error (MSE) or IoU loss, and in this embodiment, mean square error is selected for loss determination, and the specific formula is:
[0088]
[0089] wherein is the position information of the real labeled box, is the position information of the predicted bounding box. For the classification task, the cross-entropy loss is used to quantify the difference between a cluster of category probabilities and the real label, and the specific formula is:
[0090]
[0091] wherein is the probability distribution of the real category label (usually one-hot encoding), is the predicted category probability. Based on the above loss value, the total loss value is wherein and are balance coefficients. The gradients of the weight and bias parameters are calculated by the back propagation algorithm, the gradients of each weight and bias parameter are calculated by the back propagation algorithm, and the optimization algorithm (such as SGD, Adam, etc.) is used to update these parameters according to the gradients, and the goal of the optimization algorithm is to minimize the total loss value. Finally, the weight and bias parameters are iteratively updated by the optimization algorithm according to the gradients until the maximum number of iterations is reached or the total loss value converges to a preset threshold, and a preset clothing recognition model is obtained.
[0092] Further, after step S204, the method further comprises: verifying the preset clothing recognition model by using a test set to obtain a verification result, the verification result comprising an identification accuracy, a missed detection rate and a false detection rate; judging according to the verification result and a preset performance requirement to obtain a judgment result, the preset performance requirement being an accuracy threshold, a missed detection rate threshold and a false detection rate threshold; when the judgment result is that the verification result does not meet the preset performance requirement, retraining the preset clothing recognition model by using the training set until the verification result meets the preset performance requirement and outputting the preset clothing recognition model. Specifically, after the model training is completed, the preset clothing recognition model must be verified by using the test set to evaluate whether the performance meets the actual application requirements. The verification process mainly includes three core indicators: the identification accuracy, the missed detection rate and the false detection rate. The identification accuracy reflects the ability of the model to correctly identify the clothing of pedestrians and is an important standard for measuring the overall recognition effect; the missed detection rate is used to evaluate the proportion of the model that fails to detect when facing target objects, which is particularly important for pedestrian clothing recognition in complex backgrounds or small targets; and the false detection rate reflects the frequency of the model incorrectly identifying as pedestrians in non-target areas, which directly affects the stability and practicality of the system. In the verification process, the images in the test set are input into the trained preset clothing recognition model, the model outputs the corresponding detection results, including the position of each detected pedestrian and the predicted clothing category of the pedestrian. Then, the prediction results are compared with the manual annotation information in the test set, the number of accurate recognition, missed detection and false detection is counted, and the specific values of the three indicators are calculated accordingly. Next, the obtained verification result is compared with the preset performance requirement. The performance requirement usually includes: the identification accuracy needs to reach a certain minimum threshold (such as 95%), the missed detection rate needs to be controlled within a certain range (such as less than 5%), and the false detection rate needs to be less than a certain upper limit (such as less than 3%). If any of the verification results does not meet the preset threshold, it is determined that the current model performance is not up to standard. At this time, the model optimization mechanism is automatically triggered, and the training set is used to retrain the current model. In the retraining process, the learning rate can be adjusted, the training rounds can be increased, stronger data enhancement strategies can be introduced, or the loss function weight can be optimized to improve the model performance. After training, the test set is used for verification again, and the process is repeated until all performance indicators meet the preset requirements.
[0093] The embodiment improves the accuracy and robustness of pedestrian clothing recognition by obtaining and labeling historical image data to generate a training set and a test set, constructing an initial clothing recognition model, and using the training set to train the model to obtain a preset clothing recognition model.
[0094] Based on the first embodiment of the present application, in the third embodiment of the present application, the same or similar contents as the above embodiment one can refer to the above introduction, and will not be described in detail. On this basis, please refer to Figure 4The pedestrian clothing recognition step S30 based on the improved YOLOv8 model further includes steps S301-S303.
[0095] In step S301, the processed image data is subjected to feature extraction by a backbone network layer to obtain clothing features.
[0096] It should be noted that the backbone network layer is a core component of the model, responsible for extracting high-level features from the input image that are helpful for subsequent classification and detection tasks. In this process, the processed image data first passes through a series of carefully designed modules, including the CSPDarknet53 architecture, the coordinate attention module, the SCConv module, and the Focus module.
[0097] Further, the step S301 includes: performing slice operation on the processed image data by the Focus module, and performing feature extraction using a third convolution to obtain an initial feature map. Specifically, the processed image data is first split into four parts according to the spatial dimension and spliced along the channel dimension by the Focus module, to form a tensor with 2 times down-sampling and 4 times channel number, and then a third convolution with a size of 6x6, a stride of 2 and an output channel of 64 is used for feature extraction to obtain an initial feature map which retains the original details and is compressed in dimension. Then, the initial feature map is input into the CSPDarknet53 architecture to perform feature extraction by a first Bottleneck layer of the first C2f module to obtain a first intermediate feature map, wherein the first Bottleneck layer performs feature extraction by feature transformation through a first convolution and a second convolution in sequence. Specifically, the initial feature map is input into the CSPDarknet53 architecture, first passed through a 1x1 first convolution for dimension reduction, and then input into the first Bottleneck layer of the C2f module, which internally performs a 1x1 first convolution for channel compression, a 3x3 second convolution for local texture extraction, and then adds the input through a residual connection to output a first intermediate feature map rich in fine-grained textures such as sleeves and collars. Then, the first intermediate feature map is input into the coordinate attention module to be strengthened by a position-sensitive feature enhancement mechanism to obtain a second intermediate feature map. Specifically, the first intermediate feature map is input into the coordinate attention module, which performs global average pooling along the horizontal and vertical directions to generate a position encoding vector, which is multiplied with the original feature through a 1x1 convolution and a Sigmoid activation to realize position-sensitive feature enhancement and obtain a second intermediate feature map highlighting the spatial relationship of key regions. Then, the second intermediate feature map is input into the CSPDarknet53 architecture to perform feature extraction by a second Bottleneck layer of the first C2f module to obtain a third intermediate feature map, wherein the second Bottleneck layer performs feature extraction by feature transformation through a first convolution and a second convolution in sequence. Specifically, the second intermediate feature map is again input into the second Bottleneck layer of the C2f module of the CSPDarknet53 architecture to repeat the residual transformation of the 1x1 first convolution and the 3x3 second convolution, further refining detail features such as pant seams and shoe surfaces, and outputting a third intermediate feature map. Then, the third intermediate feature map is sequentially input into a preset number of maximum pooling layers for multi-scale feature fusion to obtain a fourth intermediate feature map. Specifically, the third intermediate feature map is sequentially input into three 5x5 maximum pooling layers in series, each with a stride of 1, to gradually expand the receptive field and fuse multi-scale context information, and obtain a fourth intermediate feature map that aggregates local and global information.Finally, the fourth intermediate feature map is input into the SCConv module for fast spatial pyramid pooling processing to obtain the clothing feature. Specifically, the fourth intermediate feature map is input into the SCConv module, spatial convolution is first used to capture the correlation between channels, then channel convolution is used to integrate spatial features, and finally multi-scale fusion is completed through fast spatial pyramid pooling, and a clothing feature with unified dimension, rich details, and high sensitivity to color and texture is output, providing a reliable basis for subsequent classification and positioning.
[0098] In step S302, the clothing feature is subjected to multi-scale fusion through the feature fusion layer to obtain a fused feature.
[0099] It should be noted that the feature fusion layer aims to integrate feature maps from different depths and resolutions to capture more comprehensive target information. This process usually includes upsampling, downsampling, and element-wise addition or splicing operations.
[0100] Further, the step S302 comprises: performing down-sampling processing on the clothing feature through a first down-sampling path of the PAN-FPN structure to obtain a first down-sampled feature. Specifically, the first down-sampling path of the PAN-FPN structure is used to perform 3x3 convolution with a step size of 2 on the clothing feature, to reduce the spatial size by half and simultaneously increase the channel dimension, so as to obtain the first down-sampled feature which retains the edge and contour details. Then, the first down-sampled feature is sequentially subjected to the first convolution and the second convolution of the second C2f module to obtain a first cross-stage feature. Specifically, the first down-sampled feature is input into the second C2f module, and then the 1x1 first convolution is performed to compress the channel and reduce the redundant parameters, and then the 3x3 second convolution is performed to expand the receptive field while capturing the local spatial relationship such as the trousers wrinkle and the shoe surface texture, and finally the compressed feature is fused with the original feature through the residual connection to output the first cross-stage feature which is rich in semantics and details. Next, the first cross-stage feature is subjected to up-sampling processing through the first up-sampling path of the PAN-FPN structure to obtain a first up-sampled feature. Specifically, the first up-sampling path of the PAN-FPN structure is used to perform 2 times up-sampling on the first cross-stage feature by using the nearest neighbor interpolation method, to restore the spatial resolution and introduce the high-level semantics, so as to obtain the first up-sampled feature which is consistent with the original clothing feature in size, thereby bridging the information gap between the deep and shallow layers. Then, the first up-sampled feature is processed through the second cross-stage part of the second C2f module to obtain a second cross-stage feature. Specifically, the second cross-stage part of the C2f module is used to perform cross-stage part connection on the first up-sampled feature: first, the 1x1 convolution is performed to split the feature, which is then input into two Bottleneck branches for deep feature extraction, and then the feature is fused through the 1x1 convolution after being spliced with the main path feature, so as to obtain the second cross-stage feature which takes into account the color consistency and texture integrity. Finally, the second cross-stage feature is subjected to down-sampling processing through the second down-sampling path of the PAN-FPN structure to obtain a second down-sampled feature, and then the second down-sampled feature is spliced with the clothing feature to obtain a fusion feature. Specifically, the second cross-stage feature is subjected to 3x3 convolution with a step size of 2 through the second down-sampling path of the PAN-FPN structure, to reduce the feature size by half and increase the channel dimension, so as to generate the second down-sampled feature which carries context information and suppresses background noise. Then, the second down-sampled feature is spliced with the clothing feature in the channel dimension to form the fusion feature which integrates high-resolution details, medium-resolution textures and low-resolution semantics, thereby providing the subsequent detection head with multi-scale representation which has both positioning accuracy and semantic discriminability, and significantly improving the recognition accuracy of clothing categories, colors and styles in complex scenes.
[0101] In step S303, the fusion feature is classified and regressed by the detection head to obtain a clothing recognition result.
[0102] It should be noted that the detection head is usually composed of two main parts: the classification branch and the regression branch. The classification branch is responsible for determining the class of the object within each detection box (e.g., clothing type, color, etc.), while the regression branch focuses on adjusting the position and size of the detection box to more accurately enclose the target object.
[0103] Further, step S303 includes: performing preliminary feature transformation on the fusion features by the detection head to obtain initial detection features. Specifically, the detection head performs preliminary feature transformation on the fusion features: first, using 1x1 convolution to unify the channel dimension to a preset value (e.g., 256), and then performing batch normalization and SiLU activation to obtain high expression initial detection features while maintaining gradient stability. Then, the initial detection features are enhanced by a global attention mechanism module to obtain enhanced detection features. Specifically, the initial detection features are input into the global attention mechanism module, which first performs global average pooling along the channel dimension to capture global color distribution and style statistics, then compresses them through 1x1 convolution and generates spatial-channel joint weights through Sigmoid, and finally multiplies the weights with the original features element by element to realize global context enhancement, outputting enhanced detection features with prominent details and consistent semantics. Next, the enhanced detection features are input into the classification branch and the regression branch respectively to obtain class probability distribution and target position information. The class probability distribution is obtained based on color categories and style categories. Specifically, the enhanced detection features are parallelly input into a decoupled three-branch: the classification branch outputs color category probability distribution (red, blue, black, etc.) and style category probability distribution (wind coat, jeans, sports shoes, etc.) through 1x1 convolution + Softmax, and the regression branch outputs center point offset and width-height offset through 1x1 convolution + DFL loss to obtain target position information. Finally, the class probability distribution and the target position information are fused to obtain clothing detection results, and the non-maximum suppression algorithm is used to process the clothing detection results to obtain clothing recognition results. Specifically, the color category probability distribution, the style category probability distribution, and the target position information are fused: first, the three types of outputs are concatenated in the channel dimension, then a weighted fusion layer is used to generate a comprehensive score according to a confidence threshold (0.5) to form clothing detection results containing "color-style-box" triplets, and finally the non-maximum suppression algorithm is used to process the clothing detection results: the overlapping boxes are filtered out with an IoU threshold (0.45), and the candidate box with the highest confidence is retained, and finally the structured clothing recognition results are output, including attributes such as "navy-wind coat", "light blue-jeans", and "white-sports shoes" and corresponding pixel-level bounding boxes, achieving millisecond-level accurate analysis of single-frame images.
[0104] The embodiment fuses the clothing features through the feature fusion layer, integrates feature maps of different depths to capture comprehensive target information, and generates fused features. Then, the detection head is used to classify and regress the fused features, so as to realize accurate identification of the clothing of the pedestrian, including detailed information such as clothing type, color and style, improve the accuracy and granularity of clothing identification, and enhance the robustness and adaptability of the model in complex scenes.
[0105] Based on the first embodiment of the present application, the present application also provides a pedestrian clothing identification device based on an improved YOLOv8 model, please refer to Figure 5 , the device comprises:
[0106] The acquisition module 10 is configured to acquire pedestrian image data.
[0107] The processing module 20 is configured to pre-process the image data to obtain processed image data.
[0108] The result module 30 is configured to input the processed image data into a preset clothing identification model for identification to obtain a clothing identification result. The preset clothing identification model is an improved YOLOv8 model. The improved YOLOv8 model comprises a backbone network layer, a feature fusion layer and a detection head. The backbone network layer is composed of a CSPDarknet53 architecture, a coordinate attention module, an SCConv module and a Focus module. The CSPDarknet53 architecture is composed of a first C2f module and a max pooling layer in series. The coordinate attention module is inserted into a first preset sublayer, a second preset sublayer and a third preset sublayer of the backbone network layer. The first C2f module comprises two Bottleneck layers, each of which is composed of a first convolution and a second convolution. The Focus module is composed of a third convolution. The feature fusion layer is composed of a PAN-FPN structure and a second C2f module. The PAN-FPN structure and the second C2f module are both bidirectional cross-layer connections. The detection head is configured to perform target detection and classification. The detection head is divided into a classification branch and a regression branch. Both the classification branch and the regression branch are one-dimensional convolutions. The classification branch further comprises a color classification branch and a style classification branch.
[0109] The pedestrian clothing identification device based on the improved YOLOv8 model provided by the present application adopts the pedestrian clothing identification method based on the improved YOLOv8 model in the above embodiment, which can solve the technical problem of how to improve the accuracy of pedestrian clothing identification in complex scenes. Compared with the prior art, the pedestrian clothing identification device based on the improved YOLOv8 model provided by the present application has the same beneficial effects as the pedestrian clothing identification method based on the improved YOLOv8 model provided by the above embodiment, and other technical features in the pedestrian clothing identification device based on the improved YOLOv8 model are the same as the features disclosed in the above embodiment method. Therefore, no further description is given here.
[0110] In an embodiment, the processing module 20 is further configured to perform feature extraction on the processed image data through a backbone network layer to obtain clothing features, perform multi-scale fusion on the clothing features through a feature fusion layer to obtain fused features, and perform classification and regression on the fused features through a detection head to obtain clothing recognition results.
[0111] In an embodiment, the processing module 20 is further configured to perform slicing on the processed image data through a Focus module and perform feature extraction using a third convolution to obtain an initial feature map, input the initial feature map into a CSPDarknet53 architecture through a first Bottleneck layer of a C2f module to perform feature extraction and obtain a first intermediate feature map, wherein the first Bottleneck layer performs feature extraction through feature transformation by a first convolution and a second convolution in sequence, input the first intermediate feature map into a coordinate attention module to perform strengthening through a location-sensitive feature enhancement mechanism to obtain a second intermediate feature map, input the second intermediate feature map into the CSPDarknet53 architecture through a second Bottleneck layer of the C2f module to perform feature extraction and obtain a third intermediate feature map, wherein the second Bottleneck layer performs feature extraction through feature transformation by a first convolution and a second convolution in sequence, sequentially perform multi-scale feature fusion on the third intermediate feature map through a preset number of max-pooling layers to obtain a fourth intermediate feature map, and input the fourth intermediate feature map into an SCConv module to perform fast spatial pyramid pooling processing to obtain clothing features.
[0112] In an embodiment, the processing module 20 is further configured to perform down-sampling processing on the clothing features through a first down-sampling path of a PAN-FPN structure to obtain first down-sampling features, sequentially perform operations on the first down-sampling features through a first convolution and a second convolution of a C2f module to obtain first cross-stage features, perform up-sampling processing on the first cross-stage features using a nearest neighbor interpolation method through a first up-sampling path of the PAN-FPN structure to obtain first up-sampling features, perform processing on the first up-sampling features through a second cross-stage part of the C2f module to obtain second cross-stage features, perform down-sampling processing on the second cross-stage features through a second down-sampling path of the PAN-FPN structure to obtain second down-sampling features, and splice the second down-sampling features with the clothing features to obtain fused features.
[0113] In an embodiment, the processing module 20 is further configured to perform preliminary feature transformation on the fusion features by the detection head to obtain initial detection features; perform feature enhancement on the initial detection features by a global attention mechanism module to obtain enhanced detection features; input the enhanced detection features into a classification branch and a regression branch respectively to obtain a class probability distribution and target position information, wherein the class probability distribution is obtained based on color categories and style categories; perform fusion processing on the class probability distribution and the target position information to obtain clothing detection results; and perform processing on the clothing detection results by a non-maximum suppression algorithm to obtain clothing recognition results.
[0114] In an embodiment, the processing module 20 is further configured to obtain historical image data; label the historical image data to generate a training set and a test set; construct an initial clothing recognition model; and train the clothing recognition model using the training set to obtain a preset clothing recognition model.
[0115] In an embodiment, the processing module 20 is further configured to initialize weight and bias parameters of the initial clothing recognition model; input image data in the training set into the initial clothing recognition model to obtain predicted positions and class probabilities; calculate an error between the predicted positions and real positions according to a first loss function to obtain a distribution focal loss, wherein the real positions are calculated according to an external matrix; calculate a cross-entropy loss between the class probabilities and real class labels according to a second loss function to obtain a class probability loss, wherein the real class labels are obtained by a preset encoding table; process the distribution focal loss and the class probability loss to obtain a total error value; calculate gradients of the weight and bias parameters by a back propagation algorithm; and update the weight and bias parameters by an optimization algorithm according to the gradients until a maximum iteration number is reached or the total error value converges to a preset threshold, thereby obtaining the preset clothing recognition model.
[0116] The present application provides a pedestrian clothing recognition device based on an improved YOLOv8 model, which comprises at least one processor and a memory in communication connection with the at least one processor. The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the pedestrian clothing recognition method based on the improved YOLOv8 model in the above-mentioned embodiment one.
[0117] Reference will be made to the following Figure 6, which shows a schematic structural diagram of a pedestrian clothing recognition device based on an improved YOLOv8 model suitable for implementing embodiments of the present application. The pedestrian clothing recognition device based on the improved YOLOv8 model in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The pedestrian clothing recognition device based on the improved YOLOv8 model shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0118] like Figure 6 As shown, a pedestrian clothing recognition device based on an improved YOLOv8 model may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in a read-only memory (ROM) 1002 or programs loaded from a storage device 1003 into a random access memory (RAM) 1004. RAM 1004 also stores various programs and data required for the operation of the pedestrian clothing recognition device based on the improved YOLOv8 model. Processing device 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, hard disk, etc.; and communication devices 1009. Communication devices 1009 can allow the pedestrian clothing recognition device based on the improved YOLOv8 model to communicate wirelessly or wired with other devices to exchange data. Although various pedestrian clothing recognition devices based on the improved YOLOv8 model are shown in the figure, it should be understood that not all of the illustrated devices are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
[0119] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product comprising a computer program carried on a computer readable storage medium, the computer program containing program code for executing the method shown in the flowchart. In such embodiments, the computer program can be downloaded and installed from a network through a communication device, or installed from the storage device 1003, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiments disclosed in the present application are executed.
[0120] The pedestrian clothing recognition device based on the improved YOLOv8 model provided by the present application adopts the pedestrian clothing recognition method based on the improved YOLOv8 model in the above-mentioned embodiments, which can solve the technical problem of how to improve the accuracy of pedestrian clothing recognition in complex scenes. Compared with the prior art, the pedestrian clothing recognition device based on the improved YOLOv8 model provided by the present application has the same beneficial effects as the pedestrian clothing recognition method based on the improved YOLOv8 model provided by the above-mentioned embodiments, and other technical features in the pedestrian clothing recognition device based on the improved YOLOv8 model are the same as the features disclosed in the previous embodiment method, which will not be repeated here.
[0121] It should be understood that parts of the present application can be realized by hardware, software, firmware or a combination thereof. In the description of the above-mentioned embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0122] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
[0123] The present application provides a computer readable storage medium having stored thereon computer readable program instructions (i.e. computer program) for executing the pedestrian clothing recognition method based on the improved YOLOv8 model in the above-mentioned embodiments.
[0124] The computer readable storage medium provided in the present application may, for example, be a U disk, but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor, or device, or any combination of the above. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more conductive wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present embodiment, the computer readable storage medium can be any tangible storage medium containing or storing a program that can be executed by or used in conjunction with an instruction execution device. The program code contained on the computer readable storage medium can be transmitted in any suitable storage medium, including but not limited to an electrical wire, an optical cable, an RF (Radio Frequency), and the like, or any suitable combination of the above.
[0125] The above computer readable storage medium can be contained in the pedestrian clothing recognition device based on the improved YOLOv8 model; or can exist independently without being assembled into the pedestrian clothing recognition device based on the improved YOLOv8 model.
[0126] The above computer readable storage medium carries one or more programs, which, when executed by the pedestrian clothing recognition device based on the improved YOLOv8 model, enable the pedestrian clothing recognition device based on the improved YOLOv8 model to write computer program codes in one or more programming languages or combinations thereof for executing the operations of the present application. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" language or similar programming languages. The program code can be executed entirely on a user computer, partially on a user computer, as a separate software package, partially on a user computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user computer through any kind of network, including a LAN (Local Area Network) or a WAN (Wide Area Network), or can be connected to an external computer (for example, through the Internet using an Internet service provider).
[0127] The flow and block diagrams in the drawings show possible architectural, functional, and operational scenarios of methods and computer program products according to various embodiments of the present application. In this regard, each block can represent a module, a segment, or a portion of code which comprises one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and / or flowchart illustrations, and combinations thereof, can be implemented by special purpose hardware-based systems which perform the specified functions or operations, or combinations of special purpose hardware and computer instructions.
[0128] The modules involved in the embodiments of the present application can be implemented in software or in hardware. In some cases, the name of the module does not constitute a limitation on the unit itself.
[0129] The readable storage medium provided by the present application is a computer readable storage medium, which stores computer readable program instructions (i.e. computer program) for executing the pedestrian clothing recognition method based on the improved YOLOv8 model described above, and can solve the technical problem of how to improve the accuracy of pedestrian clothing recognition in complex scenes. Compared with the prior art, the computer readable storage medium provided by the present application has the same beneficial effects as the pedestrian clothing recognition method based on the improved YOLOv8 model provided by the above embodiments, and will not be repeated here.
[0130] The present application also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the pedestrian clothing recognition method based on the improved YOLOv8 model as described above.
[0131] The computer program product provided by the present application can solve the technical problem of how to improve the accuracy of pedestrian clothing recognition in complex scenes. Compared with the prior art, the computer program product provided by the present application has the same beneficial effects as the pedestrian clothing recognition method based on the improved YOLOv8 model provided by the above embodiments, and will not be repeated here.
[0132] The above merely describes some embodiments of the present application, and does not limit the patent scope of the present application. Any equivalent structural transformation, direct / indirect application in other related technical fields, or the like, which is made based on the technical concept of the present application and the content of the specification and drawings, is included in the patent protection scope of the present application.
Claims
1. A pedestrian clothing recognition method based on an improved YOLOv8 model, characterized in that: include: Obtain pedestrian image data; Preprocessing the image data to obtain processed image data; The processed image data is input into a preset clothing recognition model for recognition to obtain a clothing recognition result. The preset clothing recognition model is an improved YOLOv8 model. The improved YOLOv8 model includes a backbone network layer, a feature fusion layer and a detection head. The backbone network layer is composed of a CSPDarknet53 architecture, a coordinate attention module, an SCConv module and a Focus module. The CSPDarknet53 architecture is composed of a first C2f module and a maximum pooling layer in series. The coordinate attention module is inserted into the first preset sublayer, the first sublayer and the second sublayer of the backbone network layer. Two preset sublayers and a third preset sublayer, the first C2f module includes two Bottleneck layers, each layer consists of a first convolution and a second convolution, and the Focus module consists of a third convolution; the feature fusion layer is composed of a PAN-FPN structure and a second C2f module, and the PAN-FPN structure and the second C2f module are both bidirectional cross-layer connections; the detection head is used for target detection and classification, and the detection head is divided into a classification branch and a regression branch, and the classification branch and the regression branch are both one-dimensional convolutions, and the classification branch also includes a color classification branch and a style classification branch.
2. The method according to claim 1, wherein The step of inputting the processed image data into a preset clothing recognition model for recognition to obtain a clothing recognition result includes: Performing feature extraction on the processed image data through the backbone network layer to obtain clothing features; Performing multi-scale fusion on the clothing features through the feature fusion layer to obtain fusion features; The detection head classifies and regresses the fused features to obtain clothing recognition results.
3. The method according to claim 2, wherein The step of extracting features from the processed image data through the backbone network layer to obtain clothing features includes: Slicing the processed image data through the Focus module and performing feature extraction using the third convolution to obtain an initial feature map; Input the initial feature map into the CSPDarknet53 architecture and perform feature extraction through the first Bottleneck layer of the first C2f module to obtain a first intermediate feature map, wherein the first Bottleneck layer performs feature transformation and feature extraction through the first convolution and the second convolution in sequence; Input the first intermediate feature map into the coordinate attention module and enhance it through the position-sensitive feature enhancement mechanism to obtain the second intermediate feature map; Input the second intermediate feature map into the CSPDarknet53 architecture and perform feature extraction through the second Bottleneck layer of the first C2f module to obtain a third intermediate feature map, wherein the second Bottleneck layer performs feature transformation and feature extraction through the first convolution and the second convolution in sequence; Passing the third intermediate feature map through a preset number of maximum pooling layers in sequence to perform multi-scale feature fusion to obtain a fourth intermediate feature map; The fourth intermediate feature map is input into the SCConv module for fast spatial pyramid pooling processing to obtain clothing features.
4. The method according to claim 2, wherein The step of performing multi-scale fusion on the clothing features through the feature fusion layer to obtain fusion features includes: Downsampling the clothing feature through a first downsampling path of a PAN-FPN structure to obtain a first downsampling feature; The first down-sampled features are sequentially subjected to a first convolution and a second convolution of a second C2f module to obtain a first cross-stage feature; Upsampling the first cross-stage feature using a nearest neighbor interpolation method through a first upsampling path of the PAN-FPN structure to obtain a first upsampled feature; Processing the first upsampled features by a second cross-stage part of a second C2f module to obtain a second cross-stage feature; Downsampling the second cross-stage feature through a second downsampling path of the PAN-FPN structure to obtain a second downsampled feature; The second down-sampled feature is concatenated with the clothing feature to obtain a fused feature.
5. The method according to claim 2, wherein The step of classifying and regressing the fused features by the detection head to obtain clothing recognition results includes: Performing preliminary feature transformation on the fusion feature by the detection head to obtain an initial detection feature; Performing feature enhancement on the initial detection feature through a global attention mechanism module to obtain an enhanced detection feature; The initial detection features are input into the classification branch and the regression branch respectively to obtain the category probability distribution and target position information, wherein the category probability distribution is obtained based on the color category and the style category: fusing the category probability distribution and the target position information to obtain a clothing detection result; The clothing detection result is processed by a non-maximum suppression algorithm to obtain a clothing recognition result.
6. The method according to claim 1, wherein Before the step of inputting the processed image data into a preset clothing recognition model for recognition to obtain a clothing recognition result, the method includes: Acquire historical image data; Annotating the historical image data to generate a training set and a test set; Build an initial clothing recognition model; The clothing recognition model is trained using the training set to obtain a preset clothing recognition model.
7. The method according to claim 6, wherein The step of using the training set to train the clothing recognition model to obtain a preset clothing recognition model includes: Initializing weight and bias parameters of the initial clothing recognition model; Inputting the image data in the training set into the initial clothing recognition model for calculation to obtain predicted position and category probability; Calculating the error between the predicted position and the actual position according to a first loss function to obtain a distributed focus loss, wherein the actual position is calculated according to an external matrix; Calculating the cross entropy loss of the class probability and the true class label according to a second loss function to obtain the class probability loss, wherein the true class label is obtained by a preset coding table; Processing is performed according to the distribution focus loss and the category probability loss to obtain a total error value; Obtaining the gradients of the weight and bias parameters by back propagation algorithm calculation; The weight and bias parameters are iteratively updated according to the gradient through an optimization algorithm until a maximum number of iterations is reached or the total error value converges to a preset threshold, thereby obtaining a preset clothing recognition model.
8. A pedestrian clothing recognition device based on an improved YOLOv8 model, characterized in that: The device comprises: An acquisition module, used to acquire pedestrian image data; A processing module, configured to pre-process the image data to obtain processed image data; The result module is used to input the processed image data into a preset clothing recognition model for recognition to obtain clothing recognition results. The preset clothing recognition model is an improved YOLOv8 model. The improved YOLOv8 model includes a backbone network layer, a feature fusion layer and a detection head. The backbone network layer is composed of a CSPDarknet53 architecture, a coordinate attention module, an SCConv module and a Focus module. The CSPDarknet53 architecture adopts a first C2f module and a maximum pooling layer in series. The coordinate attention module is inserted into the first preset sub-layer of the backbone network layer. layer, a second preset sublayer and a third preset sublayer, the first C2f module includes two Bottleneck layers, each layer consists of a first convolution and a second convolution, and the Focus module consists of a third convolution; the feature fusion layer is composed of a PAN-FPN structure and a second C2f module, and the PAN-FPN structure and the second C2f module are both bidirectional cross-layer connections; the detection head is used for target detection and classification, and the detection head is divided into a classification branch and a regression branch, and the classification branch and the regression branch are both one-dimensional convolutions, and the classification branch also includes a color classification branch and a style classification branch.
9. A pedestrian clothing recognition device based on an improved YOLOv8 model, characterized in that: The device includes: a memory, a processor, and a pedestrian clothing recognition program based on an improved YOLOv8 model stored in the memory and running on the processor, wherein the pedestrian clothing recognition program based on the improved YOLOv8 model is configured to implement the steps of the pedestrian clothing recognition method based on the improved YOLOv8 model as described in any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores a pedestrian clothing recognition program based on the improved YOLOv8 model. When the pedestrian clothing recognition program based on the improved YOLOv8 model is executed by the processor, the steps of the pedestrian clothing recognition method based on the improved YOLOv8 model as described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Clothes identification method and device, equipment and medium
CN119006874A
Real-time auricle identification and auricular point positioning method and system for multi-task feature sharing
CN119523799A