Vehicle attribute recognition network training method, vehicle attribute recognition method and device
By using the associated attribute tag to train the vehicle attribute recognition network, the problems of inaccurate and slow vehicle attribute recognition in the prior art are solved, and high-precision, stable and applicable vehicle attribute recognition effects are achieved.
Patent Information
- Application Number
- CN202210474830.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-29
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2042-04-29
AI Technical Summary
In the existing vehicle attribute recognition technology, the single-task classification recognition method does not comprehensively learn vehicle attribute information, is slow, and it is difficult to effectively identify vehicles with multiple vehicle attributes.
By acquiring the vehicle sample image and the associated attribute tag, the vehicle attribute recognition network is trained, and the associated attribute tag is used to identify the categories of at least two vehicle attributes of the vehicle in the vehicle sample image, the associated attribute tag is separated into a single attribute tag, and multiple vehicles are created The association between attributes.
It improves the recognition accuracy, stability and applicability of vehicle attribute recognition, simplifies the amount of tag data, improves the computing speed, and realizes the effective recognition of a variety of vehicle attributes.
Smart Images

Figure CN115131768B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of vehicle identification technology, and in particular to a vehicle attribute identification network training method, a vehicle attribute identification method and a device. Background Art
[0002] Vehicle attribute recognition technology plays an important role in the fields of intelligent transportation systems such as autonomous driving, traffic incidents or road management. The recognition speed and accuracy of vehicle attribute information determine the working efficiency and reliability of the intelligent transportation system. However, the vehicle attribute recognition scheme in related technologies usually performs a single classification on different vehicle attributes respectively. This single-task classification and recognition method does not learn vehicle attribute information comprehensively and is slow, and the recognition effect is not good for vehicles with multiple vehicle attributes. Summary of the invention
[0003] The present application provides a vehicle attribute recognition network training method, a vehicle attribute recognition method and a device, which can improve the recognition accuracy and efficiency of vehicle attributes.
[0004] In order to solve the above technical problems, the technical solution adopted in the present application is: to provide a training method for a vehicle attribute recognition network, the training method comprising: obtaining vehicle sample images and associated attribute labels, the associated attribute labels are used to identify the categories of at least two vehicle attributes of the vehicle in the vehicle sample images; based on the vehicle sample images and the associated attribute labels, the vehicle attribute recognition network is trained to obtain a trained vehicle attribute recognition network; wherein the vehicle attribute recognition network is used to separate the associated attribute labels into at least two single attribute labels, process the vehicle sample images, the associated attribute labels and the at least two single attribute labels, obtain the training recognition results of the vehicle sample images, and adjust the model parameters of the vehicle attribute recognition network based on the training recognition results, and return to the step of training the vehicle attribute recognition network based on the vehicle sample images and the associated attribute labels until the training end conditions are met to obtain the trained vehicle attribute recognition network.
[0005] In order to solve the above technical problems, another technical solution adopted in the present application is: to provide a vehicle attribute recognition method, which comprises: obtaining an image to be recognized; using a trained vehicle attribute recognition network to recognize the image to be recognized, and obtaining an attribute recognition result; wherein the trained vehicle attribute recognition network is obtained by using the training method of the vehicle attribute recognition network in the above technical solution.
[0006] To solve the above technical problems, another technical solution adopted in the present application is: to provide a vehicle identification device, which includes a memory and a processor connected to each other, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the training method of the vehicle attribute recognition network or the vehicle attribute recognition method in the above technical solution.
[0007] In order to solve the above technical problems, another technical solution adopted in the present application is: to provide a computer-readable storage medium, which is used to store a computer program. When the computer program is executed by a processor, it is used to implement the vehicle attribute recognition network training method or vehicle attribute recognition method in the above technical solution.
[0008] Through the above scheme, the beneficial effects of the present application are: the present application uses vehicle sample images and associated attribute labels to train the vehicle attribute recognition network, and uses the associated attribute labels to identify the categories of at least two vehicle attributes of the vehicle in the vehicle sample image, which can simplify the data volume of the label and realize the use of one associated attribute label to characterize the categories of multiple vehicle attributes, which helps to improve the calculation speed; moreover, the vehicle attribute recognition network can also separate the associated attribute label into at least two single attribute labels, so as to use the vehicle sample image, the associated attribute label and the at least two single attribute labels for training, and then can establish the association between multiple vehicle attributes, and use the correlation and constraint between each vehicle attribute in the associated attribute label to improve the recognition accuracy, stability and applicability of vehicle attribute recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, 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 application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0010] Figure 1 It is a flowchart of an embodiment of a training method for a vehicle attribute recognition network provided by the present application;
[0011] Figure 2 It is a flowchart of another embodiment of the training method of the vehicle attribute recognition network provided by the present application;
[0012] Figure 3 is a flowchart of step 23 provided by this application;
[0013] Figure 4 is a schematic diagram of the training process of the vehicle attribute recognition network provided by the present application;
[0014] Figure 5is a flowchart of step 33 provided by this application;
[0015] Figure 6 It is a schematic diagram of the process of adjusting the loss magnitude parameter provided by the present application;
[0016] Figure 7 It is a flow chart of adjusting the learning speed parameters provided by the present application;
[0017] Figure 8 It is a flow chart of an embodiment of a vehicle attribute identification method provided by the present application;
[0018] Fig. 9 It is a structural schematic diagram of an embodiment of a vehicle identification device provided by the present application;
[0019] Fig.10 It is a structural schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION
[0020] The present application is further described in detail below in conjunction with the accompanying drawings and examples. It is particularly noted that the following examples are only used to illustrate the present application, but are not intended to limit the scope of the present application. Similarly, the following examples are only some embodiments of the present application rather than all embodiments, and all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0021] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0022] It should be noted that the terms "first", "second" and "third" in this application are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first", "second" and "third" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices.
[0023] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of an embodiment of the training method for the vehicle attribute recognition network provided by this application. The method includes:
[0024] Step 11: Obtain vehicle sample images and associated attribute labels.
[0025] Vehicle sample images can be selected from the training sample image library to train the vehicle attribute recognition network using the vehicle sample images. The training sample image library can include multiple vehicle sample images, and the vehicle sample images contain clear vehicle pictures. Specifically, the vehicle images collected by the imaging device can be preprocessed to obtain the vehicle sample images in the training sample image library. Further, the vehicle images can be manually segmented to obtain the minimum circumscribed rectangle containing the vehicle outer contour, thereby generating vehicle sample images.
[0026] In one embodiment, the associated attribute labels can be custom-set by the user according to the vehicle sample images. The associated attribute labels can be used to identify the categories of at least two vehicle attributes of the vehicle in the vehicle sample images. The vehicle attributes can be features such as vehicle models or vehicle colors that characterize the vehicle appearance attributes. The categories of vehicle attributes are used to characterize the specific types of the vehicle attributes. Taking the vehicle attribute as vehicle color as an example, the category of vehicle color can be yellow.
[0027] There is a certain correlation between different vehicle attributes. Taking the vehicle attributes including vehicle models and vehicle colors as an example, the vehicle color can include N categories such as black, white, or red, and the vehicle model includes M categories. Then the total number of conventional categories of vehicle attributes is M*N, while a certain vehicle model may only have x (1 < x < N) vehicle colors. At this time, the total number of categories of the associated attributes between the vehicle model and the vehicle color is , where m is the category of the vehicle model, and N m is the number of categories of vehicle colors under the mth category of vehicle models. The total number of categories of the associated attributes is less than the total number of conventional categories of vehicle attributes.
[0028] Further, by using the associated attribute labels to identify the categories of at least two vehicle attributes of the vehicle in the vehicle sample images, on the one hand, it can simplify the data volume of the labels, using one associated attribute label to represent the categories of multiple vehicle attributes; on the other hand, it can establish the correlation between multiple vehicle attributes, and utilize the correlation and constraint between each vehicle attribute in the associated attribute label to improve the recognition accuracy, stability, and applicability of vehicle attribute recognition.
[0029] Step 12: Based on the vehicle sample images and the associated attribute labels, train the vehicle attribute recognition network to obtain the trained vehicle attribute recognition network.
[0030] The vehicle sample images and the associated attribute labels are input into the vehicle attribute recognition network, so that the vehicle attribute recognition network is trained based on the vehicle sample images and the associated attribute labels to obtain a trained vehicle attribute recognition network.
[0031] In a specific embodiment, the vehicle attribute recognition network can separate the associated attribute label into at least two single attribute labels, and then process the vehicle sample image, the associated attribute label and the at least two single attribute labels to obtain the training recognition result of the vehicle sample image; then adjust the model parameters of the vehicle attribute recognition network based on the training recognition result, and return to the step of training the vehicle attribute recognition network based on the vehicle sample image and the associated attribute label until the training end condition is met to obtain the trained vehicle attribute recognition network. It can be understood that the number of separated single attribute labels is the same as the number of categories of vehicle attributes contained in the associated attribute label, and the single attribute label can be used to identify the category of a vehicle attribute of the vehicle; for example: the associated attribute label contains the vehicle model as Ax and the vehicle color as white, at this time, the associated attribute label can be separated into two single attribute labels, Ax and white.
[0032] Furthermore, the training termination conditions may include: the number of training times reaches a set value (for example: training 10,000 times); or the accuracy obtained when testing using a test set reaches a set condition (for example: exceeding a preset accuracy rate); during the training process, the loss value under the current number of training times may be calculated based on the training and recognition results of the vehicle attribute recognition network, and then whether to terminate the training may be determined based on the loss value. If the loss value converges, that is, the difference between the previous loss value and the current loss value is less than the set value, it is determined that the training termination conditions have been met; it is determined whether the current loss value is less than a preset loss value, which is a pre-set loss threshold. If the current loss value is less than the preset loss value, it is determined that the training termination conditions have been met.
[0033] This embodiment uses vehicle sample images and associated attribute labels to train the vehicle attribute recognition network, and uses the associated attribute labels to identify the categories of at least two vehicle attributes of the vehicle in the vehicle sample image, which can simplify the data volume of the label, use one associated attribute label to represent the categories of multiple vehicle attributes, and improve the operation speed; moreover, the vehicle attribute recognition network can also separate the associated attribute label into at least two single attribute labels, so as to use the vehicle sample image, the associated attribute label and the at least two single attribute labels for training, and then can establish the association between multiple vehicle attributes, and use the association and constraint between each vehicle attribute in the associated attribute label to improve the recognition accuracy, stability and applicability of vehicle attribute recognition.
[0034] See also Figure 2 , Figure 21 is a flow chart of another embodiment of a method for training a vehicle attribute recognition network provided by the present application, the method comprising:
[0035] Step 21: Obtain vehicle sample images and at least two single attribute labels.
[0036] The step of acquiring the vehicle sample image is the same as step 11 in the above embodiment and will not be repeated here. After acquiring the vehicle sample image, the vehicle sample image may be manually identified first, and the categories of at least two vehicle attributes corresponding to the vehicle in the vehicle sample image may be set according to the manual identification result; specifically, the categories of the at least two vehicle attributes manually identified may be identified by inputting at least two single attribute labels, each of which is used to identify the category of one vehicle attribute of the vehicle in the vehicle sample image.
[0037] Step 22: Generate an associated attribute label based on the categories of at least two vehicle attributes and the total number of categories of at least one vehicle attribute.
[0038] Based on the categories of at least two vehicle attributes and the total number of categories of at least one vehicle attribute, an associated attribute label is generated. The at least two vehicle attributes may include a first single attribute and a second single attribute. The at least two single attribute labels may include a first single attribute label corresponding to the category of the first single attribute and a second single attribute label corresponding to the category of the second single attribute. It can be understood that this embodiment is described with two vehicle attributes. In other embodiments, the vehicle attributes may be three or more, which is not limited here; for example, the first single attribute may be a vehicle series, which may include information such as the brand, model, year or version of the vehicle, the second single attribute may be a vehicle color (i.e., vehicle color), and the vehicle attributes may also include a third single attribute such as vehicle size in addition to the vehicle series and vehicle color.
[0039] The label information can be set by integer encoding. The label information is represented by an integer. Each label is mapped to an integer. The expression of the label information can be shown in the following formula (1):
[0040] (1)
[0041] In the above formula (1), n and m are integers, n represents the category of the first single attribute, m represents the category of the second single attribute, N and M are positive integers, N represents the total number of categories of the first single attribute, M represents the total number of categories of the second single attribute, L n is the first single attribute label, C n is the preset label information corresponding to the first single attribute of the nth category; L m is the second single attribute label, C m is the preset label information corresponding to the second single attribute of the mth category.
[0042] In one embodiment, the step of generating an associated attribute label based on the categories of at least two vehicle attributes and the total number of categories of at least one vehicle attribute may include: calculating the product of the first single attribute label and the total number of categories of the second single attribute to obtain a first value; and then calculating the sum of the first value and the second single attribute label to obtain the associated attribute label, as shown in the following formula (2):
[0043] L m,n =(m*N)+n (2)
[0044] In the above formula (2), L m,n Indicates that the first single attribute is of class n and the second single attribute is of class m.
[0045] It can be understood that the association between the first single attribute category and the second single attribute category can be established by only using the above formula (2). Each associated attribute label can correspond to a unique combination of the first single attribute category and the second single attribute category, which can ensure the reliability and accuracy of the vehicle attribute association.
[0046] Step 23: Based on the vehicle sample images and the associated attribute labels, the vehicle attribute recognition network is trained to obtain a trained vehicle attribute recognition network.
[0047] The vehicle sample images and associated attribute labels are input into the vehicle attribute recognition network to train the vehicle attribute recognition network. After the training end condition is met, the trained vehicle attribute recognition network is obtained. Compared with directly inputting multiple single attribute labels into the vehicle attribute recognition network, the use of associated attribute labels can greatly save the input data volume of the vehicle attribute recognition network. Specifically, the specific training process of the vehicle attribute recognition network is as follows: Figure 3 As shown, a detailed description is given below.
[0048] Step 31: Separate the associated attribute label into at least two single attribute labels.
[0049] After receiving the vehicle sample image and the associated attribute label, the vehicle attribute recognition network can separate the associated attribute label into at least two single attribute labels; specifically, the associated attribute label can be modulo-operated using the total number of categories of the second single attribute to obtain the second single attribute label; the ratio of the associated attribute label to the total number of categories of the second single attribute is calculated, and the ratio is rounded down to obtain the first single attribute label, as shown in the following formula (3):
[0050] (3)
[0051] For example, if the total number of categories of the first single attribute N is 10 and the total number of categories of the second single attribute M is 5, if the first single attribute label information n entered by the user is 2 and the second single attribute label information m is 4, then the associated attribute label L generated according to the above formula (2) is m,n = (4*10) + 2 = 42. After the vehicle attribute recognition network receives the associated attribute label with label information 42, it uses the above formula (3) to separate it and obtain the first single attribute label information L n =42%10=2, get the second single attribute label information L m =4.
[0052] Step 32: Process the vehicle sample image, the associated attribute label, and at least two single attribute labels to obtain a training recognition result of the vehicle sample image.
[0053] The training recognition result may include multiple sub-training recognition results, and the vehicle attribute recognition network may include multiple sub-recognition networks, and the multiple sub-recognition networks are used to perform different sub-recognition tasks respectively to obtain corresponding sub-training recognition results; the sub-recognition task may include recognizing a first single attribute, a second single attribute or an associated attribute, and the associated attribute includes an associated first single attribute and a second single attribute, that is, a combination of the first single attribute and the second single attribute; by setting up multiple sub-recognition networks to recognize each single attribute and the associated attribute respectively, the vehicle attribute recognition network can learn the correlation and constraints between multiple single attributes, thereby improving the recognition accuracy of the vehicle attribute recognition network.
[0054] Furthermore, multiple sub-training recognition results may include first probability information, second probability information and third probability information; the first probability information is used to identify the probability of the first single attribute being each first single attribute category, the second probability information is used to identify the probability of the second single attribute being each second single attribute category, and the third probability information is used to identify the probability of the associated attribute being each associated attribute category, and the associated attribute category is a combination of the first single attribute category and the second single attribute category.
[0055] It can be understood that the number of probabilities contained in the first probability information is the same as the total number of categories of the first single attribute, the number of probabilities contained in the second probability information is the same as the total number of categories of the second single attribute, and the number of probabilities contained in the third probability information is the same as the total number of categories of the associated attributes.
[0056] In a specific embodiment, Figure 4As shown, the vehicle attribute recognition network may include an input layer, a feature extraction layer and multiple sub-recognition networks. The input layer may be used to receive vehicle sample images and associated attribute labels, and the vehicle sample images and associated attribute labels are input into the feature extraction layer; the feature extraction layer is used to perform feature extraction on the vehicle sample images to obtain image feature information, and the associated attribute labels are separated into at least two single attribute labels; then multiple sub-recognition networks are used to perform vehicle attribute recognition on the vehicle sample images based on the image feature information, the associated attribute labels and at least two single attribute labels to obtain training recognition results.
[0057] Please continue reading Figure 4 After the parameters of the vehicle attribute recognition network are initialized, the vehicle image captured by the camera device can be preprocessed, and the vehicle image can be manually segmented to obtain the minimum circumscribed rectangle containing the outer contour of the vehicle, thereby generating a vehicle sample image; the associated attribute label is preprocessed based on multiple single attribute labels to obtain the associated attribute label; the input layer may include a vehicle sample image input layer and an associated attribute label input layer, the vehicle sample image input layer is used to input the preprocessed vehicle sample image, and the associated attribute label input layer is used to input the preprocessed associated attribute label.
[0058] Specifically, the feature extraction layer may include a convolution layer and a pooling layer, etc., so as to realize the extraction of image features through alternating convolution and pooling to obtain image feature information; corresponding to the vehicle attributes including a first single attribute and a second single attribute, the multiple sub-recognition networks may include a first sub-recognition network, a second sub-recognition network and a third sub-recognition network; it can be understood that the number of sub-recognition networks can be set according to the number of single attributes, and the number of sub-recognition networks can be the number of single attributes plus one; for example: if the vehicle attributes include three single attributes, four sub-recognition networks can be set accordingly to perform vehicle attribute recognition based on each single attribute and associated attributes respectively, which is not limited here.
[0059] The first sub-recognition network may include a first fully connected layer and a first output layer, the second sub-recognition network may include a second fully connected layer and a second output layer, and the third sub-recognition network may include a third fully connected layer and a third output layer. The fully connected layer, as a linear classifier, can map image feature information to corresponding attribute labels, thereby realizing classification of corresponding single attributes / associated attributes.
[0060] Furthermore, the first fully connected layer is used to identify the vehicle attributes of the vehicle sample image based on the image feature information and the first single attribute label, and the first output layer is used to output the first probability information; the second fully connected layer is used to identify the vehicle attributes based on the image feature information and the second single attribute label, and the second output layer is used to output the second probability information; the third fully connected layer is used to identify the vehicle attributes based on the image feature information and the associated attribute label, and the third output layer is used to output the third probability information.
[0061] In one embodiment, the sub-recognition network may obtain corresponding probability information by operating an activation function, and the activation function may include but is not limited to a softmax activation function, and the softmax activation function is shown in the following formula (4):
[0062] (4)
[0063] In the above formula (4), p n Represents the first probability information, p m Represents the second probability information, p m,n represents the third probability information, and “m,n” represents the total number of categories of associated probability.
[0064] Step 33: Adjust the model parameters of the vehicle attribute recognition network based on the training recognition results, and return to the step of training the vehicle attribute recognition network based on the vehicle sample image and the associated attribute label until the training end condition is met to obtain the trained vehicle attribute recognition network.
[0065] The model parameters of the vehicle attribute recognition network can be adjusted based on the training recognition results, and the steps of training the vehicle attribute recognition network based on the vehicle sample images and the associated attribute labels are returned until the training end conditions are met to obtain the trained vehicle attribute recognition network; specifically, the loss values of each sub-recognition network can be calculated based on the training recognition results, and then the parameters in the convolutional neural network can be updated and iterated based on the loss values through back propagation to realize the training of the network model, such as Figure 5 As shown, the specific steps of adjusting the model parameters of the vehicle attribute recognition network include steps 331 to 335, which are described in detail below.
[0066] Step 331: Calculate the sub-task loss value based on the sub-training recognition result of the sub-recognition task.
[0067] Based on the sub-training recognition results of the sub-recognition task, the sub-task loss value is calculated; specifically, the sub-task loss value corresponding to each sub-recognition task can be calculated based on the first probability information, the second probability information and the third probability information, wherein the sub-task loss value includes a first loss value, a second loss value and a third loss value, and the first loss value, the second loss value and the third loss value are respectively the loss value of the first sub-recognition network, the loss value of the second sub-recognition network and the loss value of the third sub-recognition network.
[0068] In one embodiment, a preset cross entropy loss function may be used to calculate the loss value of each subtask. The calculation steps of the preset cross entropy loss function may include: first performing a logarithmic operation on the sub-training recognition result to obtain a logarithmic value; performing a weighted summation of all logarithmic values to obtain a subtask loss value corresponding to the sub-recognition task, as shown in the following formula (5):
[0069] (5)
[0070] In the above formula (5), L N is the first loss value, L M is the second loss value, L M,N is the third loss value; y (n) ,y (m) ,y (m,n) are the label information corresponding to the first single attribute label, the second single attribute label, and the associated attribute label in each sub-recognition task. When the category in each sub-recognition task is the same as the category in the label information, y (n) ,y (m) ,y (m,n) is 1 if the value is true, otherwise it is 0.
[0071] Step 332: Perform weighted summation on all subtask loss values to obtain a multi-task loss value.
[0072] The following formula (6) can be used to perform weighted summation of all subtask loss values to obtain the multi-task loss value.
[0073] (6)
[0074] In the above formula (6), L multi is the multi-task loss value, w N Represents the weight corresponding to the first loss value, w M Represents the weight corresponding to the second loss value, w M,N Represents the weight corresponding to the third loss value.
[0075] Step 333: Determine whether the training end condition is currently met.
[0076] Step 334: If the training end condition is currently met, a trained vehicle attribute recognition network is obtained.
[0077] The training end conditions may include: loss value convergence, that is, the difference between the previous loss value and the current loss value is less than the set value; determining whether the current loss value is less than the preset loss value, the preset loss value is a pre-set loss threshold. If the current loss value is less than the preset loss value, it is determined that the training end conditions are met; the number of training times reaches the set value (for example: training 10,000 times); or the accuracy obtained when testing using the test set reaches the set conditions (for example: exceeding the preset accuracy), etc.
[0078] Step 335: If the training end condition is not met currently, the model parameters are adjusted based on the multi-task loss value.
[0079] The model parameters may include a loss magnitude parameter and a learning speed parameter. The loss magnitude parameter and the learning speed parameter are adjusted to obtain loss magnitude optimization parameters and learning speed optimization parameters. Then, based on the loss magnitude optimization parameters and the learning speed optimization parameters, the weights of the sub-task loss values are adjusted. Finally, the back propagation and gradient descent methods are used to fine-tune the parameters of the entire multi-task vehicle attribute recognition network to obtain the final weights corresponding to each sub-recognition task. After the training is completed, the final weights are fixed.
[0080] Furthermore, based on the loss magnitude optimization parameter and the learning speed optimization parameter, the step of adjusting the weight of the subtask loss value may include: respectively multiplying the loss magnitude optimization parameter and the learning speed optimization parameter corresponding to each sub-recognition task to obtain the weight of the first loss value, the weight of the second loss value, and the weight of the third loss value in the next training number, as shown in the following formula (7):
[0081] (7)
[0082] In the above formula (7), w N (t) represents the weight corresponding to the adjusted first loss value, w mag,N (t) represents the loss magnitude optimization parameter corresponding to the first sub-recognition task, w lr,N (t) represents the learning speed optimization parameter corresponding to the first sub-recognition task; w M (t) represents the weight corresponding to the adjusted second loss value, w mag,M (t) represents the loss magnitude optimization parameter corresponding to the second sub-recognition task, w lr,M (t) represents the learning speed optimization parameter corresponding to the second sub-recognition task; w M,N (t) represents the weight corresponding to the adjusted third loss value, w mag,(M,N) (t) represents the loss magnitude optimization parameter corresponding to the third sub-recognition task, w lr,(M,N) (t) represents the learning speed optimization parameter corresponding to the third sub-recognition task.
[0083] In one embodiment, if Figure 6 As shown, the method for adjusting the loss magnitude parameter may include the following steps:
[0084] Step 61: Calculate the average of the first loss value, the second loss value, and the third loss value to obtain the loss average.
[0085] The following formula (8) can be used to calculate the average of the first loss value, the second loss value, and the third loss value to obtain the loss average.
[0086] (8)
[0087] In the above formula (8), L ave represents the mean loss.
[0088] Step 62: Based on the loss mean, calculate the loss magnitude difference value.
[0089] The loss magnitude difference values may include a first loss magnitude difference value corresponding to the first loss value, a second loss magnitude difference value corresponding to the second loss value, and a third loss magnitude difference value corresponding to the third loss value; the loss magnitude difference values can be used to represent the magnitude differences between the sub-loss values corresponding to each sub-identification task, and by comparing each sub-task loss value with the loss mean, the loss magnitude difference value corresponding to each sub-identification task can be obtained.
[0090] Furthermore, the step of calculating the loss magnitude difference value may include: calculating the ratio of the subtask loss value to the loss mean value to obtain a fourth value; performing a logarithmic operation on the fourth value to obtain a loss magnitude difference value, as specifically shown in the following formula (9):
[0091] (9)
[0092] Among them, in the above formula (9), (L i / L ave ) is the fourth value, L i represents the loss value of each subtask, which may include the first loss value L N , the second loss value L M And the third loss value L M,N , δ Li represents the loss magnitude difference value corresponding to each subtask loss value, which may include the loss magnitude difference value δ corresponding to the first loss value LN , the difference value of the loss magnitude corresponding to the second loss value δ LM And the loss magnitude difference δ corresponding to the third loss value LM,N .
[0093] Step 63: Based on the first loss magnitude difference value, the second loss magnitude difference value, and the third loss magnitude difference value, adjust the loss magnitude parameters of the corresponding sub-recognition network to obtain loss magnitude optimization parameters.
[0094] The loss magnitude optimization parameter may include a first loss magnitude optimization parameter corresponding to the first loss magnitude difference value, a second loss magnitude optimization parameter corresponding to the second loss magnitude difference value, and a third loss magnitude optimization parameter corresponding to the third loss magnitude difference value; specifically, the step of adjusting the loss magnitude optimization parameter may include: performing an exponential operation with the first preset value as the base and the loss magnitude difference value as the exponent to obtain a second value; dividing the loss magnitude optimization constant by the second value to obtain a third value; and then performing an exponential operation with the third value as the base and the candidate exponent value as the exponent to obtain the loss magnitude optimization parameter, as shown in the following formula (10):
[0095] (10)
[0096] In the above formula (10), T δ is the loss magnitude optimization constant. The specific value of the loss magnitude optimization constant can be set according to experience or actual application conditions. mag,N (t)、f mag,M (t)、f mag,(M,N) (t) represent the preset candidate values corresponding to different sub-recognition tasks respectively.
[0097] Whether the loss magnitude parameter of the sub-identification task needs to be adjusted can be determined based on the size of the loss magnitude difference value. When the loss magnitude difference value falls within the preset difference range, the candidate index value can be the second preset value, that is, the loss magnitude parameter of the sub-identification task does not need to be adjusted; when the loss magnitude difference value does not fall within the preset difference range, the candidate index value can be the third preset value, that is, the loss magnitude parameter of the sub-identification task needs to be adjusted; wherein the second preset value can be 0, and the third preset value can be 1, as shown in the following formula (11):
[0098] (11)
[0099] In the above formula (11), f mag,i represents a preset candidate value, which may include f mag,N (t)、f mag,M (t)、f mag,(M,N) (t), (-T, T) are preset difference ranges, and specific values can be set based on experience or actual conditions.
[0100] In one embodiment, if Figure 7 As shown, the step of adjusting the learning speed parameter may include steps 71 to 74.
[0101] Step 71: Obtain the subtask loss value of the vehicle attribute recognition network in the historical training times before the current training times, and obtain the historical loss value.
[0102] Get the sub-task loss value of the vehicle attribute recognition network in the historical training times before the current training times, and get the historical loss value; taking the current training times as t as an example, the historical training times are 1~(t-1), and the sub-loss value corresponding to each sub-recognition task under the training times 1~(t-1) can be obtained, and the historical loss value corresponding to each sub-recognition task under the historical training times can be obtained.
[0103] Step 72: Calculate the mean of the historical loss values of each sub-recognition network respectively to obtain the corresponding historical loss mean.
[0104] The historical loss value may include the historical first loss value corresponding to the first sub-recognition task under all historical training times, the historical second sub-loss value corresponding to the second sub-recognition task, and the historical third sub-loss value corresponding to the third sub-recognition task. The historical first loss value, the historical second sub-loss value, and the historical third sub-loss value are then summed and averaged to obtain the historical loss mean under all historical training times.
[0105] Step 73: Calculate the ratio of the subtask loss value of the current training times to the historical loss mean, and obtain the corresponding loss change rate.
[0106] By calculating the ratio of the subtask loss value of the current training times to the historical loss mean, the corresponding loss change rate is obtained, and the loss change rate is used to reflect the learning speed of each sub-recognition task. The smaller the loss change rate, the slower the learning speed, and the larger the loss change rate, the faster the learning speed. According to the learning speed of each sub-recognition task, the weight of each subtask loss value in the above formula (6) is dynamically optimized; specifically, the calculation formula of the loss change rate is shown in the following formula (12):
[0107] (12)
[0108] In the above formula (12), r N (t)、r M (t)、r M,N (t) are the loss change rates of each sub-recognition task in the current training number t, L N (a) L M (a) L M,N (a) are the sub-loss values of each sub-recognition task in the historical training times a; , as well as They are the mean historical losses of each sub-recognition task from training number 1 to training number (t-1).
[0109] Step 74: Based on the loss change rate and the subtask loss value, the learning speed optimization parameter is calculated.
[0110] Based on the loss change rate and the subtask loss value, the step of calculating the learning speed optimization parameter may include: respectively calculating the cube root of the subtask loss value corresponding to each sub-recognition network under the current training times, and multiplying all the cube roots to obtain a fifth value; then respectively dividing the subtask loss value corresponding to each sub-recognition network by the fifth value to obtain the corresponding learning speed optimization parameter, as shown in the following formula (13):
[0111] (13)
[0112] In the above formula (13), r i (t) is the loss change rate of each sub-recognition task in the current training number t, which may include r N (t)、r M (t)、r M,N (t), is the fifth value, , and The product of .
[0113] This embodiment establishes associated attribute labels so that the vehicle attribute recognition network can fully learn each vehicle attribute, and at the same time utilizes the association and constraint between each vehicle attribute in the associated attribute labels to improve the stability and applicability of vehicle attribute recognition; moreover, multiple sub-recognition networks in the vehicle attribute recognition network can simultaneously learn the characteristic information of each vehicle attribute, which reduces the total number of parameters and time-consuming performance of the system compared to the single-task learning method; in addition, all vehicle attributes of the vehicle are also learned, which can avoid the influence of local color cast scenes on the recognition effect and improve the accuracy of attribute recognition; in addition, based on the constraint relationship between multiple sub-recognition tasks, a multi-task loss calculation method with multiple weights is used to calculate the multi-task loss value of the vehicle attribute recognition network, and the weights are adjusted together using the loss magnitude optimization parameter and the learning speed optimization parameter to achieve the effect of balancing the loss magnitude and learning speed of each sub-recognition task, thereby realizing adaptive adjustment of the weights of each sub-loss value in the multi-task loss calculation method.
[0114] See also Figure 8 , Figure 8 : is a flow chart of an embodiment of a vehicle attribute recognition method provided by the present application, the method comprising:
[0115] Step 81: Obtain an image to be recognized.
[0116] Step 82: Use the trained vehicle attribute recognition network to recognize the image to be recognized and obtain an attribute recognition result.
[0117] The trained vehicle attribute recognition network is obtained by using the training method of the vehicle attribute recognition network in the above embodiment.
[0118] See also Fig. 9 , Fig. 9 It is a structural diagram of an embodiment of a vehicle identification device provided in the present application. The vehicle identification device 90 includes a memory 91 and a processor 92 connected to each other. The memory 91 is used to store a computer program. When the computer program is executed by the processor 92, it is used to implement the training method of the vehicle attribute recognition network or the vehicle attribute recognition method in the above-mentioned embodiment.
[0119] See also Fig.10 , Fig.10 It is a structural diagram of an embodiment of a computer-readable storage medium provided in the present application. The computer-readable storage medium 100 is used to store a computer program 101. When the computer program 101 is executed by a processor, it is used to implement the vehicle attribute recognition network training method or vehicle attribute recognition method in the above-mentioned embodiment.
[0120] The computer-readable storage medium 100 may be a server, a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., which may store program codes.
[0121] In the several embodiments provided in this application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only illustrative, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0122] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0123] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0124] The above descriptions are merely embodiments of the present application and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A training method for a vehicle attribute recognition network, characterized in that: include: Acquire a vehicle sample image and an associated attribute label, wherein the associated attribute label is used to identify categories of at least two vehicle attributes of the vehicle in the vehicle sample image; Based on the vehicle sample images and the associated attribute labels, a vehicle attribute recognition network is trained to obtain a trained vehicle attribute recognition network; The vehicle attribute recognition network is used to separate the associated attribute label into at least two single attribute labels, process the vehicle sample image, the associated attribute label and the at least two single attribute labels to obtain the training recognition result of the vehicle sample image, and adjust the model parameters of the vehicle attribute recognition network based on the training recognition result, and return to the step of training the vehicle attribute recognition network based on the vehicle sample image and the associated attribute label until the training end condition is met to obtain the trained vehicle attribute recognition network; Wherein, the at least two vehicle attributes include a first single attribute and a second single attribute, and the step of obtaining the associated attribute label includes: obtaining the first single attribute label and the second single attribute label, each of the single attribute labels is used to identify a category of a vehicle attribute of the vehicle; calculating the product of the first single attribute label and the total number of categories of the second single attribute to obtain a first value; calculating the sum of the first value and the second single attribute label to obtain the associated attribute label; The step of separating the associated attribute tag into at least two single attribute tags includes: The associated attribute label is modulo operation performed using the total number of categories of the second single attribute to obtain the second single attribute label; the ratio of the associated attribute label to the total number of categories of the second single attribute is calculated, and the ratio is rounded down to obtain the first single attribute label.
2. The method for training a vehicle attribute recognition network according to claim 1, characterized in that: The training recognition result includes a plurality of sub-training recognition results, the vehicle attribute recognition network includes a plurality of sub-recognition networks, the plurality of sub-recognition networks are used to respectively perform different sub-recognition tasks to obtain corresponding sub-training recognition results, the sub-recognition tasks include recognizing the first single attribute, the second single attribute or an associated attribute, and the associated attribute includes the associated first single attribute and the second single attribute; The step of adjusting the parameters of the vehicle attribute recognition network based on the training recognition result comprises: Calculating a subtask loss value based on the sub-training recognition result of the sub-recognition task; Performing a weighted summation on all the subtask loss values to obtain a multi-task loss value; Determine whether the training end condition is currently met; If not, adjusting the model parameters based on the multi-task loss value.
3. The method for training a vehicle attribute recognition network according to claim 2, characterized in that: The model parameters include a loss magnitude parameter and a learning speed parameter. The step of adjusting the model parameters based on the multi-task loss value includes: Adjusting the loss magnitude parameter and the learning speed parameter to obtain a loss magnitude optimization parameter and a learning speed optimization parameter; Based on the loss magnitude optimization parameter and the learning speed optimization parameter, the weight of the subtask loss value is adjusted.
4. The method for training a vehicle attribute recognition network according to claim 3, characterized in that: The multiple sub-training recognition results include first probability information, second probability information, and third probability information; the step of calculating the sub-task loss value based on the sub-training recognition results of the sub-recognition task includes: Based on the first probability information, the second probability information, and the third probability information, respectively calculate a subtask loss value corresponding to each of the sub-recognition tasks, the subtask loss value including a first loss value, a second loss value, and a third loss value; Among them, the first probability information is used to identify the probability that the first single attribute is each first single attribute category, the second probability information is used to identify the probability that the second single attribute is each second single attribute category, and the third probability information is used to identify the probability that the associated attribute is each associated attribute category, and the associated attribute category is a combination of the first single attribute category and the second single attribute category.
5. The method for training a vehicle attribute recognition network according to claim 4, characterized in that: The step of adjusting the loss magnitude parameter comprises: Calculate the average of the first loss value, the second loss value, and the third loss value to obtain a loss average; Based on the loss mean, loss magnitude difference values are calculated, the loss magnitude difference values comprising a first loss magnitude difference value corresponding to the first loss value, a second loss magnitude difference value corresponding to the second loss value, and a third loss magnitude difference value corresponding to the third loss value; Based on the first loss magnitude difference value, the second loss magnitude difference value and the third loss magnitude difference value, the loss magnitude parameters of the corresponding sub-identification network are adjusted to obtain the loss magnitude optimization parameters, which include a first loss magnitude optimization parameter corresponding to the first loss magnitude difference value, a second loss magnitude optimization parameter corresponding to the second loss magnitude difference value and a third loss magnitude optimization parameter corresponding to the third loss magnitude difference value.
6. The method for training a vehicle attribute recognition network according to claim 5, characterized in that: The step of adjusting the loss magnitude parameter of the corresponding sub-identification network based on the first loss magnitude difference value, the second loss magnitude difference value, and the third loss magnitude difference value to obtain the loss magnitude optimization parameter comprises: An exponential operation is performed with the first preset value as the base and the loss magnitude difference value as the exponent to obtain a second value; Dividing the loss magnitude optimization constant by the second value to obtain a third value; An exponential operation is performed with the third numerical value as the base and the candidate index value as the exponent to obtain the loss magnitude optimization parameter, wherein when the loss magnitude difference value falls within the preset difference range, the candidate index value is the second preset numerical value; when the loss magnitude difference value does not fall within the preset difference range, the candidate index value is the third preset numerical value.
7. The method for training a vehicle attribute recognition network according to claim 5, characterized in that: The step of calculating the loss magnitude difference value based on the loss mean value comprises: Calculate the ratio of the subtask loss value to the loss mean to obtain a fourth value; A logarithmic operation is performed on the fourth value to obtain the loss magnitude difference value.
8. The method for training a vehicle attribute recognition network according to claim 3, characterized in that: The step of adjusting the learning speed parameter comprises: Obtaining subtask loss values of the vehicle attribute recognition network in historical training times before the current training times, to obtain historical loss values; Calculate the mean of the historical loss values of each of the sub-recognition networks respectively to obtain the corresponding historical loss mean; Calculate the ratio of the subtask loss value of the current training times to the historical loss mean to obtain the corresponding loss change rate; The learning speed optimization parameter is calculated based on the loss change rate and the subtask loss value.
9. The vehicle attribute recognition network training method according to claim 8, characterized in that: The step of calculating the learning speed optimization parameter based on the loss change rate and the subtask loss value comprises: Calculate the cube root of the subtask loss value corresponding to each of the sub-recognition networks under the current training times respectively, and multiply all the cube roots to obtain a fifth value; The subtask loss value corresponding to each of the sub-recognition networks is divided by the fifth value to obtain a corresponding learning speed optimization parameter.
10. The vehicle attribute recognition network training method according to claim 4, characterized in that: The step of adjusting the weight of the subtask loss value based on the loss magnitude optimization parameter and the learning speed optimization parameter comprises: The loss magnitude optimization parameter corresponding to each of the sub-recognition tasks is multiplied by the learning speed optimization parameter to obtain the weight of the first loss value, the weight of the second loss value, and the weight of the third loss value in the next training times.
11. The vehicle attribute recognition network training method according to claim 4, characterized in that: The vehicle attribute recognition network includes an input layer, a feature extraction layer and the plurality of sub-recognition networks. The step of separating the associated attribute label into at least two single attribute labels, processing the vehicle sample image, the associated attribute label and the at least two single attribute labels, and obtaining the training recognition result of the vehicle sample image includes: Using the input layer to receive the vehicle sample image and the associated attribute label, and inputting the vehicle sample image and the associated attribute label into the feature extraction layer; Using the feature extraction layer to perform feature extraction on the vehicle sample image to obtain image feature information, and separating the associated attribute label into the at least two single attribute labels; The multiple sub-recognition networks are used to perform vehicle attribute recognition on the vehicle sample image based on the image feature information, the associated attribute label and the at least two single attribute labels to obtain the training recognition result.
12. The vehicle attribute recognition network training method according to claim 11, characterized in that: The multiple sub-recognition networks include a first sub-recognition network, a second sub-recognition network, and a third sub-recognition network, the first sub-recognition network includes a first fully connected layer and a first output layer, the second sub-recognition network includes a second fully connected layer and a second output layer, and the third sub-recognition network includes a third fully connected layer and a third output layer; the step of using the multiple sub-recognition networks to perform vehicle attribute recognition on the vehicle sample image based on the image feature information, the associated attribute label, and the at least two single attribute labels, and outputting the training recognition result includes: Using the first fully connected layer to perform vehicle attribute recognition on the vehicle sample image based on the image feature information and the first single attribute label, and using the first output layer to output the first probability information; The second fully connected layer is used to output the second probability information based on the image feature information and the second single attribute label, and the second output layer is used to output the second probability information; The third fully connected layer is used based on the image feature information and the associated attribute label, and the third output layer is used to output the third probability information.
13. A vehicle attribute recognition method, characterized in that: include: Obtain an image to be recognized; Using the trained vehicle attribute recognition network to recognize the image to be recognized, and obtaining an attribute recognition result; Wherein, the trained vehicle attribute recognition network is obtained by adopting the training method of the vehicle attribute recognition network described in any one of claims 1-12.
14. A vehicle identification device, characterized in that: It comprises a memory and a processor connected to each other, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the training method of the vehicle attribute recognition network described in any one of claims 1 to 12 or the vehicle attribute recognition method described in claim 13.
15. A computer-readable storage medium for storing a computer program, characterized in that: When the computer program is executed by a processor, it is used to implement the training method of the vehicle attribute recognition network according to any one of claims 1 to 12 or the vehicle attribute recognition method according to claim 13.
Citation Information
Patent Citations
Metric learning-based lightweight vehicle attribute identification method
CN110991349A
Vehicle multi-attribute identification method and system
CN113627477A