A class-independent target counting method based on the prompt-extraction paradigm

By jointly inputting queries and example images in the backbone network, and dynamically generating confidence thresholds and iterative optimizations, the problem of insufficient distinguishing ability of existing class-independent counting methods in multi-class scenarios is solved. This achieves high-precision and low-computational-cost target counting, and is suitable for complex multi-class scenarios.

CN120088617BActive Publication Date: 2025-11-14SICHUAN UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510198615.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-23
Publication Date
2025-11-14
Estimated Expiration
2045-02-23

AI Technical Summary

Technical Problem

Existing class-independent counting methods cannot effectively distinguish objects similar to examples in multi-class scenarios. They are highly dependent on the ViT structure and manual threshold settings, resulting in insufficient counting accuracy and robustness in complex scenarios.

Method used

We adopt a prompt-extraction paradigm-based approach, which combines the input query image and example image in the backbone network, extracts joint features using ResNet34 and U-Net structures, dynamically generates class-specific confidence thresholds, and designs a loss function by combining dynamic thresholds and iterative optimization strategies to improve model performance.

Benefits of technology

It significantly improves the target discrimination ability and generalization performance in complex scenarios, reduces MAE error, and improves the counting accuracy and stability of the model in multi-class scenarios. In particular, it outperforms existing methods on the FSC-147 and CARPK datasets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120088617B_ABST
    Figure CN120088617B_ABST
Patent Text Reader

Abstract

This invention discloses a class-independent target counting method based on a cue-extraction paradigm, belonging to the field of computer vision processing technology. The method first defines a cue-extraction paradigm, constructs a class-independent target counting and localization process based on this paradigm, then builds a pure CNN model PBECount, generating a probability map through an encoder-decoder structure; a dynamic threshold module is designed to automatically predict the optimal confidence threshold based on input data to filter candidate targets; a peak-aware mean squared error loss function is proposed to enhance the model's sensitivity to target region errors; and combined with iterative optimization and post-processing strategies, the counting accuracy in dense scenes is further improved. This method is applicable to target counting in complex multi-class scenes, featuring high accuracy, low computational cost, and wide applicability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer vision processing technology, specifically relating to a class-independent target counting method based on the cue-extraction paradigm. Background Technology

[0002] In the field of computer vision, accurate object counting in images is a core task, widely used in various practical scenarios such as traffic monitoring, retail analysis, and ecological protection. With the rapid development of deep learning technology, researchers have proposed a variety of technical approaches to solve the object counting problem, including methods based on density estimation, object detection, and feature matching.

[0003] Traditional object counting methods typically rely on density estimation or object detection, which require large amounts of labeled data and are often trained on classes. These class-specific methods perform poorly in counting objects of unknown classes, limiting their applicability in diverse scenarios. To overcome this problem, researchers have proposed the concept of Class-Agnostic Counting (CAC). Unlike Class-Specific Counting (CSC), CAC transforms the counting task into a feature matching problem, thus avoiding dependence on large-scale class-specific datasets.

[0004] The concept of CAC (Collective Object Counting) was first proposed by Lu, Xie, and Zisserman (2019). Its core idea is to compare the similarity of objects in a query image with a given example to complete the counting. This method provides a new approach to cross-category object counting. Subsequently, Ranjan et al. (2021) proposed the FSC-147 dataset, which has become an important benchmark in the field of CAC and has promoted the development of this research direction.

[0005] In practical implementation, the CAC method based on the extraction-matching paradigm is the most common research path. These methods are generally divided into two categories: The first category is single feature extraction and matching methods, which extract global features from the query image, then crop example features, and calculate the similarity between the two to complete the counting (Ranjan et al., 2021; Gong et al., 2022; Linet et al., 2022). The second category is separate feature extraction and matching methods, which extract features from the query image and the examples separately, and then determine the number of objects by calculating the similarity between the two (Yang et al., 2021; Shi et al., 2022; Liu et al., 2022).

[0006] While the extract-match paradigm of CAC methods improves counting accuracy, its classification performance in multi-class scenarios remains insufficient. Many methods prioritize counting all possible objects in an image rather than focusing on target objects similar to examples, thus performing poorly in complex scenes. To address these issues, researchers have proposed a more refined two-stage approach.

[0007] For example, Xu, Le, and Samaras (2023) proposed a two-stage method to refine predicted regions through a segmentation network. This method generates segmentation masks for example-similar regions, which are used to filter out non-example regions in the predicted density map, thereby improving classification performance. However, this method relies on manually set segmentation rules and cannot achieve end-to-end optimization. Another approach is the detection-verification paradigm proposed by Pelhan et al. (2024). In this method, non-maximum suppression is first applied to the predicted density map to locate the target object, and then non-example-similar objects are filtered out by calculating the cosine similarity between the example and the target object. This method also relies on manually designed thresholds and background information, limiting its robustness in multiple scenarios.

[0008] Furthermore, Wang et al. (2024) introduced an end-to-end extraction-matching method based on the Vision Transformer (ViT). This method crops and concatenates the query image and the example, then inputs it into the ViT model, utilizing an attention mechanism to simultaneously perform feature extraction and matching. This method greatly simplifies the operational process, but its high dependence on the ViT structure causes the model's filtering ability to decrease when encountering interfering categories, affecting the stability of the counting results. Summary of the Invention

[0009] The purpose of this invention is to provide a class-independent object counting method based on the cue-extraction paradigm, aiming to solve the problem that existing class-independent counting methods cannot effectively distinguish objects similar to examples in multi-class scenarios. This technology solves the problems of high dependence on VIT structure, specific training data, and manual threshold settings in existing class-independent counting tasks. It is suitable for object counting in complex multi-class scenarios and has high accuracy, low computational cost, and wide applicability.

[0010] The embodiments of the present invention are implemented as follows:

[0011] The present invention provides a class-independent target counting method based on the cue-extraction paradigm, comprising the following steps:

[0012] S1: Define hints - extract paradigms, and construct class-independent target counting and location based on the paradigms;

[0013] S2: Preprocess the input data and build a pure CNN model PBECount. First, obtain the query image and the example image. Convert the example image into an example probability map. Then, create an all-zero matrix of the same size as the query image. Generate a Gaussian kernel for each example in the matrix. Set the peak value of the Gaussian kernel to 1 and keep the position and size of the example. Finally, concatenate the generated example probability map with the query image of size (3, H, W) in the channel dimension to form four-channel input data of (4, H, W).

[0014] S3: Construct a network structure for feature extraction, using ResNet34 as the backbone network. Input the concatenated data into the backbone network for feature extraction, and extract the joint features of the query image and the example image through a U-Net network model.

[0015] S4: Automatically predict the optimal threshold through the network and dynamically generate category-specific confidence thresholds;

[0016] S5: Target localization and counting. Non-maximum suppression is performed on the generated probability map to obtain candidate targets. Dynamic threshold scores are used to filter the candidate targets to obtain the target counting results during the training phase.

[0017] S6: Design a loss function to improve model performance;

[0018] S7: Model Training and Optimization;

[0019] S8: Reasoning and post-processing to obtain the final target count result.

[0020] Furthermore, in step S1, the hint-extraction paradigm definition method is as follows:

[0021] S11: Provide examples before feeding the query image into the backbone network, and jointly extract features from the merged query image and examples;

[0022] S12: The normal form is represented as: C = D(B(i),e), where i represents the query image, e represents the example, B represents the backbone network, D represents the decoder, and C represents the counting result;

[0023] Furthermore, in step S3, the post-processing of the joint feature extraction is as follows:

[0024] S31: Input the joint features of the query image and the example image into the mapping module and the counting module;

[0025] S32: In the mapping module, a probability map of the prediction is generated through convolutional layers;

[0026] S33: In the counting module, dynamic threshold scores are generated through convolutional layers and fully connected layers.

[0027] Furthermore, in step S4, the dynamic threshold is calculated as follows:

[0028] S41: In the counting module, dynamic threshold scores are generated through convolutional layers and fully connected layers;

[0029] S42: During training, the true threshold score Sgt is dynamically calculated based on the number of candidate targets Ccan and the number of true targets Cgt.

[0030] When Ccan≤Cgt, Sgt is half of the lowest confidence value of the candidate object;

[0031] When Ccan > Cgt, take the average confidence score of the Cgt-th and (Cgt+1)-th objects.

[0032] Furthermore, in step S6, two loss functions were designed, specifically:

[0033] S61: Use binary cross-entropy loss to calculate the loss between the predicted threshold score and the true threshold score of the counting module;

[0034] S62: Calculate the loss between the predicted probability map and the true probability map of the mapping module using peak-aware mean squared error loss;

[0035] S63: The weighted sum of the two loss functions is used as the total loss of the model.

[0036] Furthermore, the model training and optimization steps in step S7 include:

[0037] S71: The model is trained using the AdamW optimizer, and the learning rate is adjusted using a cosine annealing strategy;

[0038] S72: During training, use data augmentation methods to improve the model's generalization ability;

[0039] S73: During training, use a probability map as the model's true label to ensure that the model can accurately identify similar targets in the examples.

[0040] Furthermore, in step S8, the model inference and post-processing steps are as follows:

[0041] S81: During the inference phase, dynamic threshold scores are used to filter the probability graph to obtain the final target counting result;

[0042] S82: Use a loop optimization method to optimize images containing multiple categories. First, calculate the distance of each target to the nearest example. Then, add the target with the farthest distance to the example set and rerun the model. Finally, repeat the above steps until the counting results no longer change.

[0043] S83: Normalize the counting results to obtain the final target counting result.

[0044] The beneficial effects of this invention are as follows:

[0045] (1) A "hint-extraction" paradigm is proposed, which uses examples as prior information and inputs them together with the query image into the backbone network. This breaks through the feature decoupling limitations of the traditional "extract-then-match" paradigm, avoids the dependency on the ViT architecture, and achieves efficient computation of pure CNN. The hint-extraction paradigm effectively solves the problem of weakened target category features in existing methods and greatly improves the target discrimination ability in complex scenes.

[0046] (2) By dynamically predicting the threshold using the score head, the problem of poor generalization of manual thresholds in probabilistic graph detection is solved. On the FSC-147 dataset, the MAE error is reduced by approximately 16.31% compared to the static threshold method.

[0047] (3) Combining loop optimization and normalization strategies, the MAE is reduced by approximately 24.46% compared to the best existing method in the CARPK cross-dataset test, significantly improving the generalization performance of complex multi-class scenarios. Attached Figure Description

[0048] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained from these drawings without creative effort.

[0049] Figure 1 This is a schematic diagram illustrating the counting performance of PBECount in images with different target densities according to the present invention;

[0050] Figure 2 This is a schematic diagram illustrating the detection results of the extraction-matching paradigm model and the hint-extraction paradigm model. Detailed Implementation

[0051] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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.

[0052] It should be noted that, where there is no conflict, the features in the embodiments of this invention can be combined with each other.

[0053] This invention provides a method for counting class-independent targets based on the cue-extraction paradigm, the method comprising the following steps:

[0054] S1: Define hints - extract paradigms, and construct class-independent target counting and location based on the paradigms.

[0055] The "hint-extraction" paradigm is defined as follows:

[0056] S11: Provide examples before feeding the query image into the backbone network, and jointly extract features from the merged query image and examples;

[0057] S12: Represent the "hint-extraction" paradigm as C=D(B(i),e), where i represents the query image, e represents the example, B represents the backbone network, D represents the decoder, and C represents the counting result.

[0058] S2: Preprocess the input data to obtain the query image and example images (exemplars). Convert the example images into example probability maps (exemplar probability maps). Then create an all-zero matrix with the same size as the query image. Generate a Gaussian kernel for each example in the matrix. Set the peak value of the Gaussian kernel to 1 and keep the position and size of the example intact. Finally, concatenate the generated example probability map with the query image of size (3, H, W) in the channel dimension to form four-channel input data of size (4, H, W).

[0059] S3: Construct a network structure for feature extraction, using ResNet34 as the backbone network. Input the concatenated input data into the backbone network for feature extraction, and extract the joint features of the query image and the example image through a U-Net network model.

[0060] In this step, the post-processing of joint feature extraction is as follows:

[0061] S31: Input the joint features of the query image and the example image into the mapping module and the counting module;

[0062] S32: In the mapping module, a probability map of the prediction is generated through convolutional layers;

[0063] S33: In the counting module, dynamic threshold scores are generated through convolutional layers and fully connected layers.

[0064] S4: The network automatically predicts the optimal threshold and dynamically generates category-specific confidence thresholds, enabling the model to adapt to the differences in feature distribution of different categories of targets and avoid the insufficient generalization ability caused by fixed thresholds.

[0065] In this step, the dynamic threshold is calculated as follows:

[0066] S41: In the counting module, dynamic threshold scores are generated through convolutional layers and fully connected layers;

[0067] S42: During training, the true threshold score Sgt is dynamically calculated based on the number of candidate targets Ccan and the number of true targets Cgt.

[0068] When Ccan≤Cgt, Sgt is half of the lowest confidence value of the candidate object;

[0069] When Ccan > Cgt, take the average confidence score of the Cgt-th and (Cgt+1)-th objects.

[0070] S5: Target localization and counting. Non-maximum suppression (NMS) is performed on the generated probability map to obtain candidate targets. Dynamic threshold scores are used to filter the candidate targets to obtain the target counting results during the training phase.

[0071] S6: Design a loss function to improve model performance.

[0072] In this step, two loss functions were designed, specifically:

[0073] S61: Calculate the loss between the predicted threshold score and the true threshold score of the counting module using binary cross-entropy loss (BCE with logits loss);

[0074] S62: Use peak-aware mean squared error loss to calculate the loss between the predicted probability map and the true probability map of the mapping module;

[0075] S63: The weighted sum of the two loss functions is used as the total loss of the model.

[0076] S7: Model training and optimization to help the PBECount model identify similar objects to the examples that have certain feature differences.

[0077] In this step, the loop optimization method is as follows:

[0078] S71: The model is trained using the AdamW optimizer, and the learning rate is adjusted using a cosine annealing strategy;

[0079] S72: During training, use data augmentation methods (such as random flipping, rotation, scaling, cropping, and HSV augmentation) to improve the model's generalization ability;

[0080] S73: During training, use a probability map as the model's true label to ensure that the model can accurately identify similar targets in the examples.

[0081] S8: Reasoning and Post-processing. The specific processing steps are as follows:

[0082] S81: During the inference phase, dynamic threshold scores are used to filter the probability graph;

[0083] S82: Use loop optimization to optimize images containing multiple categories. First, calculate the distance of each target to the nearest example. Then, add the target with the farthest distance to the example set and rerun the model. Finally, repeat the above steps until the counting results no longer change.

[0084] S83: Normalize the counting results to obtain the final target counting result.

[0085] The verification experiment is as follows:

[0086] 1. On the FSC-147 dataset, the counting performance of this application (PBECount model) was compared with other CAC methods, as shown in Table 1.

[0087] Table 1

[0088] method FSC-147 Validation Set (MAE) FSC-147 Validation Set (RMSE) FSC-147 Test Set (MAE) FSC-147 Test Set (RMSE) FSC-147 Mul Validation Set (MAE) FSC-147 Mul Validation Set (RMSE) FSC-147 Mul Test Set (MAE) FSC-147 Mul Test Set (RMSE) FamNet (Ranjan et al., 2021) 23.75 69.07 22.08 99.54 19.89 32.43 16.58 24.55 BMNet+ (Shi et al., 2022) 15.74 58.53 14.62 91.83 13.37 17.83 11.66 16.51 SAFECount (You et al., 2023) 15.28 47.20 14.32 85.54 8.66 12.33 7.93 11.27 CounTR (Liu et al., 2022) 13.13 49.83 11.95 91.23 7.09 9.98 9.98 17.76 LOCA (ukić et al., 2023) 10.24 32.56 10.79 56.97 11.09 17.39 6.82 12.85 CACViT (Wang et al., 2024) 10.63 37.95 9.13 48.96 6.00 8.22 5.74 9.90 DAVE (Pelhan et al., 2024) 8.91 28.08 8.66 32.36 - - - - PBECount (in this application) 8.88 30.24 7.71 44.92 4.39 5.72 4.86 9.16

[0089] All methods in Table 1 were tested using the complete samples provided by the FSC-147 dataset. The results show that the PBECount model achieves state-of-the-art counting performance in terms of MAE on both the validation and test sets. In particular, on the test set, PBECount reduces the MAE value by approximately 10.97% compared to the current state-of-the-art DAVE method, demonstrating the reliability of the method's counting performance.

[0090] Furthermore, 66 images were selected from the validation set and 33 images from the test set to form the FSC-147 Mul dataset (each containing targets with more than 2 classes and a number greater than 3). Experimental results show that PBECount performs excellently in multi-class scenarios, with significantly higher accuracy than all other methods, especially demonstrating outstanding ability to distinguish different target classes. Conversely, the performance of CounTR and LOCA methods drops significantly on the FSC-147 Mul dataset, even performing worse than SAFECount and BMNet+ on some metrics. This indicates that existing methods have significant limitations in multi-class scenarios.

[0091] 2. Analyze the counting performance of PBECount in images with different target densities.

[0092] The validation and test sets of the FSC-147 dataset were divided into 8 subsets, as shown below. Figure 1 As shown, PBECount performs well in various target density scenarios, demonstrating its robustness.

[0093] 3. Ablation test

[0094] Ablation experiments were conducted on the FSC-147 dataset to analyze the impact of various architectural components and peak-aware MSE loss on counting performance, as shown in Table 2.

[0095] Table 2

[0096] method FSC-147 Validation Set (MAE) FSC-147 Validation Set (RMSE) FSC-147 Test Set (MAE) FSC-147 Test Set (RMSE) <![CDATA[PBECount no CRN ]]> 9.54 33.69 8.78 53.30 <![CDATA[PBECount no LO ]]> 8.93 29.91 9.39 77.72 <![CDATA[PBECount no ESN ]]> 12.72 56.77 11.07 97.33 <![CDATA[PBECount no PA ]]> 9.49 39.00 9.79 65.98 <![CDATA[PBECount no DT ]]> 9.93 32.25 9.89 63.14 <![CDATA[PBECount (本研究) ]]> 8.88 30.24 7.71 44.92

[0097] As shown in Table 2, retraining the model after removing different components reveals that the Dynamic Thresholding (DT) method and Peak Awareness (PA) loss are crucial for performance improvement, reducing MAE by 16.31% and 13.84%, respectively. Furthermore, removing Example Size Normalization (ESN) has the greatest impact on performance, reducing MAE by 30.27%, further demonstrating the importance of normalized sample size for achieving robust class-independent counting performance.

[0098] 4. Generalization performance experiment

[0099] The generalization performance of different methods on the CARPK dataset is shown in Table 3.

[0100] Table 3

[0101] method Mean Absolute Error (MAE) Root Mean Square Error (RMSE) FamNet (Ranjan et al., 2021) 28.84 44.47 BMNet+ (Shi et al., 2022) 10.44 13.77 SAFECount (You et al., 2023) 16.66 24.08 LOCA (ukić et al., 2023) 9.97 12.51 CACViT (Wang et al., 2024) 8.30 11.18 PBECount (in this application) 6.27 9.08

[0102] As shown in Table 3, PBECount has the best generalization performance on the CARPK dataset. Compared with the current state-of-the-art method CACViT, its MAE and RMSE are reduced by 24.46% and 18.78% respectively, highlighting its strong cross-dataset generalization ability.

[0103] 5. Example Verification

[0104] refer to Figure 2 As shown, the Prompt-Before-Extract (PBE) paradigm and PBECoun model proposed in this application have significant structural advantages and technological innovations compared with the traditional Extract-then-Match paradigm.

[0105] In the traditional extraction-matching paradigm (as shown in Figure 2(a)), the main process involves extracting features from the image using the backbone, followed by analyzing and matching the extracted features using a decoder. While this method possesses some object detection capability, its feature extraction process lacks explicit differentiation between features of different object categories. This leads to a weakening of the differences between category features in complex scenes, especially when there are many object categories or unlabeled categories, resulting in a significant decrease in the model's matching ability and accuracy.

[0106] The PBE paradigm of this application ( Figure 2 (b) introduces a feature prior mechanism based on Prompt in its structural design. By integrating ViT (Visual Transformer) into the backbone, it achieves explicit cues and guidance for target features in the input image at the shallow stage of the model. Specifically, the PBE paradigm introduces examples to directly complete the initial distinction of target categories during feature extraction, thereby avoiding matching difficulties caused by insufficient feature extraction in the subsequent decoding stage. This design enables the model to effectively maintain the discriminativeness of category features when dealing with multi-class targets, improving the model's adaptability in complex task scenarios.

[0107] For specific model performance, see Figure 2 (c) and Figure 2As shown in (d), the PBECount model demonstrates significant technical advantages over other existing methods. Existing methods (such as FamNet, BMNet, SAFECount, CounTR, and LOCA) are all based on an extraction-matching paradigm, which often struggles to accurately identify and count targets in multi-class scenarios. For example, the LOCA method exhibits significant counting bias when processing the same image containing multiple target classes (as shown in the figure, LOCA's result is 92.99). The more advanced CounTR method still shows significant errors when dealing with a large number of targets with complex distributions (CounTR's result is 129.08). In contrast, the PBECount model, benefiting from its explicit guidance on target categories and feature optimization in the Prompt phase, can distinguish and count targets in the same image with higher accuracy (as shown in the figure, PBECount's result is 16, consistent with the true value). Furthermore, PBECount also demonstrates excellent generalization ability in scenarios without labeled categories.

[0108] Further analysis of its internal mechanisms reveals that the PBECount model's backbone integrates the ViT module. This not only enhances the model's capture of global contextual information but also, through the dynamic threshold adjustment mechanism of Prompt, enables the model to adaptively adjust the matching criteria based on the characteristics of the target category. For example, for difficult-to-predict categories (such as "skis" or "books"), the model can lower the threshold to enhance the capture of target features; while for easily predictable categories (such as "marbles" or "bottle caps"), a higher threshold ensures the confidence of the prediction. This dynamic adjustment mechanism further solidifies the performance stability of PBECount in complex scenarios.

[0109] The PBE paradigm and PBECount model, through significant innovations in structural design, fundamentally break through the performance bottleneck of traditional paradigms in class-independent counting tasks, demonstrating superior performance in multi-class, complex scenarios, and cross-dataset tasks.

[0110] This invention is not limited to the above-described optional embodiments. Anyone can derive other solutions under the guidance of this invention. All technical solutions that fall within the scope of the claims of this invention are within the protection scope of this invention.

Claims

1. A class-independent target counting method based on the cue-extraction paradigm, characterized in that, Includes the following steps: S1: Define hints - extract paradigms, and construct class-independent target counting and location based on the paradigms; S11: Provide examples before feeding the query image into the backbone network, and jointly extract features from the merged query image and examples; S12: The normal form is represented as: C = D(B(i),e), where i represents the query image, e represents the example, B represents the backbone network, D represents the decoder, and C represents the counting result; S2: Preprocess the input data and build a pure CNN model PBECount. First, obtain the query image and the example image. Convert the example image into an example probability map. Then, create an all-zero matrix of the same size as the query image. Generate a Gaussian kernel for each example in the matrix. Set the peak value of the Gaussian kernel to 1 and keep the position and size of the example. Finally, concatenate the generated example probability map with the query image of size (3, H, W) in the channel dimension to form four-channel input data of (4, H, W). S3: Construct a network structure for feature extraction, using ResNet34 as the backbone network. Input the concatenated data into the backbone network for feature extraction. Extract the joint features of the query image and the example image through a U-Net network model. S4: Automatically predict the optimal threshold through the network and dynamically generate category-specific confidence thresholds; S5: Target localization and counting. Non-maximum suppression is performed on the generated probability map to obtain candidate targets. Dynamic threshold scores are used to filter the candidate targets to obtain the target counting results during the training phase. S6: Design a loss function to improve model performance; S7: Model Training and Optimization; S8: Reasoning and post-processing to obtain the final target count result.

2. The class-independent target counting method based on the cue-extraction paradigm according to claim 1, characterized in that: In step S3, the post-processing of joint feature extraction is as follows: S31: Input the joint features of the query image and the example image into the mapping module and the counting module; S32: In the mapping module, a probability map of the prediction is generated through convolutional layers; S33: In the counting module, dynamic threshold scores are generated through convolutional layers and fully connected layers.

3. The class-independent target counting method based on the cue-extraction paradigm according to claim 1, characterized in that: In step S4, the dynamic threshold is calculated as follows: S41: In the counting module, dynamic threshold scores are generated through convolutional layers and fully connected layers; S42: During training, the true threshold score Sgt is dynamically calculated based on the number of candidate targets Ccan and the number of true targets Cgt. When Ccan≤Cgt, Sgt is half of the lowest confidence value of the candidate object; When Ccan > Cgt, take the average confidence score of the Cgt-th and (Cgt+1)-th objects.

4. The class-independent target counting method based on the cue-extraction paradigm according to claim 1, characterized in that: In step S6, two loss functions were designed, as follows: S61: Use binary cross-entropy loss to calculate the loss between the predicted threshold score and the true threshold score of the counting module; S62: Calculate the loss between the predicted probability map and the true probability map of the mapping module using peak-aware mean squared error loss; S63: The weighted sum of the two loss functions is used as the total loss of the model.

5. The class-independent target counting method based on the cue-extraction paradigm according to claim 1, characterized in that: The model training and optimization steps in step S7 include: S71: The model is trained using the AdamW optimizer, and the learning rate is adjusted using a cosine annealing strategy; S72: During training, use data augmentation methods to improve the model's generalization ability; S73: During training, use a probability map as the model's true label to ensure that the model can accurately identify similar targets in the examples.

6. The class-independent target counting method based on the cue-extraction paradigm according to claim 1, characterized in that: In step S8, the model inference and post-processing steps are as follows: S81: During the inference phase, dynamic threshold scores are used to filter the probability graph; S82: Use a loop optimization method to optimize images containing multiple categories. First, calculate the distance of each target to the nearest example. Then, add the target with the farthest distance to the example set and rerun the model. Finally, repeat the above steps until the counting results no longer change. S83: Normalize the counting results to obtain the final target counting result.

Citation Information

Patent Citations

  • Method for image-text error correction of digestive endoscopy report

    CN118314371A