Metric learning method and system for intelligent detection and identification of small sample ship target
By introducing the metric learning module and dynamic weight control resampling strategy in the YOLOv5 model, the feature representation and sample distribution are optimized, and the problems of low recognition rate and insufficient generalization in ship target recognition tasks in small-sample SAR images are solved, achieving higher recognition performance and robustness.
Patent Information
- Application Number
- CN202411854717.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-03-21
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Under small sample conditions, the ship target recognition task in SAR images faces the problem of low category recognition rate and serious generalization inadequate generalization.
The metric learning method of intelligent detection and recognition of small-sample ship targets is adopted, and the sample distribution is adjusted through dynamic weight control, combined with the YOLOv5 model and the metric learning module, and the feature representation is optimized by using the affinity loss function to enhance the inter-class separation and intra-class density of the model.
It improves the robustness and distinction of feature representation, enhances the robustness and generalization capabilities of the model, especially in small sample conditions, which can accurately detect targets and improves recognition performance.
Smart Images

Figure CN119672538A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of SAR image target recognition, and in particular to a metric learning method and system for intelligent detection and recognition of small sample ship targets. Background Art
[0002] In recent years, with the rapid development of remote sensing technology, the application of synthetic aperture radar (SAR) in the fields of ocean monitoring, resource management and national defense has become more and more extensive. However, the acquisition of SAR ship image data is often limited by factors such as complex working environment, high acquisition cost and non-cooperativeness of targets, resulting in insufficient number of available annotated samples. Especially in the task of ship target recognition, the accuracy and stability of recognition face many challenges. Traditional target recognition methods often rely on large-scale annotated data for training, but in practical applications, it is difficult and expensive to obtain enough high-quality samples. Therefore, researchers began to explore more effective solutions. Among them, metric learning has gradually become one of the key methods to improve the performance of SAR ship target recognition due to its advantages under small sample conditions.
[0003] As a lightweight real-time target detection model, YOLOv5 has been widely used in various image recognition tasks due to its superior speed and accuracy. Although YOLOv5 performs well on large sample data sets, when processing ship target recognition in SAR images, especially under small sample conditions, there is still a low recognition rate for categories with a small number of samples and a serious lack of generalization.
[0004] Therefore, based on the above situation, a metric learning system for intelligent detection and recognition of small sample ship targets is needed to meet the needs in small sample conditions. Summary of the invention
[0005] To this end, the present invention provides a metric learning method and system for intelligent detection and recognition of small sample ship targets to solve the problems raised in the background technology.
[0006] In order to achieve the above-mentioned object, the present invention provides the following technical solutions: a metric learning method for intelligent detection and recognition of small sample ship targets, which preprocesses the input SAR image data set;
[0007] Before entering feature extraction, the sampling weights of different categories of ship images are adjusted through dynamic weight control resampling to obtain a dynamically balanced distribution of positive and negative samples; specifically, during the training process, the sampling weights of majority class samples are gradually increased, and the oversampling of minority classes is reduced, so that the feature extraction stage can receive a more balanced sample distribution and reduce the risk of minority or majority classes over-influencing feature training;
[0008] The dynamic weight control resampling adjusts the sampling weights of positive and negative samples to achieve a balanced data distribution. The dynamic weight control resampling weight W i The calculation is:
[0009]
[0010] Where N i is the number of samples of category i, E max is the total number of rounds required for the training process, E is the current number of rounds, β is the exponential adjustment parameter, the setting range is [0,1], and the sampling probability P i The calculation is expressed as:
[0011]
[0012] Generate sample pairs for training the metric learning module, where the image pairs of ships of the same category are positive sample pairs, and the image pairs of ships of different categories are negative sample pairs, so as to enhance the inter-class separation and intra-class compactness of the model;
[0013] The feature extraction module of the YOLOv5 model is used to extract multi-scale feature maps, which are input into the metric learning module. The feature vector is obtained through the average pooling layer and the fully connected layer in the metric learning module. The affinity loss function is used to optimize the feature representation, so that the features of the same category are closer and the features of different categories are more separable, so as to improve the feature representation ability of the model.
[0014] The metric learning module calculates the Euclidean distance between the sample feature vector and the category center through the affinity loss function. The specific calculation formula is:
[0015] d(x,c i )=||xc i || 2
[0016] In the formula, i represents the category, c i represents the center of category i in the feature space, then d(x,c i ) is the feature vector x and center c of any sample i The Euclidean distance between them is mapped to similarity through Gaussian radial basis function RBF, and the formula is:
[0017]
[0018] In the formula, σ represents the hyperparameter that controls the clustering radius, which is used to enhance the intra-class compactness and inter-class separability; the similarity s decreases monotonically with the increase of Euclidean distance. Assuming that the true label corresponding to x is i, the affinity loss is defined as
[0019]
[0020] In the formula, m is the required spacing;
[0021] The feature vector generated by the metric learning module is fused with the multi-scale feature map of the YOLOv5 model to obtain the fused feature map. The number of channels of each scale feature map is adjusted through 1x1 convolution to adapt to the input requirements of the detection head, so as to enhance the model's detection ability for objects of different scales, especially to maintain high detection accuracy in complex backgrounds.
[0022] The improved YOLOv5 model detection head is used to perform target detection and classification on the fused feature map, and the final detection result is output; under complex background and small sample conditions, the low-resolution target classification performance of the classifier is optimized by combining the features output by the metric learning module.
[0023] Preferably, the second preprocessing operation on the input SAR image data set includes:
[0024] The input SAR image data is standardized: when the image size is less than 80x80 pixels, the edge is filled and expanded to 80x80 pixels; when the image size is larger than 80x80 pixels, the center is cropped to 80x80 pixels, and finally a unified 64x64 pixel SAR input image is obtained, and the brightness and contrast are randomly adjusted in the range of [80%, 120%];
[0025] Process the information of the ship target: obtain the location information of the ship, extract the coordinates of the center point, bow and stern of the ship from the XML file in the data set; calculate the direction vector and vertical vector of the ship target, calculate the direction vector and the vector perpendicular to the direction vector according to the coordinates of the bow and stern; calculate the four corner points of the bounding box, use the coordinates of the center point of the ship, the direction vector and the vertical vector to calculate the four corner points of the bounding box, which are the upper left, upper right, lower left and lower right; calculate the minimum and maximum coordinates of the bounding box, and calculate the minimum and maximum coordinates of the bounding box from the four corner points of the bounding box; adjust the coordinates of the bounding box, adjust the coordinates of the bounding box according to the original size of the image to adapt to the final image size; output the coordinates of the bounding box, and write the adjusted coordinates of the bounding box into the annotation file adapted to the network input;
[0026] The direction vector is calculated as follows:
[0027] direction_vector=(tail_x-head_x,tail_y-head_y)
[0028] Where tail_x is the x-coordinate of the stern, tail_y is the y-coordinate of the stern, head_x is the x-coordinate of the bow, and head_y is the y-coordinate of the bow. The calculation method of the vertical vector is as follows:
[0029] perpendicular_vector=(-direction_vector[1],direction_vector[0])
[0030] The coordinates of the four corner points are calculated as follows:
[0031]
[0032] Where top_left represents the coordinates of the top left corner, top_right represents the coordinates of the top right corner, bottom_left represents the coordinates of the bottom left corner, bottom_right represents the coordinates of the bottom right corner, center_x and center_y represent the x and y coordinates of the center of the ship, respectively; direction_vector[0] represents the change on the x-axis, that is, the x-coordinate of the stern minus the x-coordinate of the bow; direction_vector[1] represents the change on the y-axis, that is, the y-coordinate of the stern minus the y-coordinate of the bow; perpendicular_vector[0] represents the negative y-component of the direction vector; perpendicular_vector[1] represents the x-component of the direction vector.
[0033] The invention also discloses a metric learning system for intelligent detection and recognition of small sample ship targets, which is based on the above method.
[0034] The present invention has the following advantages:
[0035] 1. By introducing the metric learning module into the YOLOv5 model and combining it with the affinity loss function, samples of the same category are more closely distributed in the feature space, while samples of different categories are more separated, thereby improving the robustness and discrimination of feature representation. This improvement is particularly suitable for small sample SAR ship target recognition, which can accurately detect targets in complex backgrounds and improve the robustness of the model.
[0036] 2. Through dynamic weight control of the resampling strategy, the sampling probability of samples is adjusted during the training process, the weight of majority class samples is gradually increased, and the oversampling of minority classes is reduced, which effectively balances the distribution of positive and negative samples in the training set and avoids the model's excessive bias towards a certain type of samples, thereby making the model more generalizable and adaptable under small sample conditions.
[0037] 3. The improved YOLOv5 model in the present invention combines the metric learning module to significantly improve the target recognition performance under small sample conditions. Especially when there are few minority class samples, the model can achieve effective recognition of minority class samples through dynamic resampling and metric learning optimization, and maintain high accuracy and robustness in the overall detection task. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A flow chart of the metric learning method for intelligent detection and recognition of small sample ship targets provided in this embodiment;
[0039] Figure 2 This is a diagram of the model structure provided for this embodiment. DETAILED DESCRIPTION
[0040] The following is a description of the implementation of the present invention by specific embodiments. People familiar with the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] See also Figure 1 As shown, this embodiment discloses a metric learning method for intelligent detection and recognition of small sample ship targets, including the following steps:
[0042] S1. Preprocess the images in the dataset, standardize the SAR image data, expand the edge of images smaller than 80x80 pixels to 80x80 pixels, and perform center cropping on images larger than 80x80 pixels to obtain a unified 64x64 pixel input image. The bow and stern coordinates of the target ship and the target center point coordinates in the dataset are used to calculate and generate the real frame for the target recognition task, including: obtaining the position information of the ship, calculating the direction vector and the vertical vector, calculating the four corner points of the bounding box, calculating the minimum and maximum coordinates of the bounding box, adjusting the bounding box coordinates, and outputting the bounding box information.
[0043] The direction vector is calculated as follows:
[0044] direction_vector=(tail_x-head_x,tail_y-head_y)
[0045] Where tail_x is the x-coordinate of the stern, tail_y is the y-coordinate of the stern, head_x is the x-coordinate of the bow, and head_y is the y-coordinate of the bow. The calculation method of the vertical vector is as follows:
[0046] perpendicular_vector=(-direction_vector[1],direction_vector[0])
[0047] The coordinates of the four corner points are calculated as follows:
[0048]
[0049] Where top_left represents the coordinates of the top left corner, top_right represents the coordinates of the top right corner, bottom_left represents the coordinates of the bottom left corner, bottom_right represents the coordinates of the bottom right corner, center_x and center_y represent the x and y coordinates of the center of the ship, respectively. direction_vector[0] represents the change on the x-axis, i.e. the x-coordinate of the stern minus the x-coordinate of the bow; direction_vector[1] represents the change on the y-axis, i.e. the y-coordinate of the stern minus the y-coordinate of the bow; perpendicular_vector[0] represents the negative y-component of the direction vector; perpendicular_vector[1] represents the x-component of the direction vector.
[0050] S2. Before entering feature extraction, the sampling weights of each type of samples are adjusted to dynamically balance the distribution of positive and negative samples. Specifically, during the training process, the sampling weights of the majority class samples are gradually increased, and the oversampling of the minority class is reduced, so that the feature extraction stage can receive a more balanced sample distribution and reduce the risk of the minority class or majority class over-influencing feature training.
[0051] Among them, the dynamic weight controls the resampling weight W i The calculation is:
[0052]
[0053] Where N i is the number of samples of category i, E max is the total number of rounds required for the training process, E is the current round number, β is the exponential adjustment parameter, the setting range is [0,1], and the sampling probability P i The calculation is expressed as:
[0054]
[0055] S3. Generate positive and negative sample pairs for training in the metric learning module according to categories, where the positive sample pairs are image pairs of the same category and the negative sample pairs are image pairs of different categories, so as to enhance the inter-class separation and intra-class compactness of the model.
[0056] S4. Multi-scale feature maps are extracted through the improved YOLOv5 model backbone network, and the feature representation is optimized in combination with the affinity loss function, so that the features of the same category are closer and the features of different categories are more separable, thereby improving the feature representation ability of the model.
[0057] Among them, the metric learning module calculates the Euclidean distance between the sample feature vector and the category center through the affinity loss function. The specific calculation formula is:
[0058] d(x,c i )=||xc i || 2
[0059] In the formula, i represents the category, c i represents the center of category i in the feature space, then d(x,c i ) is the feature vector x and center c of any sample i The Euclidean distance between them is mapped to similarity through Gaussian radial basis function (RBF), and the formula is:
[0060]
[0061] In the formula, σ represents the hyperparameter that controls the clustering radius, which is used to enhance the intra-class compactness and inter-class separability. The similarity s decreases monotonically with the increase of Euclidean distance. Assuming that the true label corresponding to x is i, the affinity loss is defined as
[0062]
[0063] Where m is the required spacing.
[0064] S5. The feature vector generated by the metric learning module is fused with the multi-scale feature map of the YOLOv5 model. The number of channels of each scale feature map is adjusted through 1x1 convolution to adapt to the input requirements of the detection head, thereby enhancing the model's detection ability for targets of different scales, especially maintaining a high detection accuracy in complex backgrounds.
[0065] S6. Use the improved YOLOv5 model detection head to detect and classify the fused feature map and output the final detection result. If the detection result reaches the expected target, the recognition ends. If the detection result does not reach the expected target, dynamic weight control resampling is performed. The low-resolution target classification performance of the classifier is optimized by combining the features output by metric learning, especially the recognition effect under small sample conditions.
[0066] This example uses a public data set to verify the feasibility of the above ship target recognition method. For the model flow chart, please refer to Figure 2 As shown, under this method, the model of this embodiment improves the recognition accuracy of each category.
[0067] In order to verify the feasibility of the method, an ablation experiment was conducted and the results are shown in the following table.
[0068]
[0069] In summary, this embodiment also provides a metric learning system for intelligent detection and recognition of small sample ship targets. The system is based on the above method and has the characteristics of high robustness and high precision.
[0070] Although the present invention has been described in detail above by general description and specific embodiments, it is obvious to those skilled in the art that some modifications or improvements can be made to the present invention. Therefore, these modifications or improvements made without departing from the spirit of the present invention all belong to the scope of protection claimed by the present invention.
Claims
1. A metric learning method for intelligent detection and recognition of small sample ship targets, preprocessing the input SAR image data set, characterized by: Before entering feature extraction, the sampling weights of different types of ship images are adjusted through dynamic weight control resampling to obtain a dynamically balanced distribution of positive and negative samples; The dynamic weight control resampling adjusts the sampling weights of positive and negative samples to achieve a balanced data distribution. The dynamic weight control resampling weight W i The calculation is: Where N i is the number of samples of category i, E max is the total number of rounds required for the training process, E is the current number of rounds, β is the exponential adjustment parameter, the setting range is [0,1], and the sampling probability P i The calculation is expressed as: Generate sample pairs for training the metric learning module, where the image pairs of ships of the same category are positive sample pairs, and the image pairs of ships of different categories are negative sample pairs, so as to enhance the inter-class separation and intra-class compactness of the model; The feature extraction module of the YOLOv5 model is used to extract multi-scale feature maps, which are input into the metric learning module. The feature vector is obtained through the average pooling layer and the fully connected layer in the metric learning module. The affinity loss function is used to optimize the feature representation, so that the features of the same category are closer and the features of different categories are more separable, so as to improve the feature representation ability of the model. The metric learning module calculates the Euclidean distance between the sample feature vector and the category center through the affinity loss function. The specific calculation formula is: d(x,c i )=||x-c i ||2 In the formula, i represents the category, c i represents the center of category i in the feature space, then d(x,c i ) is the feature vector x and center c of any sample i The Euclidean distance between them is mapped to similarity through Gaussian radial basis function RBF, and the formula is: In the formula, σ represents the hyperparameter that controls the clustering radius, which is used to enhance the intra-class compactness and inter-class separability; the similarity s decreases monotonically with the increase of Euclidean distance. Assuming that the true label corresponding to x is i, the affinity loss is defined as In the formula, m is the required spacing; The feature vector generated by the metric learning module is fused with the multi-scale feature map of the YOLOv5 model to obtain the fused feature map. The number of channels of each scale feature map is adjusted through 1x1 convolution to adapt to the input requirements of the detection head, so as to enhance the model's detection ability for objects of different scales. Using the improved YOLOv5 model detection head to perform target detection and classification on the fused feature map, and output the final detection result; Under complex background and small sample conditions, the features output by the metric learning module are combined to optimize the low-resolution target classification performance of the classifier.
2. According to claim 1, a metric learning method for intelligent detection and recognition of small sample ship targets is characterized by: The second operation of preprocessing the input SAR image dataset includes: The input SAR image data is standardized: when the image size is less than 80x80 pixels, the edge is filled and expanded to 80x80 pixels; when the image size is larger than 80x80 pixels, the center is cropped to 80x80 pixels, and finally a unified 64x64 pixel SAR input image is obtained, and the brightness and contrast are randomly adjusted in the range of [80%, 120%]; Process the information of the ship target: obtain the location information of the ship, extract the coordinates of the center point, bow and stern of the ship from the XML file in the data set; calculate the direction vector and vertical vector of the ship target, calculate the direction vector and the vector perpendicular to the direction vector according to the coordinates of the bow and stern; calculate the four corner points of the bounding box, use the coordinates of the center point of the ship, the direction vector and the vertical vector to calculate the four corner points of the bounding box, which are the upper left, upper right, lower left and lower right; calculate the minimum and maximum coordinates of the bounding box, and calculate the minimum and maximum coordinates of the bounding box from the four corner points of the bounding box; adjust the coordinates of the bounding box, adjust the coordinates of the bounding box according to the original size of the image to adapt to the final image size; output the coordinates of the bounding box, and write the adjusted coordinates of the bounding box into the annotation file adapted to the network input; The direction vector is calculated as follows: direction_vector=(tail_x-head_x,tail_y-head_y) Where tail_x is the x-coordinate of the stern, tail_y is the y-coordinate of the stern, head_x is the x-coordinate of the bow, and head_y is the y-coordinate of the bow. The calculation method of the vertical vector is as follows: perpendicular_vector=(-direction_vector[1],direction_vector[0]) The coordinates of the four corner points are calculated as follows: Where top_left represents the coordinates of the top left corner, top_right represents the coordinates of the top right corner, bottom_left represents the coordinates of the bottom left corner, bottom_right represents the coordinates of the bottom right corner, center_x and center_y represent the x and y coordinates of the center of the ship, respectively; direction_vector[0] represents the change on the x-axis, that is, the x-coordinate of the stern minus the x-coordinate of the bow; direction_vector[1] represents the change on the y-axis, that is, the y-coordinate of the stern minus the y-coordinate of the bow; perpendicular_vector[0] represents the negative y-component of the direction vector; perpendicular_vector[1] represents the x-component of the direction vector.
3. A metric learning system for intelligent detection and recognition of small sample ship targets, characterized by: The system is based on the method according to any one of claims 1-2.
Citation Information
Patent Citations
Method for positioning ship image target by using AIS to calibrate CCTV camera in VTS system
CN113112540A
Small sample remote sensing image target detection method and system, computer and readable storage medium
CN116977716A
Cited By
Unmanned aerial vehicle collision interception method based on monocular vision and collision unmanned aerial vehicle
CN121209574A