Weight evaluation method based on spatial grid analysis and attention mechanism

By dividing the evidence images into grids and performing weight evaluation, each grid is assigned a different comprehensive weight factor, which solves the problem of poor training results caused by uneven photo quality in existing technologies, improves the accuracy of the image classification model and simplifies shooting requirements.

CN120495791BActive Publication Date: 2025-10-03WUHAN OPTICS VALLEY INFORMATION TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510974370.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-15
Publication Date
2025-10-03
Estimated Expiration
2045-07-15

AI Technical Summary

Technical Problem

The existing automatic classification algorithm for evidence photos has poor training results due to different on-site photography methods and uneven photo quality, which affects the accuracy of the image classification model.

Method used

A weight evaluation method based on spatial grid analysis and attention mechanism is adopted. By dividing the evidence images into grids, the attribute information and similarity of each grid are obtained, and a different comprehensive weight factor is assigned to each grid for training the image classification model.

Benefits of technology

It improves the training effect and recognition accuracy of the image classification model, reduces the requirements for the quality of evidence pictures, and simplifies the shooting process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120495791B_ABST
    Figure CN120495791B_ABST
Patent Text Reader

Abstract

This application proposes a weight evaluation method based on spatial grid analysis and attention mechanism, which relates to the field of image processing technology, including: obtaining a gridded evidence image and attribute information of the evidence image, wherein the attribute information includes the position information of each grid; determining the grid weight of each grid in the evidence image based on the attribute information of the evidence image; determining the attention weight of each grid in the evidence image based on the similarity between each grid in the evidence image and a reference grid; and determining the comprehensive weight factor of each grid in the evidence image based on the grid weight and attention weight of each grid in the evidence image. Using the weight evaluation method of this application to evaluate the weight of the evidence image, and training the image classification model based on the gridded evidence image and the comprehensive weight factor of each grid can improve the training effect of the image classification model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a weight evaluation method based on spatial grid analysis and attention mechanism. Background Art

[0002] To meet the needs of land change surveys, on-site evidence photography is often used to collect evidence. Field investigators must visit the site of the proposed evidence area, take photos, and fill in information. These photos serve as crucial information for verification. After the photos are taken, their attributes must be verified. This is a time-sensitive and demanding task, and the interpretation of the same photo can vary due to individual reviewer experience. An automatic classification algorithm for evidence photos can automatically identify photo types based on unified rules, improving review efficiency and reducing the impact of human factors on photo attribute interpretation.

[0003] However, automatic classification algorithms for evidence photos typically use the original photos as training samples. Because the quality of photos taken by on-site witnesses varies, the quality of these photos varies. Using these photos directly as training samples for image classification models often yields poor results. Summary of the Invention

[0004] In view of this, this application proposes a weight evaluation method based on spatial grid analysis and attention mechanism.

[0005] In a first aspect, the present application provides a weight evaluation method based on spatial grid analysis and attention mechanism, including:

[0006] Obtaining a gridded evidence image and attribute information of the evidence image, wherein the attribute information includes position information of each grid;

[0007] Determining a grid weight of each grid in the evidence picture according to the attribute information of the evidence picture;

[0008] Determining an attention weight for each grid in the evidence image based on a similarity between each grid in the evidence image and a reference grid;

[0009] The comprehensive weight factor of each grid in the evidence picture is determined according to the gridding weight and attention weight of each grid in the evidence picture.

[0010] In one embodiment, the attribute information further includes shooting pitch angle information; and determining the grid weight of each grid in the evidence image based on the attribute information of the evidence image includes:

[0011] Determining a position weight of each grid in the evidence picture according to the position information of each grid in the evidence picture, wherein the position weight of the grid in the evidence picture is inversely correlated with the center distance of the grid, and the center distance of the grid is the distance between the grid and the center of the evidence picture;

[0012] Determining the pitch angle weight of each grid in the evidence picture according to the shooting pitch angle information of the evidence picture and the position information of each grid in the evidence picture;

[0013] The product of the position weight and the pitch angle weight of each grid in the evidence picture is used as the grid weight of each grid in the evidence picture.

[0014] In one embodiment, the attribute information further includes clarity information of each grid; and determining the gridding weight of each grid in the evidence image based on the attribute information of the evidence image includes:

[0015] Determining a position weight of each grid in the evidence picture according to the position information of each grid in the evidence picture, wherein the position weight of the grid in the evidence picture is inversely correlated with the center distance of the grid, and the center distance of the grid is the distance between the grid and the center of the evidence picture;

[0016] Determining a clarity weight of each grid in the evidence picture according to clarity information of each grid in the evidence picture;

[0017] The product of the position weight and the clarity weight of each grid in the evidence picture is used as the grid weight of each grid in the evidence picture.

[0018] In one embodiment, the attribute information further includes shooting pitch angle information and clarity information of each grid; and determining the gridding weight of each grid in the evidence image based on the attribute information of the evidence image includes:

[0019] Determining a position weight of each grid in the evidence picture according to the position information of each grid in the evidence picture, wherein the position weight of the grid in the evidence picture is inversely correlated with the center distance of the grid, and the center distance of the grid is the distance between the grid and the center of the evidence picture;

[0020] Determining the pitch angle weight of each grid in the evidence picture according to the shooting pitch angle information of the evidence picture and the position information of each grid in the evidence picture;

[0021] Determining a clarity weight of each grid in the evidence picture according to clarity information of each grid in the evidence picture;

[0022] The product of the position weight, the pitch angle weight and the clarity weight of each grid in the evidence picture is used as the grid weight of each grid in the evidence picture.

[0023] In one embodiment, determining the pitch angle weight of each grid in the evidence image according to the position information and shooting pitch angle information of each grid in the evidence image includes:

[0024] Divide the evidence image into an upper half area and a lower half area, and determine the area where each grid is located based on the position information of each grid in the evidence image;

[0025] Determining a weight change trend according to the shooting pitch angle of the evidence picture;

[0026] The pitch angle weight of each grid in the evidence picture is determined according to the weight change trend, the area where each grid in the evidence picture is located, and the position information.

[0027] In one embodiment, obtaining the gridded evidence image includes:

[0028] Obtaining size information of the evidence image and size information of the pre-divided grid, wherein the divided grid is a positive direction grid;

[0029] Determining the number of grids according to the size information of the evidence image and the size information of the pre-divided grids;

[0030] When the number of grids is not an integer, the edges of the evidence picture are filled according to the size information of the evidence picture and the size information of the pre-divided grids, so that the evidence picture is divided into an integer number of grids.

[0031] In one embodiment, determining the attention weight of each grid in the evidence image according to the similarity between each grid in the evidence image and a reference grid includes:

[0032] Obtain the type of evidence to which the evidence picture belongs;

[0033] Determining a reference grid representing the type of evidence according to the type of evidence to which the evidence picture belongs;

[0034] Calculating the dot product similarity between each grid in the evidence image and the reference grid;

[0035] The attention weight of each grid is determined according to the dot product similarity between each grid in the evidence image and the reference grid.

[0036] In a second aspect, the present application provides a method for training an image classification model, comprising:

[0037] Obtaining a plurality of sample evidence images divided into grids and a comprehensive weight factor of each grid in the sample evidence images, wherein the comprehensive weight factor of each grid in the sample evidence images is determined using the weight evaluation method based on spatial grid analysis and attention mechanism as described in the first aspect;

[0038] The comprehensive weight factor of each grid of the sample evidence picture is used as the characteristic band of the sample evidence picture and superimposed on the sample evidence picture to form a training sample set;

[0039] The image classification model is trained using the training sample set to obtain a trained target image classification model.

[0040] In a third aspect, the present application also provides an electronic device comprising a processor and a memory; the memory stores a computer program, wherein when the computer program is executed by the processor, it implements the weight evaluation method based on spatial grid analysis and attention mechanism as described in the first aspect, or the training method of the image classification model as described in the second aspect.

[0041] In a fourth aspect, the present application also provides a computer storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, it implements the weight evaluation method based on spatial grid analysis and attention mechanism as described in the first aspect, or the training method of the image classification model as described in the second aspect.

[0042] The weight evaluation method based on spatial grid analysis and attention mechanism in this application has the following beneficial effects compared with related technologies:

[0043] 1. The weight evaluation method based on spatial grid analysis and attention mechanism of the present application, by gridding the evidence photo, obtaining the attribute information of the evidence picture after gridding, determining the grid weight of each grid in the evidence picture based on the attribute information of the evidence picture, and then determining the attention weight of each grid in the evidence picture according to the similarity between each grid in the evidence picture and the reference grid, and determining the comprehensive weight factor of each grid in the evidence picture according to the grid weight and attention weight of each grid in the evidence picture, thereby assigning different weights to each grid of the evidence image based on factors such as the attribute information of the evidence picture and spatial attention, performing accurate weight evaluation on each grid of the evidence photo, and enhancing the key interpretation information in the evidence image. The weight evaluation method of the present application is used to perform weight evaluation on the evidence image, and the image classification model is trained based on the gridded evidence image and the comprehensive weight factor of each grid, which can improve the training effect of the image classification model.

[0044] 2. Because the weight assessment method based on spatial grid analysis and an attention mechanism in this application can assign different weights to each grid in the evidence image, accurate weight assessment is performed on each grid in the evidence photo, enhancing the key interpretation information in the evidence image. Therefore, the solution in this application has lower quality requirements for the evidence image, and the corresponding evidence image shooting requirements are also lower, thereby reducing the difficulty of obtaining evidence images. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0046] Figure 1 Schematic diagram of a flow chart of a weight evaluation method based on spatial grid analysis and attention mechanism in one embodiment of the present application;

[0047] Figure 2 This is a flow chart of step S102 in one embodiment of the present application;

[0048] Figure 3 Schematic diagram of the process of training an image classification model in one embodiment of the present application;

[0049] Figure 4 Schematic diagram of the structure of an electronic device in one embodiment of the present application. DETAILED DESCRIPTION

[0050] The following will be combined with the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0051] As mentioned in the background, to meet the needs of land surveys, land change surveys typically use on-site evidence photography to collect evidence. Field investigators must visit the site of the proposed evidence area, take photos, and fill in information. These photos serve as crucial information for verification. After the photos are taken, their attributes must be verified. This verification process is time-sensitive and demanding, and the interpretation of the same photo can vary due to individual reviewer experience. An automatic classification algorithm for evidence photos can automatically identify photo types based on unified rules, improving the efficiency of photo review and reducing the impact of human factors on photo attribute interpretation.

[0052] However, automatic classification algorithms for evidence photos typically use the original photos as training samples. Because the quality of photos taken by on-site witnesses varies, the quality of these photos varies. Using these photos directly as training samples for image classification models often yields poor results.

[0053] Based on this, in some embodiments, such as Figure 1 As shown, the present application provides a weight evaluation method based on spatial grid analysis and attention mechanism, and the weight evaluation method based on spatial grid analysis and attention mechanism includes the following steps S101 to S104.

[0054] S101: Obtaining a gridded evidence picture and attribute information of the evidence picture, wherein the attribute information includes location information of each grid.

[0055] The evidence image is a photograph of the scene being used for evidence. Gridding involves dividing the evidence image into several sections using grids of equal size. After obtaining a gridded image, detailed information indicating the location of each grid in the image, such as its specific spatial coordinates and row and column distribution, can be obtained.

[0056] S102: Determine the grid weight of each grid in the evidence picture according to the attribute information of the evidence picture.

[0057] Understandably, a single evidence image typically contains multiple types of information, such as the sky, roads, houses, and farmland. However, each evidence image corresponds to a single evidence type. Therefore, accurately identifying the evidence type of an evidence image helps train image classification models. Based on preset weight calculation rules, grid weights are determined based on the evidence image's attribute information (such as the location of each grid). This allows for precise weight assessment of each grid in the evidence image, enhancing key interpretation information within the evidence image and improving the accuracy of evidence type recognition.

[0058] For example, the weight of each grid can be determined based on its distance from a designated reference point, using an inverse distance weighting method. This means that grids closer to the reference point have higher weights, and vice versa. Alternatively, grids can be ranked based on their importance in the rows and columns they occupy. Pre-set weight coefficients can be assigned to different rows or columns, and then combined with the specific position of the grid within the row or column to quantitatively determine the grid weight of each grid.

[0059] S103: Determine the attention weight of each grid in the evidence image based on the similarity between each grid in the evidence image and the reference grid.

[0060] The reference grid is a typical sub-image that is most capable of determining the type of the photo. The reference grid may be a grid in the currently processed evidence image or a grid in a selected specific evidence image.

[0061] It can be understood that since the reference grid is the most representative sub-image that can best identify the photo type, the more similar the grid is to the reference grid, the more likely it is to serve as evidence for identifying the photo type, and thus receive a higher attention weight. Specifically, the baseline features of the reference grid can be determined first. Based on these features, corresponding features (such as pixel features and texture features) of each target grid can be extracted. Metrics such as Euclidean distance, cosine similarity, or structural similarity (SSIM) are then used to calculate the degree of feature match between each grid and the reference grid, thereby determining similarity. To convert similarity into attention weight, normalization can be performed to map the similarity values ​​to the [0, 1] range, or the similarity value can be directly used as a weight coefficient, giving grids with more similar features to the reference grid a higher attention weight. This gives them greater priority in subsequent analysis, thereby focusing on key similar areas.

[0062] S104: Determine the comprehensive weight factor of each grid in the evidence image based on the grid weight and attention weight of each grid in the evidence image.

[0063] It can be understood that by determining the comprehensive weight factor based on the grid weight and attention weight of each grid in the evidence image, we ultimately obtain a comprehensive weight factor that comprehensively reflects the grid attributes and the representativeness of the evidence type (the higher the similarity with the reference image, the more representative the evidence type). This comprehensive weight factor can enhance key image interpretation information and improve the accuracy of the image classification algorithm. Specifically, by calculating the comprehensive weight factor, the initial weight of each part of the image is adjusted, increasing the weight of key areas and decreasing the weight of non-key areas. This improves the training effect of the image classification model, resulting in a trained image classification model with higher classification accuracy.

[0064] The above-mentioned weight evaluation method based on spatial gridding analysis and attention mechanism, by gridding the evidence photo, obtains the attribute information of the evidence picture after gridding, determines the gridding weight of each grid in the evidence picture based on the attribute information of the evidence picture, and then determines the attention weight of each grid in the evidence picture according to the similarity between each grid in the evidence picture and the reference grid, and determines the comprehensive weight factor of each grid in the evidence picture according to the gridding weight and attention weight of each grid in the evidence picture, so as to assign different weights to each grid of the evidence image based on factors such as the attribute information of the evidence picture and spatial attention, perform accurate weight evaluation on each grid of the evidence photo, enhance the key interpretation information in the evidence image, and use the weight evaluation method of this application to perform weight evaluation on the evidence image, and train the image classification model based on the gridded evidence image and the comprehensive weight factor of each grid, which can improve the training effect of the image classification model. Furthermore, because the weight assessment method based on spatial grid analysis and an attention mechanism in this application can assign different weights to each grid in the evidence image, accurate weight assessment can be performed on each grid in the evidence photo, enhancing the key interpretation information in the evidence image. Therefore, this application's solution has lower quality requirements for the evidence image, and the corresponding evidence image shooting requirements are also lower, thereby reducing the difficulty of obtaining evidence images.

[0065] In some embodiments, the attribute information also includes shooting pitch angle information. In step S102, the grid weight of each grid in the evidence image is determined based on the attribute information of the evidence image, including the following steps: determining the position weight of each grid in the evidence image based on the position information of each grid in the evidence image; determining the pitch angle weight of each grid in the evidence image based on the shooting pitch angle information of the evidence image and the position information of each grid in the evidence image; and taking the product of the position weight and the pitch angle weight of each grid in the evidence image as the grid weight of each grid in the evidence image. The position weight of a grid in the evidence image is inversely correlated with the center distance of the grid, where the center distance of the grid is the distance of the grid from the center of the evidence image. That is, different weights are assigned to the grid based on its location: if the grid is located on the periphery of the image, the grid weight is reduced; if the grid is located in the center of the image, the grid weight is increased, and the closer to the center of the image, the higher the weight.

[0066] For example, the calculation formula of the position weight Wpos(i,j) can be as follows:

[0067]

[0068] Among them, i and j represent the index of the grid in the vertical and horizontal directions respectively. N w Indicates the number of grids in the horizontal direction, N h Indicates the number of grid cells in the vertical direction.

[0069] The shooting pitch angle information of the evidence picture is the pitch angle θ when the shooting device shoots (θ>0 when shooting from above, θ<0 when shooting from below). For example, when shooting with a mobile phone, the pitch angle θ when the mobile phone takes the photo can be obtained through the IMU sensor of the mobile phone. Since the pitch angle will cause perspective deformation at different positions of the picture, after determining the pitch angle, different weights can be assigned to the grids according to the pitch angle and the grid position to determine the pitch angle weight of each grid in the evidence picture. The product of the position weight of each grid in the evidence picture and the pitch angle weight is used as the grid weight of each grid in the evidence picture. The grid weight in this embodiment takes into account the grid position and the shooting pitch angle at the same time, so that the obtained grid weight setting can be more reasonable, thereby effectively quantifying the actual effectiveness of different grids in the evidence picture.

[0070] In other embodiments, the attribute information also includes clarity information of each grid. In step S102, the grid weight of each grid in the evidence image is determined based on the attribute information of the evidence image, including: determining the position weight of each grid in the evidence image based on the position information of each grid in the evidence image; determining the clarity weight of each grid in the evidence image based on the clarity information of each grid in the evidence image; and taking the product of the position weight and the clarity weight of each grid in the evidence image as the grid weight of each grid in the evidence image.

[0071] Among them, similarly, the position weight of the grid in the evidence picture is inversely correlated with the center distance of the grid, and the center distance of the grid is the distance between the grid and the center of the evidence picture. The position weight of this embodiment can also be calculated using the position weight calculation formula of the aforementioned embodiment. After obtaining the clarity information of each grid in the evidence picture, the weight of the grid that is blurred or noisy in the picture can be reduced, and the weight of the clear grid in the picture can be increased. Based on this, the corresponding clarity weight assignment rules can be pre-set, and then the clarity weight of each grid can be determined based on the clarity weight assignment rules and the clarity information of each grid. Exemplarily, the image clarity calculation formula can be:

[0072]

[0073] Among them, f(x,y) represents the pixel value of the pixel point x,y corresponding to the image f, and D(f) represents the image clarity.

[0074] Calculate the resolution of each grid The weights are as follows:

[0075]

[0076] Where D(i,j) represents the clarity of each grid, and max(D) represents the maximum clarity of all grids.

[0077] It is understood that after determining the position weight and clarity weight of each grid in the evidence image, the product of the position weight and the clarity weight of each grid in the evidence image can be used as the grid weight of each grid in the evidence image. Because the product fusion method is suitable for scenarios where multiple factors need to be highlighted simultaneously, the grid weight in this embodiment takes into account both grid position and clarity, making the resulting grid weight setting more reasonable and effectively quantifying the actual effectiveness of different grids in the evidence image.

[0078] In some other embodiments, the attribute information also includes shooting pitch angle information and clarity information of each grid. Figure 2 As shown, in step S102, the grid weight of each grid in the evidence picture is determined according to the attribute information of the evidence picture, including the following steps S201 to S204.

[0079] S201: Determine the position weight of each grid in the evidence image based on the position information of each grid in the evidence image.

[0080] The position weight of a grid in the evidence image is inversely correlated with the center distance of the grid, where the center distance of the grid is the distance from the center of the evidence image. Similarly, the position weight of each grid in this embodiment can also be calculated using the position weight calculation formula of the aforementioned embodiment.

[0081] S202: Determine the pitch angle weight of each grid in the evidence picture according to the shooting pitch angle information of the evidence picture and the position information of each grid in the evidence picture.

[0082] The shooting pitch angle information of the evidence image is the pitch angle θ of the camera when shooting (i.e., the angle between the lens and the horizontal plane, θ>0 when shooting from above, and θ<0 when shooting from below). Because the pitch angle can cause perspective distortion at different positions of the picture, after determining the pitch angle, different weights can be assigned to the grids based on the pitch angle and grid position. For example, the evidence image can be divided into different areas in the up and down direction, and then the weight change rules of each area can be determined according to the pitch angle. The pitch angle weight of each grid in the evidence image is determined based on the weight change rules of each area and the grid position.

[0083] S203: Determine the clarity weight of each grid in the evidence image based on the clarity information of each grid in the evidence image.

[0084] After obtaining the clarity information of each grid in the evidence image, the weight of the grids that are blurry or noisy in the image can be reduced, and the weight of the grids that are clear in the image can be increased. Based on this, the corresponding clarity weight assignment rules can be pre-set, and then the clarity weight of each grid can be determined based on the clarity weight assignment rules and the clarity information of each grid. For example, the image clarity calculation formula can be:

[0085]

[0086] Among them, f(x,y) represents the pixel value of the pixel point x,y corresponding to the image f, and D(f) represents the image clarity.

[0087] Calculate the resolution of each grid The weights are as follows:

[0088]

[0089] Where D(i,j) represents the clarity of each grid, and max(D) represents the maximum clarity of all grids.

[0090] S204: The product of the position weight, pitch angle weight and clarity weight of each grid in the evidence image is used as the grid weight of each grid in the evidence image.

[0091] Get the position weight of each grid , pitch angle weight and clarity weight After that, we can multiply the three together, that is , thereby determining the grid weight of each grid in the evidence image. The grid weight determined in this embodiment simultaneously highlights the position, shooting pitch angle, and clarity of each grid, thereby assigning a grid weight to each grid in the evidence image based on multiple factors, increasing the weight of clear and important areas, and achieving accurate weight assessment of the grid weight, which is conducive to improving the training effect of the subsequent image classification model, and further improving the image classification model's recognition accuracy for the evidence image.

[0092] In some embodiments, the pitch angle weight of each grid in the evidence picture is determined based on the position information and shooting pitch angle information of each grid in the evidence picture, including: dividing the evidence picture into an upper half area and a lower half area, and determining the area where each grid is located based on the position information of each grid in the evidence picture; determining the weight change trend based on the shooting pitch angle of the evidence picture; and determining the pitch angle weight of each grid in the evidence picture based on the weight change trend, the area where each grid is located, and the position information.

[0093] It can be understood that the weight change trend is determined according to the shooting pitch angle θ of the evidence picture (that is, the angle between the lens and the horizontal plane, θ>0 when shooting from above, and θ<0 when shooting from below). When the pitch angle is positive, the lens is tilted upward, the lower half of the picture may be closer to the camera optical axis, and the imaging deformation is smaller. When θ>0, the weight of the upper half of the picture is reduced, and the weight of the lower half is increased, and the closer to the upper edge of the picture, the lower the weight. Correspondingly, when θ<0, the weight of the lower half of the picture is reduced, and the weight of the upper half is increased, and the closer to the lower edge of the picture, the lower the weight. For example, the pitch angle weight The calculation formula can be:

[0094]

[0095] In this embodiment, by determining the shooting pitch angle in the above manner, the impact of the shooting pitch angle on the imaging quality or information reliability of grids in different areas can be accurately quantified, and the impact of the shooting pitch angle on the imaging quality of different areas of the image can be reflected by assigning a weight to the pitch angle of each grid. The shooting pitch angle is introduced into each grid to correct the difference in grid information reliability caused by the shooting angle.

[0096] In some embodiments, in step S101, obtaining a gridded evidence image includes: obtaining size information of the evidence image and size information of pre-divided grids, determining the number of grids based on the size information of the evidence image and the size information of the pre-divided grids; and, if the number of grids is not an integer, padding the edges of the evidence image based on the size information of the evidence image and the size information of the pre-divided grids so that the evidence image is divided into an integer number of grids. The divided grids are positive direction grids.

[0097] The grid size can be pre-set to S×S (e.g. 512×512), and then the width W and height H of the evidence image can be determined. The number of grids can then be determined based on the size information of the evidence image and the size information of the pre-divided grid. The theoretical number of horizontal grids is , the theoretical vertical grid number .

[0098] However, it is understandable that the width W or height H of the evidence image may not be an integer multiple of S. Therefore, the number of grids in the horizontal direction or the number of grids in the vertical direction may not be an integer. If the calculated number of grids is not an integer, it means that direct division will lead to inconsistent grid sizes or there will be areas that cannot be completely divided. At this time, it is necessary to add blank spaces or pixels extended according to the original image content to the edges of the evidence image (such as left and right edges or top and bottom edges) based on the size information of the evidence image and the pre-divided grids, and perform edge filling operations to adjust the size of the evidence image so that the width and height of the evidence image are N respectively. w ×S and N h ×S, to ensure that the image can be evenly divided into Nw ×N h grids, and finally get an integer number of grids of the same size, so that the weight evaluation of each grid can be performed later.

[0099] In some embodiments, in step S103, the attention weight of each grid in the evidence picture is determined based on the similarity between each grid in the evidence picture and the reference grid, including: obtaining the evidence type to which the evidence picture belongs; determining the reference grid representing the evidence type based on the evidence type to which the evidence picture belongs; calculating the dot product similarity between each grid in the evidence picture and the reference grid; and determining the attention weight of each grid based on the dot product similarity between each grid in the evidence picture and the reference grid.

[0100] It can be understood that the evidence type (such as sky, road, house, farmland, etc.) to which the evidence picture belongs is obtained, and the reference grid representing the type is determined based on the typical characteristics of the evidence type. The feature vector of each grid in the evidence picture is dot-producted with the feature vector of the reference grid, and the directional consistency of the two is measured by the dot product value (the larger the dot product value, the smaller the vector angle, the higher the similarity). The dot product similarity of each grid and the reference grid can be calculated using the following formula :

[0101]

[0102] Where R represents the reference grid pixel value matrix, Represents the matrix of grid pixel values ​​to be calculated.

[0103] After determining the dot product similarity between each grid and the reference grid, the spatial attention weight can be calculated based on the dot product similarity :

[0104]

[0105] After determining the attention weight of each grid, the comprehensive weight factor of each grid in the image can be calculated based on the grid weight and attention weight. Based on the attribute information and spatial attention of the evidence image, different weights can be assigned to each grid in the evidence image, and accurate weight evaluation can be performed on each grid in the evidence photo to enhance the key interpretation information in the evidence image. The calculation is as follows:

[0106]

[0107] In some embodiments, the present application also provides a method for training an image classification model, such as Figure 3 As shown, the training method of the image classification model includes the following steps S301 to S303.

[0108] S301: Obtain multiple sample evidence images divided into grids and the comprehensive weight factor of each grid in the sample evidence images.

[0109] The sample evidence images are historical evidence images and can be obtained from a database. After obtaining the sample evidence images, each image can be divided into grids of a preset size according to a unified standard (if a non-integer number of grids is present, edge padding is used to ensure grid regularity). Then, a weight evaluation method based on spatial gridding analysis and an attention mechanism, as in any of the above solutions, is used to determine the comprehensive weight factor for each grid in the sample evidence image.

[0110] S302: The comprehensive weight factor of each grid of the sample evidence picture is used as the characteristic band of the sample evidence picture and superimposed on the sample evidence picture to form a training sample set.

[0111] It can be understood that after obtaining the comprehensive weight factor of each grid in each sample evidence image, the weight value of each grid can be mapped to a single-channel matrix (i.e., a feature band) consistent with the image size, where the value of each pixel in the matrix corresponds to the comprehensive weight factor of the grid in which it is located, and the weight value is adapted to the numerical range of the image through normalization. Subsequently, this feature band is superimposed with the original band of the sample evidence image in the channel dimension to form multi-channel data containing original image information and weight information. Finally, all processed sample images are integrated into a training sample set, so that each sample carries both image content features and grid importance weight features, providing input data that integrates multi-dimensional information for subsequent image classification model training.

[0112] S303: Use the training sample set to train the image classification model to obtain a trained target image classification model.

[0113] In this application, when training an image classification model using a training set of samples, the multi-channel data of each training sample can be standardized and preprocessed, and the dataset can be augmented through random flipping, rotation, and scaling to enhance model generalization. An image classification network suitable for multi-channel input can be pre-selected, the loss function and Adam optimizer defined, and the batch size, maximum number of iterations, and learning rate decay strategy set can be configured. During training, the model extracts features based on the four-channel input. The weighted feature bands guide the network to focus more on grid regions with high overall weights. Classification probabilities are calculated through forward propagation, and network parameters are updated through backpropagation. Classification accuracy and loss values ​​on the training and validation sets are monitored simultaneously. When validation set performance stops improving (to avoid overfitting), an early stopping strategy is implemented and the model parameters are saved. Ultimately, a target image classification model is obtained that integrates image content and grid weight information. This model can prioritize key regions with higher weights when classifying new images, improving classification accuracy and robustness.

[0114] In some embodiments, as Figure 4 As shown, an electronic device 40 provided in an embodiment of the present application includes a processor 41 and a memory 42; the memory 42 stores a computer program, wherein the computer program, when executed by the processor 41, implements the above-mentioned weight evaluation method based on spatial grid analysis and attention mechanism, or implements the above-mentioned training method of the image classification model.

[0115] Specifically, the processor 41 may include, for example, a general-purpose microprocessor 41, an instruction set processor 41 and / or a related chipset and / or a dedicated microprocessor 41 (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 41 may also include an onboard memory 42 for cache purposes. The processor 41 may be a single processing unit or multiple processing units for executing different actions of the method flow according to the embodiments of the present application.

[0116] Memory 42 can be, for example, any medium capable of containing, storing, conveying, disseminating, or transmitting instructions. For example, memory 42 can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, components, or communication media. Specific examples of memory 42 include: magnetic storage devices, such as magnetic tape or hard disk drives (HDDs); optical storage devices, such as compact discs (CD-ROMs); random access memory (RAM) or flash memory; and / or wired or wireless communication links.

[0117] The present application also provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned weight evaluation method based on spatial grid analysis and attention mechanism, or implements the above-mentioned training method of the image classification model. The computer-readable medium may be included in the device / apparatus / system described in the above embodiments; or it may exist independently without being assembled into the device / apparatus / system. The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed, the method of the embodiment of the present application is implemented.

[0118] According to an embodiment of the present application, a computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical cable, radio frequency signals, or any suitable combination thereof.

[0119] Those skilled in the art will understand that the features described in the various embodiments and / or claims of the present application may be combined and / or combined in a variety of ways, even if such combinations or combinations are not explicitly described in the present application. In particular, without departing from the spirit and teachings of the present application, the features described in the various embodiments and / or claims of the present application may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present application. Therefore, the scope of the present application should not be limited to the above-mentioned embodiments, but should be determined not only by the attached claims, but also by the equivalents of the attached claims. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.

Claims

1. A weight evaluation method based on spatial grid analysis and attention mechanism, characterized in that: include: Obtaining a gridded evidence image and attribute information of the evidence image, wherein the attribute information includes position information of each grid; In a case where the attribute information also includes shooting pitch angle information, determining a position weight of each grid in the evidence picture based on the position information of each grid in the evidence picture, wherein the position weight of the grid in the evidence picture is inversely correlated with the center distance of the grid, where the center distance of the grid is the distance of the grid from the center of the evidence picture; determining the pitch angle weight of each grid in the evidence picture based on the shooting pitch angle information of the evidence picture and the position information of each grid in the evidence picture; and taking the product of the position weight of each grid in the evidence picture and the pitch angle weight as the gridding weight of each grid in the evidence picture; In a case where the attribute information further includes shooting pitch angle information and clarity information of each grid, determining a position weight of each grid in the evidence picture based on the position information of each grid in the evidence picture, wherein the position weight of the grid in the evidence picture is inversely correlated with the center distance of the grid, where the center distance of the grid is the distance of the grid from the center of the evidence picture; determining a pitch angle weight of each grid in the evidence picture based on the shooting pitch angle information of the evidence picture and the position information of each grid in the evidence picture; determining a clarity weight of each grid in the evidence picture based on the clarity information of each grid in the evidence picture; and taking the product of the position weight, the pitch angle weight, and the clarity weight of each grid in the evidence picture as the gridding weight of each grid in the evidence picture; Determining an attention weight for each grid in the evidence image based on a similarity between each grid in the evidence image and a reference grid; The comprehensive weight factor of each grid in the evidence picture is determined according to the gridding weight and attention weight of each grid in the evidence picture.

2. The weight evaluation method based on spatial grid analysis and attention mechanism according to claim 1, characterized in that: Determining the pitch angle weight of each grid in the evidence picture according to the position information and shooting pitch angle information of each grid in the evidence picture includes: Divide the evidence image into an upper half area and a lower half area, and determine the area where each grid is located based on the position information of each grid in the evidence image; Determining a weight change trend according to the shooting pitch angle of the evidence picture; The pitch angle weight of each grid in the evidence picture is determined according to the weight change trend, the area where each grid in the evidence picture is located, and the position information.

3. The weight evaluation method based on spatial grid analysis and attention mechanism according to claim 1, characterized in that: The obtaining of the gridded evidence picture includes: Obtaining size information of the evidence image and size information of the pre-divided grid, wherein the divided grid is a positive direction grid; Determining the number of grids according to the size information of the evidence image and the size information of the pre-divided grids; When the number of grids is not an integer, the edges of the evidence picture are filled according to the size information of the evidence picture and the size information of the pre-divided grids, so that the evidence picture is divided into an integer number of grids.

4. The weight evaluation method based on spatial grid analysis and attention mechanism according to claim 1, characterized in that: The determining of the attention weight of each grid in the evidence picture according to the similarity between each grid in the evidence picture and the reference grid includes: Obtain the type of evidence to which the evidence picture belongs; Determining a reference grid representing the type of evidence according to the type of evidence to which the evidence picture belongs; Calculating the dot product similarity between each grid in the evidence image and the reference grid; The attention weight of each grid is determined according to the dot product similarity between each grid in the evidence image and the reference grid.

5. A training method for an image classification model, characterized in that: include: Obtaining a plurality of sample evidence images divided into grids and a comprehensive weight factor of each grid in the sample evidence images, wherein the comprehensive weight factor of each grid in the sample evidence images is determined using the weight evaluation method based on spatial grid analysis and attention mechanism according to any one of claims 1 to 4; The comprehensive weight factor of each grid of the sample evidence picture is used as the characteristic band of the sample evidence picture and superimposed on the sample evidence picture to form a training sample set; The image classification model is trained using the training sample set to obtain a trained target image classification model.

6. An electronic device, characterized in that: It comprises a processor and a memory; the memory stores a computer program, wherein the computer program, when executed by the processor, implements the weight evaluation method based on spatial grid analysis and attention mechanism as described in any one of claims 1 to 4, or the training method of the image classification model as described in claim 5.

7. A computer storage medium, characterized in that A computer program is stored thereon, wherein, when the computer program is executed by a processor, it implements the weight evaluation method based on spatial grid analysis and attention mechanism as described in any one of claims 1 to 4, or the training method of the image classification model as described in claim 5.

Citation Information

Patent Citations

  • Image recognition method and device, equipment and medium

    CN112488062A