RGB-T crowd counting method and device based on visual large model semantic guidance and medium

By using the visual large model semantic guidance method in the RGB-T crowd counting task, semantic maps are generated and features are fused, which solves the problems of background false detection and foreground missing detection, and improves the accuracy and robustness of counting, especially In small and dense crowd scenes.

CN118736482APending Publication Date: 2024-10-01NANJING UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410717483.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

In the RGB-T crowd counting task, the existing technology has problems with background false detection and foreground missing detection, resulting in low counting accuracy, especially in small and dense crowd scenes with low performance.

Method used

Using a method based on semantic guidance of large visual models, the Segment Anything Model (SAM) is used to generate semantic maps on RGB and thermal modal images, and the semantic features, modal image features and count markers are fused through the semantic-guided feature fusion module, using The multi-head self-attention mechanism enhances the features, and inputs the fused features into the multi-level decoder to generate counting tokens and density maps, and finally obtains the counting results through the regression head.

Benefits of technology

It effectively reduces background false positive counts and improves counting accuracy and robustness in crowd areas, especially producing more accurate counting results in typical environments such as dark, crowded and thermally blurred scenes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118736482A_ABST
    Figure CN118736482A_ABST
Patent Text Reader

Abstract

The invention discloses an RGB-T crowd counting method and device based on visual large model semantic guidance and a medium, and the method comprises the steps: firstly, respectively applying SAM to RGB and thermal modals, and obtaining the semantics of each modality by using the semantics as prompts; then the module fuses semantics, modality and counting information of the highest layer, and enhances features by using a multi-head self-attention mechanism; inputting the fused features and the image features of the lower layer into a multi-stage decoder to generate a counting token and a density map; and finally, processing the density map through a regression head to obtain a final counting result. Aiming at the problems of false detection and missing detection in RGB-T crowd counting, the segmentation advantage of the SAM large model is utilized, semantic and modal information is effectively integrated, and the accuracy and robustness of the counting process are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer image technology, and relates to crowd counting technology, and in particular to a crowd counting technology method using a combination of visible light images and infrared thermal images under dark or complex backgrounds, and specifically to an RGB-T crowd counting method, device and medium based on the semantic guidance of a large visual model. Background Art

[0002] The RGB-T crowd counting task is a branch of the crowd counting task, which aims to infer the number of people in an image using RGB and thermal modality images. In real-world scenarios, there is often a problem of missing modality information. In conditions such as darkness or thermal image blur, RGB and thermal modalities can complement each other. This mutual support ensures the accuracy of crowd counting in challenging environments.

[0003] Some prior art studies attempt to filter out background regions by overlaying a foreground mask with the original image to focus on the crowd region. These methods typically treat segmentation as an additional branch and utilize segmentation labels to train the segmentor. The segmentation results are then used as background filters for input images, intermediate features, or output feature maps. However, these methods typically require true segmentation labels of crowd regions to train the segmentor, which requires a lot of time and labor. In addition, they are sensitive to changes in data distribution between different datasets, such as difficulty in transferring between datasets with different crowd sizes, and are not applicable to complex and dynamic scenes encountered in the real world.

[0004] With the advent of the era of large models and big data, the powerful segmentation model Segment Anything Model (SAM) (reference [1]) has attracted widespread attention from researchers. SAM has been pre-trained on a wide range of datasets and demonstrated excellent zero-shot segmentation capabilities, capable of segmenting previously unseen images based on cues such as points, boxes, masks, or text. This has been proven to be effective in many downstream tasks. Ma et al. (reference [2]) first proposed using SAM for few-shot counting. For a given input image, the bounding box of the object to be counted is used as a cue for SAM to obtain the mask of the target object. This mask is then compared with the mask generated for the entire image for similarity. Objects with similarity scores exceeding a certain threshold are considered to be the same object. Experimental results show that without further fine-tuning, SAM performs significantly worse than other few-shot counting methods, especially for small and dense objects. In crowd counting tasks, the individuals to be counted are usually small and dense. Therefore, it may be difficult to achieve good performance by directly using SAM for crowd counting tasks such as individual instance counting.

[0005] References:

[0006] [1]Kirillov A,Mintun E,Ravi N,et al.Segment anything[C].IEEE Inter-national Conference on Computer Vision.2023

[0007] [2]Ma Z,Hong X,Shangguan Q.Can sam count anything?an empirical studyon sam counting[J].ArXiv preprint arXiv:2304.10817,2023.

[0008] [3]Liu S,Zeng Z,Ren T,et al.Grounding dino:Marrying dino withgrounded pre-training for open-set object detection[J].ArXiv preprint arXiv:2303.05499,2023.

[0009] [4]Wang B,Liu H,Samaras D,et al.Distribution matching for crowdcounting[J].Advances in Neural Information Processing Systems.2020

[0010] [5]Liu L,Chen J,Wu H,et al.Cross-modal collaborative representationlearning and a large-scale rgbt benchmark for crowd counting[C].IEEEConference on Computer Vision and Pattern Recognition.2021

[0011] [6]Zhang Y,Choi S,Hong S.Spatio-channel Attention Blocks for Cross-modal Crowd Counting[C].Asian Conference on Computer Vision.2022

[0012] [7]Liu Z,Wu W,Tan Y,et al.RGB-T Multi-Modal Crowd Counting Based onTransformer[C].British Machine Vision Conference.2022 Summary of the invention

[0013] The problem to be solved by the present invention is: in the RGB-T crowd counting task, to solve the problems of background misdetection and foreground missed detection that may occur in the crowd counting process, so as to improve the accuracy of crowd counting.

[0014] The technical solution of the present invention is: a RGB-T crowd counting method based on the semantic guidance of a large visual model, a counting network model is constructed for the RGB-T crowd counting task, in which SAM is first applied to RGB and thermal modal images respectively, semantics is used as a prompt to obtain the semantic map of each modality, and features are extracted from the modal image and the semantic map respectively; then the semantic-guided feature fusion module fuses the semantic features, modal image features and counting marks, and uses a multi-head self-attention mechanism to enhance the features; then the fused and enhanced features and the RGB image features are input into a multi-level decoder to generate counting tokens and density maps; finally, the density map is processed by a regression head to obtain the final counting result;

[0015] 1) The highest level features extracted from the two modal images are combined with the highest level features extracted from the semantic map to obtain the RGB image semantic fusion feature F' rgb , and the image semantic fusion feature F' of the thermal modality t ;

[0016] 2) The image semantic fusion features of the RGB modality, the image semantic fusion features of the thermal modality, and the learnable counting markers are concatenated along the channel dimension to form the initial fusion feature F f :

[0017] F f =Concat[F′ rgb ,F′ t ,token count ]

[0018] Among them, Concat[·] represents the concatenation of features along the channel dimension, token count is a counting marker, a tensor with an initial value of zero, a size of 1×1, and the number of channels is the same as F' rgb and F' t same;

[0019] 3) Input the initial fusion features into a multi-head self-attention module to obtain the attention representation A f ;

[0020] 4) After the output of the multi-head self-attention, it is added back to the initial fusion feature through a residual connection, then it is passed through an MLP layer and added back to the initial fusion feature again through another residual connection to obtain the final fusion-enhanced feature F' f :

[0021] F′ f =F f ⊕MLP(F f ⊕A f ).

[0022] Furthermore, features are extracted from modal images and semantic images respectively. Specifically, Pyramid Vision Transformer is used as the image encoder to extract features of RBG and thermal images at four stages. And the features of the semantic graphs corresponding to the two modalities Different multi-layer perceptron layers are used to uniformly convert the number of channels of the feature map to 512.

[0023] Furthermore, the top-level features extracted from the two modal images are combined with the top-level features extracted from the semantic graph as follows:

[0024]

[0025] and Represent the highest level image features of the two modal images, and They represent the top-level semantic features of the semantic graphs of RGB and thermal modalities respectively, and ⊕ represents element-by-element addition.

[0026] Furthermore, in the multi-head self-attention module, the query, key and value of the initial fused features are generated through a linear layer, and then they are reshaped and divided into n heads, and the attention weights are calculated in the following way:

[0027]

[0028] Among them, Q i represents the query, K i Indicates key, V i represents the value, i represents the i-th head, Represents the attention of the i-th head. The attention calculated by each head is concatenated and reshaped to obtain the final attention representation:

[0029]

[0030] Among them, ω0 is the linear transformation matrix of the self-attention module.

[0031] Furthermore, the Grounded-SAM tool is used to generate semantic maps of crowd area segmentation containing semantic information for RGB images and thermal modality images based on text prompts.

[0032] Furthermore, the multi-level decoder generates counting tokens and density maps, and the final counting results are as follows:

[0033] 1) From the fusion enhanced feature F' f Split by the input feature dimension to get the features and Will and Splice and Aggregate with the first three layers of image features extracted from the RGB image, and then calculate their multi-level deformable attention to obtain the decoded output:

[0034]

[0035] Among them, F output represents the output of the decoder, MSDAtt represents the multi-scale deformable attention mechanism, Concat represents the concatenation operation of the feature map, Represents the first three layers of image features extracted from the original RGB image;

[0036] 2) F output Split by feature dimension and get F map and F c , F map Represents the characteristics of the density map, F c Corresponding to the count feature, F c Generate count marks after linear transformation;

[0037] 3) F map After a 3×3 convolutional layer, it is restored to its original size, that is, the input image size, to obtain the final counting result.

[0038] The present invention also provides an electronic device, comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the above-mentioned counting network model and complete the RGB-T crowd counting task for the input paired RGB and thermal infrared images.

[0039] The present invention also provides a computer-readable storage medium, in which at least one instruction or at least one program is stored, and when the at least one instruction or at least one program is executed, the above-mentioned counting network model is implemented.

[0040] The present invention proposes a scheme to generate a crowd semantic map on RGB and thermal modalities using SAM, and then complete the RGB-T crowd counting task. Aiming at the problems of false detection and missed detection in RGB-T crowd counting, the method of the present invention uses semantic features to guide and enhance the representation of modal features through a semantic-guided fusion module, effectively integrates semantic and modal information, uses semantic information to reduce false positive counts in the background, and improves the counting accuracy and robustness of the crowd area. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 It is a schematic diagram of the RGB-T crowd counting network model based on the semantic guidance of the visual big model of the present invention.

[0042] Figure 2 It is a flow chart of the multi-level decoder of the present invention.

[0043] Figure 3 This is an example of comparison between the crowd counting results of the present invention and the existing representative methods. DETAILED DESCRIPTION

[0044] like Figure 1 As shown, the present invention constructs a counting network model for RGB-T crowd counting tasks, in which SAM is first applied to RGB and thermal modal images respectively, semantics is used as a prompt to obtain the semantic map of each modality, and features are extracted from the modal image and the semantic map respectively; then the semantic-guided feature fusion module fuses the semantic features, modal image features and counting tags, and uses a multi-head self-attention mechanism to enhance the features; then the fused and enhanced features and RGB image features are input into a multi-level decoder to generate counting tokens and density maps; finally, the density map is processed by a regression head to obtain the final counting result. The counting network model of the present invention includes three parts: multimodal feature extraction, semantic-guided feature fusion module, and multi-level decoder, which are specifically described as follows through an embodiment.

[0045] 1) Semantic information acquisition.

[0046] 1.1) The original RGB and thermal images in the dataset have a resolution of 640×480 pixels. For ease of processing, these images have been resized to 672×448 pixels. This modification is to split the images into blocks of size 224×224 pixels.

[0047] 1.2) Use the Grounded-SAM tool to generate a crowd area segmentation map of semantic information based on text prompts, and obtain segmentation semantic maps of RGB and thermal modes. The tool is developed based on Grounding DINO (reference [2]) and SegmentAnything (reference [3]). Grounded-DINO first generates target detection boxes based on semantic prompts, and then SAM generates semantic segmentation areas within these boxes. Specifically, the present invention uses the pre-trained models groundingdino_swint_ogc.pth and sam_vit_h_4b8939.pth. In this process, the text prompt "Humans" is used. The parameters set during the extraction process include a box threshold of 0.25, a text threshold of 0.25, and a non-maximum suppression NMS threshold of 0.8. These thresholds are crucial for depicting the boundaries of 0-human presence in the image, thereby achieving accurate extraction of the crowd area mask.

[0048] 2) Feature extraction.

[0049] 2.1) Input RGB, thermal images and their segmentation maps into the Pyramid Vision Transformer network to extract feature maps of different sizes in four stages And the features of their corresponding semantic images Among them, the extracted feature maps are reduced in size but the number of channels is increased. Their sizes are 56, 28, 14, and 7, while the number of channels is 64, 128, 320, and 512, respectively.

[0050] 2.2) Use different multi-layer perceptron layers to uniformly convert the number of channels of the four sets of feature maps to 512.

[0051] 3) The semantics-guided feature fusion module fuses the highest-level semantic, modality, and count information, and inputs the multi-head self-attention mechanism to enhance the features.

[0052] 3.1) Merge the highest level features extracted from the two modalities with the highest level features extracted from the semantic modality:

[0053]

[0054] Among them, F' rgb and F' t They represent the features after the fusion of original features and semantic features in RGB and thermal modalities respectively, and ⊕ represents element-by-element addition. and Represents the top-level image features of the two modalities, and Corresponding to the top-level semantic features of RGB and thermal modalities.

[0055] 3.2) The semantic fusion features of the RGB modality, the semantic fusion features of the thermal modality, and the learnable counting markers are concatenated to form the initial fusion features:

[0056] F f =Concat[F′ rgb ,F t ,token count ]

[0057] Where Concat[·] represents the concatenation of features along the channel dimension. F' rgb and F' t Represents the fusion features of the original features and semantic features in RGB and thermal modalities, token count It is a counting marker, a tensor with an initial value of zero, a size of 1×1, and the number of channels is the same as the previous two components F' rgb and F' t same.

[0058] 3.3) The initial fusion feature F f Input into a multi-head self-attention module. Specifically, the process starts with a linear layer to generate queries, keys, and values ​​for the input fused features. They are then reshaped and divided into n heads. The attention weights are calculated as follows:

[0059]

[0060] Among them, Q i represents the query, K i Indicates key, V i represents the value, i represents the i-th head, represents the attention of the i-th head. Then, the attention calculated by each head is concatenated and reshaped to obtain the final attention representation:

[0061]

[0062] Among them, A f represents the final attention, n is the total number of heads, Concat represents the concatenation operation, represents the attention of each head, and ω0 is the final linear transformation matrix.

[0063] 3.4) After the output of the multi-head self-attention, it is added back to the original input features through a residual connection. Then, it is passed through an MLP layer and added back to the original input features again through another residual connection to obtain the final fused features:

[0064] F′ f =Ff ⊕MLP(F f ⊕A f )

[0065] Among them, F' f is the final fusion-enhanced feature, F f is the initial fusion feature, A f represents the output of multi-head self-attention, and ⊕ represents the addition operation. The final feature effectively integrates semantic information, RGB modality information, thermal modality information, and count information.

[0066] 4) The fused enhanced features and RGB image features are input into a multi-level decoder to generate the final counting result.

[0067] 4.1) Figure 2 As shown, from the fusion enhanced feature F' f , according to the initial fusion feature F f The semantic fusion features of the two modalities spliced ​​in the feature dimension size division of the count mark are obtained. and Will and of splicing, and Aggregate with the features extracted from the initial three layers and calculate their multi-level deformable attention:

[0068]

[0069] Among them, F output represents the output of the decoder, MSDAtt represents the multi-scale deformable attention mechanism, Concat represents the concatenation operation of the feature map, Represents the first three layers of features of the original RGB input.

[0070] 4.2) F output Split by feature dimension and get F map and F c , F map represents the characteristics of the density map, and F c Corresponding to the count feature, F c Generate counting marks after linear transformation. The counting feature is a feature that is segmented and can be transformed into a counting mark after linear transformation. The counting mark is also a counting token.

[0071] 4.3) F in step 4.2) mapAfter a 3×3 convolutional layer, the image is restored to its original size, i.e., the input image size, to obtain the final counting result. Obtaining the counting result from the density map is an existing technology. The counting result is the number obtained by integrating each pixel point of the density map. The counting mark can be understood as a one-dimensional number, which is the total number of this image. During training, the deviation between the counting mark and the actual count is calculated as a supervision signal. When the counting network model actually counts, it only needs to use the integral result of the density map as the number prediction result.

[0072] The network was trained using the Adam optimizer with a batch size of 16, an initial learning rate of 2e-5, and a warm-up phase of 30 epochs. The model was trained for 500 epochs with a learning rate decay of 1e-4. The training and testing of the model of the present invention were performed on an NVIDIA RTX 3090 GPU with 24GB of memory using PyTorch 1.11.0.

[0073] The overall loss consists of two parts: density map loss and count loss. Density map loss is derived from DM-Count (reference [3]) and uses optimal transfer to measure the similarity between the normalized predicted density map and the normalized true density map. Count loss uses the L1 norm to supervise the difference between the predicted count and the actual count.

[0074]

[0075] Where D represents the predicted density map, represents the actual density map, C represents the predicted count, Indicates the actual count.

[0076] The present invention is verified on the RGBT-CC dataset and compared with existing representative methods. Figure 3 This is a comparison example of the crowd counting results of the present invention and the existing representative method. Figure 3The three rows from top to bottom show the counting examples of three scenes: dark, crowded and thermally blurred. (a) is an RGB image, (b) is a thermal modality image, (c) is a true label, (d) is the counting result of the CMCRL method (reference [5]), (e) is the counting result of the CSCA method (reference [6]), (f) is the counting result of LIURGBT (reference [7]), and (g) is the counting result of the method of the present invention. The Estimate above each counting scheme diagram in the figure refers to the estimated number of people, that is, the prediction result, and the Difference refers to the difference between the estimated result and the true result. The experimental results show that in typical environments, such as dark, crowded and thermally blurred scenes, the method of the present invention can produce more accurate counting results. In addition, the analysis of the density map distribution shows that the method of the present invention more effectively focuses the prediction on the crowd area. By integrating semantic information, the method of the present invention improves the accuracy of the predicted distribution and ensures that it focuses on areas with higher crowd density.

[0077] An exemplary embodiment of the present invention also provides an electronic device, including a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the counting network model described in the above embodiment, and complete the RGB-T crowd counting task for the input paired RGB and thermal infrared images.

[0078] An exemplary embodiment of the present invention further provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to perform a crowd counting method according to an embodiment of the present invention.

[0079] The electronic device of the present invention is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing devices, smart phones, wearable devices, and other similar computing devices. The processor can be various general and / or special processing components with processing and computing capabilities. Some examples of processors include, but are not limited to, central processing units (CPUs), graphics processing units (GPUs), various dedicated artificial intelligence (AI) computing chips, various computing units for running machine learning model algorithms, and any appropriate processors, controllers, microcontrollers, etc.

[0080] The program code for implementing the method of the present invention may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, a special purpose computer or other programmable data processing device, so that when the program code is executed by the processor or controller, the above crowd counting method is implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

Claims

1. A RGB-T crowd counting method based on semantic guidance of visual big model, Its characteristics are A counting network model is constructed for the RGB-T crowd counting task. In the counting network model, SAM is first applied to the images of RGB and thermal modalities respectively, semantics is used as a cue to obtain the semantic map of each modality, and features are extracted from the modal images and semantic maps respectively; Then, the semantic-guided feature fusion module fuses semantic features, modal image features, and count tokens, and uses a multi-head self-attention mechanism to enhance the features. The fused and enhanced features and RGB image features are then input into a multi-level decoder to generate count tokens and density maps. Finally, the density map is processed by a regression head to obtain the final count result. The semantic-guided feature fusion module is as follows: 1) The highest level features extracted from the two modal images are combined with the highest level features extracted from the semantic map to obtain the RGB image semantic fusion feature F' rgb , and the image semantic fusion feature F' of the thermal modality t ; 2) The image semantic fusion features of the RGB modality, the image semantic fusion features of the thermal modality, and the learnable counting markers are concatenated along the channel dimension to form the initial fusion feature F f : F f =Concat[F′ rgb ,F′ t ,token count ] Among them, Concat[·] represents the concatenation of features along the channel dimension, token count is a counting marker, a tensor with an initial value of zero, a size of 1×1, and the number of channels is the same as F' rgb and F' t same; 3) Input the initial fusion features into a multi-head self-attention module to obtain the attention representation A f ; 4) After the output of the multi-head self-attention, it is added back to the initial fusion feature through a residual connection, then it is passed through an MLP layer and added back to the initial fusion feature again through another residual connection to obtain the final fusion-enhanced feature F' f :

2. According to the RGB-T crowd counting method based on the semantic guidance of the visual big model according to claim 1, Its characteristics are The features of modal images and semantic images are extracted separately as follows: Pyramid Vision Transformer is used as the image encoder to extract the features of RBG and thermal images at four stages. And the features of the semantic graphs corresponding to the two modalities Different multi-layer perceptron layers are used to uniformly convert the number of channels of the feature map to 512.

3. According to claim 1 or 2, a RGB-T crowd counting method based on the semantic guidance of a visual large model, Its characteristics are The top-level features extracted from the two modal images are combined with the top-level features extracted from the semantic graph as follows: and Represent the highest level image features of the two modal images, and Represent the highest level semantic features of the semantic graph of RGB and thermal modality, Represents element-by-element addition.

4. According to claim 1, a RGB-T crowd counting method based on semantic guidance of a visual large model, Its characteristics are In the multi-head self-attention module, a linear layer is used to generate the query, key, and value of the initial fused features, which are then reshaped and divided into n heads, and the attention weights are calculated as follows: Among them, Q i represents the query, K i Indicates key, V i represents the value, i represents the i-th head, Represents the attention of the i-th head. The attention calculated by each head is concatenated and reshaped to obtain the final attention representation: Among them, ω0 is the linear transformation matrix of the self-attention module.

5. According to claim 1, a RGB-T crowd counting method based on semantic guidance of a visual large model, Its characteristics are The Grounded-SAM tool is used to generate semantic maps of crowd area segmentation containing semantic information for RGB images and thermal modality images based on text prompts.

6. According to claim 1, a RGB-T crowd counting method based on semantic guidance of a visual large model, It is characterized by multi-level The decoder generates counting tokens and density maps, and the final counting results are as follows: 1) From the fusion enhanced feature F' f Split by the input feature dimension size to get the features and Will and Splice and Aggregate with the first three layers of image features extracted from the RGB image, and then calculate their multi-level deformable attention to obtain the decoded output: Among them, F output represents the output of the decoder, MSDAtt represents the multi-scale deformable attention mechanism, Concat represents the concatenation operation of the feature map, Represents the first three layers of image features extracted from the original RGB image; 2) F output Split by feature dimension and get F map and F c , F map Represents the characteristics of the density map, F c Corresponding to the count feature, F c Generate count marks after linear transformation; 3) F map After a 3×3 convolutional layer processing, it is restored to the original size, that is, the input image size, to obtain the final counting result.

7. An electronic device, Its characteristics are The electronic device includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the counting network model described in any one of claims 1 to 6, and complete the RGB-T crowd counting task for the input paired RGB and thermal infrared images.

8. A computer-readable storage medium, Its characteristics are The computer-readable storage medium stores at least one instruction or at least one program, and when the at least one instruction or at least one program is executed, the counting network model according to any one of claims 1 to 6 is implemented.