Method for training a garment classification model and related apparatus
By sharing network parameters between the feature extraction module and the multi-level image patch encoding module, a contrastive cross-entropy loss function is constructed to train the clothing classification model, which solves the problem of low accuracy in clothing classification and improves the accuracy of clothing classification without increasing the labeling cost.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN SHULIAN TIANXIA INTELLIGENT TECH CO LTD
- Filing Date
- 2022-09-30
- Publication Date
- 2026-04-24
Smart Images

Figure CN115424080B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a training method and related apparatus for a clothing classification model. Background Technology
[0002] With the rapid development of the Internet, more and more people are choosing to buy clothes through e-commerce platforms. Therefore, using intelligent classification models to determine the category of clothing images is very important for e-commerce platforms to improve user experience.
[0003] In existing technologies, convolutional neural networks (CNNs) are commonly used to extract image features for clothing classification. However, CNNs cannot effectively handle the diversity of image samples and changes in sample spatial structure. When the detected image exhibits significant color differences, brightness variations, occlusion, or abnormal changes in spatial structure, the detection accuracy drops sharply, thus affecting the accuracy of clothing classification. Summary of the Invention
[0004] The embodiments of this application aim to provide a training method and related apparatus for a clothing classification model, which solves the technical problem of low accuracy in current clothing classification, and can enhance the learning of clothing differentiation features and improve the accuracy of clothing classification without increasing additional annotation costs.
[0005] The embodiments of this application provide the following technical solutions:
[0006] In a first aspect, embodiments of this application provide a training method for a clothing classification model. The clothing classification model includes a feature extraction module and a multi-level image patch encoding module, wherein the feature extraction module and the multi-level image patch encoding module share network parameters. The method includes:
[0007] Obtain an image dataset, which includes images of clothing from various clothing categories;
[0008] Based on the feature extraction module, features are extracted for each clothing image, enabling the feature extraction module to learn the clothing features corresponding to each clothing category in each clothing image.
[0009] Based on clothing images of various clothing categories, obtain image blocks of different clothing categories;
[0010] Based on the multi-level image block coding module, image blocks of different clothing categories are mapped to obtain the multi-dimensional feature vector corresponding to each image block;
[0011] Construct a contrastive cross-entropy loss function, which includes multi-class cross-entropy loss and contrastive cross loss. The contrastive cross loss is used to characterize the correlation between feature vectors corresponding to image patches of the same clothing category, and to characterize the difference between feature vectors corresponding to image patches of different clothing categories.
[0012] The clothing classification model is trained based on the contrastive cross-entropy loss function until the contrastive cross-entropy loss function converges, so that the feature extraction module learns the differences between different clothing categories.
[0013] In some embodiments, after acquiring the image dataset, the method further includes:
[0014] Adjust the size of clothing images of various clothing categories to obtain clothing images of various clothing categories with a fixed size;
[0015] Construct a normalization function to normalize clothing images of various clothing categories that have been adjusted to a fixed size;
[0016] The normalization function includes:
[0017]
[0018] Where norm is the pixel value of the clothing image after normalization, and x i Let x be the value of the i-th pixel in the clothing image, max(x) be the maximum value of the clothing image, and min(x) be the minimum value of the clothing image.
[0019] In some embodiments, the feature extraction module includes a clothing basic feature extraction network;
[0020] The clothing basic feature extraction network includes an input layer, a first convolutional layer, a second convolutional layer, a third convolutional layer, a fourth convolutional layer, a fifth convolutional layer, a sixth convolutional layer, a fully connected layer, and a normalization layer, which are connected in sequence.
[0021] The method also includes:
[0022] The normalized clothing image is input into the clothing basic feature extraction network to obtain the probability value corresponding to each clothing category in the normalized clothing image.
[0023] In some embodiments, the multi-level image block coding module includes a multi-level image block coding network;
[0024] The multi-level image block coding network includes a first convolutional layer, a second convolutional layer, and a third convolutional layer. The first, second, and third convolutional layers of the multi-level image block coding network share network parameters with the first, second, and third convolutional layers of the clothing basic feature extraction network.
[0025] In some embodiments, image blocks of different clothing categories are obtained based on clothing images of multiple clothing categories, including:
[0026] The clothing image input into the clothing basic feature extraction network is identified as the first clothing image, and there are at least two first clothing images;
[0027] Extract each first clothing image to obtain the first clothing image block corresponding to each first clothing image;
[0028] Identify at least two second clothing images, wherein the second clothing images belong to the same clothing category as the first clothing image;
[0029] Extract each second clothing image to obtain the second clothing image block corresponding to each second clothing image.
[0030] In some embodiments, obtaining image blocks of different clothing categories based on clothing images of multiple clothing categories further includes:
[0031] Identify at least two third clothing images, wherein the third clothing image does not belong to the same clothing category as the first clothing image;
[0032] Extract each third clothing image to obtain the third clothing image block corresponding to each third clothing image.
[0033] In some embodiments, based on a multi-level image block encoding module, image blocks of different clothing categories are mapped to obtain a multi-dimensional feature vector corresponding to each image block, including:
[0034] Input at least two first clothing image blocks into the multi-level image block encoding module to obtain the multi-dimensional feature vector corresponding to each first clothing image block;
[0035] Input at least two second clothing image blocks into the multi-level image block encoding module to obtain the multi-dimensional feature vector corresponding to each second clothing image block;
[0036] Input at least two third clothing image blocks into the multi-level image block encoding module to obtain the multi-dimensional feature vector corresponding to each third clothing image block.
[0037] In some embodiments, multi-class cross-entropy loss is used to characterize the loss between the true probability and the predicted probability of a clothing category. Multi-class cross-entropy loss includes:
[0038]
[0039] Among them, L cls For multi-class cross-entropy loss, n is the total number of clothing categories, y i S represents the true probability value of the i-th clothing category. i Let be the predicted probability value for the i-th clothing category.
[0040] In some embodiments, comparing the cross loss includes:
[0041]
[0042] Among them, L con To compare the cross loss, V K V is the multidimensional feature vector corresponding to the first clothing image patch. K+ Let V be the multidimensional feature vector corresponding to the second clothing image patch, where τ is the scaling parameter, n is the total number of clothing categories, and V is the multidimensional feature vector. K- This is the multidimensional feature vector corresponding to the third clothing image patch.
[0043] Secondly, embodiments of this application provide a method for predicting clothing categories, including:
[0044] Obtain the image of the clothing to be predicted;
[0045] The clothing image to be predicted is input into the clothing classification model to obtain the clothing category corresponding to the clothing image. The clothing classification model is trained based on the training method of the clothing classification model in the first aspect.
[0046] In some embodiments, the clothing image to be predicted is input into a clothing classification model to obtain the clothing category corresponding to the clothing image to be predicted, including:
[0047] Based on the feature extraction module, the probability value corresponding to each clothing category in the clothing image to be predicted is obtained;
[0048] The clothing category with the highest probability value is determined as the clothing category corresponding to the clothing image to be predicted.
[0049] Thirdly, embodiments of this application provide an electronic device, including:
[0050] At least one processor, and
[0051] A memory that is communicatively connected to at least one processor, wherein,
[0052] The memory stores instructions that can be executed by at least one processor, which enables the at least one processor to perform either a training method for a clothing classification model in the first aspect or a prediction method for clothing categories in the second aspect.
[0053] Fourthly, embodiments of this application provide a non-volatile computer-readable storage medium storing computer-executable instructions for causing an electronic device to execute a training method for a clothing classification model (a first aspect) or a prediction method for clothing categories (a second aspect).
[0054] The beneficial effects of this application's embodiments: Unlike existing technologies, this application provides a training method for a clothing classification model. This model includes a feature extraction module and a multi-level image patch encoding module, wherein the feature extraction module and the multi-level image patch encoding module share network parameters. The training method includes: acquiring an image dataset, wherein the image dataset includes clothing images of multiple clothing categories; acquiring an image dataset, wherein the image dataset includes clothing images of multiple clothing categories; based on the feature extraction module, performing feature extraction on each clothing image, so that the feature extraction module learns the clothing features corresponding to each clothing category of each clothing image; and according to multiple clothing categories... Other clothing images are used to obtain image patches of different clothing categories. Based on the multi-level image patch encoding module, image patch mapping is performed on the image patches of different clothing categories to obtain the multi-dimensional feature vector corresponding to each image patch. A contrastive cross-entropy loss function is constructed, which includes multi-class cross-entropy loss and contrastive cross-loss. The contrastive cross-loss is used to characterize the correlation between feature vectors corresponding to image patches of the same clothing category, and to characterize the difference between feature vectors corresponding to image patches of different clothing categories. The clothing classification model is trained based on the contrastive cross-entropy loss function until the contrastive cross-entropy loss function converges, so that the feature extraction module learns the difference features between different clothing categories.
[0055] On the one hand, by acquiring image patches of different clothing categories, the image patches of different clothing categories are mapped based on the multi-level image patch coding module to obtain the multi-dimensional feature vector corresponding to each image patch, so that the multi-level image patch coding module can learn the difference features between different clothing categories.
[0056] On the other hand, by sharing network parameters between the feature extraction module and the multi-level image patch encoding module, the clothing classification model is trained based on the contrastive cross-entropy loss function. This contrastive cross-entropy loss function includes contrastive cross-loss, which is used to characterize the correlation between feature vectors corresponding to image patches of the same clothing category, and to characterize the differences between feature vectors corresponding to image patches of different clothing categories. This allows the multi-level image patch encoding module to apply the learned difference features between different clothing categories to the feature extraction module, enabling the feature extraction module to learn the clothing features corresponding to each clothing category and the difference features between different clothing categories. This application can enhance the learning of clothing differentiation features without increasing additional annotation costs, thereby improving the accuracy of clothing classification. Attached Figure Description
[0057] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0058] Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of this application;
[0059] Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0060] Figure 3 This is a flowchart illustrating a training method for a clothing classification model provided in an embodiment of this application;
[0061] Figure 4 This is a flowchart illustrating a method for normalizing images of clothing of multiple clothing categories provided in an embodiment of this application.
[0062] Figure 5 This is a schematic diagram of the structure of a clothing basic feature extraction network provided in an embodiment of this application;
[0063] Figure 6 This is a flowchart illustrating a method for obtaining the probability value corresponding to each clothing category in a clothing image, as provided in an embodiment of this application.
[0064] Figure 7 yes Figure 3 A detailed flowchart of step S303 in the process;
[0065] Figure 8 yes Figure 3 Another detailed flowchart of step S303 in the process;
[0066] Figure 9 This is a schematic diagram of the structure of a multi-level image block coding network provided in an embodiment of this application;
[0067] Figure 10 This is a flowchart illustrating a method for obtaining a multidimensional feature vector corresponding to each image block, as provided in an embodiment of this application.
[0068] Figure 11 This is a schematic diagram of the training process of a clothing classification model provided in an embodiment of this application;
[0069] Figure 12 This is a flowchart illustrating a method for predicting clothing categories provided in an embodiment of this application;
[0070] Figure 13 yes Figure 12 A detailed flowchart of step S1202 in the process;
[0071] Figure 14 This is a schematic diagram of the structure of a training device for a clothing classification model provided in an embodiment of this application;
[0072] Figure 15 This is a schematic diagram of the structure of a clothing category prediction device provided in an embodiment of this application. Detailed Implementation
[0073] The present application will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present application, but do not limit the present application in any way. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the present application. These all fall within the protection scope of the present application.
[0074] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0075] It should be noted that, unless there is a conflict, the various features in the embodiments of this application can be combined with each other, all of which are within the protection scope of this application. Furthermore, although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than the module division in the device or the order in the flowchart. In addition, the terms "first," "second," and "third" used herein do not limit the data or execution order, but only distinguish identical or similar items with essentially the same function and effect.
[0076] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The term "and / or" as used in this specification includes any and all combinations of one or more of the associated listed items.
[0077] Furthermore, the technical features involved in the various embodiments of this application described below can be combined with each other as long as they do not conflict with each other.
[0078] Before introducing the embodiments of this application, a brief introduction will be given to the clothing classification methods known to the inventors of this application, so as to facilitate the understanding of the embodiments of this application later.
[0079] In some clothing classification methods, convolutional neural networks are trained using clothing images to obtain a clothing classification model, which is then used to extract image features and perform classification. However, this type of clothing classification model, which uses clothing images to train convolutional neural networks, cannot effectively handle the diversity of image samples or changes in sample spatial structure. Therefore, when the detected image exhibits significant color differences, brightness variations, occlusion, or abnormal changes in spatial structure, the detection accuracy will plummet.
[0080] In some clothing classification methods, attention mechanisms are used to amplify the key vectors and weights of clothing image features, and convolution and normalization are applied to the image features. Spatial transformation networks are used to transform the receptive field of image features. The image features are then input into capsule networks to extract spatial correlation information of the image features, thereby improving generalization ability.
[0081] However, the technologies known to the inventors of this application, whether convolutional neural networks or capsule networks, all extract image features and rely solely on image feature information. When faced with such a large number of clothing features and clothing categories, their accuracy is clearly insufficient.
[0082] To address the aforementioned problems, this application provides a training method for a clothing classification model. The clothing classification model includes a feature extraction module and a multi-level image patch encoding module. The training method includes: acquiring an image dataset, wherein the image dataset includes clothing images of multiple clothing categories; performing feature extraction on each clothing image based on the feature extraction module to obtain the probability value corresponding to each clothing category for each clothing image; acquiring image patches of different clothing categories based on the clothing images of multiple clothing categories; performing image patch mapping on the image patches of different clothing categories based on the multi-level image patch encoding module to obtain a multi-dimensional feature vector corresponding to each image patch; constructing a contrastive cross-entropy loss function, and training the clothing classification model based on the contrastive cross-entropy loss function until the contrastive cross-entropy loss function converges, wherein the contrastive cross-entropy loss function includes multi-class cross-entropy loss and contrastive cross-loss.
[0083] By acquiring image patches of different clothing categories, extracting image patch encoding feature vectors based on a multi-level image patch encoding module, and training the clothing classification model based on the contrastive cross-entropy loss function, this application can enhance the learning of clothing differentiation features without increasing additional annotation costs, thereby improving the accuracy of clothing classification.
[0084] In the embodiments of this application, the training method of the clothing classification model and the prediction method of clothing categories can be executed by an electronic device with computing power. The following describes an exemplary application of the electronic device provided in the embodiments of this application for training the clothing classification model or for predicting clothing categories. It is understood that the electronic device can both train the clothing classification model and use the clothing classification model to predict clothing categories.
[0085] In this embodiment, the electronic device can be a server, such as a server deployed in the cloud. When the server is used to train a clothing classification model, it constructs a clothing classification model based on image datasets, feature extraction modules, and multi-level image patch coding modules provided by other devices or those skilled in the art, and iteratively trains the clothing classification model using a contrastive cross-entropy loss function to determine the final model parameters. When the server is used to predict clothing categories, it calls the built-in clothing classification model to process the clothing images to be predicted provided by other devices or users, and obtains the clothing category corresponding to the clothing image to be predicted.
[0086] In this embodiment, the electronic device can also be various types of terminals such as laptops, desktop computers, or mobile devices. When the terminal is used to train the clothing classification model, those skilled in the art input a prepared image dataset into the terminal, design a feature extraction module and a multi-level image patch encoding module on the terminal, and construct a contrastive cross-entropy loss function so that the terminal uses the contrastive cross-entropy loss function to iteratively train the clothing classification model to determine the final model parameters. When the terminal is used for clothing classification, it calls the built-in clothing classification model to process the user-input clothing image to be predicted and obtain the clothing category corresponding to the clothing image to be predicted.
[0087] Before providing a detailed description of this application, the nouns and terms used in the embodiments of this application are explained, and the nouns and terms used in the embodiments of this application shall be interpreted as follows:
[0088] (1) A neural network, also known as a neural network (NNs) or connection model, is an algorithmic mathematical model that mimics the behavioral characteristics of animal neural networks to perform distributed parallel information processing. Neural networks rely on the complexity of the system to process information by adjusting the interconnections between a large number of internal nodes. Specifically, a neural network can be composed of neural units, which can be understood as a neural network with an input layer, hidden layers, and an output layer. Generally, the first layer is the input layer, the last layer is the output layer, and the intermediate layers are hidden layers. Neural networks with many hidden layers are called deep neural networks (DNNs). The work of each layer in a neural network can be described by the mathematical expression y = a(W·x + b). From a physical perspective, the work of each layer in a neural network can be understood as transforming the input space (the set of input vectors) to the output space (i.e., from the row space to the column space of a matrix) through five operations on the input space: 1. Dimensional increase / decrease; 2. Magnification / reduction; 3. Rotation; 4. Translation; 5. "Bending". Operations 1, 2, and 3 are performed by "W·x", operation 4 by "+b", and operation 5 by "a()". The term "space" is used here because the objects being classified are not individual things, but a class of things; space refers to the set of all individuals within that class. W is the weight matrix of each layer in the neural network, where each value represents the weight of a neuron in that layer. This matrix W determines the spatial transformation from the input space to the output space, meaning that the W of each layer in the neural network controls how the space is transformed. The purpose of training the neural network is to ultimately obtain the weight matrices of all layers in the trained neural network. Therefore, the training process of a neural network is essentially learning how to control spatial transformation, more specifically, learning the weight matrix.
[0089] It should be noted that, in the embodiments of this application, the models used for machine learning tasks are essentially neural networks. Common components in neural networks include convolutional layers, pooling layers, normalization layers, and deconvolutional layers. By assembling these common components in neural networks, a model is designed. When the model parameters (weight matrices of each layer) are determined such that the model error meets a preset condition or the number of model parameters is adjusted to reach a preset threshold, the model converges.
[0090] The convolutional layer is configured with multiple convolutional kernels, each with a corresponding stride, to perform convolution operations on the image. The purpose of convolution is to extract different features from the input image. The first convolutional layer may only extract some low-level features such as edges, lines, and corners, while deeper convolutional layers can iteratively extract more complex features from low-level features.
[0091] A deconvolutional layer is used to map a low-dimensional space to a high-dimensional space while preserving the connections / patterns between them (the connections during convolution). A deconvolutional layer is configured with multiple convolutional kernels, each with a corresponding stride, to perform deconvolution operations on the image. Generally, framework libraries used for designing neural networks (such as the PyTorch library) have a built-in `upsumple()` function, which allows for low-dimensional to high-dimensional spatial mapping.
[0092] Pooling layers mimic the human visual system, allowing for dimensionality reduction or representing images with higher-level features. Common pooling operations include max pooling, mean pooling, random pooling, median pooling, and combined pooling. Typically, pooling layers are periodically inserted between convolutional layers in neural networks to achieve dimensionality reduction.
[0093] The normalization layer is used to normalize all neurons in the intermediate layer to prevent gradient explosion and gradient vanishing.
[0094] (2) A loss function is a function that maps the values of a random event or its related random variables to non-negative real numbers to represent the "risk" or "loss" of that random event. The loss function is a non-negative real number function used to quantify the difference between the predicted label and the true label. In applications, the loss function is often used as a learning criterion in relation to optimization problems, i.e., solving and evaluating the model by minimizing the loss function. For example, it is used for parametric estimation in statistics and machine learning. During the training of a neural network, because we want the output of the neural network to be as close as possible to the actual predicted value, we can compare the current network's predicted value with the actual target value, and then update the weight matrix of each layer of the neural network based on the difference between the two (however, there is usually an initialization process before the first update, i.e., pre-configuring the parameters for each layer in the neural network). For example, if the network's predicted value is too high, the weight matrix is adjusted to make it predict lower, and this adjustment continues until the neural network can predict the actual target value. Therefore, it is necessary to predefine "how to compare the difference between the predicted value and the target value," which is the loss function or objective function. These are important equations used to measure the difference between the predicted value and the target value. Taking the loss function as an example, a higher output value (loss) of the loss function indicates a greater difference, so training the neural network becomes the process of minimizing this loss as much as possible.
[0095] The technical solution of this application will be described in detail below with reference to the accompanying drawings.
[0096] Please see Figure 1 , Figure 1 This is a schematic diagram of an application environment provided in an embodiment of this application;
[0097] like Figure 1 As shown, the application environment 100 includes an electronic device 10 and a server 20. The electronic device 10 is connected to the server 20 via network communication, wherein the network includes wired networks and / or wireless networks. It is understood that the network includes wireless networks such as 2G, 3G, 4G, 5G, wireless LAN, and Bluetooth, and may also include wired networks such as serial cables and network cables.
[0098] In this embodiment, the electronic device 10 is communicatively connected to the server 20 and is used to acquire image datasets, construct a feature extraction module and a multi-level image block encoding module. For example, those skilled in the art can download images of various clothing categories to the electronic device, and construct the feature extraction module and the multi-level image block encoding module. It is understood that the electronic device 10 can also be used to acquire clothing images to be predicted. For example, a user inputs a clothing image to be predicted through an input interface, and after input, the electronic device automatically acquires the clothing image to be predicted. Alternatively, the electronic device 10 may have a camera to capture clothing images, or the electronic device 10 may store a clothing image library from which the user can select a clothing image to be predicted. The electronic device in this embodiment includes, but is not limited to, various terminals with computing capabilities such as laptops, desktop computers, or mobile devices. Preferably, the electronic device is a smartphone.
[0099] In this embodiment, the server 20 is communicatively connected to the electronic device 10 and is used to train a clothing classification model, or to acquire a clothing image to be predicted input by the user on the electronic device 10, and to call the built-in clothing classification model to process the clothing image to be predicted, thereby obtaining the clothing category corresponding to the clothing image to be predicted, and then sending the clothing category to the electronic device 10. The number of servers 20 can also be multiple, and multiple servers can form a server cluster. For example, the server cluster includes: a first server, a second server, ..., an Nth server; or, the server cluster can be a cloud computing service center, which includes several servers. The servers in this embodiment include, but are not limited to: tower servers, rack servers, blade servers, and cloud servers. Preferably, the server is a cloud server (Elastic Compute Service, ECS).
[0100] It is understood that, in this embodiment of the application, the electronic device 10 is also used to display the clothing category on its own display interface after receiving the predicted clothing category sent by the server, so as to inform the user, or to locally execute the training method of the clothing classification model or the prediction method of the clothing category provided in this embodiment of the application.
[0101] Example 1
[0102] Please see Figure 2 , Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0103] like Figure 2 As shown, the electronic device 200 includes one or more processors 201 and a memory 202. Wherein, Figure 2 Take a processor 201 as an example.
[0104] The processor 201 and the memory 202 can be connected via a bus or other means. Figure 2 Taking the example of a connection between China and Israel via a bus.
[0105] Processor 201 provides computational and control capabilities to control electronic device 200 to perform corresponding tasks, such as controlling electronic device 200 to perform a training method for a clothing classification model in any of the following method embodiments, including: acquiring an image dataset, wherein the image dataset includes clothing images of multiple clothing categories; acquiring an image dataset, wherein the image dataset includes clothing images of multiple clothing categories; performing feature extraction on each clothing image based on a feature extraction module, such that the feature extraction module learns the clothing features corresponding to each clothing category of each clothing image; acquiring image patches of different clothing categories based on clothing images of multiple clothing categories; performing image patch mapping on image patches of different clothing categories based on a multi-level image patch encoding module to obtain a multi-dimensional feature vector corresponding to each image patch; constructing a contrastive cross-entropy loss function, wherein the contrastive cross-entropy loss function includes multi-class cross-entropy loss and contrastive cross-loss, wherein the contrastive cross-loss is used to characterize the correlation between feature vectors corresponding to image patches of the same clothing category, and to characterize the difference between feature vectors corresponding to image patches of different clothing categories; training the clothing classification model based on the contrastive cross-entropy loss function until the contrastive cross-entropy loss function converges, such that the feature extraction module learns the difference features between different clothing categories.
[0106] Alternatively, the control electronic device 200 executes the clothing category prediction method in any of the following method embodiments, including: acquiring a clothing image to be predicted; inputting the clothing image to be predicted into a clothing classification model to obtain the clothing category corresponding to the clothing image to be predicted, wherein the clothing classification model is trained based on the training method of the clothing classification model in any of the following method embodiments.
[0107] Processor 201 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), a hardware chip, or any combination thereof; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The aforementioned PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0108] The memory 202, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as the program instructions / modules corresponding to the training method of the clothing classification model or the prediction method of clothing categories in the embodiments of this application. The processor 201 can implement the training method of the clothing classification model or the prediction method of clothing categories in any of the following method embodiments by running the non-transitory software programs, instructions, and modules stored in the memory 202. Specifically, the memory 202 may include volatile memory (VM), such as random access memory (RAM); the memory 202 may also include non-volatile memory (NVM), such as read-only memory (ROM), flash memory, hard disk drive (HDD), solid-state drive (SSD), or other non-transitory solid-state storage devices; the memory 202 may also include combinations of the above types of memory.
[0109] Memory 202 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 202 may optionally include memory remotely located relative to processor 201, and these remote memories may be connected to processor 201 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.
[0110] One or more modules are stored in memory 202. When executed by one or more processors 201, they perform the training method of the clothing classification model or the prediction method of the clothing category in any of the following method embodiments. For example, they perform the following descriptions. Figure 3 The steps shown, or perform the following descriptions. Figure 11 The steps shown.
[0111] In the embodiments of this application, the electronic device 200 may also have wired or wireless network interfaces, input / output interfaces and other components to perform input and output. The electronic device 200 may also include other components for implementing device functions, which will not be described in detail here.
[0112] The following describes the training method of the clothing classification model provided in this application embodiment, with reference to the exemplary application and implementation of the server provided in the embodiments of this application.
[0113] Please see Figure 3 , Figure 3 This is a flowchart illustrating a training method for a clothing classification model provided in an embodiment of this application;
[0114] The training method of the clothing classification model is applied to electronic devices, such as terminals and servers. Specifically, the execution subject of the training method of the clothing classification model is one or at least two processors in the electronic device. The following uses a server as an example to illustrate the training method of the clothing classification model.
[0115] Specifically, the clothing classification model includes a feature extraction module and a multi-level image patch coding module, and the feature extraction module and the multi-level image patch coding module share network parameters;
[0116] like Figure 3 As shown, the training method for this clothing classification model includes:
[0117] Step S301: Obtain an image dataset, wherein the image dataset includes clothing images of various clothing categories;
[0118] Specifically, an image dataset is composed of clothing images belonging to different clothing categories downloaded from the Internet using an electronic device. The image dataset includes clothing images of multiple clothing categories, and the number of clothing images included in the image dataset can be in the tens of thousands, for example, 20,000, or the number of clothing images can be determined by those skilled in the art based on the actual situation.
[0119] It is understandable that there are currently many ways to classify clothing. For example, by gender, it can be divided into men's wear, women's wear, and children's wear; by combination, it can be divided into dresses, suits, coats, vests, skirts, trousers, shorts, or capri pants; by style, the above clothing can be further subdivided, for example, dresses can be divided into commuter dresses, casual dresses, or sporty dresses, etc., and so on. It is also understandable that those skilled in the art can determine the clothing categories that can be included in the image dataset according to actual needs, for example, including clothing images corresponding to 10 clothing categories, so that the trained clothing classification model can identify these 10 clothing categories.
[0120] Furthermore, after acquiring the image dataset, each clothing image in the dataset is labeled with its true clothing category, and the labeled image dataset is uploaded to the server. It can be understood that this true clothing category is the actual category of the clothing in the corresponding image. The true clothing category is equivalent to a label, which can be encoded using a hot-coding method. Hot-coding is a common technique in this field and will not be described in detail here.
[0121] Please see Figure 4 , Figure 4 This is a flowchart illustrating a method for normalizing images of clothing of multiple clothing categories provided in an embodiment of this application.
[0122] like Figure 4 As shown, after obtaining the image dataset, the method also includes:
[0123] Step S401: Adjust the size of clothing images of various clothing categories to obtain clothing images of various clothing categories with fixed sizes;
[0124] Specifically, the size of clothing images for various clothing categories is adjusted to a fixed size of 256*256, which is equivalent to unifying the size of each clothing image, for example, unifying it to a fixed size.
[0125] Step S402: Construct a normalization function to normalize clothing images of various clothing categories that have been adjusted to a fixed size.
[0126] Specifically, a normalization function is used to normalize clothing images of various clothing categories that have been adjusted to a fixed size, resulting in pixel values of the clothing images of various clothing categories after normalization. The normalization function is used to transform the range of pixel values in the clothing images from 0-255 to 0-1.
[0127] The above normalization functions include:
[0128]
[0129] Where norm is the pixel value of the clothing image after normalization, and x i Let x be the value of the i-th pixel in the clothing image, max(x) be the maximum value of the clothing image, and min() be the minimum value of the clothing image.
[0130] In this embodiment of the application, normalizing clothing images of various clothing categories helps to accelerate the training of subsequent clothing classification models.
[0131] Step S302: Based on the feature extraction module, perform feature extraction on each clothing image so that the feature extraction module learns the clothing features corresponding to each clothing category of each clothing image.
[0132] Specifically, the feature extraction module includes a basic clothing feature extraction network, which is used to extract features from each clothing image. By extracting features from each clothing image, the basic clothing feature extraction network can learn the clothing features corresponding to each clothing category in each clothing image, and these clothing features can be used to predict the clothing category.
[0133] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of a clothing basic feature extraction network provided in an embodiment of this application;
[0134] like Figure 5 As shown, the clothing basic feature extraction network includes an input layer, a convolutional layer, a fully connected layer, and a normalization layer connected in sequence. The convolutional layer includes a first convolutional layer, a second convolutional layer, a third convolutional layer, a fourth convolutional layer, a fifth convolutional layer, and a sixth convolutional layer connected in sequence.
[0135] Specifically, this basic feature extraction network for clothing mainly uses 3*3 convolutional kernels. The input layer can directly operate on the original input data. If the input is an image, the input data is the pixel values of the image. The first convolutional layer has 32 convolutional kernels, and its output feature map size is 256*256, with 32 output feature maps. The second convolutional layer has 64 convolutional kernels, and its output feature map size is 128*128, with 64 output feature maps. The third convolutional layer has 128 convolutional kernels, and its output feature map size is 64*64, with 128 output feature maps. The fourth convolutional layer... The number of convolutional kernels is 256, and the size of its output feature map is 32*32, with a total of 256 output feature maps; the number of convolutional kernels in the fifth convolutional layer is 256, and the size of its output feature map is 16*16, with a total of 256 output feature maps; the number of convolutional kernels in the sixth convolutional layer is 512, and the size of its output feature map is 8*8, with a total of 512 output feature maps; the size of the fully connected layer is 1*1024; the size of the normalization layer is 1*N, where N is the total number of clothing image categories in the image dataset, N can be 10, or can be set by those skilled in the art according to the actual situation.
[0136] In this embodiment of the application, the feature extraction module is also used to predict clothing categories, specifically, to predict the probability value corresponding to each clothing category of each clothing image.
[0137] Specifically, the output of each layer of the clothing basic feature extraction network serves as the input to the next layer connected to it. This clothing basic feature extraction network is used to extract features and classify each input clothing image. Finally, the normalization layer outputs an N-dimensional vector, which represents the probability value corresponding to each clothing category of each clothing image. For example, if the clothing categories include women's short-sleeved tops, women's long-sleeved tops, women's coats, women's skirts, women's pants, men's tops, men's pants, men's shoes, men's suits, and children's clothing, then the N-dimensional vector is [0.01, 0.01]. [02, 0.01, 0.01, 0.93, 0.01, 0.02, 0.01, 0.02, 0.01] represent the predicted probability values of the clothing images input to the clothing basic feature extraction network for each clothing category: women's short-sleeved tops, women's long-sleeved tops, women's coats, women's skirts, women's pants, men's tops, men's pants, men's shoes, men's suits, and children's clothing. The higher the value, the closer the clothing image is to that category. For example, 0.93 indicates that the probability of the clothing image being women's pants is 93%.
[0138] Please see Figure 6 , Figure 6 This is a flowchart illustrating a method for obtaining the probability value corresponding to each clothing category in a clothing image, as provided in an embodiment of this application.
[0139] like Figure 6 As shown, after obtaining the image dataset, the method also includes:
[0140] Step S601: Input the normalized clothing image into the clothing basic feature extraction network to obtain the probability value corresponding to each clothing category in the normalized clothing image.
[0141] Specifically, the normalized clothing image is input into the clothing basic feature extraction network, and the output vector of the clothing basic feature extraction network represents the predicted probability value corresponding to each clothing category in the clothing image.
[0142] Step S303: Based on clothing images of various clothing categories, obtain image blocks of different clothing categories;
[0143] Specifically, images of clothing from different clothing categories are randomly selected, and image blocks of different sizes are obtained by randomly cropping image blocks of different sizes.
[0144] Please see Figure 7 , Figure 7 yes Figure 3 A detailed flowchart of step S303 in the process;
[0145] like Figure 7 As shown, step S303 includes:
[0146] Step S3031: Determine the clothing image input to the clothing basic feature extraction network as the first clothing image, and there are at least two first clothing images;
[0147] Specifically, the clothing image input into the clothing basic feature extraction network is designated as the first clothing image. There can be at least two first clothing images, and each of the at least two first clothing images is labeled with the number X. i Where i is the category number of the clothing. For example, there are 10 clothing categories: women's short-sleeved tops, women's long-sleeved tops, women's coats, women's skirts, women's pants, men's tops, men's pants, men's shoes, men's suits, and children's clothing. The clothing category numbers from left to right can be 1-10, with the numbers increasing sequentially.
[0148] Step S3032: Capture each first garment image to obtain the first garment image block corresponding to each first garment image;
[0149] Specifically, let's assume the first clothing image is X. i For the first clothing image X i Randomly crop the first clothing image X of size H*H (H<200) iThe corresponding first clothing image block is labeled as V. If multiple first clothing images are cropped separately, then each first clothing image X is... i The corresponding image patch is labeled V i It is understandable that the length and width of the first clothing image block obtained by randomly cropping the first clothing image are the same.
[0150] Step S3033: Determine at least two second clothing images, wherein the second clothing images belong to the same clothing category as the first clothing image;
[0151] Specifically, select the first clothing image X i Images of clothing belonging to the same clothing category C i There can be multiple second clothing images. It is understood that the number of second clothing images is greater than or equal to the number of first clothing images; for example, one first clothing image corresponds to one or at least two second clothing images.
[0152] Step S3034: Capture each second garment image to obtain the second garment image block corresponding to each second garment image.
[0153] Specifically, regarding the second clothing image C i Randomly crop a second clothing image C of size H*H (H<200) i The corresponding second clothing image block is labeled as V. + If multiple second clothing images are cropped separately, then each second clothing image C i The corresponding second clothing image block is labeled as It is understandable that the length and width of the second clothing image block obtained by randomly cropping the second clothing image are the same.
[0154] Please see Figure 8 , Figure 8 yes Figure 3 Another detailed flowchart of step S303 in the process;
[0155] like Figure 8 As shown, step S303 further includes:
[0156] Step S3035: Determine at least two third clothing images, wherein the third clothing images do not belong to the same clothing category as the first clothing image;
[0157] Specifically, select the first clothing image X i Different categories of clothing images as third clothing images D tWhere t can be 1, 2, ..., n, and n is the number of third clothing images. It is understood that the number of third clothing images is greater than or equal to the number of first clothing images; for example, one first clothing image corresponds to one or at least two third clothing images.
[0158] Step S3036: Extract each third clothing image to obtain the third clothing image block corresponding to each third clothing image.
[0159] Specifically, let's assume the third clothing image is D. t Then for the third clothing image D t Randomly crop a third clothing image D of size H*H (H<200) t The corresponding third clothing image block is labeled as V. - If multiple third clothing images are cropped separately, then each third clothing image D will be... t The corresponding image patch is labeled as
[0160] Step S304: Based on the multi-level image block coding module, perform image block mapping on image blocks of different clothing categories to obtain the multi-dimensional feature vector corresponding to each image block;
[0161] Specifically, the feature extraction module includes a basic clothing feature extraction network, which is used to extract features from each clothing image. The multi-level image patch coding module includes a multi-level image patch coding network, which is used to map image patches of different clothing categories to obtain a multi-dimensional feature vector corresponding to each image patch.
[0162] In this embodiment, network parameters are shared between the feature extraction module and the multi-level image patch coding module. For details, please refer to [link to relevant documentation]. Figure 9 , Figure 9 This is a schematic diagram of the structure of a multi-level image block coding network provided in an embodiment of this application;
[0163] like Figure 9 As shown, the multi-level image block coding network includes a first convolutional layer, a second convolutional layer, a third convolutional layer, and a fourth convolutional layer. The first, second, and third convolutional layers of the multi-level image block coding network share network parameters with the first, second, and third convolutional layers of the clothing basic feature extraction network.
[0164] Specifically, this multi-layer image patch coding network mainly uses 3*3 convolutional kernels. The first convolutional layer has 32 kernels, and its output feature map has a size of (H / 2)*(H / 2) and a number of output feature maps of 32, where H is the size of the image patch obtained above. The second convolutional layer has 64 kernels, and its output feature map has a size of (H / 4)*(H / 4) and a number of output feature maps of 64. The third convolutional layer has 128 kernels, and its output feature map has a size of (H / 8)*(H / 8) and a number of output feature maps of 128. The fourth convolutional layer has a size of 1*1.
[0165] Understandably, the first, second, third, and fourth convolutional layers of this multi-level image patch coding network are connected sequentially, with the output of each layer serving as the input to the next layer. The output of this multi-level image patch coding network is a K-dimensional feature vector, where K is a positive integer. During the training of the clothing classification model, the value of K is dynamically adjusted according to the classification accuracy of the clothing classification model, or it can be adjusted manually.
[0166] In this embodiment, the first, second, and third convolutional layers of the multi-level image patch coding network share the parameters of the convolutional kernels with the first, second, and third convolutional layers of the clothing basic feature extraction network. This multi-level image patch coding network is designed for assisted learning. Without increasing the cost of annotation, it can assist the clothing basic feature extraction network in learning the features of clothing itself, and further strengthen the unique feature information of each type of clothing and the feature information that distinguishes it from other clothing through comparative learning, thereby improving the accuracy of clothing classification.
[0167] Please see Figure 10 , Figure 10 This is a flowchart illustrating a method for obtaining a multidimensional feature vector corresponding to each image block, as provided in an embodiment of this application.
[0168] like Figure 10 As shown, based on the multi-level image patch coding module, image patches of different clothing categories are mapped to obtain a multi-dimensional feature vector corresponding to each image patch, including:
[0169] Step S1001: Input at least two first clothing image blocks into the multi-level image block encoding module to obtain the multi-dimensional feature vector corresponding to each first clothing image block;
[0170] Specifically, let's assume the first clothing image is X. i X, the first clothing image i The corresponding first clothing image block V is input into the multi-level image block encoding module to obtain the multi-dimensional feature vector V corresponding to the first clothing image block V.K Furthermore, if multiple first clothing images are captured, then each first clothing image X i The corresponding first clothing image block V i The first clothing image block V is obtained by inputting it into the multi-level image block encoding module. i Corresponding multidimensional feature vector
[0171] Step S1002: Input at least two second clothing image blocks into the multi-level image block encoding module to obtain the multi-dimensional feature vector corresponding to each second clothing image block;
[0172] Specifically, let's assume the second clothing image is C. i The second clothing image C i The corresponding second clothing image block V + The second clothing image block V is obtained by inputting it into the multi-level image block encoding module. + The corresponding multidimensional feature vector V K+ Furthermore, if multiple second clothing images are captured, then each second clothing image C... i The corresponding second clothing image block The second clothing image block V is obtained by inputting it into the multi-level image block encoding module. i Corresponding multidimensional feature vector
[0173] It is understandable that, since the second clothing image and the first clothing image belong to the same clothing category, the multidimensional feature vector V corresponding to block V of the first clothing image is... K In terms of the second clothing image block V + The corresponding multidimensional feature vector V K + This is a positive sample.
[0174] Step S1003: Input at least two third clothing image blocks into the multi-level image block encoding module to obtain the multi-dimensional feature vector corresponding to each third clothing image block.
[0175] Specifically, let's assume the third clothing image is D. t The third clothing image D t The corresponding third clothing image block V - The third clothing image block V is obtained by inputting it into the multi-level image block encoding module. - The corresponding multidimensional feature vector V K- Furthermore, if multiple third clothing images are captured, then each third clothing image D... t The corresponding third clothing image block The third clothing image block V is obtained by inputting it into the multi-level image block encoding module. iCorresponding multidimensional feature vector
[0176] It is understandable that, since the third clothing image and the first clothing image belong to the same clothing category, the multidimensional feature vector V corresponding to block V of the first clothing image is... K In terms of the third clothing image block V - The corresponding multidimensional feature vector V K- This is a negative sample.
[0177] Step S305: Construct the contrastive cross-entropy loss function, which includes multi-class cross-entropy loss and contrastive cross loss. The contrastive cross loss is used to characterize the correlation between feature vectors corresponding to image patches of the same clothing category, and to characterize the difference between feature vectors corresponding to image patches of different clothing categories.
[0178] Specifically, a contrastive cross-entropy loss function is constructed and used to train the clothing classification model. The parameters of the clothing classification model are adjusted until the contrastive cross-entropy loss function converges. The clothing classification model at this point is taken as the trained clothing classification model. It can be understood that convergence means that under a certain model parameter, the sum of the differences between each real clothing category in the image dataset and the clothing category predicted based on the clothing classification model is less than a preset threshold or fluctuates within a certain range.
[0179] Specifically, the multi-class cross-entropy loss is used to characterize the loss between the true probability and the predicted probability of a clothing category. This multi-class cross-entropy loss includes:
[0180]
[0181] Among them, L cls For multi-class cross-entropy loss, n is the total number of clothing categories, y i S represents the true probability value of the i-th clothing category. i Let be the predicted probability value for the i-th clothing category.
[0182] Furthermore, the output vector of the clothing basic feature extraction network is used as the input to the calculation formula of the multi-class cross-entropy loss, and the multi-class cross-entropy loss is calculated through the above formula.
[0183] Specifically, the contrastive cross loss is used to characterize the correlation between feature vectors corresponding to image patches of the same clothing category, and to characterize the differences between feature vectors corresponding to image patches of different clothing categories. This contrastive cross loss includes:
[0184]
[0185] Among them, L conTo compare the cross loss, V K V is the multidimensional feature vector corresponding to the first clothing image patch. K+ Let V be the multidimensional feature vector corresponding to the second clothing image patch, where τ is the scaling parameter, n is the total number of clothing categories, and V is the multidimensional feature vector. K- This is the multidimensional feature vector corresponding to the third clothing image patch.
[0186] Furthermore, the method for calculating the contrastive cross loss involves mapping image patches to K-dimensional feature vectors and calculating the multi-dimensional feature vector V corresponding to the first clothing image patch V. K With the second clothing image block V + The corresponding multidimensional feature vector V K+ The correlation between them, where exp(V k *V K+ *τ) represents the multidimensional feature vector V corresponding to the first clothing image block V. K With the second clothing image block V + The corresponding multidimensional feature vector V K+ The correlation between them, and the calculation of the multidimensional feature vector V corresponding to the first clothing image patch V. K With the third clothing image block V - The corresponding multidimensional feature vector V K- The difference, that is, the contrast difference, in which, The multidimensional feature vector V represents the first clothing image patch V. K With the third clothing image block V - The corresponding multidimensional feature vector V K- The difference, the scaling parameter τ represents the second clothing image block V + The corresponding multidimensional feature vector V K+ The probability of being selected, for example: τ is set to 0.5, 1, etc.
[0187] Understandably, this contrastive cross-loss integrates the multi-dimensional feature vector V corresponding to the first clothing image patch V. K With the second clothing image block V + The corresponding multidimensional feature vector V K+ The correlation between them and the multidimensional feature vector V corresponding to the first clothing image patch V K With the third clothing image block V - The corresponding multidimensional feature vector V K- The differences between feature vectors can be compared to comprehensively identify the correlations and differences between them, enabling the feature extraction module to better learn the features of clothing within the same clothing category as well as the differences between different clothing categories.
[0188] Furthermore, the contrastive cross-entropy loss function is used to calculate the contrastive cross-entropy loss, specifically using the following formula:
[0189]
[0190] Where Loss is the contrastive cross-entropy loss, L cls For multi-class cross-entropy loss, n is the total number of clothing categories, y i S represents the true probability value of the i-th clothing category. i Let L be the predicted probability value for the i-th clothing category. con To compare the cross loss, V K V is the multidimensional feature vector corresponding to the first clothing image patch. K+ Let V be the multidimensional feature vector corresponding to the second clothing image patch, where τ is the scaling parameter, n is the total number of clothing categories, and V is the multidimensional feature vector. K- This is the multidimensional feature vector corresponding to the third clothing image patch.
[0191] Step S306: Train the clothing classification model based on the contrastive cross-entropy loss function until the contrastive cross-entropy loss function converges, so that the feature extraction module learns the difference features between different clothing categories.
[0192] For details, please refer to [link / reference]. Figure 11 , Figure 11 This is a schematic diagram of the training process of a clothing classification model provided in an embodiment of this application;
[0193] like Figure 11 As shown, the training process for this clothing classification model includes:
[0194] Step S1101: Construct a clothing classification model;
[0195] Specifically, the clothing classification model includes a feature extraction module and a multi-level image block encoding module. For details, please refer to the above embodiments, which will not be repeated here.
[0196] Step S1102: Construct the contrastive cross-entropy loss function;
[0197] Specifically, the contrastive cross-entropy loss function includes multi-class cross-entropy loss and contrastive cross-entropy loss. This contrastive cross-entropy loss function is used to calculate the contrastive cross-entropy loss, which is the sum of the multi-class cross-entropy loss and the contrastive cross-entropy loss.
[0198] Step S1103: Iteratively train the clothing classification model based on the contrastive cross-entropy loss function;
[0199] Specifically, the contrastive cross-entropy loss function includes multi-class cross-entropy loss and contrastive cross-entropy loss. By utilizing the image dataset, the image dataset is processed, and then the clothing classification model is iteratively trained based on the constructed contrastive cross-entropy loss function.
[0200] Step S1104: Is the number of iterations greater than the threshold for the first iteration?
[0201] This application uses the Adam algorithm (Adaptive Moment Estimation Algorithm) to optimize model parameters. For example, the number of iterations is set to 500, the initial learning rate is set to 0.001, the weight decay is set to 0.0005, and the learning rate decays to 1 / 10 of its original value every 50 iterations.
[0202] Specifically, the Adam algorithm is used to optimize the model parameters. For example, the number of iterations is set to 10,000, the initial learning rate is set to 0.001, and the learning rate weight decay is set to 0.0005. Every 1,000 iterations, the learning rate decays to 1 / 10 of its original value. The learning rate and the difference between the real clothing categories and their corresponding predicted clothing categories in the image dataset can be input into the Adam algorithm to obtain the adjusted model parameters output by the Adam algorithm. These adjusted model parameters are then used for the next training iteration until the cross-entropy loss function converges.
[0203] Specifically, the contrastive cross-entropy loss function includes multi-class cross-entropy loss and contrastive cross-entropy loss.
[0204] The multi-class cross-entropy loss includes:
[0205]
[0206] Among them, L cls For multi-class cross-entropy loss, n is the total number of clothing categories, y i S represents the true probability value of the i-th clothing category. i Let be the predicted probability value for the i-th clothing category.
[0207] The contrastive cross-loss includes:
[0208]
[0209] Among them, L con To compare the cross loss, V K V is the multidimensional feature vector corresponding to the first clothing image patch. K+ Let V be the multidimensional feature vector corresponding to the second clothing image patch, where τ is the scaling parameter, n is the total number of clothing categories, and V is the multidimensional feature vector. K- This is the multidimensional feature vector corresponding to the third clothing image patch.
[0210] It is understandable that the convergence of the contrastive cross-entropy loss function refers to the convergence of the sum of the multi-class cross-entropy loss and the contrastive cross-entropy loss.
[0211] For multi-class cross-entropy loss L cls In this case, the smaller the product of the true probability value and the predicted probability value, the smaller the value of the multi-class cross-entropy loss.
[0212] For the comparison cross loss L con In other words, it makes The larger the value, the greater the crossover loss L. con The smaller the value, that is, the more V K *V K- The larger the value of τ, the greater the comparison cross-loss L. con The smaller the value, the better, since the scaling parameter τ is a fixed value, the more the multidimensional feature vector V corresponding to the first clothing image block... K The multidimensional feature vector V corresponding to the third clothing image patch K- The larger the vector product, the greater the comparison cross-loss L. con The smaller the value.
[0213] If the cross-entropy loss function converges, it indicates that the clothing classification model has been trained successfully. The model parameters of the clothing classification model at this point are then output, thus obtaining the trained clothing classification model.
[0214] Understandably, the Adam algorithm (Adaptive Moment Estimation Algorithm) can be seen as a combination of the momentum method and the RMSprop algorithm. It not only uses momentum as a parameter to update the direction, but also can adaptively adjust the learning rate.
[0215] Specifically, it checks whether the number of iterations is greater than the first threshold, which is preset, for example, to 500. If the number of iterations is greater than the first threshold, proceed to step S1106: training complete; if the number of iterations is not greater than the first threshold, proceed to step S1105: whether the loss of the clothing classification model is less than the first loss threshold.
[0216] It is understandable that the threshold for the first count can be set according to specific needs, and no restrictions are imposed here.
[0217] Step S1105: Is the loss of the clothing classification model less than the first loss threshold?
[0218] Specifically, determine whether the loss of the clothing classification model is less than the first loss threshold. If yes, proceed to step S1106: training complete; otherwise, return to step S1103: iteratively train the clothing classification model based on the comparative cross-entropy loss function.
[0219] In the embodiments of this application, the first loss threshold can be set to 0.0005 or 0.001. It is understood that the first loss threshold can be set according to specific needs and is not limited here.
[0220] Step S1106: Training complete;
[0221] Understandably, after training is complete, a trained clothing classification model is obtained. At this point, the clothing category corresponding to the clothing image to be predicted can be predicted by calling this trained clothing classification model.
[0222] In this embodiment, by constructing a contrastive cross-entropy loss function and training the clothing classification model based on the contrastive cross-entropy loss function until the contrastive cross-entropy loss function converges, the clothing classification model can better learn clothing classification and clothing difference comparison, especially strengthening the learning of clothing differentiation features and improving the accuracy of clothing classification.
[0223] After training the clothing classification model using the training method provided in this application, the clothing classification model can be used to predict the clothing category of a clothing image. The clothing category prediction method provided in this application can be implemented by various types of electronic devices with computing power, such as smart terminals and servers.
[0224] In this embodiment, a training method for a clothing classification model is provided. The clothing classification model includes a feature extraction module and a multi-level image patch encoding module, wherein the feature extraction module and the multi-level image patch encoding module share network parameters. The method includes: acquiring an image dataset, wherein the image dataset includes clothing images of multiple clothing categories; performing feature extraction on each clothing image based on the feature extraction module, so that the feature extraction module learns the clothing features corresponding to each clothing category of each clothing image; acquiring image patches of different clothing categories based on the clothing images of multiple clothing categories; performing image patch mapping on the image patches of different clothing categories based on the multi-level image patch encoding module to obtain a multi-dimensional feature vector corresponding to each image patch; constructing a contrastive cross-entropy loss function, which includes multi-class cross-entropy loss and contrastive cross-loss, wherein the contrastive cross-loss is used to characterize the correlation between feature vectors corresponding to image patches of the same clothing category, and to characterize the difference between feature vectors corresponding to image patches of different clothing categories; training the clothing classification model based on the contrastive cross-entropy loss function until the contrastive cross-entropy loss function converges, so that the feature extraction module learns the difference features between different clothing categories.
[0225] On the one hand, by acquiring image patches of different clothing categories, the image patches of different clothing categories are mapped based on the multi-level image patch coding module to obtain the multi-dimensional feature vector corresponding to each image patch, so that the multi-level image patch coding module can learn the difference features between different clothing categories.
[0226] On the other hand, by sharing network parameters between the feature extraction module and the multi-level image patch encoding module, the clothing classification model is trained based on the contrastive cross-entropy loss function. This contrastive cross-entropy loss function includes contrastive cross-loss, which is used to characterize the correlation between feature vectors corresponding to image patches of the same clothing category, and to characterize the differences between feature vectors corresponding to image patches of different clothing categories. This allows the multi-level image patch encoding module to apply the learned difference features between different clothing categories to the feature extraction module, enabling the feature extraction module to learn the clothing features corresponding to each clothing category and the difference features between different clothing categories. This application can enhance the learning of clothing differentiation features without increasing additional annotation costs, thereby improving the accuracy of clothing classification.
[0227] Example 2
[0228] After training the clothing classification model using the method provided in the above embodiments, a trained clothing classification model is obtained, which can be used to predict clothing categories.
[0229] It is understood that the above embodiment one is the training stage of the clothing classification model, and embodiment two of this application is the prediction stage of the clothing classification model. The prediction stage requires the use of the feature extraction module to predict the clothing category in order to obtain the clothing category corresponding to the clothing image to be predicted.
[0230] The following describes the clothing category prediction method provided in this application embodiment, with reference to exemplary applications and implementations of the terminal provided in the embodiments of this application.
[0231] Please see Figure 12 , Figure 12 This is a flowchart illustrating a method for predicting clothing categories provided in an embodiment of this application;
[0232] like Figure 12 As shown, the prediction method for this clothing category includes:
[0233] Step S1201: Obtain the image of the clothing to be predicted;
[0234] Specifically, the electronic device acquires the image of the clothing to be predicted. For example, the user inputs the image of the clothing to be predicted through an input interface, and after the input is completed, the electronic device automatically acquires the image of the clothing to be predicted. Alternatively, the electronic device has a camera that captures clothing images. Or, the electronic device stores a clothing image library, from which the user can select the image of the clothing to be predicted. Or, the electronic device receives the image of the clothing to be predicted uploaded by the user through the network.
[0235] Step S1202: Input the clothing image to be predicted into the clothing classification model to obtain the clothing category corresponding to the clothing image to be predicted. The clothing classification model is trained based on the training method of the above clothing classification model.
[0236] Specifically, the clothing image to be predicted is input into the trained clothing classification model to obtain the prediction result output by the clothing classification model, which includes the clothing category corresponding to the clothing image to be predicted.
[0237] It is understood that this clothing classification model is trained using the training method of the clothing classification model in the above embodiments, and has the same structure and function as the clothing classification model in the above embodiments, which will not be described in detail here.
[0238] Please see Figure 13 , Figure 13 yes Figure 12 A detailed flowchart of step S1202 in the process;
[0239] like Figure 13 As shown, step S1202 includes:
[0240] Step S12021: Based on the feature extraction module, obtain the probability value corresponding to each clothing category of the clothing image to be predicted;
[0241] Specifically, the clothing classification model includes a feature extraction module, which includes a clothing basic feature extraction network. The clothing image to be predicted is passed through the clothing basic feature extraction network, and the predicted probability value corresponding to each clothing category of the clothing image is output.
[0242] Step S12022: Determine the clothing category with the highest probability value as the clothing category corresponding to the clothing image to be predicted.
[0243] Specifically, the higher the predicted probability value, the closer the clothing category of the clothing image is to that category. The clothing category with the highest predicted probability value is determined as the clothing category corresponding to the clothing image to be predicted.
[0244] In this embodiment of the application, by inputting the clothing image to be predicted into a pre-trained clothing classification model, the clothing category corresponding to the clothing image to be predicted is obtained. The clothing category with the highest probability value is determined as the clothing category corresponding to the clothing image to be predicted, which can more accurately obtain the predicted clothing category of the clothing image.
[0245] Example 3
[0246] Please see Figure 14 , Figure 14 This is a schematic diagram of the structure of a training device for a clothing classification model provided in an embodiment of this application;
[0247] The training device for the clothing classification model is applied to an electronic device; specifically, the training device for the clothing classification model is applied to one or at least two processors of the electronic device.
[0248] The clothing classification model includes a feature extraction module and a multi-level image block encoding module, wherein the feature extraction module and the multi-level image block encoding module share network parameters.
[0249] like Figure 14 As shown, the training device 140 for the clothing classification model includes:
[0250] The acquisition unit 141 is used to acquire an image dataset, wherein the image dataset includes clothing images of various clothing categories;
[0251] The feature extraction unit 142 is used to extract features from each clothing image based on the feature extraction module, so that the feature extraction module learns the clothing features corresponding to each clothing category of each clothing image.
[0252] Image block unit 143 is used to obtain image blocks of different clothing categories based on clothing images of multiple clothing categories;
[0253] Feature vector unit 144 is used to perform image block mapping on image blocks of different clothing categories based on the multi-level image block coding module, so as to obtain the multi-dimensional feature vector corresponding to each image block;
[0254] Loss function unit 145 is used to construct the contrastive cross-entropy loss function, which includes multi-class cross-entropy loss and contrastive cross loss. The contrastive cross loss is used to characterize the correlation between feature vectors corresponding to image patches of the same clothing category, and to characterize the difference between feature vectors corresponding to image patches of different clothing categories.
[0255] Training unit 146 is used to train the clothing classification model based on the contrastive cross-entropy loss function until the contrastive cross-entropy loss function converges, so that the feature extraction module learns the difference features between different clothing categories.
[0256] In the embodiments of this application, the training device for the clothing classification model can also be built from hardware devices. For example, the training device for the clothing classification model can be built from one or more chips, and the chips can work together to complete the training method for the clothing classification model described in the above embodiments. As another example, the training device for the clothing classification model can also be built from various logic devices, such as general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), microcontrollers, ARM processors (Advanced RISC Machines) or other programmable logic devices, discrete gate or transistor logic, discrete hardware components, or any combination of these components.
[0257] The training device for the clothing classification model in this application embodiment can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network-attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This application embodiment does not impose specific limitations.
[0258] The training device for the clothing classification model in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.
[0259] The training device for the clothing classification model provided in this application embodiment can achieve... Figure 3To avoid repetition, the various processes involved will not be described in detail here.
[0260] It should be noted that the training device for the clothing classification model described above can execute the training method for the clothing classification model provided in the above embodiments, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in the embodiments of the clothing classification model training device can be found in the training method for the clothing classification model provided in the above embodiments.
[0261] In this embodiment, a training device for a clothing classification model is provided. The clothing classification model includes a feature extraction module and a multi-level image patch encoding module, wherein the feature extraction module and the multi-level image patch encoding module share network parameters. The training device for the clothing classification model includes: an acquisition unit for acquiring an image dataset, wherein the image dataset includes clothing images of multiple clothing categories; a feature extraction unit for extracting features from each clothing image based on the feature extraction module, so that the feature extraction module learns the clothing features corresponding to each clothing category of each clothing image; an image patch unit for acquiring image patches of different clothing categories based on clothing images of multiple clothing categories; and a feature mapping module. The feature extraction unit is used to map image patches of different clothing categories based on the multi-level image patch encoding module to obtain the multi-dimensional feature vector corresponding to each image patch. The loss function unit is used to construct the contrastive cross-entropy loss function, which includes multi-class cross-entropy loss and contrastive cross-loss. The contrastive cross-loss is used to characterize the correlation between feature vectors corresponding to image patches of the same clothing category, and to characterize the difference between feature vectors corresponding to image patches of different clothing categories. The training unit is used to train the clothing classification model based on the contrastive cross-entropy loss function until the contrastive cross-entropy loss function converges, so that the feature extraction module learns the difference features between different clothing categories.
[0262] On the one hand, by acquiring image patches of different clothing categories, the image patches of different clothing categories are mapped based on the multi-level image patch coding module to obtain the multi-dimensional feature vector corresponding to each image patch, so that the multi-level image patch coding module can learn the difference features between different clothing categories.
[0263] On the other hand, by sharing network parameters between the feature extraction module and the multi-level image patch encoding module, the clothing classification model is trained based on the contrastive cross-entropy loss function. This contrastive cross-entropy loss function includes contrastive cross-loss, which is used to characterize the correlation between feature vectors corresponding to image patches of the same clothing category, and to characterize the differences between feature vectors corresponding to image patches of different clothing categories. This allows the multi-level image patch encoding module to apply the learned difference features between different clothing categories to the feature extraction module, enabling the feature extraction module to learn the clothing features corresponding to each clothing category and the difference features between different clothing categories. This application can enhance the learning of clothing differentiation features without increasing additional annotation costs, thereby improving the accuracy of clothing classification.
[0264] Example 4
[0265] Please see Figure 15 , Figure 15 This is a schematic diagram of the structure of a clothing category prediction device provided in an embodiment of this application;
[0266] like Figure 15 As shown, the prediction device 150 for this clothing category includes:
[0267] Image acquisition unit 151 is used to acquire an image of the clothing to be predicted;
[0268] The clothing category prediction unit 152 is used to input the clothing image to be predicted into the clothing category prediction model to obtain the clothing category corresponding to the clothing image to be predicted. The clothing category prediction model is trained based on the training method of the clothing classification model provided in the above embodiment.
[0269] In this embodiment, the clothing category prediction device can also be constructed from hardware devices. For example, the clothing category prediction device can be constructed from one or more chips, and the chips can work in coordination to complete the clothing category prediction method described in the above embodiments. As another example, the clothing category prediction device can also be constructed from various logic devices, such as general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), microcontrollers, ARM (Acorn RISC Machine) or other programmable logic devices, discrete gate or transistor logic, discrete hardware components, or any combination of these components.
[0270] The clothing category prediction device in this application embodiment can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network-attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This application embodiment does not impose specific limitations.
[0271] The clothing category prediction device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit it.
[0272] The clothing category prediction device provided in this application embodiment can achieve Figure 12 To avoid repetition, the various processes involved will not be described in detail here.
[0273] It should be noted that the above-described clothing category prediction device can execute the clothing category prediction method provided in the above embodiments, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in the clothing category prediction device embodiments can be found in the clothing category prediction method provided in the above embodiments.
[0274] In this embodiment of the application, a clothing category prediction device is provided, comprising: an image acquisition unit for acquiring a clothing image to be predicted; and a clothing category prediction unit for inputting the clothing image to be predicted into a clothing category prediction model to obtain the clothing category corresponding to the clothing image to be predicted, wherein the clothing category prediction model is trained based on the training method of the clothing classification model provided in the above embodiment.
[0275] By sharing network parameters between the feature extraction module and the multi-level image patch encoding module, image patches of different clothing categories are obtained. Image patch encoding feature vectors are extracted based on the multi-level image patch encoding module. The clothing classification model is trained based on the contrastive cross-entropy loss function. Through the parameter sharing mechanism and the use of contrastive cross-entropy loss, the multi-level image patch encoding module focuses on learning the clothing differentiation features. Then, by utilizing the sharing mechanism, the learned clothing differentiation features are applied to the feature extraction module, allowing the feature extraction module to learn the differentiation features. This application can enhance the learning of clothing differentiation features without increasing additional annotation costs, thereby improving the accuracy of clothing classification.
[0276] Example 5
[0277] This application embodiment also provides a computer-readable storage medium storing computer-executable instructions for causing an electronic device to execute the training method of the clothing classification model provided in the above embodiments, for example, such as... Figure 3 The training method for the clothing classification model shown, or the prediction method for clothing categories provided in the above embodiments, for example, such as... Figure 12 The prediction method for the clothing categories shown.
[0278] In the embodiments of this application, the storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a device including one or any combination of the above-mentioned memories.
[0279] In the embodiments of this application, the executable instructions may take the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including being deployed as a standalone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0280] As an example, executable instructions may, but do not necessarily, correspond to files in the file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple collaborative files (e.g., a file that stores one or more modules, subroutines, or code sections).
[0281] As an example, executable instructions can be deployed to execute on a single computing device (including devices such as smart terminals and servers), or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.
[0282] This application also provides a computer-readable storage medium storing a computer program, which includes program instructions. When executed by an electronic device, the program instructions cause the electronic device to perform a training method for a clothing classification model or a prediction method for clothing categories as described in the above embodiments.
[0283] This application also provides a computer program product comprising one or more lines of program code stored in a computer-readable storage medium. The processor of an electronic device reads the program code from the computer-readable storage medium and executes the program code to complete the method steps of the training method for the clothing classification model or the prediction method for clothing categories provided in the above embodiments.
[0284] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware, or by a program or program code related to hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0285] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software and a general-purpose hardware platform, or of course, using hardware. Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0286] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them; under the concept of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of this application as described above. For the sake of brevity, they are not provided in detail; although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A training method for a clothing classification model, characterized in that, The clothing classification model includes a feature extraction module and a multi-level image patch encoding module. The feature extraction module and the multi-level image patch encoding module share network parameters. The feature extraction module includes a basic clothing feature extraction network, which comprises an input layer, a first convolutional layer, a second convolutional layer, a third convolutional layer, a fourth convolutional layer, a fifth convolutional layer, a sixth convolutional layer, a fully connected layer, and a normalization layer, connected sequentially. The multi-level image patch encoding module includes a multi-level image patch encoding network, which comprises a first convolutional layer, a second convolutional layer, and a third convolutional layer. The first, second, and third convolutional layers of the multi-level image patch encoding network share network parameters with the first, second, and third convolutional layers of the basic clothing feature extraction network. The method includes: Obtain an image dataset, wherein the image dataset includes clothing images of various clothing categories; Based on the feature extraction module, feature extraction is performed on each of the clothing images, so that the feature extraction module learns the clothing features corresponding to each clothing category of each clothing image. Based on clothing images of various clothing categories, obtain image blocks of different clothing categories; Based on the multi-level image block encoding module, image block mapping is performed on the image blocks of the different clothing categories to obtain the multi-dimensional feature vector corresponding to each image block; Construct a contrastive cross-entropy loss function, which includes multi-class cross-entropy loss and contrastive cross loss. The contrastive cross loss is used to characterize the correlation between feature vectors corresponding to image patches of the same clothing category, and to characterize the difference between feature vectors corresponding to image patches of different clothing categories. The clothing classification model is trained based on the contrastive cross-entropy loss function until the contrastive cross-entropy loss function converges, so that the feature extraction module learns the difference features between different clothing categories. The step of obtaining image blocks of different clothing categories based on clothing images of multiple clothing categories includes: The clothing image input into the clothing basic feature extraction network is determined to be the first clothing image, and there are at least two first clothing images; Each of the first clothing images is cropped to obtain a first clothing image block corresponding to each of the first clothing images; Identify at least two second clothing images, wherein the second clothing images belong to the same clothing category as the first clothing image; Extract each of the second clothing images to obtain the second clothing image block corresponding to each second clothing image; The step of obtaining image blocks of different clothing categories based on clothing images of multiple clothing categories further includes: Identify at least two third clothing images, wherein the third clothing images do not belong to the same clothing category as the first clothing image; Each of the third clothing images is cropped to obtain a third clothing image block corresponding to each of the third clothing images.
2. The method according to claim 1, characterized in that, After acquiring the image dataset, the method further includes: Adjust the size of clothing images of various clothing categories to obtain clothing images of various clothing categories with fixed sizes; Construct a normalization function to normalize clothing images of various clothing categories that have been adjusted to a fixed size; The normalization function includes: in, These are the pixel values of the clothing image after normalization. Let i be the value of the i-th pixel in the clothing image. The maximum pixel value of the clothing image. This represents the minimum pixel value of the clothing image.
3. The method according to claim 2, characterized in that... The method further includes: The clothing image after the normalization operation is input into the clothing basic feature extraction network to obtain the probability value corresponding to each clothing category in the clothing image after the normalization operation.
4. The method according to claim 1, characterized in that, The multi-level image block encoding module performs image block mapping on image blocks of different clothing categories to obtain a multi-dimensional feature vector corresponding to each image block, including: At least two of the first clothing image blocks are input into the multi-level image block encoding module to obtain a multi-dimensional feature vector corresponding to each of the first clothing image blocks. At least two second clothing image blocks are input into the multi-level image block encoding module to obtain a multi-dimensional feature vector corresponding to each second clothing image block; At least two of the third clothing image blocks are input into the multi-level image block encoding module to obtain a multi-dimensional feature vector corresponding to each of the third clothing image blocks.
5. The method according to any one of claims 1-3, characterized in that, The multi-class cross-entropy loss is used to characterize the loss between the true probability and the predicted probability of a clothing category. The multi-class cross-entropy loss includes: in, For multi-class cross-entropy loss, The total number of clothing categories. Let be the true probability value of the i-th clothing category. Let be the predicted probability value for the i-th clothing category.
6. The method according to any one of claims 1-3, characterized in that, The contrastive cross loss includes: in, To compare the cross loss, This is the multidimensional feature vector corresponding to the first clothing image patch. This is the multidimensional feature vector corresponding to the second clothing image patch. For proportional parameters, The total number of clothing categories. This is the multidimensional feature vector corresponding to the third clothing image patch.
7. A method for predicting clothing categories, characterized in that, The method includes: Obtain the image of the clothing to be predicted; The clothing image to be predicted is input into the clothing classification model to obtain the clothing category corresponding to the clothing image to be predicted, wherein the clothing classification model is trained based on the method described in any one of claims 1-6.
8. The method according to claim 7, characterized in that, The step of inputting the clothing image to be predicted into the clothing classification model to obtain the clothing category corresponding to the clothing image to be predicted includes: Based on the feature extraction module, the probability value corresponding to each clothing category of the clothing image to be predicted is obtained; The clothing category with the highest probability value is determined as the clothing category corresponding to the clothing image to be predicted.
9. An electronic device, characterized in that, include: At least one processor, and The memory communicatively connected to the at least one processor, wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1-8.
Citation Information
Patent Citations
Method for training clothes classification model, clothes classification method and related device
CN114821244A
Image classification method, computer device, and computer-readable storage medium
US20200250491A1