Image scene recognition method and device, computer device and storage medium
By employing low-rank attention analysis and gating fusion mechanism based on kernel matrix in visual location recognition, the problem of high computational complexity is solved, achieving efficient image scene recognition and accurate scene-adaptive recognition.
Patent Information
- Application Number
- CN202611193327.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-06
- Publication Date
- 2026-11-20
AI Technical Summary
In existing technologies, deep learning-based visual location recognition methods suffer from high computational complexity and low processing efficiency. In particular, the computational complexity and memory consumption caused by fully connected relationships in cross-scale attention computation are too high, affecting the efficiency of image scene recognition.
We employ a kernel matrix-based low-rank attention analysis and gated fusion mechanism. By performing low-rank attention analysis on multi-scale feature maps, we reduce computational complexity. Furthermore, by using gated fusion processing, we adaptively integrate attention features from different scales, thus avoiding the computational explosion of cross-scale fully connected attention.
It reduces computational complexity, improves the efficiency and accuracy of image scene recognition, enhances scene adaptability, and is better able to recognize complex scenes.
Smart Images

Figure CN123142135A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology and can be applied to environmental location recognition scenarios in the fields of fintech and healthcare. In particular, it relates to an image scene recognition method, apparatus, computer equipment, and storage medium. Background Technology
[0002] Visual Place Recognition (VPR) is a technology that matches and queries image locations from map databases, and it has wide applications in fintech and healthcare. In fintech, banks use environmental images (such as store signs) captured by user devices to cross-verify with geographic location information in their databases to detect fraud and verify the authenticity of transactions. In healthcare, large hospitals use visual recognition of corridor signage and department door signs to guide patients quickly to their desired departments, reducing anxiety caused by not being able to find the right department in complex environments.
[0003] In existing technologies, deep learning-based feature representation methods can be applied to visual location recognition processes. For example, hierarchical networks with a pyramid structure can capture multi-scale visual features, but some problems still exist. Traditional pyramid fusion (such as simple concatenation or summation) cannot dynamically filter cross-scale discriminative features. Although introducing attention mechanisms can improve the discriminative power of scene representation by modeling long-range dependencies, cross-scale attention computation requires building fully connected relationships between layers, causing the dimension of the attention matrix to increase quadratically with the number of scales, increasing computational complexity and memory consumption, and reducing the processing efficiency of image scene recognition. Summary of the Invention
[0004] This invention provides an image scene recognition method, apparatus, computer device, and storage medium to solve the technical problems of high computational complexity and low processing efficiency in image scene recognition.
[0005] Firstly, an image scene recognition method is provided, including: The image to be processed is acquired, and the image to be processed is preprocessed to obtain image tensor data; The image tensor data is subjected to feature extraction processing to obtain a multi-scale feature map, which includes at least two levels of hierarchical feature maps. Low-rank attention analysis based on kernel matrix is performed on the feature map of each level to obtain the attention feature map of each level; Gated fusion processing is performed on the attention feature maps at all levels to obtain the target scene feature vector; The target scene is matched from the preset scene database based on the target scene feature vector, and the target scene is determined as the scene recognition result corresponding to the image to be processed.
[0006] Secondly, an image scene recognition device is provided, comprising: The preprocessing module is used to acquire the image to be processed, preprocess the image to be processed, and obtain image tensor data; The feature extraction module is used to perform feature extraction processing on the image tensor data to obtain a multi-scale feature map, wherein the multi-scale feature map includes at least two levels of hierarchical feature maps. The attention analysis module is used to perform low-rank attention analysis based on the kernel matrix on the feature map of each level to obtain the attention feature map of each level. The gated fusion module is used to perform gated fusion processing on the attention feature maps of all levels to obtain the target scene feature vector; The scene matching module is used to match the target recognition scene from a preset scene database based on the target scene feature vector, and determine the target recognition scene as the scene recognition result corresponding to the image to be processed.
[0007] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described image scene recognition method.
[0008] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the above-described image scene recognition method.
[0009] In the aforementioned image scene recognition method, apparatus, computer equipment, and storage medium, the method preprocesses the image to be processed to obtain image tensor data; performs feature extraction processing on the image tensor data to obtain multi-scale feature maps, which include at least two levels of hierarchical feature maps; performs low-rank attention analysis based on kernel matrix on each level of hierarchical feature map to obtain attention feature maps at each level; performs gated fusion processing on all levels of attention feature maps to obtain target scene feature vectors; matches the target recognition scene from a preset scene database based on the target scene feature vectors, and determines the target recognition scene as the scene recognition result corresponding to the image to be processed. This invention can be applied to environmental location recognition scenarios in the fintech and healthcare fields. It reduces quadratic complexity to linear complexity through low-rank matrix factorization, and simultaneously uses a gated fusion mechanism to adaptively integrate attention features of different scales. Specifically, this invention avoids the problem of computational explosion in cross-scale fully connected attention by extracting multi-scale feature maps and performing low-rank attention analysis based on kernel matrix, thereby reducing computational complexity and improving image scene recognition efficiency. Meanwhile, the present invention reduces the conflict rate of multi-scale features through a gated fusion mechanism, thereby enhancing scene adaptability and improving the accuracy of image scene recognition. Attached Figure Description
[0010] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This is a schematic diagram of an application environment for an image scene recognition method according to an embodiment of the present invention; Figure 2 This is a flowchart illustrating an image scene recognition method according to an embodiment of the present invention; Figure 3 yes Figure 2 A schematic diagram of a specific implementation method for step S20; Figure 4 yes Figure 2 A schematic diagram of a specific implementation method for step S30; Figure 5 yes Figure 4 A flowchart illustrating a specific implementation of step S303; Figure 6 yes Figure 2 A schematic diagram of a specific implementation of step S40; Figure 7 yes Figure 6A schematic diagram of a specific implementation of step S402; Figure 8 yes Figure 2 A schematic diagram of a specific implementation method for step S50; Figure 9 This is a schematic diagram of the structure of an image scene recognition device according to an embodiment of the present invention; Figure 10 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention; Figure 11 This is another structural schematic diagram of a computer device according to one embodiment of the present invention. Detailed Implementation
[0012] 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, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0013] The image scene recognition method provided in this embodiment of the invention can be applied to, for example, Figure 1 In this application environment, the client communicates with the server via a network. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers. The server can acquire the image to be processed from the client, preprocess the image to obtain image tensor data; perform feature extraction processing on the image tensor data to obtain multi-scale feature maps; perform low-rank attention analysis based on kernel matrix on the feature maps of each level to obtain attention feature maps of each level; perform gated fusion processing on the attention feature maps of all levels to obtain the target scene feature vector; match the target recognition scene from a preset scene database based on the target scene feature vector, determine the target recognition scene as the scene recognition result corresponding to the image to be processed, and feed the scene recognition result back to the client. The invention will be described in detail below through specific embodiments.
[0014] Please see Figure 2 As shown, Figure 2 The image scene recognition method provided in the embodiments of the present invention is applied in Figure 1 A flowchart of the server-side process includes the following steps: S10: Obtain the image to be processed, preprocess the image to be processed, and obtain image tensor data.
[0015] The image scene recognition method provided by this invention can be applied to environmental location recognition scenarios in the fintech and healthcare fields. Environmental location recognition is achieved through a server-side mechanism that receives images submitted by users via client-side data in real time for scene recognition. On one hand, in risk control scenarios within the financial sector, the server needs to recognize image materials submitted by users via client-side data. For example, if a user operates a clothing store and needs a loan, the server needs to recognize the submitted landmark photos or interior photos of the store to determine their authenticity. On the other hand, in rehabilitation institutions within the healthcare field, the server acquires and recognizes image information such as human posture and movement trajectories captured by the client's camera, enabling health status assessment and abnormal behavior warnings. For example, it can identify abnormal postures (such as sudden tilting) in the daily activities of the elderly and trigger alarms based on environmental scenarios (such as slippery floors), reducing the risk of falls and injuries.
[0016] The image to be processed refers to the image from which environmental locations need to be identified. The server preprocesses the image to be processed to obtain image tensor data. Image tensor data is the mathematical representation of an image in a computer, specifically a multidimensional array structure. Preprocessing is used to standardize and enhance the input image, outputting tensor data of uniform size. Specifically, the original RGB image before preprocessing can correspond to any resolution, while the normalized tensor after preprocessing corresponds to a fixed resolution.
[0017] Image tensor data is represented as a three-dimensional tensor using the format [H, W, C], consisting of height (H), width (W), and number of channels (C). Here, H represents the image height, i.e., the number of pixels in the vertical direction; W represents the image width, i.e., the number of pixels in the horizontal direction; and C represents the number of channels, representing the color or feature dimension of the image. For example, in a risk control scenario in the financial field, if the image submitted by a user during loan approval is an RGB color image of a storefront, the preprocessed image tensor data would be represented as [H, W, 3], where C=3 corresponds to the three color channels: red (R), green (G), and blue (B). As another example, in a rehabilitation institution in the healthcare field, if the image captured by a camera is a grayscale image, the preprocessed image tensor data would be represented as [H, W] or [H, W, 1], where C=1 indicates a single channel.
[0018] S20: Perform feature extraction processing on the image tensor data to obtain a multi-scale feature map, wherein the multi-scale feature map includes at least two levels of hierarchical feature maps.
[0019] Understandably, after obtaining image tensor data, the server needs to perform feature extraction processing on the image tensor data to obtain multi-scale feature maps. Multi-scale feature maps are a set of feature representations obtained by performing multi-level, multi-resolution feature extraction processing on image data. In the fields of computer vision and deep learning, multi-scale feature maps can simultaneously capture semantic and detailed information of an image at different spatial scales. Multi-scale feature maps consist of feature maps at different levels, each with different spatial dimensions (e.g., resolution from high to low). Multi-scale feature maps include at least two levels of hierarchical feature maps. For example, a multi-scale feature map may only include two levels: a shallow feature map and a deep feature map. The shallow feature map has high resolution, preserving detailed information such as edges and textures, but with less semantic information. The deep feature map has low resolution, encoding global semantic information (such as object category and scene), but losing some details. Multi-scale feature maps can also include three levels of hierarchical feature maps: shallow feature maps, intermediate-level feature maps, and deep feature maps. The resolution of the intermediate-level feature maps is between that of the shallow and deep feature maps, forming a richer multi-scale representation.
[0020] Specifically, in some implementations, the server can use a pyramid structure to generate multi-scale feature maps by downsampling the input image multiple times to generate images of different scales and extracting features from each. In some implementations, the server can also use dilated convolution to generate multi-scale feature maps, expanding the receptive field without reducing resolution and generating multi-scale contextual information.
[0021] In some embodiments of the invention, such as Figure 3 As shown, step S20, which involves feature extraction processing of the image tensor data to obtain a multi-scale feature map, includes the following steps: S201: The image tensor data is segmented and embedded to obtain multiple image block embedding features.
[0022] S202: Perform hierarchical downsampling and strided convolution processing on all the image patch embedding features to obtain multi-scale feature maps.
[0023] Understandably, the server uses a pyramid feature extractor to extract features from the image tensor data, resulting in multi-scale feature maps. Taking a multi-scale feature map comprising three levels as an example, the multi-scale feature map includes first-level, second-level, and third-level feature maps. The resolution of the first-level feature map is higher than that of the second-level feature map, and vice versa. The first level preserves high-resolution information through shallow downsampling, capturing details (such as edges and colors). The second level balances resolution and semantic information through moderate downsampling, capturing medium-scale targets (such as small objects or local structures). The third level generates low-resolution, high-semantic features through deep downsampling, aiding in global understanding (such as scene classification or large object detection). For example, the resolution of the first-level feature map is 240×135, the second-level feature map is 120×68, and the third-level feature map is 60×34. Image patch embedding features divide an image into local patches and map each patch to a high-dimensional vector space through linear or nonlinear transformations, thereby converting the image data into gridded features suitable for model processing.
[0024] This embodiment uses an improved Swing Transformer as the backbone network of the pyramid feature extractor, generating features through hierarchical downsampling. Feature maps at each scale ,in L represents the number of levels in the hierarchical feature map. Specifically, the multi-scale feature map includes hierarchical feature maps of the first, second, and third levels, i.e. L =3, l =1 indicates the first level, and F1 represents the feature map of the first level. l =2 indicates the second level, and F2 represents the feature map of the second level. l=3 indicates the third level, and F3 indicates the feature map of the third level. The standard Swin Transformer structure includes Stages 1-4. Stage 1 divides the input image into fixed-size patches, each patch is mapped to a high-dimensional space, and enters multiple Swin Transformer Blocks (computation blocks) with a fixed window size. Stages 2-4 reduce the resolution and increase the number of channels through PatchMerging layers. The feature map size gradually decreases and the number of channels gradually increases in each stage. Each Swin Transformer Block contains Layer Norm, self-attention network, and multilayer perceptron (MLP). The Window Multi-head Self-Attention (W-MSA) network divides the feature map into non-overlapping windows (e.g., 7×7) and calculates self-attention only within the window, significantly reducing computational complexity. Shifted Window Multi-head Self-Attention (SW-MSA) builds upon W-MSA by shifting the window to the lower right by a few pixels, allowing information exchange between different windows. The improved Swing Transformer network used in this embodiment, compared with the standard Swing Transformer, inserts strided convolutions between Stage 3 and Stage 4 to enhance the ability to capture local geometric features, which is crucial for the recognition of regular structures (such as doors and windows) in indoor scenes.
[0025] This embodiment preserves local information through block segmentation and embedding, and then constructs a multi-scale feature pyramid through hierarchical downsampling and strided convolution, achieving a balance between detail and global perspective, and a unity of computational efficiency and model capability. The hierarchical feature maps of multiple levels in the multi-scale feature map form complementary information, with lower-level features providing details and higher-level features providing semantics. After fusion, robustness can be improved (such as against occlusion or changes in illumination).
[0026] S30: Perform low-rank attention analysis based on the kernel matrix on the feature map of each level to obtain the attention feature map of each level.
[0027] Understandably, the server employs the Nyström method to perform low-rank attention analysis based on the kernel matrix on the hierarchical feature maps of each level, obtaining attention feature maps for each level. Attention feature maps are enhanced feature representations generated by dynamically weighting the original features, highlighting key information and suppressing redundancy. The theoretical basis of the Nyström method is the "low-rank approximation of the kernel matrix." The kernel matrix of real-world data has low-rank or near-low-rank characteristics (data is distributed on a low-dimensional manifold), and therefore can be approximated by a linear combination of a small number of anchor points.
[0028] In some embodiments of this invention, the multi-scale feature map includes hierarchical feature maps of a first level, a second level, and a third level; such as Figure 4 As shown, a specific low-rank attention analysis scheme is provided. In step S30, low-rank attention analysis based on the kernel matrix is performed on the feature map of each level to obtain the attention feature map of each level. Specifically, it includes the following steps S301-S303: S301: Perform cluster analysis on the feature map of each level, and determine the landmark feature matrix of each level based on the cluster centers obtained from the cluster analysis. S302: Perform similarity analysis on the feature matrix of the landmarks at each level to obtain the kernel matrix of each level; S303: Perform low-rank attention calculation processing based on the hierarchical feature maps and kernel matrix of the first and second levels to obtain the attention feature map of the first level; perform low-rank attention calculation processing based on the hierarchical feature maps and kernel matrix of the second and third levels to obtain the attention feature map of the second level; perform low-rank attention calculation processing based on the hierarchical feature maps and kernel matrix of the first and third levels to obtain the attention feature map of the third level.
[0029] Understandably, the server uses the Nyström method for cross-scale attention analysis at each level. Hierarchical feature map First, select by spatial clustering Landmark This constructs a landmark feature matrix. Next, the similarity matrix between landmarks is calculated, transforming the landmark feature matrix into a landmark kernel matrix. (with dimensions of m×m), then calculate the approximate attention matrix between layers. Finally, attention feature maps for each level are obtained. In similarity analysis, commonly used kernel functions (such as Gaussian kernels and polynomial kernels) can map the original features to a high-dimensional space, thereby introducing nonlinear relationships. Low-rank attention computation can assign different attention weights to different landmark features based on the similarity information in the kernel matrix, focusing on those features that are more important to the current task and ignoring irrelevant or secondary features.
[0030] In this specific embodiment, considering the characteristics of large differences in object scale (such as furniture and building structures) and high texture repetition (such as shopping mall shops) in indoor environments, this embodiment adopts an adaptive sampling strategy based on spatial clustering. For a given level The hierarchical feature map is The server first flattens it into the original feature matrix. ( Next, an improved k-means algorithm is used to perform cluster analysis on the feature maps of each level, and landmark points are selected based on the obtained cluster centers. These cluster centers constitute a landmark point feature matrix, which retains key information in a more concise form compared to the original feature maps, achieving feature dimensionality reduction. Compared with traditional k-means, a spatial constraint term is introduced. This allows landmarks to be dispersed simultaneously in both the feature space and physical space, which is particularly important for covering scattered salient areas (such as doorplates and signs) in indoor scenes. For weight parameters, For pixel coordinates, when When the value is 0, it degenerates into traditional k-means. Landmark points are... ,in Let m be the set of cluster centers, and m be the number of cluster centers, i.e., the number of landmarks. During initialization, points that are farther apart are preferred to enhance diversity. This approach maintains over 95% accuracy in attention approximation. Representative feature points are selected from the clustered center set for low-rank attention computation. The number of landmarks selected for each level (m) is 256, 128, and 64 respectively. Specifically, the first level's feature map has a resolution of 240×135 and selects 256 landmarks; the second level's feature map has a resolution of 120×68 and selects 128 landmarks; and the third level's feature map has a resolution of 60×34 and selects 64 landmarks.
[0031] Furthermore, the server performs low-rank attention calculations based on the hierarchical feature maps and kernel matrices to obtain attention feature maps for each level. For example, the server performs low-rank attention calculations based on the hierarchical feature maps and kernel matrices of the first and second levels to obtain the attention feature map of the first level. The server performs low-rank attention calculations based on the hierarchical feature maps and kernel matrices of the second and third levels to obtain the attention feature map of the second level. The server performs low-rank attention calculations based on the hierarchical feature maps and kernel matrices of the first and third levels to obtain the attention feature map of the third level.
[0032] In this embodiment, cluster analysis can aggregate a large number of similar feature points in the hierarchical feature map to form representative cluster centers, reducing the amount of data required for subsequent calculations and lowering computational complexity. The kernel matrix can intuitively reflect the degree of similarity between features of different landmarks, providing an important basis for subsequent low-rank attention calculation. Unlike simple feature truncation or linear projection, the Nyström approximate low-rank attention calculation preserves the key correlations of the original feature space through the kernel function.
[0033] In some embodiments of the invention, in step S303, such as Figure 5As shown, low-rank attention calculation is performed based on the hierarchical feature maps and kernel matrix of the first and second levels to obtain the attention feature map of the first level, specifically including the following steps S3031-S3035: S3031: Determine the query vector based on the hierarchical feature map of the first level; S3032: Determine the initial key vector and initial value vector based on the hierarchical feature map of the second level; S3033: Determine the intermediate vector based on the kernel matrix of the second level; S3034: Determine the key vector based on the initial key vector and the intermediate vector, and determine the value vector based on the initial value vector and the intermediate vector; S3035: Perform low-rank attention calculation processing based on the query vector, the key vector, and the value vector to obtain the attention feature map of the first level.
[0034] Understandably, in a cross-domain attention mechanism, the first step is to generate a query vector, a key vector, and a value vector based on the requirements of the current task. Next, the similarity between the query vector and the key vector is calculated to obtain an attention score. Similarity calculation methods include dot product, additive attention, and scaled dot product attention. Then, the attention score is normalized using the Softmax function to obtain attention weights. The attention weights are then used to perform a weighted summation of the value vectors to obtain a fused feature representation, which contains key information from different levels. Specifically, the landmark kernel matrices of the first, second, and third levels are weighted and fused (e.g., cross-scale attention weights from F1 to F2 and F2 to F3), and after adjusting the number of channels through a 1×1 convolution, they are weighted and summed with the original feature map to generate the attention features after cross-scale interaction.
[0035] In one specific embodiment, the server defines different levels. and The approximate attention matrix between them decomposes the traditional attention into low-rank components. .in, For query vector, For the initial key vector, For the initial value vector, For the first The original feature matrix of the hierarchy, For the first The original feature matrix of the hierarchy, where T represents the transpose matrix. Here, d represents the projection weights, d is the dimension of the key vector, and C is the number of image channels. The server introduces an intermediate vector... ,in, For the first A hierarchical landmark matrix. The server determines the key vector based on the initial key vector and the intermediate vector. The value vector is determined based on the initial value vector and the intermediate value vector. Finally, attention feature maps for each level are obtained. × For example, when =1 indicates the first level. =2 indicates that in the second level, the approximate attention matrix between levels L1 and L2 is calculated, ultimately obtaining the attention feature map of the first level. ,at this time × .when =2 indicates the second level. =3 indicates that in the third level, the approximate attention matrix between levels L2 and L3 is calculated, ultimately obtaining the attention feature map of the second level. ,at this time × .when =3 indicates the first level. =1 indicates that in the third level, the approximate attention matrix between levels L1 and L3 is calculated, and the attention feature map of the third level is finally obtained. ,at this time × The server decomposes the complexity from... Down to ( (For the number of landmarks), when processing high-resolution inputs (such as 1080P images), in This setting can achieve a 23x reduction in video memory.
[0036] Taking a risk control scenario in the financial sector as an example, the image submitted by a user during loan approval is a photo of a store entrance taken with a mobile phone at a resolution of 1920×1080. After pyramid feature extraction, three levels of feature maps are generated: Level 1 (L1) with a resolution of 240×135, Level 2 (L2) with a resolution of 120×68, and Level 3 (L3) with a resolution of 60×34. During low-rank attention calculation, cross-scale attention calculation is performed for different levels. Specifically, the attention between L1 and L2 focuses on matching the store's brand logo with the store name font, resulting in the attention feature map for Level 1 (L1). The attention between L2 and L3 is associated with the store layout and corridor location, resulting in the attention feature map for Level 2 (L2).
[0037] This embodiment addresses the problem of exploding computational complexity in cross-scale fully connected attention by reducing the computational complexity from quadratic to linear through landmark sampling and kernel matrix factorization. This is beneficial for real-time processing of high-resolution indoor scenes, and the low-rank attention mechanism can process information more effectively, improving the accuracy and effectiveness of feature extraction.
[0038] S40: Perform gated fusion processing on the attention feature maps of all levels to obtain the target scene feature vector.
[0039] In gated fusion processing, attention feature maps from all levels are weighted and combined, with the weighting coefficients dynamically learned through a gating mechanism. Gated fusion can adaptively fuse information based on the importance and relevance of feature maps from different levels, resulting in a more comprehensive and representative feature representation. The target scene feature vector is a highly abstract and compressed representation of the target scene in the image being processed, retaining the key features most relevant to the target scene. For example, the target scene feature vector can capture key features such as the shape, color, and texture of objects in the image, as well as the spatial relationships between objects, thus enabling accurate identification of different images.
[0040] In some embodiments of the invention, such as Figure 6 As shown, a specific gated fusion processing scheme is provided. In step S40, that is, gated fusion processing is performed on the attention feature maps of all levels to obtain the target scene feature vector, specifically including the following steps S401-S403: S401: Perform channel compression processing on the attention feature map of each level to obtain the dimensionality-reduced feature vector of each level; S402: Perform gated convolution processing on the attention feature map of each level to obtain the fusion weight parameters of each level; S403: Perform feature fusion processing on the dimensionality-reduced feature vector according to the fusion weight parameters of all levels to obtain the target scene feature vector.
[0041] Understandably, hierarchical feature maps at different levels focus on different aspects or levels of features in the target scene. Through gating mechanisms, the contribution of each level of features during the fusion process can be dynamically adjusted, making the fusion result more reasonable and accurate, and better adaptable to the needs of different scenarios and tasks. Hierarchical feature maps at different levels contain features from low to high levels and from local to global perspectives. Fusion of these maps can obtain a more comprehensive and richer representation of the target scene features, improving the ability to recognize complex scenes.
[0042] In one specific embodiment, the server uses gating weights to manage the attention feature maps at each level. Gated fusion processing is performed to obtain the target scene feature vector. .in, For the first The layered channel compression matrix, where C is the number of channels in the image, and C' is the number of channels after compression. For the sigmoid function, the gating mechanism uses learnable fusion weight parameters. Soft filtering is performed on the attention feature maps at each level. This is the projection matrix.
[0043] This embodiment significantly reduces the number of parameters involved in subsequent calculations through dimensionality reduction. Gated convolution processing adaptively generates fusion weight parameters based on the characteristics and importance of attention feature maps at different levels. Simultaneously, dynamic weight learning is introduced through a gated fusion mechanism to resolve conflicts between multi-scale features. All dimensionality-reduced feature vectors from different levels are fused according to the fusion weight parameters, comprehensively integrating the advantages of feature maps from different levels. The target scene feature vector obtained through gated fusion more accurately reflects the essential features of the target scene, providing stronger support for subsequent recognition tasks and reducing the false positive rate.
[0044] In some embodiments of the invention, in step S402, such as Figure 7 As shown, low-rank attention calculation is performed based on the hierarchical feature maps and the kernel matrix to obtain attention feature maps for each level, specifically including the following steps S4021-S4022: S4021: Perform depthwise convolution on the attention feature map of each level to obtain the intermediate feature map of each level; S4022: Perform pointwise convolution and normalization processing on the intermediate feature maps of each level to obtain the fusion weight parameters of each level.
[0045] Understandably, in image processing tasks, for an image containing multiple objects and backgrounds (such as a shop front photo submitted by a user for financial loan verification), depthwise convolution can extract local features such as object edges and textures from different color channels (e.g., RGB channels), which helps in the effective processing of features at different levels. Pointwise convolution uses a 1x1 convolution kernel and can perform linear transformations along the channel dimension, enabling information interaction and fusion between different channels. When performing pointwise convolution processing on intermediate feature maps, the model can learn the importance and correlation between features from different channels, thereby generating more representative feature representations.
[0046] In one specific embodiment, the fusion weight parameters of the gating mechanism The calculation is implemented using split convolution. The server first captures spatial correlation through a 3×3 deep convolutional network to obtain intermediate feature maps of each level. Then, it adjusts the channel dimension through a 1×1 pointwise convolutional network and obtains the fusion weight parameters of each level after normalization.
[0047] This embodiment performs depthwise convolutions on attention feature maps at different levels, enriching feature diversity by incorporating local information from different levels into the intermediate features. Pointwise convolutions can combine and enhance category-related features from different channels, highlighting key features and suppressing irrelevant features. The fusion weight parameters can automatically adjust the weights of features at different levels according to the characteristics of the scene, making the fused features more reasonable.
[0048] S50: Match the target recognition scene from the preset scene database according to the target scene feature vector, and determine the target recognition scene as the scene recognition result corresponding to the image to be processed.
[0049] Understandably, the server matches the target scene from a pre-defined scene database based on the target scene feature vector. This database is a pre-established structured dataset storing scene feature vectors and their corresponding scene labels for different scenarios, serving as a benchmark for scene matching for the server. The target scene is the one found in the pre-defined scene database that has the highest similarity to the scene features of the image to be processed. The scene recognition result refers to the recognition, classification, and description results of the image to be processed.
[0050] In some embodiments of the invention, such as Figure 8 As shown, a specific target recognition scene matching scheme is provided. In step S50, that is, matching the target recognition scene from the preset scene database according to the target scene feature vector, the specific steps include the following steps S501-S502: S501: Calculate the similarity between the candidate scene features of each candidate scene in the preset scene database and the target scene feature vector to obtain the scene similarity of each candidate scene; S502: Determine the target recognition scene based on the candidate scene feature with the highest scene similarity.
[0051] Understandably, the pre-defined scene database stores multiple candidate scenes and their associated candidate scene features. A candidate scene refers to an existing scene description or label generated based on historical data. A candidate scene feature is the scene feature vector corresponding to the candidate scene, i.e., pre-calculated environmental reference features, which can specifically be geotagged multi-scale scene features. Scene similarity refers to the similarity (range 0-1) between the candidate scene features and the target scene feature vector, and can be cosine similarity. Each candidate scene corresponds to a candidate scene feature and a scene similarity score. The server sorts the scene similarities of all candidate scenes and determines the candidate scene corresponding to the candidate scene feature with the highest scene similarity score as the target recognition scene.
[0052] Furthermore, before calculating the similarity between the candidate scene features of each candidate scene in the preset scene database and the target scene feature vector, the server first constructs the preset scene database. First, the server acquires historical scene reference images for each candidate scene. Based on these historical reference images, it performs multi-scale feature map extraction, low-rank attention analysis based on kernel matrices, and gated fusion processing to obtain the candidate scene features associated with each candidate scene. Then, the server generates the preset scene database based on all candidate scenes and the associated candidate scene features.
[0053] This embodiment calculates similarity to find the candidate scene features that are closest to the target scene feature vector from a preset scene database, making the identification of the target scene more accurate.
[0054] In practical applications, taking risk control scenarios in the financial sector as an example, a pre-set scenario database contains 200 stores as candidate scenarios, storing multi-scale features of these 200 stores as candidate scenario features. The image submitted by the user during loan approval is a 1920×1080 resolution photo of the store entrance taken with a mobile phone. After pyramid feature extraction, three levels of feature maps are generated: Level 1 (L1) with a resolution of 240×135 and 256 landmarks; Level 2 (L2) with a resolution of 120×68 and 128 landmarks; and Level 3 (L3) with a resolution of 60×34 and 64 landmarks. During low-rank attention calculation, cross-scale attention calculation is performed for different levels. The attention between L1 and L2 focuses on matching the store's brand logo with the store name font, resulting in the Level 1 (L1) attention feature map. The attention between L2 and L3 associates the store layout with the corridor location, resulting in the Level 2 (L2) attention feature map. During the gating fusion process, irrelevant regions in the third level (L3) that are obscured by pedestrians are automatically suppressed to obtain the target scene feature vector. Based on the target scene feature vector, the target scene is matched from the preset scene database as "Uniqlo 3F-12".
[0055] As can be seen, in the above scheme, this embodiment avoids the problem of computational explosion in cross-scale fully connected attention by extracting multi-scale feature maps and using low-rank attention analysis based on kernel matrices, thereby reducing computational complexity and improving the efficiency of image scene recognition. Simultaneously, it reduces the conflict rate of multi-scale features through a gating fusion mechanism, enhancing scene adaptability and improving the accuracy of image scene recognition.
[0056] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0057] In one embodiment, an image scene recognition device is provided, which corresponds one-to-one with the image scene recognition methods described in the above embodiments. For example... Figure 9 As shown, the image scene recognition device includes a preprocessing module 101, a feature extraction module 102, an attention analysis module 103, a gating fusion module 104, and a scene matching module 105. Detailed descriptions of each functional module are as follows: Preprocessing module 101 is used to acquire the image to be processed, preprocess the image to be processed, and obtain image tensor data; The feature extraction module 102 is used to perform feature extraction processing on the image tensor data to obtain a multi-scale feature map, wherein the multi-scale feature map includes at least two levels of hierarchical feature maps. Attention analysis module 103 is used to perform low-rank attention analysis based on kernel matrix on the feature map of each level to obtain the attention feature map of each level. The gated fusion module 104 is used to perform gated fusion processing on the attention feature maps of all levels to obtain the target scene feature vector; The scene matching module 105 is used to match the target recognition scene from the preset scene database according to the target scene feature vector, and determine the target recognition scene as the scene recognition result corresponding to the image to be processed.
[0058] In one embodiment, the feature extraction module 102 is specifically used for: The image tensor data is segmented and embedded to obtain multiple image block embedding features; Hierarchical downsampling and strided convolution processing are performed on all the image patch embedding features to obtain multi-scale feature maps.
[0059] In one embodiment, the attention analysis module 103 is specifically used for: Cluster analysis is performed on the feature map of each level, and the landmark feature matrix of each level is determined based on the cluster centers obtained from the cluster analysis. A similarity analysis is performed on the feature matrix of the landmarks at each level to obtain the kernel matrix of each level; Low-rank attention processing is performed based on the hierarchical feature maps and kernel matrix of the first and second levels to obtain the attention feature map of the first level; low-rank attention processing is performed based on the hierarchical feature maps and kernel matrix of the second and third levels to obtain the attention feature map of the second level; low-rank attention processing is performed based on the hierarchical feature maps and kernel matrix of the first and third levels to obtain the attention feature map of the third level.
[0060] In one embodiment, the attention analysis module 103 is further configured to: The query vector is determined based on the hierarchical feature map of the first level; The initial key vector and initial value vector are determined based on the hierarchical feature map of the second level; The intermediate vector is determined based on the kernel matrix of the second level; The key vector is determined based on the initial key vector and the intermediate vector, and the value vector is determined based on the initial value vector and the intermediate vector; Low-rank attention calculation is performed based on the query vector, the key vector, and the value vector to obtain the attention feature map of the first level.
[0061] In one embodiment, the gating fusion module 104 is specifically used for: Channel compression is performed on the attention feature map at each level to obtain the dimensionality-reduced feature vectors at each level. Gated convolution is performed on the attention feature map of each level to obtain the fusion weight parameters of each level; The reduced feature vector is subjected to feature fusion processing based on the fusion weight parameters of all levels to obtain the target scene feature vector.
[0062] In one embodiment, the gating fusion module 104 is further configured to: The attention feature map at each level is subjected to depthwise convolution to obtain the intermediate feature map at each level. The intermediate feature maps at each level are subjected to pointwise convolution and normalization to obtain the fusion weight parameters for each level.
[0063] In one embodiment, the scene matching module 105 is specifically used for: The similarity between the candidate scene features of each candidate scene in the preset scene database and the target scene feature vector is calculated to obtain the scene similarity of each candidate scene. The target recognition scene is determined based on the candidate scene features with the highest scene similarity.
[0064] This invention provides an image scene recognition device that avoids the computational explosion problem of cross-scale fully connected attention by extracting multi-scale feature maps and using low-rank attention analysis based on kernel matrices, thereby reducing computational complexity and improving image scene recognition efficiency. Simultaneously, a gated fusion mechanism reduces the conflict rate of multi-scale features, enhancing scene adaptability and improving image scene recognition accuracy.
[0065] Specific limitations regarding the image scene recognition device can be found in the limitations of the intelligent question-answering method described above, and will not be repeated here. Each module in the aforementioned image scene recognition device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0066] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 10As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements the functions or steps of an image scene recognition method on the server side.
[0067] In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 11 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface is used to communicate with an external server via a network connection. When executed by the processor, the computer program implements the functions or steps of a client-side image scene recognition method. In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps: The image to be processed is acquired, and the image to be processed is preprocessed to obtain image tensor data; The image tensor data is subjected to feature extraction processing to obtain a multi-scale feature map, which includes at least two levels of hierarchical feature maps. Low-rank attention analysis based on kernel matrix is performed on the feature map of each level to obtain the attention feature map of each level; Gated fusion processing is performed on the attention feature maps at all levels to obtain the target scene feature vector; The target scene is matched from the preset scene database based on the target scene feature vector, and the target scene is determined as the scene recognition result corresponding to the image to be processed.
[0068] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor: The image to be processed is acquired, and the image to be processed is preprocessed to obtain image tensor data; The image tensor data is subjected to feature extraction processing to obtain a multi-scale feature map, which includes at least two levels of hierarchical feature maps. Low-rank attention analysis based on kernel matrix is performed on the feature map of each level to obtain the attention feature map of each level; Gated fusion processing is performed on the attention feature maps at all levels to obtain the target scene feature vector; The target scene is matched from the preset scene database based on the target scene feature vector, and the target scene is determined as the scene recognition result corresponding to the image to be processed.
[0069] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0070] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0071] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0072] It should be noted that any AI models, software tools, or components not belonging to this company appearing in the embodiments of this application are merely illustrative examples and do not represent actual use. All user personal information involved in the embodiments of this application has been authorized (with the knowledge and consent) by the relevant parties or has been fully authorized by all parties, and the executing entity may obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with relevant laws and regulations and do not violate public order and good morals.
[0073] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. An image scene recognition method, characterized in that, include: The image to be processed is acquired, and the image to be processed is preprocessed to obtain image tensor data; The image tensor data is subjected to feature extraction processing to obtain a multi-scale feature map, which includes at least two levels of hierarchical feature maps. Low-rank attention analysis based on kernel matrix is performed on the feature map of each level to obtain the attention feature map of each level; Gated fusion processing is performed on the attention feature maps at all levels to obtain the target scene feature vector; The target scene is matched from the preset scene database based on the target scene feature vector, and the target scene is determined as the scene recognition result corresponding to the image to be processed.
2. The image scene recognition method as described in claim 1, characterized in that, The step of performing feature extraction processing on the image tensor data to obtain a multi-scale feature map includes: The image tensor data is segmented and embedded to obtain multiple image block embedding features; Hierarchical downsampling and strided convolution processing are performed on all the image patch embedding features to obtain multi-scale feature maps.
3. The image scene recognition method as described in claim 1, characterized in that, The multi-scale feature map includes hierarchical feature maps of the first, second, and third levels; The step of performing low-rank attention analysis based on the kernel matrix on the feature map of each level to obtain the attention feature map of each level includes: Cluster analysis is performed on the feature map of each level, and the landmark feature matrix of each level is determined based on the cluster centers obtained from the cluster analysis. A similarity analysis is performed on the feature matrix of the landmarks at each level to obtain the kernel matrix of each level; Low-rank attention processing is performed based on the hierarchical feature maps and kernel matrix of the first and second levels to obtain the attention feature map of the first level; low-rank attention processing is performed based on the hierarchical feature maps and kernel matrix of the second and third levels to obtain the attention feature map of the second level; low-rank attention processing is performed based on the hierarchical feature maps and kernel matrix of the first and third levels to obtain the attention feature map of the third level.
4. The image scene recognition method as described in claim 3, characterized in that, The step of performing low-rank attention calculation based on the hierarchical feature maps and kernel matrix of the first and second levels to obtain the attention feature map of the first level includes: The query vector is determined based on the hierarchical feature map of the first level; The initial key vector and initial value vector are determined based on the hierarchical feature map of the second level; The intermediate vector is determined based on the kernel matrix of the second level; The key vector is determined based on the initial key vector and the intermediate vector, and the value vector is determined based on the initial value vector and the intermediate vector; Low-rank attention calculation is performed based on the query vector, the key vector, and the value vector to obtain the attention feature map of the first level.
5. The image scene recognition method as described in claim 1, characterized in that, The gating fusion process of the attention feature maps at all levels to obtain the target scene feature vector includes: Channel compression is performed on the attention feature map at each level to obtain the dimensionality-reduced feature vectors at each level. Gated convolution is performed on the attention feature map of each level to obtain the fusion weight parameters of each level; The reduced feature vector is subjected to feature fusion processing based on the fusion weight parameters of all levels to obtain the target scene feature vector.
6. The image scene recognition method as described in claim 5, characterized in that, The gated convolution process is performed on the attention feature map at each level to obtain the fusion weight parameters for each level, including: The attention feature map at each level is subjected to depthwise convolution to obtain the intermediate feature map at each level. The intermediate feature maps at each level are subjected to pointwise convolution and normalization to obtain the fusion weight parameters for each level.
7. The image scene recognition method as described in claim 1, characterized in that, The step of matching the target recognition scene from the preset scene database based on the target scene feature vector includes: The similarity between the candidate scene features of each candidate scene in the preset scene database and the target scene feature vector is calculated to obtain the scene similarity of each candidate scene. The target recognition scene is determined based on the candidate scene features with the highest scene similarity.
8. An image scene recognition device, characterized in that, include: The preprocessing module is used to acquire the image to be processed, preprocess the image to be processed, and obtain image tensor data; The feature extraction module is used to perform feature extraction processing on the image tensor data to obtain a multi-scale feature map, wherein the multi-scale feature map includes at least two levels of hierarchical feature maps. The attention analysis module is used to perform low-rank attention analysis based on the kernel matrix on the feature map of each level to obtain the attention feature map of each level. The gated fusion module is used to perform gated fusion processing on the attention feature maps of all levels to obtain the target scene feature vector; The scene matching module is used to match the target recognition scene from a preset scene database based on the target scene feature vector, and determine the target recognition scene as the scene recognition result corresponding to the image to be processed.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the image scene recognition method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the image scene recognition method as described in any one of claims 1 to 7.
