Video subtitle generation method and device and storage medium
By introducing the image subtitle model and regional clustering selection into video subtitle generation, the problem of existing methods that ignore timing characteristics and task differences is solved, more efficient and accurate subtitle generation is achieved, and the video subtitle generation capability is improved.
Patent Information
- Application Number
- CN202410694213.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-05-31
AI Technical Summary
Existing video subtitle generation methods ignore the temporal characteristics of video frames and the differences between target detection tasks and subtitle tasks, resulting in insufficient accuracy and effectiveness of model output.
A method based on image subtitle model and region cluster selection is adopted to improve the accuracy and effectiveness of the subtitle generation model through video frame temporal feature encoding and target detection region clustering. Specific steps include: obtaining video frame features, performing target detection and knowledge graph input, clustering and counting target detection area features, and using a multi-modal decoder to generate final subtitles.
The accuracy and efficiency of video subtitle generation are significantly improved. Subtitle generation is optimized through temporal feature encoding and cluster selection, which enhances the model's understanding ability and output effectiveness.
Smart Images

Figure CN118695047A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of video processing, and in particular to a method, device and storage medium for generating video subtitles. Background Art
[0002] Video captioning is a task that combines computer vision and natural language processing technologies to automatically generate descriptive text for video content. Visual features of video frames are extracted through deep learning models (such as Resnet and Vittransformer), and multimodal information such as audio, speech transcription, frame object detection results, knowledge graphs, etc. may be combined. This information is then processed by a sequence-to-sequence (Seq2Seq) model, such as a long short-term memory network (LSTM) or a transformer, to generate a coherent text description. Video captioning has a wide range of applications in areas such as barrier-free services, content retrieval, and automatic caption generation. It can improve the understanding of video content by visually impaired people and enhance the efficiency of video search. With the continuous development of technology, the ability of video captioning is gradually improving, which is of great value in promoting the application of artificial intelligence in multimedia content understanding and generation. In community scenarios, video captioning technology has great potential and has a significant impact on enhancing the interactivity and accessibility of the community. For example, real-time captioning is provided for public safety videos to help the hearing-impaired obtain emergency information, or subtitles are automatically generated in live broadcasts of community activities so that residents with different language backgrounds can also participate in the activities. As technology advances, it is expected that video captioning technology will be able to provide more accurate and nuanced analysis of video content, such as identifying specific community activities or cultural elements and generating more culturally sensitive and personalized descriptions.
[0003] However, existing methods for generating video subtitles have certain limitations. First, most existing methods directly sample video frames from raw video data, extract multimodal features such as audio and text transcription for feature fusion, and use these features to extract as much video-related information as possible, thereby improving the accuracy of model output. However, they ignore the temporal characteristics of video frames, and the accuracy of model output still needs to be improved. Second, many existing methods use target detection output to extract the areas where video objects are located as key areas, thereby encouraging the model to pay more attention to these areas during reasoning. In order to reduce noise, they select a fixed number of k areas for each frame based on the confidence of the target detection output. This selection method ignores the difference between the target detection task and the subtitle task, and reduces the effectiveness of the model output. Therefore, how to further improve the accuracy and effectiveness of video subtitle generation has become a problem that needs to be solved in this field. Summary of the invention
[0004] The purpose of the present invention is to provide a video subtitle generation method, device and storage medium in order to overcome the defects of the above-mentioned prior art. The method is based on an image subtitle model and regional clustering selection, which can improve the accuracy and effectiveness of the output of the video subtitle generation model on the basis of the existing method.
[0005] The purpose of the present invention can be achieved by the following technical solutions:
[0006] According to a first aspect of the present invention, a method for generating video subtitles is provided, comprising the following steps: obtaining original video data and sampling to obtain video frames; based on the video frames, generating frame subtitles using a trained image subtitle model, obtaining a target detection area and a corresponding label of each video frame using a trained target detection model, and extracting video embedding features using a video encoder model; based on the frame subtitles, deriving a subgraph from a pre-acquired knowledge graph as an additional input feature, and encoding each frame subtitle with a subtitle timing encoder to obtain a corresponding frame subtitle embedding feature; clustering and counting based on the frame subtitles and the target detection area and the corresponding label, and encoding the clustered and counted regional features with a regional spatiotemporal encoder to obtain a clustered and counted regional embedding feature; inputting the video embedding feature, the additional input feature, the frame subtitle embedding feature, and the clustered and counted regional embedding feature into a preset multimodal decoder model to obtain a final video subtitle.
[0007] As a preferred technical solution, the specific process of clustering and counting based on the frame subtitles, the target detection area and the corresponding labels includes: extracting all nouns in the frame subtitles, screening words used to describe objects and obtaining corresponding feature vectors, and calculating the cosine similarity between words; clustering the words based on a pre-set similarity threshold, and selecting the top k clusters with the largest number of samples; extracting the feature vector of the output label of the target detection model, and judging whether each label belongs to the top k clusters, if yes, retaining the target detection area corresponding to the label, otherwise filtering the target detection area corresponding to the label.
[0008] As a preferred technical solution, the specific process of determining whether each label belongs to the first k clusters includes: obtaining the average characteristics of samples in each of the first k clusters; calculating the cosine similarity between the current label and the average characteristics of samples in each cluster, and when the cosine similarity exceeds the pre-set similarity threshold, the current label belongs to the corresponding cluster.
[0009] As a preferred technical solution, the cosine similarity between the words is expressed as:
[0010]
[0011] In the formula, similarity represents the similarity calculation, and X and Y represent the feature vectors of different words.
[0012] As a preferred technical solution, the multimodal decoder model includes a multimodal BERT model.
[0013] As a preferred technical solution, a regional spatiotemporal encoder is used to encode the clustered and counted regional features. The specific process includes:
[0014] imf i =Flatten(ResNet(region i ))
[0015] imr i =Concat(imf i ,Norm(bbox i ))
[0016] rf=MHA((imr 1, imr2,...,imr n )+TE)
[0017] Where imf i Represents the i-th region feature (region i ), imr i It represents the regional features with added position information, rf represents the overall features obtained by fusing all regional features, the Flatten operation flattens the features into one dimension, the ResNet operation refers to the use of the ResNet model to extract regional visualization features, the Concat operation is used for the series connection and splicing of features, Norm represents the normalization operation, bboxi represents the i-th bounding box, MHA represents the calculation of the multi-head attention mechanism, and TE is the temporal encoding.
[0018] As a preferred technical solution, the image subtitle model includes an LLaVA model.
[0019] As a preferred technical solution, the target detection model includes a Faster R-CNN model.
[0020] According to a second aspect of the present invention, there is provided a video subtitle generating device, comprising a memory, a processor, and a program stored in the memory, wherein the processor implements the method when executing the program.
[0021] According to a third aspect of the present invention, there is provided a storage medium having a program stored thereon, wherein the program implements the method described above when executed.
[0022] Compared with the prior art, the present invention has the following beneficial effects:
[0023] 1. The present invention provides a method for generating video subtitles based on an image subtitle model and regional clustering selection. On the basis of the existing video generation model, the present invention further improves the accuracy of video subtitle generation by using an image subtitle model trained on a large number of data sets to generate frame-level subtitles for the video and encode the temporal features of the frame-level subtitles, so that the model can perceive the subtitle information of each video frame and its temporal information, thereby further improving the model capability and the accuracy of video subtitle generation;
[0024] 2. The video subtitle generation method provided by the present invention clusters and counts the target detection categories based on the frame subtitle content, and through similarity calculation and comparison, filters out redundant areas and selects the areas corresponding to all categories in the top k clusters that appear most frequently in the frame subtitles as key areas. This area selection and screening method utilizes the information of the frame subtitles and is more effective than the existing confidence-based selection method;
[0025] 3. The video subtitle generation device provided by the present invention adopts a video subtitle generation method based on an image subtitle model and regional clustering selection, which significantly improves the efficiency of video subtitle generation and ensures the accuracy of video subtitle generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 A schematic diagram of the flow of the video subtitle generation method provided by the present invention;
[0027] Figure 2 Schematic diagram of the framework flow of the method for generating video subtitles in an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0029] Example
[0030] like Figure 1 As shown, the present invention provides a method for generating video subtitles based on an image subtitle model and regional clustering selection. Figure 2 As shown, in this embodiment, the important components of implementing the method include:
[0031] (1) Sampling
[0032] Get the original video data and sample it to get the video frame.
[0033] (2) Extract three types of features from video frames
[0034] 1. Use a video encoder model (such as Video Swin Transformer) to extract video embedding features;
[0035] 2. Use the trained object detector / object detection model (such as Faster R-CNN) to obtain the object detection area and corresponding labels for each frame;
[0036] 3. Generate frame captions using a trained image captioning model (such as LLaVA).
[0037] (3) Knowledge Graph and Subtitle Timing Encoder
[0038] Knowledge graph: Based on the keywords in the frame captions, subgraphs are derived from public large-scale knowledge graphs (such as ConceptNet) as additional knowledge input to obtain additional input features.
[0039] Subtitle timing encoder: Encode the timing features of each frame of subtitles. The encoder can choose LSTM, Transformer, etc. to obtain the corresponding frame subtitle embedding features.
[0040] (4) Calculate similarity
[0041] Use the stanza toolkit to extract all nouns in the frame captions, use wordnet to filter out the words used to describe objects in the nouns, use the word2vec model to obtain the feature vectors of the words, and calculate the cosine similarity between the words:
[0042]
[0043] In the formula, similarity represents the similarity calculation, and X and Y represent the feature vectors of different words used to describe the object.
[0044] (5) Clustering and counting
[0045] According to the pre-set feature similarity threshold, the words are clustered and the top k clusters with the largest number of samples are selected. This step is to remove noise. Then, wordnet is used to extract the feature vector of the target detector output label, and it is judged whether the label belongs to the top k clusters. If it does, the area corresponding to the label will be retained and used as the input of the model, otherwise the area will be filtered.
[0046] The specific process of judging whether a label belongs to the first k clusters includes:
[0047] Get the average characteristics of samples in each cluster of the first k clusters;
[0048] The cosine similarity between the current label and the average feature of samples in each cluster is calculated. When the cosine similarity exceeds the preset similarity threshold, the current label belongs to the corresponding cluster.
[0049] This step mainly filters out most of the regions output by target detection, most of which are redundant, in order to leave the regions corresponding to the labels that appear more frequently in the frame caption text, similar to denoising.
[0050] (6) Regional spatiotemporal encoder
[0051] The clustered and counted regional features are encoded using a regional spatiotemporal encoder to obtain clustered and counted regional embedding features. The specific encoding process includes:
[0052] imf i =Flatten(ResNet(region i )) (2)
[0053] imr i =Concat(imf i ,Norm(bbox i )) (3)
[0054] rf=MHA((imr 1, imr2,…,imr n )+TE) (4)
[0055] Where imf i Represents the i-th region feature (region i );imr i Represents the regional features with added location information; rf is the overall feature obtained after integrating all regional features. The Flatten operation flattens the features into one dimension; the ResNet operation refers to the use of the ResNet model to extract regional visualization features; the Concat operation is used for the concatenation and splicing of features; Norm represents the normalization operation; bboxi represents the i-th bounding box (rectangular shape), the content in the bounding box is (x1, y1, x2, y2), representing the pixel coordinates of the two vertices on the main diagonal of the bounding box, and the image framed by the bounding box is the "region" mentioned in this embodiment; MHA represents the calculation of the multi-head attention mechanism, and TE is temporal encoding.
[0056] (7) Multimodal BERT model
[0057] Using the BERT model as a decoder, the multimodal features obtained by Guo Chenchao above, namely the video embedding features, additional input features, frame subtitle embedding features, and clustered and counted region embedding features, are input into the multimodal BERT model to obtain the final video subtitles output by the model.
[0058] Applying the above method in a community, the specific process is as follows:
[0059] 1. Video Collection
[0060] Video data of community scenes is collected through public cameras in the community or uploaded by user mobile terminals, and the videos are evenly sampled to obtain video frames.
[0061] 2. Generate frame subtitles and frame target detection areas
[0062] The image subtitle model LLaVA is used to generate subtitles for each frame, and the target detection model Faster R-CNN is used to generate candidate regions for each frame. Based on the frame subtitles, the stanza toolkit is used to extract nouns in the subtitles, and then wordnet is used to further filter out nouns used to describe objects. The word2vec model is used to obtain the word vector of the word, and then the word vector is used to calculate the cosine similarity between words. Based on the given similarity threshold, DBSCAN is used to cluster the words, and the k clusters with the largest number of cluster samples are filtered out. Then, the word2vec model is used to extract the label output by the target detector. The cosine similarity is used to determine whether the label belongs to the first k clusters. If it does, the area corresponding to the label is retained. The retained area is the key area, otherwise the result is filtered out.
[0063] 3. Multimodal Data Construction
[0064] (I) Video Embedding Construction
[0065] Use the pre-trained Video Swin Transformer model to extract embedding features of the video.
[0066] 2. Embedded construction in key areas
[0067] First, the ResNet model is used to extract the image features of the key areas, and the features are flattened to one dimension. Then, they are concatenated with the normalized bbox. The triangle position embedding is used as the temporal feature to add it to the concatenated features. Then, it is input into the multi-layer Transformer model, and its multi-head attention mechanism is used for temporal encoding to obtain the embedded features of the key areas.
[0068] (III) Embedding construction of frame subtitles
[0069] Use the pre-trained BERT-Base model to extract the subtitle embedding of each frame, take the vector corresponding to the output sentence start [CLS] label to represent the feature embedding of the corresponding subtitle, use triangular position embedding to add frame timing information to the subtitle feature, and then use the multi-layer Transformer model for temporal encoding to obtain the embedding features of the frame subtitle.
[0070] (IV) Construction of Knowledge Graph
[0071] The stanza tool is used to analyze the components of the frame subtitles to form a structured syntax tree. The "adjective-noun", "noun-noun", and "adverb-verb" phrases are collected from the syntax tree. These phrases are used to retrieve and export related subgraphs from the large knowledge graph ConceptNet, and the knowledge contained in the subgraphs is used as the input of the decoder BERT model in the form of prompt words in the form of natural language.
[0072] 4. Multimodal Data Fusion
[0073] The constructed feature encodings of each modality are input into the BERT model as a decoder, and the global self-attention mechanism of the BERT model is used to fuse the modal features and generate the final output.
[0074] In order to prove the effectiveness of this method, experiments were conducted on the existing MSRVTT video captioning dataset and compared with existing methods. According to the same dataset division method as the existing SwinBERT method, the dataset was divided into a training validation set and a test set. The training was done on the training validation set, and the test results were recorded on the test set. The experimental results are shown in Table 1.
[0075] Table 1 Experimental comparison results of this method and existing methods
[0076] method Bleu_4 METEOR ROUGE_L CIDEr SwinBERT 42.0 29.9 62.1 53.8 PickNet 41.3 27.7 59.8 44.1 SibNet 40.9 27.5 60.2 47.5 OA-BTG 41.4 28.2 - 46.9 GRU-EVE 38.3 28.4 60.7 48.1 MGSA 42.4 27.6 - 47.5 POS+CG 42.0 28.2 61.6 48.7 POS+VCT 42.3 29.7 62.8 49.1 SAAT 39.9 27.7 61.2 51.0 STG-KD 40.5 28.3 60.9 47.1 PMI-CAP 42.1 28.7 - 49.4 ORG-TRL 43.6 28.8 62.1 50.9 This method 43.8 30.1 63.3 55.6
[0077] Experimental results show that the method provided in this embodiment is superior to existing methods in most indicators.
[0078] Compared with the existing video subtitle generation method, the method provided in this embodiment uses the image subtitle model to generate subtitles for each frame, encodes the spatiotemporal features of the frame subtitles, and then uses it as a new modal feature. At the same time, compared with the traditional region selection based on the confidence of the target detection result, this method proposes a method based on region cluster selection: first extract the nouns used to describe the object in the frame subtitles, then cluster them based on the cosine similarity of their feature vectors, filter out the top k clusters with the largest number of samples in the class, and then filter out the regions corresponding to the output labels of the target detectors belonging to these top k clusters, and finally encode the spatiotemporal features of these regions. Therefore, the video subtitle generation method provided in this embodiment can effectively improve the performance of the existing model (see the appendix for details) and improve the accuracy and effectiveness of video subtitle generation.
[0079] Further, the present embodiment also provides a video subtitle generation device, including a memory, a processor, and a program stored in the memory, and the processor implements the aforementioned method when executing the program. The device processor includes a central processing unit (CPU), which can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory (ROM) or computer program instructions loaded from a storage unit to a random access memory (RAM). In the RAM, various programs and data required for the operation of the device can also be stored. The CPU, ROM, and RAM are connected to each other through a bus. The input / output (I / O) interface is also connected to the bus. Multiple components in the device are connected to the I / O interface, including: input units, such as keyboards, mice, etc.; output units, such as various types of displays, speakers, etc.; storage units, such as disks, optical disks, etc.; and communication units, such as network cards, modems, wireless communication transceivers, etc. The communication unit allows the device to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunication networks. The processing unit performs the various methods and processes described above, such as the aforementioned method. For example, in some embodiments, the aforementioned method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit. In some embodiments, part or all of the computer program may be loaded and / or installed on the device via a ROM and / or a communication unit. When the computer program is loaded into the RAM and executed by the CPU, one or more steps in the aforementioned method may be performed. Alternatively, in other embodiments, the CPU may be configured to perform the aforementioned method in any other appropriate manner (e.g., by means of firmware). The functions described above may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0080] Further, the present embodiment also provides a storage medium on which a program is stored, and the aforementioned method is implemented when the program is executed. The program code for implementing the method of the present invention can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as an independent software package and partially on a remote machine or completely on a remote machine or server. In the context of the present invention, a computer-readable medium can be a tangible medium that can contain or store a program for use by an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the above. More specific examples of machine-readable storage media would include electrical connections based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fibers, a portable compact disk-read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0081] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A video subtitle generation method, It is characterized in that The following steps are involved: Obtain original video data and sample to obtain video frames; Based on the video frames, using the trained image subtitle model to generate frame subtitles, using the trained object detection model to obtain the object detection area and corresponding labels of each video frame, and using the video encoder model to extract video embedding features; Based on the frame subtitles, a subgraph is derived from a pre-acquired knowledge graph as an additional input feature, and a subtitle temporal encoder is used to encode the temporal features of each frame subtitle to obtain a corresponding frame subtitle embedding feature; Based on the frame subtitles and the target detection area and the corresponding labels, clustering and counting are performed, and regional spatiotemporal encoders are used to encode the clustered and counted regional features to obtain clustered and counted regional embedding features; The video embedding features, the additional input features, the frame subtitle embedding features, and the clustered and counted region embedding features are input into a preset multimodal decoder model to obtain final video subtitles.
2. The video subtitle generation method according to claim 1, It is characterized in that The specific process of clustering and counting based on the frame subtitles, the target detection area and the corresponding labels includes: Extract all nouns in the frame captions, filter the words used to describe the objects and obtain the corresponding feature vectors, and calculate the cosine similarity between the words; Based on the pre-set similarity threshold, the words are clustered and the top k clusters with the largest number of samples are selected; Extract the feature vector of the output label of the target detection model, and determine whether each label belongs to the first k clusters. If yes, retain the target detection area corresponding to the label, otherwise filter the target detection area corresponding to the label.
3. The video subtitle generation method according to claim 2, It is characterized in that The specific process of judging whether each label belongs to the first k clusters includes: Obtaining the average characteristics of samples in each cluster of the first k clusters; The cosine similarity between the current tag and the average feature of the samples in each cluster is calculated. When the cosine similarity exceeds the preset similarity threshold, the current tag belongs to the corresponding cluster.
4. The video subtitle generation method according to claim 2, It is characterized in that The cosine similarity between the words is expressed as: In the formula, similarity represents the similarity calculation, and X and Y represent the feature vectors of different words.
5. The video subtitle generation method according to claim 1, It is characterized in that The multimodal decoder model includes a multimodal BERT model.
6. The video subtitle generation method according to claim 1, It is characterized in that The regional spatiotemporal encoder is used to encode the clustered and counted regional features. The specific process includes: imf i =Flatten(ResNet(region i )) imr i =Concat(imf i ,Norm(bbox i )) rf=MHA((imr 1, imr 2 ,...,imr n )+TE) Where imf i Represents the i-th region feature (region i ), imr i It represents the regional features with added position information, rf represents the overall features obtained by fusing all regional features, the Flatten operation flattens the features into one dimension, the ResNet operation refers to the use of the ResNet model to extract regional visualization features, the Concat operation is used for the series connection and splicing of features, Norm represents the normalization operation, bboxi represents the i-th bounding box, MHA represents the calculation of the multi-head attention mechanism, and TE is the temporal encoding.
7. The video subtitle generation method according to claim 1, It is characterized in that The image subtitle model includes an LLaVA model.
8. The video subtitle generation method according to claim 1, It is characterized in that The target detection model includes a Faster R-CNN model.
9. A video subtitle generating device, comprising a memory, a processor, and a program stored in the memory, It is characterized in that When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.
10. A storage medium having a program stored thereon, It is characterized in that When the program is executed, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Video processing and subtitle detection model method and device
CN113361462A
Text-to-video cross-modal retrieval method based on multi-face video representation learning
CN114817627A
Video-text retrieval method based on knowledge enhancement
CN116628262A
Video-language understanding method and system
CN117251821A
Context-based enhancement of audio content
US20200321005A1
Cited By
Video subtitle generation method and device, equipment and medium
CN119383290A
Video subtitle generation method, apparatus, device, and medium
CN119383290B
Subtitle generation method, device and equipment and readable storage medium
CN119603416A
Enhanced entity perception sports video subtitle generation method combining dominant knowledge and implicit knowledge
CN119653175A
