A few-shot learning method and system based on detection feature map

By combining a one-stage detection network and a two-stage detection network in security visual inspection, an anchor point feature library is constructed, and training with a small number of samples and cascade confirmation are performed. This solves the problems of spatial location information loss and feature drift in existing technologies, and achieves efficient and accurate anomaly detection.

CN122200280APending Publication Date: 2026-06-12ZHUHAI RAYSHARP TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHUHAI RAYSHARP TECH
Filing Date
2026-03-12
Publication Date
2026-06-12

Smart Images

  • Figure CN122200280A_ABST
    Figure CN122200280A_ABST
Patent Text Reader

Abstract

The application provides a few-shot learning method and system based on detection feature maps, specifically comprising: S1, performing target detection on an original input image through a one-stage detection network to obtain a target bounding box, and cutting a corresponding region of interest from the original high-resolution image according to the target bounding box; S2, inputting the region of interest into a two-stage detection network, the two-stage detection network being configured to output only high-level feature maps with a step greater than or equal to a preset threshold, and discard feature layers with a step less than the preset threshold; S3, constructing an anchor feature library; S4, performing few-shot training; and S5, performing inference and discrimination. The application effectively retains the spatial position information of the target in few-shot learning, improves the fine-grained discrimination ability and recognition accuracy, suppresses the feature space drift caused by the scarcity of training samples, improves the model robustness, and realizes the cooperation of the general target detection ability and the rapid self-adaptation of the user scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision technology, and in particular to a few-sample detection method and system based on detection feature maps for application in intelligent security detection. Background Technology

[0002] Currently, the field of scenario-based security visual inspection faces the challenge of scarce labeled data, making few-shot learning the mainstream technical approach. Existing mainstream few-shot learning methods typically employ the following process: First, a target detection model (such as YOLO) is used to locate the region of interest (ROI) in the image; then, the cropped ROI is scaled to a fixed size (such as 224×224 pixels) and input into a classification network (such as ResNet or EfficientNet) pre-trained on large datasets like ImageNet to extract global features; finally, a fully connected layer is added on top of this classification network, and the entire network is fine-tuned using a small number of user-labeled samples. During inference, the output of this classifier is used alone to determine whether the target is abnormal.

[0003] However, the aforementioned prior art has the following significant drawbacks: (1) Loss of spatial location information: Classification networks typically employ global average pooling in the final stage, compressing feature maps with spatial dimensions (H×W×C) into one-dimensional vectors (1×1×C). This process results in the complete loss of key spatial structural information such as the relative positions and layouts of the internal structures of the target. Therefore, this method cannot effectively utilize the structural information of the target, such as the topological connections and pose geometry of key points in the human skeleton, and the relative positional relationships between the main body of the vehicle and components such as wheels and windows. Typical methods, including ResNet-based linear probing or prototypical networks, all suffer from this problem.

[0004] (2) Inconsistency between features and detection task: The classification network is pre-trained on ImageNet, and the features it extracts are biased towards texture and material discrimination. However, security few-shot detection is often strongly correlated with people and vehicles, as well as outdoor monitoring scenarios. There is a significant domain gap between the pre-trained features and the actual detection task, which affects the accuracy of anomaly detection.

[0005] (3) Fine-tuning with few samples can easily lead to feature drift: When users provide very few samples for new categories, fine-tuning the entire network can easily cause a sharp shift in the feature space, misjudging normal production variations as abnormalities, resulting in a serious decline in the model's generalization ability.

[0006] Therefore, there is an urgent need for a few-shot learning method and system that can preserve spatial location information, resist feature drift, and adapt to security scenarios. Summary of the Invention

[0007] The purpose of this invention is to address the shortcomings of the prior art by providing a few-shot learning method and system based on detection feature maps. The main technical problems solved by this invention include: (1) How to effectively preserve the spatial location information of the target in few-sample learning in order to improve fine-grained discrimination ability and recognition accuracy; (2) How to optimize the network structure to adapt to high-resolution ROIs with large targets and avoid redundant computation; (3) How to suppress feature space drift caused by scarce training samples and improve model robustness; (4) How to achieve the synergy between general target detection capabilities and rapid adaptation to user scenarios.

[0008] To achieve the above technical solution, this invention provides a few-shot learning method based on detection feature maps, specifically including the following steps: S1. Target detection is performed on the original input image through a one-stage detection network to obtain the target bounding box, and the corresponding region of interest (ROI) is cropped from the original high-resolution image based on the target bounding box. S2. Input the region of interest (ROI) into a two-stage detection network. The two-stage detection network is configured to output only high-level feature maps with a stride greater than or equal to a preset threshold, and discard feature layers with a stride less than the preset threshold. S3. Construct an anchor point feature library, which consists of high-level feature maps extracted after a large number of normal sample images are input into the two-stage detection network, and multiple feature cluster centers generated by a clustering algorithm. S4. Perform few-sample training by inputting the high-level feature map into the fine-tunable fully connected layer and using a small amount of labeled sample data provided by the user and anchor features in the anchor feature library as training data to update the weight parameters of the fully connected layer. S5. Perform reasoning and discrimination. In the detection phase, combine the detection results of the two-stage detection network with the output classification results of the fully connected layer for cascaded confirmation to complete anomaly identification.

[0009] In the above technical solution, this invention establishes a "detection + detection feature reuse" architecture through steps S1 and S2, which differs from the "detection + classification network" architecture in existing technologies. This invention directly utilizes the high-level feature maps of the detection network for few-shot learning, avoiding the loss of spatial location information caused by global average pooling (GAP) in traditional classification networks, enabling the model to perceive the internal structural layout of the target. Through steps S3 and S4, an "anchor feature library" is introduced to participate in training. Utilizing the feature centers of a large number of historical normal samples to constrain the few-shot fine-tuning process effectively prevents drastic shifts in the feature space caused by a very small number of new category samples, reducing the false alarm rate of misclassifying normal variations as abnormalities. Furthermore, through the cascaded confirmation mechanism in step S5, the system retains both general detection capabilities and rapid adaptation capabilities to user scenarios, without needing to retrain the entire backbone network, significantly reducing computational resource consumption.

[0010] Preferably, in step S2, the preset threshold for the stride is 32. The two-stage detection network is based on the YOLO architecture and originally outputs three feature layers with strides of 8, 16, and 32. In step S2, only the feature layer with stride of 32 is retained as output, and the output feature map size is 8×8×C, where C is the number of channels. Considering that the ROI image after cropping in step S1 is usually dominated by the target (large target), discarding the fine-grained feature layers with strides of 8 and 16 and retaining only the high-level semantic features with stride of 32 reduces the feature map computation and memory usage by 2 / 3, making it very suitable for deployment in security scenarios.

[0011] Preferably, in step S2, the high-level feature map retains its spatial grid structure and is not compressed using global average pooling. Many few-shot classification methods (such as prototype-based networks) often use global average pooling (GAP) to compress the feature map into a vector, which loses the location information of the defect. This scheme explicitly specifies "no global average pooling compression," preserving the spatial grid structure (e.g., 8x8) of the high-level feature map. This means that subsequent fully connected layers can perceive the spatial distribution of features during classification, such as whether the scratch is horizontal or vertical, or whether the stain is in the upper left corner or the center. This feature with spatial information is crucial for distinguishing anomalies with similar shapes.

[0012] Preferably, step S2 further includes a positive sample expansion step: in addition to considering prior boxes inside the ground truth bounding boxes as positive samples, prior boxes within a preset distance from the ground truth bounding box boundary, or the Top K prior boxes closest to the center point of the ground truth bounding box boundary, are also included in the positive sample set. In object detection, if the definition of "boxes inside the bounding box are prior boxes" is strictly followed, prior boxes located near the object boundary are often labeled as negative samples due to insufficient IoU calculation, resulting in insufficient feature learning of edge areas by the model. By introducing "within a preset distance from the boundary" or "Top K closest to the center point" as a positive sample expansion strategy, it is actually a soft label assignment. This allows the model to better learn the complete outline of the object, especially for objects that only partially reveal themselves or extremely small defects. This method of expanding positive samples can effectively improve the recall rate.

[0013] Preferably, in step S3, the anchor features are used to constrain the feature space during few-shot training, preventing feature drift caused by the scarcity of training samples. The specific process of constructing the anchor feature library includes: selecting normal sample images from the pre-training stage as the data source and inputting them into the network to extract the high-level feature maps; using the K-means clustering algorithm to cluster the extracted features, and selecting K feature cluster centers as anchor features, where K is a preset positive integer. By introducing an "anchor feature library" formed by pre-clustering a large number of normal samples, the anchor features play a role in regularization or feature space constraint when training newly added fully connected layers, preventing unreasonable distortion of the entire feature space due to the guidance of a small number of abnormal samples. This greatly improves the stability of few-shot learning and the robustness of the final model.

[0014] Preferably, in step S4, the training data comprises two parts: few-sample data of the user scenario and data from the anchor feature library. The specific process of few-sample training includes: S41. Freeze the backbone parameters of the two-stage detection network and train only the newly added fully connected layers; S42. Preprocess user scene data, including left and right flipping, translation, and perturbation operations such as adding or removing certain values ​​of the feature dimension layer. S43. Use stochastic gradient descent as the optimizer, use the cross-entropy loss function, obtain the classification prediction value through forward propagation, calculate the loss by combining the label information, and update the weight parameters of the fully connected layer through back propagation.

[0015] By freezing the backbone and training only fully connected layers (FC), the number of parameters is reduced by more than 99%, enabling minute-level adaptation to new scenarios on an embedded NPU. The addition of a "perturbation operation on the feature dimension layer" simulates sample diversity at the feature space level, further preventing overfitting with few samples and improving the model's robustness to unseen normal samples.

[0016] Preferably, in step S5, the specific process of reasoning and discrimination includes: S51. Use a two-stage detection network to perform target detection on the cropped image; S52. Use the high-level feature map output by the two-stage network to input into the trained fully connected layer to obtain the classification result; S53. If the classification result of the fully connected layer is determined to be a specific category of the user scenario, then the original detection category of the two-stage detection network is corrected, and the final judgment result is output.

[0017] The "cascaded confirmation" mechanism (S53) in the inference phase serves as a double safeguard. Even if the first-stage network falsely detects an object, subsequent fine-grained classification layers may correct it to a "non-target category"; conversely, if the first-stage network detects correctly, the classification layer can further confirm its specific anomaly type. This design significantly reduces both false positives and false negatives.

[0018] This invention also provides a few-shot anomaly detection system based on detection feature maps, used to implement the aforementioned few-shot learning method based on detection feature maps, the system comprising: The region cropping module is used to perform target detection on the original input image through a one-stage detection network, obtain the target bounding box, and crop out the corresponding region of interest (ROI). The feature extraction module is used to input the region of interest (ROI) into the two-stage detection network and output only high-level feature maps with a step size greater than or equal to a preset threshold. Anchor point construction module is used to generate an anchor point feature library by clustering high-level feature maps extracted from a large number of normal sample images; The model training module is used to input the high-level feature map into the fine-tunable fully connected layer, and use a small amount of labeled sample data provided by the user and the anchor point features as training data to perform few-sample training on the fully connected layer. The inference and discrimination module is used to combine the detection results of the two-stage detection network with the output classification results of the fully connected layer for cascaded confirmation, thereby completing anomaly identification.

[0019] The beneficial effects of the few-shot learning method and system based on detection feature maps provided by this invention are as follows: (1) This invention uses the spatial feature map of the detection network instead of the global pooling feature of the classification network for few-sample learning, which effectively preserves the internal structure and relative position information of the target, effectively identifies position-sensitive anomalies such as offset, missing, and misalignment, and significantly improves fine-grained discrimination ability and recognition accuracy.

[0020] (2) This invention targets large target ROIs, and by discarding low-level feature maps, it reduces computational redundancy, makes the extracted features more focused on high-level semantics, and improves processing efficiency.

[0021] (3) By introducing an anchor point feature library generated by clustering a large number of normal samples, the present invention constrains the fine-tuning process of a small number of samples, effectively suppresses feature space drift and reduces false alarm rate.

[0022] (4) The present invention realizes the end-to-end integrated design of "detection-discrimination", without the need to deploy an independent classification model, and the system is simple and efficient.

[0023] (5) The present invention only requires fine-tuning of the fully connected layer with a very small number of parameters to achieve rapid adaptation of user scenarios. It has low computational overhead and is very suitable for deployment on resource-constrained security edge devices. Attached Figure Description

[0024] Figure 1 This is a flowchart of the steps of the present invention.

[0025] Figure 2 This is a schematic diagram of feature layer selection in a two-stage detection network according to an embodiment of the present invention.

[0026] Figure 3 This is a schematic diagram illustrating the selection of positive sample Anchors during the training phase in an embodiment of the present invention.

[0027] Figure 4 This is a schematic diagram of the reasoning and discrimination process in an embodiment of the present invention. Detailed Implementation

[0028] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art without creative effort are within the protection scope of the present invention.

[0029] Example 1: A few-shot learning method based on detection feature maps.

[0030] Reference Figures 1 to 4 As shown, the present invention provides a few-shot learning method based on detection feature maps, which mainly includes two-stage detection network construction and training, anchor feature data construction, few-shot training and inference.

[0031] (I) Two-stage detection network construction and training The process first uses a one-stage detection network (such as YOLO) to detect objects in the original image, obtaining object bounding boxes. These bounding boxes are then mapped back to the original high-resolution image, and the corresponding regions of interest (ROIs) are cropped for a second-stage detection and judgment. The main focus of few-shot fine-tuning is on feature acquisition and training of the second-stage network.

[0032] Network Construction and Optimization: The main target in the image extracted through the process described above occupies most of the image in the second-stage inference. The standard YOLO network outputs three feature layers with different strides (stride=8, 16, 32), used for small, medium, and large target detection, respectively. Given that the second-stage input ROI occupies the main part of the image and is a typical large target, this invention only retains the high-level feature layer with stride=32, discarding the feature outputs with stride=8 and 16. The process is as follows... Figure 2 As shown, the input image has a pixel size of 256×256. The output removes features with spans of 8 and 16, retaining only the feature with a span of 32. The model outputs a feature size of 8×8. This pruning operation significantly reduces computation (reducing feature map computation and memory usage by 2 / 3) and allows the network to focus more on extracting the global semantic and structural information of the target.

[0033] Positive Sample Expansion During Training: When training this two-stage detection network, the low resolution (8×8) of the feature map with a stride of 32 results in a small number of anchors falling within the ground truth bounding boxes (GT Boxes), potentially leading to extreme imbalance between positive and negative samples and sparse gradient updates. To address this issue, such as... Figure 3 As shown, this embodiment employs a positive sample anchor expansion strategy. Specifically, in addition to considering anchors inside the ground truth box (GT box) as positive samples, anchors within a preset distance near the GT boundary are also included in the positive sample set to alleviate the sparsity problem of small-scale target backward gradients caused by stride=32. Specifically, the topk anchors closest to the center point of the GT box are selected as supplementary anchor points for training, which effectively increases the number of positive samples and ensures the sufficiency of model training. The training data is obtained by matting and organizing the data from the first-stage training to maintain a similar domain space to the actual application scenario. A size of 256 is used for training, consistent with the size of the first-stage matting and inference. Furthermore, mosaic preprocessing is not used during training preprocessing to prevent mosaic effects from easily causing target segmentation when training the detection network at such a small size.

[0034] Few-shot Feature Layer Selection: This invention abandons the 1×1×C global feature vector compressed by global average pooling (GAP) in traditional classification networks, and instead uses the high-level feature map output by the two-stage detection network before final classification (the 8×8×C feature map corresponding to stride=32 in the YOLO architecture) as the input feature for few-shot learning. The advantage of using this feature layer is that, firstly, it is the original feature of the subsequent classification layer and the direct basis for left and right detection, so it has a certain degree of classification ability. Secondly, since the grid feature output by YOLO itself also has positional information, describing the relative position of the internal information of the detected target structure, and since the ROI has already been cropped into an image with the target as the main body through the first-stage detection, the 8×8 grid with stride=32 is sufficient to cover the main structural units of the target, eliminating the need for interference from higher-resolution small target feature layers.

[0035] (II) Construction of Anchor Point Feature Data During few-shot training, the increased number of training samples may lead to better classification of the added samples, but incorrect classification of categories that haven't been added due to the lack of features for those categories during training. Therefore, this invention introduces an anchor feature. The anchor feature participates in training along with the few samples to be fine-tuned, preventing feature drift in the trained network caused by only adding a few samples, thus avoiding false positives.

[0036] The anchor feature is first selected from the images used to train the detection network, which are then input into the network to extract the features described in step (I) above. Too much feature data is detrimental to subsequent fine-tuning training, and in practical applications, too much data leads to long training times and consumes a lot of memory. Here, the k-means algorithm is used to extract the feature family centers of these features, and these family centers are selected to represent this broad category of features as anchor features.

[0037] In practice, approximately 500,000 sample images covering various normal production conditions are selected and input into the two-stage detection network trained in step (I). An 8×8×C dimensional feature map with a stride of 32 is extracted as the original features. Due to the massive amount of original feature data, it cannot be directly used for subsequent joint training. This embodiment employs the K-Means clustering algorithm to cluster these massive features into K=1000 categories, resulting in 1000 cluster center vectors. These 1000 cluster centers are the "anchor features," representing the feature distribution space of a wide range of normal samples. They constitute a prior knowledge base used to constrain the learning direction of the model in subsequent steps.

[0038] (iii) Training and extrapolation with few samples The main process involves importing a small number of samples for the user, combining them with pre-defined anchor feature data, and then training the detection network by adding a fully connected layer after the feature layer output by the detection network. The deductive process is as follows: when a target is detected, the detection network extracts features, which are then combined with the trained fully connected layer to determine whether it belongs to this category of targets with few samples.

[0039] Few-shot training: The few-shot training process mainly involves adding a fully connected layer to the feature layer output by the previous detection network. This fully connected layer, with its smaller parameters, is then fine-tuned to achieve the learning process. The training data consists of two parts: anchor feature data and user scene data. After users upload scene data, the NPU in the embedded device executes the previous detection network to extract user feature data. The user data undergoes certain preprocessing operations, including left and right flipping and a small amount of translation, to increase the diversity of the user scene image data.

[0040] The training network mainly consists of fully connected layers, an optimizer, and a loss function. The fully connected layers have an n×m dimension, where n is the input feature dimension and m is the output classification dimension. The optimizer uses stochastic gradient descent, and the loss function here uses cross-entropy loss for classification.

[0041] The training process includes data collection and integration. To increase data diversity and generalization ability, the selected feature data undergoes a certain degree of perturbation, randomly increasing or decreasing certain values ​​in some feature dimensions. This data is then input into the forward propagation code of the fully connected layer to obtain classification predictions. The loss function is calculated using the classification predictions and label information, followed by backpropagation to update the weight parameters of the fully connected layer. This process is repeated until the fully connected layer achieves good classification ability. The basic parameters used here include a batch size of 32 per training session, a total of 200 training iterations, and an initial learning rate of 0.01.

[0042] The deduction process: Through the few-shot training process described above, a set of fully connected layer parameters can be obtained. These parameters, combined with the feature layer output by the detection network, can effectively classify samples. The deduction process involves two stages. First, the extracted image is used to determine if the target belongs to the desired category using the detection network. Simultaneously, features obtained from the third branch of the second-stage network (feature layer) are input into the few-shot network (fully connected layer) to obtain the classification result. If the classification result identifies the user scene category, the previously detected category is corrected to achieve adaptive learning of customer scene data.

[0043] The specific deduction process is as follows: Figure 4As shown, the image to be detected first undergoes a first-stage detection network to locate and crop the Region of Interest (ROI). The cropped ROI is then input into a second-stage detection network. At this point, the network outputs two results in parallel: (1) Conventional detection results: from the original detection head of the two-stage network, the coarse-grained category and confidence level of the target are given.

[0044] (2) Few-sample discrimination result: from the fully connected layer trained in step 3, connected after the feature layer with a stride of 32. This result accurately determines whether the target belongs to the specific category newly adapted by the user.

[0045] Ultimately, the system employs a cascading confirmation strategy: if the few-sample discrimination result identifies the user as belonging to a "user category," that result is adopted, and the category of the regular detection result can be corrected; otherwise, the regular detection result is used. This mechanism achieves a perfect combination of general detection capabilities and specific user needs.

[0046] This invention employs a two-stage detection network with a stride=32 high-level feature map as fine-tuning input. This feature map has an H×W spatial grid structure, which can preserve the relative positional relationships of internal components of the target, effectively identifying position-sensitive anomalies such as offsets, missing parts, and misalignments, significantly improving fine-grained discrimination ability and recognition accuracy. Considering that ROIs are often large targets, this invention discards the small / medium target feature layers with stride=8 and stride=16, retaining only the stride=32 feature output, avoiding interference from irrelevant scale features and making semantic features more focused.

[0047] This invention generates K anchor features (e.g., K=1000) based on clustering a large number of normal samples, constraining the feature space to not deviate from the normal distribution, significantly improving the model's robustness to normal variations, greatly reducing sample feature drift, and lowering the false alarm rate. Moreover, this invention reuses the detection network to extract discriminative features, eliminating the need to deploy an additional independent classification model, and realizing an integrated "detection-discrimination" architecture.

[0048] In practical applications, this invention only requires fine-tuning of the fully connected layer with a very small number of parameters (parameter percentage <1%) to achieve rapid adaptation to user scenarios. It has low computational overhead and can meet the low-resource and high-efficiency requirements of security detection sites. It is very suitable for deployment on resource-constrained security edge devices.

[0049] Example 2: A few-shot learning system based on detection feature maps.

[0050] A few-shot learning system based on detection feature maps specifically includes: a region cropping module for performing the ROI acquisition step in the above method; a feature extraction module for performing the two-stage feature extraction step in the above method; an anchor point construction module for performing the anchor point feature library construction step in the above method; a model training module for performing the few-shot fine-tuning step in the above method; and an inference and discrimination module for performing the cascaded discrimination step in the above method.

[0051] This system can implement the method described in Embodiment 1 above and has corresponding beneficial effects.

[0052] The above description is only a preferred embodiment of the present invention, but the present invention should not be limited to the content disclosed in the embodiments and drawings. Therefore, any equivalent or modified embodiments made without departing from the spirit of the present invention shall fall within the protection scope of the present invention.

Claims

1. A few-shot learning method based on detection feature maps, characterized in that, Specifically, the steps include the following: S1. Target detection is performed on the original input image through a one-stage detection network to obtain the target bounding box, and the corresponding region of interest (ROI) is cropped from the original high-resolution image based on the target bounding box. S2. Input the region of interest (ROI) into a two-stage detection network. The two-stage detection network is configured to output only high-level feature maps with a stride greater than or equal to a preset threshold, and discard feature layers with a stride less than the preset threshold. S3. Construct an anchor point feature library, which consists of high-level feature maps extracted after a large number of normal sample images are input into the two-stage detection network, and multiple feature cluster centers generated by a clustering algorithm. S4. Perform few-sample training by inputting the high-level feature map into the fine-tunable fully connected layer and using a small amount of labeled sample data provided by the user and anchor features in the anchor feature library as training data to update the weight parameters of the fully connected layer. S5. Perform reasoning and discrimination. In the detection phase, combine the detection results of the two-stage detection network with the output classification results of the fully connected layer for cascaded confirmation to complete anomaly identification.

2. The few-shot learning method based on detection feature maps as described in claim 1, characterized in that, In step S2, the preset threshold for the stride is 32. The two-stage detection network is based on the YOLO architecture. Originally, it output three feature layers with stride=8, 16, and 32. In step S2, only the feature layer with stride=32 is retained as the output. The size of the output feature map is 8×8×C, where C is the number of channels.

3. The few-shot learning method based on detection feature maps as described in claim 1, characterized in that, In step S2, the high-level feature map retains the spatial grid structure and is not compressed using global average pooling.

4. The few-shot learning method based on detection feature maps as described in claim 1, characterized in that, In step S2, a positive sample expansion step is also included: in addition to considering the prior boxes inside the real box as positive samples, the prior boxes within a preset distance from the boundary of the real box, or the Top K prior boxes closest to the center point of the boundary box of the real box, are also included in the positive sample set.

5. The few-shot learning method based on detection feature maps as described in claim 1, characterized in that, In step S3, the anchor features are used to constrain the feature space during training with few samples, preventing feature drift caused by the scarcity of training samples. The specific process of constructing the anchor feature library includes: selecting normal sample images from the pre-training stage as the data source and inputting them into the network to extract the high-level feature map; using the K-means clustering algorithm to cluster the extracted features and selecting K feature cluster centers as anchor features, where K is a preset positive integer.

6. The few-shot learning method based on detection feature maps as described in claim 1, characterized in that, In step S4, the training data consists of two parts: few-shot data of user scenarios and data from the anchor feature library. The specific process of few-shot training includes: S41. Freeze the backbone parameters of the two-stage detection network and train only the newly added fully connected layers; S42. Preprocess user scene data, including left and right flipping, translation, and perturbation operations such as adding or removing certain values ​​of the feature dimension layer. S43. Use stochastic gradient descent as the optimizer, use the cross-entropy loss function, obtain the classification prediction value through forward propagation, calculate the loss by combining the label information, and update the weight parameters of the fully connected layer through back propagation.

7. The few-shot learning method based on detection feature maps as described in claim 1, characterized in that, In step S5, the specific process of reasoning and discrimination includes: S51. Use a two-stage detection network to perform target detection on the cropped image; S52. Use the high-level feature map output by the two-stage network to input into the trained fully connected layer to obtain the classification result; S53. If the classification result of the fully connected layer is determined to be a specific category of the user scenario, then the original detection category of the two-stage detection network is corrected, and the final judgment result is output.

8. A few-sample anomaly detection system based on detection feature maps, characterized in that, The system for implementing the method according to any one of claims 1 to 7, the system comprising: The region cropping module is used to perform target detection on the original input image through a one-stage detection network, obtain the target bounding box, and crop out the corresponding region of interest (ROI). The feature extraction module is used to input the region of interest (ROI) into the two-stage detection network and output only high-level feature maps with a step size greater than or equal to a preset threshold. Anchor point construction module is used to generate an anchor point feature library by clustering high-level feature maps extracted from a large number of normal sample images; The model training module is used to input the high-level feature map into the fine-tunable fully connected layer, and use a small amount of labeled sample data provided by the user and the anchor point features as training data to perform few-sample training on the fully connected layer. The inference and discrimination module is used to combine the detection results of the two-stage detection network with the output classification results of the fully connected layer for cascaded confirmation, thereby completing anomaly identification.