Ship re-identification method

By constructing a dual optimization loss function and utilizing attention mechanism, combining local and global characteristics, the problem of low accuracy in marine environments is solved, and the sensitivity to viewing angle changes and the robustness of the model is improved.

CN118968432APending Publication Date: 2024-11-15NANJING TECH UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410970690.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

The existing ship re-identification method has low accuracy in marine environments, is affected by changes in waves, wind and light, and it is difficult to effectively deal with changes in the perspective of the ship.

Method used

By introducing perspective information, a double-optimized loss function is constructed, combined with local and global features, and using attention mechanisms to train the BFFM model to improve the accuracy of ship re-identification and sensitivity to viewing angle changes.

Benefits of technology

It significantly improves the accuracy of ship re-identification and robustness to viewing angle changes, and enhances the model's viewing angle invariance and feature representation ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118968432A_ABST
    Figure CN118968432A_ABST
Patent Text Reader

Abstract

The invention discloses a ship re-identification method, and belongs to the field of computer vision, and the method comprises the steps: marking a ship image, obtaining an identity tag, and carrying out the data enhancement processing; the ResNet-50 model and the YOLOv5s model are trained; acquiring global features and local features; performing bidirectional BFFM feature fusion on the obtained features to obtain a fused feature map; constructing a first loss function and a second loss function; wherein the first loss function is used for measuring the internal characteristic difference of the same type of ships at different visual angles; the second loss function is used for measuring the characteristic difference of the same type of ships at different visual angles; obtaining a dual optimization loss function according to the first loss function and the second loss function, and constructing a total loss function in combination with local loss and cross entropy loss; training the ship re-identification model by using the total loss function; in view of low ship identification precision in the prior art, the ship re-identification precision is improved by introducing view angle information and local features and constructing a dual optimization loss function amount attention mechanism and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer vision, and more specifically, to a method for ship re-identification. Background Art

[0002] With the development of computer vision technology, visible light cameras have played an important role in detecting the marine environment around ships. Compared with AIS and radar technology, visible light cameras can provide clearer and more intuitive images, identify targets even in bad weather conditions, and have a wider range of applications. Ship re-identification is an important application of object re-identification in the marine field, which helps to build a complete marine situational awareness system.

[0003] Currently, object re-identification has been widely used in the fields of pedestrians and vehicles, and to a certain extent has solved the inherent difficulties of re-identification tasks, such as occlusion, low resolution, large viewpoint changes, target similarity, and variable lighting / weather conditions. However, ship re-identification faces more severe challenges than pedestrian and vehicle re-identification. This is mainly because the complexity of the marine environment, such as waves, wind and lighting changes, may affect the visual characteristics of the ship, resulting in significant differences in the images of the ship in different environments. In addition, the motion state of the ship, such as speed and heading, will also change the visual characteristics of the ship. These unique features increase the difficulty of ship re-identification, which limits the effectiveness of existing re-identification methods in marine environments.

[0004] The Chinese patent application, application number CN202410270413.5, published on May 7, 2024, discloses a ship re-identification method, device, medium and equipment, which aims to solve the problem that the accuracy of the existing technology needs to be improved. It includes: obtaining the ship image to be re-identified, inputting it into the pre-trained ship re-identification model, and obtaining the ship re-identification result; the training of the ship re-identification model includes: feature acquisition of the source domain image to obtain the first feature information; style transfer of the target domain image to obtain a new target domain image with the style of the source domain image; purifying the label noise of the source domain image to obtain a new source domain image, and training to obtain a preliminary ship re-identification model; assigning pseudo labels to the new target domain image to obtain a new target domain image with a first-generation pseudo label; performing pseudo label purification on the new target domain image with a pseudo label to obtain a new target domain image with a second-generation pseudo label, and training a preliminary ship re-identification model to obtain a ship re-identification model. However, during the training process of the ship re-identification model, the scheme has certain limitations in the processing methods of source domain images and target domain images. Therefore, the ship re-identification accuracy of this scheme needs to be further improved. Summary of the invention

[0005] In response to the problem of low accuracy of ship re-identification in the prior art, the present application provides a method for ship re-identification, which introduces perspective information, constructs a dual optimization loss function, constructs a BFFM method through local and global features, and uses an attention mechanism to improve the accuracy of ship re-identification and the sensitivity to changes in ship perspective.

[0006] The purpose of this application is achieved through the following technical solutions.

[0007] The present application provides a method for ship re-identification, comprising: acquiring ship images, assigning a unique identity tag to each ship image, which is implemented through information in the file name, and annotating the ship images with viewpoints and local components; wherein the viewpoint annotation includes the front, side and rear; the local component annotation includes the bow, stern, side freeboard and superstructure; performing data enhancement processing on the annotated ship images; using the data-enhanced ship images, training a ResNet-50 model and a YOLOv5s model; setting the last layer of the ResNet-50 model as a fully connected layer, and obtaining a viewpoint identifier AC that distinguishes different viewpoints of the ship image through forward propagation and backward propagation training; using the data-enhanced ship images as input, using the trained ResNet-50 model to obtain global features and obtain a global feature map; using the data-enhanced ship images as input, using the trained YOLOv5s model to locate local components; obtaining local features, obtaining local features, obtaining local The invention relates to a method for obtaining a ship re-identification model, a ship re-identification model and a ship image. The method comprises the following steps: first, a first loss function and a second loss function are constructed; the first loss function is used to measure the intrinsic feature differences of the same type of ships under different perspectives; the second loss function is used to measure the feature differences of the same type of ships under different perspectives; a double optimization loss function is constructed according to the first loss function and the second loss function; a double optimization loss function is obtained according to the first loss function and the second loss function, and a total loss function is constructed by combining the local loss and the cross entropy loss; a ship re-identification model is constructed, the obtained fusion feature map is used as input, and the ship re-identification model is trained using the total loss function; and the ship re-identification model after training is used to obtain the prediction result of the ship image.

[0008] Among them, the angle classifier (AC) that can identify different angles of ship images is used. The main function of AC is to assist the dual optimization loss function to better distinguish ships from different angles. Specifically, by marking different angles of ship images and training the angle classifier, the model can perceive and utilize the angle change information of the ship, thereby enhancing the distinguishability of feature representation. The first loss function focuses on the intrinsic feature differences of ships of the same category under different angles, and the second loss function focuses on the feature differences of ships of the same category under different angles. Combining the two into a dual optimization loss function can better characterize the impact of angle changes on ship features and improve the perspective invariance of the model. ResNet-50 and YOLOv5s are used to obtain the global features and local features of ship images respectively, and then the two are enhanced by bidirectional feature fusion. This way of fusing global and local information can obtain a more comprehensive and discriminative ship feature representation. Bilateral Feature Fusion Module (BFFM) enhances the local feature map through self-attention mechanism and residual connection, and fuses it with the global feature map, which can highlight the features useful for recognition and improve the feature representation ability. Combining the dual optimization loss function, local loss, and cross entropy loss into a total loss function for joint optimization helps obtain a model with better performance.

[0009] Furthermore, the first loss function Intrinsic Feature Loss is constructed, which aims to measure the intrinsic feature differences of the same type of ships under different perspectives, including: representing the ship image set as I; selecting the i-th anchor image I from I i ; Use the viewpoint identifier AC to select the anchor image I from the ship image set I i Images belonging to the same category but from different perspectives are considered positive sample images I psv1 , and the anchor image I i Images that do not belong to the same category and have the same perspective are used as negative sample images I ngv1 ; Calculate anchor image I i with I psv1 The characteristic distance D(f(I i ),f(I psv1 )); Calculate anchor image I i with I ngv1 The characteristic distance D(f(I i ),f(I ngv1 )); where, calculate I i with I psv1 The characteristic distance D(f(I i ),f(I psv1 ))The formula is as follows: Among them, f(Ii ) and f(I psv1 ) represent I i and I psv1 The eigenvector of ; represents the dot product operation of the vector, ||f(I i )||2 means f(I i )’s L2 norm; ||f(I psv1 )||2 means f(I psv1 )’s L2 norm; Calculate I i with I ngv1 The characteristic distance D(f(I i ),f(I ngv1 )), the calculation formula is as follows: Among them, f(I i ) and f(I ngv1 ) represent I i and I ngv1 The feature vector of i ),f(I psv1 )) and D(f(I i ),f(I ngv1 )) Construct the first loss function L IN .

[0010] Furthermore, the first loss function L IN The goal is to maximize the feature distance of the same type of ships under different viewing angles, while minimizing the feature distance of different types of ships under the same viewing angle. By introducing a boundary value, the distance difference between positive and negative samples is controlled, and the expression is as follows:

[0011] Among them, VI represents different ship images; KI represents images of the same ship from different perspectives; batch represents the number of batch processed images; max IN Indicates I psv1 With anchor image I i The maximum feature distance; min IN Indicates I ngv1 With anchor image I i The minimum characteristic distance; ε represents L IN The threshold is used to control the minimum value of the distance difference between positive samples and negative samples; [max IN D(f(I i ),f(I psv1 ))-min IN D(f(I i ),f(I ngv1 ))+ε] + It means that if the value in the brackets is less than or equal to 0, the output is 0, otherwise the output is the value in the brackets;

[0012] Furthermore, the second loss function L is constructed VV , Viewpoint Variation Loss, which aims to measure the feature differences of the same category of ships under different viewpoints, including: representing the ship image set as I; selecting the i-th anchor image I from I i ; Use the viewpoint identifier AC to obtain the anchor image I i The positive sample image I belongs to the same category under the same perspective psv2 , select the anchor image I i Belonging to different categories under the same perspective as negative sample images I ngv2 ; Calculation I i with I psv2 The characteristic distance D(f(I i ),f(I psv2 ))The calculation formula is as follows:

[0013] Among them, f(I i ) and f(I psv2 ) represent I i and I psv2 eigenvector of; Calculate I i with I ngv2 The characteristic distance D(f(I i ),f(I ngv2 )), the calculation formula is as follows: Among them, f(I i ) and f(I ngv2 ) represent I i and I ngv2 The feature vector of the anchor image I is obtained by using the viewpoint identifier AC i The same category under different perspectives is regarded as a positive sample image I psv3 , select the anchor image I i Belonging to different categories under different perspectives as negative sample images I ngv3 ; Calculation I i with I psv3 The characteristic distance D(f(I i ),f(I psv3 )), the calculation formula is as follows: Among them, f(I i ) and f(I psv3 ) represent I i and I psv3 eigenvector of; Calculate I i with I ngv3 The characteristic distance D(f(I i ),f(I ngv3 )), the calculation formula is as follows: Among them, f(I i ) and f(I ngv3 ) represent I i and I ngv3 The feature vector of i ),f(I psv2 ))、D(f(I i ),f(I ngv2 ))、D(f(I i ),f(I psv3 )) and D(f(I i ),f(I ngv3 )) Construct the second loss function L VV .

[0014] Furthermore, the second loss function L VV It consists of two parts: the first part is the difference in feature distance between the anchor image and the positive and negative samples. The goal is to maximize the feature distance of the same category and the same perspective images, and minimize the feature distance of different categories and the same perspective images; the second part is the difference in feature distance between the anchor image and the positive and negative samples at another perspective. The goal is to maximize the feature distance of the same category and different perspective images, while minimizing the feature distance of different categories and different perspective images, and at the same time control the distance difference between them and different category images through the threshold. The expression of the second loss function is as follows: Among them, VI represents different ship images; KI represents images of the same ship from different perspectives; batch represents the number of batch processed images; max v2 Indicates I psv2 With anchor image I i The maximum feature distance; min v2 Indicates I ngv2 With anchor image I i The minimum feature distance; max v3 Indicates I psv3 With anchor image I i The maximum feature distance; min v3 Indicates I ngv3 With anchor image I i The minimum characteristic distance; α represents L VV The threshold value at the same viewing angle, β represents L VV Thresholds at different viewing angles.

[0015] Furthermore, a dual optimization loss function and a model total loss function are constructed to guide the model to learn the intrinsic feature representation of the ship and enhance the feature learning ability of the ship image under different perspective changes. q, which consists of the first loss function (Intrinsic Feature Loss) and the second loss function (Viewpoint Variation Loss), which is used to measure the loss of the intrinsic features and viewpoint variation of the ship. The expression is as follows: L q =weight in ×L IN +weight vv ×L VV , where weight in Indicates L IN The weight of the loss function, weight vv YesL VV The weight of the loss function;

[0016] Furthermore, based on the dual optimization loss function, the model's total loss function further introduces a local loss function and a cross entropy loss function to achieve a more comprehensive optimization goal. The model's total loss function is expressed as follows: s =weight double ×L q +weight local ×L0+weight cross ×L c , where weight double Represents the weight of the dual optimization loss function; weight local Represents the weight of local loss, weight cross represents the weight of the cross entropy loss function; L q represents the dual optimization loss function; L c represents the cross entropy loss function; L0 represents the local loss function.

[0017] L c It is used to measure the difference between the probability distribution of the model output and the true label. The expression is as follows: Among them, batch_size represents the batch size, Indicates the first samples, represents the total category, ψ represents the ψth category, log represents the logarithm with base e, represents the true distribution, represents the network output distribution;

[0018] L0 represents the local loss function, which is expressed as follows: L0 = λ coord ×L coord +λ class ×L class +λ conf ×L conf , where λcoord Represents the weight parameter of coordinate loss, λ class Represents the weight parameter of the class loss, λ conf Represents the weight parameter of confidence loss, L coord Expressed as coordinate loss, L class Expressed as category loss, L conf It is expressed as confidence loss.

[0019] The dual optimization loss function and the total model loss function guide the model to learn the feature representation of ships from different perspectives through the joint optimization of multiple loss functions. Among them, the dual optimization loss function focuses on the consistency of the intrinsic characteristics of the ship and its adaptability to different perspectives, the cross entropy loss function is mainly used to measure the difference between the probability distribution of the model output and the true label, and the local loss function focuses on the difference in local features. Through this multi-objective learning strategy, the model can obtain a more comprehensive and robust representation of ship features, thereby improving the performance of ship re-identification.

[0020] Furthermore, the view annotation data and local component annotation data of the ship image are obtained as the basis for training the view identifier. The view annotation data provides the view category corresponding to each image, and the local component annotation data provides the location information of the key components of the ship, including: obtaining the view annotation data and local component annotation data of the ship image; obtaining the pre-trained ResNet-50 model, and obtaining the last fully connected layer of the ResNet-50 model; setting the output dimension of the last fully connected layer of the obtained ResNet-50 model to be equal to the number of view categories. Through this modification, the output feature dimension of the model corresponds to the view category; the view identifier AC is expressed as: y ac =FC(ResNet50(x)), where y acRepresents the prediction score of the input image x on each category, FC represents the fully connected layer, and ResNet50 represents the pre-trained ResNet-50 model; using the view annotation data, the ResNet-50 model and the set fully connected layer FC are trained through forward propagation to obtain the view identifier AC. Specifically, the ship image is input, and the view prediction score is obtained after being processed by the convolutional layer and the fully connected layer FC of ResNet-50. Then, by comparing the difference between the predicted score and the true view label, the loss function is calculated, and the model parameters are updated through the back propagation algorithm to make the prediction result as close to the true view as possible. The acquisition process of the view identifier AC mainly includes three steps: data preparation, model selection and modification, and model training. By replacing the last fully connected layer on the basis of the pre-trained ResNet-50 model and conducting targeted training, a special model that can predict the ship's view is obtained. The introduction of the view identifier AC provides the view prediction result for the subsequent construction of the second loss function, so that the model can better measure the feature differences of ships of the same category under different view angles, and improve the adaptability of ship re-identification to view angle changes.

[0021] Furthermore, the acquisition process of the global feature map and local feature map enhanced by attention improves the quality of feature representation by introducing the attention mechanism and feature fusion strategy, including: L2 regularization of the local feature map; processing the local feature map after L2 regularization through the self-attention mechanism and residual connection to obtain the enhanced local feature map. The self-attention mechanism can learn the long-range dependency between features, and by assigning weights to each feature, it can highlight the features that are important to the recognition task and suppress redundant or irrelevant features. The residual connection can alleviate the network degradation problem, allowing the gradient to be more easily propagated to the shallow layer while retaining the information of the original features.

[0022] The enhanced local feature map is projected to the corresponding position of the global feature map to obtain the fused feature map, and the regional information in the local feature map is fused with the contextual information in the global feature map to make the feature representation more comprehensive and semantic; the fused feature map is used as input, and the ResNet-50 model with the last fully connected layer is used to obtain the attention-enhanced global feature map; the attention-enhanced global feature map is spliced ​​to the original local feature map to obtain the attention-enhanced local feature map, and the high-level semantic information in the global feature map is combined with the fine-grained information in the local feature map to make the local feature representation richer and more discriminative.

[0023] Furthermore, the L2 regularization expression is as follows: l2_reg =λ l2 ×||W|| 2 , where L l2_reg represents the L2 regularization term; λl2 represents the regularization coefficient, W represents the weight vector, ||W|| 2 represents the sum of the squares of all weights; the self-attention mechanism expression is as follows: Among them, Q, K, and V are query, key, and value respectively; QK T represents the dot product of the query and the key, represents the similarity between the query and the key, represents the scaling factor, and d represents the dimension of the key or query; It means converting the dot product result into probability distribution; the residual connection expression is as follows: R = F(A,{Wi})+A, where A represents the input matrix and R represents the output matrix; F is the residual mapping and {Wi} represents the weight set.

[0024] Compared with the prior art, the advantages of this application are:

[0025] By introducing perspective information, annotating the ship images by perspective (front, side, back), and training the perspective identifier AC, the model's ability to recognize ships from different perspectives is improved. By using perspective information to construct a loss function, the model can better learn the intrinsic characteristics of the same ship from different perspectives, thereby improving the re-identification accuracy.

[0026] A dual optimization loss function is constructed, which comprehensively considers the feature differences of the same ship under different perspectives (the first loss function) and the feature differences of different ships under the same perspective (the second loss function). The dual optimization loss function can measure the intrinsic characteristics of the ship and the perspective changes, making the trained model more robust to the perspective changes of the ship. By weighted combination of the first loss function and the second loss function, the contribution of the two losses can be flexibly adjusted to achieve better model training results.

[0027] The local and global features are fused. The YOLOv5s model is used to locate the local parts of the ship image and extract the local features. The global features are extracted using ResNet-50. The local feature map and the global feature map are fused through the bidirectional feature fusion module BFFM to obtain a more comprehensive and semantically rich ship feature representation. The attention mechanism is introduced to enhance the fused local and global features and further improve the feature representation capability.

[0028] The total loss function is constructed by weighting the dual optimization loss, local loss and cross entropy loss to form a total loss function, which constrains model training from multiple angles and improves model performance. The cross entropy loss measures the difference between the model output and the true label, the local loss constrains the target detection result, and the dual optimization loss measures the intrinsic characteristics and perspective changes. The three complement each other and jointly guide the model to learn a more robust representation of ship features. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1A schematic diagram of a process flow of a ship re-identification method of the present application;

[0030] Figure 2 A schematic diagram of the process of constructing the first loss function of this application;

[0031] Figure 3 This is a schematic diagram of the process of constructing the second loss function of this application. DETAILED DESCRIPTION

[0032] The present application is described in detail below in conjunction with the accompanying drawings and specific embodiments.

[0033] Figure 1 A flow chart of a method for ship re-identification of the present application, a method for ship re-identification, comprising: obtaining a ship image, and annotating the ship image with perspectives and local components; wherein the perspective annotation includes the front, side, and rear; the local component annotation includes the bow, stern, side freeboard, and superstructure; wherein, obtaining the ship image can be achieved by: installing high-definition cameras in ports, docks, waterways, and other areas where ships frequently appear; when the ship enters the camera's shooting range, triggering the camera to automatically shoot and obtain the ship image; transmitting the collected ship image to an image processing server. Obtain surveillance videos of ports, docks, waterways, and other areas; use video processing techniques, such as frame difference method, background subtraction method, etc., to detect and obtain the key frame image of the ship from the video; save and transmit the acquired ship image to an image processing server.

[0034] Specifically, the file name format of the image is "0002_c1s1_000001_00", where "0002" represents the category of the ship. The category number "0002" in the file name is obtained as the category label of the ship. The angle annotation is represented by: angle label =A(I), local component marking is represented by: part label =B(I). Where, angle label is the perspective tag, part labelis the local component label, I is the set of ship images, A(I) is the view annotation function, and B(I) is the local component annotation function. Among them, the front view: the image directly in front of the ship, usually the key information such as the bow structure and the ship name can be seen. The side view: the image of the side of the ship, usually the overall outline and the side structure of the ship can be seen. The rear view: the image directly behind the ship, usually the key information such as the stern structure and the ship number can be seen. Bow: the structure at the front of the ship, including the bow longitudinal plate, the forecastle deck, etc. Stern: the structure at the rear of the ship, including the stern longitudinal plate, the poop deck, etc. Side freeboard: the outer shell structure on both sides of the ship, including the side plate, portholes, etc. Superstructure: the structure above the ship, including the cab, bridge, etc. The annotation process is carried out by manual annotation. Manual annotation is performed by professionals one by one according to the image content and annotation rules, which is highly accurate but time-consuming.

[0035] Data enhancement is performed on the annotated ship images to improve the generalization and robustness of the model; specific enhancement methods include random rotation and translation. The range of random rotation is set to ±20 degrees. Through random rotation operations, ship images at different angles can be generated to increase the diversity of data. This helps the model learn the characteristics of ships at different angles and improves its adaptability to changes in ship rotation. Horizontal translation: Randomly translate the image in the horizontal direction by a certain pixel distance to simulate the change in the horizontal position of the ship. Vertical translation: Randomly translate the image in the vertical direction by a certain pixel distance to simulate the change in the vertical position of the ship. The translation operation is to simulate the fluctuations at sea, so that the model can better handle the position changes of the ship in practical applications. These data enhancement operations are all performed on the original image and will not change the perspective and local component annotations of the ship.

[0036] Using the ship images after data enhancement, the ResNet-50 model and the YOLOv5s model are trained; the last layer of the ResNet-50 model is set as a fully connected layer to train a viewpoint recognizer AC that can recognize different viewpoints of the ship image; specifically, the viewpoint annotation data of the ship image is obtained; the input feature dimension n1 of the last fully connected layer of the pre-trained ResNet-50 model is set; the input feature dimension n1 of the last fully connected layer is set to the fully connected layer FC with an output dimension n2, so that the output feature dimension is consistent with the viewpoint category; the viewpoint recognizer AC is expressed as: y ac =FC(ResNet50(x)), where y ac Represents the prediction score of the input image x on each category, FC represents the fully connected layer, and ResNet50 represents the pre-trained ResNet-50 model.

[0037] Using the view annotation data, the ResNet-50 model and the set fully connected layer FC are trained through forward propagation to obtain the view identifier AC; specifically, the ship image is input and processed by the convolutional layer and the fully connected layer FC of ResNet-50 to obtain the view prediction score; then, the difference between the predicted score and the true view label is calculated through the cross entropy loss function, and the model parameters are updated through the back propagation algorithm to make the prediction result as close to the true view as possible.

[0038] We obtained ship image data with labeled local components, which included the labeling information of local components such as the bow, stern, side freeboard and superstructure. We constructed a YOLOv5s model and used these locally labeled ship image data to train the YOLOv5s model, so that the model can accurately identify and locate the local components in the ship image.

[0039] The data-enhanced ship image is taken as input, and the global features and local features are obtained respectively through the trained ResNet-50 model and YOLOv5s model, and the attention-enhanced global feature map and local feature map are obtained through bidirectional BFFM feature fusion, and finally spliced ​​in the spatial dimension to obtain the final feature fusion map; wherein, the data-enhanced ship image is taken as input, and the trained ResNet-50 model is used to obtain global features and obtain the global feature map; the ResNet-50 model obtains the high-level semantic features of the image through multi-layer convolution and pooling operations, and captures the overall structure and context information of the ship image; the data-enhanced ship image is taken as input, and the trained YOLOv5s model is used to locate the local components in the ship image, such as the bow, stern, side freeboard and superstructure; then, the local features are obtained in the located local component area to obtain the local feature map; at the same time, the loss of local component positioning is calculated to obtain the local loss.

[0040] Among them, local features refer to feature representations obtained from local areas of ship images. In ship re-identification tasks, local features usually correspond to key components of ships, such as bows, sterns, side freeboards, and superstructures. Through the trained YOLOv5s model, these local components can be located and local features can be obtained from the corresponding areas. Local features contain detailed information about the local area of ​​the ship, which plays an important role in distinguishing different ships. Global features refer to feature representations obtained from the entire ship image. Global features describe the overall characteristics of the ship image, including information such as the shape, structure, and texture of the ship. Through the trained ResNet-50 model, global features can be obtained from the data-enhanced ship image to obtain a global feature map; global features provide global information of the ship, which helps to capture the overall characteristics of the ship, and are of great significance for ship re-identification; local loss refers to the loss function for locating local parts of the ship and obtaining features during the training process. During the training process of the ship re-identification model, the YOLOv5s model needs to be optimized to accurately locate the local components of the ship; the local loss is used to measure the performance of the YOLOv5s model in local component positioning and feature acquisition; by minimizing the local loss, the accuracy of the YOLOv5s model in local component positioning and feature acquisition can be improved, thereby improving the performance of ship re-identification.

[0041] The local feature map and the global feature map are respectively subjected to bidirectional BFFM feature fusion to obtain the attention-enhanced global feature map and the attention-enhanced local feature map, including: performing L2 regularization on the local feature map to make it have a unit norm. The L2 regularization expression is as follows: l2_reg =λ l2 ×||W|| 2 , where L l2_reg represents the L2 regularization term; λ l2 represents the regularization coefficient, W represents the weight vector, ||W|| 2 represents the sum of the squares of all weights; the self-attention mechanism expression is as follows: Among them, Q, K, and V are query, key, and value respectively; QK T represents the dot product of the query and the key, represents the similarity between the query and the key, represents the scaling factor, and d represents the dimension of the key or query; It means converting the dot product result into probability distribution; the residual connection expression is as follows: R = F(A,{Wi})+A, where A represents the input matrix and R represents the output matrix; F is the residual mapping and {Wi} represents the weight set.

[0042] The enhanced local feature map is projected to the corresponding position of the global feature map to obtain the fused feature map. Specifically, according to the ratio of the convolution kernel, the position corresponding to each position on the local feature map on the global feature map is determined, and then the feature value on the local feature map is projected to the corresponding position of the global feature map to achieve the fusion of local and global features. The fused feature map is used as input, and the ResNet-50 model with the last fully connected layer is used to obtain features to obtain the attention-enhanced global feature map. The attention-enhanced global feature map is spliced ​​to the original local feature map to obtain the attention-enhanced local feature map. The purpose of this step is to combine the high-level semantic information in the global feature map with the fine-grained information in the local feature map, so that the local feature representation is richer and more discriminative. The attention-enhanced global feature map and the attention-enhanced local feature map are spliced ​​in the spatial dimension to obtain the final feature fusion map. Specifically, the two feature maps are aligned in the height and width dimensions, and then spliced ​​in the channel dimension to form a feature map that combines global and local features. By obtaining global features and local features on the ship image after data enhancement, and obtaining the attention-enhanced global feature map and local feature map through bidirectional BFFM feature fusion, they are finally spliced ​​in the spatial dimension to obtain a feature fusion map that integrates global and local information. Among them, the application of technologies such as L2 regularization, self-attention mechanism and residual connection helps to improve the stability, discrimination and robustness of feature representation. At the same time, through the fusion of local feature maps and global feature maps, and the introduction of attention mechanism, the feature representation can capture the overall structure and local details of the ship image at the same time, improving the expressive ability of the features. The feature fusion map finally obtained provides high-quality feature representation for subsequent ship re-identification tasks, which is expected to improve recognition accuracy and generalization ability.

[0043] A dual optimization loss function is constructed, including constructing a first loss function and a second loss function; wherein the first loss function is used to measure the intrinsic feature differences of the same category of ships under different perspectives; and the second loss function is used to measure the feature differences of the same category of ships under different perspectives.

[0044] Figure 2 This is a flow chart of constructing the first loss function of the present application. The process of constructing the first loss function is as follows: First, the ship image set is represented as I, and the i-th anchor image I is selected from I. i , and then use the viewpoint identifier AC to select the anchor image I from the ship image set I i Images belonging to the same category but from different perspectives are considered positive sample images I psv1 , and the anchor image I i Images that do not belong to the same category and have the same perspective are used as negative sample images I ngv1For example, if the anchor image is the front image of a certain type of ship, the side image and the back image of the ship of that type can be used as positive sample images, while the front images of other types of ships are negative sample images. In this way, the first loss function can effectively measure the intrinsic feature differences of the same type of ships under different viewing angles.

[0045] Calculate anchor image I i with I psv1 The characteristic distance D(f(I i ),f(I psv1 ))The formula is as follows:

[0046]

[0047] Among them, f(I i ) and f(I psv1 ) represent I i and I psv1 The eigenvector of , represents the dot product operation of the vector, ||f(I i )||2 means f(I i )’s L2 norm; ||f(I psv1 )||2 means f(I psv1 )’s L2 norm; Calculate the anchor image I i with I ngv1 The characteristic distance D(f(I i ),f(I ngv1 )), the calculation formula is as follows: Among them, f(I i ) and f(I ngv1 ) represent I i and I ngv1 The feature vector of i ),f(I psv1 )) and D(f(I i ),f(I ngv1 )) Construct the first loss function L IN The goal of the first loss function is to maximize the feature distance between the anchor image and the positive sample image, while minimizing the feature distance between the anchor image and the negative sample image, so as to achieve the purpose of making the intrinsic feature differences of the same category of ships under different viewing angles as large as possible, and the feature differences between different categories of ships as small as possible. This design enables the model to better distinguish different categories of ships and enhance the model's ability to capture the intrinsic features of ships, thereby improving the performance of ship re-identification.

[0048] The first loss function expression is as follows:

[0049]

[0050] Among them, VI represents different ship images; KI represents images of the same ship from different perspectives; batch represents the number of batch processed images; max IN Indicates I psv1 with I i The maximum feature distance; min IN Indicates I ngv1 with I i The minimum characteristic distance; ε represents L IN The threshold is used to control the minimum value of the distance difference between positive samples and negative samples; [max IN D(f(I i ),f(I psv1 ))-min IN D(f(I i ),f(I ngv1 ))+ε] + It means that if the value in the brackets is less than or equal to 0, the output is 0, otherwise the output is the value in the brackets.

[0051] Figure 3 The schematic diagram of the process of constructing the second loss function of the present application is as follows. The second loss function is constructed to measure the feature differences of the same type of ships under different viewing angles, including: representing the ship image set as I; selecting the i-th anchor image I from I i ; Use the viewpoint identifier AC to obtain the anchor image I i The positive sample image I belongs to the same category under the same perspective psv2 , select the anchor image I i Belonging to different categories under the same perspective as negative sample images I ngv2 ; Calculate anchor image I i with I psv2 The characteristic distance D(f(I i ),f(I psv2 )), the calculation formula is as follows:

[0052]

[0053] Among them, f(I i ) and f(I psv2 ) represent I i and I psv2 Calculate the feature vector of the anchor image I i with I ngv2 The characteristic distance D(f(I i ),f(I ngv2 )), the calculation formula is as follows: Among them, f(I i ) and f(I ngv2 ) represent Ii and I ngv2 The eigenvector of

[0054] Use the viewpoint identifier AC to obtain the anchor image I i The same category under different perspectives is regarded as a positive sample image I psv3 , select the anchor image I i Belonging to different categories under different perspectives as negative sample images I ngv3 ; Calculation I i with I psv3 The characteristic distance D(f(I i ),f(I psv3 )), the calculation formula is as follows: Among them, f(I i ) and f(I psv3 ) represent I i and I psv3 eigenvector of; Calculate I i with I ngv3 The characteristic distance D(f(I i ),f(I ngv3 )), the calculation formula is as follows: Among them, f(I i ) and f(I ngv3 ) represent I i and I ngv3 The feature vector of i ),f(I psv2 ))、D(f(I i ),f(I ngv2 ))、D(f(I i ),f(I psv3 )) and D(f(I i ),f(I ngv3 )) Construct the second loss function L VV .

[0055] The expression of the second loss function is as follows:

[0056]

[0057] Among them, VI represents different ship images; KI represents images of the same ship from different perspectives; batch represents the number of batch processed images; max v2 Indicates I psv2 With anchor image I i The maximum feature distance; min v2 Indicates I ngv2 With anchor image I i The minimum feature distance; max v3 Indicates Ipsv3 With anchor image I i The maximum feature distance; min v3 Indicates I ngv3 With anchor image I i The minimum characteristic distance; α represents L VV The threshold value at the same viewing angle, β represents L VV Thresholds at different viewing angles.

[0058] Specifically, the second loss function maximizes the feature distance between the anchor image and the positive sample image with the largest difference at the same viewpoint to ensure that the feature representations of the same category of ships at the same viewpoint are as different as possible; at the same time, by minimizing the feature distance between the anchor image and the negative sample image with the smallest difference at the same viewpoint, the feature representations of different categories of ships at the same viewpoint are as similar as possible; the second loss function takes into account the feature differences of the same category of ships at the same viewpoint and different viewpoints, as well as the feature similarities of different categories of ships at the same viewpoint and different viewpoints. By introducing anchor images, positive sample images and negative sample images, and combining the viewpoint identifier for viewpoint prediction, we can effectively construct a loss function. This loss function and the first loss function together constitute a dual optimization loss function, which is used to guide the network to learn feature representations with viewpoint invariance and category discrimination, thereby improving the performance of ship re-identification.

[0059] According to the first loss function and the second loss function, a dual optimization loss function L is constructed. q , which is used to simultaneously consider the intrinsic feature differences of the ship and the impact of the perspective change; specifically, the dual optimization loss function L q It is used to measure the loss of the intrinsic characteristics of the ship and the change of the perspective. The expression is as follows: L q =weight in ×L IN +weight vv ×L VV , where weight in Represents the first loss function L IN The weight of the loss function, weight vv is the second loss function L VVThe weight of the loss function. By minimizing the dual optimization loss function, the intrinsic feature differences and feature differences of the same type of ships under different perspectives can be considered at the same time, so that the feature representation can not only distinguish different types of ships, but also reduce the impact of perspective changes, thereby improving the performance of ship re-identification. During the training process, we first calculate the first loss function to ensure that the intrinsic feature representation of the same type of ships under different perspectives is as consistent as possible. Then, the second loss function is calculated to make the overall feature representation of the same type of ships under different perspectives as similar as possible. Finally, the two loss functions are weighted and summed according to the weights to obtain the value of the dual optimization loss function. Through the back-propagation algorithm, we calculate the gradient of the dual optimization loss function to the network parameters, and use an optimization algorithm (such as stochastic gradient descent) to update the network parameters to minimize the dual optimization loss function. After multiple batches of iterative optimization, the network will learn a robust and effective ship feature representation that can distinguish different types of ships and reduce the impact of perspective changes.

[0060] Combining the dual optimization loss function, local loss and cross entropy loss function, the total loss function is constructed; the total loss function of the model is expressed as follows: L s =weight double ×L q +weight local ×L0+weight cross ×L c , where weight double Represents the weight of the dual optimization loss function; weight local Represents the weight of local loss, weight cross represents the weight of the cross entropy loss function, and the weight size is initialized to 0.5, 0.3, and 0.2; L q represents the dual optimization loss function; L c represents the cross entropy loss function; L0 represents the local loss function. c It is used to measure the difference between the probability distribution of the model output and the true label. The expression is as follows: Among them, batch_size represents the batch size, Indicates the first samples, represents the total category, ψ represents the ψth category, log represents the logarithm with base e, represents the true distribution, Represents the network output distribution.

[0061] Among them, local loss is introduced to measure the difference of local features of ship images. Local features refer to the bow, stern, side freeboard, etc. These local features vary between different images, such as changes in local texture, shape and other features of the image caused by factors such as lighting and shooting angle. By introducing local loss, the model can learn more robust and discriminative local feature representations, thereby improving the recognition and re-recognition performance of ship images.

[0062] The local loss L0 includes coordinate loss, category loss, and confidence loss. The calculation process is: L0 = λ coord ×L coord +λ class ×L class +λ conf ×L conf , where λ coord Represents the weight parameter of coordinate loss, λ class Represents the weight parameter of the class loss, λ conf Represents the weight parameter of confidence loss, L coord Expressed as coordinate loss, L class Expressed as category loss, L conf It is expressed as confidence loss.

[0063] For each predicted bounding box, the squared difference is used to calculate the difference between its center coordinates and width and height and the true bounding box. The center coordinates and width and height of the predicted bounding box are (xpred, ypred, wpred, hpred), and the center coordinates and width and height of the true bounding box are (xtrue, ytrue, wtrue, htrue); coordinate loss L coord Expressed as: L coord =(xpred-xtrue) 2 +(ypred-ytrue) 2 +(wpred-wtrue) 2 +(hpred-htrue) 2 . Among them, (xpred, ypred) represents the center coordinates of the predicted bounding box, (wpred, hpred) represents the width and height of the predicted bounding box, (xtrue, ytrue) represents the center coordinates of the true bounding box, and (wtrue, htrue) represents the width and height of the true bounding box; the category loss is for each predicted bounding box, using the cross entropy loss to calculate the difference between its predicted category and the true category; the category loss L class Expressed as: L class=-Σptrue*log(ppred), where Σ represents the sum of all categories, ptrue represents the true category probability, the corresponding value is either 0 or 1, ppred represents the category probability distribution predicted by the model, log(ppred) represents the logarithm of the predicted category probability, and ptrue*log(ppred) represents the product of the logarithm of the true category probability and the predicted category probability; the confidence loss is the difference between the predicted target existence probability (i.e., the confidence of the bounding box) and the true value calculated using the squared difference for each predicted bounding box. Confidence loss L conf Expressed as: L conf =(confpred-conftrue) 2 , where confpred represents the probability that the bounding box predicted by the model contains the target, and conftrue represents the probability that the real target exists, and this value is either 1 or 0.

[0064] Among them, in order to minimize the prediction error, the cross entropy loss function is introduced to measure the difference between the probability distribution of the model output and the true label. Through the cross entropy loss function, the network can learn more discriminative feature representations, thereby optimizing the model. The intrinsic features of a ship refer to its inherent properties, such as the type, size, and structure of the ship, which should be consistent under different perspectives. However, due to factors such as shooting angles and lighting conditions, there may be certain differences in the intrinsic feature representations of the same type of ship under different perspectives. The purpose of the first loss function is to minimize this intrinsic feature difference so that the intrinsic feature representations of the same type of ship under different perspectives are as close as possible. The feature difference of the same type of ship under different perspectives refers to the difference between the overall feature representations of the same type of ship under different perspectives. The ship presents different appearances and details under different perspectives, such as the shape, texture and other features of the ship under the front, side and back perspectives. The purpose of the second loss function is to measure the overall feature difference of the same type of ship under different perspectives, so that the ship re-identification model can capture the feature differences brought about by the change of perspective, thereby improving the robustness and generalization ability of the model.

[0065] During the training process, by minimizing the total loss function, the dual optimization loss function, the local loss function and the cross entropy loss function are comprehensively optimized, so that the network learns a feature representation with perspective invariance, category discrimination and local consistency. Specifically, in each training batch, the local loss is first calculated to measure the difference in local features of the ship to ensure that the local positioning of the ship is as accurate as possible. Then the dual optimization loss function is calculated to measure the intrinsic feature difference and perspective change of the ship to ensure that the feature representation of ships of the same category is as consistent as possible under different perspectives, while the feature representation of ships of different categories is as different as possible under any perspective. Next, the cross entropy loss function is calculated to make the feature representation of ships of the same category more compact and clear. Finally, the three loss functions are weighted and summed according to the weights to obtain the value of the total loss function, and the model parameters are optimized by back propagation. The gradient of the total loss function to the network parameters is calculated by the back propagation algorithm, and the network parameters are updated using an optimization algorithm (such as stochastic gradient descent) to minimize the total loss function. After iterative optimization of multiple training batches, the network will learn a robust and effective ship feature representation that can not only distinguish different categories of ships, but also reduce the impact of perspective changes, while maintaining the consistency of local features with global features. By combining the dual optimization loss function, the local loss function and the cross entropy loss function to construct the total loss function, the comprehensive optimization of the ship feature representation is achieved. The dual optimization loss function is used to measure the intrinsic feature differences and perspective changes of the ship, the local loss function is used to measure the differences in the local features of the ship, and the cross entropy loss function is used to measure the difference between the output probability distribution of the model and the true label in order to minimize the prediction error. By minimizing the total loss function, the network can learn the ship feature representation with perspective invariance, category discrimination and local consistency, and improve the performance of ship re-identification.

[0066] At the same time, the weights of different loss functions are introduced to better balance their contributions to the total loss function, so that the model can adapt to different task requirements and data characteristics, thereby improving its adaptability and generalization ability. The ship re-identification model is trained using the constructed total loss function using the fused feature map as input.

[0067] First, pre-train ResNet-50 as the infrastructure of the ship re-identification model. We will add a fully connected layer to the last layer of ResNet-50 to map the dimension of the fused feature map to the same dimension as the number of ship categories. A softmax activation function is added after the fully connected layer to calculate the probability distribution of each category. The fused feature map is used as the input of the training data, where each fused feature map corresponds to a ship image with the corresponding ship category label. The training data is divided into a training set and a validation set for model training and performance evaluation.

[0068] The total loss function consists of the first loss function, the second loss function, the local loss, and the cross entropy loss. The first loss function uses the Intrinsic Feature Loss loss function to measure the intrinsic feature differences of the same type of ships under different perspectives. The second loss function uses the Viewpoint Variation Loss loss function to measure the feature differences of the same type of ships under different perspectives. The local loss is used to optimize the performance of the YOLOv5s model in local component positioning and feature acquisition, including bounding box regression loss and classification loss. The double optimization loss function composed of the first loss function and the second loss function is weighted summed with the local loss and the cross entropy loss to obtain the total loss function.

[0069] The parameters of the ship re-identification model are updated using the back-propagation algorithm and the optimizer SGD to minimize the total loss function. In each training iteration, the forward propagation calculates the predicted output of the model and calculates the value of the total loss function. The gradient of the loss function with respect to the model parameters is calculated by back-propagation, and the model parameters are updated using the optimizer. During the training process, the performance of the model is regularly evaluated on the validation set, such as R1 (Rank-1 Accuracy), mPA (Mean Precision at k) and other indicators to monitor the generalization ability of the model. Among them, Rank-1 accuracy is an indicator to measure whether the re-identification model can correctly match the query image with the target in the database in a single query, and mPA is a variant of Mean Precision, which calculates the average precision over k queries. According to the performance indicators on the validation set, we adjust the hyperparameters of the model, such as learning rate, batch size, regularization coefficient, etc. We also try different loss function weights to obtain the best performance. Through this training process, we can improve the final prediction accuracy and thus achieve the task of ship re-identification.

[0070] When using the trained ship re-identification model for prediction, the test image is first input into the trained model, and the output of the model is calculated through forward propagation. Then, the output of the model is compared with the predefined category label to obtain the prediction result. The softmax activation function can be used to convert the output of the model into a probability distribution, and the category with the largest probability is selected as the prediction result. When evaluating the performance of the model, the common indicators for evaluating re-identification, such as R1 and mPA, are used. If it is found that the model performance is not up to standard, the model structure, loss function, hyperparameters, etc. can be further adjusted, and the model can be retrained. In the training process of the ship re-identification model, the fused feature map is used as input, and the model is optimized by combining the dual optimization loss function, the local loss function and the cross entropy loss function. During the training process, the gradient descent method is used to optimize the model parameters. By repeatedly calculating the gradient and updating the parameters, the total loss function is continuously reduced, thereby improving the performance of the model. The trained model can be used to predict ship re-identification on the test data, and the prediction result is obtained by comparing the model output with the predefined category label. This method makes full use of the global and local information of the fused feature map, and improves the model's ability to model the intrinsic characteristics of ships and perspective changes through the optimization of multiple loss functions, thereby achieving efficient and accurate ship re-identification.

[0071] The invention of the present application and its implementation methods are described schematically above. The description is not restrictive. Without departing from the spirit or basic features of the present application, the present application can be implemented in other specific forms. What is shown in the accompanying drawings is only one of the implementation methods of the invention of the present application. The actual structure is not limited to this. Any figure mark in the claims should not limit the claims involved. Therefore, if a person of ordinary skill in the art is inspired by it, without departing from the purpose of the present invention, a structural method and an embodiment similar to the technical solution are designed without creativity, which should all fall within the scope of protection of this patent. In addition, the word "including" does not exclude other elements or steps, and the word "one" before the element does not exclude the inclusion of "multiple" elements. The multiple elements stated in the product claim can also be implemented by one element through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any specific order.

Claims

1. A method for ship re-identification, comprising: Obtain ship images, and annotate the ship images with view angles and local parts; the view angle annotation includes the front, side, and rear; the local parts annotation includes the bow, stern, side freeboard, and superstructure; Using ship images, the ResNet-50 model and the YOLOv5s model are trained. The last layer of the ResNet-50 model is set as a fully connected layer. The ResNet-50 model is trained through forward propagation and backward propagation to obtain a viewpoint identifier AC that can distinguish different viewpoints of the ship image. Take the ship image as input and use the trained ResNet-50 model to obtain global features and obtain the global feature map; Take the ship image as input and use the trained YOLOv5s model to locate local parts; obtain local features, obtain local feature maps and local losses; The local feature map and the global feature map obtained are subjected to bidirectional feature fusion BFFM respectively to obtain the global feature map and the local feature map; The global feature map and the local feature map are spliced ​​in the spatial dimension to obtain the final fused feature map; Constructing a first loss function and a second loss function; wherein the first loss function is used to measure the intrinsic feature differences of the same type of ships under different perspectives; and the second loss function is used to measure the feature differences of the same type of ships under different perspectives; According to the first loss function, the second loss function and the dual optimization loss function, a total loss function is constructed by combining the cross entropy loss function and the local loss; wherein the dual optimization loss function is constructed according to the first loss function and the second loss function; A ship re-identification model based on a neural network is constructed, the obtained fusion feature map is used as input, and the ship re-identification model is trained using the total loss function; The image of the ship to be identified is taken as input, and the trained ship re-identification model is used to perform forward propagation calculation on the input image to generate a feature vector; The feature vector is transformed by the softmax activation function of the ship re-identification model to obtain a probability distribution; According to the probability distribution, the category with the highest probability is selected as the result of ship re-identification.

2. The method for ship re-identification according to claim 1, characterized in that: Construct the first loss function, including: Denote the ship image set as I; Select the i-th anchor image I from I i ; Use the viewpoint identifier AC to select the i-th anchor image I from the ship image set I i Images belonging to the same category but from different perspectives are considered positive sample images I psv1 , and the i-th anchor image I i Images belonging to different categories and different perspectives are used as negative sample images I ngv1 ; Computation I i with I psv1 The characteristic distance D(f(I i ),f(I psv1 )), the calculation formula is as follows: Among them, f(I i ) and f(I psv1 ) represent I i and I psv1 The eigenvector of , represents the dot product operation of the vector, ||f(I i )||2 means f(I i )’s L2 norm; ||f(I psv1 )||2 means f(I psv1 )’s L2 norm; Computation I i with I ngv1 The characteristic distance D(f(I i ),f(I ngv1 )), the calculation formula is as follows: Among them, f(I i ) and f(I ngv1 ) represent I i and I ngv1 The eigenvector of According to the characteristic distance D(f(I i ),f(I psv1 )) and D(f(I i ),f(I ngv1 )) Construct the first loss function L IN .

3. The method for ship re-identification according to claim 2, characterized in that: The first loss function L IN The expression is as follows: Among them, VI represents different ship images; KI represents images of the same ship from different perspectives; batch represents the number of batch processed images; max IN Indicates I psv1 With the i-th anchor image I i The maximum feature distance; min IN Indicates I ngv1 With anchor image I i The minimum characteristic distance; ε represents L IN The threshold is used to control the minimum value of the distance difference between positive samples and negative samples; [max IN D(f(I i ),f(I psv1 ))-min IN D(f(I i ),f(I ngv1 ))+ε] + It means that if the value in the brackets is less than or equal to 0, the output is 0, otherwise the output is the value in the brackets.

4. The method for ship re-identification according to claim 3, characterized in that: Construct the second loss function L VV ,include: Denote the ship image set as I; Select the i-th anchor image I from I i ; Use the view detector AC to obtain the i-th anchor image I i The positive sample image I belongs to the same category under the same perspective psv2 , select the image I with the i-th anchor point i Belonging to different categories under the same perspective as negative sample images I ngv2 ; Computation I i with I psv2 The characteristic distance D(f(I i ),f(I psv2 )), the calculation formula is as follows: Among them, f(I i ) and f(I psv2 ) represent I i and I psv2 The eigenvector of Computation I i with I ngv2 The characteristic distance D(f(I i ),f(I ngv2 )), the calculation formula is as follows: Among them, f(I i ) and f(I ngv2 ) represent I i and I ngv2 The eigenvector of Use the view detector AC to obtain the i-th anchor image I i The same category under different perspectives is regarded as a positive sample image I psv3 , select the image I with the i-th anchor point i Belonging to different categories under different perspectives as negative sample images I ngv3 ; Computation I i with I psv3 The characteristic distance D(f(I i ),f(I psv3 )), the calculation formula is as follows: Among them, f(I i ) and f(I psv3 ) represent I i and I psv3 The eigenvector of Computation I i with I ngv3 The characteristic distance D(f(I i ),f(I ngv3 )), the calculation formula is as follows: Among them, f(I i ) and f(I ngv3 ) represent I i and I ngv3 The eigenvector of According to the characteristic distance D(f(I i ),f(I psv2 ))、D(f(I i ),f(I ngv2 ))、D(f(I i ),f(I psv3 )) and D(f(I i ),f(I ngv3 )) Construct the second loss function L VV .

5. The method for ship re-identification according to claim 4, characterized in that: The second loss function L VV The expression is as follows: Among them, VI represents different ship images; KI represents images of the same ship from different perspectives; batch represents the number of batch processed images; max v2 Indicates I psv2 With anchor image I i The maximum feature distance; min v2 Indicates I ngv2 With anchor image I i The minimum feature distance; max v3 Indicates I psv3 With anchor image I i The maximum feature distance; min v3 Indicates I ngv3 With anchor image I i The minimum characteristic distance; α represents L VV The threshold value at the same viewing angle, β represents L VV Thresholds at different viewing angles.

6. The method for ship re-identification according to claim 5, characterized in that: Double optimization loss function L q The loss used to measure the intrinsic characteristics of the ship and the change in perspective is as follows: L q =weight in ×L IN +weight vv ×L VV Among them, weight in Represents the first loss function L IN The weight of the loss function, weight vv is the second loss function L VV The weight of the loss function.

7. The method for ship re-identification according to claim 6, characterized in that: The total loss function of the model is L s The expression is as follows: L s =weight double ×L q +weight local ×L0+weight cross ×L c Among them, weight double Represents the weight of the dual optimization loss function; weight local Represents the local loss weight, weight cross represents the weight of the cross entropy loss function; L q represents the dual optimization loss function; L0 represents the local loss function; L c represents the cross entropy loss function; L c It is used to measure the difference between the output probability distribution of the model and the true label. The expression is as follows: Among them, batch_size represents the batch size, Indicates the first samples, represents the total category, ψ represents the ψth category, log represents the logarithm with base e, represents the true distribution, represents the network output distribution; The local loss function L0 is expressed as follows: L0=λ coord ×L coord +λ class ×L class +λ conf ×L conf Among them, λ coord Represents the weight parameter of coordinate loss, λ class Represents the weight parameter of the class loss, λ conf Represents the weight parameter of confidence loss, L coord Expressed as coordinate loss, L class Expressed as category loss, L conf It is expressed as confidence loss.

8. The method for ship re-identification according to any one of claims 1 to 7, characterized in that: Obtain the view angle identifier AC, including: Obtaining viewpoint annotation data and local component annotation data of the ship image; Get the pre-trained ResNet-50 model and the last fully connected layer of the ResNet-50 model; The output dimension of the last fully connected layer of the obtained ResNet-50 model is set to be equal to the number of view categories; Using the view annotation data, the ResNet-50 model and the fully connected layer are trained through forward and backward propagation to obtain the view identifier AC.

9. The method for ship re-identification according to claim 1, characterized in that: Obtain attention-enhanced global feature maps and attention-enhanced local feature maps, including: Perform L2 regularization on the local feature map; The L2 regularized local feature map is processed through the self-attention mechanism and residual connection to obtain the enhanced local feature map; Project the enhanced local feature map to the corresponding position of the global feature map to obtain the fused feature map; The fused feature map is used as input, and the ResNet-50 model with the last fully connected layer is used to obtain the global feature map with attention enhancement. The attention-enhanced global feature map is concatenated to the original local feature map to obtain the attention-enhanced local feature map.

10. The method for ship re-identification according to claim 9, characterized in that: The L2 regularization expression is as follows: L l2_reg =λ l2 ×||W|| 2 Among them, L l2_reg represents the value of the regularization term; λ l2 represents the regularization parameter, which controls the strength of the regularization term, W represents the weight of the model, ||W|| 2 It represents the square of the L2 norm of the weight, that is, the sum of the squares of all weights.

Citation Information

Patent Citations

  • Ship re-identification method and device, medium and equipment

    CN117994742A