Visual spatial knowledge fusion video inference method and device and storage medium
By constructing a video knowledge graph and converting the retrieved compact subgraph into visual reasoning frames and fusing them with video frames, the problem of information redundancy in video reasoning models when processing text information is solved, thus improving the accuracy of video reasoning.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SUN YAT SEN UNIV
- Filing Date
- 2026-06-24
- Publication Date
- 2026-07-21
AI Technical Summary
Existing video reasoning models are prone to information redundancy when processing large amounts of text information, which can interfere with the focus on visual information and affect the accuracy of reasoning.
A video knowledge graph is constructed, and the query difficulty is evaluated by an intelligent agent. A compact subgraph is retrieved and converted into a visual reasoning frame, which is then fused with the video frame to form an extended video sequence. This sequence is then input into the video reasoning model for reasoning.
By naturally integrating structured knowledge with original visual content, information redundancy and attentional interference are avoided, thereby improving the accuracy of video reasoning.
Smart Images

Figure CN122432382A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of video processing technology, and in particular to a method, device and storage medium for video reasoning based on visual spatial knowledge fusion. Background Technology
[0002] Video reasoning models, by jointly processing visual and textual information, can semantically understand video content and answer user questions. In practical applications, video understanding tasks often involve knowledge retrieval enhancement techniques, which involve retrieving information relevant to the user's query from external knowledge bases and providing the retrieved knowledge to the video reasoning model for inference, thereby improving the model's ability to answer complex questions.
[0003] However, current video retrieval enhancement methods typically append the retrieved knowledge as text to the model input. Since video inference models rely primarily on visual features when processing video information, when a large amount of text information is appended to the input prompts, it can easily lead to information redundancy, interfere with the video inference model's focus on visual information, and thus affect the inference effect, resulting in lower accuracy of video inference.
[0004] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0005] The main objective of this application is to provide a visual spatial knowledge fusion video reasoning method, device, and storage medium, aiming to solve the technical problem of how to improve the accuracy of video reasoning.
[0006] To achieve the above objectives, this application proposes a visual spatial knowledge fusion video reasoning method, which includes: Constructing a video knowledge graph based on video data; Obtain the query statement and determine the query difficulty coefficient of the query statement through a preset intelligent agent; When the query difficulty coefficient is greater than a preset threshold, a compact subgraph is retrieved from the video knowledge graph according to the query statement. The compact subgraph is converted into a visual inference frame, and the visual inference frame is fused with the video frame in the video data to obtain an extended video sequence; The extended video sequence and the query statement are input into the video inference model, and the video inference model generates video inference results.
[0007] In one embodiment, the video knowledge graph includes an event causal view, and the step of constructing the video knowledge graph based on video data includes: Video keyframes are obtained by sampling the video data; In the video keyframes, human and object entities are extracted as nodes, and the interaction relationships between the human and object entities are extracted as relationship edges. Each pair of person entity nodes and object entity nodes connected by a relation edge is taken as an event node. The temporal order of each event node is determined according to the occurrence time corresponding to the relation edge in the event node. Based on the temporal sequence, the causal relationship edges between the event nodes are determined to obtain the event causal view.
[0008] In one embodiment, the video knowledge graph further includes a scene availability view, and the step of constructing the video knowledge graph based on video data further includes: Video keyframes are obtained by sampling the video data; In the video keyframes, scene entities and object entities are extracted as nodes; The object attributes of the object entity are used as the node attributes of the object entity node, and the spatial positional relationship between the object entity and the scene entity is used as the relation edge to obtain the scene availability view.
[0009] In one embodiment, the frequency knowledge graph further includes a cross-link graph, and the step of constructing the video knowledge graph based on video data further includes: Based on the same object entity nodes in the event causal view and the scene availability view, the event causal view and the scene availability view are associated to obtain the cross-link graph.
[0010] In one embodiment, the step of retrieving a compact subgraph in the video knowledge graph according to the query statement includes: Generate a query vector based on the query statement; Based on the relevance score between the query vector and the nodes in the video knowledge graph, the target node is determined in the video knowledge graph; Based on the relevance score corresponding to the target node and the preset complexity constraint parameters, the subgraph nodes of the compact subgraph are determined in the target node; The compact subgraph is determined based on the subgraph node and the edge corresponding to the subgraph node in the video knowledge graph.
[0011] In one embodiment, the step of converting the compact subgraph into a visual inference frame includes: Based on the type of the subgraph node, the subgraph node is converted into the corresponding visual element; Transform the edges in the compact subgraph into relational lines connecting the visual elements; The visual inference frame is generated based on the visual elements and the relationship lines.
[0012] In one embodiment, the step of fusing the visual inference frame with the video frames in the video data to obtain an extended video sequence includes: Convert the visual inference frame into an image of a preset resolution; The image is inserted at the end of the video frame sequence to obtain the extended video sequence.
[0013] In one embodiment, the step of determining the query difficulty coefficient of the query statement through a preset intelligent agent includes: A first prompt word is generated based on the query statement, the video data, and the video knowledge graph. The first prompt word is then input into the intelligent agent, which determines the first difficulty score of the query statement. A second prompt word is generated based on the query statement and the video data. The second prompt word is input into the intelligent agent, and the second difficulty score of the query statement is obtained through the intelligent agent. The query difficulty coefficient is determined based on the difference between the first difficulty score and the second difficulty score.
[0014] Furthermore, to achieve the above objectives, this application also proposes a visual spatial knowledge fusion video reasoning device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the visual spatial knowledge fusion video reasoning method as described above.
[0015] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the visual spatial knowledge fusion video reasoning method described above.
[0016] This application provides a visual spatial knowledge fusion video reasoning method. First, a video knowledge graph is constructed based on video data. Then, a query statement is obtained, and the query difficulty coefficient of the query statement is determined by a preset intelligent agent. When the query difficulty coefficient is greater than a preset threshold, a compact subgraph is retrieved from the video knowledge graph according to the query statement. The compact subgraph is converted into a visual reasoning frame, and the visual reasoning frame is fused with the video frames in the video data to obtain an extended video sequence. Finally, the extended video sequence and the query statement are input into a video reasoning model, and the video reasoning model generates a video reasoning result.
[0017] The above method constructs a video-specific structured knowledge graph, converts the retrieved key knowledge subgraphs into visual reasoning frames, and then merges them with the original video frames in a temporal appending manner to form a unified extended visual sequence input multimodal large model. This allows structured knowledge and original visual content to be naturally integrated within the model, avoiding information redundancy and attention interference caused by text knowledge injection, thereby improving the accuracy of video reasoning. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart illustrating an embodiment of the visual spatial knowledge fusion video reasoning method of this application. Figure 2 This is a flowchart illustrating Embodiment 2 of the visual spatial knowledge fusion video reasoning method of this application; Figure 3 A simplified flowchart illustrating the visual spatial knowledge fusion video reasoning method provided in Embodiment 2 of this application; Figure 4 This is a schematic diagram of the device structure of the hardware operating environment involved in the visual spatial knowledge fusion video reasoning method in the embodiments of this application.
[0021] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0022] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of this application and are not intended to limit this application.
[0023] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific embodiments. It should be noted that all actions involving the acquisition of signals, information, or data in this application are performed in accordance with the relevant data protection laws and regulations of the country where the application is located, and with authorization from the owner of the corresponding device.
[0024] Video reasoning models, by jointly processing visual and textual information, can semantically understand video content and answer user questions. In practical applications, video understanding tasks often involve knowledge retrieval enhancement techniques, which involve retrieving information relevant to the user's query from external knowledge bases and providing the retrieved knowledge to the video reasoning model for inference, thereby improving the model's ability to answer complex questions.
[0025] In view of the above problems, this application proposes a video reasoning method based on visual spatial knowledge fusion. First, a video knowledge graph is constructed based on video data. Then, a query statement is obtained, and the query difficulty coefficient of the query statement is determined by a pre-defined agent. When the query difficulty coefficient is greater than a pre-defined threshold, a compact subgraph is retrieved from the video knowledge graph according to the query statement. The compact subgraph is converted into a visual reasoning frame, and the visual reasoning frame is fused with the video frames in the video data to obtain an extended video sequence. Finally, the extended video sequence and the query statement are input into a video reasoning model, and the video reasoning model generates a video reasoning result.
[0026] The above method constructs a video-specific structured knowledge graph, converts the retrieved key knowledge subgraphs into visual reasoning frames, and then merges them with the original video frames in a temporal appending manner to form a unified extended visual sequence input multimodal large model. This allows structured knowledge and original visual content to be naturally integrated within the model, avoiding information redundancy and attention interference caused by text knowledge injection, thereby improving the accuracy of video reasoning.
[0027] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device capable of implementing the above functions and a visual spatial knowledge fusion video reasoning system, etc. The following description uses a visual spatial knowledge fusion video reasoning system as an example to illustrate this embodiment and the subsequent embodiments.
[0028] First Embodiment The first embodiment of this application provides a visual spatial knowledge fusion video reasoning method, referring to... Figure 1 In this embodiment, the visual spatial knowledge fusion video reasoning method includes steps S10~S50: Step S10: Construct a video knowledge graph based on video data.
[0029] It's important to note that the video data is the raw, unprocessed video input. The visual spatial knowledge fusion video reasoning system first acquires this video data and extracts features from it. Based on the extracted visual information features, it constructs a video knowledge graph. Since it's difficult for video reasoning models to understand the complex spatiotemporal relationships and implicit logic within long videos, constructing a video knowledge graph is equivalent to pre-organizing and summarizing a structured summary of the video content for the video reasoning model, reducing the cognitive load on the model when directly understanding the raw video.
[0030] Optionally, the aforementioned video knowledge graph includes an event causal view. As a first alternative scheme for constructing a video knowledge graph, step S10 includes steps S11 to S14: Step S11: Sample the video data to obtain video keyframes.
[0031] The original video data is usually a media stream consisting of consecutive image frames. As an option for the first sampling method to extract video keyframes, video keyframes can be extracted from consecutive image frames at a preset sampling rate, which reduces the amount of data to be processed while retaining the main visual information.
[0032] In addition to extracting video keyframes according to a preset sampling rate, as a second optional method for sampling and extracting video keyframes, the difference values between consecutive frames at the pixel level, feature level, or motion vector level can be calculated. For example, the difference value can be the histogram difference between consecutive frames, the inter-frame difference, or the change value of the optical flow field. When the calculated difference value exceeds a preset threshold, it is determined that a significant scene transition or subject motion has occurred, and any frame in the aforementioned consecutive frames is taken as the aforementioned video keyframe.
[0033] As a second option for sampling and extracting video keyframes, a trained neural network model can be used to directly evaluate and predict the importance score of the video content in each video keyframe, and the video keyframe can be determined based on the importance score.
[0034] Step S12: In the video keyframes, extract the human and object entities as nodes, and extract the interaction relationship between the human and object entities as relationship edges.
[0035] A person entity refers to a person appearing in the video frame, while an object entity refers to an item, tool, or building appearing in the video frame, such as a "cup," a "chair," and a "door." The interaction relationship between person and object entities refers to the specific dynamic association that occurs between a person entity and an object entity in a single video keyframe or a preset number of consecutive video keyframes, such as "picking up," "sitting on," and "looking."
[0036] For example, the steps for extracting person and object entities may specifically include: for each video keyframe, using an object detection model, such as a deep learning-based detector, to identify and locate all person and object bounding boxes in the video keyframe. For each detected entity bounding box, its specific category is determined using an image recognition model or classifier, such as "person-chef" or "object-pot," thereby instantiating person and object entity nodes. The node attributes of each node include a category label, a unique identifier, and its spatial location in the video keyframe.
[0037] As a first option for extracting the interaction relationships between human and object entities, based on the extraction of the aforementioned human and object entities, a pre-trained deep learning model can be used to directly input video keyframes into the deep learning model, and the deep learning model can output structured human-object interaction triples.
[0038] For example, each video keyframe, along with the bounding box coordinates and category labels of the identified entities within it, is formatted into an input format acceptable to the deep learning model, resulting in a formatted single-frame data sample. Preferably, a scene graph generation model such as MotifNet (Motif-based Scene Graph Generation Network), VTree (Visual Context Tree Network), or its variants, is used as the deep learning model. The deep learning model first encodes the input single-frame data sample using its visual backbone network, such as ResNet (Residual Network) or Vision Transformer, to extract a global visual feature map. Simultaneously, the deep learning model utilizes an object detection sub-network, such as Faster R-CNN (Faster Region-based Convolutional Neural Network), or directly uses the detection results provided by the aforementioned object detection model to locate and identify all entities in the single-frame data sample, generating a visual feature vector and bounding box coordinates for each entity. Next, the deep learning model generates all possible person-object entity pairs as candidate interaction pairs. For each candidate interaction pair (person i, object j), the deep learning model fuses the visual features of the two entities from the global feature map and encodes their spatial relationship features, including geometric information such as the relative position, size ratio, and overlapping area of the two bounding boxes. Then, these spatial relationship features are used as input to a relationship classifier in the deep learning model, such as a fully connected network or graph neural network layer, for forward propagation computation. The output layer of the relationship classifier is a multi-class classifier, where each output node corresponds to a predefined interaction relationship category, such as "holding," "looking," "sitting," and "near." Simultaneously, the deep learning model calculates the probability distribution of each candidate interaction pair belonging to each interaction relationship category. Finally, for each candidate interaction pair, the interaction relationship category with the highest probability value is selected as the prediction result. A confidence threshold is applied for filtering, retaining only candidate interaction pairs whose prediction results exceed the confidence threshold and whose interaction relationship category is not "unrelated." Finally, each retained candidate interaction pair is combined with the predicted interaction relationship category to form a semantic triple of <person entity, interaction relationship category, object entity>. This triple contains a specific person identifier, an object identifier, and a relational predicate.
[0039] As a second alternative for extracting the interaction relationships between human and object entities, the pixel coordinates of key points on the human skeleton can be determined using a human pose estimation model and the human bounding box. Based on predefined functional interaction areas of these key points—for example, defining a certain radius around the left and right wrist key points as the "hand operation area," and defining the area enclosed by key points on the torso such as the shoulders and hips as the "body bearing area"—for each human-object entity pair, the spatial relationship between the object's bounding box and each functional interaction area of the human is calculated. This spatial relationship includes, but is not limited to: overlap (e.g., intersection-over-union ratio); distance (e.g., the Euclidean distance from the center point of the object's bounding box to the hand key point); and relative orientation (i.e., the object's position relative to the human body). After obtaining the spatial relationships of the human-object entity pairs, a predefined interaction relationship inference rule library is loaded. Using "IF-THEN" logic, the spatial relationships and the entity categories in the human-object entity pairs are used as conditions to match the rules in the interaction relationship inference rule library, thus determining the interaction relationship corresponding to each human-object entity pair.
[0040] For example, the rules in the inference rule base can be: IF the object category is "chair" AND the overlap between the object's bounding box and the human body's "body support area" is greater than threshold 1, THEN the interaction relationship is "sitting on..."; IF the overlap between the object's bounding box and any "hand operation area" is greater than threshold 2, THEN the interaction relationship is "holding".
[0041] Step S13: Treat each pair of person entity nodes and object entity nodes connected by relation edges as an event node, and determine the temporal order of each event node according to the occurrence time corresponding to the relation edge in the event node.
[0042] An event node refers to a complete semantic unit formed by a specific pair of human and object entities through a specific interaction at a specific moment. It abstractly represents an instantaneous or short-term action or state, such as "the chef picks up the pot".
[0043] For example, after determining the aforementioned character entity nodes and object entity nodes, as well as the relationship edges between character entity nodes and object entity nodes, each relationship edge and the nodes at both ends are defined as an event node. The timestamp of the video keyframe corresponding to the interaction between the character entity node and the object entity node is taken as the occurrence time of the relationship edge, and this occurrence time is taken as the event time of the event node. The event times are sorted in ascending order to determine the temporal order of each event node. Event nodes occurring in the same video keyframe can be considered concurrent events.
[0044] Step S14: Based on the temporal sequence, determine the causal relationship edges between the event nodes to obtain the event causal view.
[0045] A causal relationship edge is a directed edge that connects two event nodes in an event causal view. It indicates that the former event is the cause of the latter event, or that there is a high probability that the former will cause the latter.
[0046] For example, for each pair of event nodes that are adjacent or close in temporal order, denoted as event A and event B, where event A precedes event B, the visual spatial knowledge fusion video reasoning system creates a directed causal relationship edge from event A to event B in the event causal view.
[0047] Preferably, if the interaction relationship between the person entity and the object entity is not extracted in the video keyframe, the state feature of the person in the video keyframe is identified, the state feature is used as the node attribute of the person entity node, and the person entity node with the node attribute is used as the event node.
[0048] The event causal view created through the above steps can depict how a series of micro-events in video data are connected and progressively advanced through causal relationships, thereby forming a macro-event evolution path.
[0049] Optionally, in addition to the event causal view described above, the video knowledge graph also includes a scene availability view. As a second alternative scheme for constructing a video knowledge graph, step S10 above also includes steps S15 to S17: Step S15: Sample the video data to obtain video keyframes.
[0050] The implementation method for sampling and extracting key frames from video can refer to step S11 above, and will not be repeated here.
[0051] Step S16: Extract scene entities and object entities as nodes from the video keyframes.
[0052] For example, the step of extracting scene entities from video keyframes may include: classifying the image pixels of each video keyframe using a semantic segmentation model to identify different semantic regions such as sky, road, building, bedroom, and desktop; instantiating consecutive regions of the same category into a scene entity node; and recording its category and spatial extent. This spatial extent can be a mask or a bounding box. The steps for extracting entity objects can refer to step S12 above and will not be elaborated here.
[0053] Step S17: Use the object attributes of the object entity as the node attributes of the object entity node, and use the spatial positional relationship between the object entity and the scene entity as the relation edge to obtain the scene availability view.
[0054] It should be noted that the aforementioned object attributes may include the object's visual appearance attributes, physical state attributes, and functional attributes. Preferably, in this embodiment, the aforementioned object attributes also include the execution action associated with the object entity. This execution action refers to the operation that a person associated with a specific object can perform on that object, representing the object's availability and describing its potential use, rather than the actual action occurring in the video. For example, the execution action associated with "chair" could be "sit," and the execution action associated with "door" could be "open" or "pass through." The aforementioned object attributes are attached as node attributes to the corresponding object entity nodes.
[0055] The spatial relationship between an object entity and a scene entity refers to the orientation or containment relationship of the object entity relative to the scene entity, such as "above," "inside," "near," or "attached to." For example, the steps to extract the spatial relationship between an object entity and a scene entity may include: traversing each object entity node and each scene entity node; for each pair of object entities and scene entities, determining their spatial relationship based on their spatial position information in the current video keyframe, including: determining whether the object bounding box overlaps with the semantic region mask of the scene; if there is an overlap, further determining the relative orientation between the center point of the object bounding box and the center point of the semantic region mask of the scene, and determining whether the object bounding box is completely within the semantic region mask of the scene. Here, the above spatial relationship can be represented by a preset encoding value, and this preset encoding value can be used as an edge attribute to create directed relationship edges between object entity nodes and scene entity nodes, thus obtaining the above scene availability view.
[0056] The role of scene availability views is to model the environment, objects and their inherent functions in a video. This forms the static context and physical constraints for understanding any behavior or event in the video, and helps video inference models understand what objects exist in what environment, what attributes these objects have and what their potential uses are.
[0057] Optionally, in addition to the event causal view and scene availability view mentioned above, the video knowledge graph also includes a cross-link graph. As a third optional scheme for constructing a video knowledge graph, step S10 above further includes: associating the event causal view and scene availability view based on the same object entity nodes in the event causal view and scene availability view to obtain a cross-link graph.
[0058] In the aforementioned event causal view and scene availability view, there are nodes that point to the same specific object in the video. For example, the "pot" node in the event view that participates in the event of "the chef picking up the pot" is the same object entity node as the "pot" node located on the "stove" in the scene view that has a "cooking" function. Therefore, the event causal view and scene availability view can be associated based on this same object entity node, allowing a node in one view to track and access the node representing the same entity in the other view and all its associated information. Specifically, a bridge edge can be created between the same object entity nodes in the event causal view and scene availability view to associate them; or the associated nodes and associated edges of the same object entity node in the event causal view can be migrated to the same object entity node in the scene availability view to associate them.
[0059] The aforementioned cross-links enable the fusion of knowledge between event evolution and scene context, providing complete structured knowledge for subsequent complex queries, knowledge retrieval, and visual reasoning. For example, starting from an event node "the boy breaks the cup" in the event causal view, one can find the object "cup" involved, and then, through cross-view bridging edges, jump to the corresponding "cup" node in the scene availability view. This allows obtaining information such as the cup's material "glass" and its spatial location "at the edge of the table," thus completing the compound reasoning that "because the cup is glass and at the edge of the table, it will scatter glass shards on the ground after breaking."
[0060] Step S20: Obtain the query statement and determine the query difficulty coefficient of the query statement through a preset intelligent agent.
[0061] A query is a natural language question or instruction entered by a user, designed to seek answers or make inferences about given video content. For example: "Why did the person in the video leave the room at the end?"
[0062] The agent is configured as a proxy module capable of understanding tasks, self-reflection, and outputting evaluation scores. Its role is to simulate the reasoning process under different knowledge support conditions after receiving a user query and related video context information. By comparing its own information differences during this process, it quantifies the complexity of the current query and ultimately outputs a query difficulty coefficient to guide subsequent processes.
[0063] This application does not limit the specific implementation of the intelligent agent, but aims to cover various feasible methods that can be conceived by those skilled in the art. As an optional implementation, the intelligent agent can be based on an existing, large-scale pre-trained general-purpose large language model or a large-scale multimodal model, guided by prompts to complete the aforementioned evaluation task. In this implementation, there is no need to retrain the agent's internal parameters; simply changing the input instructions is sufficient for it to perform the evaluation function. As another optional implementation, the intelligent agent can also be a dedicated evaluation model self-trained or fine-tuned based on specific task data, such as video question-answering difficulty annotation data. Such dedicated evaluation models can learn the difficulty evaluation criteria more accurately through supervised learning. Regardless of the specific model used, the deployment of the intelligent agent serves the same purpose: to pre-evaluate the query difficulty before formally calling the video reasoning model for reasoning. For simple queries, the visual spatial knowledge fusion video reasoning system will directly input the query statement into the video reasoning model for reasoning to improve processing efficiency; for queries deemed complex, it will automatically trigger a knowledge retrieval and fusion enhancement reasoning path, combining the video knowledge graph and the query statement for reasoning to improve the accuracy of video reasoning.
[0064] Step S30: When the query difficulty coefficient is greater than a preset threshold, a compact subgraph is retrieved from the video knowledge graph according to the query statement.
[0065] A compact subgraph is a substructure retrieved from a video knowledge graph that is most semantically relevant to the current query. Its purpose is to provide the video reasoning model with the most relevant structured knowledge context necessary to solve the query problem.
[0066] When the query difficulty coefficient output by the agent is less than or equal to a preset threshold, it is determined to be a simple query, and the query statement is directly input into the video inference model for inference. When the query difficulty coefficient output by the agent is greater than the preset threshold, it is determined to be a complex query. Based on the query statement, a compact subgraph is retrieved from the video knowledge graph. This compact subgraph is used as auxiliary knowledge and input together with the query statement into the video inference model to help the video inference model generate more accurate video inference results.
[0067] Furthermore, the steps described above for retrieving a compact subgraph from the video knowledge graph based on the query statement include steps S31 to S34: Step S31: Generate a query vector based on the query statement.
[0068] A query vector is a fixed-dimensional numerical array that represents the semantics of a query statement. It maps the semantic information of the text into a continuous vector space so that it can be compared with the vector representations of nodes in a knowledge graph.
[0069] For example, the above query statement is processed by a pre-trained text embedding model such as BERT (Bidirectional Encoder Representations from Transformers, a bidirectional deep pre-trained encoder based on Transformer) or Sentence-BERT (Sentence Bidirectional Encoder Representations from Transformers, a sentence-level bidirectional Transformer pre-trained encoding model) for word segmentation, encoding, etc., to aggregate the information of the entire sentence and output a dense vector that can represent the global semantics of the query, i.e., the query vector.
[0070] Step S32: Determine the target node in the video knowledge graph based on the relevance score between the query vector and the nodes in the video knowledge graph.
[0071] For example, each node in the video knowledge graph is traversed. For each node, the semantic similarity between its node vector and the query vector is calculated as the relevance score mentioned above. The formula for calculating the relevance score is: ,in For query vector, For video knowledge graphs The node vector of the i-th node in the array. A relevance score is assigned. Nodes whose semantic similarity is greater than a preset similarity threshold are selected as target nodes.
[0072] Preferably, based on the relevance score between the query vector and the nodes in the cross-link graph, nodes corresponding to node vectors with a relevance score greater than a first similarity threshold are prioritized as target nodes. If the relevance score between the query vector and the nodes in the cross-link graph is greater than a second similarity threshold but less than the first similarity threshold, then it is determined whether the relevance score between the query vector and the adjacent nodes of that node is greater than the first similarity threshold. If the relevance score between the query vector and the adjacent nodes of that node is greater than the first similarity threshold, meaning that the node itself has low relevance but is located at the center of two highly relevant paths, then that node is also selected as a target node to ensure the logical coherence of the retrieved knowledge. Here, the first similarity threshold is greater than the second similarity threshold.
[0073] The node vector can be obtained by encoding the node attributes of the node or encoding the node attributes and the edge attributes of the associated edges, using the same method as in step S31.
[0074] Step S33: Based on the relevance score corresponding to the target node and the preset complexity constraint parameters, determine the subgraph node of the compact subgraph in the target node.
[0075] Complexity constraint parameters are used to control the size of the final retrieved subgraph. They can be an upper limit on the maximum number of nodes or a regularization coefficient used to balance relevance and complexity. The purpose is to prevent the retrieved compact subgraph from being too large or too complex, which would overload the information in the converted visual inference frame.
[0076] For example, the formula for determining the subgraph nodes of the compact subgraph can be as follows:
[0077] in, Subgraph nodes representing compact subgraphs, Indicates the target node. This function represents the index of the maximum value in a given array. Represents correlation. and These are complexity constraint parameters, representing the complexity regularization term and the balance coefficient, respectively.
[0078] Step S34: Determine the compact subgraph based on the subgraph node and the edge corresponding to the subgraph node in the video knowledge graph.
[0079] After identifying the subgraph nodes of the compact subgraph, all relational edges connecting these subgraph nodes are determined in the original video knowledge graph. These extracted relational edges are then combined with the subgraph nodes to reconstruct a new data structure, resulting in the aforementioned compact subgraph.
[0080] Step S40: Convert the compact subgraph into a visual inference frame, and fuse the visual inference frame with the video frame in the video data to obtain an extended video sequence.
[0081] It should be noted that a visual reasoning frame is a static image generated from structured knowledge to aid reasoning. It is a visual representation transformed from the compact subgraph retrieved in step S30 according to specific visual grammar rules. The extended video sequence is a new, longer frame sequence formed by splicing the original video frame sequence and the visual reasoning frame in the temporal dimension.
[0082] Furthermore, the step of converting the compact subgraph into a visual inference frame includes steps S41-S43: Step S41: Based on the type of the subgraph node, convert the subgraph node into the corresponding visual element.
[0083] Visual elements refer to the geometric shapes or icons that represent a subgraph node in the generated visual inference frame image. There is a one-to-one correspondence between visual elements and node types. For example, all character entity nodes are represented by blue visual elements, and the "chef" character is represented by a blue "chef's hat."
[0084] Step S42: Convert the edges in the compact subgraph into relational lines connecting the visual elements.
[0085] Step S43: Generate the visual inference frame based on the visual elements and the relationship lines.
[0086] The edges connecting two subgraph nodes in a compact subgraph are converted into relationship lines in the visual inference frame image, connecting two visual elements. The style of these relationship lines is determined from preset rules based on the edge attributes of the edges between the two subgraph nodes. This includes line type (solid or dashed), color (red for causal relationships, black for spatial relationships), and endpoint shape (one-way arrows for causal directions, no-arrow lines for equivalence). These visual elements and relationship lines are then combined to generate the visual inference frame.
[0087] It is understandable that the compact subgraph obtained after retrieval is essentially a structured subset of the video knowledge graph, stored as a numerical matrix of nodes and edges, representing the entities, events, and their logical relationships most relevant to the query. However, the core reasoning mechanism of the video reasoning model relies on attention calculation of visual sequences. If abstract structured data is directly input in numerical or text form, it will face technical problems of modality mismatch and low information utilization efficiency. Therefore, this embodiment converts the graph structure represented by the numerical matrix into a static image composed of visual elements and relation lines, i.e., a visual reasoning frame, according to preset visual grammar rules. This allows abstract symbolic logical knowledge to be translated into visual spatial information that the video reasoning model excels at. As a result, the knowledge for auxiliary reasoning and the original video frame can be presented in the same visual modality, thus seamlessly integrating into the visual encoding and attention calculation process of the video reasoning model, eliminating information loss caused by cross-modal fusion, and improving the accuracy of video reasoning.
[0088] Furthermore, the step of fusing the visual inference frame with the video frame in the video data to obtain the extended video sequence includes steps S44-S45: Step S44: Convert the visual inference frame into an image with a preset resolution.
[0089] Step S45: Insert the image into the end of the video frame sequence to obtain the extended video sequence.
[0090] For example, the size of the visual inference frame is first checked. If its resolution does not match the preset resolution, an image scaling algorithm, such as bilinear interpolation, is used to resample it to the preset width and height, resulting in the converted image. The preset resolution can be the resolution of the original video frame. After converting the visual inference frame into an image, this image is appended to the end of the original video frame sequence to obtain an extended video sequence. This extended video sequence temporally includes the original dynamic video content and the static knowledge image at the end.
[0091] The above steps, by converting visual inference frames into visual images and appending them to the end of the video, ensure that the integrity and temporal order of the original video content are not disrupted. This allows key structured knowledge to be provided to the video inference model as a special visual context frame without disturbing any temporal information or content order of the original video.
[0092] Step S50: Input the extended video sequence and the query statement into the video inference model, and generate video inference results through the video inference model.
[0093] Video inference models are used to achieve deep fusion and final inference of multimodal information. They can be any intelligent model capable of receiving temporal visual input and text queries, and generating natural language responses. For example, video inference models can be video understanding models trained on large-scale video-text pairs, such as Video-LLaMA (Video Large Language Model) and Video-ChatGPT (Video ChatGenerative Pre-trained Transformer), which are extensions of visual language models. They can also be general-purpose multimodal large language models with video processing capabilities, such as GPT-4V (Vision) and Gemini 1.5 Pro.
[0094] Second Embodiment Based on the first embodiment described above, in the visual spatial knowledge fusion video reasoning method proposed in the second embodiment of this application, referring to... Figure 2 The above step S20 includes steps S21 to S23: Step S21: Generate a first prompt word based on the query statement, the video data, and the video knowledge graph; input the first prompt word into the intelligent agent; and determine the first difficulty score of the query statement through the intelligent agent.
[0095] Step S22: Generate a second prompt word based on the query statement and the video data, input the second prompt word into the agent, and use the agent to obtain a second difficulty score for the query statement.
[0096] Step S23: Determine the query difficulty coefficient based on the difference between the first difficulty score and the second difficulty score.
[0097] For example, based on the query statement, video data, and video knowledge graph, a first prompt word is generated according to a predetermined template to guide the agent in reasoning under the assumption that it can access the video knowledge graph. The agent receives and understands the first prompt word, performs knowledge-based reasoning simulation internally, and finally outputs a first difficulty score as a self-evaluation result. Simultaneously, based on the query statement and video data, a second prompt word is generated according to a predetermined template to guide the agent in reasoning under the assumption that it relies solely on the video data itself, without relying on additional knowledge graph information. The same agent receives and understands the second prompt word, performs knowledge-based reasoning simulation internally, and finally outputs a second difficulty score as a self-evaluation result. The difference between the first and second difficulty scores is calculated to quantify the expected gain that the video knowledge graph can provide in answering the current query. If the difference is greater than or equal to a preset difference threshold, the knowledge gain is considered significant, meaning the query is complex and the query difficulty coefficient is high. If the difference is less than the preset difference threshold, the knowledge gain is considered limited, meaning the query is simple and the query difficulty coefficient is low.
[0098] Specifically, the formula for determining the query difficulty coefficient can be as follows:
[0099]
[0100] in, This indicates a user query. Indicates the original video. Represents a video knowledge graph. This indicates the score for the first difficulty level. This indicates the score for the second difficulty level. Indicates the preset difference. This indicates that the query is a complex query. This indicates that the query is a simple query.
[0101] Third Embodiment Based on the first and second embodiments described above, this embodiment also proposes a visual-spatial knowledge fusion video reasoning system. This visual-spatial knowledge fusion video reasoning system includes: Knowledge Graph Construction Module: Used to build video knowledge graphs based on video data; Query parsing and hierarchical scheduling module: Obtains the query statement and determines the query difficulty coefficient of the query statement through a preset intelligent agent; Knowledge retrieval module: When the query difficulty coefficient is greater than a preset threshold, it retrieves a compact subgraph from the video knowledge graph based on the query statement; Visual inference frame generation module: converts compact subgraphs into visual inference frames; Multimodal fusion inference module: It fuses visual inference frames with video frames in video data to obtain an extended video sequence, and inputs the extended video sequence and query statement into the video inference model to generate video inference results.
[0102] For example, to help understand the implementation process of the visual spatial knowledge fusion video reasoning method obtained by combining this embodiment with the above embodiments, please refer to... Figure 3 , Figure 3 A simplified flowchart of a video reasoning method based on visual spatial knowledge fusion is provided, specifically: The offline phase corresponds to step S10 in the above embodiment, with the goal of constructing a video knowledge graph. The graph-building agent processes the input video data, identifies dynamic event sequences and their causal logic from the video, and constructs an event causal view; identifies objects, scenes, and their functional attributes and spatial relationships from the video, and constructs a scene availability view; and cross-links the event causal view and scene availability view to form a cross-link graph. The online phase corresponds to steps S20-S50 in the above embodiment. When a user submits a query, such as "Why is this person wearing an overcoat?", the orchestration agent assesses the query difficulty. If the assessment determines the query is simple, the original video V and the query statement are directly input into the multimodal large model, i.e., the video reasoning model. If the assessment determines the query is complex, the retrieval agent accurately locates and extracts a compact subgraph from the video knowledge graph based on the complex query. The rendering agent converts this compact subgraph into a visual graph, i.e., the visual reasoning frame in the scheme, and splices the visual reasoning frame and the original video to form an extended video sequence, i.e., the video... Input to a multimodal large model. Finally, the multimodal large model outputs the video inference result "because he feels cold".
[0103] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the visual spatial knowledge fusion video reasoning method of this application. Any simple transformations based on this technical concept are within the protection scope of this application.
[0104] This application provides a visual spatial knowledge fusion video reasoning device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the visual spatial knowledge fusion video reasoning method in the above embodiment 1.
[0105] The following is for reference. Figure 4 The diagram illustrates a structural schematic suitable for implementing a visual spatial knowledge fusion video reasoning device according to embodiments of this application. The visual spatial knowledge fusion video reasoning device in these embodiments may include, but is not limited to, mobile terminals such as laptops and tablets (PADs, Portable Application Description), and fixed terminals such as desktop computers. Figure 4 The visual spatial knowledge fusion video reasoning device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0106] like Figure 4 As shown, the visual spatial knowledge fusion video reasoning device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the visual spatial knowledge fusion video reasoning device. The processing unit 1001, the read-only memory 1002, and the RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the visual spatial knowledge fusion video reasoning device to communicate wirelessly or wiredly with other devices to exchange data. Although a visual spatial knowledge fusion video reasoning device with various systems is shown in the figure, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented alternatively.
[0107] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0108] The visual spatial knowledge fusion video reasoning device provided in this application, employing the visual spatial knowledge fusion video reasoning method in the above embodiments, can solve the technical problem of how to improve the accuracy of video reasoning. Compared with the prior art, the beneficial effects of the visual spatial knowledge fusion video reasoning device provided in this application are the same as those of the visual spatial knowledge fusion video reasoning method provided in the above embodiments, and other technical features in this visual spatial knowledge fusion video reasoning device are the same as those disclosed in the method of the previous embodiment, and will not be repeated here.
[0109] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0110] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0111] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the visual spatial knowledge fusion video reasoning method in the above embodiments.
[0112] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or flash memory, optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, radio frequency (RF), etc., or any suitable combination thereof.
[0113] The aforementioned computer-readable storage medium may be included in the visual spatial knowledge fusion video reasoning device; or it may exist independently and not be assembled into the visual spatial knowledge fusion video reasoning device.
[0114] The aforementioned computer-readable storage medium carries one or more programs that, when executed by the visual-spatial knowledge fusion video inference device, enable the device to write computer program code for performing the operations of this application in one or more programming languages or combinations thereof. These programming languages include object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, or as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0115] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation that may be implemented in systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0116] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0117] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described visual spatial knowledge fusion video reasoning method, thereby solving the technical problem of how to improve the accuracy of video reasoning. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the visual spatial knowledge fusion video reasoning method provided in the above embodiments, and will not be repeated here.
[0118] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the visual spatial knowledge fusion video reasoning method described above.
[0119] The computer program product provided in this application can solve the technical problem of how to improve the accuracy of video reasoning. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the visual spatial knowledge fusion video reasoning method provided in the above embodiments, and will not be repeated here.
[0120] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A video reasoning method based on visual spatial knowledge fusion, characterized in that, The visual spatial knowledge fusion video reasoning includes: Constructing a video knowledge graph based on video data; Obtain the query statement and determine the query difficulty coefficient of the query statement through a preset intelligent agent; When the query difficulty coefficient is greater than a preset threshold, a compact subgraph is retrieved from the video knowledge graph according to the query statement. The compact subgraph is converted into a visual inference frame, and the visual inference frame is fused with the video frame in the video data to obtain an extended video sequence; The extended video sequence and the query statement are input into the video inference model, and the video inference model generates video inference results.
2. The visual spatial knowledge fusion video reasoning method as described in claim 1, characterized in that, The video knowledge graph includes an event causal view, and the steps of constructing the video knowledge graph based on video data include: Video keyframes are obtained by sampling the video data; In the video keyframes, human and object entities are extracted as nodes, and the interaction relationships between the human and object entities are extracted as relationship edges. Each pair of person entity nodes and object entity nodes connected by a relation edge is taken as an event node. The temporal order of each event node is determined according to the occurrence time corresponding to the relation edge in the event node. Based on the temporal sequence, the causal relationship edges between the event nodes are determined to obtain the event causal view.
3. The visual spatial knowledge fusion video reasoning method as described in claim 2, characterized in that, The video knowledge graph also includes a scene availability view, and the step of constructing the video knowledge graph based on video data further includes: Video keyframes are obtained by sampling the video data; In the video keyframes, scene entities and object entities are extracted as nodes; The object attributes of the object entity are used as the node attributes of the object entity node, and the spatial positional relationship between the object entity and the scene entity is used as the relation edge to obtain the scene availability view.
4. The visual spatial knowledge fusion video reasoning method as described in claim 3, characterized in that, The frequency knowledge graph also includes a cross-link graph, and the step of constructing the video knowledge graph based on video data further includes: Based on the same object entity nodes in the event causal view and the scene availability view, the event causal view and the scene availability view are associated to obtain the cross-link graph.
5. The visual spatial knowledge fusion video reasoning method as described in any one of claims 2 to 3, characterized in that, The step of retrieving a compact subgraph from the video knowledge graph based on the query statement includes: Generate a query vector based on the query statement; Based on the relevance score between the query vector and the nodes in the video knowledge graph, the target node is determined in the video knowledge graph; Based on the relevance score corresponding to the target node and the preset complexity constraint parameters, the subgraph nodes of the compact subgraph are determined in the target node; The compact subgraph is determined based on the subgraph node and the edge corresponding to the subgraph node in the video knowledge graph.
6. The visual spatial knowledge fusion video reasoning method as described in claim 5, characterized in that, The step of converting the compact subgraph into a visual inference frame includes: Based on the type of the subgraph node, the subgraph node is converted into the corresponding visual element; Transform the edges in the compact subgraph into relational lines connecting the visual elements; The visual inference frame is generated based on the visual elements and the relationship lines.
7. The visual spatial knowledge fusion video reasoning method as described in claim 6, characterized in that, The step of fusing the visual inference frame with the video frame in the video data to obtain the extended video sequence includes: Convert the visual inference frame into an image of a preset resolution; The image is inserted at the end of the video frame sequence to obtain the extended video sequence.
8. The visual spatial knowledge fusion video reasoning method as described in claim 1, characterized in that, The step of determining the query difficulty coefficient of the query statement through a preset intelligent agent includes: A first prompt word is generated based on the query statement, the video data, and the video knowledge graph. The first prompt word is then input into the intelligent agent, which determines the first difficulty score of the query statement. A second prompt word is generated based on the query statement and the video data. The second prompt word is input into the intelligent agent, and the second difficulty score of the query statement is obtained through the intelligent agent. The query difficulty coefficient is determined based on the difference between the first difficulty score and the second difficulty score.
9. A visual spatial knowledge fusion video reasoning device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the visual spatial knowledge fusion video reasoning method as described in any one of claims 1 to 8.
10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the visual spatial knowledge fusion video reasoning method as described in any one of claims 1 to 8.