Classification and classification model training method, device and storage medium
By normalizing the weight vector of the classification model, the problem of a wide variety of product images and uneven training samples in video accounts or live broadcasts is solved, and the accurate identification of products in short videos and the identification of long-tail products are achieved. Effective learning improves recognition accuracy.
Patent Information
- Application Number
- CN202210813655.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-11
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2042-07-11
AI Technical Summary
In video account products or live streaming, due to the wide variety of product images and uneven training samples, the general classification model cannot accurately classify the products in short videos, especially the recognition effect of long-tail products is poor.
By normalizing the weight vector of the classification model during the training process, the impact of the first data on the model weight vector is reduced, and the impact of long-tail data on the model weight vector is improved, thereby achieving training data with uneven samples. Balanced training to enhance learning of long-tail data. The specific method includes obtaining the target short video, predicting the product category through the classification model for each image, calculating the loss based on the predicted value and the real value, and updating the normalized weight vector to optimize the model.
It improves the accuracy of product identification, especially the accurate identification of long-tail products, improves the learning effect of the classification model on uneven sample data, and enhances the ability to classify long-tail products.
Smart Images

Figure CN115187809B
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a classification and classification model training method, device and storage medium. Background Art
[0002] With the development of e-commerce technology, video account products or live broadcast products include a variety of products, which need to be classified.
[0003] There are many types of commodity images, and there are often problems such as insufficient standard samples for some commodity data and uneven training samples. At this time, using a general classification model to identify the classification of commodities in short videos may result in inaccurate classification. Summary of the invention
[0004] The present application provides a classification and classification model training method, device and storage medium, which can realize accurate identification of products in short videos.
[0005] In a first aspect, the present application provides a classification method, comprising:
[0006] Obtain a target short video, and obtain N first images from the target short video, where N is a positive integer;
[0007] For each of the N first images, predicting a commodity category included in the first image by using a classification model, wherein the classification model performs normalization processing on a weight vector during training;
[0008] Recommendation information is determined according to the commodity categories included in the N first images.
[0009] In some embodiments, the classification model normalizes the weight vector during training, including:
[0010] Decomposing the weight vector to obtain a parameter vector and a parameter scalar;
[0011] The weight vector is normalized according to the parameter vector and the parameter scalar.
[0012] In some embodiments, the loss of the classification model during training is determined based on the first weight and the classification prediction value of the commodity in the training image predicted by the classification model;
[0013] The first weight is determined according to the proportion of the training data included in the sample category to which the training image belongs in the training data set, and the proportion is negatively correlated with the first weight.
[0014] In some embodiments, the loss is determined based on the first weight and a prediction value that the product in the training image belongs to a first classification, where the first classification is a true classification of the product in the training image.
[0015] In some embodiments, the loss is determined based on the first weight, the second weight, and a prediction value that the product in the training image belongs to the first category;
[0016] The second weight is determined according to the prediction value that the commodity in the training image belongs to the first category, and the second weight is negatively correlated with the prediction value that the commodity in the training image belongs to the first category.
[0017] In some embodiments, the second weight is a difference between a first value and a predicted value that the commodity in the training image belongs to the first category, and the first value is a positive number.
[0018] In some embodiments, the second weight is the rth power of the difference between the first value and the predicted value that the commodity in the training image belongs to the first category, the first value is a positive number, and r is a non-negative number.
[0019] In some embodiments, the loss is the product of the negative of the first product and a second value, where the second value is obtained by performing a logarithmic operation on the predicted value that the product belongs to the first category, and the first product is the product of the first weight and the second weight.
[0020] In a second aspect, the present application provides a classification model training method, comprising:
[0021] Acquire a training image, and classify commodities in the training image through a classification model to obtain a classification prediction value of the commodity, wherein the training image includes a commodity image frame in a short video;
[0022] Determining the loss of the classification model according to the classification prediction value of the commodity;
[0023] Normalizing the weight vector corresponding to the classification prediction value to obtain a normalized weight vector;
[0024] The normalized weight vector is updated according to the loss to obtain the trained classification model.
[0025] In a third aspect, the present application provides a classification device, comprising:
[0026] An acquisition unit, used to acquire a target short video, and acquire N first images from the target short video, where N is a positive integer;
[0027] a classification unit, configured to predict, for each of the N first images, a commodity category included in the first image by using a classification model, wherein the classification model performs normalization processing on a weight vector during training;
[0028] The recommendation unit is used to determine recommendation information according to the commodity categories included in the N first images.
[0029] In a fourth aspect, the present application provides a classification model training device, comprising:
[0030] A classification unit, used to obtain a training image, and classify the commodities in the training image through a classification model to obtain a classification prediction value of the commodities, wherein the training image includes a commodity image frame in a short video;
[0031] A loss determination unit, configured to determine the loss of the classification model according to the classification prediction value of the commodity;
[0032] A normalization unit, used to normalize the weight vector corresponding to the classification prediction value to obtain a normalized weight vector;
[0033] An updating unit is used to update the normalized weight vector according to the loss to obtain the trained classification model.
[0034] In a fifth aspect, the present application provides an electronic device, comprising a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the method in the first aspect or the second aspect.
[0035] In a sixth aspect, a chip is provided for implementing the method in any one of the first aspect or the second aspect or its respective implementations. Specifically, the chip includes: a processor for calling and running a computer program from a memory, so that a device equipped with the chip executes the method in any one of the first aspect or its respective implementations.
[0036] In a seventh aspect, a computer-readable storage medium is provided for storing a computer program, wherein the computer program enables a computer to execute the method in any one of the first or second aspects or their respective implementations.
[0037] In an eighth aspect, a computer program product is provided, comprising computer program instructions, wherein the computer program instructions enable a computer to execute the method in any one of the first or second aspects or their respective implementations.
[0038] In a ninth aspect, a computer program is provided, which, when executed on a computer, enables the computer to execute the method in any one of the first or second aspects or their respective implementations.
[0039] In summary, the present application obtains a target short video, and obtains N first images from the target short video, where N is a positive integer; for each of the N first images, a classification model is used to predict the commodity category included in the first image, wherein the classification model normalizes the weight vector during the training process; and the recommendation information is determined according to the commodity category included in the N first images. Since the classification model of the embodiment of the present application normalizes the weight vector during the training process, this can reduce the influence of the header data on the model weight vector and increase the influence of the long-tail data on the model weight vector, thereby enabling the classification model to achieve balanced training of training data with uneven samples and improve the classification model's learning of long-tail data. In this way, when using the trained classification model for commodity prediction, the long-tail commodities in the target short video can be accurately identified, thereby improving the accuracy of commodity identification. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0041] Figure 1 A schematic diagram of an application scenario involved in an embodiment of the present application;
[0042] Figure 2 A flow chart of a classification model training method provided in one embodiment of the present application;
[0043] Figure 3 Schematic diagram of different types of clothing;
[0044] Figure 4 Schematic diagram of different distributions;
[0045] FIG. 5A to FIG. 5E Schematic diagram of the network structure of different versions of EfficientNet;
[0046] Figure 6 A comparison diagram between EfficientNet and other networks and different versions of EfficientNet networks;
[0047] Figure 7 Schematic diagram of the output nodes of the classification network;
[0048] Figure 8 A schematic diagram of a classification method flow chart provided in an embodiment of the present application;
[0049] Fig. 9 This is a schematic diagram of recommendation information involved in an embodiment of the present application;
[0050] Fig.10 is a schematic block diagram of a classification device provided in one embodiment of the present application;
[0051] Fig.11 is a schematic block diagram of a classification model training device provided in one embodiment of the present application;
[0052] Fig.12 It is a schematic block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0053] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0054] It should be understood that in the embodiment of the present invention, "B corresponding to A" means that B is associated with A. In one implementation, B can be determined based on A. However, it should also be understood that determining B based on A does not mean determining B based only on A, and B can also be determined based on A and / or other information.
[0055] In the description of the present application, unless otherwise specified, “plurality” means two or more than two.
[0056] In addition, in order to clearly describe the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish the same items or similar items with substantially the same functions and effects. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit the difference.
[0057] In order to facilitate understanding of the embodiments of the present application, the relevant concepts involved in the embodiments of the present application are briefly introduced as follows:
[0058] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0059] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0060] Machine Learning (ML) is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and self-learning.
[0061] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as intelligent search, intelligent classification, etc., and has played an increasingly important role.
[0062] The embodiments of the present application use artificial intelligence technology to achieve accurate classification of commodities in short videos, for example, accurate classification of commodities in short videos.
[0063] The classification method provided in the embodiments of the present application can be applied to potential applications such as product sales through video accounts, live streaming, or video product searches.
[0064] Figure 1 A schematic diagram of an application scenario involved in an embodiment of the present application, including a terminal device 101 and a server 102.
[0065] The terminal device 101 may include but is not limited to: PC (Personal Computer), PDA (Tablet Computer), mobile phone, wearable smart device, intelligent voice interaction device, smart home appliance, vehicle-mounted terminal, etc. The device is often equipped with a display device, which may also be a display, a display screen, a touch screen, etc. The touch screen may also be a touch screen, a touch panel, etc. The display device may be used to display recommendation information, etc.
[0066] Server 102 may be one or more. When there are multiple servers 102, there are at least two servers for providing different services, and / or there are at least two servers for providing the same service, such as providing the same service in a load balancing manner, which is not limited in the embodiments of the present application. Among them, the above-mentioned server 102 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Server 102 can also become a node of the blockchain.
[0067] The terminal device 101 and the server 102 may be directly or indirectly connected via wired communication or wireless communication, which is not limited in this application.
[0068] In some embodiments, the server 102 of the embodiment of the present application can train the classification model involved in the embodiment of the present application and store the trained classification model.
[0069] In some embodiments, the classification method of the embodiment of the present application can be completed by the terminal device 101. For example, the terminal device 101 obtains the target short video, loads the classification model trained in the server 102, and predicts the classification of the commodity corresponding to the target short video through the method of the embodiment of the present application, and determines the recommendation information according to the classification of the commodity.
[0070] In some embodiments, the classification method of the embodiment of the present application can be completed by the server 102. For example, the terminal device 101 sends the target short video to the server 102, and the server 102 uses the trained classification model to identify the classification of the goods in the target short video, and determines the recommendation information according to the classification of the goods, and sends the recommendation information to the terminal device 101 for display.
[0071] In some embodiments, the classification method of the embodiment of the present application can be jointly performed by the terminal device 101 and the server 102. For example, the server 102 performs operations related to the network model, and the terminal device 101 performs other operations except the network model. Exemplarily, the terminal device 101 obtains the target short video, obtains N first images from the target short video, and sends the N first images to the server 102. The server 102 uses the classification model to predict the category of the goods included in each of the N first images. Then, according to the category of the goods, the recommended information is determined, and finally, the recommended information is sent to the terminal device 101 for display.
[0072] It should be noted that the application scenarios of the embodiments of the present application include but are not limited to Figure 1 shown.
[0073] The technical solutions of the embodiments of the present application are described in detail below through some embodiments. The following embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
[0074] First, the training process of the classification model involved in the embodiment of the present application is introduced.
[0075] Figure 2 A flowchart of a classification model training method provided in one embodiment of the present application.
[0076] The execution subject of the embodiment of the present application is a device with a model training function, such as a classification model training device. In some embodiments, the classification model training device can be a server. In some embodiments, the classification model training device can be a terminal device. In some embodiments, the classification model training device can be a system composed of a server and a terminal device. The server and the terminal device can both be understood as electronic devices, so for the sake of ease of description, the following is an example of an execution subject being an electronic device.
[0077] like Figure 2 As shown, the model training method of the embodiment of the present application includes:
[0078] S201: Acquire a training image, and classify commodities in the training image using a classification model to obtain a classification prediction value of the commodity.
[0079] The training images include product image frames in short videos.
[0080] Due to deformation, occlusion, motion blur and other reasons of the goods in the video, the image of the goods in the video is slightly different from the real image of the goods. In order to improve the classification model's accurate recognition of the classification of goods in the short video, the embodiment of the present application can use the image frames of the goods in the short video as training images to train the classification model. For example, extract image frames including the target goods from the live short video or the video account short video, and use these image frames as training images.
[0081] In some embodiments, product images in the product library may also be used as training images for the classification model.
[0082] Take clothing product identification in video accounts as an example. Figure 3It can be seen that the differences between different types of clothing may be relatively small, such as vest tops, sleeveless tops and suspender tops, while the differences within the category may be relatively large, for example, among short-sleeved tops, there are various types of women's clothing. Therefore, a good quality classification model is expected to achieve fine and accurate classification of products.
[0083] Continuing with the real scene of clothing product recognition in the video account, Figure 4 From the distribution of collected and labeled sample data shown in the figure, the training data set includes nearly 300,000 images, among which the number of head categories such as short-sleeved tops is very large, while the number of categories such as vest tops and long vests is very small. Therefore, the usual classification model is very sensitive to the distribution of samples, and generally defaults to fitting the effect of categories with more samples, and underfits the long-tail samples with fewer samples. In other words, the current classification model does not learn enough about long-tail products, and thus cannot accurately classify long-tail products. Among them, long-tail products can be understood as dusted products that are not in high demand or have poor sales.
[0084] In order to solve the problem of insufficient accuracy of commodity identification by the classification model due to insufficient long-tail samples, in an embodiment of the present application, during the training process of the classification model, the weight vector of the classification model is normalized, and then the normalized weight vector is updated and optimized according to the loss of the classification model, so as to increase the classification model's attention to long-tail samples, enhance the classification model's learning of long-tail samples, and thereby improve the classification accuracy of the classification model.
[0085] In an embodiment of the present application, the training data set includes multiple training images, and the process of training the classification model using each training image is consistent. For the sake of ease of description, the embodiment of the present application is explained using one training image as an example.
[0086] The embodiment of the present application does not limit the specific network structure of the classification model, which can be any model that can implement image classification.
[0087] In some embodiments, the backbone network of the classification model of the embodiments of the present application may be an EfficientNet.
[0088] EfficientNet is a network model based on MnasNet, which is obtained by optimizing both accuracy (ACC) and computational power (FLOPS).
[0089] For example, the structure of the first generation of EfficientNet, EfficientNet-B0, is shown in Table 1:
[0090] Table 1
[0091]
[0092] As shown in Table 1, EfficientNet-B0 consists of 9 layers. The first layer is a 3*3 convolution layer. The 2nd to 8th layers are network attention mechanism layers established by different MB convolution blocks. The last 9th layer is composed of a 1*1 convolution operation and delay, followed by a fully connected layer.
[0093] EfficientNet is a multi-dimensional hybrid model scaling method that optimizes the depth, width, and input size (i.e., resolution) of the network based on the neural network architecture to obtain a more efficient structure.
[0094] Among them, depth refers to the number of layers of the network. The deeper the network is, the richer and more complex features it can capture.
[0095] Width width, that is, the number of channels. The deeper the number of channels, the easier it is for the network to capture fine-grained features and the easier it is to train.
[0096] Resolution is the product of the length and width of the image. The higher the resolution, the less image information is lost and the better the ability to capture fine-grained patterns.
[0097] like Figure 5A As shown, Figure 5A Is the basic network, namely EfficientNet-B0. Figure 5B , Figure 5C , Figure 5C The three networks shown are Figure 5A The width, depth, and input resolution of the basic network shown are expanded, that is, a single dimension is expanded. Figure 5E The network shown is a combination of width, depth, and resolution Figure 5A The base network shown is extended to balance the three dimensions.
[0098] It should be noted that Figure 5A When scaling up the base network, increasing any dimension of network width, depth, or resolution can improve accuracy.
[0099] Figure 6 The following is a comparison diagram between EfficientNet and other networks and different versions of EfficientNet networks. Figure 6 As shown, it can be seen that EfficientNet has a significant breakthrough in accuracy compared to other networks.
[0100] Further, such as Figure 6As shown, different efficientNet versions, from B0 to BN, correspond to different model accuracy effects and model parameter scales. Theoretically, to obtain the highest model accuracy of 84%, efficientNet-B7 should be selected, but this means that the number of model parameters must reach 66M, which brings challenges to model training time and computing resources in practical applications. In this embodiment of the application, EfficientNet-B3 is selected as the classification model by comprehensively considering the acceptable product recognition accuracy and existing training resources in the video account or live broadcast scenario.
[0101] It should be noted that EfficientNet-B3 is only an example of the classification model selected in the embodiment of the present application when considering the balance between training time and model effect. The embodiment of the present application can also select other versions of EfficientNet or other types of classification models. The embodiment of the present application does not limit the specific network structure of the component model.
[0102] In some embodiments, in order to further reduce the training complexity of the model, the embodiments of the present application scale the training images to the same size. That is, in the embodiments of the present application, before the training model is input into the classification model, the size of the training image is first scaled to the target size, and then the classification model is used to classify the goods in the training image of the target size to obtain the classification prediction value of the goods.
[0103] The embodiment of the present application does not limit the specific size of scaling the training image to the target size.
[0104] Exemplarily, the target size is 300*300, that is, the embodiment of the present application uniformly scales the size of the training image to 300*300, and then inputs it into the classification model to train the classification model.
[0105] According to the above steps, the training image is input into the classification model, and the classification model predicts the classification prediction value of the commodity in the training image. Then, the following step S202 is executed.
[0106] S202: Determine the loss of the classification model according to the classification prediction value of the commodity.
[0107] The embodiment of the present application does not limit the specific method of determining the loss of the classification model based on the classification prediction value of the goods predicted by the classification model.
[0108] In a possible implementation, the loss of the classification model is determined based on the actual classification of the commodity in the training image and the classification prediction value of the commodity predicted by the classification model. For example, the loss of the classification model is determined based on the deviation between the actual classification of the commodity in the training image and the classification prediction value of the commodity predicted by the classification model.
[0109] In a possible implementation, in order to improve the model's learning of long-tail products, the above S202 includes the following steps S202-A to S202-D:
[0110] S202-A, determining the sample category to which the training image belongs;
[0111] S202-B, determining the proportion of training data included in the sample category in the training data set;
[0112] S202-C, determining a first weight according to the proportion, wherein the proportion is negatively correlated with the first weight;
[0113] S202-D: Determine the loss of the classification model according to the first weight and the classification prediction value of the commodity.
[0114] In this implementation, the weights of different types of training data are determined by determining the proportions of different types of training data in the training data set. That is, the embodiment of the present application assigns different weights to different types of training data, so as to increase the weights of training data types with less data in the training data set and reduce the weights of training data types with larger data, so that the classification model can learn about long-tail products with less data in the training data set, and then the trained classification model can accurately predict the categories of long-tail products.
[0115] When training data, prepare training data of different product types. For example, in order to identify the category of clothing products in videos or live broadcasts, collect and annotate sample data such as Figure 4 As shown. Nearly 300,000 images were collected for training, such as Figure 4 From the different types of products shown, we can see that the data volume of categories such as short-sleeved tops is large, forming head data, while the data volume of categories such as vests and long vests is small, forming long-tail data. The general classification models such as EfficientNet are very sensitive to the distribution of samples. Usually, the loss of the classification model will default to fit the effect of categories with more samples. This will make the classification model pay more attention to the types of products with more sample data during training, and ignore the types of products with less sample data, which ultimately leads to the inability of the trained classification model to accurately predict the categories of long-tail products.
[0116] In order to solve this technical problem, in the embodiment of the present application, the loss function is optimized during the model training process so that the classification model can effectively learn the long-tail data when the training samples are unevenly distributed, thereby improving the classification model's accurate prediction of the long-tail commodity category. Specifically, when determining the loss of the classification model, the weight of the long-tail data is increased to improve the classification model's learning of the long-tail data.
[0117] The specific process of determining the loss of the classification model in the embodiment of the present application is introduced below.
[0118] By the above Figure 4 It can be seen that the training data set includes different types of training data. When a training image in the training data set is used to train the classification model, the training image is input into the classification model, and the classification model predicts the category prediction value of the product in the training image. Then, according to the category prediction value, the loss of the classification model is determined, and then the parameters in the classification model are adjusted according to the loss to achieve the training of the classification model. Among them, when determining the loss of the classification model with respect to the training image, the sample category to which the training image belongs is first determined, for example, Figure 4 As shown, it is determined whether the training image belongs to a short-sleeved top or a vest top.
[0119] Next, the training data included in the sample category to which the training image belongs in the training data set is determined, and then the proportion of the training data included in the sample category in the training data set is determined.
[0120] For example, assuming that the training image is an image of a vest, in the training data set, it is determined that the training data included in the vest is assumed to be 100 images, and the training data set is assumed to have 30,000 images. In this way, it can be determined that the proportion of the training data included in the vest in the training data set is 100 / 30,000=1 / 300.
[0121] According to the above steps, the proportion of the training data included in the sample category to which the training image belongs in the training data set is determined, and then the first weight corresponding to the training image is determined according to the proportion. In the embodiment of the present application, in order to enable the classification model to fully learn long-tail products, a larger weight is assigned to long-tail products, and a smaller weight is assigned to head products. Based on this, in the embodiment of the present application, the first weight corresponding to the training image is negatively correlated with the proportion corresponding to the training image, that is, when the proportion of the training data included in the sample category to which the training image belongs in the training data set is large, it means that the product in the training image is a head product, and a smaller first weight is assigned. If the proportion of the training data included in the sample category to which the training image belongs in the training data set is small, it means that the product in the training image is a long-tail product, and a larger first weight is assigned. In other words, the larger the proportion corresponding to the training image, the smaller the first weight corresponding to the training image, and the smaller the proportion corresponding to the training image, the larger the first weight corresponding to the training image.
[0122] The embodiment of the present application does not limit the specific process of determining the first weight according to the proportion.
[0123] For example, the reciprocal of the proportion is determined as the first weight, or the reciprocals of the proportions of different types of training samples are normalized, and the reciprocals of the normalized proportions are determined as the first weights corresponding to the respective proportions.
[0124] For another example, the first weight=1-proportion.
[0125] Optionally, the first weight may be determined according to other methods, which are not limited in the embodiments of the present application, as long as the proportion is negatively correlated with the corresponding first weight.
[0126] After the first weight of the training image is determined, the above step S202-D is performed to determine the loss of the classification model according to the first weight and the classification prediction value of the commodity.
[0127] The specific implementation methods of S202-D in the embodiment of the present application include but are not limited to the following:
[0128] Method 1: Determine a first loss value based on the classification prediction value of the commodity in the training image predicted by the classification model, and use the first weight to correct the first loss value to obtain the loss of the classification model corresponding to the training image. For example, the negative of the product of the first weight and the first loss value is determined as the loss of the classification model. There is no limitation on the specific method of determining a first loss value based on the classification prediction value of the commodity in the training image predicted by the classification model, and it can be calculated by referring to any existing or future loss calculation method.
[0129] Mode 2, the above S202-D includes the following steps S202-D1 and S202-D2:
[0130] S202-D1, from the classification prediction values of the commodity, determining the prediction value that the commodity belongs to the first classification, where the first classification is the actual classification of the commodity;
[0131] S202-D2. Determine the loss of the classification model based on the first weight and the prediction value that the product belongs to the first category.
[0132] In the embodiment of the present application, the classification prediction value of the commodity in the training image predicted by the classification model includes the classification prediction value that the commodity belongs to N preset commodity categories. The size of N can be set according to actual needs, and N can be understood as the number of commodity categories that the classification model can predict. Exemplarily, the output of the classification model includes the probability that the commodity in the training image belongs to each of the N commodity categories, for example Figure 4As shown, N=23, so the classification model outputs the probability that the product in the training image belongs to each of the 23 product categories. Next, the prediction value that the product belongs to the first category is determined from the classification prediction value predicted by the classification model, where the first category is the true classification of the product.
[0133] Next, the loss of the classification model is determined based on the first weight determined above and the predicted value that the product belongs to the first category.
[0134] For example, assuming that the real classification (i.e., the first classification) of the commodity included in the training image is a vest, the training image is input into the classification model, and the classification model outputs the prediction value of the commodity in the training image belonging to each of the 23 commodity categories. From the 23 classification prediction values, the prediction value of the vest is determined. Next, based on the first weight determined above and the determined prediction value of the vest, the loss of the classification model is determined.
[0135] The embodiment of the present application does not limit the specific method of determining the loss of the classification model in the above S202-D2 based on the first weight and the predicted value that the product belongs to the first category.
[0136] In some embodiments, the loss of the classification model corresponding to the training image is determined by multiplying the first weight by the negative of the predicted value that the commodity in the training image belongs to the first category predicted by the classification model.
[0137] In some embodiments, the above S202-D2 includes the following steps S202-D21 and S202-D22:
[0138] S202-D21, determining a second weight according to the prediction value that the commodity in the training image belongs to the first category, where the second weight is negatively correlated with the prediction value that the commodity in the training image belongs to the first category;
[0139] S202-D22. Determine the loss of the classification model according to the first weight, the second weight, and the predicted value that the commodity belongs to the first category.
[0140] In this embodiment, in order to further improve the prediction accuracy of the classification model, the second weight is determined according to the prediction accuracy of the classification model, and the loss of the classification model is modified by the second weight so that the classification model focuses on learning the inaccurately predicted commodity categories. Among them, the second weight is negatively correlated with the prediction accuracy of the classification model. The larger the prediction value of a certain commodity predicted by the classification model to belong to the first category (i.e., the true classification), the more accurate the classification model's prediction of the commodity type is. At this time, a smaller value can be assigned to the second weight so that the classification model reduces the learning of the commodity type in subsequent training. If the smaller the prediction value of the commodity predicted by the classification model to belong to the first category (i.e., the true classification), it means that the classification model is inaccurate in predicting the commodity type. At this time, a larger value can be assigned to the second weight so that the classification model can enhance the learning of the commodity type in subsequent training.
[0141] Based on this, when using the training image to train the classification model, the second weight can be determined according to the prediction value of the classification model that the product in the training image belongs to the first category (i.e., the true category). For example, the larger the prediction value, the smaller the second weight, and the smaller the prediction value, the larger the second weight.
[0142] The embodiment of the present application does not limit the specific process of determining the second weight based on the prediction value that the product in the training image belongs to the first category.
[0143] In a possible implementation, a difference between the first value and a predicted value that the commodity in the training image belongs to the first category is determined as the second weight, and the first value is a positive number.
[0144] Exemplarily, the second weight W2 is determined according to the following formula (1):
[0145] W2=c-Pt (1)
[0146] Wherein, c is the first value, and Pt is the predicted value predicted by the classification model that the product in the training image belongs to the first classification (ie, the true classification).
[0147] The embodiment of the present application does not limit the specific value of the first numerical value.
[0148] In one example, c=1.
[0149] In another possible implementation, a difference between the first value and a predicted value that the commodity in the training image belongs to the first category is determined, and the rth power of the difference is determined as the second weight, where r is a non-negative number.
[0150] Exemplarily, the second weight W2 is determined according to the following formula (2):
[0151] W2=(c-Pt) r (2)
[0152] The embodiment of the present application does not limit the specific value of r.
[0153] In one example, r is a non-negative number such as 0, 0.5, 1, 2, or 5.
[0154] After the second weight is determined according to the above steps, the above steps S202-D22 are executed to determine the loss of the classification model according to the first weight, the second weight and the predicted value that the product belongs to the first category.
[0155] The embodiment of the present application does not limit the specific implementation process of the above S202-D22.
[0156] In some embodiments, a first loss is first determined based on the predicted value that the product in the training image belongs to the first category, and then the first loss is corrected based on the first weight and the second weight to obtain the loss of the classification model under the training image.
[0157] For example, the negative of the product of the first weight, the second weight, and the first loss is determined as the loss of the classification model under the training image.
[0158] In some embodiments, the first weight and the second weight are multiplied to obtain a first product; a logarithmic operation is performed on the predicted value that the product belongs to the first category to obtain a second value; and the negative of the first product and the product of the second value are determined as the loss of the classification model with respect to the training image.
[0159] Exemplarily, the loss L of the classification model is determined according to the following formula (3):
[0160] L=-W1*W2*log(Pt) (3)
[0161] Wherein, W1 is the first weight, W2 is the second weight, and Pt is the predicted value of the commodity in the training image predicted by the classification model to belong to the first classification (ie, the true classification).
[0162] In some examples, when W1=1-a, W2=(1-Pt) r When , the loss of the classification model can be determined according to the following formula (4):
[0163] L=-(1-a)*(1-Pt) r *log(Pt) (4)
[0164] Wherein, a is the proportion of the training data included in the sample category to which the training image belongs in the training data set.
[0165] According to the above steps, after the loss of the classification model under the training image is determined, the following step S203 is performed.
[0166] S203: normalize the weight vector corresponding to the classification prediction value to obtain a normalized weight vector.
[0167] It should be noted that there is no difference in the execution order between the above S203 and the above S202, that is, the above S203 can be executed before the above S202, can also be executed after the above S202, or can be executed simultaneously with the above S202.
[0168] From the above description, it can be seen that the training image is input into the classification model, and the classification model outputs the probability that the product in the training image belongs to each of the preset N categories.
[0169] For example, Figure 7 As shown, the output layer of the classification model includes N nodes, and the N nodes include a label, and the N nodes respectively output the probability that the product in the training image belongs to the label category included in the node. At this time, the output of a node in the output layer is shown in formula (5):
[0170] P=Φ(W﹒X+b) (5)
[0171] Among them, P represents the probability that the product in the training image output by the node belongs to the label category included in the node, X is the input, W is the weight vector, and b is the model parameter.
[0172] During the model training process, model training is achieved by updating W and b. That is, during the model training process, a training image is input into the classification model to obtain the classification prediction value output by the classification model. For example, formula (5) shows the classification prediction value output by a node. Then, the loss of the classification model with respect to the training image is determined based on the classification prediction value, and then the weight vector W and parameter b of the model are updated and optimized based on the loss. Then, the next training image is input into the classification model after the weight vector W and parameter b are updated, the loss is continued to be determined, and the weight vector W and parameter b of the classification model are continued to be updated based on the loss, and the updating process is repeated until the training end condition is reached. Among them, the training end condition can be that the number of training times reaches a preset number of times, or the model accuracy reaches a preset accuracy.
[0173] In the embodiment of the present application, in order to make the classification model fully learn the long-tail products, so that the trained classification model can accurately classify the long-tail products, the embodiment of the present application normalizes the weight vector W before updating the weight vector W of the classification model each time. In this way, the influence of the header data on the model weight vector can be reduced, and the influence of the long-tail data on the model weight vector can be increased, so that the classification model can achieve balanced training of the training data with uneven samples, and improve the classification model's learning of the long-tail data.
[0174] The specific method of normalizing the weight vector is not limited in the embodiment of the present application, and can be any existing normalization method, for example.
[0175] In some embodiments, the normalization process of the weight vector can be implemented by the following steps S203-A1 and S203-A2:
[0176] S203-A1, decomposing the weight vector to obtain a parameter vector and a parameter scalar;
[0177] S203-A2. Normalize the weight vector according to the parameter vector and the parameter scalar to obtain a normalized weight vector.
[0178] The embodiment of the present application decomposes the weight vector into a vector (ie, a parameter vector) and a scalar (ie, a parameter scalar), so that the parameter vector and the parameter scalar represent the weight vector.
[0179] The embodiment of the present application does not limit the specific decomposition method of the weight vector. For example, the weight vector can be decomposed into a vector and a scalar along the direction of the weight vector.
[0180] In some embodiments, the weight vector is decomposed based on two indicators, the norm and the direction of the weight vector, to obtain a parameter vector v and a parameter scalar g.
[0181] In one example, the relationship between the weight vector W, the parameter vector v and the parameter scalar g is shown in formula (6):
[0182]
[0183] Here, ||v|| represents the Euclidean norm of v.
[0184] The above formula (6) takes the Euclidean norm as an example. In some embodiments, other norms of v may be used to replace the Euclidean norm, and the embodiments of the present application do not limit this.
[0185] According to the above steps, the weight vector corresponding to the classification prediction value is normalized, and after the normalized weight vector is obtained, the following step S204 is executed.
[0186] S204. Update the normalized weight vector according to the loss to obtain a trained classification model.
[0187] According to the above step S202, the loss of the classification model under the training image is determined. According to the above step S203, the weight vector corresponding to the classification prediction value is normalized to obtain the normalized weight vector. Then, the loss determined in step S202 is used to update and optimize the normalized weight vector determined in step S203 to obtain an updated and optimized classification model. Then, the updated and optimized classification model is updated again using the next training image, and the above updating steps are repeated until the model training end condition is met.
[0188] In some embodiments, the weight vector is decomposed into a parameter vector v and a parameter scalar g according to the above formula (6), so that the parameter vector v and / or the parameter scalar g can be updated and optimized according to the loss determined in the above S202 to achieve optimization of the weight vector.
[0189] For example, when g is fixed to ||W||, only v is optimized, which is equivalent to optimizing only the direction of W while retaining its norm. When v is fixed to W, it is equivalent to optimizing only the norm of W while retaining its direction, which provides more options for optimizing the weight vector, and the strategy of decoupling direction and norm can also accelerate the convergence of W.
[0190] In one example, when optimizing g, it is generally accomplished by optimizing the log-level parameters of g.
[0191] In one example, v and g may be updated via SGD.
[0192] For example, the updated value of g determined by SGD is shown in formula (7):
[0193]
[0194] in, is the updated value of g, L is the loss determined in S202 above, is the gradient of W under L.
[0195] For another example, the updated value of g determined by SGD is shown in formula (8):
[0196]
[0197] in, is the updated value of v.
[0198] The above is an example of determining the updated values of v and g by the gradient descent method. In some embodiments, other methods can also be used to determine the updated values of v and g, and the embodiments of the present application do not limit this.
[0199] In the embodiment of the present application, in order to make the classification model fully learn the long-tail products, so that the trained classification model can accurately classify the long-tail products, the embodiment of the present application normalizes the weight vector W before updating the weight vector W of the classification model each time. In this way, the influence of the header data on the model weight vector can be reduced, and the influence of the long-tail data on the model weight vector can be increased, so that the classification model can achieve balanced training of the training data with uneven samples, and improve the classification model's learning of the long-tail data.
[0200] Furthermore, the embodiment of the present application determines a first weight according to the distribution of different types of goods in the training data set, determines a second weight according to the degree of learning of the classification model for different types of goods, and then determines the loss of the classification model under the training image according to the first weight and / or the second weight. In this way, when the classification model is trained according to the loss, the classification model can effectively learn the long-tail data, and then when the trained classification model is used for classification, accurate classification of long-tail goods can be achieved.
[0201] The classification model training method provided in the embodiment of the present application obtains a training image and classifies the commodities in the training image through a classification model to obtain a classification prediction value of the commodity, wherein the training image includes a commodity image frame in a short video; the loss of the classification model is determined according to the classification prediction value of the commodity; the weight vector corresponding to the classification prediction value is normalized to obtain a normalized weight vector; the normalized weight vector is updated according to the loss to obtain a trained classification model. That is, before the weight vector of the classification model is updated, the embodiment of the present application normalizes the weight vector. In this way, the influence of the header data on the model weight vector can be reduced, and the influence of the long-tail data on the model weight vector can be increased, thereby enabling the classification model to achieve balanced training of training data with uneven samples and improving the classification model's learning of long-tail data.
[0202] The above text introduces the training process of the classification model in detail. Based on the above trained classification model, the classification method provided in the embodiment of the present application is introduced below.
[0203] Figure 8 A schematic diagram of a classification method flow chart provided in one embodiment of the present application.
[0204] The execution subject of the embodiments of the present application is a device with a classification function, such as a classification device. In some embodiments, the classification device may be a server. In some embodiments, the classification device may be a terminal device. In some embodiments, the classification device may be a system consisting of a server and a terminal device. The server and the terminal device may both be understood as electronic devices, so for ease of description, the following description is made by taking the execution subject as an electronic device as an example. In some embodiments, the classification device may be the same device as the above-mentioned classification model training device, and in some embodiments, the classification device may be a different device from the above-mentioned classification model training device.
[0205] like Figure 8 As shown, the classification method of the embodiment of the present application includes:
[0206] S901. Obtain a target short video, and obtain N first images from the target short video, where N is a positive integer.
[0207] The embodiment of the present application uses the above-trained classification model to identify the category of the goods in the target short video. As can be seen from the above, the classification model effectively learns long-tail goods during the training process. Therefore, when the classification model is used to identify goods, the long-tail goods in the target short video can be accurately identified, thereby improving the accuracy of goods identification.
[0208] The embodiment of the present application does not limit the specific method for obtaining the target short video. For example, the target short video is a product promotion video of a video account, or a live broadcast promotion video.
[0209] In some embodiments, the N first images are N images of a certain product in the target short video. That is, in the embodiment of the present application, image detection technology is used to detect the N images of the product in the target short video, and then the classification model is used to classify and identify the product included in each of the N first images.
[0210] In some embodiments, the N first images are all video frames of the target short video. That is, the embodiment of the present application uses a classification model to detect the goods included in each image in the target short video, and then detects the category of the goods included in each image in the target short video.
[0211] In some embodiments, the N first images are N randomly selected images from the target short video.
[0212] In some embodiments, the N first images are images of the target short video being played in the current time period. That is, the embodiment of the present application performs category recognition on the commodity in the target short video being played.
[0213] The embodiment of the present application does not limit the specific method of obtaining N first images from the target short video.
[0214] S902: For each of the N first images, predict the commodity category included in the first image by using a classification model, wherein the classification model performs normalization processing on the weight vector during training.
[0215] According to the above steps, after obtaining N first images in the target short video, for each of the N first images, the first image is input into the above-mentioned trained classification model, so that the classification model recognizes the category of the goods included in the first image and outputs the category of the goods included in the first image.
[0216] From the above, it can be seen that the classification model of the embodiment of the present application normalizes the weight vector during the training process, which can reduce the influence of the header data on the model weight vector and increase the influence of the long-tail data on the model weight vector, thereby enabling the classification model to achieve balanced training of training data with uneven samples and improve the classification model's learning of long-tail data.
[0217] In some embodiments, the classification model normalizes the weight vector during the training process, including: decomposing the weight vector to obtain a parameter vector and a parameter scalar; and normalizing the weight vector according to the parameter vector and the parameter scalar. The specific process of normalizing the weight vector can refer to the description of the above model training process, which will not be repeated here.
[0218] In some embodiments, the loss of the classification model during the training process is determined based on the first weight and the classification prediction value of the product in the training image predicted by the classification model; wherein the first weight is determined based on the proportion of the training data included in the sample category to which the training image belongs in the training data set, wherein the proportion is negatively correlated with the first weight.
[0219] In some embodiments, the loss of the classification model during the training process is determined based on the first weight and the prediction value that the product in the training image belongs to a first category, where the first category is the actual category of the product in the training image.
[0220] In some embodiments, the loss of the classification model during the training process is determined based on the first weight, the second weight, and the prediction value that the product in the training image belongs to the first category; wherein the second weight is determined based on the prediction value that the product in the training image belongs to the first category, and the second weight is negatively correlated with the prediction value that the product in the training image belongs to the first category.
[0221] In some embodiments, the second weight is a difference between the first value and a predicted value that the commodity in the training image belongs to the first category, and the first value is a positive number.
[0222] In some embodiments, the second weight is the rth power of the difference between the first value and the predicted value that the commodity in the training image belongs to the first category, the first value is a positive number, and r is a non-negative number.
[0223] In some embodiments, the loss of the classification model during training is the product of the negative of the first product and the second value, where the second value is obtained by performing a logarithmic operation on the predicted value that the product belongs to the first category, and the first product is the product of the first weight and the second weight.
[0224] The classification model of the embodiment of the present application determines the first weight according to the distribution of different types of goods in the training data set during the training process, determines the second weight according to the degree of learning of the classification model for different types of goods, and then determines the loss of the classification model under the training image according to the first weight and / or the second weight. In this way, when the classification model is trained according to the loss, the classification model can effectively learn the long-tail data, and then when the trained classification model is used for classification, the accurate classification of the long-tail goods can be achieved.
[0225] In the embodiment of the present application, the specific process of determining the loss of the classification model during the training process can refer to the description of the above-mentioned model training process and will not be repeated here.
[0226] S903: Determine recommendation information according to the commodity categories included in the N first images.
[0227] In the embodiment of the present application, a target short video is obtained, and N first images are obtained from the target short video. For each of the N first images, the first image is input into the trained classification model. Since the classification model learns long-tail products during the training process, if the first image includes long-tail products, the classification model can accurately identify the products in the first image.
[0228] Next, recommendation information is determined according to the commodity categories included in the N first images.
[0229] In the embodiment of the present application, in S903, determining the recommendation information according to the commodity categories included in the N first images includes at least the following scenarios:
[0230] Scenario 1: According to the commodity categories included in the N first images, at least one commodity matching the commodity categories included in the N first images is obtained from a commodity library; and the at least one commodity is determined as recommendation information for display.
[0231] For example, Fig. 9 As shown in the figure, during the process of selling goods on video accounts or live streaming, the target short video is as follows Fig. 9As shown on the left, during the playback of the target video, N first images of the target short video are obtained, for example, N images being played in the current time period of the target short video are obtained. Each of the N first images is input into the trained classification model for commodity category recognition, and the category of the commodity included in each of the N first images is identified. Then, at least one commodity consistent with the category of the commodity included in the first image is searched from the commodity library, and the at least one commodity is used as recommendation information. Fig. 9 is displayed in the right area of .
[0232] In some embodiments, the above N is equal to 1, that is, the classification model identifies the category of the goods included in the image currently played in the target short video, and based on the product identification result, searches from the product library to retrieve at least one product that is consistent with the category of the goods included in the currently played image, and then displays this at least one product as recommended information.
[0233] In some embodiments, if the N first images include multiple commodities, commodities that match the multiple commodities respectively may be retrieved from the commodity library, and the respective matching commodities may be displayed as recommendation information.
[0234] Scenario 2: The target short video of the embodiment of the present application can be any short video on the video account playback platform or the live broadcast platform. When the user clicks on the target short video, the classification model classifies and identifies the products included in the target short video, and searches for at least one short video matching the recognition result from the video account playback platform or the live broadcast platform based on the recognition result, and then displays the at least one short video as recommended information.
[0235] It should be noted that the above-mentioned scenarios 1 and 2 are only two scenario examples of the classification method provided in the embodiment of the present application. The classification method provided in the embodiment of the present application can also be applied to any other scenario that requires identifying the category of goods in short videos.
[0236] The classification method provided in the embodiment of the present application is obtained by obtaining a target short video and obtaining N first images from the target short video, where N is a positive integer; for each of the N first images, the classification model is used to predict the commodity category included in the first image, wherein the classification model normalizes the weight vector during the training process; and the recommendation information is determined according to the commodity category included in the N first images. Since the classification model of the embodiment of the present application normalizes the weight vector during the training process, this can reduce the influence of the header data on the model weight vector and increase the influence of the long-tail data on the model weight vector, thereby enabling the classification model to achieve balanced training of training data with uneven samples and improve the classification model's learning of long-tail data. In this way, when using the trained classification model for commodity prediction, the long-tail commodities in the target short video can be accurately identified, thereby improving the accuracy of commodity identification.
[0237] Combination of the above Figures 2 to 9 , describes in detail the method embodiment of the present application, and the following is combined with Figures 10 to 12 , describe in detail the device embodiments of the present application.
[0238] Fig.10 1 is a schematic block diagram of a classification device provided in an embodiment of the present application. The device 10 may be an electronic device or a part of an electronic device.
[0239] like Fig.10 As shown, the classification device 10 comprises:
[0240] An acquisition unit 11 is used to acquire a target short video and acquire N first images from the target short video, where N is a positive integer;
[0241] A classification unit 12, configured to predict, for each of the N first images, a commodity category included in the first image by using a classification model, wherein the classification model performs normalization processing on a weight vector during training;
[0242] The recommendation unit 13 is configured to determine recommendation information according to the commodity categories included in the N first images.
[0243] In some embodiments, the N first images are images of the target short video being played in the current time period.
[0244] In some embodiments, the recommendation unit 13 is specifically configured to obtain, from a product library, at least one product that matches the product category included in the N first images; and determine the at least one product as the recommendation information for display.
[0245] In some embodiments, the classification model normalizes the weight vector during training, including: decomposing the weight vector to obtain a parameter vector and a parameter scalar; and normalizing the weight vector according to the parameter vector and the parameter scalar.
[0246] In some embodiments, the loss of the classification model during the training process is determined based on a first weight and a classification prediction value of the commodity in the training image predicted by the classification model; wherein the first weight is determined based on the proportion of the training data included in the sample category to which the training image belongs in the training data set, and the proportion is negatively correlated with the first weight.
[0247] In some embodiments, the loss is determined based on the first weight and a prediction value that the product in the training image belongs to a first classification, where the first classification is a true classification of the product in the training image.
[0248] In some embodiments, the loss is determined based on the first weight, the second weight and the prediction value that the product in the training image belongs to the first category; wherein the second weight is determined based on the prediction value that the product in the training image belongs to the first category, and the second weight is negatively correlated with the prediction value that the product in the training image belongs to the first category.
[0249] In some embodiments, the second weight is a difference between a first value and a predicted value that the commodity in the training image belongs to the first category, and the first value is a positive number.
[0250] In some embodiments, the second weight is the rth power of the difference between the first value and the predicted value that the commodity in the training image belongs to the first category, the first value is a positive number, and r is a non-negative number.
[0251] In some embodiments, the loss is the product of the negative of the first product and a second value, where the second value is obtained by performing a logarithmic operation on the predicted value that the product belongs to the first category, and the first product is the product of the first weight and the second weight.
[0252] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, they will not be described here. Specifically, Fig.10 The device shown can execute the above-mentioned classification method embodiment, and the aforementioned and other operations and / or functions of each module in the device are respectively for realizing the above-mentioned method embodiment, which will not be described in detail here for the sake of brevity.
[0253] Fig.1120 is a schematic block diagram of a classification model training device provided in an embodiment of the present application. The device 20 may be an electronic device or a part of an electronic device.
[0254] like Fig.11 As shown, the classification model training device 20 includes:
[0255] A classification unit 21 is used to obtain a training image and classify the commodities in the training image through a classification model to obtain a classification prediction value of the commodities, wherein the training image includes a commodity image frame in a short video;
[0256] A loss determination unit 22, configured to determine the loss of the classification model according to the classification prediction value of the commodity;
[0257] A normalization unit 23, used to normalize the weight vector corresponding to the classification prediction value to obtain a normalized weight vector;
[0258] The updating unit 24 is used to update the normalized weight vector according to the loss to obtain the trained classification model.
[0259] In some embodiments, the normalization unit 23 is specifically used to decompose the weight vector to obtain a parameter vector and a parameter scalar; and normalize the weight vector according to the parameter vector and the parameter scalar to obtain the normalized weight vector.
[0260] In some embodiments, the loss determination unit 22 is specifically used to determine the sample category to which the training image belongs; determine the proportion of the training data included in the sample category in the training data set; determine a first weight based on the proportion, and the proportion is negatively correlated with the first weight; determine the loss of the classification model based on the first weight and the classification prediction value of the product.
[0261] In some embodiments, the loss determination unit 22 is specifically used to determine the prediction value that the commodity belongs to a first category from the classification prediction value of the commodity, where the first category is the true classification of the commodity; and determine the loss of the classification model based on the first weight and the prediction value that the commodity belongs to the first category.
[0262] In some embodiments, the loss determination unit 22 is specifically used to determine a second weight based on the predicted value that the commodity belongs to the first category, wherein the second weight is negatively correlated with the predicted value that the commodity belongs to the first category; and determine the loss of the classification model based on the first weight, the second weight and the predicted value that the commodity belongs to the first category.
[0263] In some embodiments, the loss determination unit 22 is specifically configured to determine the difference between the first value and the predicted value that the commodity belongs to the first category as the second weight, and the first value is a positive number.
[0264] In some embodiments, the loss determination unit 22 is specifically used to determine the difference between a first numerical value and a predicted value that the commodity belongs to a first category, wherein the first numerical value is a positive number; and the rth power of the difference is determined as the second weight, wherein r is a non-negative number.
[0265] In some embodiments, the loss determination unit 22 is specifically used to multiply the first weight and the second weight to obtain a first product; perform a logarithmic operation on the predicted value that the product belongs to the first category to obtain a second value; and determine the negative of the first product and the product of the second value as the loss of the classification model with respect to the training image.
[0266] In some embodiments, the classification unit 21 is further used to scale the size of the training image to a target size; classify the commodities in the training image of the target size by using the classification model to obtain a classification prediction value of the commodities.
[0267] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, they will not be described here. Specifically, Fig.11 The device shown can execute the above-mentioned classification model training method embodiment, and the aforementioned and other operations and / or functions of each module in the device are respectively for realizing the above-mentioned method embodiment, which will not be repeated here for the sake of brevity.
[0268] The above describes the device of the embodiment of the present application from the perspective of the functional module in conjunction with the accompanying drawings. It should be understood that the functional module can be implemented in hardware form, can be implemented by instructions in software form, and can also be implemented by a combination of hardware and software modules. Specifically, the steps of the method embodiment in the embodiment of the present application can be completed by the hardware integrated logic circuit and / or software form instructions in the processor, and the steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or a combination of hardware and software modules in the decoding processor to perform. Optionally, the software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory, and completes the steps in the above method embodiment in conjunction with its hardware.
[0269] Fig.12It is a schematic block diagram of an electronic device provided in an embodiment of the present application, which is used to execute the above-mentioned classification method and / or classification model training method embodiment.
[0270] like Fig.12 As shown, the electronic device 30 may include:
[0271] The memory 31 and the processor 32, the memory 31 is used to store the computer program 33 and transmit the program code 33 to the processor 32. In other words, the processor 32 can call and run the computer program 33 from the memory 31 to implement the method in the embodiment of the present application.
[0272] For example, the processor 32 may be configured to execute the above method steps according to instructions in the computer program 33 .
[0273] In some embodiments of the present application, the processor 32 may include but is not limited to:
[0274] General-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.
[0275] In some embodiments of the present application, the memory 31 includes but is not limited to:
[0276] Volatile memory and / or non-volatile memory. Among them, the non-volatile memory can be read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM) or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).
[0277] In some embodiments of the present application, the computer program 33 may be divided into one or more modules, which are stored in the memory 31 and executed by the processor 32 to complete the method for recording pages provided by the present application. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 33 in the electronic device.
[0278] like Fig.12 As shown, the electronic device 30 may further include:
[0279] The transceiver 34 may be connected to the processor 32 or the memory 31 .
[0280] The processor 32 may control the transceiver 34 to communicate with other devices, specifically, to send information or data to other devices, or to receive information or data sent by other devices. The transceiver 34 may include a transmitter and a receiver. The transceiver 34 may further include an antenna, and the number of antennas may be one or more.
[0281] It should be understood that the various components in the electronic device 30 are connected via a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus and a status signal bus.
[0282] According to one aspect of the present application, a computer storage medium is provided, on which a computer program is stored. When the computer program is executed by a computer, the computer is enabled to perform the method of the above method embodiment.
[0283] The embodiment of the present application also provides a computer program product including instructions, which, when executed by a computer, enables the computer to execute the method of the above method embodiment.
[0284] According to another aspect of the present application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the method of the above method embodiment.
[0285] In other words, when implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server, or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (digital video disc, DVD)), or a semiconductor medium (e.g., a solid state drive (solid state disk, SSD)), etc.
[0286] Those of ordinary skill in the art will appreciate that the modules and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0287] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the module is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0288] The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. For example, each functional module in each embodiment of the present application may be integrated into a processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0289] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A classification method, characterized in that: include: Obtain a target short video, and obtain N first images from the target short video, where N is a positive integer; For each of the N first images, predict the commodity category included in the first image through a classification model, wherein the training process of the classification model includes: obtaining a training image, and classifying the commodities in the training image through a classification model to obtain a classification prediction value of the commodity, wherein the training image includes a commodity image frame in a short video; determining the sample category to which the training image belongs; determining the proportion of the training data included in the sample category in the training data set; determining a first weight based on the proportion, wherein the proportion is negatively correlated with the first weight; determining the loss of the classification model based on the first weight and the classification prediction value of the commodity; normalizing the weight vector of the classification model to obtain a normalized weight vector; updating the normalized weight vector based on the loss to obtain the trained classification model; Recommendation information is determined according to the commodity categories included in the N first images.
2. The method according to claim 1, characterized in that The N first images are images of the target short video being played in the current time period.
3. The method according to claim 1, characterized in that The determining of recommendation information according to the categories of commodities included in the N first images includes: Acquire at least one commodity matching the commodity category included in the N first images from the commodity library; The at least one commodity is determined as the recommendation information for display.
4. A classification model training method, characterized in that: include: Acquire a training image, and classify commodities in the training image through a classification model to obtain a classification prediction value of the commodity, wherein the training image includes a commodity image frame in a short video; Determining the sample category to which the training image belongs; Determine the proportion of training data included in the sample category in the training data set; Determine a first weight according to the proportion, wherein the proportion is negatively correlated with the first weight; Determining the loss of the classification model according to the first weight and the classification prediction value of the commodity; Normalizing the weight vector of the classification model to obtain a normalized weight vector; The normalized weight vector is updated according to the loss to obtain the trained classification model.
5. The method according to claim 4, characterized in that The step of normalizing the weight vector of the classification model to obtain a normalized weight vector includes: Decomposing the weight vector to obtain a parameter vector and a parameter scalar; The weight vector is normalized according to the parameter vector and the parameter scalar to obtain the normalized weight vector.
6. The method according to claim 4, characterized in that The determining the loss of the classification model according to the first weight and the classification prediction value of the commodity includes: Determining, from the classification prediction values of the commodity, a prediction value that the commodity belongs to a first classification, where the first classification is a real classification of the commodity; The loss of the classification model is determined according to the first weight and the prediction value that the commodity belongs to the first category.
7. The method according to claim 6, characterized in that The determining the loss of the classification model according to the first weight and the prediction value that the commodity belongs to the first classification includes: Determining a second weight according to the predicted value that the commodity belongs to the first category, wherein the second weight is negatively correlated with the predicted value that the commodity belongs to the first category; The loss of the classification model is determined according to the first weight, the second weight, and the predicted value that the commodity belongs to the first category.
8. The method according to claim 7, characterized in that The determining the second weight according to the predicted value that the commodity belongs to the first category includes: Determine the difference between the first value and the predicted value that the product belongs to the first category as the second weight, and the first value is a positive number; or A difference between the first numerical value and the predicted value that the commodity belongs to the first category is determined, and the rth power of the difference is determined as the second weight, where r is a non-negative number.
9. The method according to claim 7, characterized in that: The determining the loss of the classification model according to the first weight, the second weight, and the predicted value that the commodity belongs to the first category includes: multiplying the first weight and the second weight to obtain a first product; Performing a logarithmic operation on the predicted value of the product belonging to the first category to obtain a second value; The product of the negative of the first product and the second value is determined as the loss of the classification model with respect to the training image.
10. The method according to claim 4, characterized in that Before classifying the commodities in the training image by using the classification model to obtain the classification prediction value of the commodities, the method further includes: Scaling the size of the training image to a target size; The classifying the commodities in the training image by using the classification model to obtain the classification prediction value of the commodities includes: The commodities in the training image of the target size are classified by the classification model to obtain a classification prediction value of the commodities.
11. A classification device, characterized in that: include: An acquisition unit, used to acquire a target short video, and acquire N first images from the target short video, where N is a positive integer; A classification unit, for predicting the commodity category included in each of the N first images through a classification model, wherein the training process of the classification model includes: acquiring a training image, and classifying the commodities in the training image through a classification model to obtain a classification prediction value of the commodity, wherein the training image includes a commodity image frame in a short video; determining the sample category to which the training image belongs; determining the proportion of the training data included in the sample category in the training data set; determining a first weight based on the proportion, wherein the proportion is negatively correlated with the first weight; determining a loss of the classification model based on the first weight and the classification prediction value of the commodity; normalizing the weight vector of the classification model to obtain a normalized weight vector; updating the normalized weight vector based on the loss to obtain the trained classification model; The recommendation unit is used to determine recommendation information according to the commodity categories included in the N first images.
12. A classification model training device, characterized in that: include: A classification unit, used to obtain a training image, and classify the commodities in the training image through a classification model to obtain a classification prediction value of the commodities, wherein the training image includes a commodity image frame in a short video; A loss determination unit, used to determine the sample category to which the training image belongs; Determine the proportion of training data included in the sample category in the training data set; Determine a first weight according to the proportion, wherein the proportion is negatively correlated with the first weight; determine a loss of the classification model according to the first weight and the classification prediction value of the commodity; A normalization unit, used to normalize the weight vector of the classification model to obtain a normalized weight vector; An updating unit is used to update the normalized weight vector according to the loss to obtain the trained classification model.
13. An electronic device, characterized in that: including a processor and a memory; The memory is used to store computer programs; The processor is used to execute the computer program to implement the method according to any one of claims 1 to 3 or 4 to 10.
14. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein the computer program causes a computer to execute the method according to any one of claims 1 to 3 or 4 to 10.
