Vehicle recognition method, device and software fusing angle and distance of feature vector
By integrating the loss function and the Swin Transformer architecture to optimize the vehicle recognition model, and combining angle and distance metrics, the problem of recognition accuracy under different lighting conditions was solved, achieving higher recognition accuracy and model simplicity.
Patent Information
- Application Number
- CN202410659831.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2044-05-24
AI Technical Summary
Existing vehicle recognition models have low accuracy in complex road environments, especially under different lighting conditions and camera settings, which can easily lead to recognition errors. Furthermore, existing methods increase model complexity and the number of parameters.
A fusion loss function is adopted, combining the angle metric loss branch and the distance metric branch to optimize the vehicle recognition model. Feature extraction and recognition are performed through the Swing Transformer architecture, and cross-domain image data generated by the GAN model is used for training.
It improves the recognition accuracy of vehicle recognition models in cross-domain images, reduces intra-class distance of feature vectors and increases inter-class distance, thereby enhancing the clustering effect of the model.
Smart Images

Figure CN118397417B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer vision and image processing, and particularly relates to a vehicle recognition method and device fusing angles and distances of feature vectors and software. BACKGROUND
[0002] In application scenarios such as intelligent transportation systems, vehicle tracking systems and road safety monitoring systems, the identification of vehicle license plates, vehicle models and vehicle body colors and other features through image recognition algorithms can greatly improve the efficiency of road safety monitoring.
[0003] The Swin Transformer model is a major breakthrough in visual deep learning models. The Swin Transformer model solves many problems in the field of computer vision, such as high image resolution, multiple visual entity features and weak feature extraction capabilities. The Swin Transformer model greatly improves the speed of image processing by the model.
[0004] For example, in an intelligent transportation system, it is necessary to count the traffic of each type of vehicle passing by. Therefore, it is necessary to first take vehicle images of each passing vehicle through road cameras, and then input the images into a deep learning model for recognition.
[0005] For entity recognition of image data, the complexity of the image scene brings great difficulties. For example, the same vehicle model in the same road image scene may be misidentified by the model due to factors such as light intensity, road visibility, camera perspective distortion and vehicle modification. Commonly, the vehicle model is identified as another color, another brand or another vehicle model.
[0006] Therefore, to solve the above technical problems, the current solution in the field of computer vision is to increase the number of feature extraction of image data to adjust the hyperparameters, network structure and loss function of the model. This solution increases the workload of entity labeling and increases the number of model parameters.
[0007] Therefore, on the basis of the Transformer architecture, the Swin Transformer architecture proposed by Microsoft is applied to the image processing model to further solve the above technical problems. The Swin Transformer architecture also brings improvements to reduce the computational load of the road vehicle recognition method.
[0008] However, due to the complexity of the shooting environment of the road system, the imaging quality is uneven, and the vehicle recognition model accuracy is not high.
[0009] Therefore, in order to enhance the feature extraction capability of the vehicle recognition model on cross-domain images, the application provides a vehicle recognition method fusing the angle and distance of feature vectors. SUMMARY
[0010] To overcome the problems in the related art, the application provides a vehicle recognition method fusing the angle and distance of feature vectors, comprising the following steps:
[0011] S1, acquiring image data;
[0012] S2, preprocessing the image data;
[0013] S3, performing feature extraction on the image data;
[0014] S4, performing entity recognition on the image data using a trained vehicle recognition model;
[0015] The fusion loss function of the vehicle recognition model comprises an angle measurement loss branch and a distance measurement branch; and the fusion loss function expression is:
[0016]
[0017] wherein, L f is a function value of the fusion loss function, L A is a function value of the angle measurement loss branch, L D is a function value of the distance measurement branch;
[0018] The angle measurement loss branch is used to calculate the angle between the feature vector of the image data and the class feature vector.
[0019] The distance measurement branch is used to calculate the distance between the feature vector of the image data and the class feature vector.
[0020] In an embodiment, before the image data is acquired, the method further comprises:
[0021] constructing the vehicle recognition model;
[0022] training the vehicle recognition model according to an image data set;
[0023] optimizing the vehicle recognition model according to the fusion loss function.
[0024] In an embodiment, the vehicle recognition model is constructed, specifically comprising:
[0025] The vehicle recognition model is provided with a vehicle feature extraction module, which comprises a block segmentation layer, a linear embedding layer and three sampling layers connected in sequence.
[0026] The block segmentation layer is provided with a convolution kernel, and a block label of the image data is obtained by convolution through the convolution kernel;
[0027] The linear embedding layer projects the block label output by the block segmentation layer to an arbitrary dimension;
[0028] The sampling layer is provided with a block merging layer and a Swin Transfomer block, and the output of the linear embedding layer is sampled through the block merging layer and the Swin Transfomer block to obtain a feature vector of the image data.
[0029] In an embodiment, the vehicle recognition model is optimized according to the fusion loss function, specifically comprising:
[0030] The loss function of the angle measurement loss branch is:
[0031]
[0032] In an embodiment, the vehicle recognition model is optimized according to the fusion loss function, further comprising:
[0033] The feature vector to be identified is scaled, and the scaling formula is:
[0034] W i T F=s F ×cosθ i
[0035] Wherein, ||W j || is 1, s F is the scaled feature vector F, and θ F represents the angle between the feature vector F and the weight vector W i of the i-th class.
[0036] In an embodiment, the loss function of the distance measurement branch is:
[0037] L D =ω1L d +(1-ω1)L n
[0038] Wherein, L D is the inter-group loss function value, L d is the intra-day group loss function value, L n is the intra-night group loss function value, and ω1 is a weight parameter.
[0039] In an embodiment, before the image data is obtained, further comprising:
[0040] S401, generating a night domain image and a day domain image respectively by a night image generator and a day image generator;
[0041] S402, evaluating a real confidence of the generated night domain image according to a night image discriminator, and evaluating a real confidence of the generated day domain image according to a day image discriminator;
[0042] S403, judging whether the GAN model is trained completely according to the real confidence output by the night image discriminator or the day image discriminator, if yes, re-executing step S401, if not, ending the iteration of the generator.
[0043] In an implementation, the loss function of the feature vectors of the twice generated image data is:
[0044]
[0045]
[0046] wherein G M is a day image generator, G Q is a night image generator, D M is a day image discriminator, D Q is a night image discriminator, M represents a day domain, Q represents a night domain, m represents a training sample of the M domain, q represents a training sample of the Q domain, P data (q) represents a data distribution of the sample q, P data (m) represents a data distribution of the sample m, and λ is a weight parameter.
[0047] The second aspect of the application provides a vehicle recognition device based on any of the above vehicle recognition methods, comprising an image shooting module and a calculation module.
[0048] The image shooting module is configured to obtain the image data.
[0049] The calculation module is configured to execute the vehicle recognition method.
[0050] The third aspect of the application provides a computer software encoded according to any of the above vehicle recognition methods.
[0051] The technical solution provided by the application can have the following beneficial effects:
[0052] In the vehicle recognition model, the fusion loss function increases the clustering information of the included angle distance compared with the single loss function, the vehicle recognition model can sufficiently reduce the intra-class distance of the feature vectors and increase the inter-class distance of the feature vectors, so that the vehicle recognition model can more accurately predict the input image data.
[0053] It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application, as claimed. BRIEF DESCRIPTION OF DRAWINGS
[0054] The above and other objects, features and advantages of the present application will become more apparent from the following detailed description when taken in conjunction with the accompanying drawings in which like reference characters refer to like parts throughout the figures, and in which:
[0055] Figure 1 Flowchart of a vehicle recognition method shown in an embodiment of the present application;
[0056] Figure 2 Another flowchart of a vehicle recognition method shown in an embodiment of the present application;
[0057] Figure 3 Architecture diagram of a vehicle recognition model shown in an embodiment of the present application;
[0058] Figure 4 Flowchart of a training data set generation method for training a vehicle recognition model shown in an embodiment of the present application.
[0059] Figure 5 Architecture diagram of a training data set generation model shown in an embodiment of the present application.
[0060] BRIEF DESCRIPTION OF DRAWINGS: In order to embody the difference between cross-domain images, Figure 3 and Figure 5 are color drawings. DETAILED DESCRIPTION
[0061] The preferred embodiments of the present application will be described herein below with reference to the accompanying drawings. While the preferred embodiments of the present application are shown in the drawings, it is understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that this application will be thorough and complete, and will fully convey the scope of the application to those skilled in the art.
[0062] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and / or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0063] It should be understood that although the terms "first", "second", "third", etc. can be used in this application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information without departing from the scope of the application. Therefore, the features defined as "first", "second" can explicitly or implicitly include one or more features. In the description of this application, the meaning of "multiple" is two or more, unless otherwise specifically limited.
[0064] Embodiment one
[0065] Computer vision technology has a large-scale application in intelligent transportation systems, vehicle tracking systems and road safety monitoring systems, etc. Compared with traditional manual identification, it greatly improves the processing efficiency of road violations.
[0066] For example, in a road violation photographing system, when there is a vehicle violating traffic rules on the road, the vehicle violating traffic rules can be photographed by a road camera, and the vehicle violating traffic rules can be identified by identifying the photo of the vehicle violating traffic rules to automatically obtain the vehicle type, color, license plate number and other characteristics of the vehicle violating traffic rules.
[0067] And the image recognition algorithm based on the deep learning model is a key technology to realize the automatic processing of the above road violations.
[0068] The existing image processing model has the problem of low recognition rate for images of different domains. The main reason is that the image shooting will be affected by external factors such as light, visibility, or rainy and foggy days, resulting in differences in imaging effects of each image. At the same time, the height, shooting angle and shooting distance of the camera set on different roads are not the same.
[0069] Classifying different domain image datasets and identifying the characteristics of different domain image datasets can effectively improve the recognition accuracy. However, this operation method also means that the parameters of the image processing model increase with the increase of the classes, resulting in a complex structure of the image processing model and large parameters, which is not easy to train.
[0070] Therefore, as shown in the method flow diagram, the embodiment of the present application provides a vehicle recognition method fusing the angle and distance of the feature vector, comprising the following steps: Figure 1
[0071] S1, obtaining image data;
[0072] S2, preprocessing the image data;
[0073] S3, feature extraction on the image data;
[0074] S4, performing entity recognition on the image data using the trained vehicle recognition model.
[0075] Specifically, during the training of the vehicle recognition model, a loss function is linked to the output layer, the parameters of the vehicle recognition model are optimized according to the function value of the loss function and the back propagation algorithm, and the function value of the loss function is subjected to gradient descent until the prediction value of the vehicle recognition model reaches the required accuracy.
[0076] Therefore, the construction of the loss function will affect the parameters of the vehicle recognition model based on the back propagation algorithm. The prior art often only considers the norm distance between the feature vectors of the predicted sample and the real sample when defining the loss function, ignoring the angle distance between the feature vectors of the predicted sample and the real sample, resulting in underfitting of the vehicle recognition model, i.e., the loss function is not accurate enough to cause the vehicle recognition model to accurately classify the feature vectors.
[0077] To overcome the above technical problems, further, in the vehicle recognition model of the embodiments of the present application, the loss function simultaneously judges the clustering effect of the vehicle recognition model according to the angle measurement and the norm distance of the feature vectors in the same domain.
[0078] Specifically, the fusion loss function includes an angle measurement loss branch and a distance measurement branch.
[0079] The expression of the fusion loss function is:
[0080]
[0081] wherein L f is the function value of the fusion loss function, L A is the function value of the angle measurement loss branch, and L D is the function value of the distance measurement branch.
[0082] In the embodiments of the present application, the image data to be predicted is input into the vehicle recognition model. After pre-processing and feature extraction of the image data, the feature vector representation of the image data is obtained, and the feature vector is output after mapping through the full connection layer. Finally, the angle distance between the feature vector of the image data and the class feature vector is calculated through the angle measurement loss branch, and the norm distance between the feature vector of the image data and the class feature vector is calculated through the distance measurement branch. The angle distance and the norm distance are weighted and summed to obtain the total loss function, and the model is optimized according to the function value of the total loss function.
[0083] Since the fusion loss function constructed in the embodiment of the present application increases the clustering information of the included angle distance compared with the single loss function, the vehicle recognition model can sufficiently reduce the intra-class distance of the feature vector and increase the inter-class distance of the feature vector, so that the vehicle recognition model can more accurately predict the input image data.
[0084] Embodiment two
[0085] On the basis of the embodiment one of the present application, in order to illustrate the specific application scene and other characteristics of the model of the vehicle recognition method described in the present application, the embodiment of the present application also provides a vehicle recognition method as shown in Figure 2
[0086] In the intelligent management system of the road, the identification of the vehicle driving on the road is a key technology. In addition to realizing the photographing of illegal driving behavior, it is also a key technology in scenes such as automatic calculation of highway tolls.
[0087] In the scene of automatic calculation of highway tolls, for example, the deep learning model can calculate the travel mileage and travel time of each vehicle through the image information of the vehicle driving on the highway section without manual and ETC system.
[0088] In order to calculate the highway toll of a vehicle, the driving mileage and driving time of the vehicle on the highway section need to be known. The driving mileage and driving time will be tracked and identified for the same vehicle on the road, and in the road illegal photographing system as described in embodiment one, the license plate number and vehicle model of the illegal vehicle need to be identified.
[0089] In the known deep learning model of the road management system, the real-time image information of the photographing node of the highway section is first needed to be obtained, and the vehicle model, license plate and body color of each vehicle passing through the node are identified, and then the driving trajectory of each vehicle on the section is simulated.
[0090] The problem based on the real-time image information of the photographing node is that the image is easily affected by external factors, such as weather factors such as rainy and foggy days, and light intensity factors such as daytime and nighttime. In the vehicle recognition model, in order to better cluster, the photographed images under different factors are subdivided into multiple image domains, such as daytime and nighttime images based on light intensity.
[0091] In the daytime and nighttime images of the same vehicle, due to the difference in light intensity, there is a difference in the feature vector of the target vehicle in the image data. In simple terms, the outline and color features of the same vehicle identified in the daytime and nighttime images do not match.
[0092] For example, for two images of the same model Y vehicle in the day and night, due to the different feature vectors extracted from the two images, the same model Y vehicle is mistaken as different vehicles.
[0093] In the vehicle recognition model constructed by the convolutional neural network, in order to overcome the influence of different domain images, the image data needs to be converted into images of the same domain before being input into the model. For example, the night domain image is compensated for illumination, so that the night domain image is converted into a day domain image, that is, an image data of the same illumination. This processing method causes the image to lose feature data, which also causes the feature vector to be inaccurate.
[0094] Therefore, in order to reduce the misrecognition of the same vehicle model cross-domain image, the embodiment of the present application provides a training method of the vehicle recognition model according to embodiment one.
[0095] In the embodiment of the present application, a group of cross-domain images of the same vehicle model is input for training, and the vehicle recognition model extracts features of the same vehicle model in different domains at the same time, and then inputs a full connection layer for training. As shown in the vehicle recognition method of fusing the angle and distance of the feature vector, Figure 2
[0096] S201, acquiring image data;
[0097] For example, the image data is a public vehicle recognition data set, and the public vehicle recognition data set is divided into a training set and a test set. For example, the VERI Wild data set, the VeRi776 data set, and the Vehicle ID data set.
[0098] Specifically, the image data includes a plurality of images of the same vehicle model in different domains. Therefore, in the embodiment of the present application, a group of images input into the vehicle recognition model in the image data are Each image in the group of images is represented as (w, h, C), w and h are the width and height of the image, and C represents the number of feature channels.
[0099] S202, pre-processing the image data;
[0100] S203, building a deep learning environment;
[0101] In the embodiment of the present application, a Pytorch GPU virtual environment and a Pytorch library are installed on a server.
[0102] S204, defining the optimizer as SGD;
[0103] For example, the batch size of the optimizer is set to 16, the initial learning rate is set to 0.002, and the momentum is set to 0.9.
[0104] In image processing, batch size represents the number of images processed at the same time.
[0105] S205, using Step LR function to create a learning rate scheduler of the model;
[0106] In the embodiments of the present application, the learning rate in the learning rate scheduler is defined as decaying by a factor of 0.1 every 5 epochs. The model described in the embodiments of the present application completes the training process after 50 iterations.
[0107] S206, constructing a vehicle feature extraction module;
[0108] Specifically, the structure of the vehicle feature extraction module is as shown in Figure 3
[0109] As shown in Figure 3 Further, the vehicle feature extraction module is sequentially connected with a block segmentation layer, a linear embedding layer, a Swin Transformer block and three sampling layers.
[0110] The design principle of the vehicle feature extraction model is to simultaneously extract features from a group of images of the same vehicle model in different domains.
[0111] For example, the vehicle image X0 is represented as (224, 224, 3), which is first input into the block segmentation layer, which is convolved by a two-dimensional convolution layer. The parameter stride and kernel size of the two-dimensional convolution layer is 4, and the output channel value is set to 4x4x3. Then, the last two dimensions of the feature map obtained by two-dimensional convolution are concatenated.
[0112] Then, the channel dimension and the new dimension of the connection are exchanged to obtain the block label of the vehicle image X0 as (56, 56, 48).
[0113] Subsequently, the block label (56, 56, 48) is input into the linear embedding layer. The linear embedding layer projects the dimension of the block label to an arbitrary dimension, and then inputs the projected features of the block label into the sampling layer after processing by the Swin Transformer block.
[0114] Specifically, the three sampling layers each include a block merging layer and a Swin Transformer block. We first use the block merging method to merge adjacent block labels from the input, resulting in a four-fold increase in channel count. Subsequently, we use a linear layer to reduce the dimension and reduce the channel count.
[0115] In the 3 sampling layers, the block markers (56, 56, 48) will present shapes (28, 28, 2C), (14, 14, 4C) and (7, 7, 8C) respectively after the Swin Transformer block.
[0116] In the embodiment of the present application, for a group of images input into the vehicle feature extraction module a group of feature representations are output as
[0117] S207, define a fusion loss function;
[0118] Specifically, the fusion loss function includes an angle measurement loss branch and a distance measurement branch.
[0119] In the vehicle recognition model of the embodiment of the present application, the loss function simultaneously judges the clustering effect of the vehicle recognition model according to the angle measurement and the norm distance of the feature vector in the same domain.
[0120] As in Embodiment One, the fusion loss function is represented as:
[0121]
[0122] wherein L f is the function value of the fusion loss function.
[0123] L A is the function value of the angle measurement loss branch, and the formula of the angle measurement loss branch is:
[0124]
[0125] In the angle measurement loss branch, in order to obtain the angle feature of the feature vector F with better separability, the feature vector F to be recognized is scaled.
[0126] The scaling formula is:
[0127] w i T F = s F x cos θ i
[0128] wherein ||W j || is 1, s F is the scaled feature vector F, and θ F represents the angle between the feature vector F and the weight vector W i of the i-th class.
[0129] In the distance metric branch, different domain images in a group of images need to be grouped. For example, for an input vehicle image (w, h, 3), according to the day domain image and the night domain image, the intra-group distance of the feature vector of the vehicle image (w, h, 3) is calculated first, and then the inter-group distance is calculated.
[0130] For example, given four different features, they are first divided into two different groups according to the day domain and the night domain, then intra-group operation is performed, and then inter-group operation is performed. The inter-group operation includes two steps:
[0131] Specifically, the intra-group distance formula is calculated as:
[0132]
[0133]
[0134] wherein D d is the intra-group distance of the vehicle image (w, h, 3) in the day domain, and D n is the intra-group distance of the vehicle image (w, h, 3) in the night domain.
[0135] Further, the intra-group loss is calculated according to the intra-group distances D d and D n , and the intra-group loss calculation formula is:
[0136]
[0137] wherein L is the intra-group loss value, y i and y j represent the categories corresponding to each group of input features, and D is the intra-group loss. D d and D n are substituted into the intra-group loss calculation formula to obtain L d and L n .
[0138] Further, the inter-group loss is determined according to the intra-group loss, and the inter-group loss calculation formula is: the formula of the distance metric branch is:
[0139] L D = ω1L d + (1-ω1)L n
[0140] wherein L D is the function value of the distance metric branch, and ω1 is a weight parameter.
[0141] S208, training the vehicle recognition model.
[0142] Embodiment three
[0143] The vehicle training model described in embodiment one and embodiment two can be trained by using the GAN model to generate the training data set in addition to obtaining the disclosed training data set.
[0144] Since the disclosed vehicle recognition training set usually only includes daytime or nighttime images of one vehicle, there is no contrast image of the same vehicle in both daytime and nighttime, and the training samples are insufficient for cross-domain recognition of the vehicle recognition model.
[0145] In order to train the vehicle recognition model with cross-domain images as described in embodiment one and embodiment two, the embodiment of the present application provides a vehicle recognition model training data set generation method, as shown in Figure 4 The method comprises the following steps:
[0146] S401, generating night domain images and day domain images by a night image generator and a day image generator respectively;
[0147] S402, evaluating the real confidence of the generated night domain images according to a night image discriminator, and evaluating the real confidence of the generated day domain images according to a day image discriminator;
[0148] S403, determining whether the GAN model is trained according to the real confidence output by the night image discriminator or the day image discriminator, if yes, re-executing step S401, if not, ending the iteration of the generator.
[0149] In the embodiment of the present application, the GAN model comprises a night image generator, a day image generator, a night image discriminator and a day image discriminator; the output layer of the night image generator is linked to the input layer of the night image discriminator and the day image discriminator; and the output layer of the day image generator is linked to the input layer of the night image discriminator and the night image discriminator.
[0150] The image data generation method of the embodiment of the present application adopts a structure of two layers of generators and two layers of discriminators.
[0151] Taking the generation of a day domain image as an example:
[0152] First, input the first day domain image in the disclosed training data set into the night image generator to generate a corresponding night domain image, and then input the generated night domain image into the day image generator in reverse to generate a second day domain image.
[0153] Second, evaluate the authenticity of the generated second day domain image by the day image discriminator.
[0154] In the embodiment of the present application, the loss function of the GAN model is:
[0155] L3=L1+λL2
[0156] wherein, L3 is a function value of the loss function of the GAN model, L1 is the loss function of the first generated output layer, and L2 is the loss function of the second generated output layer.
[0157] Specifically, the loss function of the feature vectors of the twice generated image data is:
[0158]
[0159]
[0160] wherein, G M is a day image generator, G Q is a night image generator, D M is a day image discriminator, D Q is a night image discriminator, M represents a day domain, Q represents a night domain, m represents a training sample in the M domain, q represents a training sample in the Q domain, P data (q) represents a data distribution of the sample q, P data (m) represents a data distribution of the sample m, and λ is a weight parameter.
[0161] In the embodiments of the present application, the weight of the loss value of the second generated data is controlled by adjusting λ.
[0162] The structure of the GAN model of the embodiments of the present application is shown in Figure 5 The embodiments of the present application perform data augmentation through a unique GAN model structure, and since the loss functions of the twice generated data are different, the same image data can be avoided from being repeatedly generated. Through the GAN model of the embodiments of the present application, a generated day domain image and a night domain image can be obtained by inputting a day road image of a vehicle, which greatly expands the magnitude of the training data set.
[0163] Embodiment Four
[0164] The embodiments of the present application provide a vehicle recognition device based on any one of the vehicle recognition methods described above, which comprises an image shooting module and a calculation module.
[0165] The image shooting module is used to acquire the image data.
[0166] The calculation module is used to execute the vehicle recognition method.
[0167] Embodiment Five
[0168] The embodiments of the present application provide a computer software which is encoded according to any one of the vehicle recognition methods described above.
[0169] With respect to the apparatus in the above embodiments, in which the specific manner in which each module performs operations has been described in detail in the embodiments related to the method, here will not be described in detail.
[0170] Embodiments of the application have been described above with the aid of functional and structural descriptions of specific embodiments. It is to be understood that the description applied as such to the hardware, but also to the software in which equivalent functionality is implemented. Embodiments of the application also relate to computer programs, storage media, computing devices and computer networks which operate according to the principles of the application.
Claims
1. A vehicle recognition method that fuses angles and distances of feature vectors, characterized by, The method comprises the following steps: S1, acquiring image data; S2, preprocessing the image data; S3, feature extraction on the image data; S4, entity recognition on the image data using a trained vehicle recognition model; The fusion loss function of the vehicle recognition model comprises an angle measurement loss branch and a distance measurement branch; the expression of the fusion loss function is: wherein is a function value of the fusion loss function, is a function value of the angular metric loss branch, is a function value of the distance metric branch; The angle measurement loss branch is used to calculate the angle between the feature vector of the image data and the class feature vector; The distance measurement branch is used to calculate the distance between the feature vector of the image data and the class feature vector; The vehicle recognition model is provided with a vehicle feature extraction module, which comprises a block segmentation layer, a linear embedding layer and three sampling layers connected in sequence; The block segmentation layer is provided with a convolution kernel, and the block label of the image data is obtained by convolution of the convolution kernel; The linear embedding layer projects the block label output by the block segmentation layer to any dimension; The sampling layer is provided with a block merging layer and a Swin Transfomer block, and the output of the linear embedding layer is sampled through the block merging layer and the Swin Transfomer block to obtain the feature vector of the image data; The loss function of the angle measurement loss branch is: wherein scaled feature vector ; The loss function of the distance metric branch is wherein, is the inter-group loss function value, is the intra-day group loss function value, is the intra-night group loss function value, is a weight parameter; Before acquiring the image data, the method further comprises: S401, generating a night domain image and a day domain image through a night image generator and a day image generator respectively; S402, evaluating the real confidence of the generated night domain image according to a night image discriminator, and evaluating the real confidence of the generated day domain image according to a day image discriminator; S403, determining whether the GAN model is trained according to the real confidence output by the night image discriminator or the day image discriminator, if yes, re-executing step S401, if not, ending the iteration of the generator. 2.The vehicle recognition method of claim 1, wherein, Before acquiring the image data, the method further comprises: constructing the vehicle recognition model; training the vehicle recognition model according to an image data set; optimizing the vehicle recognition model according to the fusion loss function. 3.The vehicle identification method of claim 2, wherein, Before inputting the angle measurement loss branch, the method further comprises: scaling the feature vector to be recognized; the scaling formula is: Among them, Set to 1, The scaled feature vector , Representing the eigenvector With the Class weight vector Angle, These are the eigenvectors. 4.The vehicle recognition method of claim 3, wherein, the loss function of the feature vectors of the two generated image data is: wherein is a day image generator, is a night image generator, denotes a day time domain, denotes a night time domain, denotes training samples of the day time domain, denotes training samples of the night time domain, denotes a data distribution of samples denotes a data distribution of samples denotes a data distribution of samples denotes a data distribution of samples is a loss function of the first generated output layer, is a loss function of the second generated output layer.
5. A vehicle identification device, characterized by comprising: The vehicle recognition method according to any one of claims 1 to 4 comprises an image shooting module and a calculation module; The image shooting module is used to acquire the image data; The calculation module is used to execute the vehicle recognition method.
Citation Information
Patent Citations
Parking space detection method and device, electronic equipment and storage medium
CN115393820A
Image processor, image processing method, image processing program and on-vehicle terminal
WO2009107199A1