Scene graph generation method and device, electronic equipment and readable storage medium
Through the dual-branch Transformer model and attention mechanism, combined with object and regional features, it solves the problem of inability to accurately generate scene graphs in the existing technology, achieves more accurate and efficient scene graph generation, and improves the semantic performance of image scenes.
Patent Information
- Application Number
- CN202310434335.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-21
- Publication Date
- 2024-10-22
AI Technical Summary
Existing technologies cannot accurately generate scene graphs, resulting in scene graphs that do not conform to real semantics and affecting the performance of image scene generation.
A dual-branch Transformer model is used to obtain object features and regional relationship features through target detection and feature extraction, combine contextual information to generate scene graphs, and use attention mechanisms and semantic feature fusion to improve predicate prediction accuracy.
It achieves more accurate generation of image scene graphs that conform to real semantics, and improves the performance and efficiency of scene graph generation.
Smart Images

Figure CN118823291A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of artificial intelligence technology, and specifically relates to a scene graph generation method, device, electronic device and readable storage medium. Background Art
[0002] A scene graph is an abstract data structure used to describe the relationships between objects in an image or video scene. Currently, the conventional method for generating scene graphs is to directly extract the triplet relationship between object pairs from the image, i.e., the subject-verb-object relationship, and generate the scene graph based on the extracted triplet relationship. In this case, since the scene graph is not only related to the contextual information of the objects in the corresponding image, it will cause the problem of inaccurate generation of the scene graph. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a scene graph generation method, device, electronic device and readable storage medium to solve the current problem that scene graphs cannot be accurately generated.
[0004] In order to solve the above technical problems, this application is implemented as follows:
[0005] In a first aspect, a scene graph generation method is provided, comprising:
[0006] Get the target image;
[0007] Performing target detection on the target image to obtain a first candidate region and a second candidate region, wherein the first candidate region is a region corresponding to a single object in the target image, and the second candidate region is a region corresponding to a single object pair having a subject-predicate-object relationship in the target image;
[0008] Performing feature extraction on the first candidate region to obtain a first feature, and performing feature extraction on the second candidate region to obtain a second feature;
[0009] Inputting the first feature into a first branch of a two-branch Transformer model for processing to obtain contextualized object features, and inputting the second feature into a second branch of the two-branch Transformer model for processing to obtain contextualized region relationship features;
[0010] A scene graph of the target image is generated according to the object features and the region relationship features.
[0011] Optionally, generating a scene graph of the target image according to the object features and the region relationship features includes:
[0012] Predicting the subject and object objects in the target image according to the object features, and predicting the predicates corresponding to the subject and object objects in the target image according to the object features and the region relationship features;
[0013] A scene graph of the target image is generated according to the subject and object objects and the predicates corresponding to the subject and object objects.
[0014] Optionally, predicting the predicates corresponding to the subject and object objects in the target image according to the object features and the region relationship features includes:
[0015] Mapping the object feature and the region relationship feature to the same feature space to obtain a first object feature and a first region relationship feature;
[0016] Obtaining a predicate feature according to the first object feature and the first region relationship feature;
[0017] Predict the predicates corresponding to the subject and object objects in the target image according to the predicate features.
[0018] Optionally, predicting the predicates corresponding to the subject and object objects in the target image according to the predicate features includes:
[0019] Inputting the predicate feature into an attention function to obtain an attention weight of the visual feature of the second candidate region;
[0020] Calibrate the visual features of the second candidate region using the attention weight to obtain low-level relationship features;
[0021] Predicates corresponding to the subject and object objects in the target image are predicted according to the predicate features and the low-level relationship features.
[0022] Optionally, extracting features from the first candidate region to obtain a first feature includes:
[0023] Extracting visual features from the feature map corresponding to the first candidate region to obtain visual features of the first candidate region;
[0024] Extracting spatial features from the first candidate region to obtain spatial features of the first candidate region;
[0025] Extracting language features from the first candidate region to obtain language features of the first candidate region;
[0026] The visual features, spatial features, and language features of the first candidate region are connected to obtain the first features.
[0027] Optionally, extracting features from the second candidate region to obtain a second feature includes:
[0028] Extracting visual features from the feature map corresponding to the second candidate region to obtain visual features of the second candidate region;
[0029] Extracting spatial features from the second candidate region to obtain spatial features of the second candidate region;
[0030] The visual features and the spatial features of the second candidate region are connected to obtain the second features.
[0031] Optionally, inputting the first feature representation into the first branch of a two-branch Transformer model for processing to obtain contextualized object features includes:
[0032] Encode the first feature representation using the first Transformer encoding layer of the first branch to obtain a third feature, where the third feature is a node-level contextualized object feature;
[0033] Connecting the third feature and the visual feature and the language feature of the first candidate region to obtain a fourth feature;
[0034] The second Transformer encoding layer of the first branch is used to perform context extraction on the fourth feature to obtain edge-level contextualized object features.
[0035] Optionally, the step of inputting the second feature representation into the second branch of the dual-branch Transformer model for processing to obtain contextualized regional relationship features includes:
[0036] Encode the second feature representation using the first Transformer encoding layer of the second branch to obtain a fifth feature, where the fifth feature is a node-level contextualized regional relationship feature;
[0037] Connecting the fifth feature and the visual feature of the second candidate area to obtain a sixth feature;
[0038] The second Transformer encoding layer of the second branch is used to perform context extraction on the sixth feature to obtain edge-level contextualized regional relationship features.
[0039] Optionally, after generating the scene graph of the target image, the method further includes:
[0040] Encoding a scene graph of the target image;
[0041] The encoded scene graph is sent to a receiving end, wherein the encoded scene graph is used to decode to obtain a scene graph of the target image, and a downstream task is performed according to the decoded scene graph.
[0042] In a second aspect, a scene graph generation device is provided, comprising:
[0043] An acquisition module, used for acquiring a target image;
[0044] a target detection module, configured to perform target detection on the target image to obtain a first candidate region and a second candidate region, wherein the first candidate region is a region corresponding to a single object in the target image, and the second candidate region is a region corresponding to a single object pair having a subject-predicate-object relationship in the target image;
[0045] A feature extraction module, configured to extract features from the first candidate region to obtain a first feature, and to extract features from the second candidate region to obtain a second feature;
[0046] A processing module, configured to input the first feature into a first branch of a two-branch Transformer model for processing to obtain a contextualized object feature, and input the second feature into a second branch of the two-branch Transformer model for processing to obtain a contextualized region relationship feature;
[0047] A generation module is used to generate a scene graph of the target image according to the object features and the region relationship features.
[0048] In a third aspect, an electronic device is provided, comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.
[0049] In a fourth aspect, a readable storage medium is provided, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0050] In an embodiment of the present application, after acquiring a target image, target detection can be performed on the target image to obtain a first candidate area and a second candidate area, wherein the first candidate area is an area corresponding to a single object, and the second candidate area is an area corresponding to a single object pair having a subject-predicate-object relationship, and feature extraction is performed on the first candidate area and the second candidate area to obtain a first feature and a second feature, and the first feature is input into the first branch of a two-branch Transformer model for processing to obtain a contextualized object feature, and the second feature is input into the second branch of a two-branch Transformer model for processing to obtain a contextualized regional relationship feature, and a scene graph of the target image is generated based on the object feature and the regional relationship feature. Thus, the corresponding scene graph can be generated by combining the object context information and the relationship context information in the target image, thereby accurately generating a scene graph, promoting the generation of an image scene graph that is more in line with real semantics, and greatly improving the performance of scene graph generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 is a flow chart of a scene graph generation method provided in an embodiment of the present application;
[0052] Figure 2 is a schematic diagram of the architecture of a scene graph-based semantic communication system in an embodiment of the present application;
[0053] Figure 3 It is an overall flow chart of the scene graph generation process in the embodiment of the present application;
[0054] Figure 4 It is a specific flow chart of the scene graph generation process in the embodiment of the present application;
[0055] Figure 5 It is a structural schematic diagram of a scene graph generating device provided in an embodiment of the present application;
[0056] Figure 6 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0058] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0059] A scene graph is an abstract data structure used to describe the relationships between objects in an image or video scene. As an effective way to extract visual semantics, scene graphs can build a bridge between vision and language. Scene graph generation tasks can help downstream visual tasks such as image generation, image description, and visual question answering. In addition, scene graph generation can be used as an effective source coding method for semantic communication, which can significantly compress video and image data and save communication bandwidth.
[0060] In order to solve the current problem of being unable to accurately generate scene graphs, considering that the process of human understanding of scenes is a process of integrating the connection information between different objects and different relationships from a global perspective, that is, object context information and relationship context information (that is, the connection information between different subject-predicate-object relationships) are particularly important for improving the scene graph generation performance. In the embodiments of the present application, it is proposed to generate a corresponding scene graph based on the object context information and relationship context information in the image, thereby promoting the generation of an image scene graph that is more in line with real semantics and greatly improving the performance of scene graph generation.
[0061] In the following, in combination with the accompanying drawings, the scene graph generation method, device, electronic device and readable storage medium provided in the embodiments of the present application are described in detail through specific embodiments and their application scenarios.
[0062] See also Figure 1 , Figure 1 1 is a flow chart of a scene graph generation method provided in an embodiment of the present application. The method is applied to an electronic device, which may be a tablet computer, a computer, a mobile phone or other terminal, without limitation. Figure 1 As shown, the method comprises the following steps:
[0063] Step 11: Get the target image;
[0064] Step 12: performing target detection on the target image to obtain a first candidate region and a second candidate region, wherein the first candidate region is a region corresponding to a single object in the target image, and the second candidate region is a region corresponding to a single object pair having a subject-predicate-object relationship in the target image;
[0065] Step 13: extracting features from the first candidate region to obtain a first feature, and extracting features from the second candidate region to obtain a second feature;
[0066] Step 14: inputting the first feature into the first branch of the two-branch Transformer model for processing to obtain contextualized object features, and inputting the second feature into the second branch of the two-branch Transformer model for processing to obtain contextualized region relationship features;
[0067] Step 15: Generate a scene graph of the target image based on the object features and region relationship features.
[0068] Here, the target image can be understood as an image to be processed, such as a frame image or a picture in a video, and is not limited to this. When performing target detection on a target image, multiple first candidate regions (also referred to as object regions) can be obtained, which are based on the number of objects contained in the target image, and multiple second candidate regions (also referred to as environment regions) can be obtained, which are based on the number of object pairs with a subject-predicate-object relationship contained in the target image. Afterwards, steps 13 and 14 are performed on each first candidate region and each second candidate region respectively, and a scene graph of the target image is generated based on the obtained contextualized object features and region relationship features.
[0069] In some embodiments, a target detector may be used to perform target detection on a target image.
[0070] The first feature mentioned above can be understood as an object feature representation of the first candidate region. The second feature mentioned above can be understood as a region relationship feature representation of the second candidate region.
[0071] The dual-branch Transformer model is used to perform context analysis, wherein one branch (first branch) is used to obtain object context information (i.e., first feature) in the target image, and the other branch (second branch) is used to obtain relationship context information (i.e., second feature) in the target image, thereby extracting object context information and relationship context information in the target image. This relationship context information can also be called environmental context information.
[0072] In this way, the scene graph generation method in this embodiment can combine the object context information and relationship context information in the target image to generate a corresponding scene graph, thereby accurately generating a scene graph, promoting the generation of an image scene graph that is more in line with real semantics, and greatly improving the performance of scene graph generation.
[0073] Optionally, the above process of generating a scene graph of a target image based on object features and regional relationship features may include: first, predicting the subject and object objects (i.e., subject and object objects) in the target image based on the object features, and predicting the predicates corresponding to the subject and object objects in the target image based on the object features and regional relationship features; then, generating a scene graph of the target image based on the subject and object objects and the predicates corresponding to the subject and object objects. For example, the predicted subject and object objects and the corresponding predicates may be combined to obtain multiple prediction results of subject, predicate and object relationships, and thereby generate a scene graph that conforms to the semantics of the real scene.
[0074] Considering that when humans understand a specific relationship, they usually first identify the subject area, object area and local surrounding environment area, and then analyze and understand the parts outside the subject and object area in the environment area to achieve the final predicate recognition, when implementing semantic feature fusion, the embodiment of the present application can first project / map the contextualized object features and regional relationship features to the same feature space through a fully connected layer, and then remove the subject and object features from the regional relationship features, and perform predicate prediction based on the obtained predicate features.
[0075] Optionally, the process of predicting the predicates corresponding to the subject and object objects in the target image according to the object features and the regional relationship features may include:
[0076] The object feature and the region relationship feature are mapped to the same feature space to obtain a first object feature and a first region relationship feature; for example, the object feature and the region relationship feature can be projected / mapped to the same feature space through a fully connected layer.
[0077] Obtaining a predicate feature according to the first object feature and the first region relationship feature; for example, the first object feature may be removed from the first region relationship feature to obtain a corresponding predicate feature;
[0078] Predicates corresponding to the subject and object objects in the target image are predicted according to the predicate features.
[0079] In this way, predicate prediction can be achieved based on accurate semantic feature fusion.
[0080] In some embodiments, the obtained predicate features may be input into a predicate classifier based on a multi-layer perceptron (MLP) to perform predicate prediction.
[0081] Relevant research in computer vision shows that low-level features are more suitable for describing simple appearance features of objects, such as color, size, and texture, while high-level features are more suitable for describing complex features and semantics of objects. In visual scenes, some relationships are related to the complex semantics of objects and environments, while some relationships can be well distinguished by simple appearance features. Therefore, using only high-level features for final predicate classification will lead to suboptimal relationship detection results. In order to improve predicate prediction, the semantic information of features at different levels can be selectively used for predicate prediction.
[0082] Optionally, an enhanced attention mechanism may be used to improve predicate prediction. The above process of predicting the predicate corresponding to the subject and object in the target image based on the predicate features may include:
[0083] Inputting the predicate feature into the attention function to obtain the attention weight of the visual feature of the second candidate region; for example, a fully connected layer with a ReLU (rectified linear unit) activation can be used to implement the attention function;
[0084] Calibrate the visual features of the second candidate region using the attention weight to obtain low-level relationship features;
[0085] Predicates corresponding to the subject and object objects in the target image are predicted according to the predicate features and the low-level relationship features.
[0086] In this way, high-level and low-level relational features can be combined to perform predicate prediction, thereby improving predicate prediction. In addition, combined with the enhanced attention mechanism, the optimization difficulty can be reduced, model parameters can be saved, and the relational semantics of the generated scene graph can be more complete and accurate.
[0087] In the embodiment of the present application, a visual feature extractor, a spatial feature extractor, a language feature extractor, etc. may be used to perform feature extraction. The above process of extracting features from the first candidate area and obtaining the first feature may include:
[0088] Extracting visual features from the feature map corresponding to the first candidate region to obtain visual features of the first candidate region;
[0089] Extracting spatial features from the first candidate region to obtain spatial features of the first candidate region;
[0090] Extracting language features from the first candidate region to obtain language features of the first candidate region;
[0091] The visual features, spatial features and language features of the first candidate region are connected to obtain the first feature. For example, the Concat function can be used to perform a connection operation on the visual features, spatial features and language features of the first candidate region to obtain the first feature, namely the object feature.
[0092] In this way, the object features of the object area can be fully extracted from the perspectives of visual features, spatial features and language features, so as to accurately realize the feature expression of the object area, which is helpful for subsequent deeper semantic analysis and calculation.
[0093] Optionally, the process of extracting features from the second candidate region to obtain the second features includes:
[0094] Extracting visual features from the feature map corresponding to the second candidate region to obtain visual features of the second candidate region;
[0095] Extracting spatial features from the second candidate region to obtain spatial features of the second candidate region;
[0096] The visual features and the spatial features of the second candidate region are connected to obtain the second feature. For example, a Concat function can be used to perform a connection operation on the visual features and the spatial features of the second candidate region to obtain the second feature, namely, the region relationship feature.
[0097] In this way, the relational features of environmental areas can be fully extracted from the perspectives of visual features and spatial features, thereby accurately realizing the relational expression of environmental areas, which is helpful for subsequent deeper semantic analysis and calculation.
[0098] Optionally, the step of inputting the first feature into the first branch of the dual-branch Transformer model for processing to obtain the contextualized object feature may include:
[0099] Encode the first feature representation using the first Transformer encoding layer of the first branch to obtain a third feature, where the third feature is a node-level contextualized object feature;
[0100] The third feature and the visual feature and the language feature of the first candidate region are connected to obtain a fourth feature; for example, a Concat function may be used to perform the connection operation;
[0101] The second Transformer encoding layer of the first branch is used to perform context extraction on the fourth feature to obtain edge-level contextualized object features.
[0102] In this way, with the help of two encoding layers at the node level and the edge level, more refined contextualized object features can be obtained, thereby improving the performance of the subsequently generated scene graph.
[0103] Optionally, the step of inputting the second feature into the second branch of the dual-branch Transformer model for processing to obtain the contextualized regional relationship feature may include:
[0104] Encode the second feature representation using the first Transformer encoding layer of the second branch to obtain a fifth feature, where the fifth feature is a node-level contextualized regional relationship feature;
[0105] Connecting the fifth feature and the visual feature of the second candidate area to obtain a sixth feature; for example, a Concat function may be used to perform the connection operation;
[0106] The second Transformer encoding layer of the second branch is used to perform context extraction on the sixth feature to obtain edge-level contextualized regional relationship features.
[0107] In this way, with the help of two encoding layers at the node level and the edge level, more refined contextualized regional relationship features can be obtained, thereby improving the performance of the subsequently generated scene graph.
[0108] Optionally, after the scene graph of the target image is generated, the scene graph can be encoded and sent to the receiving end, wherein the encoded scene graph is used to decode to obtain the scene graph of the target image, and downstream tasks such as image generation, image description, visual question answering, etc. are performed according to the decoded scene graph to meet the various needs of users. In this way, compared with the traditional communication solution of directly transmitting the image bit stream, by extracting and transmitting the scene graph of the target image, the amount of transmitted data can be reduced and communication bandwidth resources can be saved.
[0109] See also Figure 2 , Figure 2 It is an architectural diagram of a semantic communication system based on a scene graph provided in an embodiment of the present application. The semantic communication system includes a transmitting end and a receiving end, wherein the execution operation of the transmitting end includes: receiving an image, using a scene graph generation module to generate a scene graph of the image, and channel encoding the scene graph semantic data. Afterwards, the encoded scene graph semantic data is channel transmitted, and during the channel transmission process, channel noise is considered. The execution operation of the receiving end includes: receiving the encoded scene graph semantic data, channel decoding the encoded scene graph semantic data, restoring the scene graph, and performing downstream tasks according to the decoded scene graph, such as image reconstruction or semantic synthesis (such as image retrieval, anomaly detection, event prediction) and other downstream tasks, to obtain a reconstructed image or semantic synthesis results to meet the needs of the receiving end users.
[0110] Regarding the scene graph generation part, this application proposes to make full use of the implicit contextual information between objects and regional relationships, and adaptively fuse high-level and low-level features to generate a scene graph that is more in line with real semantics. In terms of specific implementation, the embodiment of this application proposes a dual-branch context analysis Transformer algorithm, involving four main collaborative modules: a feature representation learning module is used to enrich the feature representation of objects and relationships; a dual-branch Transformer module is used to mine hidden connections between objects and regional relationships; a semantic feature fusion module is used to aggregate object features and environmental features containing global context information; and an enhanced attention module is used to adaptively improve low-level features and enhance predicate prediction. Based on this algorithm, a scene graph that conforms to the semantics of a real visual scene can be extracted.
[0111] like Figure 3 As shown in the figure, the scene graph generation process may include: first, the input image passes through the target detector, and the candidate region (including the object region and the environment region) and the corresponding feature map are output; second, the feature representation learning module uses three feature extractors, namely, vision, space and language, to extract features from different angles of the candidate region, and obtain rich object feature representation and relationship feature representation; then, the two feature representations are respectively input into different branches of the dual-branch Transformer model to capture and analyze the object context and relationship context, and output contextualized subject-object object features and regional relationship features; then, the semantic feature fusion module performs semantic-guided feature fusion on the contextualized features, and then performs predicate classification prediction; wherein, the enhanced attention module adaptively selects important parts of the low-level features according to the high-level predicate representation output by the semantic feature fusion module, and supplements the predicate prediction; finally, the prediction result of the scene graph is output, wherein the system optimization goal is to minimize the sum of the cross entropy losses of the object and the predicate. The scene graph result consists of multiple subject-predicate-object triples. For example, for a dataset with 150 types of objects and 50 types of predicates, the feature of each subject or object object can be represented by 8 bits, and the feature of each predicate can be represented by 6 bits.
[0112] by Figure 4 Taking the input image shown in as an example, the specific scene graph generation process includes:
[0113] Step (a) Feature representation learning: The candidate regions and feature maps output by the object detector are used as input. First, the smallest rectangular box enclosing the subject object region and the object object region is defined as the environment region of the subject and object objects. This region can be used as an explicit visual pattern expression of the relationship. Then, for each object region c i and the host and guest environment area ij ,Through three feature extractors, heterogeneous relational feature representations are extracted.
[0114] Step (a.1) Visual feature extractor: For each object region c i and the host and guest environment area ij , the ROIAlign algorithm is used to extract visual features from the corresponding feature map to obtain a 7×7×256 tensor. After that, the tensor is flattened and passed through two fully connected layers (including ReLU activation) to project the expanded features into a 4096-dimensional vector as the visual feature u of the corresponding area. i or ij .
[0115] Step (a.2) Spatial feature extractor: Considering that the semantics of some relations are closely related to the spatial information of the corresponding object pairs, a spatial feature extractor is used to mine the spatial attributes of the region. If the target box coordinates of the candidate region (i.e., object region and environment region) are defined as (x1, y1, x2, y2), the spatial feature z∈R 9 It can be expressed as:
[0116]
[0117] Among them, W and H are the width and height of the image, (x c ,y c ) is the center coordinate of the target box, and (w,h) is the width and height of the target box. After that, two fully connected layers (including ReLU activation) are used to project the spatial feature z into a 128-dimensional vector s as the final spatial feature:
[0118] s = η(ReLU(W2η(ReLU(W1z))))
[0119] Among them, η represents the deactivation probability of the random deactivation layer (Dropout layer) after the two fully connected layers. For example, the deactivation probability can be set to 0.1.
[0120] Step (a.3) Language feature extractor: Since the reasoning of some predicates is closely related to the label categories of the subject and object regions, the language features of the object regions are used to enrich the feature expression. For example, the word embedding layer is used to encode the predicted category probability vector p of each object region to obtain a 200-dimensional language feature vector l:
[0121]
[0122] Among them, the word embedding layer can be initialized using the GloVe pre-trained dictionary, W e Represents the linear parameters of the word embedding layer.
[0123] After that, the Concat function is used to perform the connection operation to obtain the feature representation r of the object area. i The relationship between the environment and the region ij:
[0124] r i =Concat(u i ,s i ,l i )
[0125] r ij =Concat(u ij ,s ij )
[0126] Step (b) uses a dual-branch Transformer module to perform contextual analysis. The goal here is to integrate global object context and regional relationship context information into the extraction of relationships. The Transformer structure can achieve global association modeling, strengthen important semantic information, and ignore redundant irrelevant information through an excellent self-attention mechanism. This embodiment adopts a dual-branch Transformer module, using the Transformer structure as the core encoding layer to model global object and environmental regional information exchange and transmission. Specifically, the module includes an object Transformer branch and an environmental Transformer branch. Each branch contains two encoding stages, node level and edge level, to deepen more refined object and environmental semantics.
[0127] Step (b.1) Object Transformer Branch. First, the Transformer encoding layer is used to represent the object feature obtained in step (a) i Encode to achieve global information exchange between different objects and output node-level contextual object features g i :
[0128] g i =TrEncoder(r i )
[0129] After that, g i Compared with the shallow object visual feature u i and language features i Connect (such as using the Concat function to perform the connection operation) to achieve early feature fusion:
[0130]
[0131] Afterwards, the fused node-level object features Input to another Transformer encoding layer for further object context extraction:
[0132]
[0133] Finally, the edge-level contextualized object features t are output i .
[0134] Step (b.2), environment Transformer branch. This branch adopts a symmetrical structure design with the object Transformer branch. First, the Transformer encoding layer is used to represent the relational feature obtained in step (a). ij Encode to achieve global information exchange between different environmental areas and output node-level contextual environmental features g ij :
[0135] g ij =TrEncoder(r ij )
[0136] After that, g ij With shallow environmental visual features u ij Connect (such as using the Concat function to perform the connection operation) to achieve early feature fusion:
[0137]
[0138] Afterwards, the fused node-level relational features Input to another Transformer encoding layer for further environmental context extraction:
[0139]
[0140] Finally, the contextualized environment features (i.e., relationship features) of the edge level are outputted ij .
[0141] Step (c) performs semantic feature fusion. First, the edge-level contextualized object features and environment features are projected into the same feature space through a fully connected layer:
[0142] f i =W obj t i
[0143] f ij =W env t ij
[0144] Afterwards, the subject and object feature vectors are removed from the environment feature vector to achieve semantic feature fusion:
[0145] m ij =f ij -f i -f j
[0146] Finally, the contextualized predicate feature m is output ij , and send it to the MLP predicate classifier for predicate prediction.
[0147] Step (d) performs enhanced attention: the high-level contextualized predicate feature m output from step (c) is ij Input to the attention function φ a (·) to calculate the attention weight G:
[0148] G=φ a (m ij )
[0149] Here, a fully connected layer with ReLU activation is used to implement the attention function. Then the attention weight G is used to adaptively enhance the low-level environmental visual features u ij The important parts of the image are suppressed, and the redundant parts are suppressed to recalibrate the visual features:
[0150]
[0151] The calibrated low-level environmental features are then represented as d ij Feed into the MLP predicate classifier to supplement the predicate prediction.
[0152] Step (e) Training and testing: In the training phase, the node-level contextualized object features g output by step (b.1) are used i , through the MLP object classifier φ obj (·) to predict the object category and obtain the object category and the corresponding prediction probability Define the object's true label vector as The cross entropy loss function can be used to calculate the object classification loss:
[0153]
[0154] Among them, N o Indicates the total number of object categories.
[0155] Similarly, using the contextualized predicate feature m output from step (c) ij and the calibrated low-level environmental feature representation d output by step (d) ij , through the MLP predicate classifier φ rel1 (·) and φ rel2 (·) to predict the object category, and introduce the predicate frequency statistical prior information of the data set to obtain the predicate category prediction probability Define the predicate true label vector as The cross entropy loss function can be used to calculate the predicate classification loss:
[0156]
[0157] Among them, N r Indicates the total number of predicate categories.
[0158] Finally, the overall optimization goal of the classifier during the training phase is:
[0159] L=L obj +L rel
[0160] During the testing phase, the prediction results of the subject and object and the corresponding predicates are integrated to output the prediction results of multiple relationships, thereby generating a scene graph that conforms to the semantics of the real scene.
[0161] It should be noted that the scene graph generation method provided in the embodiment of the present application can be executed by a scene graph generation device, or a control module in the scene graph generation device for executing the scene graph generation method. In the embodiment of the present application, the scene graph generation device provided in the embodiment of the present application is described by taking the scene graph generation method executed by the scene graph generation device as an example.
[0162] See also Figure 5 , Figure 5 1 is a schematic diagram of a scene graph generation device provided in an embodiment of the present application. The device is applied to an electronic device, which may be a tablet computer, a computer, a mobile phone or other terminal, without limitation. Figure 5 As shown, the scene graph generating device 50 includes:
[0163] An acquisition module 51 is used to acquire a target image;
[0164] The target detection module 52 is used to perform target detection on the target image to obtain a first candidate region and a second candidate region, wherein the first candidate region is a region corresponding to a single object in the target image, and the second candidate region is a region corresponding to a single object pair having a subject-predicate-object relationship in the target image;
[0165] A feature extraction module 53, configured to extract features from the first candidate region to obtain a first feature, and to extract features from the second candidate region to obtain a second feature;
[0166] A processing module 54 is used to input the first feature into the first branch of the two-branch Transformer model for processing to obtain contextualized object features, and input the second feature into the second branch of the two-branch Transformer model for processing to obtain contextualized region relationship features;
[0167] The generating module 55 is used to generate a scene graph of the target image according to the object features and the region relationship features.
[0168] Optionally, the generation module 55 is specifically used to: predict the host and guest objects in the target image based on the object features, and predict the predicates corresponding to the host and guest objects in the target image based on the object features and the regional relationship features; generate a scene graph of the target image based on the host and guest objects and the predicates corresponding to the host and guest objects.
[0169] Optionally, the generating module 55 is further used for:
[0170] Mapping the object feature and the region relationship feature to the same feature space to obtain a first object feature and a first region relationship feature;
[0171] Obtaining a predicate feature according to the first object feature and the first region relationship feature;
[0172] Predict the predicates corresponding to the subject and object objects in the target image according to the predicate features.
[0173] Optionally, the generating module 55 is further used for:
[0174] Inputting the predicate feature into an attention function to obtain an attention weight of the visual feature of the second candidate region;
[0175] Calibrate the visual features of the second candidate region using the attention weight to obtain low-level relationship features;
[0176] Predicates corresponding to the subject and object objects in the target image are predicted according to the predicate features and the low-level relationship features.
[0177] Optionally, the feature extraction module 53 is specifically used for:
[0178] Extracting visual features from the feature map corresponding to the first candidate region to obtain visual features of the first candidate region;
[0179] Extracting spatial features from the first candidate region to obtain spatial features of the first candidate region;
[0180] Extracting language features from the first candidate region to obtain language features of the first candidate region;
[0181] The visual features, spatial features, and language features of the first candidate region are connected to obtain the first features.
[0182] Optionally, the feature extraction module 53 is specifically used for:
[0183] Extracting visual features from the feature map corresponding to the second candidate region to obtain visual features of the second candidate region;
[0184] Extracting spatial features from the second candidate region to obtain spatial features of the second candidate region;
[0185] The visual features and the spatial features of the second candidate region are connected to obtain the second features.
[0186] Optionally, the processing module 54 is specifically used for:
[0187] Encode the first feature representation using the first Transformer encoding layer of the first branch to obtain a third feature, where the third feature is a node-level contextualized object feature;
[0188] Connecting the third feature and the visual feature and the language feature of the first candidate region to obtain a fourth feature;
[0189] The second Transformer encoding layer of the first branch is used to perform context extraction on the fourth feature to obtain edge-level contextualized object features.
[0190] Optionally, the processing module 54 is specifically used for:
[0191] Encode the second feature representation using the first Transformer encoding layer of the second branch to obtain a fifth feature, where the fifth feature is a node-level contextualized regional relationship feature;
[0192] Connecting the fifth feature and the visual feature of the second candidate area to obtain a sixth feature;
[0193] The second Transformer encoding layer of the second branch is used to perform context extraction on the sixth feature to obtain edge-level contextualized regional relationship features.
[0194] Optionally, the scene graph generating device 50 further includes:
[0195] An encoding module, configured to encode the scene graph of the target image after generating the scene graph of the target image;
[0196] The sending module is used to send the encoded scene graph to the receiving end, wherein the encoded scene graph is used to decode to obtain the scene graph of the target image, and perform downstream tasks according to the decoded scene graph.
[0197] The scene graph generation device 50 of the embodiment of the present application can realize the above Figure 1 The various processes of the method embodiment shown can achieve the same technical effect, and will not be described again here to avoid repetition.
[0198] Optional, such as Figure 6 As shown, an embodiment of the present application also provides an electronic device 60, including a processor 61, a memory 62, and a program or instruction stored in the memory 62 and executable on the processor 61. When the program or instruction is executed by the processor 61, each process of the above-mentioned scene graph generation method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0199] The embodiment of the present application also provides a readable storage medium on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned scene graph generation method embodiment can be implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0200] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0201] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0202] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0203] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a service classification device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0204] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A scene graph generation method, characterized in that: include: Get the target image; Performing target detection on the target image to obtain a first candidate region and a second candidate region, wherein the first candidate region is a region corresponding to a single object in the target image, and the second candidate region is a region corresponding to a single object pair having a subject-predicate-object relationship in the target image; Performing feature extraction on the first candidate region to obtain a first feature, and performing feature extraction on the second candidate region to obtain a second feature; Inputting the first feature into a first branch of a two-branch Transformer model for processing to obtain contextualized object features, and inputting the second feature into a second branch of the two-branch Transformer model for processing to obtain contextualized region relationship features; A scene graph of the target image is generated according to the object features and the region relationship features.
2. The method according to claim 1, characterized in that The step of generating a scene graph of the target image according to the object features and the regional relationship features includes: Predicting the subject and object objects in the target image according to the object features, and predicting the predicates corresponding to the subject and object objects in the target image according to the object features and the region relationship features; A scene graph of the target image is generated according to the subject and object objects and the predicates corresponding to the subject and object objects.
3. The method according to claim 2, characterized in that The predicting, based on the object features and the regional relationship features, the predicates corresponding to the subject and object objects in the target image includes: Mapping the object feature and the region relationship feature to the same feature space to obtain a first object feature and a first region relationship feature; Obtaining a predicate feature according to the first object feature and the first region relationship feature; Predict the predicates corresponding to the subject and object objects in the target image according to the predicate features.
4. The method according to claim 3, characterized in that The step of predicting the predicates corresponding to the subject and object objects in the target image according to the predicate features includes: Inputting the predicate feature into an attention function to obtain an attention weight of the visual feature of the second candidate region; Calibrate the visual features of the second candidate region using the attention weight to obtain low-level relationship features; Predicates corresponding to the subject and object objects in the target image are predicted according to the predicate features and the low-level relationship features.
5. The method according to claim 1, characterized in that The extracting a feature of the first candidate region to obtain a first feature includes: Extracting visual features from the feature map corresponding to the first candidate region to obtain visual features of the first candidate region; Extracting spatial features from the first candidate region to obtain spatial features of the first candidate region; Extracting language features from the first candidate region to obtain language features of the first candidate region; The visual features, spatial features, and language features of the first candidate region are connected to obtain the first features.
6. The method according to claim 1, characterized in that The extracting features from the second candidate region to obtain a second feature includes: Extracting visual features from the feature map corresponding to the second candidate region to obtain visual features of the second candidate region; Extracting spatial features from the second candidate region to obtain spatial features of the second candidate region; The visual features and the spatial features of the second candidate region are connected to obtain the second features.
7. The method according to claim 5, characterized in that The step of inputting the first feature representation into the first branch of the dual-branch Transformer model for processing to obtain contextualized object features includes: Encode the first feature representation using the first Transformer encoding layer of the first branch to obtain a third feature, where the third feature is a node-level contextualized object feature; Connecting the third feature and the visual feature and the language feature of the first candidate region to obtain a fourth feature; The second Transformer encoding layer of the first branch is used to perform context extraction on the fourth feature to obtain edge-level contextualized object features.
8. The method according to claim 6, characterized in that The step of inputting the second feature representation into the second branch of the dual-branch Transformer model for processing to obtain contextualized regional relationship features includes: Encode the second feature representation using the first Transformer encoding layer of the second branch to obtain a fifth feature, where the fifth feature is a node-level contextualized regional relationship feature; Connecting the fifth feature and the visual feature of the second candidate area to obtain a sixth feature; The second Transformer encoding layer of the second branch is used to perform context extraction on the sixth feature to obtain edge-level contextualized regional relationship features.
9. The method according to claim 1, characterized in that: After generating the scene graph of the target image, the method further includes: Encoding a scene graph of the target image; The encoded scene graph is sent to a receiving end, wherein the encoded scene graph is used to decode to obtain a scene graph of the target image, and a downstream task is performed according to the decoded scene graph.
10. A scene graph generating device, characterized in that: include: An acquisition module, used for acquiring a target image; a target detection module, configured to perform target detection on the target image to obtain a first candidate region and a second candidate region, wherein the first candidate region is a region corresponding to a single object in the target image, and the second candidate region is a region corresponding to a single object pair having a subject-predicate-object relationship in the target image; A feature extraction module, configured to extract features from the first candidate region to obtain a first feature, and to extract features from the second candidate region to obtain a second feature; A processing module, configured to input the first feature into a first branch of a two-branch Transformer model for processing to obtain a contextualized object feature, and input the second feature into a second branch of the two-branch Transformer model for processing to obtain a contextualized region relationship feature; A generation module is used to generate a scene graph of the target image according to the object features and the region relationship features.
11. An electronic device, characterized in that: The method comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the scene graph generation method as described in any one of claims 1 to 9.
12. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the scene graph generation method according to any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Transform-based double-branch complementary semantic line detection method
CN115908912A
Method and system for automated visual question answering
EP3920048A1
