A vehicle classification method for traffic videos based on quantum optimization algorithm
By combining quantum optimization algorithms and deep learning networks, we optimize the hyperparameters of the target detection algorithm and build a support vector machine model, which solves the problem of difficulty in processing complex traffic data with traditional methods and achieves efficient classification, identification and data processing of vehicle brands in traffic videos. Improvement of efficiency.
Patent Information
- Application Number
- CN202111662993.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2041-12-31
AI Technical Summary
Traditional methods are difficult to efficiently process and analyze the increasingly large and complex traffic data in modern transportation network systems, and cannot meet the data analysis needs of smart cities.
A traffic video vehicle classification method based on quantum optimization algorithm is adopted, combined with target detection algorithm and deep learning network, quantum particle swarm optimization algorithm is used to optimize hyperparameters, and a support vector machine model is constructed to classify vehicle brand features.
It achieves the correct classification and recognition of vehicle brands in traffic videos, improves the convergence speed of the target detection algorithm and the accuracy of the classification model, and improves data processing efficiency.
Smart Images

Figure CN114494947B
Abstract
Description
Technical Field
[0001] The present invention relates to a traffic video vehicle classification method, and in particular to a traffic video vehicle classification method based on a quantum optimization algorithm. Background Art
[0002] In recent years, quantum computing technology has developed rapidly, and has made positive progress in both the design and preparation of quantum computing hardware and the development and optimization of quantum algorithm software. Research on quantum computing applications involves many aspects, among which optimization is an important research direction. It is widely used in many fields such as traffic optimization, image analysis, financial transactions, logistics routes, engineering design and management, and high-end equipment manufacturing. In solving optimization problems, using quantum computing to achieve acceleration is one of the current research directions of great concern, namely quantum optimization. The corresponding quantum optimization algorithms include Grover quantum search algorithm, quantum approximate optimization algorithm, HHL quantum algorithm for solving linear equations, quantum annealing algorithm, Hamiltonian simulation, etc.
[0003] With the continuous deepening of smart city construction, my country has gradually built a multi-dimensional and all-round sensor system in the fields of ground transportation such as roads, railways and urban rails, which has built a strong data support for smart transportation. Faced with all-weather traffic data collected by sensors, traditional methods can no longer complete big data analysis. Quantum information technology is based on the theory of quantum mechanics. With the characteristics of quantum superposition and entanglement, it has powerful parallel computing capabilities and can achieve quantum acceleration in specific fields. In particular, in the face of modern transportation network systems with increasingly large data scales and complex structures, the use of quantum optimization algorithms combined with traditional methods can achieve efficient data processing and analysis, which is of great significance to the construction and management of smart cities.
[0004] In order to solve the above problems, people have been seeking an ideal technical solution. Summary of the invention
[0005] The purpose of the present invention is to address the deficiencies of the prior art and thus provide a traffic video vehicle classification method based on a quantum optimization algorithm.
[0006] In order to achieve the above object, the technical solution adopted by the present invention is: a traffic video vehicle classification method based on quantum optimization algorithm, comprising the following steps:
[0007] Step 1: Use the target detection algorithm to perform coarse-grained target detection of vehicles in unstructured traffic videos and extract target vehicle images in traffic videos;
[0008] Step 2: Use a deep learning network algorithm to extract vehicle brand features from the target vehicle image, preprocess the extracted vehicle brand features, and divide the preprocessed data into a training data set and a test data set according to a ratio of 70% / 30%;
[0009] Step 3, using the training data set in step 2, combining the quantum optimization algorithm and the traditional support vector machine, to build and train a traffic video vehicle feature classification model;
[0010] Step 4: Use the trained traffic video vehicle classification model to perform classification tests on the test data set in step 2 to obtain the traffic video vehicle prediction classification results, compare and analyze them with the actual vehicle brand results to verify the correctness of the traffic video vehicle feature classification model.
[0011] Based on the above, the target detection algorithm in step 1 is the YOLOv5 detection algorithm.
[0012] Based on the above, before using the YOLOv5 detection algorithm for coarse-grained vehicle target detection in unstructured traffic videos, it is necessary to first use the quantum particle swarm optimization QPSO algorithm to synchronously and comprehensively optimize the hyperparameters of the YOLOv5 detection algorithm, namely, the learning rate lr0, the cosine annealing hyperparameter lrf, the learning rate momentum momentum, and the weight decay coefficient weight_decay, to obtain the optimal hyperparameters learning rate lr0, the optimal cosine annealing hyperparameter lrf, the optimal learning rate momentum momentum, and the optimal weight decay coefficient weight_decay.
[0013] Based on the above, in step 2, the deep learning network algorithm used to extract the vehicle brand features of the target vehicle is the basic network layer of the Faster RCNN network structure, which includes 13 convolutional layers and 4 pooling layers. Each convolutional layer is followed by a ReLU function. The convolution kernel of the convolutional layer is 3*3, the step size is 1, and the pooling size of the pooling layer is 2*2, the step size is 2;
[0014] After processing by the basic network layer, 4096-dimensional features are obtained, and the first 512-dimensional features are selected as vehicle brand features.
[0015] Compared with the prior art, the present invention has outstanding substantive features and significant progress. Specifically, the present invention uses a target detection algorithm to identify vehicles in unstructured traffic videos, extracts vehicle feature information to construct a sample data set, and combines a support vector machine based on a quantum optimization algorithm to train and classify the sample data set to perform a traffic video vehicle brand feature classification model and classification test, thereby achieving correct classification and identification of vehicle brands in traffic video information.
[0016] The present invention uses quantum particle swarm optimization QPSO algorithm to perform synchronous comprehensive optimization on the hyperparameter learning rate lr0, cosine annealing hyperparameter lrf, learning rate momentum momentum, and weight decay coefficient weight_decay of the target detection algorithm, which can effectively make up for the defects of premature convergence and poor global optimization calculation accuracy caused by the gradual reduction of particle population diversity due to multiple optimization iterations of the particle swarm optimization algorithm, thereby improving the convergence speed of the target detection algorithm training process. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is a flow chart of the traffic video vehicle classification method based on quantum optimization algorithm of the present invention.
[0018] Figure 2 It is a flowchart of extracting feature values by deep learning target detection algorithm.
[0019] Figure 3 It is the flow chart of quantum particle swarm optimization algorithm.
[0020] Figure 4 It is the quantum circuit diagram of the HHL algorithm for solving linear equations.
[0021] Figure 5 This is a schematic diagram of the amplitude expansion of the Grover quantum search algorithm. DETAILED DESCRIPTION
[0022] The technical solution of the present invention is further described in detail below through specific implementation methods.
[0023] Example 1
[0024] like Figure 1 As shown, this embodiment provides a traffic video vehicle classification method based on a quantum optimization algorithm, comprising the following steps:
[0025] Step 1: Use the target detection algorithm to perform coarse-grained target detection of vehicles in unstructured traffic videos and extract target vehicle images in traffic videos;
[0026] Since traffic video vehicle analysis has high real-time requirements, the target detection algorithm adopts the YOLOv5 algorithm with higher real-time performance. Compared with previous versions of YOLO, the YOLOv5 algorithm has a faster detection speed and a lighter network while maintaining the same accuracy.
[0027] Step 2: Use a deep learning network algorithm to extract vehicle brand features from the target vehicle image, preprocess the extracted vehicle brand features, and divide the preprocessed data into a training data set and a test data set according to a ratio of 70% / 30%;
[0028] In the specific implementation, the Faster RCNN network is used to extract vehicle brand features from vehicle target images;
[0029] Specifically, Figure 2 As shown in the figure, when extracting vehicle brand features, the basic network layer of the Faster RCNN network structure is selected, which includes 13 convolutional layers and 4 pooling layers. Each convolutional layer is followed by a ReLU function. The convolution kernel of the convolutional layer is 3*3, the step size is 1, and the pooling size of the pooling layer is 2*2, and the step size is 2.
[0030] After processing by the basic network layer, 4096-dimensional features are obtained. After clustering analysis of the features, it is found that the first 512-dimensional features have the same data distribution status as the 4096-dimensional features. Therefore, the first 512-dimensional features are used instead of the 4096-dimensional features as vehicle brand features and saved in the data set, which can reduce the amount of calculation and reduce memory.
[0031] The reason why 512-dimensional features are chosen here is to select some features in 4096 dimensions as identification features. After clustering analysis of the features, it is found that the first 512-dimensional features have the same data distribution as the 4096-dimensional features, so the first 512-dimensional features are used instead of the 4096-dimensional features as the unique identification features of the image.
[0032] The vehicle brand features in the data set are preprocessed. The specific preprocessing includes data normalization, standardization and data dimensionality reduction. The above data preprocessing process helps to accelerate the convergence of the subsequent traffic video vehicle feature classification model solution process and improve the calculation accuracy. 70% of the data in the processed new data set is used as a training data set to train the traffic video vehicle feature classification and recognition model, and the rest is used as a test data set to verify the traffic video vehicle feature classification and recognition model.
[0033] Step 3, using the training data set in step 2, combining the quantum optimization algorithm and the traditional support vector machine, to build and train a traffic video vehicle feature classification model;
[0034] Specifically, the steps for constructing the traffic video vehicle feature classification model are as follows:
[0035] Set the sample form of the training data set to: in is the 512-dimensional feature vector of the training sample, x j is 512-dimensional attribute feature data, y j is the real vehicle brand corresponding to the training sample, N is the feature vector dimension of the training sample in the training dataset and N=512, M is the total number of samples in the training dataset;
[0036] The support vector machine based on quantum optimization algorithm is used to classify and identify vehicle brand features. Its specific goal is to find the maximum margin hyperplane to achieve the best vehicle brand feature classification. After conversion, the objective function is: is the weight vector; consider the noise-tolerant data as approximately linearly separable and find the soft boundary hyperplane; introduce the slack variable e j , used to indicate the allowable deviation of data points, then the objective function is Where γ is the penalty coefficient, b is the bias constant, and the constraint is given by the inequality Convert to equality constraints
[0037] Introducing the Lagrange function multiplier Build
[0038] α j ≥0 corresponds to The Lagrange multiplier of is [α1,α2,…,α j ,…,α M ], is the relaxation vector;
[0039] Based on KKT conditions Taking partial derivatives, we get Right now Thus, the quadratic programming optimization problem is transformed into the problem of solving a system of linear equations;
[0040] in and are the j-th and k-th model input vectors respectively, j, k = 1, 2, …, M; E is the unit matrix;
[0041] Solve the linear equations to get the optimal hyperplane parameters and b, thereby constructing a support vector machine model for traffic video vehicle feature analysis y(x) = ∑ j=1 α j k(x,x j )+b, That is, the traffic video vehicle feature classification model.
[0042] Step 4: Use the trained traffic video vehicle classification model to perform classification tests on the test data set in step 2 to obtain the traffic video vehicle prediction classification results, compare and analyze them with the actual vehicle brand results to verify the correctness of the traffic video vehicle feature classification model.
[0043] Example 2
[0044] The difference between this embodiment and embodiment 1 is that before using the YOLOv5 detection algorithm to perform coarse-grained target detection of vehicles in unstructured traffic videos, it is necessary to first use the quantum particle swarm optimization QPSO algorithm to synchronously and comprehensively optimize the hyperparameters of the YOLOv5 detection algorithm, namely, the learning rate lr0, the cosine annealing hyperparameter lrf, the learning rate momentum momentum, and the weight decay coefficient weight_decay, to obtain the optimal hyperparameters learning rate lr0, the optimal cosine annealing hyperparameter lrf, the optimal learning rate momentum momentum, and the optimal weight decay coefficient weight_decay.
[0045] It is understandable that the result of the loss function affects the accuracy of target recognition; and the loss function of Yolov5 is multi-peaked, with multiple local optimal solutions in addition to the global optimal solution. During training, the gradient descent algorithm may fall into the local minimum, oscillate back and forth near the minimum, and may even fail to converge. In order to solve this problem, the hyperparameters selected by the quantum particle swarm optimization algorithm, the learning rate lr0, the cosine annealing hyperparameter lrf, the learning rate momentum momentum, and the weight decay coefficient weight_decay make the loss function converge to the global minimum in the shortest time, which can effectively make up for the defects of premature convergence and poor global optimization calculation accuracy caused by the gradual reduction of particle population diversity due to multiple optimization iterations in the particle swarm optimization algorithm, and improve the convergence speed of the algorithm training process.
[0046] The quantum particle swarm algorithm is based on the superposition of microscopic particles in quantum mechanics theory. It uses a quantum rotating gate to transform the probability amplitude of quantum bits, thereby realizing the transformation of particle positions in the solution space. When the position of quantum particles is transformed according to the quantum rotating gate, two positions in the solution space can be changed simultaneously. Therefore, using quantum bit encoding for particle optimization can expand the search range, traverse as many particle positions as possible, and ultimately improve the accuracy and efficiency of optimization calculations.
[0047] Specifically, Figure 3 As shown in the figure, the specific steps of using the quantum particle swarm optimization QPSO algorithm to synchronously and comprehensively optimize the hyperparameters of the YOLOv5 detection algorithm: learning rate lr0, cosine annealing hyperparameter lrf, learning rate momentum momentum, and weight decay coefficient weight_decay are as follows:
[0048] a. Initialize the four hyperparameters to be optimized, namely, the learning rate lr0, the cosine annealing hyperparameter lrf, the learning rate momentum momentum, and the weight decay coefficient weight_decay of the YOLOv5 detection algorithm, and set a reasonable optimization interval;
[0049] b. Initial parameter settings for quantum particle swarm optimization, including particle swarm size and dimension;
[0050] c. Initialization probability amplitude coding of individual position information of quantum particle swarm;
[0051] d. Transform the randomly generated particle position probability amplitude into the quantum solution space;
[0052] e. Calculate the fitness value of each particle based on the objective function to obtain the initial individual optimal value and the global optimal value;
[0053] f. Use quantum rotating gate to transform the quantum state probability amplitude to update the particle position and generate a new particle group;
[0054] g. Calculate the fitness value of each particle in the new group based on the objective function to obtain the new individual optimal value and the global optimal value;
[0055] h. Compare it with the original optimal value and update it if it is better than the original optimal value, otherwise keep the original optimal value information;
[0056] i. Determine whether the iteration is finished, if so, then it is finished, if not, return to execute step f;
[0057] j. Finally, the global individual optimal particle value is output. The global individual optimal particle value includes the learning rate lr0, the cosine annealing hyperparameter lrf, the learning rate momentum momentum, and the weight decay coefficient weight_decay.
[0058] Example 3
[0059] The difference between this embodiment and embodiment 1 is that the HHL quantum algorithm and quantum optimization algorithms such as amplitude amplification are used to solve the linear equation system. The solution.
[0060] like Figure 5 As shown, the linear equations The specific steps for solving are:
[0061] Prepare input quantum states And set |u j >is the eigenstate of the matrix F;
[0062] Convert the matrix F to a unitary operation
[0063] Apply quantum phase estimation to the clock register and input register, so that the clock register and input register can obtain The eigenvalue of |λ j > and eigenvector
[0064] The clock register is used as the control qubit to rotate the auxiliary qubit and convert it into a superposition state of |0> and |1>; the auxiliary qubit is controlled to rotate from the ground state |λ j > respectively extract λ j To probability amplitude and in The quantum states in all three registers will become
[0065] The amplitude amplification module is used to increase the amplitude of the quantum state in the register to |1>;
[0066] Measure the auxiliary register. If the result is |1>, the result of the input register will be the same as The calculation ends with the proportional calculation result.
[0067] Among them, amplitude amplification is an important core of Grover search algorithm, such as Figure 5 As shown, the geometrical explanation of Grover's algorithm is as follows: N elements are placed in n qubits (N = 2 n ), where there are M correct solutions, satisfying 1≤M≤N, and applying the initial state n quantum bits All calculated ground states |0> can be obtained as uniform superposition states with equal weights:
[0068]
[0069] Where x is a string of numbers consisting of |0>,|1>, let N=2 n , the above uniform superposition state |Ψ> can also be described in the following form:
[0070]
[0071] If x is the correct solution, then f(x) = 1, if x is not the correct solution, then f(x) = 0. The correct solution can be identified using quantum Oracle, |x>→(-1) f(x) |x>, the superposition state description form is:
[0072]
[0073] The above formula consists of two parts: f(x) = 0 and f(x) = 1, where The corresponding quantum state is composed of all x where f(x)=0. The corresponding quantum state is composed of all x where f(x)=1, and the superposition state is described as follows:
[0074]
[0075] set up Let G = (2|Ψ><Ψ|-I)O, where |Ψ><Ψ| is the operator corresponding to the uniform superposition state of the system, I is the unit operator, and O is the Oracle operator.
[0076] The result of using the G operator once for the uniform superposition state |Ψ> is as follows:
[0077]
[0078] The result of using k G operator iterations for the uniform superposition state |Ψ> is as follows:
[0079]
[0080] Using the G operator multiple times can make |Ψ> continue to approach |β>, and the final measurement of |Ψ> can obtain a ground state of |β> with a high probability, that is, the correct solution corresponding to f(x)=1.
[0081] After all the above processes are completed, the input register will be become in This enables solving linear equations and constructing the maximum margin hyperplane.
[0082] The training data set in step 2 is used to train the support vector machine model based on the quantum optimization algorithm, thereby constructing a vehicle feature classification and recognition model for unstructured traffic videos.
[0083] The present invention uses a data set consisting of information on different vehicle brands for preliminary testing. The support vector machine model based on the quantum optimization algorithm can achieve a vehicle brand recognition accuracy of 96.2% in traffic video information, basically achieving correct classification and recognition of vehicle features in traffic videos.
[0084] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, ordinary technicians in the field should understand that the specific implementation methods of the present invention can still be modified or some technical features can be replaced by equivalents without departing from the spirit of the technical solution of the present invention, which should be included in the scope of the technical solution for protection of the present invention.
Claims
1. A traffic video vehicle classification method based on quantum optimization algorithm, characterized in that: The following steps are involved: Step 1: Use the target detection algorithm to perform coarse-grained target detection of vehicles in unstructured traffic videos and extract target vehicle images in traffic videos; Step 2: Use a deep learning network algorithm to extract vehicle brand features from the target vehicle image, preprocess the extracted vehicle brand features, and divide the preprocessed data into a training data set and a test data set according to a ratio of 70% / 30%; Step 3, using the training data set in step 2, combining the quantum optimization algorithm and the traditional support vector machine, to build and train a traffic video vehicle feature classification model; The steps to build a traffic video vehicle feature classification model are as follows: Set the sample form of the training data set to: in is the 512-dimensional feature vector of the training sample, x j is 512-dimensional attribute feature data, y j is the real vehicle brand corresponding to the training sample, N is the feature vector dimension of the training sample in the training dataset and N=512, M is the total number of samples in the training dataset; The support vector machine based on quantum optimization algorithm is used to classify and identify vehicle brand features. Its specific goal is to find the maximum margin hyperplane to achieve the best vehicle brand feature classification. After conversion, the objective function is: is the weight vector; consider the noise-tolerant data as approximately linearly separable and find the soft boundary hyperplane; introduce the slack variable e j , used to indicate the allowable deviation of data points, then the objective function is Where γ is the penalty coefficient, b is the bias constant, and the constraint is given by the inequality Convert to equality constraints Introducing the Lagrange function multiplier Build α j ≥0 corresponds to The Lagrange multiplier of is [α1,α2,…,α j ,…,α M ], is the relaxation vector; Based on KKT conditions Taking partial derivatives, we get Right now Thus, the quadratic programming optimization problem is transformed into the problem of solving a system of linear equations; in I=[1,1,…,1], and are the j-th and k-th model input vectors respectively, j, k = 1, 2, …, M; E is the unit matrix; Solve the linear equations to get the optimal hyperplane parameters and b, thereby constructing a support vector machine model for traffic video vehicle feature analysis That is, the traffic video vehicle feature classification model; Step 4: Use the trained traffic video vehicle classification model to perform classification tests on the test data set in step 2 to obtain the traffic video vehicle prediction classification results, compare and analyze them with the actual vehicle brand results to verify the correctness of the traffic video vehicle feature classification model.
2. The traffic video vehicle classification method based on quantum optimization algorithm according to claim 1 is characterized in that: The target detection algorithm in step 1 is the YOLOv5 detection algorithm.
3. The traffic video vehicle classification method based on quantum optimization algorithm according to claim 2 is characterized in that: Before using the YOLOv5 detection algorithm for coarse-grained vehicle target detection in unstructured traffic videos, it is necessary to use the quantum particle swarm optimization QPSO algorithm to synchronously and comprehensively optimize the hyperparameters of the YOLOv5 detection algorithm, namely, the learning rate lr0, the cosine annealing hyperparameter lrf, the learning rate momentum momentum, and the weight decay coefficient weight_decay, to obtain the optimal hyperparameters learning rate lr0, the optimal cosine annealing hyperparameter lrf, the optimal learning rate momentum momentum, and the optimal weight decay coefficient weight_decay.
4. The traffic video vehicle classification method based on quantum optimization algorithm according to claim 3 is characterized in that: The specific steps of using the quantum particle swarm optimization QPSO algorithm to synchronously and comprehensively optimize the hyperparameters of the YOLOv5 detection algorithm, namely, the learning rate lr0, the cosine annealing hyperparameter lrf, the learning rate momentum momentum, and the weight decay coefficient weight_decay are as follows: a. Initialize the four hyperparameters to be optimized, namely, the learning rate lr0, the cosine annealing hyperparameter lrf, the learning rate momentum momentum, and the weight decay coefficient weight_decay of the YOLOv5 detection algorithm, and set a reasonable optimization interval; b. Initial parameter settings for quantum particle swarm optimization, including particle swarm size and dimension; c. Initialization probability amplitude coding of individual position information of quantum particle swarm; d. Transform the randomly generated particle position probability amplitude into the quantum solution space; e. Calculate the fitness value of each particle based on the objective function to obtain the initial individual optimal value and the global optimal value; f. Use quantum rotating gate to transform the quantum state probability amplitude to update the particle position and generate a new particle group; g. Calculate the fitness value of each particle in the new group based on the objective function to obtain the new individual optimal value and the global optimal value; h. Compare it with the original optimal value and update it if it is better than the original optimal value, otherwise keep the original optimal value information; i. Determine whether the iteration is finished, if so, then it is finished, if not, return to execute step f; j. Finally, the global individual optimal particle value is output. The global individual optimal particle value includes the learning rate lr0, the cosine annealing hyperparameter lrf, the learning rate momentum momentum, and the weight decay coefficient weight_decay.
5. The traffic video vehicle classification method based on quantum optimization algorithm according to claim 1 is characterized in that: In step 2, the deep learning network algorithm used to extract vehicle brand features from the target vehicle image is the basic network layer of the Faster RCNN network structure, which includes 13 convolutional layers and 4 pooling layers. Each convolutional layer is followed by a ReLU function. The convolution kernel of the convolutional layer is 3*3, the step size is 1, and the pooling size of the pooling layer is 2*2, with a step size of 2. After processing by the basic network layer, 4096-dimensional features are obtained, and the first 512-dimensional features are selected as vehicle brand features.
