Vehicle re-identification method and model training method
By training a target neural network model and associating its output feature dimensions with parts of the vehicle, the problem of low recognition accuracy and low feature interpretability caused by inconsistent image integrity in vehicle re-identification is solved, achieving higher accuracy and lower cost recognition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ALIBABA INNOVATION PRIVATE LIMITED
- Filing Date
- 2021-05-25
- Publication Date
- 2026-08-04
AI Technical Summary
In existing technologies, vehicle re-identification results are less accurate due to inconsistent image integrity, and the interpretability of generated features is also low.
By training a target neural network model and associating its output feature dimensions with parts of the vehicle, feature sets of the same parts are extracted for similarity comparison, and the target loss function is used to optimize the neural network model.
It improves the accuracy of vehicle re-identification and the interpretability of features, while reducing computational costs.
Smart Images

Figure CN115393750B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of machine learning technology, and more specifically, to a vehicle re-identification method and a model training method. Background Technology
[0002] In typical object re-identification, the image to be detected is processed by a neural network to generate multi-dimensional feature vectors of the target objects. When two images are compared, the feature vectors of the two target objects are determined, the distance between the two feature vectors is calculated, and then a distance threshold is used to determine whether the two images contain the same target object. However, this method has the following drawbacks: when the target object is partially occluded, especially when the completeness of the two target objects is inconsistent (e.g., when comparing vehicle images, image one shows the entire vehicle, while image two shows only the front half), the accuracy of re-identification using neural network feature extraction will significantly decrease due to the inconsistency of the input parts. In this case, although the accuracy can be improved to some extent by aligning the completeness of the two images, such as cropping the front half of image one and then comparing it with image two which only contains the front half, in many scenarios, such as search services, an image needs to be compared with multiple different images simultaneously. This solution requires multiple image cropping and feature extraction, which increases the computational cost significantly. Furthermore, the interpretability of the generated features is low.
[0003] There is currently no effective solution to the above problems. Summary of the Invention
[0004] This application provides a vehicle re-identification method and a model training method to at least solve the technical problems in related technologies where the accuracy of the recognition results is low due to inconsistent image integrity and the interpretability of the generated features is not high.
[0005] According to one aspect of the embodiments of this application, a vehicle re-identification method is provided, comprising: acquiring a first image including a first vehicle and a second image including a second vehicle, wherein the first vehicle in the first image and the second vehicle in the second image have the same target part; inputting the first image and the second image into a target neural network model for analysis to obtain a first feature set corresponding to the target part of the first vehicle and a second feature set corresponding to the target part of the second vehicle, wherein the target neural network model is used to extract feature sets corresponding to the dimension range of each part of the vehicle, and the first feature set and the second feature set have the same dimension range; determining the similarity between the first feature set and the second feature set, and determining that the first vehicle and the second vehicle are the same vehicle when the similarity is greater than a preset threshold.
[0006] According to another aspect of the embodiments of this application, another vehicle re-identification method is also provided, including: acquiring a third image and determining the part information of a third vehicle in the third image; determining all fourth images in a database based on the part information of the third vehicle, wherein the fourth vehicle in the fourth image has the same target part as the third vehicle in the third image; inputting the third image and each of the fourth images into a target neural network model for analysis to obtain a fifth feature set corresponding to the target part of the third vehicle and a sixth feature set corresponding to the target part of the fourth vehicle, wherein the target neural network model is used to extract feature sets corresponding to the dimension range of each part of the vehicle, and the fifth feature set and the sixth feature set have the same dimension range; for any fourth image, determining the similarity between the sixth feature set corresponding to the fourth image and the fifth feature set, and outputting the fourth image when the similarity is greater than a preset threshold.
[0007] According to another aspect of the embodiments of this application, a model training method is also provided, comprising: acquiring a sample image, the sample image including different parts of a sample object; inputting the sample image into a pre-trained neural network model for analysis to obtain a multi-dimensional feature set corresponding to the sample image; determining a target loss function for aligning the parts of the sample object with the dimensions of the features based on the multi-dimensional feature set corresponding to the sample image; adjusting the parameters of the pre-trained neural network model according to the target loss function to obtain a target neural network model, the target neural network model being used to extract feature sets corresponding to the dimensional range of each part of the target object.
[0008] According to another aspect of the embodiments of this application, a model training apparatus is also provided, comprising: an acquisition module for acquiring a sample image, the sample image including different parts of a sample object; an analysis module for inputting the sample image into a pre-trained neural network model for analysis to obtain a multi-dimensional feature set corresponding to the sample image; a determination module for determining a target loss function for aligning the parts of the sample object with the dimensions of the features based on the multi-dimensional feature set corresponding to the sample image; and an adjustment module for adjusting the parameters of the pre-trained neural network model based on the target loss function to obtain a target neural network model, the target neural network model being used to extract feature sets corresponding to the dimensional range of each part of the target object.
[0009] According to another aspect of the embodiments of this application, a non-volatile storage medium is also provided, the non-volatile storage medium including a stored program, wherein, when the program is running, it controls the device where the non-volatile storage medium is located to execute the above-described vehicle re-identification method or model training method.
[0010] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a processor and a memory, the memory being connected to the processor and configured to provide the processor with instructions to perform the following processing steps: acquiring a first image including a first vehicle and a second image including a second vehicle, wherein the first vehicle in the first image and the second vehicle in the second image have the same target part; inputting the first image and the second image into a target neural network model for analysis to obtain a first feature set corresponding to the target part of the first vehicle and a second feature set corresponding to the target part of the second vehicle, wherein the target neural network model is used to extract feature sets corresponding to the dimension range of each part of the vehicle, and the first feature set and the second feature set have the same dimension range; determining the similarity between the first feature set and the second feature set, and determining that the first vehicle and the second vehicle are the same vehicle when the similarity is greater than a preset threshold.
[0011] In this embodiment, by training the target neural network model, the dimension of the vehicle features output by the model is associated with the parts of the vehicle, thereby improving the interpretability of the features. When performing image comparison, the common parts of the vehicle included in each image are determined, and the features corresponding to the common parts in each image are extracted according to the target neural network model to obtain a feature set of the same dimension range. By comparing the similarity of the feature sets of the same dimension range, the accuracy of the obtained recognition result is higher, thereby solving the technical problem of low recognition accuracy and low interpretability of generated features when performing vehicle re-identification in related technologies due to inconsistent image integrity. Attached Figure Description
[0012] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0013] Figure 1 This is a schematic diagram of the structure of a computer terminal according to an embodiment of this application;
[0014] Figure 2 This is a flowchart illustrating a target neural network model training method according to an embodiment of this application;
[0015] Figure 3 This is a schematic diagram illustrating a method for training by extracting vehicle features according to an embodiment of this application;
[0016] Figure 4 This is a schematic diagram illustrating a method for training by extracting pedestrian features according to an embodiment of this application;
[0017] Figure 5 This is a flowchart illustrating a vehicle re-identification method according to an embodiment of this application;
[0018] Figure 6 This is a schematic diagram of vehicle image comparison according to an embodiment of this application;
[0019] Figure 7 This is a schematic diagram of pedestrian image comparison according to an embodiment of this application;
[0020] Figure 8 This is a flowchart illustrating another vehicle re-identification method according to an embodiment of this application;
[0021] Figure 9 This is a flowchart illustrating a model training method according to an embodiment of this application;
[0022] Figure 10 This is a schematic diagram of the structure of a model training device according to an embodiment of this application. Detailed Implementation
[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0025] First, some nouns or terms that appear in the description of the embodiments of this application shall be interpreted as follows:
[0026] Object re-identification, also known as object re-identification, is a technique that uses computer vision to determine whether a specific object exists in an image or video sequence. It is widely considered a sub-problem of image retrieval. Object re-identification aims to learn a model that can extract identity features from object images, that is, extract features that can fully represent the appearance of the object. Based on this model, images of the same object from different cameras can be matched together. By giving an image of an object, images of that object across devices can be retrieved, which can make up for the visual limitations of fixed cameras. It can also be combined with object detection / object tracking technology and can be widely used in various scenarios.
[0027] Example 1
[0028] In related technologies, vehicle re-identification mainly involves inputting vehicle images into a pre-trained neural network model, which extracts vehicle features from the images. During image comparison, the distance relationship between the vehicle features in two images is determined to determine whether the vehicles in the two images are the same vehicle. During image retrieval, the distance relationship between the features of the image to be retrieved and all vehicle images in the database is determined and sorted to find the image that best matches the image to be retrieved.
[0029] However, if parts of the vehicle in the input image are occluded, especially when the two vehicles are not as complete (e.g., image 1 shows the entire vehicle, while image 2 shows only the front half), the accuracy of re-identification using a neural network model to extract features will significantly decrease due to the inconsistency in the input parts. While aligning the completeness of the two images—for example, cropping the front half of image 1 and then comparing it with image 2 which only contains the front half—can improve accuracy to some extent, a search service requires comparing one image with multiple images simultaneously. This necessitates multiple cropping and feature extraction processes, significantly increasing computational costs and reducing the interpretability of the generated features.
[0030] To address the aforementioned issues, this application optimizes the neural network model in related technologies. By introducing new training methods and loss functions, the feature dimensions generated by the final target neural network model are correlated with the vehicle's parts, thereby improving the interpretability of the features and ultimately enhancing the accuracy of vehicle re-identification.
[0031] The training method for the target neural network model provided in this application embodiment can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal (or mobile device) for implementing the training method of the target neural network model is shown. Figure 1As shown, the computer terminal 10 (or mobile device 10) may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0032] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0033] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the target neural network model training method in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the above-mentioned application vulnerability detection method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0034] The transmission module 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0035] The display can be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or mobile device).
[0036] Under the aforementioned operating environment, the training method for the target neural network model provided in this application is as follows: Figure 2 As shown, the process includes at least steps S202-S206, wherein:
[0037] Step S202: Obtain a sample image, which includes different parts of the sample object.
[0038] In some optional embodiments of this application, an original image of the sample object can be obtained, which includes all parts of the sample object; the original image is divided into a preset number of sub-images based on the parts of the sample object, wherein each sub-image includes one part of the sample object; the original image and the preset number of sub-images are used as sample images.
[0039] The sample objects can be vehicles or pedestrians, and the division and quantity of sample objects can be defined according to the user's needs. Figure 3 Taking a vehicle as an example, after acquiring the full vehicle image A, image A can be segmented into a front half image B and a rear half image C based on the front and rear halves of the vehicle. Images A, B, and C are then used together as sample images. Figure 4 Taking a pedestrian as an example, after obtaining the complete image D of the pedestrian, the image D can be divided into an upper body image E and a lower body image F based on the upper and lower body parts. Images D, E, and F are used together as sample images.
[0040] Step S204: Input the sample image into the pre-trained neural network model for analysis to obtain a multi-dimensional feature set corresponding to the sample image.
[0041] Among them, the pre-trained neural network model is used to extract a multi-dimensional feature set corresponding to the sample object in the sample image. The dimension of the output feature can be defined by the user according to their needs, such as the common 256 dimensions.
[0042] Specifically, the original image is input into a pre-trained neural network model for analysis to obtain a third feature set corresponding to the first dimension range of the original image. The third feature set consists of multiple third feature subsets, and the dimension range of each third feature subset is a subset of the first dimension range. Each third feature subset corresponds to a part of the sample object, and the third feature set corresponds to all parts of the sample object.
[0043] For any given sub-image, the sub-image is input into a pre-trained neural network model for analysis to obtain the fourth feature set of the first dimension range corresponding to the sub-image. From the fourth feature set, the fourth feature subset of the second dimension range is determined. The fourth feature subset corresponds to the part of the sample object in the sub-image.
[0044] by Figure 3 For example, when the full vehicle image A is input into the neural network model, the output is a 0-255 dimension third feature set corresponding to the entire vehicle. The third feature set includes two third feature subsets: a 0-127 dimension third feature subset corresponding to the front half of the vehicle and a 128-255 dimension third feature subset corresponding to the rear half of the vehicle. When the front half of the vehicle image B is input into the neural network model, a 0-255 dimension fourth feature set will also be output, where the 0-127 dimension fourth feature subset corresponds to the front half of the vehicle. When the rear half of the vehicle image C is input into the neural network model, a 0-255 dimension fourth feature set will also be output, where the 128-255 dimension fourth feature subset corresponds to the rear half of the vehicle. Figure 4 The same principle applies to extracting features from pedestrian images using a neural network model.
[0045] Step S206: Determine the target loss function based on the multi-dimensional feature set corresponding to the sample image, and adjust the parameters of the pre-trained neural network model according to the target loss function to obtain the target neural network model.
[0046] To ensure that the feature dimensions generated by the final target neural network model are correlated with the parts of the sample object, in some optional embodiments of this application, a second target loss function is determined based on the third feature set and the fourth feature set, respectively, and the parameters of the pre-trained neural network model are adjusted based on the second target loss function; a second target loss function is determined based on each third feature subset and each fourth feature subset, and the parameters of the pre-trained neural network model are adjusted based on the second target loss function; wherein, the type of the second target loss function includes: feature loss function (ID Loss).
[0047] Then, for any sub-image, determine the fourth feature subset corresponding to that sub-image; determine the third feature subset with the same dimensional range as the fourth feature subset from the third feature set; determine the first target loss function based on the third feature subset and the fourth feature subset; adjust the parameters of the pre-trained neural network model based on the first target loss function to obtain the target neural network model. The type of the first target loss function includes: mean squared error loss function (MSELoss).
[0048] Specifically, firstly, for all features generated in each image of the sample image, the ID Loss is determined and the parameters of the pre-trained neural network model are adjusted; then, for the feature set corresponding to each part of the generated image, the ID Loss is determined and the parameters of the pre-trained neural network model are adjusted; finally, for the feature set corresponding to the dimensional range of the included parts generated in each sub-image and the feature set corresponding to the dimensional range of the same parts in the original image, the MSE Loss is determined and the parameters of the pre-trained neural network model are adjusted to obtain the final target neural network model.
[0049] by Figure 3 For example, firstly, the ID Loss is determined based on the 0-255 dimension third feature set corresponding to the full vehicle image A, the 0-255 dimension fourth feature set corresponding to the front half vehicle image B, and the 0-255 dimension fourth feature set corresponding to the rear half vehicle image C, respectively, to adjust the parameters of the neural network model. Then, the ID Loss is determined based on the 0-127 dimension third feature subset corresponding to the full vehicle image A, the 128-255 dimension third feature subset corresponding to the full vehicle image A, the 0-127 dimension fourth feature subset corresponding to the front half vehicle image B, and the 128-255 dimension fourth feature subset corresponding to the rear half vehicle image C, respectively, to adjust the parameters of the neural network model. Finally, the MSE Loss is determined based on the 0-127 dimension third feature subset corresponding to the full vehicle image A and the 0-127 dimension fourth feature subset corresponding to the front half vehicle image B, and the MSE is determined based on the 128-255 dimension third feature subset corresponding to the full vehicle image A and the 128-255 dimension fourth feature subset corresponding to the rear half vehicle image C. Loss is used to adjust the parameters of the neural network model, ultimately obtaining the target neural network model. Figure 4 The same principle applies to determining the target loss function based on the features of pedestrian images.
[0050] Based on the aforementioned target neural network model, this application provides a vehicle re-identification method. It should be noted that the steps shown in the flowchart in the accompanying drawings can also be implemented as follows: Figure 1 The steps are executed in the computer terminal shown, and although the logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0051] Specifically, the process of the vehicle re-identification method provided in this application embodiment is as follows: Figure 5 As shown, the method includes at least steps S502-S506, wherein:
[0052] Step S502: Obtain a first image including a first vehicle and a second image including a second vehicle, wherein the first vehicle in the first image and the second vehicle in the second image have the same target part.
[0053] Understandably, for two vehicle images to be compared, both images must contain at least the same vehicle parts; otherwise, the comparison results will inevitably have significant errors. Therefore, in some optional embodiments of this application, after acquiring the first image and the second image, the first image can be input into a pre-trained target classification model for analysis to obtain the first part information of the first vehicle included in the first image; the second image can be input into the target classification model for analysis to obtain the second part information of the second vehicle included in the second image; based on the first part information and the second part information, the common target parts of the first vehicle in the first image and the second vehicle in the second image can be determined.
[0054] Specifically, when comparing vehicle images, a pre-trained vehicle classification model can be used to analyze the two input images to identify the same vehicle parts in the two images, and these same parts can be used as the target parts for subsequent feature extraction and comparison.
[0055] Step S504: Input the first image and the second image into the target neural network model for analysis to obtain a first feature set corresponding to the target part of the first vehicle and a second feature set corresponding to the target part of the second vehicle. The target neural network model is used to extract feature sets corresponding to the dimension range of each part of the vehicle. The dimension range of the first feature set and the second feature set is the same.
[0056] Step S506: Determine the similarity between the first feature set and the second feature set. If the similarity is greater than a preset threshold, determine that the first vehicle and the second vehicle are the same vehicle.
[0057] In some optional embodiments of this application, the similarity between a first feature set and a second feature set can be represented by determining the distance relationship between them. Commonly used distance relationships include Euclidean distance, cosine distance, KL divergence, and JS divergence. Understandably, the distance between the first feature set and the second feature set is inversely proportional to the similarity; the smaller the distance, the greater the similarity, and vice versa. Users can preset a distance threshold or a similarity threshold to calculate the distance between the first feature set and the second feature set. If the distance is less than the preset distance threshold, it indicates that the similarity between the first feature set and the second feature set is greater than the preset similarity threshold. In this case, the first vehicle and the second vehicle can be considered to be the same vehicle.
[0058] Figure 6 An optional vehicle image comparison strategy is illustrated: if the first input image is a full-vehicle image H and the second image is a full-vehicle image I, the target neural network model extracts a 0-255 dimension first feature set corresponding to the full-vehicle image H and a 0-255 dimension second feature set corresponding to the full-vehicle image I, respectively, and performs distance comparison; if the first input image is a full-vehicle image H and the second image is a front half-vehicle image J, the target neural network model extracts a 0-127 dimension first feature set corresponding to the full-vehicle image H and a 0-127 dimension second feature set corresponding to the front half-vehicle image J, respectively. The second feature set is used for distance comparison. The comparison between the full vehicle image I and the front half vehicle image J is similar. If the first input image is the full vehicle image H and the second image is the rear half vehicle image K, the target neural network model extracts the first feature set of 128-255 dimensions corresponding to the full vehicle image H and the second feature set of 128-255 dimensions corresponding to the rear half vehicle image K, respectively, and performs distance comparison. The comparison between the full vehicle image I and the rear half vehicle image K is similar. It is understandable that the front half vehicle image J and the rear half vehicle image K do not have any identical parts, so there is no value in comparing them. Figure 7 This demonstrates an optional pedestrian image matching strategy, the process of which is the same as that of vehicle image matching, and will not be described in detail here.
[0059] In this embodiment, by training the target neural network model, the dimension of its output features is associated with the parts of the vehicle, thereby improving the interpretability of the features. When performing image comparison, the common parts of the vehicle included in each image are determined, and the features corresponding to the common parts in each image are extracted according to the target neural network model to obtain a feature set of the same dimension range. By comparing the similarity of the feature sets of the same dimension range, the accuracy of the obtained recognition result is higher, thereby solving the technical problem of low recognition accuracy and low interpretability of generated features when performing vehicle re-identification in related technologies due to inconsistent image integrity.
[0060] Example 2
[0061] According to an embodiment of this application, another embodiment of a vehicle re-identification method is also provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can also be implemented as follows: Figure 1 The steps are executed in the computer terminal shown, and although the logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0062] Figure 8 This is a flowchart illustrating the vehicle re-identification method provided in the embodiments of this application, as shown below. Figure 6 As shown, the method includes steps S802-S808, wherein:
[0063] Step S802: Obtain the third image and determine the part information of the third vehicle in the third image.
[0064] Step S804: Based on the part information of the third vehicle, determine all fourth images in the database. The fourth vehicle in the fourth image has the same target part as the third vehicle in the third image.
[0065] In some optional embodiments of this application, when performing image retrieval, after obtaining the input third image, the third image can be input into a pre-trained target classification model for analysis to obtain the target part of the third vehicle included in the third image. Then, all fourth images including the target part are found from the database, and each fourth image is compared with the third image in turn.
[0066] Taking vehicle retrieval as an example, if the vehicle classification model determines that the input third image is a rear half of a vehicle, then all fourth images including the rear half of the vehicle (i.e., all rear half vehicle images and full vehicle images, or images that include only the rear half of the vehicle) are retrieved from the database. These are then compared sequentially with the third image to find the fourth image that matches it. Alternatively, this method can also be applied to pedestrian retrieval. If the pedestrian classification model determines that the input third image is an upper body image, then all fourth images including the upper body (i.e., all upper body images and full body images, or images that include only the upper body) are retrieved from the database. These are then compared sequentially with the third image to find the fourth image that matches it.
[0067] Step S806: Input the third image and each fourth image into the target neural network model for analysis to obtain the fifth feature set corresponding to the target part of the third vehicle and the sixth feature set corresponding to the target part of the fourth vehicle. The target neural network model is used to extract the feature set corresponding to the dimension range of each part of the vehicle. The dimension range of the fifth feature set and the sixth feature set is the same.
[0068] Step S808: For any fourth image, determine the similarity between the sixth feature set and the fifth feature set corresponding to the fourth image, and output the fourth image when the similarity is greater than a preset threshold.
[0069] In some optional embodiments of this application, the training method of the target neural network model is the same as in Embodiment 1. The process of comparing the third image and each fourth image can also refer to the process of comparing the first image with the second image in Embodiment 1. When it is determined that the similarity between the sixth feature set corresponding to a certain fourth image and the fifth feature set corresponding to the third image is greater than a preset threshold, it can be considered that the fourth vehicle in the fourth image and the third vehicle in the third image are the same vehicle, that is, the fourth image matches the third image, and the fourth image is output at this time.
[0070] Alternatively, after determining the similarity between the sixth feature set corresponding to each fourth image and the fifth feature set corresponding to the third image, all the obtained similarities can be sorted, and one or more fourth images with the highest similarity can be selected as the images that match the third image and output.
[0071] In this embodiment, by training a target neural network model, the dimensions of its output features are correlated with the parts of the vehicle, thus improving the interpretability of the features. During image retrieval, all images containing the same parts as the image to be retrieved are first identified. Features corresponding to these same parts in each image are extracted based on the target neural network model, resulting in a feature set with the same dimensional range. By comparing the similarity of these feature sets with the same dimensional range, images matching the image to be retrieved are identified. Since this method only needs to generate the features corresponding to the target part's dimension once and then compare them with the features of the same dimension corresponding to the same part in other images, instead of extracting features multiple times when comparing with different images, it effectively reduces computational costs. Simultaneously, it solves the technical problems in related technologies where inconsistent image completeness leads to low accuracy in vehicle re-identification and low interpretability of generated features.
[0072] Example 3
[0073] According to an embodiment of this application, an embodiment of a model training method is also provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can also be implemented as follows: Figure 1 The steps are executed in the computer terminal shown, and although the logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0074] Figure 9 This is a flowchart illustrating the model training method provided in the embodiments of this application, as shown below. Figure 9As shown, the method includes steps S902-S908, wherein:
[0075] Step S902: Obtain a sample image, which includes different parts of the sample object.
[0076] In some optional embodiments of this application, an original image of the sample object can be obtained, which includes all parts of the sample object; based on the parts of the sample object, the original image is divided into a preset number of sub-images, wherein each sub-image includes one part of the sample object; the original image and the preset number of sub-images are used as a sample image. The sample object can be a vehicle or a pedestrian, and the division and number of parts of the sample object can be defined according to the user's needs.
[0077] Step S904: Input the sample image into the pre-trained neural network model for analysis to obtain a multi-dimensional feature set corresponding to the sample image.
[0078] The pre-trained neural network model is used to extract multi-dimensional feature sets corresponding to sample objects in the sample image. The dimension of the output features can be defined according to the user's needs, such as the common 256 dimensions. Specifically, the original image is input into the pre-trained neural network model for analysis, resulting in a third feature set corresponding to the first dimension range of the original image. The third feature set consists of multiple third feature subsets, each of which has a dimension range that is a subset of the first dimension range. Each third feature subset corresponds to a part of the sample object, and the third feature set corresponds to all parts of the sample object. For any sub-image, the sub-image is input into the pre-trained neural network model for analysis, resulting in a fourth feature set corresponding to the first dimension range of the sub-image. From the fourth feature set, a fourth feature subset with a second dimension range is determined, and this fourth feature subset corresponds to a part of the sample object in the sub-image.
[0079] Step S906: Based on the multi-dimensional feature set corresponding to the sample image, determine the target loss function used to align the parts of the sample object with the dimensions of the features.
[0080] Step S908: Adjust the parameters of the pre-trained neural network model according to the target loss function to obtain the target neural network model. The target neural network model is used to extract the feature set corresponding to the dimension range of each part of the target object.
[0081] To ensure that the feature dimensions generated by the final target neural network model are correlated with the parts of the sample object, in some optional embodiments of this application, a second target loss function is determined based on a third feature set and a fourth feature set, respectively, and the parameters of the pre-trained neural network model are adjusted based on the second target loss function; a second target loss function is also determined based on each third feature subset and each fourth feature subset, and the parameters of the pre-trained neural network model are adjusted based on the second target loss function; wherein, the type of the second target loss function includes ID Loss. Then, for any sub-image, a fourth feature subset corresponding to that sub-image is determined; a third feature subset with the same dimensional range as the fourth feature subset is determined from the third feature set; a first target loss function is determined based on the third and fourth feature subsets, and the parameters of the pre-trained neural network model are adjusted based on the first target loss function to obtain the target neural network model, wherein, the type of the first target loss function includes MSE Loss.
[0082] In this embodiment, by introducing a new training method and loss function, the neural network model in the related technology is optimized, so that the feature dimension generated by the final target neural network model is related to the part of the target object, thereby improving the interpretability of the features and thus improving the accuracy of target object re-identification.
[0083] Example 4
[0084] According to an embodiment of this application, a model training apparatus for implementing the model method in embodiment 3 is also provided, such as... Figure 10 As shown, the device includes an acquisition module 100, an analysis module 102, a determination module 104, and an adjustment module 106, wherein:
[0085] The acquisition module 100 is used to acquire sample images, which include different parts of the sample object.
[0086] In some optional embodiments of this application, an original image of the sample object can be obtained, which includes all parts of the sample object; based on the parts of the sample object, the original image is divided into a preset number of sub-images, wherein each sub-image includes one part of the sample object; the original image and the preset number of sub-images are used as a sample image. The sample object can be a vehicle or a pedestrian, and the division and number of parts of the sample object can be defined according to the user's needs.
[0087] The analysis module 102 is used to input the sample image into the pre-trained neural network model for analysis, and obtain a multi-dimensional feature set corresponding to the sample image.
[0088] The pre-trained neural network model is used to extract multi-dimensional feature sets corresponding to sample objects in the sample image. The dimension of the output features can be defined according to the user's needs, such as the common 256 dimensions. Specifically, the original image is input into the pre-trained neural network model for analysis, resulting in a third feature set corresponding to the first dimension range of the original image. The third feature set consists of multiple third feature subsets, each of which has a dimension range that is a subset of the first dimension range. Each third feature subset corresponds to a part of the sample object, and the third feature set corresponds to all parts of the sample object. For any sub-image, the sub-image is input into the pre-trained neural network model for analysis, resulting in a fourth feature set corresponding to the first dimension range of the sub-image. From the fourth feature set, a fourth feature subset with a second dimension range is determined, and this fourth feature subset corresponds to a part of the sample object in the sub-image.
[0089] The determination module 104 is used to determine the target loss function for aligning the parts of the sample object with the dimensions of the features based on the multi-dimensional feature set corresponding to the sample image.
[0090] The adjustment module 106 is used to adjust the parameters of the pre-trained neural network model according to the target loss function to obtain the target neural network model. The target neural network model is used to extract the feature set corresponding to the dimension range of each part of the target object.
[0091] To ensure that the feature dimensions generated by the final target neural network model are correlated with the parts of the sample object, in some optional embodiments of this application, a second target loss function is determined based on a third feature set and a fourth feature set, respectively, and the parameters of the pre-trained neural network model are adjusted based on the second target loss function; a second target loss function is also determined based on each third feature subset and each fourth feature subset, and the parameters of the pre-trained neural network model are adjusted based on the second target loss function; wherein, the type of the second target loss function includes ID Loss. Then, for any sub-image, a fourth feature subset corresponding to that sub-image is determined; a third feature subset with the same dimensional range as the fourth feature subset is determined from the third feature set; a first target loss function is determined based on the third and fourth feature subsets, and the parameters of the pre-trained neural network model are adjusted based on the first target loss function to obtain the target neural network model, wherein, the type of the first target loss function includes MSE Loss.
[0092] It should be noted that each module in the model training device in this embodiment corresponds one-to-one with the implementation steps of the model training method in embodiment 3. Some details not shown in this embodiment can be referred to embodiment 3, and will not be elaborated further here.
[0093] Example 5
[0094] According to an embodiment of this application, a non-volatile storage medium is also provided, which includes a stored program, wherein the program controls the device where the non-volatile storage medium is located to execute the above-described vehicle re-identification method or model training method when it is running.
[0095] Optionally, during program execution, the device containing the non-volatile storage medium is controlled to perform the following steps: acquiring a first image including a first vehicle and a second image including a second vehicle, wherein the first vehicle in the first image and the second vehicle in the second image have the same target part; inputting the first image and the second image into a target neural network model for analysis to obtain a first feature set corresponding to the target part of the first vehicle and a second feature set corresponding to the target part of the second vehicle, wherein the target neural network model is used to extract feature sets corresponding to the dimension range of each part of the vehicle, and the dimension range of the first feature set and the second feature set is the same; determining the similarity between the first feature set and the second feature set, and determining that the first vehicle and the second vehicle are the same vehicle when the similarity is greater than a preset threshold.
[0096] Optionally, during program execution, the device containing the non-volatile storage medium executes the following steps: acquiring a third image and determining the part information of the third vehicle in the third image; based on the part information of the third vehicle, determining all fourth images in the database, wherein the fourth vehicle in the fourth image has the same target part as the third vehicle in the third image; inputting the third image and each fourth image into a target neural network model for analysis to obtain a fifth feature set corresponding to the target part of the third vehicle and a sixth feature set corresponding to the target part of the fourth vehicle, wherein the target neural network model is used to extract feature sets corresponding to the dimension range of each part of the vehicle, and the dimension range of the fifth feature set and the sixth feature set is the same; for any fourth image, determining the similarity between the sixth feature set and the fifth feature set corresponding to the fourth image, and outputting the fourth image when the similarity is greater than a preset threshold.
[0097] Optionally, during program execution, the device containing the non-volatile storage medium is controlled to perform the following steps: acquiring a sample image, which includes different parts of the sample object; inputting the sample image into a pre-trained neural network model for analysis to obtain a multi-dimensional feature set corresponding to the sample image; determining a target loss function to align the parts of the sample object with the dimensions of the features based on the multi-dimensional feature set corresponding to the sample image; adjusting the parameters of the pre-trained neural network model based on the target loss function to obtain a target neural network model, which is used to extract the feature set corresponding to the dimension range of each part of the target object.
[0098] Example 6
[0099] According to an embodiment of this application, an electronic device is also provided, comprising a processor and a memory, wherein: the memory is connected to the processor and is used to provide the processor with instructions to perform the following processing steps: acquiring a first image including a first vehicle and a second image including a second vehicle, wherein the first vehicle in the first image and the second vehicle in the second image have the same target part; inputting the first image and the second image into a target neural network model for analysis to obtain a first feature set corresponding to the target part of the first vehicle and a second feature set corresponding to the target part of the second vehicle, wherein the target neural network model is used to extract feature sets corresponding to the dimension range of each part of the vehicle, and the dimension range of the first feature set and the second feature set are the same; determining the similarity between the first feature set and the second feature set, and determining that the first vehicle and the second vehicle are the same vehicle when the similarity is greater than a preset threshold.
[0100] Optionally, the memory also stores instructions for processing the following steps: acquiring a third image and determining the part information of a third vehicle in the third image; based on the part information of the third vehicle, determining all fourth images in the database, wherein the fourth vehicle in the fourth image has the same target part as the third vehicle in the third image; inputting the third image and each fourth image into a target neural network model for analysis to obtain a fifth feature set corresponding to the target part of the third vehicle and a sixth feature set corresponding to the target part of the fourth vehicle, wherein the target neural network model is used to extract feature sets corresponding to the dimension range of each part of the vehicle, and the fifth feature set and the sixth feature set have the same dimension range; for any fourth image, determining the similarity between the sixth feature set and the fifth feature set corresponding to the fourth image, and outputting the fourth image when the similarity is greater than a preset threshold.
[0101] Optionally, the memory also stores instructions for processing the following steps: acquiring a sample image, which includes different parts of a sample object; inputting the sample image into a pre-trained neural network model for analysis to obtain a multi-dimensional feature set corresponding to the sample image; determining a target loss function to align the parts of the sample object with the dimensions of the features based on the multi-dimensional feature set corresponding to the sample image; adjusting the parameters of the pre-trained neural network model based on the target loss function to obtain a target neural network model, which is used to extract the feature set corresponding to the dimensional range of each part of the target object.
[0102] In some optional embodiments of this application, the specific structure of the above-described electronic device can be referred to as follows: Figure 1 The computer terminal shown. It should be noted that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. The structure of this electronic device can be similar to... Figure 1The computer terminals shown are the same, but may also include those shown. Figure 1 The more or fewer components shown may also have the same Figure 1 The different configurations shown.
[0103] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0104] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0105] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of units or modules may be electrical or other forms.
[0106] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0107] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0108] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0109] The above are merely preferred embodiments of this application. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A vehicle re-identification method, comprising: Acquire a first image including a first vehicle and a second image including a second vehicle, wherein the first vehicle in the first image and the second vehicle in the second image have the same target part; The first image and the second image are input into a target neural network model for analysis to obtain a first feature set corresponding to the target part of the first vehicle and a second feature set corresponding to the target part of the second vehicle. The target neural network model is used to extract feature sets corresponding to the dimension range of each part of the vehicle. The first feature set and the second feature set have the same dimension range. Determine the similarity between the first feature set and the second feature set, and determine that the first vehicle and the second vehicle are the same vehicle when the similarity is greater than a preset threshold; The target neural network model is determined through the following steps: acquiring an original image of a sample object, wherein the original image includes all parts of the sample object; segmenting the original image into a predetermined number of sub-images based on the parts of the sample object, wherein each sub-image includes one part of the sample object; using the original image and the predetermined number of sub-images as sample images, wherein the sample images include different parts of the sample object; acquiring a multi-dimensional feature set corresponding to the sample images, wherein the multi-dimensional feature set includes: a third feature set corresponding to the original image, a fourth feature set corresponding to the sub-images, a fourth feature subset of the fourth feature set, and a third feature subset of the third feature set; determining a second target loss function based on the third feature set and the fourth feature set; determining the second target loss function based on the third feature subset and the fourth feature subset; determining a first target loss function based on the third feature subset and the fourth feature subset; and adjusting the model parameters of the pre-trained neural network model based on the second target loss function and the first target loss function to obtain the target neural network model.
2. The method according to claim 1, wherein, The step of obtaining the multi-dimensional feature set corresponding to the sample image includes: The sample image is input into the pre-trained neural network model for analysis to obtain the multi-dimensional feature set corresponding to the sample image.
3. The method according to claim 2, wherein, The step of inputting the sample image into the pre-trained neural network model for analysis to obtain the multi-dimensional feature set corresponding to the sample image includes: The original image is input into the pre-trained neural network model for analysis to obtain the third feature set corresponding to the first dimension range of the original image. The third feature set is composed of multiple third feature subsets, and the dimension range of each third feature subset is a subset of the first dimension range. Each third feature subset corresponds to a part of the sample object, and the third feature set corresponds to all parts of the sample object. For any given sub-image, the sub-image is input into the pre-trained neural network model for analysis to obtain the fourth feature set corresponding to the first dimension range of the sub-image. From the fourth feature set, a fourth feature subset with a second dimension range is determined, and the fourth feature subset corresponds to the part of the sample object in the sub-image.
4. The method according to claim 1, wherein, The step of obtaining the multi-dimensional feature set corresponding to the sample image includes: For any given sub-image, determine the fourth feature subset corresponding to the sub-image; From the third feature set, determine the third feature subset that has the same dimensional range as the fourth feature subset; The step of determining the first target loss function based on the third feature subset and the fourth feature subset includes: The first target loss function is determined based on the third feature subset and the fourth feature subset, wherein the type of the first target loss function includes: mean squared error loss function.
5. The method according to claim 4, wherein, The step of determining the second target loss function based on the third feature set and the fourth feature set includes: The second target loss function is determined based on the third feature set and the fourth feature set, respectively. The step of determining the second target loss function based on the third feature subset and the fourth feature subset includes: The second target loss function is determined based on each of the third feature subsets and each of the fourth feature subsets, wherein the type of the second target loss function includes: feature loss function.
6. The method according to claim 1, wherein, After acquiring a first image including a first vehicle and a second image including a second vehicle, the method further includes: The first image is input into a pre-trained target classification model for analysis to obtain information about the first part of the first vehicle included in the first image. The second image is input into the target classification model for analysis to obtain information about the second part of the second vehicle included in the second image; Based on the first part information and the second part information, the same target part is determined to be present in the first vehicle in the first image and the second vehicle in the second image.
7. The method according to claim 1, wherein the distance between the first feature set and the second feature set is inversely proportional to the similarity, wherein, The distances include: Euclidean distance, cosine distance, KL divergence, and JS divergence.
8. A vehicle re-identification method, comprising: Acquire a third image and determine the part information of the third vehicle in the third image; Based on the part information of the third vehicle, all fourth images in the database are identified, wherein the fourth vehicle in the fourth image has the same target part as the third vehicle in the third image; The third image and each of the fourth images are input into the target neural network model for analysis to obtain a fifth feature set corresponding to the target part of the third vehicle and a sixth feature set corresponding to the target part of the fourth vehicle. The target neural network model is used to extract feature sets corresponding to the dimension range of each part of the vehicle. The dimension range of the fifth feature set and the sixth feature set are the same. For any of the fourth images, determine the similarity between the sixth feature set corresponding to the fourth image and the fifth feature set, and output the fourth image when the similarity is greater than a preset threshold; The target neural network model is determined through the following process: acquiring the original image of the sample object, wherein the original image includes all parts of the sample object; segmenting the original image into a predetermined number of sub-images based on the parts of the sample object, wherein each sub-image includes one part of the sample object; using the original image and the predetermined number of sub-images as sample images, wherein the sample images include different parts of the sample object; acquiring a multi-dimensional feature set corresponding to the sample images, wherein the multi-dimensional feature set includes: a third feature set corresponding to the original image, a fourth feature set corresponding to the sub-images, a fourth feature subset of the fourth feature set, and a third feature subset of the third feature set; determining a second target loss function based on the third feature set and the fourth feature set; determining the second target loss function based on the third feature subset and the fourth feature subset; determining a first target loss function based on the third feature subset and the fourth feature subset; and adjusting the model parameters of the pre-trained neural network model based on the second target loss function and the first target loss function to obtain the target neural network model.
9. A model training method, comprising: Obtain the original image of the sample object, wherein the original image includes all parts of the sample object; based on the parts of the sample object, divide the original image into a preset number of sub-images, wherein each sub-image includes one part of the sample object; use the original image and the preset number of sub-images as sample images, wherein the sample images include different parts of the sample object; The sample image is input into a pre-trained neural network model for analysis to obtain a multi-dimensional feature set corresponding to the sample image. The multi-dimensional feature set includes: a third feature set corresponding to the original image, a fourth feature set corresponding to the sub-image, a fourth feature subset in the fourth feature set, and a third feature subset in the third feature set. Based on the multi-dimensional feature set corresponding to the sample image, a target loss function is determined to align the parts of the sample object with the dimensions of the features; The parameters of the pre-trained neural network model are adjusted according to the target loss function to obtain the target neural network model, which is used to extract the feature set corresponding to the dimension range of each part of the target object; The step of determining a target loss function to align the parts of the sample object with the dimensions of the features based on the multi-dimensional feature set corresponding to the sample image includes: determining a second target loss function based on the third feature set and the fourth feature set; determining the second target loss function based on the third feature subset and the fourth feature subset; and determining a first target loss function based on the third feature subset and the fourth feature subset.
10. A non-volatile storage medium, the non-volatile storage medium comprising a stored program, wherein, When the program is running, it controls the device containing the non-volatile storage medium to execute the vehicle re-identification method according to any one of claims 1 to 8.
11. An electronic device, comprising: processor; as well as A memory, connected to the processor, for providing the processor with instructions to perform the following processing steps: Acquire a first image including a first vehicle and a second image including a second vehicle, wherein the first vehicle in the first image and the second vehicle in the second image have the same target part; The first image and the second image are input into a target neural network model for analysis to obtain a first feature set corresponding to the target part of the first vehicle and a second feature set corresponding to the target part of the second vehicle. The target neural network model is used to extract feature sets corresponding to the dimension range of each part of the vehicle. The first feature set and the second feature set have the same dimension range. Determine the similarity between the first feature set and the second feature set, and determine that the first vehicle and the second vehicle are the same vehicle when the similarity is greater than a preset threshold; The target neural network model is determined through the following process: acquiring the original image of the sample object, wherein the original image includes all parts of the sample object; segmenting the original image into a predetermined number of sub-images based on the parts of the sample object, wherein each sub-image includes one part of the sample object; using the original image and the predetermined number of sub-images as sample images, wherein the sample images include different parts of the sample object; acquiring a multi-dimensional feature set corresponding to the sample images, wherein the multi-dimensional feature set includes: a third feature set corresponding to the original image, a fourth feature set corresponding to the sub-images, a fourth feature subset of the fourth feature set, and a third feature subset of the third feature set; determining a second target loss function based on the third feature set and the fourth feature set; determining the second target loss function based on the third feature subset and the fourth feature subset; determining a first target loss function based on the third feature subset and the fourth feature subset; and adjusting the model parameters of the pre-trained neural network model based on the second target loss function and the first target loss function to obtain the target neural network model.