Method and device for predicting character image classification, computer device and storage medium
By combining color, texture, and contour feature extraction models with a target classification model that utilizes residual blocks and attention mechanisms, the problem of inaccurate prediction results under different lighting conditions is solved, achieving higher recognition accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INSPUR SUZHOU INTELLIGENT TECH CO LTD
- Filing Date
- 2024-11-15
- Publication Date
- 2026-07-07
AI Technical Summary
Under different lighting conditions, traditional laboratory clothing inspection methods lead to inaccurate prediction results.
By combining feature extraction models of multiple feature categories, including color, texture and contour feature extraction models, image feature index values are extracted from the target person image. The target classification model is then used to make predictions using residual blocks, attention mechanism modules and global pooling layers. Key pixels are selected by combining preset weights and clustering models to construct a feature matrix for classification.
It improves recognition accuracy under different lighting conditions, ensuring more accurate clothing inspection results.
Smart Images

Figure CN119540997B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically to a method, apparatus, computer equipment, and storage medium for predicting the classification of human images. Background Technology
[0002] To ensure laboratory safety, staff must undergo a clothing check before entering the lab to confirm that they are wearing the necessary protective equipment, such as lab coats, safety shoes, safety glasses, and gloves. Traditionally, this check is conducted by management personnel.
[0003] With the rapid advancement of machine vision and artificial intelligence technologies, it is now possible to automatically photograph workers and perform automatic identification based on the captured images to complete the work of checking workers' attire. The specific process of image recognition involves: extracting the color feature value of each pixel from the image; then, determining the Region of Interest (ROI) in the image based on the color feature value of each pixel; and finally, obtaining a prediction result based on a pre-built attire standard recognition model and the color feature value of each pixel in the ROI.
[0004] Because of varying laboratory lighting conditions, the color of the same garment can differ under different lighting conditions, leading to inaccurate prediction results. Summary of the Invention
[0005] In view of this, the present invention provides a method, apparatus, computer device, storage medium and program product for predicting the classification of human images, so as to solve the problem of inaccurate prediction results in related technologies.
[0006] In a first aspect, the present invention provides a method for predicting the classification of person images, the method comprising:
[0007] Acquire the image of the target person;
[0008] Based on the pre-constructed feature extraction model for multiple feature categories, the image feature index value corresponding to each pixel under each of the multiple feature categories is extracted from the target person image;
[0009] Based on the image feature index values corresponding to each pixel under various feature categories, and the preset weight values corresponding to each feature category, a comprehensive image feature index value corresponding to each pixel is determined.
[0010] Based on the comprehensive image feature index value corresponding to each pixel, the pre-constructed clustering model, the preset length, and the preset width, multiple target pixels are selected from the target person image;
[0011] A first feature matrix is constructed based on the comprehensive image feature index value corresponding to each of the target pixels;
[0012] The first feature matrix is input into a pre-constructed target classification model to obtain the predicted classification result corresponding to the target person image.
[0013] The present invention provides a method for predicting the classification of human images, which has the following advantages:
[0014] This method can extract multi-dimensional image information (i.e., image feature index values of multiple feature categories) from target person images. This multi-dimensional information can more comprehensively describe each pixel in the image, thus providing richer details. There is complementarity between different feature categories. For example, color features may not be accurate enough in some cases, while texture features can provide additional information. By combining multiple features, the shortcomings of a single feature can be compensated for, improving the overall recognition accuracy.
[0015] In one optional implementation, the target classification model includes multiple residual blocks, an attention mechanism module, a global pooling layer, a first activation function, and a first convolutional layer corresponding to each residual block;
[0016] The step of inputting the first feature matrix into a pre-constructed target classification model to obtain a predicted classification result corresponding to the target person image includes:
[0017] The first input matrix is input into the target residual block to obtain the first output matrix output by the target residual block. The target residual block is any one of the multiple residual blocks. When the target residual block is the residual block that is ranked first among the multiple residual blocks, the target input matrix is the first feature matrix.
[0018] The first input matrix is input into the first convolutional layer corresponding to the target residual block to obtain the second output matrix output by the first convolutional layer;
[0019] Perform a residual concatenation operation on the first output matrix and the second output matrix to obtain the third output matrix;
[0020] When the target residual block is not the last residual block in the sorted order among the multiple residual blocks, the third output matrix is used as the first input matrix and input to the next residual block sorted after the target residual block;
[0021] or,
[0022] When the target residual block is the last residual block in the sorted order among multiple residual blocks, the third output matrix is input into the attention mechanism module for feature extraction to obtain the target feature vector output by the attention mechanism module;
[0023] The target feature vector is input into the global pooling layer to obtain the target classification index value output by the global pooling layer;
[0024] The target classification index value is input into the first activation function to obtain the predicted classification result output by the first activation function.
[0025] Specifically, residual blocks effectively address the vanishing gradient problem in deep networks by introducing residual connections. During training, residual connections allow gradients to be directly transferred from deeper layers to shallower layers, accelerating convergence and improving model performance. Furthermore, residual blocks can learn more complex feature representations because they learn not only the original features but also the residual features. This dual learning mechanism enables the model to more accurately capture subtle changes in images. The attention mechanism module automatically learns the most important regions in an image and assigns higher weights to these regions. This helps the model ignore background noise and other irrelevant parts, focusing on key features and thus improving classification accuracy. The global pooling layer compresses each channel of the feature map into a single value, reducing the number of model parameters and thus lowering the risk of overfitting. Moreover, by aggregating information from the feature map, the global pooling layer retains the most important features of each channel, helping the model to classify better. The introduction of a non-linear transformation through the first activation function enables the model to learn more complex feature representations, allowing it to better fit complex data distributions and improve classification accuracy. By stacking multiple residual blocks, the model can extract features at different levels layer by layer, from low-level edge and texture features to high-level semantic features, forming a hierarchical feature representation.
[0026] In one optional implementation, the residual block includes multiple filters, a normalization layer, and a second activation function, and the number of filters included in the residual block is 2. n+2 Where n is the order of the residual blocks, 2 n+2 2 of the filters n+1 Two filters constitute the second convolutional layer in the residual block. n+2 The remaining 2 of the filters n+1 Each filter constitutes the third convolutional layer in the residual block;
[0027] The step of inputting the first input matrix into the target residual block to obtain the first output matrix output by the target residual block includes:
[0028] The first input matrix is used to extract features by the multiple filters included in the second convolutional layer to obtain a second feature matrix;
[0029] The second feature matrix is input into the normalization layer for normalization processing to obtain the third feature matrix;
[0030] The third feature matrix is input into the second activation function to obtain the fourth feature matrix;
[0031] The first output matrix is obtained by extracting features from the fourth feature matrix using multiple filters included in the third convolutional layer.
[0032] Specifically, the number of filters in each residual block is 2. n+2 This allows the model to have different numbers of filters at different levels, enabling more flexible extraction of features at different scales. Each residual block contains two convolutional layers (a second and a third convolutional layer), each responsible for extracting features at different levels. This multi-stage feature extraction approach allows the model to capture more detailed complex patterns in the image. Normalization layers accelerate the model's training process, reduce internal covariate bias, and make the input distribution of each layer more stable, thereby speeding up convergence. Furthermore, normalization layers help improve the model's generalization ability.
[0033] In one optional implementation, the feature extraction models for the various feature categories include a color feature extraction model, a texture feature extraction model, and a contour feature extraction model;
[0034] The step of extracting image feature index values corresponding to each pixel under various feature categories from the target person image based on a pre-constructed feature extraction model with multiple feature categories includes:
[0035] The target person image is input into the color feature extraction model to obtain the color feature index value of each pixel output by the color feature extraction model;
[0036] The target person image is input into the texture feature extraction model to obtain the texture feature index value of each pixel output by the texture feature extraction model;
[0037] The target person image is input into the contour feature extraction model to obtain the contour feature index value of each pixel output by the contour feature extraction model.
[0038] Specifically, color, texture, and contour are crucial features in images, each describing different aspects of the image. Color features reflect the image's color information, texture features describe its surface structure, and contour features capture the edges and shapes of objects. By extracting this multi-dimensional information, each pixel in the image can be described more comprehensively. Furthermore, different feature categories are complementary. For example, color features may not be accurate enough in some cases, while texture and contour features can provide additional information. This combination of multiple features can compensate for the shortcomings of a single feature, improving overall recognition accuracy.
[0039] In one optional implementation, the preset weight value corresponding to the color feature, the preset weight value corresponding to the contour feature, and the preset weight value corresponding to the texture feature decrease sequentially.
[0040] Specifically, color is the most intuitive and easily identifiable feature when determining whether a person's clothing conforms to rules. Giving color the highest weight ensures that the model prioritizes color information during classification, improving accuracy and reliability. Contour features are crucial for recognizing the shape and boundaries of objects, but may be less intuitive than color features in some situations. Giving contour features the second-highest weight ensures that color features are prioritized while still paying attention to shape and boundaries. Texture features provide detailed information about the surface structure of objects, but their importance is relatively low in many visual tasks. Giving texture features the lowest weight allows them to serve as auxiliary information, helping the model make more nuanced distinctions when necessary.
[0041] In an optional implementation, determining the comprehensive image feature index value corresponding to each pixel based on the image feature index values corresponding to each of the multiple feature categories and the preset weight value corresponding to each feature category includes:
[0042] Based on the image feature index value of the target feature category corresponding to each pixel, a first preset threshold, and a second preset threshold, a normalized image feature index value of the target feature category corresponding to each pixel is determined, wherein the target feature category is any one of the multiple feature categories;
[0043] Based on the normalized image feature index value corresponding to each of the feature categories and the preset weight value of the first pixel, a comprehensive image feature index value corresponding to the first pixel is determined, wherein the first pixel is any pixel in the target person image.
[0044] Specifically, normalization unifies the feature index values of different feature categories to the same range. This eliminates the dimensional differences between different feature categories, allowing for a fair comparison and weighting of the contributions of different features. By presetting weight values, the contribution of different feature categories can be reasonably allocated. This weighting method ensures that the model prioritizes the most important features during classification.
[0045] In one optional implementation, selecting multiple target pixels from the target person image based on the comprehensive image feature index value corresponding to each pixel, a pre-constructed clustering model, a preset length, and a preset width includes:
[0046] Based on the comprehensive image feature index value corresponding to each pixel and the clustering model, multiple candidate pixels are selected from the target person image;
[0047] Obtain the position information of multiple candidate pixels in the target person image;
[0048] Based on the position information of multiple candidate pixels in the target person image, a center pixel is determined among the multiple target pixels, wherein the center pixel includes one or more;
[0049] Based on the center pixel, preset length, and preset width, select multiple target pixels from the target person image.
[0050] Specifically, a clustering model is used to select multiple candidate pixels from a pool of pixels. Clustering models effectively group pixels with similar features together, reducing the complexity of subsequent processing. By using a center pixel and predefined length and width constraints, the selected target pixels are ensured to be distributed more reasonably and centrally within the image. This helps reduce the influence of noise and irrelevant pixels, improving the accuracy of the final result.
[0051] Secondly, the present invention provides an apparatus for predicting the classification of person images, the apparatus comprising:
[0052] The acquisition module is used to acquire images of the target person.
[0053] The extraction module is used to extract the image feature index value corresponding to each pixel under the various feature categories from the target person image based on the pre-constructed feature extraction model for multiple feature categories.
[0054] The determining module is used to determine the comprehensive image feature index value corresponding to each pixel based on the image feature index value corresponding to each of the multiple feature categories and the preset weight value corresponding to each feature category.
[0055] The selection module is used to select multiple target pixels from the target person image based on the comprehensive image feature index value corresponding to each pixel, a pre-constructed clustering model, a preset length, and a preset width.
[0056] A construction module is used to construct a first feature matrix based on the comprehensive image feature index value corresponding to each of the target pixels;
[0057] The prediction module is used to input the first feature matrix into a pre-constructed target classification model to obtain a prediction classification result corresponding to the target person image.
[0058] Thirdly, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to perform the method for predicting human image classification as described in the first aspect or any corresponding embodiment.
[0059] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to perform the method for predicting human image classification as described in the first aspect or any corresponding embodiment.
[0060] Fifthly, the present invention provides a computer program product, including computer instructions for causing a computer to execute the method for predicting human image classification described in the first aspect or any corresponding embodiment thereof. Attached Figure Description
[0061] To more clearly illustrate the technical solutions in the specific embodiments or related technologies of the present invention, the drawings used in the description of the specific embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0062] Figure 1 This is a system architecture diagram according to an embodiment of the present invention;
[0063] Figure 2 This is a flowchart illustrating a method for predicting the classification of human images according to an embodiment of the present invention;
[0064] Figure 3 This is a schematic diagram of an RGB model according to an embodiment of the present invention;
[0065] Figure 4 This is a schematic diagram of the structure of a target classification model according to an embodiment of the present invention;
[0066] Figure 5 This is a schematic diagram of the ReLU function according to an embodiment of the present invention;
[0067] Figure 6 This is a flowchart illustrating a method for training a classification model according to an embodiment of the present invention;
[0068] Figure 7 This is a structural block diagram of an apparatus for predicting the classification of human images according to an embodiment of the present invention;
[0069] Figure 8 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. Detailed Implementation
[0070] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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, 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.
[0071] The embodiments of the present invention can be implemented by a system consisting of an image acquisition device and an image analysis device, and the system can be as follows: Figure 1 As shown. The image acquisition device can be a camera or similar device installed at the laboratory entrance, or a webcam on a terminal. The image analysis device can be a server, server cluster, or terminal. The image acquisition device can take a picture when it detects a person to obtain an image of that person, and then transmit it to the image analysis device. Alternatively, the image acquisition device can capture video and transmit it to the image analysis device. The image analysis device can analyze the acquired image of a person, or extract images of people from the video, to determine whether the clothing of the person in the image conforms to regulations or meets preset clothing rules.
[0072] This invention provides a method for predicting the classification of human images. By combining image feature indicators corresponding to multiple feature categories in the human image, it can more accurately identify whether the human's clothing conforms to preset clothing rules.
[0073] According to an embodiment of the present invention, a method for predicting the classification of human images is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0074] This embodiment provides a method for predicting the classification of human images, which can be executed by the image analysis device described above. Figure 2 This is a flowchart of a method for predicting the classification of person images according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps:
[0075] Step S201: Obtain the image of the target person.
[0076] Specifically, before staff enter the laboratory, image acquisition equipment at the laboratory entrance can capture images of the target individuals and transmit them to image analysis equipment, which can then obtain the target individual image. Alternatively, cameras can be installed inside the laboratory to transmit video data captured within the laboratory to the image analysis equipment. For each second of video, the image analysis equipment can extract one frame of a person's image as the target individual image, thus obtaining the target individual image.
[0077] Step S202: Based on the pre-constructed feature extraction model for multiple feature categories, extract the image feature index values corresponding to each pixel under multiple feature categories from the target person image.
[0078] The feature extraction model, which can encompass multiple feature categories, may include several of the following: color feature extraction model, texture feature extraction model, and contour feature extraction model. For example, the color feature extraction model could be a Red-Green-Blue (RGB) model, and the RGB model could be as follows: Figure 3 As shown. Texture feature extraction models can include Gray-Level Co-occurrence Matrix (GLCM), Local Binary Pattern (LBP), etc. Contour feature extraction models can include Canny edge detector, Hough transform, etc.
[0079] Specifically, the image analysis device can be equipped with feature extraction models for the three feature categories mentioned above. Accordingly, the image feature index values for these three feature categories can be extracted according to the following specific steps:
[0080] First, the target person image is input into the color feature extraction model to obtain the color feature index value of each pixel output by the color feature extraction model.
[0081] Among them, the color feature index value can be an index value calculated based on the intensity of the pixel in the three colors of red, green and blue. Specifically, it can be the average value or weighted average value of the intensity corresponding to the three colors respectively.
[0082] Second, the target person image is input into the texture feature extraction model to obtain the texture feature index value of each pixel output by the texture feature extraction model.
[0083] Third, the target person image is input into the contour feature extraction model to obtain the contour feature index value of each pixel output by the contour feature extraction model.
[0084] Step S203: Determine the comprehensive image feature index value corresponding to each pixel based on the image feature index value corresponding to each pixel under multiple feature categories and the preset weight value corresponding to each feature category.
[0085] The preset weight values corresponding to color features, contour features, and texture features can be adjusted according to the usage scenario. These preset weight values can be decreased sequentially; for example, the preset weight value corresponding to color features is 0.5, the preset weight value corresponding to contour features is 0.3, and the preset weight value corresponding to texture features is 0.2.
[0086] Specifically, since feature extraction models of different feature categories extract image feature values of different orders of magnitude, and the influence of different categories of features on the prediction results also varies, the specific process for calculating the comprehensive image feature index value corresponding to each pixel can be as follows:
[0087] Step 1: Determine the normalized image feature index value of the target feature category corresponding to each pixel based on the image feature index value of the target feature category corresponding to each pixel, the first preset threshold, and the second preset threshold.
[0088] The target feature category can be any one of multiple feature categories. For example, the first preset threshold can be 0, and the second preset threshold can be 1.
[0089] Specifically, the image analysis device can determine the number of pixels (i.e., the number of image feature index values corresponding to the target feature category), the maximum image feature index value, and the minimum image feature index value based on the image feature index value of the target feature category corresponding to each pixel. It then calculates a first difference between the maximum and minimum image feature index values, and a second difference between a second preset threshold and the first preset threshold. Next, it calculates a target ratio between the second difference and the first difference. Finally, for each pixel's corresponding image feature index value, a third difference between the pixel's image feature index value and the minimum image feature index value can be calculated. The product of the third difference and the target ratio, plus the first preset threshold, is used to determine the corresponding normalized image feature index value. Alternatively, a fourth difference between the maximum image feature index value and the pixel's image feature index value can be calculated, and the product of the fourth difference and the target ratio is subtracted from the second preset threshold to determine the corresponding normalized image feature index value.
[0090] Step 2: Determine the comprehensive image feature index value corresponding to the first pixel based on the normalized image feature index value and the preset weight value corresponding to each feature category of the first pixel.
[0091] The first pixel is any one of the multiple pixels.
[0092] Specifically, taking the first pixel as an example, the image analysis device can determine the target image feature index value corresponding to the target feature category based on the normalized image feature index value and the preset weight value of the target feature category of the first pixel, and then determine the sum of the target image feature index values corresponding to all feature categories of the first pixel as the comprehensive image feature index value corresponding to the first pixel.
[0093] Step S204: Select multiple target pixels from the target person image based on the comprehensive image feature index value corresponding to each pixel, the pre-constructed clustering model, the preset length, and the preset width.
[0094] Alternatively, step S204 can be performed as follows:
[0095] Step 1: Select multiple candidate pixels from the target person image based on the comprehensive image feature index value and clustering model corresponding to each pixel.
[0096] Step 2: Obtain the position information of multiple candidate pixels in the target person image.
[0097] Step 3: Based on the position information of multiple candidate pixels in the target person image, determine the center pixel among multiple target pixels.
[0098] The center pixel can include one or more pixels.
[0099] Step 4: Select multiple target pixels from the target person image based on the center pixel, preset length, and preset width.
[0100] Both the preset length and preset width can be represented by the number of pixels. For example, both the preset length and preset width can be 256.
[0101] Specifically, firstly, the image analysis device inputs the comprehensive image feature index value corresponding to each pixel into a clustering model to obtain the clustering results (including multiple clusters) output by the model. Then, based on the positional information of the pixels included in each cluster, it determines the bounding box corresponding to each cluster in the target person image. Next, the image analysis device selects the rectangle with the largest area as the Region of Interest (ROI) and selects all pixels in the ROI as candidate pixels. Since the size of the ROI determined in different person images is different, and the target classification model is used to process data of a specified size, the image analysis device also needs to obtain the positional information of multiple candidate pixels in the target person image. Based on the positional information of multiple candidate pixels in the target person image, it determines the center pixel among multiple target pixels. Finally, the image analysis device can use the center pixel as a reference to select target pixels within a preset length and preset width range in the target person image.
[0102] In some optional implementations, before step two, the image analysis device can first determine whether the length value of the ROI is equal to a preset length and whether the width value of the ROI is equal to a preset width. If the length value of the ROI is equal to the preset length and the width value of the ROI is equal to the preset width, then the candidate pixels of the ROI region can be determined as target pixels. If the length value of the ROI is not equal to the preset length or the width value of the ROI is not equal to the preset width, then the subsequent step three processing is performed. This can save processing resources.
[0103] Step S205: Construct a first feature matrix based on the comprehensive image feature index value corresponding to each target pixel.
[0104] Specifically, the image analysis device can place the comprehensive pre-feature index value of the target pixels at the corresponding position in a matrix of a preset size according to the arrangement of the target pixels in the image of the target person, thereby obtaining the first feature matrix.
[0105] Step S206: Input the first feature matrix into the pre-constructed target classification model to obtain the predicted classification result corresponding to the target person image.
[0106] The predicted classification result is used to indicate whether the clothing of the person in the target image meets the preset clothing rules.
[0107] Optionally, the object classification model can be a convolutional neural network (CNN) model. For example, the structure of the object classification model can be as follows: Figure 4 As shown, it includes multiple residual blocks, an attention mechanism module (Squeeze-and-Excitation, SE), a global average pooling layer (GAP), a first activation function, and a first convolutional layer corresponding to each residual block. Each residual block includes multiple filters, a normalization layer, and a second activation function, and the number of filters included in a residual block is 2. n+2 Where n is the sorting order of the residual blocks, 2 n+2 2 of the filters n+1 The filters constitute the second convolutional layer in the residual block, 2 n+2 The remaining 2 of the filters n+1 Each filter constitutes the third convolutional layer in the residual block. Accordingly, the specific processing in step S206 may include the following steps:
[0108] Step 1: Input the first input matrix into the target residual block to obtain the first output matrix of the target residual block.
[0109] The target residual block is any one of the multiple residual blocks. When the target residual block is the first residual block in the multiple residual blocks, the target input matrix is the first feature matrix.
[0110] Step 1: Extract features from the first input matrix using multiple filters included in the second convolutional layer to obtain the second feature matrix.
[0111] Step 2: Input the second feature matrix into the normalization layer for normalization processing to obtain the third feature matrix.
[0112] Step 3: Input the third feature matrix into the second activation function to obtain the fourth feature matrix.
[0113] Step 4: Extract features from the fourth feature matrix using multiple filters included in the third convolutional layer to obtain the first output matrix.
[0114] Step 2: Input the first input matrix into the first convolutional layer corresponding to the target residual block to obtain the second output matrix output by the first convolutional layer.
[0115] Step 3: Perform a residual join operation on the first and second output matrices to obtain the third output matrix.
[0116] Step 4: When the target residual block is not the last residual block in the sorted order among multiple residual blocks, the third output matrix is used as the first input matrix and input into the next residual block after the target residual block.
[0117] or,
[0118] Step 5: When the target residual block is the last residual block in the sorted order among multiple residual blocks, the third output matrix is input into the attention mechanism module for feature extraction, and the target feature vector output by the attention mechanism module is obtained.
[0119] Step 6: Input the target feature vector into the global pooling layer to obtain the target classification index value output by the global pooling layer.
[0120] Step 7: Input the target classification index value into the first activation function to obtain the predicted classification result output by the first activation function.
[0121] For example, the number of residual blocks can be 6, and the number of filters included in the residual blocks from beginning to end are 8, 16, 32, 64, 128, and 256, respectively. The size of the filters included in the residual blocks can be 3×3. When the size of the first feature matrix is 256×256, after processing through 6 residual blocks, the matrix size changes to: 256×256, 128×128, 64×64, 32×32, 16×16, and 8×8. The first convolutional layer can include one filter, and the filter size can be 1×1. The first activation function can be a rectified linear unit (ReLU) function, and its function graph can be as follows: Figure 5 As shown. The second activation function can be Softmax. The attention mechanism module can include a feature adaptive fusion layer. Adaptive feature fusion learns the optimal fusion weights based on the input features and their correlations. The fusion process in the adaptive fusion layer is controlled by a set of fusion functions, which can be linear, non-linear, or a combination thereof.
[0122] Specifically, an alarm can be triggered when the predicted classification result indicates that the clothing of a person in a target image does not meet the preset clothing rules.
[0123] The method for predicting and classifying human images provided in this embodiment can extract multi-dimensional image information (i.e., image feature index values of multiple feature categories) from target human images, such as color, texture, and contour. This multi-dimensional information can more comprehensively describe each pixel in the image, thus providing richer details. Different feature categories are complementary. For example, color features may not be accurate enough in some cases, while texture features can provide additional information. By combining multiple features, the shortcomings of a single feature can be compensated for, improving the overall recognition accuracy.
[0124] This embodiment provides a method for training a classification model, which can be executed by the aforementioned image analysis device. Figure 6 This is a flowchart of a method for training a classification model according to an embodiment of the present invention, such as... Figure 6 As shown, the process includes the following steps:
[0125] Step S601: Obtain the training dataset.
[0126] The training dataset includes multiple images of people and the corresponding true classification results for each image. Each image contains multiple pixels, and the true classification results are used to indicate whether the clothing of the people in the images is standard.
[0127] Specifically, users can first collect images of people dressed according to and not according to preset dress rules (these images can include people of different genders, ages, and body types, and images of clothing under different lighting, angles, and background conditions). These images are then labeled with their clothing type (e.g., lab coat, protective suit), color, style, wearing condition (clothing clean and intact, lab coat buttons fastened, etc.), and other relevant features. Furthermore, users can determine whether an image conforms to the preset dress rules based on the labels and classify it accordingly, thus labeling the actual classification result. For example, an image conforming to the preset dress rules can be labeled "1," and an image not conforming can be labeled "0." In this way, users can collect multiple images. Furthermore, the image acquisition device can use a certain proportion of the collected images as a training dataset.
[0128] Step S602: Based on the pre-constructed feature extraction model for multiple feature categories, extract the image feature index values corresponding to each pixel under multiple feature categories from the first person image.
[0129] The first person image is any one of multiple person images.
[0130] Step S603: Determine the comprehensive image feature index value corresponding to each pixel based on the image feature index value corresponding to each pixel under multiple feature categories and the preset weight value corresponding to each feature category.
[0131] Step S604: Select multiple target pixels from the first person image based on the comprehensive image feature index value corresponding to each pixel, the pre-constructed clustering model, the preset length, and the preset width.
[0132] Step S605: Construct a target feature matrix based on the comprehensive image feature index value corresponding to each target pixel.
[0133] Step S606: Input the target feature matrix into the classification model to be trained to obtain the predicted classification result corresponding to the first person image.
[0134] The predicted classification result is used to indicate whether the clothing of the person in the first image meets the preset clothing rules.
[0135] The specific processing of steps S602 to S606 is similar to that of steps S202 to S206, and will not be described again here.
[0136] Step S607: Determine the target loss value based on the actual classification result and the predicted classification result corresponding to each person image.
[0137] Specifically, the image analysis device can calculate the target loss value by using a pre-constructed loss function to evaluate the true classification result and the predicted classification result for each image of a person. For example, the loss function can be the cross-entropy loss function or the mean squared error loss function.
[0138] During training, a learning rate of 1.0×10^(-4) can be used to train the classification model.
[0139] Step S608: When the target loss value is less than the preset loss value threshold, it is determined that the training stop condition is met, and the prediction classification model that has completed training is determined as the target classification model.
[0140] Step S609: When the target loss value is greater than or equal to the preset loss value threshold, continue to train the classification model according to the target loss value until the calculated loss value is less than the preset loss value threshold, and then determine the completed training prediction classification model as the target classification model.
[0141] The method for predicting image classification of people provided in this embodiment firstly integrates image texture features and contour analysis into the feature engineering of the training dataset, using not only image color attributes but also these three methods into a single image feature processing. This integration helps improve detection accuracy and minimizes false positives and false negatives in traditional deep learning models. Secondly, the use of residual blocks helps improve model training and detection efficiency and reduces overfitting to some extent. An attention mechanism module is used to handle the interaction relationships between different feature sequences. By focusing on the interrelated information in multiple sequences, it achieves information interaction and fusion, improving the efficiency and accuracy of the model when processing complex data. The attention mechanism allows the model to selectively focus on relevant features while suppressing less important features. Linear and nonlinear fusion functions are used to combine features within the adaptive fusion layer. These functions are responsible for transforming the input features into a feature space where they can be adaptively combined, making the trained classification model more accurate.
[0142] This embodiment also provides an apparatus for predicting the classification of person images. This apparatus is used to implement the above embodiments and preferred embodiments, and details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0143] This embodiment provides a device for predicting the classification of human images, such as... Figure 7 As shown, it includes:
[0144] The acquisition module 701 is used to acquire the image of the target person;
[0145] The extraction module 702 is used to extract the image feature index values corresponding to each pixel under multiple feature categories from the target person image based on the pre-constructed feature extraction model for multiple feature categories.
[0146] The determining module 703 is used to determine the comprehensive image feature index value corresponding to each pixel based on the image feature index values corresponding to each pixel under multiple feature categories, and the preset weight value corresponding to each feature category.
[0147] The selection module 704 is used to select multiple target pixels from the target person image based on the comprehensive image feature index value corresponding to each pixel, the pre-constructed clustering model, the preset length and the preset width.
[0148] The construction module 705 is used to construct a first feature matrix based on the comprehensive image feature index value corresponding to each target pixel;
[0149] The prediction module 706 is used to input the first feature matrix into the pre-constructed target classification model to obtain the prediction classification result corresponding to the target person image.
[0150] In one alternative implementation, the target classification model includes multiple residual blocks, an attention mechanism module, a global pooling layer, a first activation function, and a first convolutional layer corresponding to each residual block.
[0151] Prediction module 706 is specifically used for:
[0152] The first input matrix is input into the target residual block to obtain the first output matrix of the target residual block. The target residual block is any one of multiple residual blocks. When the target residual block is the residual block that is ranked first among multiple residual blocks, the target input matrix is the first feature matrix.
[0153] The first input matrix is input into the first convolutional layer corresponding to the target residual block to obtain the second output matrix output by the first convolutional layer;
[0154] Perform a residual join operation on the first and second output matrices to obtain the third output matrix;
[0155] When the target residual block is not the last residual block in the sorted order among multiple residual blocks, the third output matrix is used as the first input matrix and input to the next residual block after the target residual block.
[0156] or,
[0157] When the target residual block is the last residual block in the sorted order among multiple residual blocks, the third output matrix is input into the attention mechanism module for feature extraction, and the target feature vector output by the attention mechanism module is obtained.
[0158] The target feature vector is input into the global pooling layer to obtain the target classification index value output by the global pooling layer;
[0159] The target classification index value is input into the first activation function to obtain the predicted classification result output by the first activation function.
[0160] In one optional implementation, the residual block includes multiple filters, a normalization layer, and a second activation function, and the number of filters included in the residual block is 2. n+2 Where n is the sorting order of the residual blocks, 2 n+2 2 of the filters n+1 The filters constitute the second convolutional layer in the residual block, 2 n+2 The remaining 2 of the filters n+1 Each filter constitutes the third convolutional layer in the residual block;
[0161] Prediction module 706 is specifically used for:
[0162] The second feature matrix is obtained by extracting features from the first input matrix through multiple filters included in the second convolutional layer;
[0163] The second feature matrix is input into the normalization layer for normalization processing to obtain the third feature matrix;
[0164] The third feature matrix is input into the second activation function to obtain the fourth feature matrix;
[0165] The first output matrix is obtained by extracting features from the fourth feature matrix through multiple filters included in the third convolutional layer.
[0166] In one optional implementation, the feature extraction model for multiple feature categories includes a color feature extraction model, a texture feature extraction model, and a contour feature extraction model;
[0167] Extraction module 702 is specifically used for:
[0168] The target person image is input into the color feature extraction model to obtain the color feature index value of each pixel output by the color feature extraction model;
[0169] The target person image is input into the texture feature extraction model to obtain the texture feature index value of each pixel output by the texture feature extraction model;
[0170] The target person image is input into the contour feature extraction model to obtain the contour feature index value of each pixel output by the contour feature extraction model.
[0171] In one optional implementation, the preset weight value corresponding to the color feature, the preset weight value corresponding to the contour feature, and the preset weight value corresponding to the texture feature decrease sequentially.
[0172] In one alternative implementation, the determining module 703 is specifically used for:
[0173] Based on the image feature index value of the target feature category corresponding to each pixel, the first preset threshold, and the second preset threshold, the normalized image feature index value of the target feature category corresponding to each pixel is determined, wherein the target feature category is any one of multiple feature categories;
[0174] Based on the normalized image feature index value and preset weight value corresponding to each feature category of the first pixel, the comprehensive image feature index value corresponding to the first pixel is determined, wherein the first pixel is any pixel in the target person image.
[0175] In one alternative implementation, module 704 is selected and is specifically used for:
[0176] Based on the comprehensive image feature index value corresponding to each pixel and the clustering model, multiple candidate pixels are selected from the target person image;
[0177] Obtain the positional information of multiple candidate pixels in the target person image;
[0178] Based on the positional information of multiple candidate pixels in the target person image, a center pixel is determined among the multiple target pixels, wherein the center pixel includes one or more;
[0179] Based on the center pixel, preset length, and preset width, select multiple target pixels from the target person image.
[0180] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0181] In this embodiment, the device for predicting the classification of human images is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above-mentioned functions.
[0182] This invention also provides a computer device having the above-described features. Figure 8 The device shown is for predicting the classification of images of people.
[0183] Please see Figure 8 , Figure 8 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of the present invention, such as... Figure 8 As shown, the computer device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 8 Take a processor 10 as an example.
[0184] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware integrated circuit. The aforementioned hardware integrated circuit may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The aforementioned programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0185] The memory 20 stores instructions executable by at least one processor 10 to cause the at least one processor 10 to perform the method shown in the above embodiments.
[0186] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0187] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0188] The computer device also includes a communication interface 30 for communicating with other devices or communication networks.
[0189] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.
[0190] A portion of this invention can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the invention through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0191] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for predicting the classification of human images, characterized in that, The method includes: Acquire the image of the target person; Based on the pre-constructed feature extraction model for multiple feature categories, the image feature index value corresponding to each pixel under each of the multiple feature categories is extracted from the target person image; Based on the image feature index values corresponding to each pixel under various feature categories, and the preset weight values corresponding to each feature category, a comprehensive image feature index value corresponding to each pixel is determined. The various feature categories include color features, contour features, and texture features. The preset weight values corresponding to the color features, the contour features, and the texture features decrease sequentially. The comprehensive image feature index value corresponding to each pixel is input into a pre-constructed clustering model to obtain multiple clusters output by the clustering model; Based on the positional information of the pixels included in each cluster, a rectangular box corresponding to the cluster is determined in the target person image; All pixels included in the largest rectangle within the rectangles corresponding to the multiple clusters are determined as candidate pixels; Obtain the position information of multiple candidate pixels in the target person image; Based on the position information of multiple candidate pixels in the target person image, a center pixel is determined among the multiple candidate pixels, wherein the center pixel includes one or more; Based on the center pixel, preset length, and preset width, select multiple target pixels from the target person image; A first feature matrix is constructed based on the comprehensive image feature index value corresponding to each of the target pixels; The first feature matrix is input into a pre-constructed target classification model to obtain a predicted classification result corresponding to the target person image. The predicted classification result indicates whether the clothing of the person in the target person image meets a preset clothing rule. The target classification model includes multiple residual blocks, an attention mechanism module, a global pooling layer, a first activation function, and a first convolutional layer corresponding to each residual block. Each residual block includes multiple filters, a normalization layer, and a second activation function, and the number of filters included in each residual block is... , where n is the order of the residual blocks. In the filters The filters constitute the second convolutional layer in the residual block. The remaining filters Each filter constitutes the third convolutional layer in the residual block; The step of inputting the first feature matrix into a pre-constructed target classification model to obtain a predicted classification result corresponding to the target person image includes: The first input matrix is input into the target residual block to obtain the first output matrix of the target residual block. The target residual block can be any one of the multiple residual blocks. When the target residual block is the first residual block in the sorted order among the multiple residual blocks, the first input matrix is the first feature matrix. The first input matrix is then input into the first convolutional layer corresponding to the target residual block to obtain the second output matrix of the first convolutional layer. A residual concatenation operation is performed on the first output matrix and the second output matrix to obtain the third output matrix. When the target residual block is not in the sorted order among the multiple residual blocks... When the target residual block is the last residual block, the third output matrix is used as the first input matrix and input to the next residual block after the target residual block; or, when the target residual block is the last residual block among the multiple residual blocks, the third output matrix is input to the attention mechanism module for feature extraction to obtain the target feature vector output by the attention mechanism module; the target feature vector is input to the global pooling layer to obtain the target classification index value output by the global pooling layer; the target classification index value is input to the first activation function to obtain the predicted classification result output by the first activation function. The step of inputting the first input matrix into the target residual block to obtain the first output matrix output by the target residual block includes: The first input matrix is subjected to feature extraction by the multiple filters included in the second convolutional layer to obtain a second feature matrix; the second feature matrix is input into the normalization layer for normalization processing to obtain a third feature matrix; the third feature matrix is input into the second activation function to obtain a fourth feature matrix; the fourth feature matrix is subjected to feature extraction by the multiple filters included in the third convolutional layer to obtain the first output matrix.
2. The method according to claim 1, characterized in that, The feature extraction models for various feature categories include color feature extraction models, texture feature extraction models, and contour feature extraction models; The step of extracting image feature index values corresponding to each pixel under various feature categories from the target person image based on a pre-constructed feature extraction model with multiple feature categories includes: The target person image is input into the color feature extraction model to obtain the color feature index value of each pixel output by the color feature extraction model; The target person image is input into the texture feature extraction model to obtain the texture feature index value of each pixel output by the texture feature extraction model; The target person image is input into the contour feature extraction model to obtain the contour feature index value of each pixel output by the contour feature extraction model.
3. The method according to claim 1, characterized in that, The step of determining the comprehensive image feature index value corresponding to each pixel based on the image feature index values corresponding to each of the multiple feature categories, and the preset weight value corresponding to each feature category, includes: Based on the image feature index value of the target feature category corresponding to each pixel, a first preset threshold, and a second preset threshold, a normalized image feature index value of the target feature category corresponding to each pixel is determined, wherein the target feature category is any one of the multiple feature categories; Based on the normalized image feature index value corresponding to each of the feature categories and the preset weight value of the first pixel, a comprehensive image feature index value corresponding to the first pixel is determined, wherein the first pixel is any pixel in the target person image.
4. A device for predicting the classification of human images, characterized in that, The device includes: The acquisition module is used to acquire images of the target person. The extraction module is used to extract the image feature index value corresponding to each pixel under the various feature categories from the target person image based on the pre-constructed feature extraction model for multiple feature categories. The determining module is used to determine the comprehensive image feature index value corresponding to each pixel based on the image feature index value corresponding to each of the multiple feature categories and the preset weight value corresponding to each of the feature categories. The multiple feature categories include color features, contour features and texture features, and the preset weight value corresponding to the color feature, the preset weight value corresponding to the contour feature and the preset weight value corresponding to the texture feature decrease in sequence. A selection module is used to input the comprehensive image feature index value corresponding to each pixel into a pre-constructed clustering model to obtain multiple clusters output by the clustering model; determine the rectangle corresponding to the cluster in the target person image based on the position information of the pixels included in each cluster; determine all pixels included in the rectangle with the largest area in the rectangles corresponding to the multiple clusters as candidate pixels; obtain the position information of the multiple candidate pixels in the target person image; determine the center pixel among the multiple candidate pixels based on the position information of the multiple candidate pixels in the target person image, wherein the center pixel includes one or more; select multiple target pixels from the target person image based on the center pixel, a preset length, and a preset width. A construction module is used to construct a first feature matrix based on the comprehensive image feature index value corresponding to each of the target pixels; The prediction module is used to input the first feature matrix into a pre-constructed target classification model to obtain a prediction classification result corresponding to the target person image. The prediction classification result indicates whether the clothing of the person in the target person image meets a preset clothing rule. The target classification model includes multiple residual blocks, an attention mechanism module, a global pooling layer, a first activation function, and a first convolutional layer corresponding to each residual block. Each residual block includes multiple filters, a normalization layer, and a second activation function, and the number of filters included in each residual block is... , where n is the order of the residual blocks. In the filters The filters constitute the second convolutional layer in the residual block. The remaining filters Each filter constitutes the third convolutional layer in the residual block; The step of inputting the first feature matrix into a pre-constructed target classification model to obtain a predicted classification result corresponding to the target person image includes: The first input matrix is input into the target residual block to obtain the first output matrix of the target residual block. The target residual block can be any one of the multiple residual blocks. When the target residual block is the first residual block in the sorted order among the multiple residual blocks, the first input matrix is the first feature matrix. The first input matrix is then input into the first convolutional layer corresponding to the target residual block to obtain the second output matrix of the first convolutional layer. A residual concatenation operation is performed on the first output matrix and the second output matrix to obtain the third output matrix. When the target residual block is not in the sorted order among the multiple residual blocks... When the target residual block is the last residual block, the third output matrix is used as the first input matrix and input to the next residual block after the target residual block; or, when the target residual block is the last residual block among the multiple residual blocks, the third output matrix is input to the attention mechanism module for feature extraction to obtain the target feature vector output by the attention mechanism module; the target feature vector is input to the global pooling layer to obtain the target classification index value output by the global pooling layer; the target classification index value is input to the first activation function to obtain the predicted classification result output by the first activation function. The step of inputting the first input matrix into the target residual block to obtain the first output matrix output by the target residual block includes: The first input matrix is subjected to feature extraction by the multiple filters included in the second convolutional layer to obtain a second feature matrix; the second feature matrix is input into the normalization layer for normalization processing to obtain a third feature matrix; the third feature matrix is input into the second activation function to obtain a fourth feature matrix; the fourth feature matrix is subjected to feature extraction by the multiple filters included in the third convolutional layer to obtain the first output matrix.
5. A computer device, characterized in that, include: A memory and a processor are communicatively connected, the memory storing computer instructions, and the processor executing the computer instructions to perform the method for predicting image classification of people as described in any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to perform the method for predicting the classification of human images as described in any one of claims 1 to 3.