Vehicle re-identification method, system and device based on CAM-OSNet, and medium
Through CAM-OSNet's full-scale network training and feature fusion, the problem of unstable feature extraction of vehicle re-identification under different cameras is solved, and efficient and accurate vehicle recognition is achieved, and it is applied to traffic management and security monitoring.
Patent Information
- Application Number
- CN202510558150.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2025-08-08
AI Technical Summary
When existing vehicle re-identification technology faces changes in vehicle attitude and scale, it is difficult to maintain stable and accurate feature extraction under different cameras, resulting in limited accuracy and efficiency of the identification system.
The vehicle re-identification method based on CAM-OSNet is adopted to train the vehicle re-identification model through a full-scale network, combining hierarchical feature fusion, attention mechanism and consistency loss calculation to improve feature extraction and matching accuracy.
It improves the accuracy and efficiency of vehicle re-identification, enhances the robustness of the model, and can accurately identify vehicles in different scenarios and camera perspectives, improving the intelligence level of traffic management and security monitoring.
Smart Images

Figure CN120451870A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of deep learning technology and relates to a vehicle re-identification method, system, device and medium based on CAM-OSNet. Background Art
[0002] In today's era of booming digitalization and intelligentization, vehicle re-identification technology has emerged as the times require. The widespread coverage of traffic cameras in cities provides strong data support for its development. Vehicle re-identification technology plays an indispensable role in many areas of society today, including key aspects such as traffic management and security. When a suspicious vehicle is captured at a monitoring point, vehicle re-identification technology can automatically and quickly identify and lock onto the target in all camera images along the route, providing key clues for public security investigations. This technology is also widely used in scenarios such as traffic violation evidence collection, intelligent parking management, and autonomous driving environmental perception, effectively enhancing the level of intelligent urban management.
[0003] Early vehicle identification relied primarily on license plate recognition systems based on optical character recognition (OCR). While this technology can achieve high accuracy using high-definition cameras, its application has significant limitations. Conventional surveillance cameras are not specifically designed for license plate recognition, making it difficult to ensure clear license plate visibility. Cameras are limited by factors such as mounting angle and shooting distance, often resulting in incomplete license plate capture, blurry images, or reflections. Furthermore, traditional solutions face challenges with license plates that are obscured, damaged, forged, or unlicensed, making it even more difficult to ensure consistent vehicle identity across cameras. Vehicle re-ID technology, however, achieves precise identity association by extracting multi-dimensional vehicle features. This overcomes the scenario limitations of traditional methods and enables more reliable vehicle tracking in a variety of complex surveillance scenarios.
[0004] Deep learning algorithms have greatly promoted the development of vehicle re-identification technology. By building a multi-layer neural network structure to learn from massive amounts of vehicle images, it is possible to accurately capture information such as the vehicle's appearance, color, and model. This deep learning-based feature extraction frees vehicle re-identification methods from reliance on a single license plate. Even if the license plate is invisible, it can still achieve accurate matching based on the vehicle's deep features. Currently, a variety of vehicle re-identification methods have been developed. Global feature-based methods achieve recognition by extracting the overall appearance of the vehicle. Local feature-based methods focus on details such as headlights and grilles to improve robustness. Metric learning algorithms optimize feature space distances. Multimodal fusion technology integrates appearance and auxiliary information. Video sequence analysis methods fully utilize temporal features to enhance recognition performance.
[0005] However, vehicle re-identification technology faces many challenges in its application. First, the different distances of the vehicle from the camera will cause significant scale changes. When the vehicle is close to the camera, it will appear larger in the image and can show more details; when the vehicle is far away from the camera, it will appear smaller, and many key details of the vehicle may become blurred due to insufficient resolution. This makes it difficult for the recognition system to maintain stable and accurate feature extraction capabilities at different scales, seriously affecting the accuracy of vehicle matching. Secondly, the difference in viewing angles between different surveillance cameras will also cause the same vehicle to appear significantly different in appearance in the images captured by different cameras. When the vehicle switches from a frontal perspective to a side or oblique perspective, its visible visual features will change significantly, further increasing the difficulty of matching.
[0006] In summary, existing re-ID algorithms cannot accurately match vehicles when the vehicle posture and scale vary greatly. Summary of the Invention
[0007] The purpose of the present invention is to overcome the shortcomings of the above-mentioned prior art and provide a vehicle re-identification method, system, device and medium based on CAM-OSNet, which can improve the accuracy and efficiency of vehicle re-identification.
[0008] To achieve the above objectives, the present invention discloses a vehicle re-identification method based on CAM-OSNet, comprising:
[0009] Acquire vehicle images;
[0010] The vehicle image is input into a trained vehicle re-identification model to identify information about the current vehicle, wherein the vehicle re-identification model is trained based on a full-scale network.
[0011] The vehicle re-identification method based on CAM-OSNet described in the present invention is further improved in that:
[0012] Furthermore, the vehicle re-identification model includes Layer 1, Layer 2, Layer 3, Layer 4, Layer 5, a first upsampling layer, a second upsampling layer, a first 1×1 convolution kernel, a second 1×1 convolution kernel, a first splicing layer, a Light 3×3 layer, a coordinate attention mechanism layer, a second splicing layer, a batch normalization layer, a global average pooling layer, and a classifier;
[0013] The output of Layer1 is connected to the input of Layer2, the output of Layer2 is connected to the input of Layer3, the output of Layer3 is connected to the input of the first upsampling layer and the input of Layer4, the output of the first upsampling layer is connected to the input of the first 1×1 convolution kernel, the output of Layer4 is connected to the input of Layer5, the output of Layer4 is connected to the input of the second upsampling layer, the output of the second upsampling layer is connected to the input of the second 1×1 convolution kernel, the output of the first 1×1 convolution kernel, the output of the second 1×1 convolution kernel and the output of Layer2 are connected to the input of the first splicing layer, and the output of the first splicing layer is connected to the input of the Light 3×3 layer. The output of the 3×3 layer is connected to the input of the coordinate attention mechanism layer, the output of the coordinate attention mechanism layer and the output of the Layer5 layer are connected to the input of the second splicing layer, the output of the second splicing layer is connected to the input of the batch normalization (BN) layer, the output of the batch normalization layer is connected to the input of the global average pooling (GAP) layer, and the output of the global average pooling layer is connected to the input of the classifier.
[0014] Furthermore, the vehicle re-identification model also includes a two-dimensional convolutional layer and a consistency loss calculation module;
[0015] During the training process, the feature map output by the batch normalization layer is averaged in the C direction to obtain the spatial attention map. At the same time, the feature map output by the batch normalization layer passes through the two-dimensional convolution layer to obtain the category activation map. The spatial attention map and the category activation map are sent to the consistency loss calculation module. The difference between the two is measured by the mean square error loss. By minimizing the loss, the spatial attention map and the category activation map are kept consistent.
[0016] Furthermore, the loss function of the vehicle re-identification model during training is:
[0017] Loss=Loss ID +Loss tri +λLoss MSE
[0018] Among them, Loss ID 、Loss tri and Loss MSE They represent cross entropy loss, triplet loss and consistency loss respectively, and λ is the corresponding weight coefficient.
[0019] Furthermore, the video frames are acquired through the camera for detection, and a single vehicle image is obtained.
[0020] The present invention discloses a vehicle re-identification system based on CAM-OSNet, comprising:
[0021] An acquisition module, used for acquiring vehicle images;
[0022] The recognition module is used to input the vehicle image into the trained vehicle re-identification model to identify the information of the current vehicle. The vehicle re-identification model is trained based on the full-scale network.
[0023] The vehicle re-identification system based on CAM-OSNet described in the present invention is further improved in that:
[0024] Furthermore, the vehicle re-identification model includes Layer 1, Layer 2, Layer 3, Layer 4, Layer 5, a first upsampling layer, a second upsampling layer, a first 1×1 convolution kernel, a second 1×1 convolution kernel, a first splicing layer, a Light 3×3 layer, a coordinate attention mechanism layer, a second splicing layer, a batch normalization layer, a global average pooling layer, and a classifier;
[0025] The output of Layer1 is connected to the input of Layer2, the output of Layer2 is connected to the input of Layer3, the output of Layer3 is connected to the input of the first upsampling layer and the input of Layer4, the output of the first upsampling layer is connected to the input of the first 1×1 convolution kernel, the output of Layer4 is connected to the input of Layer5, the output of Layer4 is connected to the input of the second upsampling layer, the output of the second upsampling layer is connected to the input of the second 1×1 convolution kernel, the output of the first 1×1 convolution kernel, the output of the second 1×1 convolution kernel and the output of Layer2 are connected to the input of the first splicing layer, and the output of the first splicing layer is connected to the input of the Light 3×3 layer. The output of the 3×3 layer is connected to the input of the coordinate attention mechanism layer, the output of the coordinate attention mechanism layer and the output of the Layer5 layer are connected to the input of the second splicing layer, the output of the second splicing layer is connected to the input of the batch normalization (BN) layer, the output of the batch normalization layer is connected to the input of the global average pooling (GAP) layer, and the output of the global average pooling layer is connected to the input of the classifier.
[0026] Furthermore, the vehicle re-identification model also includes a two-dimensional convolutional layer and a consistency loss calculation module;
[0027] During the training process, the feature map output by the batch normalization layer is averaged in the C direction to obtain the spatial attention map. At the same time, the feature map output by the batch normalization layer passes through the two-dimensional convolution layer to obtain the category activation map. The spatial attention map and the category activation map are sent to the consistency loss calculation module. The difference between the two is measured by the mean square error loss. By minimizing the loss, the spatial attention map and the category activation map are kept consistent.
[0028] The present invention discloses a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the vehicle re-identification method based on CAM-OSNet are implemented.
[0029] The present invention discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the vehicle re-identification method based on CAM-OSNet are implemented.
[0030] The present invention has the following beneficial effects:
[0031] During specific operation, the CAM-OSNet-based vehicle re-identification method, system, device, and medium of the present invention input the vehicle image into a trained vehicle re-identification model to identify the features of the current vehicle. The vehicle re-identification model is trained based on a full-scale network. The full-scale network uses efficient convolution operations to perform multi-scale feature extraction on the vehicle image, enabling the network to capture the detailed features and overall features of the vehicle and enrich the feature expression. After fusing features from different layers, an attention mechanism is used to integrate information from different layers and scales, and potential correlations between features are explored, thereby improving the accuracy and efficiency of vehicle re-identification and enhancing the robustness of the model. After consistency processing of the class activation map, the feature map is supervised to enhance the features. Finally, the cosine distance is used to calculate similarity to achieve vehicle re-identification with high recognition efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The accompanying drawings, which constitute part of the present invention, are intended to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are intended to explain the present invention and do not constitute an undue limitation of the present invention. In the accompanying drawings:
[0033] Figure 1 is a flow chart of the method of the present invention;
[0034] Figure 2 This is a model architecture diagram of the present invention. DETAILED DESCRIPTION
[0035] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0036] In the description of the present invention, it is to be understood that the terms “include” and “comprise” indicate the presence of the described features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or collections thereof.
[0037] It should also be understood that the terms used in the present specification are only for the purpose of describing particular embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0038] It should be further understood that the term "and / or" as used in the present specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in the present invention generally indicates that the associated objects are in an "or" relationship.
[0039] It should be understood that although the terms "first," "second," and "third" may be used to describe preset ranges in embodiments of the present invention, these preset ranges should not be limited to these terms. These terms are merely used to distinguish one preset range from another. For example, without departing from the scope of embodiments of the present invention, the first preset range may also be referred to as the second preset range, and similarly, the second preset range may also be referred to as the first preset range.
[0040] The word "if," as used herein, may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to the determination" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)," depending on the context.
[0041] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0042] The accompanying drawings illustrate various schematic diagrams of structures according to embodiments disclosed herein. These figures are not drawn to scale; for clarity, some details are exaggerated and some details may be omitted. The shapes of the various regions and layers shown in the figures, as well as their relative sizes and positional relationships, are merely exemplary and may deviate in practice due to manufacturing tolerances or technical limitations. Those skilled in the art may design regions / layers with different shapes, sizes, and relative positions as needed.
[0043] Example 1
[0044] refer to Figure 1 and Figure 2 The vehicle re-identification method based on CAM-OSNet of the present invention comprises the following steps:
[0045] The camera acquires video frames for detection and obtains a single vehicle image;
[0046] The vehicle image is input into the trained vehicle re-identification model to identify the information of the current vehicle.
[0047] The vehicle re-identification model is based on the Omni Scale Network (OSNet) and improves the Omni Scale Network. Specifically, the vehicle re-identification model includes Layer 1, Layer 2, Layer 3, Layer 4, Layer 5, the first upsampling layer, the second upsampling layer, the first 1×1 convolution kernel, the second 1×1 convolution kernel, the first splicing layer, the Light 3×3 layer, the coordinate attention mechanism layer, the second splicing layer, the batch normalization layer, the global average pooling layer, the classifier, the two-dimensional convolution layer and the consistency loss calculation module;
[0048] The output of Layer1 is connected to the input of Layer2, the output of Layer2 is connected to the input of Layer3, the output of Layer3 is connected to the input of the first upsampling layer and the input of Layer4, the output of the first upsampling layer is connected to the input of the first 1×1 convolution kernel, the output of Layer4 is connected to the input of Layer5, the output of Layer4 is connected to the input of the second upsampling layer, the output of the second upsampling layer is connected to the input of the second 1×1 convolution kernel, the output of the first 1×1 convolution kernel, the output of the second 1×1 convolution kernel and the output of Layer2 are connected to the input of the first splicing layer, and the output of the first splicing layer is connected to the input of the Light 3×3 layer. The output of the 3×3 layer is connected to the input of the coordinate attention mechanism layer, the output of the coordinate attention mechanism layer and the output of the Layer5 layer are connected to the input of the second splicing layer, the output of the second splicing layer is connected to the input of the batch normalization (BN) layer, the output of the batch normalization layer is connected to the input of the global average pooling (GAP) layer, and the output of the global average pooling layer is connected to the input of the classifier. The classifier includes a fully connected layer and a Softmax function, and the classifier outputs the probability distribution of vehicles belonging to each category.
[0049] In addition, during the training process, the feature map output by the batch normalization (BN) layer is averaged in the channel (C) direction to obtain a spatial attention map (dimension is H×W). At the same time, the feature map output by the batch normalization layer first passes through a two-dimensional convolution layer to obtain a category activation map. The spatial attention map and the category activation map are sent to the consistency loss (MSE loss) calculation module. The mean square error loss (MSE loss) is used to measure the difference between the two. By minimizing the loss, the spatial attention map and the category activation map are kept consistent, thereby guiding the network to focus on more discriminative areas and improving the effectiveness of the features.
[0050] During inference, the vehicle image first enters the Layer 1 layer, which performs preliminary feature extraction on the image. Through convolution operations, the basic features of the image are preliminarily abstracted and transformed, and a feature map with certain feature expressions is output; the feature map processed by Layer 1 enters the Layer 2 layer, and the feature map processed by Layer 2 enters the Layer 3 layer. The feature map output by Layer 3 is divided into two paths, one of which is upsampled through the first upsampling layer. The upsampling process is: the resolution of the feature map is increased by nearest neighbor interpolation to increase its size so that it can be better integrated with the feature maps of other branches in the future. Then, after convolution and regression, the feature map is output. The first 1×1 convolution kernel processes the upsampled feature map to adjust the number of channels, reduce or increase the channel dimension of the feature map, so as to further screen and integrate the features. The other path enters the Layer4 layer. The feature map output by the Layer4 layer is divided into two paths, one of which is sent to the Layer5 layer, and the other path enters the second upsampling layer for upsampling, and then enters the second 1×1 convolution kernel. The feature map output by the Layer2 layer, the feature map output by the first 1×1 convolution kernel, and the feature map output by the second 1×1 convolution kernel are spliced according to the channel dimension to form a new feature map. The new feature map is decomposed into depth convolution and point-by-point convolution by the Light 3×3 layer through depth-separable convolution, extracting spatial features while reducing the amount of calculation, and then entering the coordinate attention mechanism layer. The coordinate attention mechanism layer calculates the attention weights of the feature map in the spatial and channel dimensions, so that the network pays more attention to important areas and feature channels related to vehicle recognition, thereby enhancing the expression ability of the features.
[0051] The feature map output by the coordinate attention mechanism layer is spliced with the feature map output by Layer 5. The spliced feature map contains comprehensive information from the basic appearance details of the vehicle to high-level semantics, providing a rich and effective feature representation for subsequent vehicle re-identification tasks.
[0052] Among them, the shape of the spliced feature map is B×C×H×W, where B represents the batch size (Batch Size), that is, the number of images processed simultaneously in one training; C represents the number of channels (Channels), which represents the dimension of the feature, and each channel contains different image feature information, that is, features in terms of color, texture, shape, etc.; H is the height (Height) of the feature map; W is the width (Width) of the feature map. The spliced feature map enters the batch normalization layer. The role of batch normalization is to normalize the feature map of each batch, and by adjusting the mean and variance of the feature map, its distribution is more stable, reducing internal covariate offset, accelerating the convergence speed of the network, and enhancing the generalization ability of the model. The feature map after batch normalization enters the global average pooling layer for global average pooling. Local average pooling is to average the feature map in the spatial dimension (height and width), compressing the spatial information of each feature map into one value, thereby converting the feature map into a feature vector, effectively reducing the number of parameters and the amount of calculation, while retaining the global information of the feature map. The resulting feature vector is input into a classifier consisting of fully connected layers (FClayers) and a Softmax function. The fully connected layers further perform a linear transformation on the feature vector, mapping it to an appropriate feature space to better distinguish between different categories. The Softmax function converts the output of the fully connected layer into a probability distribution for each category. The cross-entropy loss (IDloss) is calculated to measure the difference between the predicted result and the true label (LABEL), thereby guiding network training and enabling the network to learn more discriminative feature representations for accurate classification. Furthermore, the feature vector after global average pooling is also used to calculate the triplet loss (Tripletloss), a metric loss that constructs triplets (anchor, positive sample, negative sample) to bring feature vectors of the same category closer together in the feature space and feature vectors of different categories further apart, further enhancing the distinguishing ability of features. Ultimately, during the inference phase, the learned feature representation and classifier are used to accurately classify and identify the input features.
[0053] The loss function of the vehicle re-identification model during training is:
[0054] Loss=Loss ID +Loss tri +λLoss MSE
[0055] Among them, Loss ID 、Loss tri and Loss MSE They represent cross entropy loss, triplet loss and consistency loss respectively, and λ is the corresponding weight coefficient.
[0056] Example 2
[0057] This example uses the public dataset VeRi-776. This dataset, collected from a real-world traffic monitoring system in Beijing, contains over 50,000 high-resolution vehicle images of 776 vehicles on real roads, captured by cameras at 20 different locations at different times of day and night, under various weather conditions. Each vehicle contains an average of 64 multi-angle images, capturing a complete front, rear, and side view, and annotated with precise vehicle ID, camera location, timestamp, and partial license plate information.
[0058] Test analysis indicators:
[0059] 1a) Rank-1 accuracy is a key evaluation metric in visual recognition tasks such as vehicle re-identification. It primarily measures the probability that, given a query vehicle image, the correct matching target vehicle image ranks first among all vehicle images in the database. Simply put, it measures the probability that the best matching vehicle image for a query is the target vehicle image.
[0060] 2a) mAP (mean Average Precision) is a widely used evaluation metric in fields such as information retrieval and object detection. It comprehensively considers both precision and recall. Precision refers to the proportion of relevant results retrieved out of all retrieved results, while recall refers to the proportion of relevant results retrieved out of all relevant results. mAP is the average of precision at different recall rates and provides a more comprehensive measure of a model or algorithm's performance in recognition tasks.
[0061] The present invention was tested using Python 3.8 on the Ubuntu operating platform. The specific software and hardware environment is shown in Table 1:
[0062] Table 1
[0063] Environmental parameters illustrate Memory 256.00GB CPU AMD EPYC 7763 64-Core Processor GPU NVIDIA Corporation Device 4090+cuda:11.8 operating system Ubuntu 18.04 Test environment Python 3.8 + PyTorch 2.3
[0064] Table 2
[0065]
[0066]
[0067] This invention can improve the accuracy of recognition and matching, and aims to solve the problem of accurately identifying, tracking and managing vehicles in different scenarios, different camera perspectives and complex environments, bringing many conveniences and improvements to the fields of traffic management, security monitoring and so on.
[0068] Example 3
[0069] The vehicle re-identification system based on CAM-OSNet of the present invention comprises:
[0070] An acquisition module, used for acquiring vehicle images;
[0071] The recognition module is used to input the vehicle image into the trained vehicle re-identification model to identify the information of the current vehicle. The vehicle re-identification model is trained based on the full-scale network.
[0072] In this embodiment, the vehicle re-identification model includes Layer 1, Layer 2, Layer 3, Layer 4, Layer 5, a first upsampling layer, a second upsampling layer, a first 1×1 convolution kernel, a second 1×1 convolution kernel, a first splicing layer, a Light 3×3 layer, a coordinate attention mechanism layer, a second splicing layer, a batch normalization layer, a global average pooling layer, and a classifier;
[0073] The output of Layer1 is connected to the input of Layer2, the output of Layer2 is connected to the input of Layer3, the output of Layer3 is connected to the input of the first upsampling layer and the input of Layer4, the output of the first upsampling layer is connected to the input of the first 1×1 convolution kernel, the output of Layer4 is connected to the input of Layer5, the output of Layer4 is connected to the input of the second upsampling layer, the output of the second upsampling layer is connected to the input of the second 1×1 convolution kernel, the output of the first 1×1 convolution kernel, the output of the second 1×1 convolution kernel and the output of Layer2 are connected to the input of the first splicing layer, and the output of the first splicing layer is connected to the input of the Light 3×3 layer. The output of the 3×3 layer is connected to the input of the coordinate attention mechanism layer, the output of the coordinate attention mechanism layer and the output of the Layer5 layer are connected to the input of the second splicing layer, the output of the second splicing layer is connected to the input of the batch normalization (BN) layer, the output of the batch normalization layer is connected to the input of the global average pooling (GAP) layer, and the output of the global average pooling layer is connected to the input of the classifier.
[0074] In this embodiment, the vehicle re-identification model further includes a two-dimensional convolutional layer and a consistency loss calculation module;
[0075] During the training process, the feature map output by the batch normalization layer is averaged in the C direction to obtain the spatial attention map. At the same time, the feature map output by the batch normalization layer passes through the two-dimensional convolution layer to obtain the category activation map. The spatial attention map and the category activation map are sent to the consistency loss calculation module. The difference between the two is measured by the mean square error loss. By minimizing the loss, the spatial attention map and the category activation map are kept consistent.
[0076] The division of modules in the embodiments of the present application is illustrative and is merely a logical functional division. In actual implementation, other division methods may be used. Furthermore, the functional modules in the various embodiments of the present application may be integrated into a single processor, or may exist physically separately, or two or more modules may be integrated into a single module. The aforementioned integrated modules may be implemented in the form of hardware or software functional modules.
[0077] Example 4
[0078] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the CAM-OSNet-based vehicle re-identification method are implemented, including, for example: acquiring a vehicle image; inputting the vehicle image into a trained vehicle re-identification model to identify the current vehicle information. The vehicle re-identification model is trained based on a full-scale network. The memory may include internal memory, such as a high-speed random access memory (RAM), or non-volatile memory, such as at least one disk drive. The processor, network interface, and memory are interconnected via an internal bus, which may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PII) bus, an Extended Industry Standard Architecture (ESIA) bus, or other bus types. The bus may be categorized as an address bus, a data bus, or a control bus. The memory is used to store programs. Specifically, the programs may include program code, which includes computer operating instructions. The memory may include both internal memory and non-volatile memory, and provides instructions and data to the processor.
[0079] Example 5
[0080] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of a vehicle re-identification method based on CAM-OSNet, including, for example: acquiring a vehicle image; inputting the vehicle image into a trained vehicle re-identification model trained based on a full-scale network to identify information about the current vehicle. Specifically, the computer-readable storage medium includes, but is not limited to, volatile memory and / or non-volatile memory. The volatile memory may include random access memory and / or cache memory, etc. The non-volatile memory may include read-only memory, a hard disk, flash memory, an optical disk, a magnetic disk, etc.
[0081] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program code.
[0082] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0083] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0084] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0085] Those skilled in the art will readily identify other embodiments of the present invention after considering the specification and disclosure of the invention. This application is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the invention being indicated by the following claims.
[0086] It should be understood that the present invention is not limited to the exact construction described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
[0087] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any way. Any simple modification, change and equivalent structural change made to the above embodiment based on the technical essence of the present invention shall still fall within the scope of protection of the technical solution of the present invention.
Claims
1. A vehicle re-identification method based on CAM-OSNet, characterized in that: include: Acquire vehicle images; The vehicle image is input into a trained vehicle re-identification model to identify information about the current vehicle, wherein the vehicle re-identification model is trained based on a full-scale network.
2. The vehicle re-identification method based on CAM-OSNet according to claim 1, characterized in that: The vehicle re-identification model includes Layer 1, Layer 2, Layer 3, Layer 4, Layer 5, the first upsampling layer, the second upsampling layer, the first 1×1 convolution kernel, the second 1×1 convolution kernel, the first splicing layer, the Light 3×3 layer, the coordinate attention mechanism layer, the second splicing layer, the batch normalization layer, the global average pooling layer and the classifier; The output of Layer1 is connected to the input of Layer2, the output of Layer2 is connected to the input of Layer3, the output of Layer3 is connected to the input of the first upsampling layer and the input of Layer4, the output of the first upsampling layer is connected to the input of the first 1×1 convolution kernel, the output of Layer4 is connected to the input of Layer5, the output of Layer4 is connected to the input of the second upsampling layer, the output of the second upsampling layer is connected to the input of the second 1×1 convolution kernel, the output of the first 1×1 convolution kernel, the output of the second 1×1 convolution kernel and the output of Layer2 are connected to the input of the first splicing layer, and the output of the first splicing layer is connected to the input of the Light 3×3 layer. The output of the 3×3 layer is connected to the input of the coordinate attention mechanism layer, the output of the coordinate attention mechanism layer and the output of the Layer5 layer are connected to the input of the second splicing layer, the output of the second splicing layer is connected to the input of the batch normalization layer, the output of the batch normalization layer is connected to the input of the global average pooling layer, and the output of the global average pooling layer is connected to the input of the classifier.
3. The vehicle re-identification method based on CAM-OSNet according to claim 2, characterized in that: The vehicle re-identification model also includes a two-dimensional convolutional layer and a consistency loss (MSE) calculation module; During the training process, the feature map output by the batch normalization layer is averaged in the channel C direction to obtain the spatial attention map. At the same time, the feature map output by the batch normalization layer passes through the two-dimensional convolution layer to obtain the category activation map. The spatial attention map and the category activation map are sent to the consistency loss calculation module. The difference between the two is measured by the mean square error loss. By minimizing the loss, the spatial attention map and the category activation map are kept consistent.
4. The vehicle re-identification method based on CAM-OSNet according to claim 1, characterized in that: The loss function of the vehicle re-identification model during training is: Loss=Loss ID +Loss tri +λLoss MSE Among them, Loss ID 、Loss tri and Loss MSE They represent cross entropy loss, triplet loss and consistency loss respectively, and λ is the corresponding weight coefficient.
5. The vehicle re-identification method based on CAM-OSNet according to claim 1, characterized in that: The video frames are acquired through the camera for detection and a single vehicle image is obtained.
6. A vehicle re-identification system based on CAM-OSNet, characterized in that: include: An acquisition module, used for acquiring vehicle images; The recognition module is used to input the vehicle image into the trained vehicle re-identification model to identify the information of the current vehicle. The vehicle re-identification model is trained based on the full-scale network.
7. The vehicle re-identification system based on CAM-OSNet according to claim 6, characterized in that: The vehicle re-identification model includes Layer 1, Layer 2, Layer 3, Layer 4, Layer 5, the first upsampling layer, the second upsampling layer, the first 1×1 convolution kernel, the second 1×1 convolution kernel, the first splicing layer, the Light 3×3 layer, the coordinate attention mechanism layer, the second splicing layer, the batch normalization layer, the global average pooling layer and the classifier; The output of Layer1 is connected to the input of Layer2, the output of Layer2 is connected to the input of Layer3, the output of Layer3 is connected to the input of the first upsampling layer and the input of Layer4, the output of the first upsampling layer is connected to the input of the first 1×1 convolution kernel, the output of Layer4 is connected to the input of Layer5, the output of Layer4 is connected to the input of the second upsampling layer, the output of the second upsampling layer is connected to the input of the second 1×1 convolution kernel, the output of the first 1×1 convolution kernel, the output of the second 1×1 convolution kernel and the output of Layer2 are connected to the input of the first splicing layer, and the output of the first splicing layer is connected to the input of the Light 3×3 layer. The output of the 3×3 layer is connected to the input of the coordinate attention mechanism layer, the output of the coordinate attention mechanism layer and the output of the Layer5 layer are connected to the input of the second splicing layer, the output of the second splicing layer is connected to the input of the batch normalization layer, the output of the batch normalization layer is connected to the input of the global average pooling layer, and the output of the global average pooling layer is connected to the input of the classifier.
8. The vehicle re-identification system based on CAM-OSNet according to claim 7, characterized in that: The vehicle re-identification model also includes a two-dimensional convolutional layer and a consistency loss calculation module; During the training process, the feature map output by the batch normalization layer is averaged in the C direction to obtain the spatial attention map. At the same time, the feature map output by the batch normalization layer passes through the two-dimensional convolution layer to obtain the category activation map. The spatial attention map and the category activation map are sent to the consistency loss calculation module. The difference between the two is measured by the mean square error loss. By minimizing the loss, the spatial attention map and the category activation map are kept consistent.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the vehicle re-identification method based on CAM-OSNet as described in any one of claims 1 to 5 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the vehicle re-identification method based on CAM-OSNet as claimed in any one of claims 1 to 5 are implemented.