A small sample ship target detection method, system and device based on meta learning

By combining the energy function attention module and the multi-view variational feature aggregation module, the problems of background noise and intra-class variance collapse in ship target detection are solved, achieving high-precision and stable detection results.

CN122223309BActive Publication Date: 2026-07-21HARBIN ENGINEERING UNIVERSITY SANYA NANHAI INNOVATION & DEVELOPMENT BASE +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HARBIN ENGINEERING UNIVERSITY SANYA NANHAI INNOVATION & DEVELOPMENT BASE
Filing Date
2026-05-15
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Existing meta-learning methods for ship target detection suffer from background noise pollution, intra-class variance collapse, and background noise diversity interference, leading to decreased detection accuracy and insufficient generalization ability.

Method used

We employ an energy function-based attention module and a multi-view variational feature aggregation module, combined with reconstructed prototype constraints, to perform joint inference by acquiring query images and support set samples, thereby suppressing background interference and enhancing the diversity of new category features.

Benefits of technology

Significantly improves the accuracy and positioning stability of ship target detection in complex marine environments, reduces false detection and false negative rates, and enhances the model's generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122223309B_ABST
    Figure CN122223309B_ABST
Patent Text Reader

Abstract

The application provides a small sample ship target detection method, system and equipment based on meta learning, and relates to the technical field of artificial intelligence. The detection method: acquires a query image to be detected and a support set sample, and the support set sample contains at least one ship target example image with labels; inputs the query image and the support set sample into a pre-trained target detection model to obtain a class prediction result and a bounding box position prediction result of the ship target; wherein the pre-trained target detection model includes an attention module based on an energy function, a multi-view variational feature aggregation module and a reconstruction prototype constraint module used in the model training stage. The application significantly improves the detection accuracy and positioning stability of the ship target under the condition of a small amount of samples, reduces the false detection and missed detection rates, and has stronger generalization ability and practical application value compared with the existing meta learning algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and more specifically, to a method, system, and device for detecting small-sample ship targets based on meta-learning. Background Technology

[0002] Few-sample object detection aims to enable detection models to quickly adapt to new object categories using a very small number of labeled samples, which has significant application value in scenarios such as ship inspection where labeled data is difficult to obtain. Current mainstream methods are mostly based on the meta-learning paradigm, which learns general knowledge from a large number of basic category tasks and then quickly adapts it to a small number of new category samples to alleviate the overfitting problem caused by data scarcity.

[0003] However, existing meta-learning methods still have the following problems when applied to ship target detection: First, ship inspection scenarios are generally characterized by complex sea backgrounds, lighting variations, and wave interference. Existing methods lack targeted background suppression mechanisms in the feature extraction process of supporting samples, resulting in background noise contaminating supporting features and reducing the purity and reliability of the category prototype.

[0004] Second, existing meta-learning methods typically use global average pooling or simple prototype aggregation to generate class representations, which tend to produce single, compact class prototypes. This leads to severe collapse of the intra-class variance of new class features, making it difficult to cover the reasonable appearance differences of ship targets caused by changes in viewpoint, scale, attitude, etc., thus limiting the generalization ability of the model.

[0005] Third, simply introducing data augmentation and other operations to enhance intra-class diversity will proportionally amplify the diversity of background noise, causing the model to learn a large number of irrelevant variations that are not related to target discrimination, further interfering with the extraction of key discrimination features of ship targets, resulting in blurred discrimination boundaries and decreased detection accuracy.

[0006] Therefore, how to achieve high-precision detection of ship targets using a very small number of labeled samples in a complex marine environment, while effectively suppressing background interference and maintaining reasonable intra-class feature diversity, is a technical problem that urgently needs to be solved in this field. Summary of the Invention

[0007] The problem solved by this invention is one or more of the aforementioned related technical problems.

[0008] To address the aforementioned problems, this invention provides a method, system, and device for detecting small-sample ship targets based on meta-learning.

[0009] In a first aspect, the present invention provides a small-sample ship target detection method based on meta-learning, comprising: Obtain the query image to be detected and the support set sample, wherein the support set sample contains at least one labeled example image of a ship target; The query image and the support set samples are input into a pre-trained target detection model to obtain the category prediction results and bounding box position prediction results of the ship target; The pre-trained target detection model includes a first backbone network, a second backbone network, a region proposal network, an energy function-based attention module, a multi-view variational feature aggregation module, and a reconstructed prototype constraint module for the model training phase. The pre-trained target detection model further includes a first backbone network, a second backbone network, and a region proposal network. The step of inputting the query image and the support set samples into a pre-trained target detection model to obtain the category prediction result and bounding box location prediction result of the ship target includes: The support set samples are input into the first backbone network to extract the original support feature map; the query image is input into the second backbone network to extract the query feature map. The original support feature map is input into the energy function-based attention module to obtain the enhanced support feature map; The query feature map is input into the region proposal network to generate candidate regions; The RoIAlign operation extracts query RoI features corresponding to the candidate region from the query feature map and extracts supporting RoI features from the enhanced support feature map. The RoI-supporting features are input into the multi-view variational feature aggregation module to obtain the aggregated feature representation; The aggregated feature representation is aggregated with the query RoI feature by dot product, and the aggregated feature is input into a classifier to obtain the category prediction result of the ship target; and the query RoI feature is input into a regressor to obtain the bounding box location prediction result of the ship target.

[0010] Optionally, the step of inputting the original support feature map into the energy function-based attention module to obtain the enhanced support feature map includes: The feature map spatial mean is determined based on the original support feature map, and the squared deviation of each spatial position in the channel relative to the channel mean and the channel variance are obtained based on the feature map spatial mean. The inverse energy response is obtained based on the squared deviation of each spatial position within the channel relative to the channel mean and the channel variance. Based on the Sigmoid function, attention weights are obtained according to the inverse energy response; The attention weights are multiplied element-wise with the original support feature map to obtain the enhanced support feature map.

[0011] Optionally, the multi-view variational feature aggregation module includes a variational feature encoder; the step of inputting the RoI-supporting features into the multi-view variational feature aggregation module to obtain the aggregated feature representation includes: The RoI-supporting features are input into the variational feature encoder to obtain the mean and variance parameters of each RoI-supporting feature; Based on the mean parameter and variance parameter, a deterministic latent representation of each of the supporting RoI features is constructed; Multiple deterministic latent representations belonging to the same category are aggregated to obtain the aggregated feature representation.

[0012] Optionally, the pre-trained target detection model is obtained through two-stage training, which includes a meta-training stage. The meta-training phase includes: Obtain a basic category dataset and divide it into a query set and a support set. Input the query set and support set into the target detection model to be trained, obtain the prediction result through forward computation, construct the total loss with the ground truth labels, and backpropagate the gradient of the total loss to jointly optimize the target detection model to be trained, thereby obtaining the meta-trained target detection model.

[0013] Optionally, the two-stage training further includes a meta-fine-tuning stage, which includes: Obtain new category samples from a small sample ship target detection dataset, and construct a support set-query set pair based on the small sample ship target detection dataset using a dynamic sampling strategy. The support set-query set pair is input into the meta-trained target detection model; The support set samples in the support set-query set pair are sequentially passed through the attention module and the multi-view variational feature aggregation module in the meta-trained target detection model to obtain temporary aggregated feature representations and temporary reconstructed support features; the multi-view variational feature aggregation module includes a variational feature encoder and a variational feature decoder. The query set samples from the support set-query set pair are passed through the backbone network of the meta-trained object detection model to obtain temporary query RoI features; the category prediction is obtained by performing dot product aggregation processing on the temporary aggregated feature representation and the temporary query RoI features. The temporary query RoI features are input into the regressor in the meta-trained object detection model to obtain bounding box predictions. The temporary reconstruction support features are input into the reconstruction prototype constraint module of the meta-trained target detection model. Based on the temporary reconstruction support features, a class prototype set is constructed and the reconstruction prototype loss is calculated. The reconstruction prototype loss is superimposed with the total loss of the meta-training stage as the total loss of the meta-fine-tuning stage. The gradient of the total loss of the meta-fine-tuning stage is backpropagated to optimize the model parameters, thereby obtaining the pre-trained target detection model.

[0014] Optionally, the step of constructing a set of class prototypes based on the temporary reconstruction support features and calculating the reconstruction prototype loss includes: Based on the temporary reconstruction support features, construct a class prototype set and determine the negative Euclidean distance between each temporary query RoI feature and each class prototype in the class prototype set; The negative log-likelihood loss is calculated by normalizing the negative Euclidean distances using the softmax function, and the reconstructed prototype loss is obtained.

[0015] Optionally, the first backbone network and the second backbone network share weights.

[0016] Secondly, the present invention provides a small-sample ship target detection system based on meta-learning, comprising: The acquisition unit is used to acquire the query image to be detected and the support set sample, wherein the support set sample contains at least one labeled example image of a ship target; The processing unit is configured to input the query image and the support set samples into a pre-trained target detection model to obtain the category prediction result and the bounding box position prediction result of the ship target; wherein, the pre-trained target detection model includes a first backbone network, a second backbone network, a region proposal network, an energy function-based attention module, a multi-view variational feature aggregation module, and a reconstruction prototype constraint module for the model training phase; wherein, the step of inputting the query image and the support set samples into the pre-trained target detection model to obtain the category prediction result and the bounding box position prediction result of the ship target includes: inputting the support set samples into the first backbone network to extract the original support feature map; inputting the query image into the second backbone network to extract the query image; and inputting the query image into the second backbone network to extract the original support feature map. The query feature map is input into the energy function-based attention module to obtain an enhanced support feature map. The query feature map is then input into the region proposal network to generate candidate regions. Through the RoIAlign operation, query RoI features corresponding to the candidate regions are extracted from the query feature map, and support RoI features are extracted from the enhanced support feature map. The support RoI features are input into the multi-view variational feature aggregation module to obtain an aggregated feature representation. The aggregated feature representation and the query RoI features are then subjected to a dot product aggregation. The aggregated features are input into a classifier to obtain the category prediction result of the ship target. Finally, the query RoI features are input into a regressor to obtain the bounding box position prediction result of the ship target.

[0017] Thirdly, the present invention provides a small-sample ship target detection device based on meta-learning, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the small-sample ship target detection method based on meta-learning as described in the first aspect.

[0018] Fourthly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the small-sample ship target detection method based on meta-learning as described in the first aspect.

[0019] The beneficial effects of the meta-learning-based small-sample ship target detection method and system of the present invention are: By acquiring the query image to be detected and a small number of labeled ship support samples, and using a pre-trained target detection model that includes an energy function-based attention module, a multi-view variational feature aggregation module, and a reconstructed prototype constraint module for joint inference, this method can effectively suppress interference from sea waves, lighting changes, and port clutter in complex marine environments, thereby improving the class purity of support samples. At the same time, multi-view variational aggregation enhances the diversity of new class features, avoids prototype representation collapse, and the reconstructed prototype constraint module guides the alignment of discriminative features. Thus, under conditions of very few samples, this method significantly improves the detection accuracy and positioning stability of ship targets, reduces false detection and false negative rates, and has stronger generalization ability and practical application value compared to existing meta-learning algorithms. Attached Figure Description

[0020] Figure 1 This is a flowchart illustrating a small-sample ship target detection method based on meta-learning according to an embodiment of the present invention. Figure 2 This is a schematic diagram of the category prediction result and bounding box position prediction result of a ship target according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the overall architecture and data flow of a target detection model according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the internal structure and data flow of a multi-view variational feature aggregation module in the inference phase (or the forward process of the training phase) according to an embodiment of the present invention. Figure 5 This is a schematic diagram illustrating loss calculation and optimization during model training according to an embodiment of the present invention; Figure 6 This is a schematic diagram showing the results of a comparative experiment in an embodiment of the present invention. Detailed Implementation

[0021] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Although some embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present invention. It should be understood that the accompanying drawings and embodiments of the present invention are for illustrative purposes only and are not intended to limit the scope of protection of the present invention.

[0022] It should be understood that the various steps described in the method embodiments of the present invention may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.

[0023] The term "comprising" and its variations as used herein are open-ended, meaning "including but not limited to"; the term "based on" means "at least partially based on"; the term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments"; and the term "optionally" means "optional embodiments". Definitions of other terms will be given in the following description. It should be noted that the concepts of "first," "second," etc., mentioned in this invention are used only to distinguish different devices, modules, or units, and are not intended to limit the order of functions performed by these devices, modules, or units or their interdependencies.

[0024] It should be noted that the terms "one" and "more" used in this invention are illustrative rather than restrictive. Those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0025] The names of the messages or information exchanged between the multiple devices in the embodiments of the present invention are for illustrative purposes only and are not intended to limit the scope of these messages or information.

[0026] like Figure 1 As shown in the figure, an embodiment of the present invention provides a small-sample ship target detection method based on meta-learning, comprising: Step S100: Obtain the query image to be detected and the support set sample, wherein the support set sample contains at least one labeled example image of a ship target.

[0027] Specifically, the process begins by acquiring the query image to be detected. This query image is the original image from which ship target detection is performed, such as a frame of sea surface footage containing multiple ships captured by a port surveillance camera. Simultaneously, a support set of samples is acquired. This support set contains at least one labeled example image of a ship target. For instance, if the user needs to detect the "yacht" category, the support set could be three pre-prepared images of a yacht taken from different angles and under different lighting conditions, each image labeled with a bounding box indicating the yacht's location and its category label "yacht." These support set samples serve as category references, indicating the appearance of the target the model is currently searching for. The support set samples can come from a pre-built small sample ship target detection dataset or be provided by the user in real time. The acquired query image and support set samples are then fed together into a pre-trained target detection model for inference.

[0028] Query Image: The original image to be detected. The model needs to find ship targets in this image that are of the same category as the samples in the support set and output their bounding boxes and categories.

[0029] Support set samples: Contains at least one example image of a ship target with complete annotations (bounding box and category label) to indicate to the model the target category to be detected and its typical appearance features.

[0030] Labeling: refers to the manual marking of targets in an image, which usually includes the bounding box coordinates of the target (e.g., xmin: minimum horizontal coordinate, ymin: minimum vertical coordinate, xmax: maximum horizontal coordinate, ymax: maximum vertical coordinate) and category name (e.g., "sailboat" "yacht").

[0031] By simultaneously acquiring query images and a small number of labeled support set samples, a clear category reference is provided for the subsequent detection model. This allows the model to dynamically understand the appearance features of the target to be detected during the inference stage without having seen the new category beforehand. Only a very small number of support set samples (e.g., 1 to 10 images) are needed to effectively guide the model, greatly reducing the dependence on large-scale labeled data. This is especially suitable for real-world scenarios in ship detection where new ship categories frequently appear and labeling costs are high. At the same time, this step adopts a flexible acquisition method (either read from the dataset or provided by the user in real time), enhancing the practicality and ease of deployment of the method.

[0032] Step S200: Input the query image and the support set samples into the pre-trained target detection model to obtain the category prediction result and bounding box position prediction result of the ship target; The pre-trained target detection model includes an attention module based on an energy function, a multi-view variational feature aggregation module, and a reconstructed prototype constraint module for the model training phase.

[0033] Specifically, the query image and support set samples obtained in step S100 are input together into a pre-trained object detection model. This model contains three core modules: an energy function-based attention module, a multi-view variational feature aggregation module, and a prototype constraint module for model training. During the inference phase, the model first uses the energy function-based attention module to enhance the feature maps of the support set samples by background suppression, highlighting the foreground response of the ship target. Subsequently, the multi-view variational feature aggregation module encodes the enhanced support features into latent representations and generates aggregated feature representations through multi-view fusion methods such as mean, maximum, and attention weighting. Finally, the aggregated feature representations are matched with candidate region features extracted from the query image, outputting the category prediction (e.g., "yacht" or "sailboat") and the bounding box coordinates for each candidate region. The prototype constraint module is used to assist optimization during model training, but since the model parameters are fixed during the inference phase, this module does not participate in forward computation.

[0034] For example, if the support set contains 3 images of yachts and the query image is an aerial view of a port, the model will output the bounding boxes of all yacht targets in the image (such as "xmin=120, ymin=80, xmax=310, ymax=220") and the corresponding category label "yacht".

[0035] Aggregated feature representation: A comprehensive feature vector obtained by fusing the latent representations of multiple supporting samples through multi-view fusion (mean, maximum, attention weighting), which is used for similarity matching with query features.

[0036] Candidate region features: Feature vectors corresponding to image regions in the query image that may contain targets, selected by the region proposal network.

[0037] Category prediction results: The specific ship category output by the model after classifying each candidate region, such as "sailboat" or "container ship".

[0038] Bounding box location prediction results: The precise location of the target in the image predicted by the model, usually represented by the coordinates (xmin, ymin, xmax, ymax) of the top left and bottom right corners.

[0039] By inputting the query image and support set samples into a detection model incorporating an energy attention mechanism and multi-view variational aggregation, efficient utilization of a very small number of support samples can be achieved during the inference phase: the energy attention module dynamically suppresses background interference such as sea waves and lighting changes, significantly improving the purity of support features; the multi-view variational aggregation module generates target representations with reasonable intra-class variance, avoiding feature collapse caused by traditional single prototypes. Thus, without retraining, it can accurately detect ship targets of the same category in the query image using only a few example images. This method significantly reduces the false detection and false negative rates in small-sample scenarios, with detection accuracy significantly superior to existing meta-learning algorithms, and high inference efficiency, making it suitable for real-time applications such as port monitoring and maritime patrol.

[0040] In this embodiment, by acquiring the query image to be detected and a small number of labeled ship support samples, and using a pre-trained target detection model that includes an energy function-based attention module, a multi-view variational feature aggregation module, and a reconstructed prototype constraint module for joint inference, interference from sea waves, lighting changes, and port clutter in complex marine backgrounds can be effectively suppressed, improving the class purity of support samples. At the same time, the diversity of new class features is enhanced through multi-view variational aggregation to avoid prototype representation collapse, and the reconstructed prototype constraint module guides the alignment of discriminative features. Thus, under conditions of very few samples, the detection accuracy and positioning stability of ship targets are significantly improved, and the false detection and false negative rates are reduced. Compared with existing meta-learning algorithms, it has stronger generalization ability and practical application value.

[0041] Optionally, the pre-trained target detection model further includes a first backbone network, a second backbone network, and a region proposal network; The step of inputting the query image and the support set samples into a pre-trained target detection model to obtain the category prediction result and bounding box location prediction result of the ship target includes: The support set samples are input into the first backbone network to extract the original support feature map; the query image is input into the second backbone network to extract the query feature map. The original support feature map is input into the energy function-based attention module to obtain the enhanced support feature map; The query feature map is input into the region proposal network to generate candidate regions; The RoIAlign operation extracts query RoI features corresponding to the candidate region from the query feature map and extracts supporting RoI features from the enhanced support feature map. The RoI-supporting features are input into the multi-view variational feature aggregation module to obtain the aggregated feature representation; The aggregated feature representation is aggregated with the query RoI feature by dot product, and the aggregated feature is input into a classifier to obtain the category prediction result of the ship target; and the query RoI feature is input into a regressor to obtain the bounding box location prediction result of the ship target.

[0042] Specifically, firstly, the support set samples (e.g., 3 images of yachts) are input into the first backbone network (e.g., ResNet-101), and the original support feature map is extracted through convolution operations. This feature map preserves the spatial structure and channel semantic information of the image. At the same time, the query image (e.g., an aerial view of a port) is input into the second backbone network (which shares weights with the first backbone network) to obtain the query feature map.

[0043] Next, the original support feature map is fed into an energy function-based attention module. This module calculates the energy response at each spatial location in the feature map, generates attention weights, suppresses background interference such as sea waves and illumination changes, and outputs an enhanced support feature map. The foreground response of the ship target in the enhanced feature map is significantly strengthened.

[0044] The query feature map is then fed into a region proposal network, which generates a series of candidate regions (e.g., hundreds of bounding boxes) that may contain the target through a sliding window and anchor point mechanism. The RoIAlign operation (a feature alignment method based on bilinear interpolation) is used to precisely extract the query RoI features corresponding to each candidate region from the query feature map; simultaneously, supporting RoI features are extracted from the enhanced supporting feature map, with each supporting RoI feature corresponding to a labeled ship target instance in the support set image.

[0045] Next, all RoI-supporting features are input into the multi-view variational feature aggregation module. This module first performs variational encoding on each RoI-supporting feature to obtain the mean and variance of its latent distribution, and then constructs a deterministic latent representation. Then, it fuses the mean view, maximum view and attention-weighted view of multiple deterministic latent representations belonging to the same category (such as yachts) to generate a compact aggregated feature representation with reasonable intra-class variance.

[0046] Finally, the aggregated feature representation is combined with the query RoI features using a dot product (i.e., calculating the inner product of feature vectors to measure similarity). The aggregated features are then input into the classifier, which outputs the category prediction result for each candidate region (e.g., "yacht" or "background"). Simultaneously, the query RoI features are independently input into the regressor, which outputs the precise location of the bounding box (e.g., xmin, ymin, xmax, ymax). At this point, the model has completed the detection of all ship targets in the query image. Figure 2 The diagram shows the prediction results for the ship target category and the bounding box location. Figure 2 (a) Figure 2 (b) Figure 2 (c) Visualization of ship target detection results under 1-shot / 5-shot / 10-shot sample conditions; the figure shows that the proposed method can still effectively detect ship targets in the face of complex background interference such as port facilities, shoreline and sea clutter; it can also achieve relatively accurate identification and positioning for distant ships that occupy a small proportion in the image.

[0047] Among them, the first backbone network / second backbone network are deep convolutional neural networks with shared weights (such as ResNet-101), which are used to extract high-level semantic feature maps of support set samples and query images, respectively.

[0048] Raw support feature maps: Feature maps directly output by the backbone network from the support set images, without attention enhancement, containing raw foreground and background information.

[0049] Enhanced Support Feature Map: The feature map processed by the energy function-based attention module has background noise suppressed and the foreground response of the ship target enhanced.

[0050] Region Proposal Network: A network module used to quickly generate a large number of candidate target regions from the query feature map, and outputs the coordinates of the candidate regions and a preliminary score as to whether they are foreground.

[0051] Candidate regions: The set of rectangular boxes that may contain the target output by the region proposal network, usually numbering in the hundreds, which need to be further classified and fine-tuned.

[0052] RoIAlign operation: A feature extraction method that maps candidate regions of different sizes to a fixed-size feature map and avoids quantization errors by using bilinear interpolation, thus preserving spatial accuracy.

[0053] RoI Query Features: Fixed-size feature vectors of the corresponding candidate regions extracted from the query feature map, which are used for subsequent classification and regression.

[0054] Support RoI features: Fixed-size feature vectors of the corresponding labeled targets extracted from the enhanced support feature map are used to construct category representations.

[0055] Dot product aggregation: Calculates the inner product between the aggregated feature representation and the query RoI feature. The larger the inner product value, the more similar the two are, which is used for classification decision-making.

[0056] Classifier: Typically a fully connected layer plus Softmax, outputting the probability that each candidate region belongs to each category.

[0057] Regressor: Typically a fully connected layer, it outputs the offset of the bounding box coordinates, used to fine-tune the position of candidate regions.

[0058] By introducing a dual-backbone network with shared weights to extract support and query features, and combining this with an energy attention module to suppress background effects on support features, the class purity of support samples is significantly improved. The RoIAlign operation achieves pixel-level precise feature alignment, ensuring feature quality for small targets (such as distant ships). A multi-view variational feature aggregation module generates aggregated representations with reasonable intra-class variance, avoiding feature collapse common in traditional prototype aggregation. The decoupling of dot product aggregation and classification / regression design allows the model to quickly and accurately match ship targets of the same class in the query image with a very small number of support samples. The entire process balances detection accuracy and computational efficiency, demonstrating excellent generalization ability and robustness in complex marine scenarios.

[0059] In some embodiments, such as Figure 3 As shown in the diagram, this illustration demonstrates the overall architecture and data flow of the object detection model, highlighting the core modules within the meta-learner and their interactions.

[0060] The diagram is divided into two branches, one above the other: Upper branch (support set branch): Processes support set samples, generates latent class representations through feature extraction, energy-guided variational feature encoding, and multi-view aggregation, and calculates the reconstructed prototype loss.

[0061] The lower branch (query set branch) processes the query image, obtains query RoI features through feature extraction, RPN, and RoI Align, and finally matches them with the aggregated features of the supporting branches.

[0062] The dashed box in the figure represents the entire small sample object detection model, that is, the pre-trained object detection model.

[0063] Detailed process instructions: 1. Support set branch: Support set samples are input to feature extraction (first backbone network) and output the original support feature map.

[0064] After enhancement by an attention module based on an energy function, an enhanced support feature map is obtained.

[0065] The enhanced support feature map is formed by the variational feature encoder, which outputs the mean μ and variance σ to form the latent distribution N(μ,σ).

[0066] A deterministic latent representation is constructed based on μ and σ, and an aggregated feature representation is generated through multi-view aggregation (mean, maximum, attention weighting).

[0067] Meanwhile, during the training phase, latent representations are obtained through sampling, and the reconstructed prototype loss is calculated after the decoder.

[0068] 2. Query set branches: The query image is input into the feature extraction (second backbone network), and the query feature map is output.

[0069] The query feature map is fed into the Region Proposal Network (RPN) to generate candidate regions.

[0070] RoI Align (extracts query RoI features from the query feature map).

[0071] 3. Integration and Output: The aggregated feature representation of the support branch is aggregated with the query RoI feature by dot product and fed into the classifier to obtain the category prediction. The query RoI feature is fed into the regressor to obtain the bounding box prediction.

[0072] 4. Additional constraints during training: The variational feature decoder outputs reconstructed support features, which are used to calculate the reconstructed prototype loss and jointly optimize it with KL divergence, reconstruction loss, consistency loss, etc.

[0073] The figure clearly illustrates the three parts: "energy-guided variational feature encoding", "multi-view aggregation" and "reconstruction prototype loss", as well as the integration method of standard detection components such as RPN and RoI Align with meta-learning frameworks.

[0074] Optionally, the step of inputting the original support feature map into the energy function-based attention module to obtain the enhanced support feature map includes: The feature map spatial mean is determined based on the original support feature map, and the squared deviation of each spatial position in the channel relative to the channel mean and the channel variance are obtained based on the feature map spatial mean. The inverse energy response is obtained based on the squared deviation of each spatial position within the channel relative to the channel mean and the channel variance. Based on the Sigmoid function, attention weights are obtained according to the inverse energy response; The attention weights are multiplied element-wise with the original support feature map to obtain the enhanced support feature map.

[0075] Specifically, the original support feature map is input into an energy function-based attention module, and an enhanced support feature map is generated through the following sub-steps to suppress background noise and highlight the foreground of the ship target.

[0076] Assume the original support feature map is Where C is the number of channels (e.g., 1024), and H and W are the spatial height and width of the feature map.

[0077] Calculate the spatial mean and channel variance of the feature map: First, for each channel... Calculate its mean across the entire spatial location. : ; Then, calculate the squared deviation of each spatial location within each channel relative to the mean of that channel. : ; Then calculate the variance of the channel. : ; Calculate the inverse energy response for each spatial location: Define its "inverse energy response" within this channel: ; in, It is a very small stable term (e.g.) This prevents the denominator from being zero. The physical meaning of this response is: when the squared deviation at a certain position is small relative to the channel variance (i.e., the position is close to the channel mean), the inverse energy response is large; conversely, if the deviation is large (which may be due to strong background or noise), the inverse energy response is small. h: the height direction index of the feature map, ranging from 1 to H (the spatial height of the feature map), used to traverse each row; w: the width direction index of the feature map, ranging from 1 to W (the spatial width of the feature map), used to traverse each column.

[0078] Attention weights are generated using the Sigmoid function: The inverse energy response is mapped to the (0,1) interval using a Sigmoid function to obtain the attention weights. : ; In this way, positions close to the channel mean receive a weight close to 0.5, while positions significantly deviating from the mean (usually corresponding to the target foreground or strong interference) receive a weight greater than 0.5 or less than 0.5 depending on the degree of deviation. Experiments show that the target area of ​​a ship typically exhibits statistical characteristics different from the background, thus receiving a higher attention weight.

[0079] Finally, the attention weights are multiplied element-wise with the original feature map: ; Right now Output Enhanced Support Feature Map The foreground response related to the ship target is preserved or enhanced, while background noise such as sea waves and light reflection is effectively suppressed.

[0080] Suppose a supporting sample is an image containing "yacht," whose feature map has a high response value in the yacht region, and this region... The response value is relatively large; while in calm sea areas, the response value is close to the channel mean, resulting in... The initial value is relatively small, while the inverse energy response is relatively large. However, the weight after Sigmoid is still close to 0.5, and it remains small even after multiplying by the original small value. Ultimately, the features of the yacht area are highlighted, while the background is blurred.

[0081] The energy function-based attention mechanism requires no additional parameters and adaptively enhances the foreground and suppresses the background using only the statistical distribution of the feature map itself. Compared to general global data augmentation or fixed attention, this method can accurately improve the class purity of ship targets in the support samples, reduce the contamination of support features by complex sea backgrounds, waves, and lighting changes, thereby enabling subsequent variational coding and multi-view aggregation to obtain more reliable support representations, ultimately significantly improving the recall and precision of ship target detection under small sample conditions.

[0082] Optionally, the multi-view variational feature aggregation module includes a variational feature encoder; the step of inputting the RoI-supporting features into the multi-view variational feature aggregation module to obtain the aggregated feature representation includes: The RoI-supporting features are input into the variational feature encoder to obtain the mean and variance parameters of each RoI-supporting feature; Based on the mean parameter and variance parameter, a deterministic latent representation of each of the supporting RoI features is constructed; Multiple deterministic latent representations belonging to the same category are aggregated to obtain the aggregated feature representation.

[0083] In some embodiments, it is assumed that there are N supporting RoI features under the current category (e.g., "yacht"), and the i-th supporting RoI feature is denoted as . (D is the feature dimension, for example, 1024).

[0084] Variational feature encoding, outputting mean and variance parameters: Each RoI-supporting feature is input into the variational feature encoder (consisting of fully connected layers with a leaky rectified function and batch normalization). The encoder maps it to the mean and log-variance of a latent Gaussian distribution. ; in, , L represents the dimension of the latent space (e.g., 128). For numerical stability, the logarithmic variance is typically output, and the variance parameter is obtained through exponential operations. .

[0085] Constructing a deterministic latent representation: In the inference phase, deterministic latent representations are typically used to avoid the randomness introduced by sampling. This scheme employs a construction method based on "mean + standard deviation": ; in, The standard deviation vector (i.e.) This construction method preserves variance information, giving the latent representation controllable intrinsic variability while avoiding the uncertainty introduced by random sampling. Each supporting RoI feature corresponds to a deterministic latent representation. .

[0086] Aggregation processing of multiple deterministic latent representations of the same category: For N deterministic latent representations under the same category (such as "yachts") This involves multi-view aggregation to generate the final aggregated feature representation. This scheme employs the fusion of three views: Mean view : Calculate the mean of all potential representations, which represents the central tendency of the category.

[0087] ; Maximum value view Take the maximum value in each dimension and retain the most significant feature response.

[0088] Take the maximum value for each element; Attention-weighted view Based on the current query RoI features (Candidate region features extracted from the query image) Calculate the attention weights for each supporting latent representation. Then, sum them up using weighted averages.

[0089] ; ; Finally, the three views are fused (e.g., added or concatenated and then passed through a linear layer) to obtain the final aggregated feature representation: ; In this embodiment, a simple addition and fusion method is used to output the aggregated feature representation. .

[0090] Suppose there are three yachts supporting RoI features, corresponding to yachts under different angles and lighting conditions. The variational encoder obtains their respective... and ,structure The mean view yields the "average" latent representation of the yacht; the maximum view captures the most prominent features among the samples (such as the hull outline); and the attention-weighted view dynamically selects and weights the most relevant supporting samples based on the features of the current query RoI. The fused view... It includes common information about categories, retains reasonable individual differences, and can also adaptively adjust according to queries.

[0091] This multi-view variational feature aggregation module introduces controllable intrinsic perturbations through a variational encoder, avoiding feature collapse caused by traditional global average pooling. The mean view ensures the stability of the class representation, the maximum view enhances the discriminative power of the features, and the attention-weighted view enables dynamic aggregation that adapts to the query. The fusion of these three elements results in aggregated feature representations with richer intra-class variance and stronger generalization ability. With a very small number of support samples, this module effectively alleviates the discriminative ambiguity caused by insufficient appearance diversity in small-sample ship detection, significantly improving the model's robustness to changes in viewpoint, lighting, and scale.

[0092] Optionally, the pre-trained target detection model is obtained through two-stage training, which includes a meta-training stage. The meta-training phase includes: Obtain a basic category dataset and divide it into a query set and a support set. Input the query set and support set into the target detection model to be trained, obtain the prediction result through forward computation, construct the total loss with the ground truth labels, and backpropagate the gradient of the total loss to jointly optimize the target detection model to be trained, thereby obtaining the meta-trained target detection model.

[0093] Optionally, the two-stage training further includes a meta-fine-tuning stage, which includes: Obtain new category samples from a small sample ship target detection dataset, and construct a support set-query set pair based on the small sample ship target detection dataset using a dynamic sampling strategy. The support set-query set pair is input into the meta-trained target detection model; The support set samples in the support set-query set pair are sequentially passed through the attention module and the multi-view variational feature aggregation module in the meta-trained target detection model to obtain temporary aggregated feature representations and temporary reconstructed support features; the multi-view variational feature aggregation module includes a variational feature encoder and a variational feature decoder. The query set samples from the support set-query set pair are passed through the backbone network of the meta-trained object detection model to obtain temporary query RoI features; the category prediction is obtained by performing dot product aggregation processing on the temporary aggregated feature representation and the temporary query RoI features. The temporary query RoI features are input into the regressor in the meta-trained object detection model to obtain bounding box predictions. The temporary reconstruction support features are input into the reconstruction prototype constraint module of the meta-trained target detection model. Based on the temporary reconstruction support features, a class prototype set is constructed and the reconstruction prototype loss is calculated. The reconstruction prototype loss is superimposed with the total loss of the meta-training stage as the total loss of the meta-fine-tuning stage. The gradient of the total loss of the meta-fine-tuning stage is backpropagated to optimize the model parameters, thereby obtaining the pre-trained target detection model.

[0094] Optionally, the step of constructing a set of class prototypes based on the temporary reconstruction support features and calculating the reconstruction prototype loss includes: Based on the temporary reconstruction support features, construct a class prototype set and determine the negative Euclidean distance between each temporary query RoI feature and each class prototype in the class prototype set; The negative log-likelihood loss is calculated by normalizing the negative Euclidean distances using the softmax function, and the reconstructed prototype loss is obtained.

[0095] Specifically, the pre-trained object detection model of this application is obtained through two-stage training, including a meta-training stage and a meta-fine-tuning stage.

[0096] First, the meta-training phase uses a large-scale basic category dataset (e.g., the trainval set of PASCAL VOC 2007+2012, containing 20 basic categories, excluding the new ship category) to enable the model to learn general object detection knowledge and meta-learning capabilities.

[0097] Specific steps: 1. Randomly sample images from the basic category dataset and divide them into query sets. and support set The support set is used to provide category references, and the query set is used to calculate the prediction loss.

[0098] 2. Input the support set and query set into the object detection model to be trained. The model structure includes an energy function-based attention module, a multi-view variational feature aggregation module (containing a variational encoder and decoder), and a reconstructed prototype constraint module.

[0099] 3. The prediction results are obtained through forward computation and compared with the ground truth annotations to construct the total loss. The total loss during the meta-training phase can be expressed as: ; in, The region proposal network loss includes RPN classification loss and bounding box regression loss; The bounding box regression loss for the detection head (Smooth L1 loss); For the classification loss (cross-entropy loss) of the detection head, use support-query aggregated features; The reconstruction loss of the variational autoencoder constrains the consistency between the reconstructed support features output by the decoder and the original support features. The divergence loss is used to make the latent distribution of the encoder output approximate the standard normal distribution N(0,I); The weighting factor for the divergence (e.g., 0.00025); For consistency loss, the reconstructed supporting features are classified to minimize their cross-entropy with the true label.

[0100] Optionally, in the meta-training phase: a stochastic gradient descent optimizer is used, combined with learning rate, momentum, and weight decay hyperparameters, to perform gradient updates on the model parameters, with the update formula being: ,in, For all trainable parameters of the model, For learning rate, Let be the gradient of the total loss with respect to the parameters; the mean accuracy mAP is calculated using the validation set at each evaluation interval to monitor convergence, and the formula for calculating mAP is: Repeat the iteration until the preset total number of training iterations is completed, and save the model weights as the meta-trained target detection model. Here, C: the total number of categories. In a small sample ship target detection task, C=10, corresponding to 10 fine-grained ship categories (sailboats, small boats, kayaks, fireboats, hovercraft, container ships, torpedo boats, ships, yachts, and submarines). : Average Precision for the c-th class, calculated by the area under the precision-recall curve for that class, used to evaluate the model's detection performance for a single class. mAP: Mean Average Precision for all classes, the arithmetic mean of the APs for each class, a standard metric for measuring the overall performance of a model in object detection tasks.

[0101] 4. Total losses Gradient backpropagation is used to jointly optimize all parameters of the model, resulting in a meta-trained object detection model.

[0102] II. Meta-fine-tuning Stage: The meta-fine-tuning stage uses new category samples from a small-sample ship target detection dataset (e.g., 10 fine-grained ship categories such as sailboats, yachts, and container ships), with only a very small number of labeled samples (K-shot, K=1,2,3,5,10) provided for each category. This stage rapidly adapts the meta-trained model to enable it to accurately detect new ship categories.

[0103] Specific steps: 1. Dynamic sampling to construct support set-query set pairs: From the ship dataset, randomly select K labeled samples for each new category as the support set. A number of samples are drawn from the remaining samples of this category to form the query set. Dynamic resampling is performed at different training cycles to increase diversity.

[0104] 2. Support set-query set pairs for training the target detection model on the input meta-data.

[0105] 3. Support Set Forward Pass: Support set samples sequentially pass through an energy function-based attention module and a multi-view variational feature aggregation module. The multi-view variational feature aggregation module includes: Variational Feature Encoder: Maps each feature supporting an RoI to the mean of a Gaussian distribution. Sum of logarithmic variance .

[0106] Sampling and Reconstruction: Sampling Latent Representations from Distributions , And input the variational feature decoder to obtain temporary reconstructed support features. .

[0107] Multi-view aggregation: Deterministic latent representation of multiple supporting samples of the same category The mean, maximum value, and attention-weighted fusion are performed to obtain a temporary aggregated feature representation.

[0108] 4. Forward pass of query set: The query set samples are passed through the backbone network (second backbone network) to obtain temporary query RoI features. .

[0109] 5. Detection Head Prediction: Combine temporary aggregated feature representation with temporary query RoI features. Perform dot product aggregation and feed it into a classifier to obtain class predictions; simultaneously, temporarily query RoI features. The bounding box predictions are obtained by feeding them into the regressor.

[0110] 6. Calculation of prototype reconstruction loss: The temporary reconstructed support features output by the variational feature decoder As class prototypes, they constitute the class prototype set. , where M is the number of reconstructed supporting features (usually equal to the number of supporting samples multiplied by the number of RoIs per sample).

[0111] For each temporary query RoI feature Calculate its relationship with each class prototype Negative Euclidean distance between them: The distance vector is normalized to a matching probability using the softmax function. ; Calculate the negative log-likelihood loss as the reconstruction prototype loss: ; in, To the number of query features, To match query features The most similar prototype index. This loss forces query features to align with the most similar class prototype, thereby enhancing discriminative power.

[0112] 7. Total Loss and Backpropagation: The total loss during the meta-fine-tuning stage is: ; in, The weighting coefficients (e.g., 0.5) are used to reconstruct the prototype loss. The gradient backpropagation is used to optimize the model parameters (especially the variational encoder / decoder, detection head, and other modules), and finally a pre-trained object detection model is obtained.

[0113] Assuming a 5-shot configuration, five yacht images from different angles are provided as the support set for the "yacht" category. During the meta-fine-tuning stage, the model generates five reconstructed support features as class prototypes through variational encoding and decoding. When a query image containing a yacht is input, the model extracts the query RoI features, calculates its negative Euclidean distance to the five yacht prototypes, and the prototype index corresponding to the highest probability after softmax is the predicted category (yacht). If the query RoI feature is closest to a certain yacht prototype, the loss is small, and the model parameters are updated in the correct direction.

[0114] This two-stage training strategy first learns general feature representations and meta-learning capabilities on a large number of basic categories through a meta-training stage, enabling the model to quickly adapt by learning how to learn. Then, in the meta-fine-tuning stage, it uses a very small number of new ship category samples and combines them with reconstructed support features generated by a variational autoencoder to construct class prototypes. The matching relationship between query features and class prototypes is explicitly constrained through the reconstructed prototype loss. This design effectively suppresses the interference of background noise and irrelevant variations while introducing controllable intra-class variance, avoiding the problems of feature collapse or overfitting in traditional fine-tuning.

[0115] Optionally, the small sample ship target detection dataset is constructed based on the PASCAL VOC data organization specification, and its directory structure includes three subdirectories: annotation file directory, image directory, and image set directory. The annotation file directory stores annotation files in XML format. The category tags in the annotation files are limited to one of the categories in the new ship category set. The new ship category set specifically includes: sailboats, small boats, kayaks, fireboats, hovercraft, container ships, torpedo boats, steamships, yachts, and submarines. The image directory stores the original JPEG images corresponding to the annotation files; The image set directory contains pre-built fixed sampling files used to select a fixed number of K target instances for each ship category under different training sample numbers K∈{1,2,3,5,10}.

[0116] In some embodiments, the small-sample ship target detection dataset is constructed strictly in accordance with the PASCAL VOC data organization specification, and its directory structure contains three core subdirectories: Annotations directory: Stores XML format annotation files corresponding to each image. Each annotation file follows the VOC standard definition and contains basic image information fields (such as image filename, width, height, and depth), as well as one or more target nodes. Each target node corresponds to a ship instance in the image, including a category label (name) and bounding box location information (bndbox, including xmin, ymin, xmax, and ymax). The category label is limited to a new set of ship categories, specifically including: sailboats, small boats, kayaks, fireboats, hovercraft, container ships, torpedo boats, steamships, yachts, and submarines. These categories are independent of the original "boat" category in PASCAL VOC, forming a new category system for fine-grained ship detection.

[0117] Image Directory (JPEGImages): Stores the original JPEG format images corresponding to the annotation files. The filenames correspond one-to-one with the XML files in the Annotations directory. Each image contains at least one instance of a ship target, whose annotation information is fully described in the corresponding XML file.

[0118] ImageSets: Specifies the image indices used for training, validation, and testing. To accommodate the small-sample fine-tuning stage, this scheme pre-constructs fixed sampling files. Specifically, for each new ship category, a fixed set of K target instances is selected from all labeled samples according to the K-shot scheme (K∈{1,2,3,5,10}), and their corresponding image IDs are written to separate text files (e.g., "1shot.txt", "2shot.txt", etc.) as pre-sampling indices for the small-sample stage. These fixed sampling files replace random sampling, ensuring consistent data partitioning across different experimental rounds, thus making comparisons between different methods fairer, more stable, and more reproducible.

[0119] This dataset is constructed based on the standardized PASCAL VOC organization specification, ensuring the uniformity and compatibility of the data structure and facilitating seamless integration with mainstream detection frameworks. By pre-constructing fixed sampling files and employing multiple settings of K∈{1,2,3,5,10}, the comparability and reproducibility of small-sample experiments are achieved, avoiding the fluctuations in results caused by random sampling. At the same time, the fine-grained set of new ship categories (10 categories) is independent of the VOC base categories, ensuring that the categories in the meta-training stage and the meta-fine-tuning stage do not overlap at all. This more realistically simulates the scenario where new ship categories constantly emerge in real-world applications, thus providing a standard and fair benchmark for evaluating the generalization ability of small-sample ship target detection algorithms.

[0120] In other embodiments, such as Figure 4As shown in the figure, this diagram illustrates the internal structure and data flow of the multi-view variational feature aggregation module in the inference phase (or the forward process of the training phase) of this application.

[0121] Detailed process instructions: 1. Input and Backbone Network: The input consists of support set samples (raw support feature maps extracted through the first backbone network) and query set samples (query feature maps extracted through the second backbone network). In the figure, "N×C×H×W" represents the dimension of the support feature map (N is the number of support samples, C is the number of channels, and H and W are the spatial dimensions).

[0122] 2. Energy Function (Attention Module Based on Energy Function): This module is located after the backbone network and performs background suppression enhancement on the original support feature map. The specific calculation process includes: calculating the spatial mean, squared bias, and channel variance of the feature map to obtain the inverse energy response, generating attention weights through a sigmoid function, multiplying them element-wise with the original feature map, and outputting the enhanced support feature map.

[0123] 3. Support descriptor extraction: Perform global spatial aggregation (e.g., global average pooling) on ​​the enhanced support feature map to obtain a vector representation of each support sample with a dimension of "N×C" (N samples, each with C dimensions).

[0124] 4. Variational encoder (Linear → BN → LeakyReLU → μ / logσ) 2 The support descriptors are mapped sequentially through a linear layer, batch normalization (BN), and a leaky rectified function (LeakyReLU) to the mean parameter μ and log-variance logσ of a latent Gaussian distribution. 2 .

[0125] 5. Reparameterization: Sample noise ε ~ N(0, I) from the standard normal distribution, and combine it with μ and σ (σ = sqrt(exp(logσ)). 2 Constructing a latent representation: This latent representation is used for subsequent decoding (generating reconstructed support features). Where μ: the mean parameter of the variational encoder output (the mean vector of the latent Gaussian distribution), logσ 2 : The logarithmic variance parameter of the variational encoder output (used to calculate the standard deviation σ) 6. Deterministic Latent Representation and Multi-View Aggregation (Mean Pooling, Max Pooling, AttentionPooling): Constructing deterministic latent representations using μ and σ. (No sampling required), used for multi-view aggregation.

[0126] Mean Pooling: Calculates the mean of the deterministic latent representations of all supporting samples in the same category to obtain a mean view.

[0127] Max Pooling: Takes the maximum value of each element to obtain a view of the maximum value.

[0128] Attention Pooling: Based on the features of the current query RoI ("query features" in the figure), attention weights are calculated, and the supporting latent representations are weighted and summed to obtain an attention-weighted view.

[0129] The three views are fused (the fusion method is not shown in the figure, but it is usually an addition or a linear transformation after splicing) to output an aggregated feature representation.

[0130] 7. Classification and Regression: Aggregate the feature representation and query RoI features by performing dot product aggregation, and feed them into the RCNN head: the classifier (not shown separately in the figure) outputs the class prediction, and the bounding box regression head (Bbox Head) outputs the bounding box position.

[0131] 8. Reconstruction Prototype Loss: The variational decoder (not shown in detail in the figure, but reconstructed from the reparameterized z through linear layers, etc.) outputs reconstructed support features, which are used to construct class prototypes. The negative Euclidean distance between the query RoI features and the class prototype is calculated, and after softmax normalization, the negative log-likelihood is taken to obtain the reconstruction prototype loss, which is used as an auxiliary loss in the meta-fine-tuning stage of training.

[0132] This figure fully presents the data flow and operation steps of the core modules of this application (energy attention + variational coding + multi-view aggregation + reconstructed prototype loss), highlighting the innovative design of enhancing intra-class variance and suppressing background interference while maintaining semantic consistency.

[0133] In other embodiments, such as Figure 5 As shown, this diagram illustrates the loss calculation and optimization process during model training. It showcases the complete training flow in the meta-fine-tuning stage, highlighting the joint optimization of variational autoencoder and multi-view aggregation, as well as the composition and backpropagation of various losses.

[0134] Detailed process instructions: 1. Supporting feature descriptors: Supporting RoI features derived from energy attention enhancement are used as input to the variational feature encoder.

[0135] 2. Variational feature encoding: The encoder outputs the mean μ and standard deviation σ (or logarithmic variance) to form a latent distribution.

[0136] 3. KL divergence: Calculate the coding distribution N(μ,σ) 2 The KL divergence between N(0,I) and the standard normal prior N(0,I) is used as the regularization term. To prevent overfitting.

[0137] 4. Variational feature sampling: The reparameterization technique z=μ+σ⊙ε is used to make the sampling process differentiable.

[0138] 5. Reconstruction Loss: Input z into the variational feature decoder, output the reconstructed support features, calculate the mean squared error with the original support feature descriptors, and obtain the reconstruction loss. This ensures that key information is preserved during encoding and decoding.

[0139] 6. Consistency Loss: Classify the reconstructed support features to ensure the classification results are consistent with the true labels in the support set, and calculate the cross-entropy loss. This ensures that the reconstructed features retain class discriminative properties.

[0140] 7. Multi-view aggregation: Construct a deterministic latent representation s=μ+σ using μ and σ, and obtain an aggregated feature representation by weighted fusion of mean, maximum and attention.

[0141] 8. Classification Loss vs. Regression Loss: The aggregated feature representation is then multiplied by the query RoI features and fed into a classifier to output the class prediction. This prediction is then compared with the true labels of the query set to calculate the cross-entropy loss. .

[0142] The RoI features are directly fed into the bounding box regression head, which outputs the bounding box offsets. These offsets are then compared with the ground truth bounding boxes in the query set to calculate the Smooth L1 loss. .

[0143] 9. Reconstructing the Prototype and the Loss of Reconstructing the Prototype: The reconstructed support features output by the variational feature decoder are used as class prototypes.

[0144] The negative Euclidean distance between the query RoI features and various prototypes is calculated, and after Softmax normalization, the negative log-likelihood is taken to obtain the prototype reconstruction loss. .

[0145] 10. Total Loss and Backpropagation: The above loss and RPN loss (not shown in the figure) are weighted and summed, and gradient backpropagation is used to optimize the model parameters.

[0146] Figure 5 Focusing on the loss composition and optimization objectives during the training phase, this paper demonstrates how KL divergence, reconstruction loss, consistency loss, classification regression loss, and reconstruction prototype loss jointly constrain the model to achieve constrained and controllable intra-class variance enhancement for new types of ship targets.

[0147] In some embodiments, the meta-learning-based few-sample ship target detection method described in this application is compared with traditional meta-learning methods such as VFA (baseline algorithm), Meta R-CNN, and Meta Faster R-CNN on a few-sample ship dataset. The results are as follows: Figure 6 As shown in the figure, the proposed algorithm exhibits superior detection performance. In particular, the mean accuracy (mAP) under different K-shot conditions (number of support samples in the small sample training setting: 1, 2, 3, 5, 10) is significantly improved compared to the baseline algorithm VFA, and outperforms the Meta R-CNN and Meta Faster R-CNN algorithms, which are also based on meta-learning. The experiments fully verify the effectiveness and practical value of the proposed method.

[0148] This invention provides a small-sample ship target detection system based on meta-learning, comprising: The acquisition unit is used to acquire the query image to be detected and the support set sample, wherein the support set sample contains at least one labeled example image of a ship target; The processing unit is used to input the query image and the support set samples into a pre-trained target detection model to obtain the category prediction result and the bounding box position prediction result of the ship target; wherein, the pre-trained target detection model includes an energy function-based attention module, a multi-view variational feature aggregation module and a reconstructed prototype constraint module.

[0149] This invention provides a small-sample ship target detection device based on meta-learning, comprising a memory and a processor; the memory is used to store a computer program; the processor is used to implement the small-sample ship target detection method based on meta-learning as described above when the computer program is executed.

[0150] This invention provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the small-sample ship target detection method based on meta-learning as described above.

[0151] While the present invention has been disclosed above, its scope of protection is not limited thereto. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention, and all such changes and modifications will fall within the scope of protection of the present invention.

Claims

1. A small-sample ship target detection method based on meta-learning, characterized in that, include: Obtain the query image to be detected and the support set sample, wherein the support set sample contains at least one labeled example image of a ship target; The query image and the support set samples are input into a pre-trained target detection model to obtain the category prediction result and bounding box position prediction result of the ship target; wherein, the pre-trained target detection model includes a first backbone network, a second backbone network, a region proposal network, an energy function-based attention module, a multi-view variational feature aggregation module, and a reconstructed prototype constraint module for the model training stage; The step of inputting the query image and the support set samples into a pre-trained target detection model to obtain the category prediction result and bounding box position prediction result of the ship target includes: The support set samples are input into the first backbone network to extract the original support feature map; the query image is input into the second backbone network to extract the query feature map. The original support feature map is input into the energy function-based attention module to obtain the enhanced support feature map; the query feature map is input into the region proposal network to generate candidate regions. The RoIAlign operation extracts query RoI features corresponding to the candidate region from the query feature map and extracts supporting RoI features from the enhanced support feature map. The RoI-supporting features are input into the multi-view variational feature aggregation module to obtain the aggregated feature representation; The aggregated feature representation is aggregated with the query RoI feature by dot product, and the aggregated feature is input into a classifier to obtain the category prediction result of the ship target; and the query RoI feature is input into a regressor to obtain the bounding box position prediction result of the ship target. The pre-trained target detection model is obtained through two-stage training, which includes a meta-training stage. The meta-training phase includes: Obtain a basic category dataset and divide it into a query set and a support set. Input the query set and support set into the target detection model to be trained, obtain the prediction result through forward computation and construct the total loss with the ground truth labels, and backpropagate the gradient of the total loss to jointly optimize the target detection model to be trained, thereby obtaining the meta-trained target detection model. The two-stage training also includes a meta-fine-tuning stage, which includes: Obtain new category samples from a small sample ship target detection dataset, and construct a support set-query set pair based on the small sample ship target detection dataset using a dynamic sampling strategy. The support set-query set pair is input into the meta-trained target detection model; The support set samples in the support set-query set pair are sequentially passed through the attention module and the multi-view variational feature aggregation module in the meta-trained target detection model to obtain temporary aggregated feature representations and temporary reconstructed support features; the multi-view variational feature aggregation module includes a variational feature encoder and a variational feature decoder. The query set samples from the support set-query set pair are passed through the backbone network of the meta-trained object detection model to obtain temporary query RoI features; the category prediction is obtained by performing dot product aggregation processing on the temporary aggregated feature representation and the temporary query RoI features. The temporary query RoI features are input into the regressor in the meta-trained object detection model to obtain bounding box predictions. The temporary reconstruction support features are input into the reconstruction prototype constraint module of the meta-trained target detection model. Based on the temporary reconstruction support features, a class prototype set is constructed and the reconstruction prototype loss is calculated. The reconstruction prototype loss is superimposed with the total loss of the meta-training stage as the total loss of the meta-fine-tuning stage. The gradient of the total loss of the meta-fine-tuning stage is backpropagated to optimize the model parameters, thereby obtaining the pre-trained target detection model.

2. The small-sample ship target detection method based on meta-learning according to claim 1, characterized in that, The step of inputting the original support feature map into the energy function-based attention module to obtain the enhanced support feature map includes: The feature map spatial mean is determined based on the original support feature map, and the squared deviation of each spatial position in the channel relative to the channel mean and the channel variance are obtained based on the feature map spatial mean. The inverse energy response is obtained based on the squared deviation of each spatial position within the channel relative to the channel mean and the channel variance. Based on the Sigmoid function, attention weights are obtained according to the inverse energy response; The attention weights are multiplied element-wise with the original support feature map to obtain the enhanced support feature map.

3. The small-sample ship target detection method based on meta-learning according to claim 1, characterized in that, The multi-view variational feature aggregation module includes a variational feature encoder; The step of inputting the RoI-supporting features into the multi-view variational feature aggregation module to obtain the aggregated feature representation includes: The RoI-supporting features are input into the variational feature encoder to obtain the mean and variance parameters of each RoI-supporting feature; Based on the mean parameter and variance parameter, a deterministic latent representation of each of the supporting RoI features is constructed; Multiple deterministic latent representations belonging to the same category are aggregated to obtain the aggregated feature representation.

4. The small-sample ship target detection method based on meta-learning according to claim 1, characterized in that, The step of constructing a set of class prototypes based on the temporary reconstruction support features and calculating the reconstruction prototype loss includes: Based on the temporary reconstruction support features, construct a class prototype set and determine the negative Euclidean distance between each temporary query RoI feature and each class prototype in the class prototype set; The negative log-likelihood loss is calculated by normalizing the negative Euclidean distances using the softmax function, and the reconstructed prototype loss is obtained.

5. The small-sample ship target detection method based on meta-learning according to claim 1, characterized in that, The first backbone network and the second backbone network share weights.

6. A small-sample ship target detection system based on meta-learning, characterized in that, The system, applied to the small-sample ship target detection method based on meta-learning as described in any one of claims 1 to 5, comprises: The acquisition unit is used to acquire the query image to be detected and the support set sample, wherein the support set sample contains at least one labeled example image of a ship target; The processing unit is configured to input the query image and the support set samples into a pre-trained target detection model to obtain the category prediction result and the bounding box position prediction result of the ship target; wherein, the pre-trained target detection model includes a first backbone network, a second backbone network, a region proposal network, an energy function-based attention module, a multi-view variational feature aggregation module, and a reconstruction prototype constraint module for the model training phase; wherein, the step of inputting the query image and the support set samples into the pre-trained target detection model to obtain the category prediction result and the bounding box position prediction result of the ship target includes: inputting the support set samples into the first backbone network to extract the original support feature map; inputting the query image into the second backbone network to extract the query image; and inputting the query image into the second backbone network to extract the original support feature map. The query feature map is input into the energy function-based attention module to obtain an enhanced support feature map. The query feature map is then input into the region proposal network to generate candidate regions. Through the RoIAlign operation, query RoI features corresponding to the candidate regions are extracted from the query feature map, and support RoI features are extracted from the enhanced support feature map. The support RoI features are input into the multi-view variational feature aggregation module to obtain an aggregated feature representation. The aggregated feature representation and the query RoI features are then subjected to a dot product aggregation. The aggregated features are input into a classifier to obtain the category prediction result of the ship target. Finally, the query RoI features are input into a regressor to obtain the bounding box position prediction result of the ship target.

7. A small-sample ship target detection device based on meta-learning, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the small-sample ship target detection method based on meta-learning as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the small-sample ship target detection method based on meta-learning as described in any one of claims 1 to 5.