Target relation identification method based on spatial relation discrimination

By introducing a spatial relationship discrimination module into the visual relationship extraction model and using multi-task learning to optimize the joint loss function, the problem of low accuracy in identifying spatial relationships between targets in the existing technology is solved, and high-precision visual relationship extraction is achieved.

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

Patent Information

Application Number
CN202410678132.3
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 relationship between targets, affecting its recognition accuracy.

Method used

A method based on multi-task learning is used to build a visual relationship extraction model, which includes a pre-trained visual model, a spatial relationship discrimination module and a semantic relationship prediction layer. Through the spatial relationship discrimination loss function and the relationship extraction loss function, the joint loss function is optimized, and the training model is Identify spatial relationships between objects.

Benefits of technology

It improves the accuracy of visual relationship extraction, achieves high-precision recognition of spatial relationships between targets, and enhances the understanding and reasoning capabilities of computer vision.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570445A
    Figure CN118570445A
Patent Text Reader

Abstract

The invention discloses a target relation identification method based on spatial relation discrimination, and the method comprises the steps: constructing a visual relation extraction model which comprises a pre-training visual model, a spatial relation discrimination module and a semantic 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; inputting the feature representation of the target pair into a spatial relationship discrimination module to obtain a predicted spatial relationship probability vector, and calculating a spatial relationship discrimination loss function; inputting the feature representation of the target pair into a semantic relation prediction layer to obtain a predicted relation probability vector, and calculating a relation extraction loss function; and calculating and optimizing a joint loss function, training a visual relation extraction model, and performing visual relation extraction by using the model. According to the method, a multi-task learning thought is used, an auxiliary task of spatial relationship discrimination is innovatively proposed, a visual relationship extraction model learns a spatial relationship, 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 recognition method based on spatial relationship discrimination. 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 relationship 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 relationship also conveys semantic information, such as A is part of B or A depends on the existence of B. Therefore, using this spatial relationship can assist in the recognition of semantic relationships and improve the accuracy of visual relationship extraction. How to introduce the space 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 identifying target relationships based on spatial relationship discrimination. The method can identify the relationship between targets in a picture. Compared with the existing method, the method uses the idea of ​​multi-task learning and innovatively proposes an auxiliary task of spatial relationship discrimination, so that the visual relationship extraction model can learn the spatial relationship between targets and achieve high-precision visual relationship extraction.

[0005] The object of the present invention is to achieve a method for identifying target relationships based on spatial relationship discrimination through the following technical solution, the method comprising:

[0006] Step 1: Build a visual relationship extraction model, including a pre-trained visual model, a spatial relationship discrimination module, and a semantic 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: Input the feature representation of the target pair into the spatial relationship discrimination module to obtain the predicted spatial relationship probability vector and calculate the spatial relationship discrimination loss function;

[0010] Step 5: Input the feature representation of the target pair into the semantic relationship prediction layer, obtain the predicted relationship probability vector, and calculate the relationship extraction loss function;

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

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

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

[0014] F img =ResNet(x)

[0015] 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.

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

[0017] 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;

[0018] 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:

[0019]

[0020] 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;

[0021] 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:

[0022]

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

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

[0025]

[0026] in, represents the feature representation of all targets, and n represents the number of targets.

[0027] The step of inputting the feature representation of the target pair into the spatial relationship discrimination module, obtaining the predicted spatial relationship probability vector, and calculating the spatial relationship discrimination loss function includes the following steps:

[0028] Step 401, input the feature representation of the i-th target and the j-th target into the spatial relationship discrimination module to obtain the predicted spatial relationship probability vector of the i-th target and the j-th target, which is expressed as:

[0029]

[0030] in, represents the predicted spatial relationship probability vector between the i-th target and the j-th target, represents the feature representation of the i-th target, represents the feature representation of the jth target, W m , W s , W o , b1 and b2 are learnable parameters;

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

[0032] Step 402, construct the area containing the label 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 ijThe 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;

[0033] After assignment, e ij is the area inclusion label vector of the i-th target and the j-th target, and the area inclusion label vector is calculated for all target pairs;

[0034] Step 403, construct a direction annotation 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:

[0035]

[0036] 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;

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

[0038]

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

[0040] After assignment, s ijis the direction label vector of the i-th target and the j-th target; the direction label vector is calculated for all target pairs;

[0041] Step 404, construct a spatial relationship annotation vector; the area inclusion annotation vector of the i-th target and the j-th target and the direction annotation vector of the i-th target and the j-th target are concatenated to obtain the spatial relationship annotation vector of the i-th target and the j-th target, and the expression is:

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

[0043] Among them, u ij Represents the spatial relationship annotation vector between the i-th target and the j-th target;

[0044] Calculate the spatial relationship annotation vector for all target pairs;

[0045] Step 405, calculate the spatial relationship discrimination loss function; the expression is:

[0046]

[0047] Among them, L s represents the spatial relationship discrimination loss function, n represents the number of targets, u ij Represents the spatial relationship annotation vector between the i-th target and the j-th target, u ijk Indicates u ij The kth element of a ij Represents the predicted spatial relationship probability vector between the i-th target and the j-th target, a ijk Indicates a ij The kth element of .

[0048] The step of inputting the feature representation of the target pair into the semantic relationship prediction layer, obtaining the predicted relationship probability vector, and calculating the relationship extraction loss function includes the following steps:

[0049] Step 501, input the feature representation of the i-th target and the j-th target into the semantic relationship prediction layer, the expression is:

[0050]

[0051] Among them, p ij is the predicted relationship probability vector between the i-th target and the j-th target, softmax is the activation function, represents the feature representation of the i-th target, represents the feature representation of the jth target, W r and b r is a learnable parameter;

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

[0053] Step 502, calculate the relationship extraction loss function; the expression is:

[0054]

[0055] 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.

[0056] The calculation and optimization of the joint loss function, training the visual relationship extraction model, and performing visual relationship extraction using the visual relationship extraction model include the following steps:

[0057] Step 601: convert the relation extraction loss function L p And the spatial relationship discrimination loss function L s Perform weighted summation to obtain the joint loss function L join , the mathematical expression is:

[0058] L join =λ1L p +λ2L s

[0059] Among them, L join represents the joint loss function, L p is the relation extraction loss function, L s is the spatial relationship discrimination loss function, λ1 and λ2 are set hyperparameters, and λ1 represents the relationship extraction loss function L p In the joint loss function L join The weight coefficient in; λ2 represents the spatial relationship discrimination loss function L s In the joint loss function L join The weight coefficient in ;

[0060] Step 602: Use an optimization algorithm to optimize the joint loss function L join Optimize and train the visual relationship extraction model;

[0061] Step 603: extract visual relationships using a visual relationship extraction model.

[0062] Compared with the existing methods, the advantages of the method of the present invention are: the present technology provides a method for identifying target relationships based on spatial relationship discrimination. The present method uses the idea of ​​multi-task learning, defines the spatial relationship as the area inclusion relationship and direction relationship between targets, and innovatively proposes an auxiliary task of spatial relationship discrimination, so that the visual relationship extraction model can learn the spatial relationship between targets and achieve high-precision visual relationship extraction. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0064] 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.

[0065] 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.

[0066] 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 recognition method based on spatial relationship discrimination is used.

[0067] Therefore, if Figure 1 As shown, a target relationship recognition method based on spatial relationship discrimination includes:

[0068] Step 1: Build a visual relationship extraction model, including a pre-trained visual model, a spatial relationship discrimination module, and a semantic relationship prediction layer;

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

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

[0071] Step 4: Input the feature representation of the target pair into the spatial relationship discrimination module to obtain the predicted spatial relationship probability vector and calculate the spatial relationship discrimination loss function;

[0072] Step 5: Input the feature representation of the target pair into the semantic relationship prediction layer, obtain the predicted relationship probability vector, and calculate the relationship extraction loss function;

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

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

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

[0076] F img =ResNet(x)

[0077] 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.

[0078] 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.

[0079] 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.

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

[0081] 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;

[0082] 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:

[0083]

[0084] 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;

[0085] 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.

[0086] 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.

[0087] 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.

[0088] 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:

[0089]

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

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

[0092]

[0093] in, represents the feature representation of all targets, and n represents the number of targets.

[0094] The step of inputting the feature representation of the target pair into the spatial relationship discrimination module, obtaining the predicted spatial relationship probability vector, and calculating the spatial relationship discrimination loss function includes the following steps:

[0095] Step 401, input the feature representation of the i-th target and the j-th target into the spatial relationship discrimination module to obtain the predicted spatial relationship probability vector of the i-th target and the j-th target, which is expressed as:

[0096]

[0097] in, represents the predicted spatial relationship probability vector between the i-th target and the j-th target, represents the feature representation of the i-th target, represents the feature representation of the jth target, W m , W s , W o , b1 and b2 are learnable parameters;

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

[0099] Step 402, construct the area containing the label 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;

[0100] 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.

[0101] After assignment, e ij is the area inclusion label vector of the i-th target and the j-th target, and the area inclusion label vector is calculated for all target pairs;

[0102] Step 403, construct a direction annotation 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 (xj ,y j ,w j ,h j ), calculate the angle between the i-th target and the j-th target, the expression is:

[0103]

[0104] 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;

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

[0106]

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

[0108] After assignment, s ij is the direction label vector of the i-th target and the j-th target; the direction label vector is calculated for all target pairs;

[0109] Step 404, construct a spatial relationship annotation vector; the area inclusion annotation vector of the i-th target and the j-th target and the direction annotation vector of the i-th target and the j-th target are concatenated to obtain the spatial relationship annotation vector of the i-th target and the j-th target, and the expression is:

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

[0111] Among them, u ij Represents the spatial relationship annotation vector between the i-th target and the j-th target;

[0112] Calculate the spatial relationship annotation vector for all target pairs;

[0113] Step 405, calculate the spatial relationship discrimination loss function; the expression is:

[0114]

[0115] Among them, L s represents the spatial relationship discrimination loss function, n represents the number of targets, u ij Represents the spatial relationship annotation vector between the i-th target and the j-th target, u ijk Indicates u ij The kth element of a ij Represents the predicted spatial relationship probability vector between the i-th target and the j-th target, a ijk Indicates a ij The kth element of .

[0116] The step of inputting the feature representation of the target pair into the semantic relationship prediction layer, obtaining the predicted relationship probability vector, and calculating the relationship extraction loss function includes the following steps:

[0117] Step 501, input the feature representation of the i-th target and the j-th target into the semantic relationship prediction layer, the expression is:

[0118]

[0119] Among them, p ij is the predicted relationship probability vector between the i-th target and the j-th target, softmax is the activation function, represents the feature representation of the i-th target, represents the feature representation of the jth target, W r and b r is a learnable parameter;

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

[0121] Step 502, calculate the relationship extraction loss function; the expression is:

[0122]

[0123] 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.

[0124] The calculation and optimization of the joint loss function, training the visual relationship extraction model, and performing visual relationship extraction using the visual relationship extraction model include the following steps:

[0125] Step 601: convert the relation extraction loss function L p And the spatial relationship discrimination loss function L s Perform weighted summation to obtain the joint loss function L join , the mathematical expression is:

[0126] L join =λ1L p +λ2L s

[0127] Among them, L join represents the joint loss function, L p is the relationship extraction loss function, L s is the spatial relationship discrimination loss function, λ1 and λ2 are set hyperparameters, and λ1 represents the relationship extraction loss function L p In the joint loss function L join The weight coefficient in; λ2 represents the spatial relationship discrimination loss function L s In the joint loss function L join The weight coefficient in ;

[0128] Step 602: Use an optimization algorithm to optimize the joint loss function L join Optimize and train the visual relationship extraction model;

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

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

[0131]

[0132]

[0133] Among them, m t 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.

[0134] Step 603: extract visual relationships using a visual relationship extraction model.

[0135] 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. A target relationship recognition method based on spatial relationship discrimination, characterized in that: The method comprises: Step 1: Build a visual relationship extraction model, including a pre-trained visual model, a spatial relationship discrimination module, and a semantic 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: Input the feature representation of the target pair into the spatial relationship discrimination module to obtain the predicted spatial relationship probability vector and calculate the spatial relationship discrimination loss function; Step 5: Input the feature representation of the target pair into the semantic relationship prediction layer, obtain the predicted relationship probability vector, and calculate the relationship extraction loss function; Step 6: Calculate and optimize the joint loss function, train the visual relationship extraction model, and use the visual relationship extraction model to perform visual relationship extraction.

2. The object relationship recognition method based on spatial relationship discrimination according to claim 1 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. The object relationship recognition method based on spatial relationship discrimination according to claim 2 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, and AdaptivePooling represents the adaptive pooling operation; 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. The object relationship recognition method based on spatial relationship discrimination according to claim 3 is characterized in that: The step of inputting the feature representation of the target pair into the spatial relationship discrimination module, obtaining the predicted spatial relationship probability vector, and calculating the spatial relationship discrimination loss function includes the following steps: Step 401, input the feature representation of the i-th target and the j-th target into the spatial relationship discrimination module to obtain the predicted spatial relationship probability vector of the i-th target and the j-th target, which is expressed as: in, represents the predicted spatial relationship probability vector between the i-th target and the j-th target, represents the feature representation of the i-th target, represents the feature representation of the jth target, W m , W s , W o , b1 and b2 are learnable parameters; Calculate the predicted spatial relationship probability vector for all target pairs; Step 402, construct the area containing the label 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 inclusion label vector of the i-th target and the j-th target, and the area inclusion label vector is calculated for all target pairs; Step 403, construct a direction annotation 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 argument of 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 label vector of the i-th target and the j-th target; the direction label vector is calculated for all target pairs; Step 404, construct a spatial relationship annotation vector; the area inclusion annotation vector of the i-th target and the j-th target and the direction annotation vector of the i-th target and the j-th target are concatenated to obtain the spatial relationship annotation 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 relationship annotation vector between the i-th target and the j-th target; Calculate the spatial relationship annotation vector for all target pairs; Step 405, calculate the spatial relationship discrimination loss function; the expression is: Among them, L s represents the spatial relationship discrimination loss function, u ijk Indicates u ij The kth element of a ijk Indicates a ij The kth element of .

5. The object relationship recognition method based on spatial relationship discrimination according to claim 4 is characterized in that: The step of inputting the feature representation of the target pair into the semantic relationship prediction layer, obtaining the predicted relationship probability vector, and calculating the relationship extraction loss function includes the following steps: Step 501, input the feature representation of the i-th target and the j-th target into the semantic relationship prediction layer, the expression is: Among them, p ij is the predicted relationship probability vector between the i-th target and the j-th target, W r and b r is a learnable parameter; Calculate the relationship probability vector for all target pairs; Step 502, 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.

6. The object relationship recognition method based on spatial relationship discrimination according to claims 4 and 5 is characterized in that: The calculation and optimization of the joint loss function, training the visual relationship extraction model, and performing visual relationship extraction using the visual relationship extraction model include the following steps: Step 601: convert the relation extraction loss function L p And the spatial relationship discrimination loss function L s Perform weighted summation to obtain the joint loss function L join , the mathematical expression is: L join =λ1L p +λ2L s Among them, L join represents the joint loss function, L p is the relation extraction loss function, L s is the spatial relationship discrimination loss function, λ1 and λ2 are set hyperparameters, and λ1 represents the relationship extraction loss function L p In the joint loss function L join The weight coefficient in; λ2 represents the spatial relationship discrimination loss function L s In the joint loss function L join The weight coefficient in ; Step 602: Use an optimization algorithm to optimize the joint loss function L join Optimize and train the visual relationship extraction model; Step 603: extract visual relationships using a visual relationship extraction model.