Vehicle series identification method based on one-shot learning
By using twin neural network and distance threshold technology in vehicle system recognition, the problem of data imbalance is solved, the generalization ability and prediction accuracy of the model are improved, and the overfitting of traditional one-time learning neural networks under data imbalance is solved. Problems with excessive distance between classes.
Patent Information
- Application Number
- CN202411215672.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-24
AI Technical Summary
Traditional learning neural networks face data imbalance during training, resulting in insufficient generalization capabilities of the model and excessive intra-class distances, resulting in blurred category boundaries and affecting the prediction accuracy of the model.
Through data collection and labeling, vehicle system verification and screening, data screening and set construction, data set division, model training and feature vector storage, twin neural networks are used for vehicle system recognition, and data distribution is optimized using distance threshold and random sampling technology to enhance the Generalization ability and prediction accuracy of the model.
The sample size of training data with fewer categories is effectively increased, the intra-class distance is reduced, the data distribution is optimized, the prediction accuracy of the model is significantly improved, and the support for complex image recognition tasks is enhanced.
Smart Images

Figure CN119181064A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer vision and machine learning, and specifically is a vehicle series recognition method based on one-shot learning. Background Art
[0002] In the traditional one-shot learning neural network architecture, the Siamese Neural Network occupies an important position. This type of network achieves efficient learning of a small number of training samples by processing two randomly selected images in parallel and calculating the similarity between them. Traditional one-shot learning neural networks often face the challenge of data imbalance during training. Categories with small data volumes are prone to overfitting due to insufficient sample diversity, which limits the generalization ability of the model; while categories with large data volumes may have too wide internal data feature spaces, increasing the intra-class distance, blurring the feature boundaries between different categories, causing confusion, and affecting the model's accurate judgment of category boundaries. Therefore, how to effectively deal with data imbalance has become the key to improving the performance of one-shot learning neural networks. Summary of the invention
[0003] The purpose of the present invention is to provide a vehicle series identification method based on one-shot learning to solve the problems raised in the above background technology.
[0004] In order to achieve the above object, the present invention provides the following technical solution: a vehicle series identification method based on one-shot learning, wherein the specific steps of the vehicle series identification method are as follows:
[0005] S1: Data collection and annotation: Use a camera or mobile phone to take a car image A and annotate it with clear car model information;
[0006] S2: Car series verification and screening condition setting; verify whether the car series of image A is in the training set, and confirm after query; set the distance threshold M for feature vector comparison;
[0007] S3: Data screening and set construction: Calculate feature vectors based on the existence of the car series, screen neighboring images to construct set R, and ensure that no duplicates are added;
[0008] S4: Dataset division: From each type of data in the set R, a proportion of images are randomly selected as the validation set, and the remaining (1-a) proportion of images are used as the training set;
[0009] S5: Model training: Use the divided training set to train the twin network, and adjust the parameters of the validation set to optimize the performance;
[0010] S6: Feature vector storage: Train the twin network E to calculate the features of the R image and store them in the database for subsequent query;
[0011] S7: Model reasoning and user query: When the user uploads a picture, the twin network E is used to extract feature L, the database is searched for similar features Z, and the Z car series information is output to match the car series.
[0012] Preferably, the data collection and annotation in S1: is performed by picking up a camera, aiming at an eye-catching car parked on the roadside, and steadily photographing its full appearance to obtain image A. Subsequently, the photo is carefully observed to determine the brand and series of the car, and professional annotation tools are used to mark "This car is a brand series" in a prominent position of image A in clear and easy-to-read fonts.
[0013] Preferably, the specific steps of vehicle series verification and screening condition setting in S2 are as follows:
[0014] Step 1: Query the training data set: First, you need to access and query the existing training data set, including traversing all the car series labels in the data set, looking for entries that match the car series information annotated in image A. If the exact same car series label is found, confirm that the car series in image A already exists in the training set;
[0015] Step 2: Confirm the existence of the car series: After querying the training data set, confirm whether the car series of image A is included according to the query results. If the query result returns a matching car series label, it is determined that the car series exists in the training set; if no match is found, the car series is not covered by the current training data set;
[0016] Step 3: Set the distance threshold M: To compare the feature vector distance, you need to set a distance threshold M. This threshold is used to determine whether the similarity between two feature vectors is high enough to be considered to belong to the same category. The specific value of M depends on the application scenario, data characteristics, and the required accuracy requirements.
[0017] Preferably, the specific steps of data screening and set construction in S3: are as follows:
[0018] Step 1: Calculate and filter feature vectors: Calculate feature vectors based on whether the car series to which image A belongs exists in the data set. If the car series exists, only the feature vectors of all images of the car series are calculated. If not, the feature vectors of all images in the data set are calculated. Then, the feature vector F of image A is calculated, and images whose distance to F is less than M are filtered out. At the same time, these images have not been added to the set R.
[0019] Step 2: Construct a temporary set: Construct a temporary set based on the screening results. If the car series exists, the screened images and image A together form set P; if the car series does not exist, then form set Q;
[0020] Step 3: Merge into set R: Finally, all images in the temporary set P or Q are added to set R, which is used to store all images similar to image A.
[0021] Preferably, the data set division in S4 refers to further dividing the images in the set R into a training set and a validation set. For each type of data in the set R, a random sampling method is used to extract images according to a predetermined ratio a. These extracted images will be assigned to the validation set, and the images that are not extracted, that is, the images that account for the remaining (1-a) ratio, naturally constitute the training set.
[0022] Preferably, the model training in S5 utilizes the training set and validation set carefully divided in S4. The training set is used for the initial learning of the model. By iteratively updating the network weights, the model gradually masters the ability to judge the similarity between images. At the same time, the validation set is used as a benchmark for performance evaluation to help continuously adjust network parameters during the training process, such as learning rate and optimizer settings.
[0023] Preferably, the feature vector storage in S6 refers to using the trained twin neural network E to calculate the feature vector of each image in the data set R, compressing the complex information of the image into an efficient numerical representation to facilitate subsequent processing and query. These calculated feature vectors are stored in a database, building an efficient indexing system.
[0024] Preferably, the specific steps of model reasoning and user query in S7 are as follows:
[0025] Step 1: Feature extraction: Receive the image taken by the user and use the trained twin neural network E to calculate the feature vector L of the image;
[0026] Step 2: Database query: In the pre-stored image feature vector database, perform a similarity query to find the image Z corresponding to the feature vector with the highest similarity to the feature vector L;
[0027] Step 3: Matching image recognition: Based on the query results, determine the image Z corresponding to the feature vector most similar to L;
[0028] Step 4: Output vehicle series information: Extract and output vehicle series information from the associated data of image Z. This information should be the same as the vehicle series of the image taken by the user.
[0029] The beneficial effects of the present invention are as follows:
[0030] The present invention addresses the challenge of imbalanced training data. For categories with less training data, the intelligent data expansion technology is used to effectively increase the sample size of the category, thereby compensating for the deficiency caused by data scarcity and enhancing the generalization ability of the model. For categories with abundant training data, a sophisticated data screening process is implemented to reduce the distance between samples within the category, that is, the intra-class distance, making the feature space of the category more compact and clear, optimizing data distribution, and significantly improving the prediction accuracy of the model for each category, providing strong support for processing complex and changeable image recognition tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 This is the overall flow chart of the identification method of the present invention;
[0032] Figure 2 The data screening algorithm flow chart of the present invention;
[0033] Figure 3 This is a flow chart of the model training algorithm of the present invention. DETAILED DESCRIPTION
[0034] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0035] like Figures 1 to 3 As shown, the embodiment of the present invention provides a vehicle series identification method based on one-shot learning. The specific steps of the vehicle series identification method are as follows:
[0036] S1: Data collection and annotation: Use a camera or mobile phone to take a car image A and annotate it with clear car series information (XX brand and XX car series);
[0037] S2: Car series verification and screening condition setting; verify whether the car series of image A is in the training set, and confirm after query; set the distance threshold M for feature vector comparison;
[0038] S3: Data screening and set construction: Calculate feature vectors based on the existence of the car series, screen neighboring images to construct set R, and ensure that no duplicates are added;
[0039] S4: Dataset division: From each type of data in the set R, a proportion of images are randomly selected as the validation set, and the remaining (1-a) proportion of images are used as the training set;
[0040] S5: Model training: Use the divided training set to train the twin network, and adjust the parameters of the validation set to optimize the performance;
[0041] S6: Feature vector storage: Train the twin network E to calculate the features of the R image and store them in the database for subsequent query;
[0042] S7: Model reasoning and user query: When the user uploads a picture, the twin network E is used to extract feature L, the database is searched for similar features Z, and the Z car series information is output to match the car series.
[0043] The data collection and annotation in S1: is performed by picking up a camera (or mobile phone), aiming at a striking car parked on the roadside, and steadily photographing its full appearance to obtain image A. Subsequently, the photo is carefully observed to determine the brand and series of the car, and a professional annotation tool is used to mark "This car is a brand series" in a clear and readable font at a prominent position of image A. This ensures that no matter who views this picture, the specific model of the car can be recognized at a glance. Such annotation not only facilitates subsequent image processing and analysis, but also enhances the information transmission capability of the image.
[0044] The specific steps of vehicle series verification and screening condition setting in S2 are as follows:
[0045] Step 1: Query the training data set: First, you need to access and query the existing training data set. This step includes traversing all the car series labels in the data set and looking for entries that match the car series information annotated in image A. If the exact same car series label is found, it is confirmed that the car series in image A already exists in the training set.
[0046] Step 2: Confirm the existence of the car series: After querying the training data set, confirm whether the car series of image A is included based on the query results. If the query result returns a matching car series label, it is determined that the car series exists in the training set; if no match is found, the car series is not covered by the current training data set.
[0047] Step 3: Set the distance threshold M: When performing feature vector distance comparison (such as in classification, recognition and other tasks), you need to set a distance threshold M, which is used to determine whether the similarity between two feature vectors is high enough to be considered to belong to the same category. The specific value of M depends on the application scenario, data characteristics and required accuracy requirements. Usually, this value needs to be determined through experiments or based on domain knowledge.
[0048] By querying the training data set, it can quickly confirm whether the car model in image A already exists in the data, providing direction for subsequent processing; secondly, confirming the existence of the car model avoids unnecessary calculation and resource waste; finally, reasonably setting the distance threshold M ensures the accuracy of feature vector similarity judgment, laying a solid foundation for image recognition tasks. This series of steps improves the intelligence level of the system and user satisfaction.
[0049] The specific steps of data screening and set construction in S3: are as follows:
[0050] Step 1: Calculate and filter feature vectors: Calculate feature vectors based on whether the car series to which image A belongs exists in the data set. If the car series exists, only the feature vectors of all images of the car series are calculated. If not, the feature vectors of all images in the data set are calculated. Then, the feature vector F of image A is calculated, and images whose distance to F is less than M are filtered out. At the same time, these images have not been added to the set R.
[0051] Step 2: Construct a temporary set: Construct a temporary set based on the screening results. If the car series exists, the screened images and image A together form set P; if the car series does not exist, then form set Q; this step is to temporarily organize similar images for subsequent processing.
[0052] Step 3: Merge to set R: Finally, all images in temporary set P or Q are added to set R, which is used to store all images similar to image A, regardless of whether they belong to the same car series. This step completes the screening of similar images and the construction of set R.
[0053] The data screening and set building process ensures that set R contains only images that are highly similar to image A through precise feature vector calculation and screening. This process not only improves the efficiency of data processing, but also ensures the accuracy and relevance of set R. By organizing similar images into temporary sets P or Q and then merging them into R, effective data integration and utilization are achieved, providing a solid foundation for subsequent image recognition and analysis.
[0054] The data set partitioning in S4 refers to further partitioning the images in the set R into a training set and a validation set. For each type of data in the set R, images are randomly sampled according to a predetermined ratio a. These selected images will be assigned to the validation set, while the unselected images, i.e., the images that account for the remaining (1-a) ratio, naturally constitute the training set. Such a partitioning strategy helps us evaluate the generalization ability of the model during the model training process, while ensuring that the training set is large enough to support effective learning of the model.
[0055] Dataset partitioning brings multiple benefits by carefully dividing the images in set R into training and validation sets, ensuring that the training and validation processes of the model are independent of each other and avoiding data contamination. Random sampling and proportional allocation methods ensure the representativeness and balance of the data, which helps the model learn more comprehensive features. At the same time, this partitioning method enables the model to evaluate performance and adjust parameters in a timely manner during the training process, thereby improving the generalization ability and stability of the model.
[0056] The model training in S5 utilizes the training set and validation set carefully divided in S4. The training set is used for the initial learning of the model. By iteratively updating the network weights, the model gradually masters the ability to judge the similarity between images. At the same time, the validation set is used as a benchmark for performance evaluation to help continuously adjust network parameters such as learning rate and optimizer settings during the training process to optimize the generalization ability and accuracy of the model and ensure that the final model can also perform well on unseen data.
[0057] The training set enables the model to gradually master the ability to judge image similarity and optimize the network weights through iteration; the validation set is used as a performance evaluation benchmark to timely adjust network parameters such as learning rate and optimizer settings to ensure that the model is not overfitting and has good generalization ability. This training strategy effectively improves the accuracy and stability of the model, laying a solid foundation for subsequent image recognition tasks.
[0058] Among them, the feature vector storage in S6 refers to the use of the trained twin neural network E to calculate the feature vector of each image in the data set R, compressing the complex information of the image into an efficient numerical representation to facilitate subsequent processing and query. These calculated feature vectors are stored in the database, building an efficient indexing system.
[0059] The benefit of feature vector storage is that it uses the twin neural network E to convert image data into efficient and compact numerical representations, greatly reducing the complexity of data storage and processing. The efficient indexing system constructed by these feature vectors not only supports fast retrieval, but also ensures accurate matching of image information, providing strong support for subsequent image recognition, classification, retrieval and other tasks. In addition, this storage method also promotes the effective management and utilization of data, and improves the intelligence and response speed of the overall system.
[0060] The specific steps of model reasoning and user query in S7 are as follows:
[0061] Step 1: Feature extraction: Receive the image taken by the user and use the trained twin neural network E to calculate the feature vector L of the image;
[0062] Step 2: Database query: In the pre-stored image feature vector database, perform a similarity query to find the image Z corresponding to the feature vector with the highest similarity to the feature vector L;
[0063] Step 3: Matching image recognition: Based on the query results, determine the image Z corresponding to the feature vector most similar to L;
[0064] Step 4: Output vehicle series information: Extract and output vehicle series information from the associated data of image Z. This information should be the same as the vehicle series of the image taken by the user.
[0065] Through the feature extraction step, the powerful capabilities of the twin neural network E can be used to efficiently convert complex image information into concise and representative feature vectors L. This process greatly simplifies the complexity of subsequent processing. Secondly, the database query step ensures that the stored image Z that is most similar to the user's image is found quickly and accurately, thanks to the pre-built efficient index and similarity calculation mechanism. The matching image recognition step further confirms the accuracy of the query results and provides a reliable basis for subsequent information output. Finally, the step of outputting the car series information not only meets the actual needs of users, but also reflects the efficiency and intelligence level of the entire system. This process-oriented processing method not only improves recognition efficiency, but also enhances user experience. It is an advanced practice in the field of image recognition.
[0066] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0067] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A vehicle series recognition method based on one-shot learning, characterized by: The specific steps of the vehicle series identification method are as follows: S1: Data collection and annotation: Use a camera or mobile phone to take a car image A and annotate it with clear car model information; S2: Car series verification and screening condition setting; verify whether the car series of image A is in the training set, and confirm after query; set the distance threshold M for feature vector comparison; S3: Data screening and set construction: Calculate feature vectors based on the existence of the car series, screen neighboring images to construct set R, and ensure that no duplicates are added; S4: Dataset division: From each type of data in the set R, a proportion of images are randomly selected as the validation set, and the remaining (1-a) proportion of images are used as the training set; S5: Model training: Use the divided training set to train the twin network, and adjust the parameters of the validation set to optimize the performance; S6: Feature vector storage: Train the twin network E to calculate the features of the R image and store them in the database for subsequent query; S7: Model reasoning and user query: When the user uploads a picture, the twin network E is used to extract feature L, the database is searched for similar features Z, and the Z car series information is output to match the car series.
2. The vehicle type identification method based on one-shot learning according to claim 1, characterized in that: The data collection and annotation in S1: is performed by picking up a camera, aiming it at an eye-catching car parked on the side of the road, and steadily photographing its full appearance to obtain image A. Subsequently, the photo is carefully observed to determine the brand and series of the car, and professional annotation tools are used to mark "This car is a brand series" in a prominent position of image A in clear and easy-to-read fonts.
3. The vehicle type identification method based on one-shot learning according to claim 1, characterized in that: The specific steps of vehicle series verification and screening condition setting in S2 are as follows: Step 1: Query the training data set: First, you need to access and query the existing training data set, including traversing all the car series labels in the data set, looking for entries that match the car series information annotated in image A. If the exact same car series label is found, confirm that the car series in image A already exists in the training set; Step 2: Confirm the existence of the car series: After querying the training data set, confirm whether the car series of image A is included according to the query results. If the query result returns a matching car series label, it is determined that the car series exists in the training set; if no match is found, the car series is not covered by the current training data set; Step 3: Set the distance threshold M: To compare the feature vector distance, you need to set a distance threshold M. This threshold is used to determine whether the similarity between two feature vectors is high enough to be considered to belong to the same category. The specific value of M depends on the application scenario, data characteristics, and the required accuracy requirements.
4. The vehicle type identification method based on one-shot learning according to claim 1, characterized in that: The specific steps of data screening and collection construction in S3: are as follows: Step 1: Calculate and filter feature vectors: Calculate feature vectors based on whether the car series to which image A belongs exists in the data set. If the car series exists, only the feature vectors of all images of the car series are calculated. If not, the feature vectors of all images in the data set are calculated. Then, the feature vector F of image A is calculated, and images whose distance to F is less than M are filtered out. At the same time, these images have not been added to the set R. Step 2: Construct a temporary set: Construct a temporary set based on the screening results. If the car series exists, the screened images and image A together form set P; if the car series does not exist, then form set Q; Step 3: Merge into set R: Finally, all images in the temporary set P or Q are added to set R, which is used to store all images similar to image A.
5. The vehicle type identification method based on one-shot learning according to claim 1, characterized in that: The data set partitioning in S4 refers to further dividing the images in the set R into a training set and a validation set. For each type of data in the set R, a random sampling method is used to extract images according to a predetermined ratio a. These extracted images will be assigned to the validation set, and the images that are not extracted, that is, the images that account for the remaining (1-a) ratio, naturally constitute the training set.
6. The vehicle type identification method based on one-shot learning according to claim 1, characterized in that: The model training in S5 utilizes the training set and validation set carefully divided in S4. The training set is used for the initial learning of the model. By iteratively updating the network weights, the model gradually masters the ability to judge the similarity between images. At the same time, the validation set is used as a benchmark for performance evaluation to help continuously adjust network parameters during the training process, such as learning rate and optimizer settings.
7. The vehicle type identification method based on one-shot learning according to claim 1, characterized in that: The feature vector storage in S6 refers to the use of the trained twin neural network E to calculate the feature vector of each image in the data set R, compressing the complex information of the image into an efficient numerical representation to facilitate subsequent processing and query. These calculated feature vectors are stored in the database, building an efficient indexing system.
8. The vehicle type identification method based on one-shot learning according to claim 1, characterized in that: The specific steps of model reasoning and user query in S7 are as follows: Step 1: Feature extraction: Receive the image taken by the user and use the trained twin neural network E to calculate the feature vector L of the image; Step 2: Database query: In the pre-stored image feature vector database, perform a similarity query to find the image Z corresponding to the feature vector with the highest similarity to the feature vector L; Step 3: Matching image recognition: Based on the query results, determine the image Z corresponding to the feature vector most similar to L; Step 4: Output vehicle series information: Extract and output vehicle series information from the associated data of image Z. This information should be the same as the vehicle series of the image taken by the user.
Citation Information
Patent Citations
Vehicle recognition method and device, and storage medium
CN108446612A
Vehicle re-identification method and device, computer equipment and model training method
CN110826484A
A method and device for identifying category to which vehicle belongs
CN111666898A
Vehicle re-identification method and device based on multi-dimensional features
CN112580569A
Motor bearing fault diagnosis method based on twin neural network small sample learning
CN115270883A
