Target relation extraction method based on spatial correlation enhancement

By introducing a spatial correlation enhancement mechanism into the visual relationship extraction technology, calculating the spatial correlation vectors between targets and using the attention mechanism, the problem of insufficient utilization of spatial correlation in the existing technology is solved, and the accuracy and performance of visual relationship extraction are significantly improved. .

CN118570446APending Publication Date: 2024-08-30NAT UNIV OF DEFENSE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410678134.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-29
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

Existing visual relationship extraction technology is difficult to effectively utilize the spatial correlation between targets to improve the accuracy of relationship extraction, and lacks explicit modeling and feature enhancement mechanisms for spatial correlation.

Method used

A target relationship extraction method based on spatial correlation enhancement is adopted. By building a visual relationship extraction model, the pre-trained visual model is used to extract image features, calculate the spatial correlation vectors between targets, and introduce an attention mechanism to aggregate and enhance the features, ultimately improving relationship prediction. accuracy.

Benefits of technology

It achieves explicit modeling and feature enhancement of spatial correlations between targets, improves the accuracy and performance of visual relationship extraction, and can more effectively perceive and identify the spatial relationships between targets in images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570446A
    Figure CN118570446A
Patent Text Reader

Abstract

The invention discloses a target relation extraction method based on spatial correlation enhancement, and the method comprises the steps: constructing a visual relation extraction model which comprises a pre-training visual model, a feature enhancement layer and a relation prediction layer; extracting picture features by using a pre-trained visual model; obtaining feature representations of all targets according to the picture features and the target region labels; calculating space correlation vectors of all target pairs; inputting the feature representations of all the targets and the spatial correlation vectors of all the target pairs into a feature enhancement layer to obtain enhanced feature representations of all the targets; inputting the enhanced feature representation of the target pair into a relation prediction layer to obtain a predicted relation probability vector; and calculating and optimizing a relation extraction loss function, training a visual relation extraction model, and performing visual relation extraction by using the visual relation extraction model. According to the method, explicit modeling is carried out on spatial association, target features are innovatively guided to be aggregated by using the spatial association, the target features are enhanced, and high-precision visual relationship extraction is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of deep learning and image processing, and in particular to a target relationship extraction method based on spatial correlation enhancement. Background Art

[0002] Visual relationship extraction is a task in the field of computer vision that aims to identify and understand the relationships between different objects in an image. It involves modeling and inferring spatial, functional, and semantic relationships between objects. Usually the input is an image and the location of the target in the image, and the output is a label or category that describes the relationship between the objects. For example, in an image containing a person and a ball, the visual relationship extraction task can classify the relationship between the person and the ball, such as "holding", "kicking", "touching", etc.

[0003] The value of the visual relationship extraction task lies in improving the computer's understanding and reasoning ability of image scenes, providing support for visual search and other computer vision tasks, and playing an important role in practical applications, such as scene understanding, visual reasoning, visual search, and computer-assisted visual tasks. In visual relationship extraction, there is a strong correlation between the spatial association between objects, such as A is on top of B and C is contained by D, and the semantic relationship between objects. For example, when there are two objects in a "wearing" relationship, they often overlap to a certain extent in space. This is because this relationship usually involves one object being covered or nested by another object, which causes them to have overlapping areas visually. At the same time, this spatial association also conveys semantic information, such as A is part of B or A depends on the existence of B. Therefore, using this spatial association can assist in the recognition of semantic relationships and improve the accuracy of visual relationship extraction. How to introduce the spatial association between objects into the visual relationship extraction algorithm so that it can perceive the spatial relationship between objects and improve its performance is a research path worth exploring. Summary of the invention

[0004] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention discloses a method for extracting target relationships based on spatial association enhancement. The method can identify the relationship between targets in a picture. Compared with the existing method, the method explicitly models the spatial association, introduces the attention mechanism to aggregate and enhance the entity features, and innovatively uses the spatial association to guide the feature aggregation process of the attention mechanism, enhances the features of the target, and realizes high-precision visual relationship extraction.

[0005] The object of the present invention is to achieve a target relationship extraction method based on spatial association enhancement through the following technical solution, the method comprising:

[0006] Step 1: Build a visual relationship extraction model, including a pre-trained visual model, a feature enhancement layer, and a relationship prediction layer;

[0007] Step 2: Use the pre-trained visual model to extract image features;

[0008] Step 3, obtain the feature representation of all targets based on the image features and target area annotations;

[0009] Step 4, calculate the spatial correlation vectors of all target pairs;

[0010] Step 5: Input the feature representations of all targets and the spatial correlation vectors of all target pairs into the feature enhancement layer to obtain enhanced feature representations of all targets;

[0011] Step 6: Input the enhanced feature representation of the target pair into the relationship prediction layer to obtain the predicted relationship probability vector;

[0012] Step 7: Calculate and optimize the relationship extraction loss function, train the visual relationship extraction model, and use the visual relationship extraction model to perform visual relationship extraction.

[0013] The method of extracting image features using a pre-trained visual model includes the following steps:

[0014] The input image is represented as Use the pre-trained visual model to extract the visual features of the input image. The expression is:

[0015] F img =ResNet(x)

[0016] in, Represents the visual features of the image, W and H represent the width and height of the image, d represents the hidden layer dimension of ResNet, and s represents the downsampling multiple of ResNet.

[0017] The method of obtaining feature representations of all targets based on image features and target area annotations includes the following steps:

[0018] According to the target area annotation, the target position is represented as the coordinates of the rectangular box (x i ,y i ,w i ,h i ), where i represents the index of the target, x i and i Indicates the coordinates of the upper left corner of the rectangular box, w i and h i Indicates the width and height of the rectangular box;

[0019] Use the ROIAlign algorithm to map the target area annotation to the space of image features to obtain the visual feature map of the target, which is expressed as:

[0020]

[0021] in, represents the visual feature map of the i-th target, d represents the hidden layer dimension of ResNet, and s o Indicates the output size of ROIAlign;

[0022] Adaptively pool the visual feature map of the i-th target to obtain the feature representation of the i-th target, which is expressed as:

[0023]

[0024] in, Represents the feature representation of the i-th target;

[0025] Visual features are extracted for each target to obtain feature representations of all targets:

[0026]

[0027] in, represents the feature representation of all targets, d represents the hidden layer dimension of ResNet, and n represents the number of targets.

[0028] The calculation of the spatial association vectors of all target pairs comprises the following steps:

[0029] Step 401, calculate the area association vector; for the i-th target and the j-th target, construct a vector with a length of 3 Calculate the IOU of the i-th target and the j-th target; if the IOU of the i-th target and the j-th target is not less than 0.6, then e ij The first element of is assigned to 1, and the other elements are assigned to 0; if the IOU between the i-th target and the j-th target is not less than 0.3 and less than 0.6, then e ij The second element of is assigned to 1, and the other elements are assigned to 0; if the IOU between the i-th target and the j-th target is less than 0.3, then e ij The third element of is assigned a value of 1, and the other elements are assigned a value of 0;

[0030] After assignment, e ij is the area association vector between the i-th target and the j-th target, and the area association vector is calculated for all target pairs;

[0031] Step 402, calculate the direction association vector; for the i-th target and the j-th target, construct a vector with a length of 4 The coordinates of the rectangular box of the i-th target are expressed as (x i ,y i ,w i ,h i ), the coordinates of the rectangular box of the jth target are expressed as (x j ,y j ,w j ,h j ), calculate the angle between the i-th target and the j-th target, the expression is:

[0032]

[0033] Among them, θ ij represents the angle between the i-th target and the j-th target, x i and i Represents the coordinate of the upper left corner of the rectangular box of the i-th target, w i and h i Indicates the width and height of the rectangular box of the i-th target; x j and j The coordinates of the upper left corner of the rectangular box representing the jth target, w j and h j Represents the width and height of the rectangular box of the jth target;

[0034] For ij To assign a value, the expression is:

[0035]

[0036] Among them, s ijk Indicates ij The kth element of ;

[0037] After assignment, s ij is the direction association vector between the i-th target and the j-th target; the direction association vector is calculated for all target pairs;

[0038] Step 403, calculate the spatial correlation vector; the area correlation vector of the i-th target and the j-th target and the direction correlation vector of the i-th target and the j-th target are concatenated to obtain the spatial correlation vector of the i-th target and the j-th target, and the expression is:

[0039] u ij =[e ij ,s ij ]

[0040] Among them, u ij Represents the spatial association vector between the i-th target and the j-th target;

[0041] Compute the spatial association vector for all target pairs.

[0042] The step of inputting the feature representations of all targets and the spatial correlation vectors of all target pairs into the feature enhancement layer to obtain the enhanced feature representations of all targets comprises the following steps:

[0043] Step 501, calculate the semantic attention matrix; construct an n×n matrix A h , for A h To assign a value, the expression is:

[0044]

[0045] Among them, A h,ij Represents the matrix A h The element in the i-th row and j-th column of , softmax is the activation function, represents the feature representation of the i-th target, represents the feature representation of the jth target, d represents the hidden layer dimension of ResNet, is a learnable parameter;

[0046] The matrix A after assignment h is the semantic attention matrix;

[0047] Step 502, calculate the spatial attention matrix; construct an n×n matrix A s , for A s To assign a value, the expression is:

[0048]

[0049] Among them, A s,ij Represents the matrix A s The element in the i-th row and j-th column of , softmax is the activation function, represents the feature representation of the i-th target, represents the feature representation of the jth target, u ij represents the spatial association vector between the i-th target and the j-th target, d represents the hidden layer dimension of ResNet, and is a learnable parameter;

[0050] The matrix A after assignment s is the spatial attention matrix;

[0051] Step 503, calculate the attention matrix; take the bitwise average of the semantic attention matrix and the spatial attention matrix, the expression is:

[0052]

[0053] Among them, A represents the attention matrix, Ah represents the semantic attention matrix, A s represents the spatial attention matrix;

[0054] Step 504, use the attention matrix to aggregate the feature representation of the target to obtain an enhanced feature representation of the target; the expression is:

[0055]

[0056] Among them, g i represents the enhanced feature representation of the i-th target, A ij represents the element in the i-th row and j-th column of the attention matrix A, represents the feature representation of the jth target, and n represents the number of targets;

[0057] The enhanced feature representation is calculated for all targets, and the expression is:

[0058] g=[g1,g2,...,g n ]

[0059] Among them, g represents the enhanced feature representation of all targets, g i represents the enhanced feature representation of the i-th target, and n represents the number of targets.

[0060] The step of inputting the enhanced feature representation of the target pair into the relationship prediction layer to obtain the predicted relationship probability vector includes the following steps:

[0061] The enhanced feature representations of the i-th target and the j-th target are input into the relationship prediction layer, and the expression is:

[0062] p ij =softmax(W o ·relu(W p1 ·g i +W p2 ·g j +b p )+b o )

[0063] Among them, p ij is the predicted relationship probability vector between the i-th target and the j-th target, softmax and relu are activation functions, g i represents the enhanced feature representation of the i-th target, g j represents the enhanced feature representation of the jth target, W o , W p1 , W p2 、b p and b o is a learnable parameter;

[0064] Calculate the predicted relationship probability vector for all target pairs;

[0065] The calculation and optimization of the relation extraction loss function, the training of the visual relation extraction model, and the use of the visual relation extraction model to perform visual relation extraction include the following steps:

[0066] Step 701, calculate the relationship extraction loss function; the expression is:

[0067]

[0068] Among them, L p represents the relation extraction loss function, n represents the number of targets, c represents the number of relation categories in the dataset, and p ijk Represents the predicted relationship probability vector p between the i-th target and the j-th target ij The kth element of ijk is a relation annotation. When the i-th target and the j-th target have the k-th relationship, q ijk =1, otherwise q ijk =0.

[0069] Step 702: Use an optimization algorithm to extract the loss function L p Optimize and train the visual relationship extraction model;

[0070] Step 703: perform visual relationship extraction using a visual relationship extraction model.

[0071] Compared with the existing methods, the advantages of the method of the present invention are: this technology provides a target relationship extraction method based on spatial correlation enhancement. This method explicitly models the spatial correlation, introduces the attention mechanism to aggregate and enhance the entity features, and innovatively uses the spatial correlation to guide the attention matrix calculation of the attention mechanism, thereby enhancing the characteristics of the target and enabling it to perceive the spatial correlation between targets, thereby achieving high-precision visual relationship extraction. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] Figure 1 A schematic diagram of a flow chart of an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0073] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0074] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0075] In this example, we assume that we want to build an intelligent security system. The system aims to automatically detect and identify the relationship between objects by analyzing the real-time video stream captured by the surveillance camera, thereby providing a more intelligent and efficient security monitoring function. The system can identify the relationship between people and objects in the image, such as "carrying", "placing", "pushing", etc. through visual relationship extraction technology. When the system detects abnormal behavioral relationships, such as "carrying large objects into prohibited areas" or "placing objects in dangerous locations", it can automatically trigger an alarm and notify security personnel. For the task of visual relationship extraction, a target relationship extraction method based on spatial association enhancement is used.

[0076] Therefore, if Figure 1 As shown, a target relationship extraction method based on spatial association enhancement includes:

[0077] Step 1: Build a visual relationship extraction model, including a pre-trained visual model, a feature enhancement layer, and a relationship prediction layer;

[0078] Step 2: Use the pre-trained visual model to extract image features;

[0079] Step 3, obtain the feature representation of all targets based on the image features and target area annotations;

[0080] Step 4, calculate the spatial correlation vectors of all target pairs;

[0081] Step 5: Input the feature representations of all targets and the spatial correlation vectors of all target pairs into the feature enhancement layer to obtain enhanced feature representations of all targets;

[0082] Step 6: Input the enhanced feature representation of the target pair into the relationship prediction layer to obtain the predicted relationship probability vector;

[0083] Step 7: Calculate and optimize the relationship extraction loss function, train the visual relationship extraction model, and use the visual relationship extraction model to perform visual relationship extraction.

[0084] The method of extracting image features using a pre-trained visual model includes the following steps:

[0085] The input image is represented as Use the pre-trained visual model to extract the visual features of the input image. The expression is:

[0086] F img =ResNet(x)

[0087] in, Represents the visual features of the image, W and H represent the width and height of the image, d represents the hidden layer dimension of ResNet, and s represents the downsampling multiple of ResNet.

[0088] ResNet is a deep convolutional neural network structure proposed by Kaiming He et al. of Microsoft Research. Its main innovation is the introduction of residual connections or skip connections to solve the gradient vanishing and gradient exploding problems in deep network training.

[0089] The introduction of ResNet is of great significance in deep learning. Through the design of residual connections, it allows the construction of very deep networks, which has achieved significant performance improvements in large-scale image classification and other computer vision tasks. The flexibility and powerful feature representation capabilities of ResNet make it an important basic model in many fields.

[0090] The method of obtaining feature representations of all targets based on image features and target area annotations includes the following steps:

[0091] According to the target area annotation, the target position is represented as the coordinates of the rectangular box (x i ,y i ,w i ,h i ), where i represents the index of the target, x i and i Indicates the coordinates of the upper left corner of the rectangular box, w i and h i Indicates the width and height of the rectangular box;

[0092] Use the ROIAlign algorithm to map the target area annotation to the space of image features to obtain the visual feature map of the target, which is expressed as:

[0093]

[0094] in, represents the visual feature map of the i-th target, d represents the hidden layer dimension of ResNet, and s o Indicates the output size of ROIAlign;

[0095] RoIAlign is a feature alignment method used in target detection and object recognition tasks. It solves the problem of information loss and accuracy degradation that may occur when using RoIPooling.

[0096] In the object detection task, a common method is to extract the region of interest and project it onto the feature map, and then map each RoI to a fixed-size feature map region through the RoIPooling operation. However, the RoIPooling operation is based on rounding operations, which may cause fine feature position offsets, thereby reducing positioning accuracy.

[0097] RoIAlign solves this problem by using bilinear interpolation to extract the features of the RoI region from the feature map in a more accurate way.

[0098] Adaptively pool the visual feature map of the i-th target to obtain the feature representation of the i-th target, which is expressed as:

[0099]

[0100] in, Represents the feature representation of the i-th target;

[0101] Visual features are extracted for each target to obtain feature representations of all targets:

[0102]

[0103] in, represents the feature representation of all targets, d represents the hidden layer dimension of ResNet, and n represents the number of targets.

[0104] The calculation of the spatial association vectors of all target pairs comprises the following steps:

[0105] Step 401, calculate the area association vector; for the i-th target and the j-th target, construct a vector with a length of 3 Calculate the IOU of the i-th target and the j-th target; if the IOU of the i-th target and the j-th target is not less than 0.6, then e ij The first element of is assigned to 1, and the other elements are assigned to 0; if the IOU between the i-th target and the j-th target is not less than 0.3 and less than 0.6, then e ij The second element of is assigned to 1, and the other elements are assigned to 0; if the IOU between the i-th target and the j-th target is less than 0.3, then e ij The third element of is assigned a value of 1, and the other elements are assigned a value of 0;

[0106] After assignment, e ij is the area association vector between the i-th target and the j-th target, and the area association vector is calculated for all target pairs;

[0107] IOU (Intersection over Union) is a commonly used indicator in the field of object detection to evaluate the degree of overlap between two regions (usually rectangles). It represents the degree of overlap between two bounding boxes by calculating the intersection area of ​​the two bounding boxes divided by their union area. The value range of IOU is between 0 and 1, where 0 means that the two bounding boxes have no overlap and 1 means that the two bounding boxes completely overlap. A higher IOU value indicates a higher degree of overlap between the two bounding boxes.

[0108] Step 402, calculate the direction association vector; for the i-th target and the j-th target, construct a vector with a length of 4 The coordinates of the rectangular box of the i-th target are expressed as (x i ,y i ,w i ,h i ), the coordinates of the rectangular box of the jth target are expressed as (x j ,y j ,w j ,h j ), calculate the angle between the i-th target and the j-th target, the expression is:

[0109]

[0110] Among them, θ ij represents the angle between the i-th target and the j-th target, x i and i Represents the coordinate of the upper left corner of the rectangular box of the i-th target, w i and h i Indicates the width and height of the rectangular box of the i-th target; x j and j The coordinates of the upper left corner of the rectangular box representing the jth target, w j and h j Represents the width and height of the rectangular box of the jth target;

[0111] For ij To assign a value, the expression is:

[0112]

[0113] Among them, s ijk Indicates ij The kth element of ;

[0114] After assignment, s ij is the direction association vector between the i-th target and the j-th target; the direction association vector is calculated for all target pairs;

[0115] Step 403, calculate the spatial correlation vector; the area correlation vector of the i-th target and the j-th target and the direction correlation vector of the i-th target and the j-th target are concatenated to obtain the spatial correlation vector of the i-th target and the j-th target, and the expression is:

[0116] u ij =[e ij ,s ij ]

[0117] Among them, u ij Represents the spatial association vector between the i-th target and the j-th target;

[0118] Compute the spatial association vector for all target pairs.

[0119] The step of inputting the feature representations of all targets and the spatial correlation vectors of all target pairs into the feature enhancement layer to obtain the enhanced feature representations of all targets comprises the following steps:

[0120] Step 501, calculate the semantic attention matrix; construct an n×n matrix A h , for A h To assign a value, the expression is:

[0121]

[0122] Among them, A h,ij Represents the matrix A h The element in the i-th row and j-th column of , softmax is the activation function, represents the feature representation of the i-th target, represents the feature representation of the jth target, d represents the hidden layer dimension of ResNet, is a learnable parameter;

[0123] The matrix A after assignment h is the semantic attention matrix;

[0124] Step 502, calculate the spatial attention matrix; construct an n×n matrix A s , for A s To assign a value, the expression is:

[0125]

[0126] Among them, A s,ij Represents the matrix A s The element in the i-th row and j-th column of , softmax is the activation function, represents the feature representation of the i-th target, represents the feature representation of the jth target, u ijrepresents the spatial association vector between the i-th target and the j-th target, d represents the hidden layer dimension of ResNet, and is a learnable parameter;

[0127] The matrix A after assignment s is the spatial attention matrix;

[0128] Step 503, calculate the attention matrix; take the bitwise average of the semantic attention matrix and the spatial attention matrix, the expression is:

[0129]

[0130] Among them, A represents the attention matrix, A h represents the semantic attention matrix, A s represents the spatial attention matrix;

[0131] Step 504, use the attention matrix to aggregate the feature representation of the target to obtain an enhanced feature representation of the target; the expression is:

[0132]

[0133] Among them, g i represents the enhanced feature representation of the i-th target, A ij represents the element in the i-th row and j-th column of the attention matrix A, represents the feature representation of the jth target, and n represents the number of targets;

[0134] The enhanced feature representation is calculated for all targets, and the expression is:

[0135] g=[g1,g2,...,g n ]

[0136] Among them, g represents the enhanced feature representation of all targets, g i represents the enhanced feature representation of the i-th target, and n represents the number of targets.

[0137] The step of inputting the enhanced feature representation of the target pair into the relationship prediction layer to obtain the predicted relationship probability vector includes the following steps:

[0138] The enhanced feature representations of the i-th target and the j-th target are input into the relationship prediction layer, and the expression is:

[0139] p ij =softmax(W o ·relu(W p1 ·g i +W p2 ·g j+b p )+b o )

[0140] Among them, p ij is the predicted relationship probability vector between the i-th target and the j-th target, softmax and relu are activation functions, g i represents the enhanced feature representation of the i-th target, g j represents the enhanced feature representation of the jth target, W o , W p1 , W p2 、b p and b o is a learnable parameter;

[0141] Calculate the predicted relationship probability vector for all target pairs;

[0142] The calculation and optimization of the relation extraction loss function, the training of the visual relation extraction model, and the use of the visual relation extraction model to perform visual relation extraction include the following steps:

[0143] Step 701, calculate the relationship extraction loss function; the expression is:

[0144]

[0145] Among them, L p represents the relation extraction loss function, n represents the number of targets, c represents the number of relation categories in the dataset, and p ijk Represents the predicted relationship probability vector p between the i-th target and the j-th target ij The kth element of ijk is a relation annotation. When the i-th target and the j-th target have the k-th relationship, q ijk =1, otherwise q ijk =0.

[0146] Step 702: Use an optimization algorithm to extract the loss function L p Optimize and train the visual relationship extraction model;

[0147] Taking the AdamW optimization algorithm as an example, its mathematical expression is as follows:

[0148] m t =β1m t-1 +(1-β1)g t

[0149]

[0150]

[0151] Among them, mt and v t are the first-order and second-order momentum estimates in the Adam algorithm, β1 and β2 are the decay rates of the momentum estimates, and g t is the gradient, and is the bias correction for the momentum estimate, η is the learning rate, ∈ is a small constant added for numerical stability, and θ t is a model parameter and λ is a hyperparameter of weight decay, which is used to control the strength of the regularization term.

[0152] Step 703: perform visual relationship extraction using a visual relationship extraction model.

[0153] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

Claims

1. Target relationship extraction method based on spatial association enhancement, It is characterized in that The method comprises: Step 1: Build a visual relationship extraction model, including a pre-trained visual model, a feature enhancement layer, and a relationship prediction layer; Step 2: Use the pre-trained visual model to extract image features; Step 3, obtain the feature representation of all targets based on the image features and target area annotations; Step 4, calculate the spatial correlation vectors of all target pairs; Step 5: Input the feature representations of all targets and the spatial correlation vectors of all target pairs into the feature enhancement layer to obtain enhanced feature representations of all targets; Step 6: Input the enhanced feature representation of the target pair into the relationship prediction layer to obtain the predicted relationship probability vector; Step 7: Calculate and optimize the relationship extraction loss function, train the visual relationship extraction model, and use the visual relationship extraction model to perform visual relationship extraction.

2. According to the target relationship extraction method based on spatial association enhancement according to claim 1, It is characterized in that The method of extracting image features using a pre-trained visual model includes the following steps: The input image is represented as Use the pre-trained visual model to extract the visual features of the input image. The expression is: F img =ResNet(x) in, Represents the visual features of the image, W and H represent the width and height of the image, d represents the hidden layer dimension of ResNet, and s represents the downsampling multiple of ResNet.

3. According to the target relationship extraction method based on spatial association enhancement according to claim 2, It is characterized in that The method of obtaining feature representations of all targets based on image features and target area annotations includes the following steps: According to the target area annotation, the target position is represented as the coordinates of the rectangular box (x i ,y i ,w i ,h i ), where i represents the index of the target, x i and i Indicates the coordinates of the upper left corner of the rectangular box, w i and h i Indicates the width and height of the rectangular box; Use the ROIAlign algorithm to map the target area annotation to the space of image features to obtain the visual feature map of the target, which is expressed as: in, represents the visual feature map of the i-th target, d represents the hidden layer dimension of ResNet, and s o Indicates the output size of ROIAlign; Adaptively pool the visual feature map of the i-th target to obtain the feature representation of the i-th target, which is expressed as: in, Represents the feature representation of the i-th target; Visual features are extracted for each target to obtain feature representations of all targets: in, represents the feature representation of all targets, and n represents the number of targets.

4. According to claim 3, the object relationship extraction method based on spatial association enhancement, It is characterized in that The calculation of the spatial association vectors of all target pairs comprises the following steps: Step 401, calculate the area association vector; for the i-th target and the j-th target, construct a vector with a length of 3 Calculate the IOU of the i-th target and the j-th target; if the IOU of the i-th target and the j-th target is not less than 0.6, then e ij The first element of is assigned to 1, and the other elements are assigned to 0; if the IOU between the i-th target and the j-th target is not less than 0.3 and less than 0.6, then e ij The second element of is assigned to 1, and the other elements are assigned to 0; if the IOU between the i-th target and the j-th target is less than 0.3, then e ij The third element of is assigned a value of 1, and the other elements are assigned a value of 0; After assignment, e ij is the area association vector between the i-th target and the j-th target, and the area association vector is calculated for all target pairs; Step 402, calculate the direction association vector; for the i-th target and the j-th target, construct a vector with a length of 4 The coordinates of the rectangular box of the i-th target are expressed as (x i ,y i ,w i ,h i ), the coordinates of the rectangular box of the jth target are expressed as (x j ,y j ,w j ,h j ), calculate the angle between the i-th target and the j-th target, the expression is: Among them, θ ij represents the angle between the i-th target and the j-th target; For ij To assign a value, the expression is: Among them, s ijk Indicates ij The kth element of ; After assignment, s ij is the direction association vector between the i-th target and the j-th target; the direction association vector is calculated for all target pairs; Step 403, calculate the spatial correlation vector; the area correlation vector of the i-th target and the j-th target and the direction correlation vector of the i-th target and the j-th target are concatenated to obtain the spatial correlation vector of the i-th target and the j-th target, and the expression is: u ij =[and ij ,s ij ] Among them, u ij Represents the spatial association vector between the i-th target and the j-th target; Compute the spatial association vector for all target pairs.

5. According to claim 4, the object relationship extraction method based on spatial association enhancement, It is characterized in that The step of inputting the feature representations of all targets and the spatial correlation vectors of all target pairs into the feature enhancement layer to obtain the enhanced feature representations of all targets comprises the following steps: Step 501, calculate the semantic attention matrix; construct an n×n matrix A h , for A h To assign a value, the expression is: Among them, A h,ij Represents the matrix A h The element in the i-th row and j-th column of , softmax is the activation function, is a learnable parameter; The matrix A after assignment h is the semantic attention matrix; Step 502, calculate the spatial attention matrix; construct an n×n matrix A s , for A s To assign a value, the expression is: Among them, A s,ij Represents the matrix A s The element in the i-th row and j-th column of and is a learnable parameter; The matrix A after assignment s is the spatial attention matrix; Step 503, calculate the attention matrix; take the bitwise average of the semantic attention matrix and the spatial attention matrix, the expression is: Among them, A represents the attention matrix, A h represents the semantic attention matrix, A s represents the spatial attention matrix; Step 504, use the attention matrix to aggregate the feature representation of the target to obtain the enhanced feature representation of the target; the expression is: Among them, g i represents the enhanced feature representation of the i-th target, A ij represents the element in the i-th row and j-th column of the attention matrix A, represents the feature representation of the jth target, and n represents the number of targets; The enhanced feature representation is calculated for all targets, and the expression is: g=[g 1 ,g 2 ,...,g n ] Among them, g represents the enhanced feature representation of all targets, g i represents the enhanced feature representation of the i-th target.

6. The target relationship extraction method based on spatial association enhancement according to claim 5, It is characterized in that The step of inputting the enhanced feature representation of the target pair into the relationship prediction layer to obtain the predicted relationship probability vector includes the following steps: The enhanced feature representations of the i-th target and the j-th target are input into the relationship prediction layer, and the expression is: p ij =softmax(W o ·relu(W p1 ·g i +W p2 ·g j +b p )+b o ) Among them, p ij is the predicted relationship probability vector between the i-th target and the j-th target, softmax and relu are activation functions, W o , W p1 , W p2 , b p and b o is a learnable parameter; Compute the predicted relation probability vector for all target pairs.

7. The target relationship extraction method based on spatial association enhancement according to claim 6, It is characterized in that The calculation and optimization of the relation extraction loss function, the training of the visual relation extraction model, and the use of the visual relation extraction model to perform visual relation extraction include the following steps: Step 701, calculate the relationship extraction loss function; the expression is: Among them, L p represents the relation extraction loss function, c represents the number of relation categories in the dataset, and p ijk Represents the predicted relationship probability vector p between the i-th target and the j-th target ij The kth element of ijk is a relation annotation. When the i-th target and the j-th target have the k-th relationship, q ijk =1, otherwise q ijk =0. Step 702: Use an optimization algorithm to extract the loss function L p Optimize and train the visual relationship extraction model; Step 703: perform visual relationship extraction using a visual relationship extraction model.