Vehicle detection method and device, electronic equipment and storage medium

By constructing pre-trained samples and a self-supervised learning model to pre-train the vehicle detection model, the problem of low accuracy of existing vehicle detection models is solved, and higher detection accuracy is achieved.

CN116311162BActive Publication Date: 2026-04-14GUANGZHOU YUNCONG INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-09
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Most existing vehicle detection methods are based on unsupervised training, resulting in low accuracy of vehicle detection models.

Method used

By acquiring historical vehicle images to construct pre-training samples, a vehicle detection model is built. A self-supervised learning model, such as the MoCo model, is then used to pre-train the model. The model parameters are optimized using weighted feature vectors and contrastive loss until convergence, resulting in the pre-trained vehicle detection model.

Benefits of technology

This improved the training effect of the vehicle detection model, resulting in higher accuracy and detection precision.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116311162B_ABST
    Figure CN116311162B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of image recognition, and specifically provides a vehicle detection method and device, electronic equipment and storage medium, aiming at solving the technical problem of low accuracy of the existing vehicle detection model. To this end, the vehicle detection method comprises: obtaining a historical vehicle image, constructing a pre-training sample based on the historical vehicle image; constructing a vehicle detection model; pre-training the vehicle detection model based on the pre-training sample and a self-supervised learning model to obtain a pre-trained vehicle detection model; inputting a to-be-detected image into the pre-trained vehicle detection model to obtain a detection result. In this way, a vehicle detection model with higher accuracy is obtained, and the detection accuracy of the vehicle is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image recognition technology, and specifically provides a vehicle detection method, apparatus, electronic device, and storage medium. Background Technology

[0002] The rapid development of artificial intelligence technology has provided significant support for the automotive industry, with intelligent driving vehicles gaining considerable attention. In the environmental perception of intelligent driving vehicles, camera-based sensing plays a crucial role, and object detection technology has become a key component.

[0003] Most existing vehicle detection methods are based on unsupervised training to obtain vehicle detection models, which are then used for vehicle detection. However, the accuracy of vehicle detection models obtained through this method is relatively low.

[0004] Accordingly, there is a need in this field for a new vehicle inspection solution to address the aforementioned problems. Summary of the Invention

[0005] To overcome the aforementioned deficiencies, this invention is proposed to provide solutions or at least partially solve the aforementioned technical problems. This invention provides a vehicle detection method, apparatus, electronic device, and storage medium.

[0006] In a first aspect, the present invention provides a vehicle detection method, the method comprising: acquiring historical vehicle images; constructing pre-training samples based on the historical vehicle images; constructing a vehicle detection model; pre-training the vehicle detection model based on the pre-training samples and a self-supervised learning model to obtain a pre-trained vehicle detection model; and inputting an image to be detected into the pre-trained vehicle detection model to obtain a detection result.

[0007] In one embodiment, the vehicle detection model includes a backbone network and a classifier network; the backbone network is used to extract feature vectors from the historical vehicle images; the classifier network is used to classify the image features to obtain image detection results.

[0008] In one embodiment, the self-supervised learning model is a MoCo model; the step of pre-training the vehicle detection model based on the pre-trained samples and the self-supervised learning model to obtain a pre-trained vehicle detection model includes: extracting features from the pre-trained samples using the backbone network of the vehicle detection model to obtain a first feature vector; extracting features from the pre-trained samples using the backbone network of the MoCo model to obtain a second feature vector and a third feature vector queue, the third feature vector queue including multiple third feature vectors; determining a fourth feature vector queue based on the third feature vector queue and a temperature coefficient matrix; calculating a contrast loss based on the first feature vector, the second feature vector, and the fourth feature vector queue; and determining the pre-trained vehicle detection model based on the contrast loss.

[0009] In one implementation, determining the fourth feature vector queue based on the third feature vector queue and the temperature coefficient matrix includes: determining the fourth feature vector based on the product between each third feature vector in the third feature vector queue and the corresponding temperature coefficient in the temperature coefficient matrix; and determining the fourth feature vector queue based on the fourth feature vector.

[0010] The formula for calculating the fourth feature vector is as follows:

[0011] k i =p i *Temp i

[0012] Where, k i p is the i-th fourth eigenvector in the fourth eigenvector queue. i Temp is the i-th third feature vector in the third feature vector queue. i Let i be the i-th temperature coefficient in the temperature coefficient matrix, i = 1, 2, ..., K, where K is the length of the third feature vector queue.

[0013] In one implementation, calculating the contrast loss based on the first feature vector, the second feature vector, and the fourth feature vector queue includes:

[0014]

[0015] Among them, L q For comparison of losses, q is the first feature vector, and k + Let k be the second feature vector. i Let τ be the i-th fourth eigenvector in the fourth eigenvector queue, and let τ be the temperature hyperparameter.

[0016] In one implementation, determining the pre-trained vehicle detection model based on the contrastive loss includes: using the contrastive loss to update the model parameters of the backbone network of the MoCo model via backpropagation; determining whether the contrastive loss has converged; if so, outputting the updated model parameters of the backbone network of the MoCo model; if not, returning to continue training iterations until the contrastive loss converges; determining the model parameters of the backbone network of the vehicle detection model based on the updated model parameters of the backbone network of the MoCo model, thereby obtaining the pre-trained vehicle detection model.

[0017] In one implementation, both the backbone network of the MoCo model and the backbone network of the vehicle detection model are ResNet50 networks.

[0018] In a second aspect, the present invention provides a vehicle detection device, the device comprising:

[0019] The acquisition module is configured to acquire historical vehicle images and construct pre-training samples based on the historical vehicle images;

[0020] A building module, configured to build a vehicle detection model;

[0021] The training module is configured to pre-train the vehicle detection model based on the pre-training samples and the self-supervised learning model to obtain the pre-trained vehicle detection model.

[0022] The detection module is configured to input the image to be detected into the pre-trained vehicle detection model to obtain the detection result.

[0023] In a third aspect, an electronic device is provided, comprising at least one processor and at least one storage device, the storage device being adapted to store a plurality of program codes adapted to be loaded and executed by the processor to perform the vehicle detection method described in any of the preceding claims.

[0024] In a fourth aspect, a computer-readable storage medium is provided, wherein a plurality of program codes are stored therein, the program codes being adapted to be loaded and run by a processor to perform the vehicle detection method described in any of the preceding claims.

[0025] The above-described technical solutions of the present invention have at least one or more of the following beneficial effects:

[0026] The vehicle detection method provided by this invention specifically includes: acquiring historical vehicle images; constructing pre-training samples based on the historical vehicle images; constructing a vehicle detection model; pre-training the vehicle detection model based on the pre-training samples and a self-supervised learning model to obtain a pre-trained vehicle detection model; and inputting the image to be detected into the pre-trained vehicle detection model to obtain the detection result. Thus, by pre-training the vehicle detection model using a self-supervised learning model, the training effect of the vehicle detection model is improved, resulting in a more accurate vehicle detection model and further enhancing the vehicle detection precision. Attached Figure Description

[0027] The disclosure of this invention will become more readily understood with reference to the accompanying drawings. It will be readily understood by those skilled in the art that these drawings are for illustrative purposes only and are not intended to limit the scope of protection of this invention. Furthermore, similar numbers in the drawings are used to denote similar components, wherein:

[0028] Figure 1 This is a schematic flowchart of the main steps of a vehicle detection method according to an embodiment of the present invention;

[0029] Figure 2 This is a schematic diagram of the process of pre-training a vehicle detection model in one embodiment;

[0030] Figure 3 This is a schematic diagram of the process of pre-training a vehicle detection model in one embodiment;

[0031] Figure 4 This is a schematic diagram of the structure of a vehicle detection device according to an embodiment of the present invention;

[0032] Figure 5 This is a schematic diagram of the structure of an electronic device in one embodiment. Detailed Implementation

[0033] Some embodiments of the present invention will now be described with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are merely illustrative of the technical principles of the present invention and are not intended to limit the scope of protection of the present invention.

[0034] In the description of this invention, "module" and "processor" can include hardware, software, or a combination of both. A module can include hardware circuitry, various suitable sensors, communication ports, memory, and may also include software components, such as program code, or a combination of software and hardware. A processor can be a central processing unit, microprocessor, image processor, digital signal processor, or any other suitable processor. The processor has data and / or signal processing capabilities. The processor can be implemented in software, in hardware, or a combination of both. Non-transitory computer-readable storage media includes any suitable medium capable of storing program code, such as magnetic disks, hard disks, optical disks, flash memory, read-only memory, random access memory, etc. The term "A and / or B" means all possible combinations of A and B, such as only A, only B, or A and B. The terms "at least one A or B" or "at least one of A and B" have a similar meaning to "A and / or B" and can include only A, only B, or A and B. The singular terms "a" or "this" can also include plural forms.

[0035] Currently, most traditional vehicle detection methods are based on unsupervised training to obtain vehicle detection models, which are then used for vehicle detection. However, the accuracy of vehicle detection models obtained through this method is relatively low.

[0036] To address this, this application proposes a vehicle detection method, apparatus, electronic device, and storage medium, specifically including: acquiring historical vehicle images; constructing pre-training samples based on the historical vehicle images; constructing a vehicle detection model; pre-training the vehicle detection model based on the pre-training samples and a self-supervised learning model to obtain a pre-trained vehicle detection model; and inputting the image to be detected into the pre-trained vehicle detection model to obtain the detection result. Thus, by pre-training the vehicle detection model using a self-supervised learning model, the training effect of the vehicle detection model is improved, resulting in a more accurate vehicle detection model and further enhancing the accuracy of vehicle detection.

[0037] See appendix Figure 1 , Figure 1 This is a schematic flowchart of the main steps of a vehicle detection method according to an embodiment of the present invention.

[0038] like Figure 1 As shown, the vehicle detection method in this embodiment of the invention mainly includes the following steps S101-S104.

[0039] Step S101: Obtain historical vehicle images and construct pre-training samples based on the historical vehicle images.

[0040] Specifically, multiple historical vehicle images can be acquired, and data augmentation methods can be used to generate pre-training samples from these images. The data augmentation methods can be any of the following: random cropping, random color perturbation, random grayscale conversion, random Gaussian blurring, and random horizontal flipping of the historical vehicle images.

[0041] Step S102: Construct a vehicle detection model.

[0042] Vehicle detection models can be deep learning models based on convolutional neural networks.

[0043] Step S103: Based on the pre-trained samples and the self-supervised learning model, pre-train the vehicle detection model to obtain the pre-trained vehicle detection model.

[0044] Step S104: Input the image to be detected into the pre-trained vehicle detection model to obtain the detection result.

[0045] Based on steps S101-S104 above, historical vehicle images are acquired, and pre-training samples are constructed based on these images. A vehicle detection model is then built. The vehicle detection model is pre-trained using the pre-training samples and a self-supervised learning model to obtain a pre-trained vehicle detection model. The image to be detected is then input into the pre-trained vehicle detection model to obtain the detection result. Thus, by pre-training the vehicle detection model using a self-supervised learning model, the training effect of the vehicle detection model is improved, resulting in a more accurate vehicle detection model and further enhancing the accuracy of vehicle detection.

[0046] The following provides further explanation of steps S102 to S104.

[0047] In one specific implementation, the vehicle detection model includes a backbone network and a classifier network; the backbone network is used to extract feature vectors from the historical vehicle images; the classifier network is used to classify the image features to obtain image detection results.

[0048] Specifically, the ResNet50 network can be used as an example of the backbone network of the vehicle detection model, but it is not limited to this.

[0049] The ResNet50 network consists of five feature extraction stages and three fully connected layers. Stage 1 consists of two convolutions and one pooling layer. Stage 2 consists of two convolutions and one pooling layer. Stage 3 consists of three fixed convolutions and one fixed pooling layer. Stage 4 consists of three fixed convolutions and one fixed pooling layer. Stage 5 consists of three fixed convolutions and one fixed pooling layer.

[0050] The classifier network can be a binary classifier model, which can classify the features of the image to be predicted and obtain the detection result of whether it is a vehicle.

[0051] The above is a further explanation of step S102. The following is a further explanation of step S103.

[0052] Among self-supervised learning methods, the MoCo series of algorithms is one of the most effective. The MoCo algorithm requires saving image feature vectors from previous iterations during training to calculate the loss function for the current iteration. However, because the model parameters change during training, the image features from previous iterations are not accurate, thus affecting the performance of the trained model. Therefore, this embodiment employs a weighted approach to address this technical problem.

[0053] Specifically, the self-supervised learning model can be a MoCo model. In one embodiment, the backbone network of the MoCo model uses the same network model as the backbone network of the vehicle detection model, such as the ResNet50 network.

[0054] Specifically, such as Figure 2 As shown, step S103 can be implemented by the following steps S1031 to S1035.

[0055] S1031: Use the backbone network of the vehicle detection model to extract features from the pre-trained samples to obtain a first feature vector.

[0056] Specifically, such as Figure 3 As shown, an image x from the pre-training samples is used. query Input the backbone network (encoder) of the vehicle detection model and output the first feature vector q.

[0057] S1032: Use the backbone network of the MoCo model to extract features from the pre-trained samples to obtain the second feature vector k. + and a third feature vector queue, wherein the third feature vector queue includes multiple third feature vectors.

[0058] Specifically, an image from the pre-training samples Input the backbone network (momentum encoder) of the MoCo model and output the second feature vector k. + And the third eigenvector k0, by storing the third eigenvector generated in each iteration in history, we can obtain the queue of third eigenvectors k0, k1, k2, ..., where the second eigenvector k + It is the feature vector that matches the first feature vector q.

[0059] During training, each iteration takes a batch of historical images as input and simultaneously obtains a batch of first feature vector q and second feature vector k. + To obtain the third eigenvector, the algorithm needs to maintain a feature queue (memory queue) to store the third eigenvectors generated in each iteration throughout history. This results in a queue of third eigenvectors, which contains K third eigenvectors. Therefore, the queue length of the third eigenvector queue is K, where K is a positive integer.

[0060] S1033: Determine the fourth feature vector queue based on the third feature vector queue and the temperature coefficient matrix.

[0061] Specifically, the fourth feature vector queue can be determined by multiplying each third feature vector in the third feature vector queue with its corresponding temperature coefficient, or by the ratio of each third feature vector in the third feature vector queue to its corresponding temperature coefficient.

[0062] The temperature coefficient matrix is ​​a predefined queue of temperature coefficients of a preset length, containing multiple temperature coefficients. The length of the temperature coefficient matrix is ​​the same as the queue length of the third eigenvector queue, meaning that each third eigenvector in the third eigenvector queue corresponds to a temperature coefficient in the temperature coefficient matrix.

[0063] In one embodiment, [1,0.95,0.95] 2 ,…,0.95 K ] T This can serve as an example of the temperature coefficient matrix.

[0064] In a preferred embodiment, determining the fourth feature vector queue based on the third feature vector queue and the temperature coefficient matrix includes: determining the fourth feature vector based on the product between each third feature vector in the third feature vector queue and the corresponding temperature coefficient in the temperature coefficient matrix; and determining the fourth feature vector queue based on the fourth feature vector.

[0065] The formula for calculating the fourth feature vector is as follows:

[0066] k i =p i *Temp i

[0067] Where, k i p is the i-th fourth eigenvector in the fourth eigenvector queue. i Temp is the i-th third feature vector in the third feature vector queue. iLet i be the i-th temperature coefficient in the temperature coefficient matrix, i = 1, 2, ..., K, where K is the length of the third feature vector queue.

[0068] Specifically, the product of the third eigenvector and its corresponding temperature coefficient can be used as the fourth eigenvector, and multiple fourth eigenvectors can form a queue of fourth eigenvectors.

[0069] In one embodiment, each third feature vector in the third feature vector queue is multiplied by a temperature coefficient Tempi less than 1. Thus, as the reasoning process progresses, the feature vector that is farther away from the current iteration is multiplied by this temperature coefficient less than 1 more times, and the feature vector occupies a smaller weight in the loss function. This is equivalent to the training process gradually forgetting earlier historical features and paying more attention to more recent features, which is conducive to improving the training effect of the model and further improving the accuracy of the model.

[0070] S1034: Calculate the contrast loss based on the first feature vector, the second feature vector, and the fourth feature vector queue.

[0071] In one specific implementation, the step of calculating the contrast loss based on the first feature vector, the second feature vector, and the fourth feature vector queue includes:

[0072]

[0073] Among them, L q For comparison of losses, q is the first feature vector, and k + Let k be the second feature vector. i Let τ be the i-th fourth eigenvector in the fourth eigenvector queue, and let τ be the temperature hyperparameter.

[0074] S1035: Determine the pre-trained vehicle detection model based on the contrastive loss.

[0075] In one specific implementation, determining the pre-trained vehicle detection model based on the contrastive loss includes: using the contrastive loss to update the model parameters of the backbone network of the MoCo model through backpropagation; determining whether the contrastive loss has converged; if so, outputting the updated model parameters of the backbone network of the MoCo model; if not, returning to continue training iterations until the contrastive loss converges; determining the model parameters of the backbone network of the vehicle detection model based on the updated model parameters of the backbone network of the MoCo model, thereby obtaining the pre-trained vehicle detection model.

[0076] Backpropagation refers to a method of training certain feedforward neural networks for a given input pattern, given a known classification. As each segment of the sample set is shown to the network, it observes its output response to the example input pattern. The error between the output response and the expected output is then calculated, and the connection weights are adjusted based on this error.

[0077] After updating the model parameters of the backbone network of the MoCo model through backpropagation, it is determined whether the contrast loss has converged, that is, whether the contrast loss is less than a preset value. If so, the updated model parameters of the backbone network of the MoCo model are output; otherwise, training iteration continues until the contrast loss converges. Finally, the updated model parameters of the backbone network of the MoCo model are used as the model parameters of the backbone network of the vehicle detection model to obtain the pre-trained vehicle detection model.

[0078] Thus, by multiplying each third feature vector by the corresponding temperature coefficient to determine the contrast loss, and then using the contrast loss and backpropagation to determine the pre-trained vehicle detection model, the training effect of the vehicle detection model is improved, the training process is accelerated, and fewer iterations are needed to achieve the same model effect, which is beneficial to improving the accuracy of the vehicle detection model.

[0079] The above is a further explanation of step S103. The following is a further explanation of step S104.

[0080] Specifically, for S104, the image to be detected is input into the pre-trained vehicle detection model to obtain the detection result of whether the object in the image is a vehicle.

[0081] It should be noted that although the steps in the above embodiments are described in a specific order, those skilled in the art will understand that in order to achieve the effects of the present invention, different steps do not necessarily have to be executed in such an order. They can be executed simultaneously (in parallel) or in other orders, and these variations are all within the scope of protection of the present invention.

[0082] Furthermore, the present invention also provides a vehicle detection device.

[0083] See appendix Figure 4 , Figure 4 This is a main structural block diagram of a vehicle detection device according to an embodiment of the present invention.

[0084] like Figure 4As shown, the vehicle detection device in this embodiment of the invention mainly includes an acquisition module 11, a construction module 12, a training module 13, and a detection module 14. In some embodiments, one or more of the acquisition module 11, the construction module 12, the training module 13, and the detection module 14 can be combined into a single module.

[0085] In some embodiments, the acquisition module 11 may be configured to acquire historical vehicle images and construct pre-trained samples based on the historical vehicle images.

[0086] Module 12 can be configured to build a vehicle detection model.

[0087] Training module 13 can be configured to pre-train the vehicle detection model based on the pre-trained samples and the self-supervised learning model to obtain the pre-trained vehicle detection model.

[0088] The detection module 14 can be configured to input the image to be detected into the pre-trained vehicle detection model to obtain the detection result.

[0089] In one implementation, a description of the specific functions can be found in steps S101-S104.

[0090] The aforementioned vehicle detection device is used for performing Figure 1 The vehicle detection method embodiments shown are similar in technical principle, the technical problems solved and the technical effects produced. Those skilled in the art can clearly understand that, for the sake of convenience and brevity, the specific working process and related descriptions of the vehicle detection device can be referred to the content described in the vehicle detection method embodiments, and will not be repeated here.

[0091] Those skilled in the art will understand that all or part of the processes in the method of the above embodiment of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable storage medium can include any entity or device capable of carrying the computer program code, a medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory, a random access memory, an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc. It should be noted that the content included in the computer-readable storage medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable storage medium does not include electrical carrier signals and telecommunication signals.

[0092] Furthermore, the present invention also provides an electronic device. In one embodiment of the electronic device according to the present invention, specifically as follows: Figure 5 As shown, the electronic device includes at least one processor 51 and at least one storage device 52. The storage device can be configured to store a program for executing the vehicle detection method of the above-described method embodiments, and the processor can be configured to execute the program in the storage device. This program includes, but is not limited to, the program for executing the vehicle detection method of the above-described method embodiments. For ease of explanation, only the parts related to the embodiments of the present invention are shown; for specific technical details not disclosed, please refer to the method section of the embodiments of the present invention.

[0093] In embodiments of the present invention, the electronic device may be a control device comprising various devices. In some possible implementations, the electronic device may include multiple storage devices and multiple processors. The program executing the vehicle detection method of the above method embodiments may be divided into multiple subroutines, each subroutine being loaded and run by a processor to execute different steps of the vehicle detection method of the above method embodiments. Specifically, each subroutine may be stored in different storage devices, and each processor may be configured to execute programs in one or more storage devices to jointly implement the vehicle detection method of the above method embodiments, that is, each processor executes different steps of the vehicle detection method of the above method embodiments to jointly implement the vehicle detection method of the above method embodiments.

[0094] The aforementioned multiple processors can be processors deployed on the same device. For example, the aforementioned electronic device can be a high-performance device composed of multiple processors, and the aforementioned multiple processors can be processors configured on that high-performance device. Alternatively, the aforementioned multiple processors can also be processors deployed on different devices. For example, the aforementioned electronic device can be a server cluster, and the aforementioned multiple processors can be processors on different servers within the server cluster.

[0095] Furthermore, the present invention also provides a computer-readable storage medium. In one embodiment of the computer-readable storage medium according to the present invention, the computer-readable storage medium can be configured to store a program for performing the vehicle detection method of the above-described method embodiments. This program can be loaded and run by a processor to implement the above-described vehicle detection method. For ease of explanation, only the parts related to the embodiments of the present invention are shown; for specific technical details not disclosed, please refer to the method section of the embodiments of the present invention. The computer-readable storage medium can be a storage device comprising various electronic devices. Optionally, in the embodiments of the present invention, the computer-readable storage medium is a non-transitory computer-readable storage medium.

[0096] Furthermore, it should be understood that since the various modules are only provided to illustrate the functional units of the device of the present invention, the physical devices corresponding to these modules may be the processor itself, or a part of the processor's software, hardware, or a combination of software and hardware. Therefore, the number of modules shown in the figures is merely illustrative.

[0097] Those skilled in the art will understand that the various modules in the device can be adaptively split or combined. Such splitting or combining of specific modules will not cause the technical solution to deviate from the principles of the present invention; therefore, the technical solutions after splitting or combining will fall within the protection scope of the present invention.

[0098] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after such changes or substitutions will all fall within the scope of protection of the present invention.

Claims

1. A vehicle inspection method, characterized in that, The method includes: Acquire historical vehicle images and construct pre-training samples based on the historical vehicle images; A vehicle detection model is constructed, which includes a backbone network and a classifier network; Based on the pre-trained samples and the self-supervised learning model, the vehicle detection model is pre-trained to obtain a pre-trained vehicle detection model. The self-supervised learning model is a MoCo model, comprising: The backbone network of the vehicle detection model is used to extract features from the pre-trained samples to obtain a first feature vector; The backbone network of the MoCo model is used to extract features from the pre-trained samples to obtain a second feature vector and a third feature vector queue. The second feature vector is a feature vector that matches the first feature vector. The third feature vector queue includes multiple third feature vectors and stores the third feature vectors generated in each iteration in history to obtain the third feature vector queue. Determining the fourth feature vector queue based on the third feature vector queue and the temperature coefficient matrix includes: The fourth feature vector is determined based on the product of each third feature vector in the third feature vector queue and the temperature coefficient in the corresponding temperature coefficient matrix. The fourth feature vector queue is determined based on the fourth feature vector; The contrast loss is calculated based on the first feature vector, the second feature vector, and the fourth feature vector queue. The pre-trained vehicle detection model is determined based on the contrastive loss. The image to be detected is input into the pre-trained vehicle detection model to obtain the detection result.

2. The vehicle detection method according to claim 1, characterized in that, The backbone network is used to extract feature vectors from the historical vehicle images; The classifier network is used to classify the image features to obtain image detection results.

3. The vehicle inspection method according to claim 1, characterized in that, The formula for calculating the fourth feature vector is as follows: in, For the i-th fourth feature vector in the fourth feature vector queue, For the i-th third feature vector in the third feature vector queue, Let i be the i-th temperature coefficient in the temperature coefficient matrix, i=1,2,…,K, where K is the length of the third feature vector queue.

4. The vehicle detection method according to claim 1, characterized in that, The calculation of the contrast loss based on the first feature vector, the second feature vector, and the fourth feature vector queue includes: in, To compare the losses, The first eigenvector, This is the second feature vector. For the i-th fourth feature vector in the fourth feature vector queue, This refers to temperature hyperparameters.

5. The vehicle inspection method according to claim 1, characterized in that, The process of determining the pre-trained vehicle detection model based on the contrastive loss includes: Using the contrastive loss, the model parameters of the backbone network of the MoCo model are updated via backpropagation. Determine whether the contrastive loss has converged. If it has, output the updated backbone network parameters of the MoCo model. If not, return to continue training iterations until the contrastive loss converges. Based on the model parameters of the backbone network of the updated MoCo model, the model parameters of the backbone network of the vehicle detection model are determined, and the pre-trained vehicle detection model is obtained.

6. The vehicle detection method according to claim 1, characterized in that, The backbone networks of both the MoCo model and the vehicle detection model are ResNet50 networks.

7. A vehicle detection device, characterized in that, The device includes: The acquisition module is configured to acquire historical vehicle images and construct pre-training samples based on the historical vehicle images; A construction module is configured to build a vehicle detection model, which includes a backbone network and a classifier network. A training module, configured to pre-train the vehicle detection model based on the pre-trained samples and a self-supervised learning model, to obtain a pre-trained vehicle detection model, wherein the self-supervised learning model is a MoCo model, includes: extracting features from the pre-trained samples using the backbone network of the vehicle detection model to obtain a first feature vector; extracting features from the pre-trained samples using the backbone network of the MoCo model to obtain a second feature vector and a third feature vector queue, wherein the second feature vector is a feature vector matching the first feature vector, and the third feature vector queue includes multiple third feature vectors, storing the third feature vectors generated in each iteration in history to obtain a third feature vector queue; determining a fourth feature vector queue based on the third feature vector queue and a temperature coefficient matrix, including: determining a fourth feature vector based on the product between each third feature vector in the third feature vector queue and the corresponding temperature coefficient in the temperature coefficient matrix; determining the fourth feature vector queue based on the fourth feature vector; calculating a contrast loss based on the first feature vector, the second feature vector, and the fourth feature vector queue; and determining the pre-trained vehicle detection model based on the contrast loss. The detection module is configured to input the image to be detected into the pre-trained vehicle detection model to obtain the detection result.

8. An electronic device comprising at least one processor and at least one storage device, said storage device being adapted to store a plurality of program codes, characterized in that, The program code is adapted to be loaded and run by the processor to perform the vehicle detection method according to any one of claims 1 to 6.

9. A computer-readable storage medium storing a plurality of program codes, characterized in that, The program code is adapted to be loaded and run by a processor to perform the vehicle detection method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Image processing method, device and equipment and readable storage medium

    CN115100489A

  • Pavement defect detection method, system and equipment and storage medium

    CN115170528A