Unsupervised efficient video retrieval method, device and equipment based on contrastive learning

Through contrastive learning and self-distillation learning, an unsupervised video retrieval model is constructed by combining long and short clip features, which solves the problem of low video retrieval efficiency and reliance on manual annotation in massive video databases, and achieves efficient and accurate video retrieval.

CN118410206BActive Publication Date: 2024-09-13HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202410875356.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-01
Publication Date
2024-09-13
Estimated Expiration
2044-07-01

AI Technical Summary

Technical Problem

In massive video databases, it is difficult for existing technologies to efficiently retrieve target videos that match the videos to be detected, resulting in high consumption of computing resources and long processing time, and requiring manual annotation of data to train the retrieval model.

Method used

Using an unsupervised method based on contrastive learning, through data enhancement of video features, long and short segment features are obtained, and combined with self-distillation learning and similarity complementation, a target retrieval model is built to achieve video retrieval, avoiding the reliance on manual annotation of data. .

Benefits of technology

It achieves video retrieval within a small amount of computing resources and time, improves retrieval efficiency and accuracy, reduces storage requirements, and does not rely on manual annotation of data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118410206B
    Figure CN118410206B
Patent Text Reader

Abstract

The present application provides an unsupervised efficient video retrieval method, device and equipment based on contrastive learning, the method comprising: performing data enhancement on the initial features corresponding to the first sample video to obtain enhanced features; obtaining long-segment features and short-segment features based on the enhanced features; inputting the long-segment features into the initial retrieval model to obtain the first video-level features, and inputting the short-segment features into the initial retrieval model to obtain the second video-level features; determining the first loss value based on the similarity between the first video-level features and the second video-level features, and the similarity between the reference video-level features of the first sample video and the reference video-level features of the second sample video; optimizing the initial retrieval model based on the first loss value to obtain an optimized retrieval model, and determining the target retrieval model based on the optimized retrieval model; the target retrieval model is used to retrieve the target video matching the video to be detected. Through the technical solution of the present application, the retrieval efficiency of the retrieval model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of video retrieval technology, and in particular to an unsupervised and efficient video retrieval method, device and equipment based on contrastive learning. Background Art

[0002] With the rapid development and popularization of information technology, multimedia data in the form of video is increasing. Therefore, how to retrieve the desired content from the massive video information has become a problem that needs to be solved. Therefore, content-based video retrieval technology has become a research focus. In content-based video retrieval technology, it is necessary to retrieve videos in a large-scale video database based on the content and context of the video.

[0003] For example, for a video to be detected, it is necessary to retrieve a target video that matches the video to be detected from a video database, that is, the target video has a high degree of similarity with the video to be detected and is used as the video most similar to the video to be detected. In the video retrieval process, it is necessary to compare the similarity between the video to be detected and each video in the video database, such as determining the similarity between the video to be detected and the videos in the video database based on the color texture, shape, motion information, object information and spatial relationship of each image in the video.

[0004] Since there are a large number of videos in the video database, a large amount of computing resources and a long time are required to compare the similarity between the video to be detected and each video in the video database. Summary of the invention

[0005] The present application provides an unsupervised and efficient video retrieval method based on contrastive learning, comprising:

[0006] Performing data enhancement on the initial features corresponding to the first sample video to obtain enhanced features, wherein the enhanced features include multiple frame-level feature values; obtaining long-segment features and short-segment features based on the enhanced features, wherein the long-segment features include some or all of the frame-level feature values ​​of the multiple frame-level feature values ​​of the enhanced features, and the short-segment features include some of the frame-level feature values ​​of the multiple frame-level feature values ​​of the long-segment features;

[0007] Inputting the long segment feature into the initial retrieval model to obtain a first video-level feature, and inputting the short segment feature into the initial retrieval model to obtain a second video-level feature;

[0008] Determine a first loss value based on the similarity between the first video-level feature and the second video-level feature, and the similarity between the reference video-level feature of the first sample video and the reference video-level feature of the second sample video; wherein the reference video-level feature is the first video-level feature or the second video-level feature;

[0009] Optimizing the initial retrieval model based on the first loss value to obtain an optimized retrieval model, and determining a target retrieval model based on the optimized retrieval model;

[0010] The target retrieval model is used to retrieve a target video that matches the video to be detected.

[0011] The present application provides an unsupervised and efficient video retrieval device based on contrastive learning, comprising:

[0012] An acquisition module is used to perform data enhancement on the initial features corresponding to the first sample video to obtain enhanced features, wherein the enhanced features include multiple frame-level feature values; based on the enhanced features, a long-segment feature and a short-segment feature corresponding to the first sample video are acquired; wherein the long-segment feature includes part or all of the frame-level feature values ​​of the multiple frame-level feature values ​​of the enhanced features, and the short-segment feature includes part of the frame-level feature values ​​of the multiple frame-level feature values ​​of the long-segment feature;

[0013] A processing module, used for inputting the long segment feature into an initial retrieval model to obtain a first video-level feature, and inputting the short segment feature into the initial retrieval model to obtain a second video-level feature;

[0014] a determination module, configured to determine a first loss value based on a similarity between the first video-level feature and the second video-level feature, and a similarity between a reference video-level feature of the first sample video and a reference video-level feature of the second sample video; the reference video-level feature is the first video-level feature or the second video-level feature;

[0015] A training module, configured to optimize the initial retrieval model based on the first loss value to obtain an optimized retrieval model, and determine a target retrieval model based on the optimized retrieval model;

[0016] The target retrieval model is used to retrieve a target video that matches the video to be detected.

[0017] The present application provides an electronic device, comprising: a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor; the processor is used to execute the machine-executable instructions to implement an unsupervised and efficient video retrieval method based on contrastive learning.

[0018] The present application provides a computer program product, including a computer program, which implements the above-mentioned unsupervised efficient video retrieval method based on contrastive learning when executed by a processor.

[0019] The present application provides a machine-readable storage medium, which stores machine-executable instructions that can be executed by a processor; wherein the processor is used to execute the machine-executable instructions to implement the above-mentioned unsupervised and efficient video retrieval method based on contrastive learning.

[0020] It can be seen from the above technical solution that in the embodiment of the present application, the target video matching the video to be detected is retrieved based on the target retrieval model, that is, the video to be detected and the videos in the video database are input into the target retrieval model, and the similarity between the video to be detected and each video in the video database can be obtained. This process only requires a small amount of computing resources and a short time to complete the comparison process.

[0021] When training the target retrieval model, the positive samples are composed of the long clip features and short clip features of the first sample video, and the negative samples are composed of the long clip features (or short clip features) of the first sample video and the long clip features (or short clip features) of the second sample video. The long clip features and short clip features are obtained based on the sample video. In this way, there is no need to manually calibrate the positive and negative samples, that is, the training process of the target retrieval model does not rely on manually labeled data. By mining the characteristics of the video itself, the unsupervised retrieval model training can be achieved. The rich background content of the long clip features and the local fine-grained information of the short clip features are combined to guide the retrieval model to effectively learn the video representation, improve the retrieval efficiency of the retrieval model, improve the accuracy and reliability of the retrieval, improve the performance of the retrieval model, and ensure the retrieval accuracy of the retrieval model. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 It is a flowchart of the unsupervised efficient video retrieval method based on contrastive learning of the present application;

[0023] Figure 2 is a schematic diagram of an unsupervised and efficient video retrieval method based on contrastive learning of the present application;

[0024] Figure 3 It is a schematic diagram of performing data enhancement operation on initial features corresponding to sample videos in the present application;

[0025] Figure 4 is a schematic diagram of the long-short dynamic sampling video clip representation process of the present application;

[0026] Figure 5 is a schematic diagram of similarity complementary self-distillation of the present application;

[0027] Figure 6 It is a structural schematic diagram of an unsupervised efficient video retrieval device based on contrastive learning of the present application;

[0028] Figure 7It is a hardware structure diagram of an electronic device in one embodiment of the present application. DETAILED DESCRIPTION

[0029] The present application embodiment proposes an unsupervised and efficient video retrieval method based on contrastive learning, which can be applied to electronic devices, see Figure 1 FIG. 4 is a flow chart of the method, which may include:

[0030] Step 101: perform data enhancement on initial features corresponding to the first sample video to obtain enhanced features, wherein the enhanced features include multiple frame-level feature values; based on the enhanced features, long-segment features and short-segment features are obtained, wherein the long-segment features include part or all of the frame-level feature values ​​of the multiple frame-level feature values ​​of the enhanced features, and the short-segment features include part of the frame-level feature values ​​of the multiple frame-level feature values ​​of the long-segment features.

[0031] Step 102: input the long segment feature to the initial retrieval model to obtain a first video-level feature, and input the short segment feature to the initial retrieval model to obtain a second video-level feature.

[0032] Step 103: determine a first loss value based on the similarity between the first video level feature and the second video level feature, and the similarity between the reference video level feature of the first sample video and the reference video level feature of the second sample video; wherein the reference video level feature is the first video level feature or the second video level feature.

[0033] Step 104: optimize the initial retrieval model based on the first loss value to obtain an optimized retrieval model, and determine a target retrieval model (i.e., a retrieval model that is finally output) based on the optimized retrieval model; wherein the target retrieval model is used to retrieve a target video that matches the video to be detected.

[0034] Exemplarily, data enhancement is performed on the initial features corresponding to the first sample video to obtain enhanced features, which may include but is not limited to: generating a mask feature for the initial feature, the initial feature may include multiple initial feature values, and the mask feature may include multiple mask values ​​corresponding to the multiple initial feature values ​​one by one; dividing the multiple initial feature values ​​into first-category feature values ​​and second-category feature values ​​based on the mask feature; wherein, if the mask value corresponding to the initial feature value is a first value, then the initial feature value is a first-category feature value, and if the mask value corresponding to the initial feature value is a second value, then the initial feature value is a second-category feature value; for each first-category feature value, the first-category feature value is used as an enhanced frame-level feature value; for each second-category feature value, K neighboring feature values ​​are selected from multiple initial feature values; based on the second-category feature value and the K neighboring feature values, an enhanced frame-level feature value is determined; and the enhanced frame-level feature values ​​corresponding to all first-category feature values ​​and all second-category feature values ​​are combined to obtain the enhanced feature.

[0035] Exemplarily, obtaining long-segment features and short-segment features based on enhanced features may include but is not limited to: determining a first number corresponding to long-segment features based on the total number of frame-level feature values ​​of the enhanced features and a configured long-segment scaling factor, randomly selecting a first number of frame-level feature values ​​from all frame-level feature values ​​of the enhanced features, and generating long-segment features based on the first number of frame-level feature values; wherein the long-segment scaling factor is greater than 0 and less than or equal to 1; determining a second number corresponding to short-segment features based on the total number of frame-level feature values ​​of the long-segment features and a configured short-segment scaling factor, randomly selecting a second number of frame-level feature values ​​from all frame-level feature values ​​of the long-segment features, and generating short-segment features based on the second number of frame-level feature values; wherein the short-segment scaling factor is greater than 0 and less than 1.

[0036] Exemplarily, the initial retrieval model may include a fully connected layer and a Transformer network layer; inputting the long segment feature into the initial retrieval model to obtain the first video-level feature, and inputting the short segment feature into the initial retrieval model to obtain the second video-level feature, which may include but is not limited to: performing a dimensionality reduction operation on the long segment feature through the fully connected layer to obtain a long feature after dimensionality reduction; using an activation function to activate the long feature after dimensionality reduction to obtain an activated long feature; inputting the position encoding corresponding to the activated long feature and the long segment feature into the Transformer network layer to obtain a first frame-level feature; performing a pooling operation on the first frame-level feature to obtain the first video-level feature. Also, performing a dimensionality reduction operation on the short segment feature through the fully connected layer to obtain a short feature after dimensionality reduction; using an activation function to activate the short feature after dimensionality reduction to obtain an activated short feature; inputting the position encoding corresponding to the activated short feature and the short segment feature into the Transformer network layer to obtain a second frame-level feature; and performing a pooling operation on the second frame-level feature to obtain a second video-level feature.

[0037] Exemplarily, determining the first loss value based on the similarity between the first video-level feature and the second video-level feature, and the similarity between the reference video-level feature of the first sample video and the reference video-level feature of the second sample video may include but is not limited to: if the reference video-level feature of the first sample video is the second video-level feature of the first sample video, and the reference video-level feature of the second sample video is the first video-level feature or the second video-level feature of the second sample video, then the first loss value is determined using the following formula:

[0038] ;

[0039] in, can represent the first loss value, It can represent the similarity between the first video-level feature and the second video-level feature. It can represent the similarity between the reference video-level features of the first sample video and the reference video-level features of the second sample video. represents the configured control factor, represents the similarity function, and .

[0040] Exemplarily, the initial retrieval model is optimized based on the first loss value to obtain an optimized retrieval model, which may include but is not limited to: inputting long segment features into the teacher retrieval model to obtain a third frame-level feature, and inputting short segment features into the teacher retrieval model to obtain a fourth frame-level feature; wherein the network structure of the teacher retrieval model is the same as the network structure of the initial retrieval model, and the accuracy of the teacher retrieval model is higher than the accuracy of the initial retrieval model; the feature dimension of the third frame-level feature is higher than the feature dimension of the first frame-level feature, and the feature dimension of the fourth frame-level feature is higher than the feature dimension of the second frame-level feature. The feature dimension of the third frame-level feature is higher than the feature dimension of the first video-level feature, and the feature dimension of the fourth frame-level feature is higher than the feature dimension of the first video-level feature. Based on the similarity between the third frame-level feature and the fourth frame-level feature, and the similarity between the reference frame-level feature of the first sample video and the reference frame-level feature of the second sample video, a second loss value is determined; the reference frame-level feature is the third frame-level feature or the fourth frame-level feature; based on the similarity between the first video-level feature and the second video-level feature, and the similarity between the third frame-level feature and the fourth frame-level feature, a third loss value is determined; based on the first loss value, the second loss value and the third loss value, a target loss value is determined, and based on the target loss value, the initial retrieval model is optimized to obtain an optimized retrieval model.

[0041] Exemplarily, the teacher retrieval model includes a fully connected layer and a Transformer network layer; inputting the long segment features into the teacher retrieval model to obtain the third frame-level features, and inputting the short segment features into the teacher retrieval model to obtain the fourth frame-level features, which may include: performing a dimensionality reduction operation on the long segment features through the fully connected layer to obtain the reduced-dimensional long features; using an activation function to activate the reduced-dimensional long features to obtain the activated long features; inputting the position codes corresponding to the activated long features and the long segment features into the Transformer network layer to obtain the third frame-level features; performing a dimensionality reduction operation on the short segment features through the fully connected layer to obtain the reduced-dimensional short features; using an activation function to activate the reduced-dimensional short features to obtain the activated short features; inputting the position codes corresponding to the activated short features and the short segment features into the Transformer network layer to obtain the fourth frame-level features.

[0042] Exemplarily, before determining the second loss value based on the similarity between the third frame-level feature and the fourth frame-level feature, and the similarity between the reference frame-level feature of the first sample video and the reference frame-level feature of the second sample video, it may also include: based on the third frame-level feature and the fourth frame-level feature, a chamfer similarity algorithm may be used to calculate the similarity between the third frame-level feature and the fourth frame-level feature.

[0043] Exemplarily, based on the similarity between the first video-level feature and the second video-level feature, and the similarity between the third frame-level feature and the fourth frame-level feature, determining the third loss value may include but is not limited to: based on the similarity between the first video-level feature and the second video-level feature, and the similarity between the third frame-level feature and the fourth frame-level feature, The divergence loss determines the third loss value.

[0044] It can be seen from the above technical solution that in the embodiment of the present application, the target video matching the video to be detected is retrieved based on the target retrieval model, that is, the video to be detected and the videos in the video database are input into the target retrieval model, and the similarity between the video to be detected and each video in the video database can be obtained. This process only requires a small amount of computing resources and a short time to complete the comparison process.

[0045] When training the target retrieval model, the positive samples are composed of the long clip features and short clip features of the first sample video, and the negative samples are composed of the long clip features (or short clip features) of the first sample video and the long clip features (or short clip features) of the second sample video. The long clip features and short clip features are obtained based on the sample video. In this way, there is no need to manually calibrate the positive and negative samples, that is, the training process of the target retrieval model does not rely on manually labeled data. By mining the characteristics of the video itself, the unsupervised retrieval model training can be achieved. The rich background content of the long clip features and the local fine-grained information of the short clip features are combined to guide the retrieval model to effectively learn the video representation, improve the retrieval efficiency of the retrieval model, improve the accuracy and reliability of the retrieval, improve the performance of the retrieval model, and ensure the retrieval accuracy of the retrieval model. The first video-level features and the second video-level features of the initial retrieval model are guided based on the third frame-level features and the fourth frame-level features of the teacher retrieval model, and the rich semantic information of the frame-level features is effectively integrated into the video-level features using the self-distillation learning method. This strategy cleverly combines the richness of frame-level features with the compactness of video-level features, not only retaining the low-dimensional characteristics but also significantly reducing the retrieval and storage overhead.

[0046] The above technical solutions of the embodiments of the present application are described below in combination with specific application scenarios.

[0047] In content-based video retrieval technology, it is necessary to retrieve videos in a large-scale video database based on the content and context of the video. For example, for a video to be detected, it is necessary to retrieve a target video that matches the video to be detected from the video database. In the video retrieval process, it is necessary to compare the similarity between the video to be detected and each video in the video database, and find the video with the highest similarity as the target video. However, due to the large number of videos in the video database, it takes a lot of computing resources and time to compare the similarity between the video to be detected and each video in the video database.

[0048] In the application process of video retrieval, a key requirement of video retrieval is to return the query results within seconds. Obviously, when it takes a lot of time to retrieve the target video that matches the video to be detected, the query results cannot be returned within seconds, resulting in the inability to meet the application requirements of video retrieval.

[0049] In view of the above findings, an unsupervised and efficient video retrieval method based on contrastive learning is proposed in an embodiment of the present application, and unsupervised and efficient video retrieval is achieved based on contrastive learning. When training the retrieval model, the training process of the retrieval model does not rely on manually annotated data. By mining the characteristics of the video itself, the training of the unsupervised retrieval model can be achieved. A content-aware feature-level data enhancement method is proposed to improve the utilization of data by the retrieval model. The rich background content of long-segment features and the local fine-grained information of short-segment features are combined to guide the retrieval model to effectively learn video representations. The similarity obtained based on dense frame-level features is migrated to the similarity based on video-level features through self-distillation learning. While ensuring performance, video retrieval based on video-level features is achieved, thereby improving the retrieval efficiency of the retrieval model.

[0050] Regarding unsupervised learning, it is a learning method that does not rely on manually labeled data, but uses the intrinsic information of the video data itself to achieve a deep understanding and analysis of the video content. In the video field, unsupervised learning methods capture the spatiotemporal information in the video sequence and learn by mining the natural attributes of the video, thus avoiding the tedious work of manually labeling a large amount of video data, saving resources and time.

[0051] Regarding self-distillation learning, self-distillation learning is to train the network itself as both the teacher model and the student model. Through knowledge distillation, the teacher model transfers useful gain information to the student model, thereby improving the performance of the model. Although the teacher model is not more complex than the student model, the information provided by the teacher model is valuable incremental knowledge for the student model, which helps to improve the efficiency and accuracy of the student model.

[0052] Regarding data augmentation, data augmentation is a technique that generates more training samples by changing the way the input data is used. Through data augmentation, the training data set can be expanded so that the model can show better generalization ability and effect when facing different data transformations. Data augmentation methods help reduce the model's excessive dependence on specific features, thereby reducing the risk of overfitting and improving the robustness of the model.

[0053] Contrastive learning, as an unsupervised learning mechanism, enables the model to learn more robust feature representations by shortening the distance between similar (positive) sample pairs and pushing away the distance between dissimilar (negative) sample pairs. This method effectively utilizes the similarities and dissimilarities between samples, allowing the model to better capture the inherent laws and structures of the data, thereby improving its performance on various tasks.

[0054] See also Figure 2 As shown in FIG. 1 , a schematic diagram of an unsupervised efficient video retrieval method based on contrastive learning is shown. The video retrieval method may involve the following processes: a video feature initialization representation process, in which efficient initialized video features can be obtained. A feature-level data enhancement process based on content perception, in which the K-nearest neighbor algorithm is used to explore neighboring features in the feature space, and feature-level data enhancement is performed. Compared with image-level data enhancement, repeated and cumbersome operations in the pixel space can be avoided, and data diversity is increased. A long-short dynamic sampling video clip representation process, in which the long-short dynamic sampling video clip representation process is used to dynamically select long and short clips to generate video clips of different lengths. A video aggregation process, in which the frame-level features are aggregated into video-level features. A similarity contrast learning process, in which the similarity contrast learning process is used to train the retrieval model. A similarity complementary self-distillation learning process, in which the self-distillation learning process is used to train the retrieval model.

[0055] The above process involved in the video retrieval method is described below in conjunction with specific application scenarios.

[0056] First, the video feature initialization representation process: In the video feature initialization representation process, the initial feature corresponding to the sample video can be obtained, and the initial feature can include multiple initial feature values.

[0057] For example, for a given sample video, multiple initial frame images can be extracted from the sample video, such as extracting multiple initial frame images from the sample video at a frequency of once per second.

[0058] Then, using the pre-trained feature extraction network (in Figure 2In the example, 2D or 3D convolutional network is used as the feature extraction network), feature extraction is performed on these initial frame images to obtain the initial features corresponding to the sample video. In this initial feature, Indicates the initial eigenvalue corresponding to the first initial frame image, which can be the initial eigenvalue of dimensions such as 512, 1024, or 2048. represents the initial eigenvalue corresponding to the second initial frame image, and so on. Assuming that a total of n initial frame images are extracted from the sample video, n is a positive integer. Represents the initial eigenvalue corresponding to the nth initial frame image.

[0059] In the subsequent training process, the initial features It can be used for more advanced feature representation to further mine deep information in sample videos. It can also serve as the basis for building a retrieval model, so that the retrieval model can accurately capture the dynamic characteristics of video content that change over time.

[0060] Second, the feature-level data enhancement process based on content awareness. In the feature-level data enhancement process based on content awareness, the initial features corresponding to the sample video can be Perform data enhancement to obtain enhanced features , , is the initial eigenvalue The eigenvalue obtained after enhancement is is the characteristic value for a frame image (i.e. the first initial frame image), therefore, It can also be called frame-level feature value. is the initial eigenvalue The frame-level feature value obtained after enhancement, and so on. In summary, it can be seen that the enhanced feature Multiple frame-level feature values ​​may be included.

[0061] In contrastive learning, the diversity of samples in the training dataset is crucial, and data augmentation is a key means to achieve this goal. Since videos are composed of continuous frames, applying image-level data augmentation to each frame is not only inefficient, but this repeated data augmentation process also consumes a lot of time.

[0062] In view of the above findings, in an embodiment of the present application, data enhancement is not performed on each frame of the video, but on the initial features corresponding to the sample video, that is, data enhancement is performed at the feature level. For example, applying a transformation or adding noise to the features can reduce the demand for storage and computing resources without repeatedly enhancing the video frames. By transferring data enhancement from the original pixel space to the feature space, the efficiency problems caused by processing each video frame multiple times are avoided.

[0063] When performing data enhancement operations on the initial features corresponding to the sample video, the Mix-up method can be used to achieve feature-level data enhancement. Figure 3 As shown in the figure, the left side (a) is a schematic diagram of the Mix-up method to achieve feature-level data enhancement. ), a eigenvalue can be randomly selected from the remaining eigenvalues ​​(e.g., the 4th eigenvalue is selected for the 1st eigenvalue, the 8th eigenvalue is selected for the 2nd eigenvalue, and so on). The eigenvalue and the selected eigenvalue are mixed up to obtain the fused eigenvalue (e.g., the 1st eigenvalue and the 4th eigenvalue are mixed up to obtain the fused eigenvalue corresponding to the 1st eigenvalue). All the fused eigenvalues ​​are combined into an enhanced frame sequence (i.e., the enhanced feature value). ). Of course, the above is just an example of the Mix-up method and is not limited to this.

[0064] When using the Mix-up method to achieve feature-level data enhancement, new training data can be generated in the feature space by linearly interpolating sample pairs. However, the Mix-up method often ignores the actual similarities between samples and sometimes even introduces unrealistic data points, especially when dealing with samples of different categories. In this case, the model may learn inaccurate features, which will affect its generalization ability.

[0065] Compared with the Mix-up method, this embodiment proposes a feature-level data enhancement method based on content perception, see Figure 3 As shown in the figure, the right side (b) is a schematic diagram of the feature-level data enhancement method based on content perception. This feature-level data enhancement method fully considers the neighboring samples of each sample by utilizing the K-nearest neighbor algorithm, and generates corresponding new samples based on this. In this way, the local structure and category consistency of the features can be better maintained. Unlike the Mix-up method, which may generate samples spanning different category spaces, the new samples generated by this feature-level data enhancement method are more likely to remain in the same category, while making full use of spatiotemporal context information to obtain better new samples. Obviously, this method not only improves the processing speed, but may also further improve the accuracy and generalization ability of the model when processing complex video data.

[0066] For example, the content-aware feature-level data enhancement method can include the following steps:

[0067] Step S11: Generate a mask feature for the initial feature. The initial feature may include multiple initial feature values, and the mask feature may include multiple mask values ​​corresponding to the multiple initial feature values.

[0068] See also Figure 3 As shown, the original frame sequence is the initial feature V, , that is, the initial feature includes n initial feature values, so a mask feature can be defined (i.e. random mask ), mask feature Includes n mask values, i.e., mask features is a length and a number Same binary vector (array), mask features Elements in Corresponding to the first initial eigenvalues.

[0069] Mask Features Elements in The value of (i.e., the mask value) is used to determine whether to retain the original features. If the element The value of is 1, then the element The corresponding initial eigenvalue (i.e. The enhanced features will be used if the element The value of is 0, then the element The corresponding initial eigenvalues ​​retain their original values.

[0070] Using mask features The purpose of is to provide flexibility in the data enhancement process, allowing the features of individual frames to remain unchanged while the features of other frames are replaced with enhanced features. This method can help the model generalize better, prevent overfitting, and increase the diversity of the data set.

[0071] Step S12: divide the multiple initial feature values ​​in the initial feature V into first-category feature values ​​and second-category feature values ​​based on the mask feature. For example, if the mask value corresponding to the initial feature value in the mask feature is a first value (such as 0), then the initial feature value is a first-category feature value; if the mask value corresponding to the initial feature value in the mask feature is a second value (such as 1), then the initial feature value is a second-category feature value.

[0072] For example, the initial eigenvalue With elements Corresponding, if If the mask value of is 0, is the first type eigenvalue, if The mask value of is 1, then is the second type of eigenvalue, and so on.

[0073] Step S13: for each first-category feature value, use the first-category feature value as the enhanced frame-level feature value, that is, use the initial feature value of the first-category feature value as the enhanced frame-level feature value.

[0074] Step S14: for each second-class eigenvalue, select K neighboring eigenvalues ​​from a plurality of initial eigenvalues; and determine an enhanced frame-level eigenvalue based on the second-class eigenvalue and the K neighboring eigenvalues.

[0075] The second eigenvalue For example, based on - The nearest neighbor algorithm finds the second type of eigenvalues ​​in the feature space (i.e. all the initial eigenvalues ​​in the initial feature V). The nearest neighbor feature For example, we can calculate the second-class eigenvalue The similarity between each initial eigenvalue is calculated, and these initial eigenvalues ​​are sorted (ranked) according to the similarity. Based on the sorting results, the K initial eigenvalues ​​with large similarity can be used as the second type of eigenvalues If the value of K is 1, the initial eigenvalue with the largest similarity can be used as the second type of eigenvalue The nearest neighbor feature .

[0076] In getting the second type of eigenvalue After finding the K nearest neighbor eigenvalues, we can And K nearest neighbor eigenvalues ​​determine the second type of eigenvalue For example, the K nearest neighbor feature values ​​are the nearest neighbor feature For example, formula (1) is used to determine the enhanced frame-level feature value.

[0077] Formula (1)

[0078] In formula (1), Represents the second type of eigenvalue The enhanced frame-level feature value of Represents the second type of eigenvalue The weighting coefficient is configured according to experience. Represents the nearest neighbor feature From formula (1), it can be seen that a perturbation strategy can be used to fuse the second type of eigenvalues and nearest neighbor features , generate new enhanced frame-level feature values For the second type of eigenvalue The weighting factor , is a mixing coefficient between 0 and 1, which controls the proportion of the original features and the nearest neighbor features in the new features.

[0079] Obviously, when the K nearest neighbor eigenvalues ​​are multiple eigenvalues, we can also use the second type of eigenvalues A weighted operation is performed with multiple neighboring feature values, and the neighboring feature values ​​with higher similarity have larger weighting coefficients.

[0080] Step S15: Combine the enhanced frame-level feature values ​​corresponding to all the first-class feature values ​​and the enhanced frame-level feature values ​​corresponding to all the second-class feature values ​​to obtain an enhanced feature value. (i.e. enhanced frame sequence), i.e. enhanced features It includes enhanced frame-level feature values ​​(original feature values) corresponding to all first-category feature values ​​and enhanced frame-level feature values ​​corresponding to all second-category feature values, and the enhanced feature includes multiple frame-level feature values.

[0081] In summary, it can be seen that in the process of feature-level data enhancement based on content perception, the initial features can be Perform data enhancement processing to obtain enhanced features , and the enhanced features It includes multiple frame-level feature values, which are used to replace the original feature values ​​and participate in the subsequent video segment representation. The final output is the enhanced feature , is the number of video frames, is the frame feature dimension.

[0082] In the process of feature-level data enhancement based on content perception, both simplicity and effectiveness should be taken into account. Therefore, the K-nearest neighbor algorithm is used to achieve feature-level data enhancement. The K-nearest neighbor algorithm achieves data enhancement by determining the data points closest to each sample center, which are defined from the actual frame. The advantage of this method is that there is no need to go through a tedious training phase, and all calculations are completed at one time during data preprocessing. This not only makes the algorithm easy to understand and deploy, but also because it operates directly in the feature space, it shows strong robustness to noise and outliers in the data.

[0083] Third, the long-short dynamic sampling video clip representation process. In the long-short dynamic sampling video clip representation process, based on the enhanced features Get long segment features and short segment features, for example, dynamically adopt the segment feature constructor based on the enhanced features A long segment feature and a short segment feature are obtained, wherein the long segment feature may include part or all of the frame-level feature values ​​of the enhanced feature, and the short segment feature may include part of the frame-level feature values ​​of the long segment feature.

[0084] The core of contrastive learning is to construct positive sample pairs, which is the key to training the model to learn discriminative features. By constructing positive sample pairs, the model can learn how to distinguish different samples and extract their unique features. Therefore, the way to construct positive sample pairs has an important impact on the effect of contrastive learning.

[0085] When constructing positive sample pairs, two video clips of the same length can be randomly selected. This method ignores the temporal coherence and stability of the video content and is not conducive to learning fine-grained temporal features. This method requires non-overlapping clips to have similar features. Although sampling two partially overlapping clips can alleviate this problem, it sacrifices the diversity of the spatiotemporal context, resulting in a decrease in representation quality.

[0086] In view of the above findings, this embodiment proposes a long-short dynamic sampling method, first from the enhanced feature A long-segment feature is randomly extracted from the image, and then a short-segment feature is extracted within the time range of the long-segment feature. In this way, the long-segment feature provides rich spatiotemporal context information, and the short-segment feature ensures that there is a corresponding embedding relationship between the two segments. This method can not only learn temporal coherence and stability, but also capture fine-grained feature changes.

[0087] See also Figure 4 FIG. 1 is a schematic diagram of a long-short dynamic sampling video clip representation process, which shows a long-short dynamic sampling video clip strategy. The long-short dynamic sampling video clip representation process may include:

[0088] Step S21: Determine a first quantity corresponding to the long segment feature based on the total number of frame-level feature values ​​of the enhanced feature and a configured long segment scale factor, where the long segment scale factor is greater than 0 and less than or equal to 1.

[0089] For example, you can use a dynamic scale factor to set the long clip scale factor , 0< ≤1 , long segment scaling factor Defines the ratio of long segment features to the total number of enhanced features.

[0090] Given a The enhanced features of frame-level feature values , that is, the total number of frame-level feature values ​​of the enhanced feature is n, assuming that the first number corresponding to the long segment feature is recorded as , the first quantity can be determined by the following formula: Of course, if When the value of is a decimal, you can use rounding, rounding down, rounding up, etc. to get the first number .

[0091] Step S22: randomly selecting a first number of frame-level feature values ​​from all frame-level feature values ​​of the enhanced features, and generating long-segment features based on the selected first number of frame-level feature values.

[0092] For example, we can randomly select from a video sequence (the video sequence is the initial video frame extracted from the video, and the video sequence corresponds to the initial feature) Frames, randomly selected frames, regardless of their temporal order. The frames are sorted according to their original order in the video to maintain temporal relevance, and the sorted frame sequence is finally formed into a long clip sequence. . Long fragment sequence It can be expressed as: In long fragment sequences middle, is the index of the frame selected according to the non-continuous sampling strategy.

[0093] Based on long fragment sequence The frame-level feature values ​​corresponding to these indexes can be selected from all the frame-level feature values ​​of the enhanced features, and these frame-level feature values ​​can be combined into long-segment features. . Long fragment features The index comes from the long fragment sequence , and long fragment sequences Includes the first number of indices, so the long segment features A first number of frame-level feature values ​​may be included, which capture the global characteristics of the video. Figure 4 Medium and long segment features It can also be written as .

[0094] Step S23: Determine a second quantity corresponding to the short segment feature based on the total quantity of the frame-level feature values ​​of the long segment feature and the configured short segment scale factor, where the short segment scale factor is greater than 0 and less than 1.

[0095] For example, you can use a dynamic scale factor to set the short clip scale factor , 0< ≤1, short fragment scaling factor Defines the ratio of short segment features to the total number of long segment features.

[0096] Based on the long segment feature, the second quantity corresponding to the short segment feature can be calculated. Assume that the quantity corresponding to the long segment feature is , the second number corresponding to the short segment feature is , the second quantity can be determined using the following formula: .certainly, When the value of is a decimal, you can use rounding, rounding down, rounding up, etc. to get the second number .

[0097] Step S24: randomly select a second number of frame-level feature values ​​from all frame-level feature values ​​of the long segment feature, and generate the short segment feature based on the selected second number of frame-level feature values.

[0098] For example, in addition to the non-continuous sampling strategy for long clips, a method for sampling short clips in the video is also considered. The short clips also adopt a non-continuous sampling strategy, containing frames at different time points in the video, which may represent different local contents of the video. This diversity helps the model capture the local features of the video at different time periods. Since not all frames will be selected, the model may learn to pay more attention to frames that contain key information, even if these frames are separated on the timeline. This helps the model learn to identify and utilize key content in the video, so that it can capture important information locally.

[0099] For example, randomly from a long sequence Select Frames, randomly selected frames, regardless of their temporal order. The frames are sorted according to their original order in the video to maintain temporal relevance, and the sorted frame sequence is finally formed into a short clip sequence. . Short fragment sequence It is expressed as: In short fragment sequences middle, is the index of the frame selected according to the non-continuous sampling strategy.

[0100] Based on short sequence The frame-level feature values ​​corresponding to these indexes are selected from all frame-level feature values ​​of the long segment feature, and these frame-level feature values ​​are combined into short segment features. . Short fragment features The index comes from the short fragment sequence , short fragment sequence Includes a second number of indices, short snippet features A second number of frame-level feature values ​​are included. Figure 4 Short and medium clip features Recorded as .

[0101] In summary, in the process of long-short dynamic sampling video clip representation, the long clip feature is obtained and short segment features , long fragment features , short segment features .

[0102] Fourth, the video aggregation process. During the video aggregation process, the long-segment features can be converted into first-video-level features. The first-video-level features are features for sample videos, that is, features of the video dimension, rather than features of the image dimension in the video (that is, not frame-level features). For example, the long-segment features can be input into the initial retrieval model to obtain the first-video-level features. During the video aggregation process, the short-segment features can also be converted into second-video-level features. The second-video-level features are features for sample videos, that is, features of the video dimension, rather than features of the image dimension in the video (that is, not frame-level features). For example, the short-segment features can be input into the initial retrieval model to obtain the second-video-level features.

[0103] In contrastive learning, video-level features can fully capture the overall information and contextual associations of video data to more accurately reflect the video content. Therefore, the video aggregation process is introduced, in which the key information in the video sequence can be efficiently integrated to generate video-level features with rich expressive capabilities.

[0104] Exemplarily, a configured initial retrieval model may be obtained, which is a model to be trained and used to implement the video retrieval function. The initial retrieval model may include a fully connected layer and a Transformer network layer (i.e., a neural network based on a self-attention mechanism). Of course, this is only an example of the initial retrieval model, and there is no restriction on the structure of the initial retrieval model, as long as it can implement the video retrieval function.

[0105] On this basis, the long fragment features can be Input to the initial retrieval model. Assuming that the fully connected layer of the initial retrieval model has an activation function (such as Relu activation function, etc.), the long segment features can be queried through the fully connected layer of the initial retrieval model. Perform dimensionality reduction to obtain the reduced long features. Then, the activation function can be used to activate the reduced long features to obtain the activated long features. Then, the position encoding corresponding to the activated long features and the long segment features (used to characterize the position of each frame-level feature value in the long segment features) is input into the Transformer network layer to obtain the first frame-level features (video frame-level features).

[0106] For example, a fully connected layer with a ReLU activation function can be used to represent long fragment features. Perform dimensionality reduction and position embedding encoding at the same time, and then input it into the Transformer network layer to capture long-segment features Context information, get the first frame level feature The above processing can be expressed as: . represents the fully connected layer, represents the activation function, represents the position code, represents the first frame-level feature, Indicates long fragment features.

[0107] In addition, short segment features can be Input to the initial retrieval model. Assuming that the fully connected layer of the initial retrieval model has an activation function (such as Relu activation function, etc.), the short segment features can be queried through the fully connected layer of the initial retrieval model. Perform dimensionality reduction to obtain the reduced short features. Then, the activation function can be used to activate the reduced short features to obtain the activated short features. Then, the position encoding corresponding to the activated short features and the short segment features (used to characterize the position of each frame-level feature value in the short segment features) is input into the Transformer network layer to obtain the second frame-level features (video frame-level features).

[0108] For example, a fully connected layer with a ReLU activation function can be used to represent short segment features. Perform dimensionality reduction and position embedding encoding at the same time, and then input it into the Transformer network layer to capture short segment features The context information of the second frame level feature is obtained The above processing can be expressed as: . represents the fully connected layer, represents the activation function, represents the position code, represents the second frame-level feature, Represents a short segment feature.

[0109] Exemplarily, after obtaining the first frame-level feature Afterwards, the first frame level features can also be Perform pooling operation to obtain the first video level feature For example, the first frame level feature can be calculated using the following formula: Perform average pooling to obtain the first video-level features: .

[0110] After obtaining the second frame level features Afterwards, the second frame level features can also be Perform pooling operation to obtain the second video level feature For example, the following formula can be used to calculate the second frame level feature Perform average pooling to obtain the second video level feature : .

[0111] In the above formula, the first video-level feature , the second video level feature , is the average pooling function, is the output dimension of video-level features.

[0112] In summary, in the video aggregation process, long clip features Encoded into the first video level features , short segment features Encoded into the second video level features On this basis, the first video level features corresponding to the same sample video are and second video level features Form positive samples, and use the first video-level features corresponding to different sample videos (or second video level feature ) constitute negative samples.

[0113] Fifth, similarity comparison learning process. In the similarity comparison learning process, a first loss value can be determined based on the similarity of positive samples and the similarity of negative samples, the initial retrieval model is optimized based on the first loss value to obtain an optimized retrieval model, and the target retrieval model is determined based on the optimized retrieval model.

[0114] Exemplarily, the above operation can be performed on multiple sample videos to obtain the first video-level feature corresponding to each sample video. and second video level features Each sample video may be traversed in sequence from a plurality of sample videos. For the sample video currently traversed, the sample video may be referred to as a first sample video, and other sample videos (one sample video or multiple sample videos) other than the sample video may be referred to as second sample videos, that is, a first sample video may correspond to one or more second sample videos.

[0115] For the first sample video currently being traversed, the first video-level feature corresponding to the first sample video can be and second video level features As a positive sample pair. The first video-level feature corresponding to the first sample video Reference video-level features corresponding to the second sample video (such as the first video level features or second video level features ) as a negative sample pair; or, the second video-level feature corresponding to the first sample video Reference video-level features corresponding to the second sample video as negative sample pairs.

[0116] In summary, we can see that regarding the definition of positive and negative sample pairs for similarity learning, in the process of video segment representation, long and short segments are constructed in a video through a long-short dynamic sampling strategy, which contains rich spatiotemporal context and local dynamic information in a video. Therefore, after the video aggregation process, the generated can be regarded as mutually positive sample pairs. are considered as negative sample pairs.

[0117] Exemplarily, the first loss value can be determined based on the similarity of the positive sample pair and the similarity of the negative sample pair. The similarity of the positive sample pair is the similarity between the first video-level feature and the second video-level feature of the first sample video. The similarity of the negative sample pair is the similarity between the reference video-level feature of the first sample video (such as the first video-level feature or the second video-level feature of the first sample video) and the reference video-level feature of the second sample video (such as the first video-level feature or the second video-level feature of the second sample video).

[0118] For example, a loss function based on contrastive learning can be pre-configured. The loss function can be configured based on experience. See formula (2) for an example of the loss function. There is no restriction on this. Formula (2) is given a positive sample pair , contrastive learning loss on a batch of samples.

[0119] Formula (2)

[0120] In formula (2), can represent the first loss value, represents the similarity between the first video-level feature and the second video-level feature (i.e., the similarity of the positive sample pair), It can represent the similarity between the reference video-level features of the first sample video and the reference video-level features of the second sample video (i.e., the similarity of the negative sample pair). When there are multiple second sample videos, For multiple.

[0121] Represents the configured control factor, also known as the temperature coefficient, which can be configured based on experience.

[0122] Represents the similarity function. Taking cosine similarity as an example, the similarity function Of course, distance similarity and the like may also be used, and there is no limitation to this.

[0123] In formula (2), the negative sample pair It can be seen that the reference video-level feature of the first sample video is the second video-level feature of the first sample video. , the reference video-level features of the second sample video is the first video-level feature or the second video-level feature of the second sample video.

[0124] After obtaining the first loss value, the initial retrieval model can be optimized based on the first loss value to obtain an optimized retrieval model. For example, the initial retrieval model can be optimized by using a gradient descent method or the like. The optimization goal of the initial retrieval model is to make the first loss value smaller and smaller by adjusting the network parameters of the initial retrieval model, such as the network parameters of the fully connected layer and the Transformer network layer.

[0125] After obtaining the optimized retrieval model, if the convergence conditions are met, such as the number of optimizations of the initial retrieval model has reached the number threshold, or the optimization duration of the initial retrieval model has reached the duration threshold, or the first loss value is less than the preset threshold, the optimized retrieval model will be used as the target retrieval model.

[0126] After obtaining the optimized retrieval model, if the convergence condition is not met, the optimized retrieval model is used as the initial retrieval model, and the process of inputting the long segment features into the initial retrieval model to obtain the first video-level features and the short segment features into the initial retrieval model to obtain the second video-level features is returned.

[0127] Sixth, similarity complementary self-distillation learning process. In the similarity complementary self-distillation learning process, in addition to the first loss value obtained in the similarity comparison learning process, it is also necessary to obtain the second loss value and the third loss value, optimize the initial retrieval model based on the first loss value, the second loss value and the third loss value to obtain the optimized retrieval model, and determine the target retrieval model based on the optimized retrieval model.

[0128] In order to reduce the memory consumption of the model, the video frame-level features can be reduced in dimension through the fully connected layer and converted into video-level features after the pooling operation to achieve the purpose of reducing memory consumption. Although video-level features are conducive to improving retrieval speed and reducing storage requirements, they also lose a lot of details and semantic information, which directly affects the retrieval accuracy. Based on this, in this embodiment, during the model training process, the initial retrieval model can be used as a student model (i.e., the video-level feature branch is used as a student), and a teacher retrieval model (i.e., the frame-level feature branch is used as a teacher) is configured. In this way, learning can be performed by self-distillation in a complementary similarity manner, so as to achieve the integration of rich information of frame-level features into video-level features.

[0129] See also Figure 5 The following is a schematic diagram of similarity complementary self-distillation. a Indicates the first sample video, video b The video feature processing module is used to implement the video feature initialization representation process, the content-aware feature level data enhancement process, and the long-short dynamic sampling video clip representation process.

[0130] During the video feature initialization process, the video feature processing module can determine the first sample video video a Corresponding initial features, determine the second sample video video b The corresponding initial features.

[0131] In the feature-level data enhancement process based on content perception, the video feature processing module can process the first sample video video a The corresponding initial features are enhanced to obtain enhanced features, and the second sample video video is b The corresponding initial features are enhanced to obtain enhanced features.

[0132] In the long-short dynamic sampling video segment representation process (long-short dynamic sampling segment feature constructor), the video feature processing module is based on the first sample video video a The corresponding enhanced features obtain the first sample video video a The long fragment feature C long_a and short segment feature C short_a, based on the second sample video video b The corresponding enhanced features obtain the second sample video video b The long fragment feature C long_b and short segment feature C short_b .

[0133] After obtaining the long segment feature C long_a and short segment feature C short_a , long segment feature C long_b and short segment feature C short_b Afterwards, the self-distillation learning module can be based on the long segment feature C long_a and short segment feature C short_a , long segment feature C long_b and short segment feature C short_b Realize the similarity complementary self-distillation learning process.

[0134] exist Figure 5 In the figure, only the long segment feature C is shown. long_a and long segment feature C long_b The processing process of short segment feature C short_a and short segment feature C short_b The processing process is similar to Figure 5 Not shown in the figure.

[0135] For example, the similarity complementary self-distillation learning process can include the following steps:

[0136] Step S31: long segment feature C long_a Input to the initial retrieval model (student model) to obtain the first video-level feature V corresponding to the first retrieval video long_a . The long segment feature C long_b Input to the initial retrieval model to obtain the first video-level feature V corresponding to the second retrieval video long_b . The short segment feature C short_a Input to the initial retrieval model to obtain the second video-level feature V corresponding to the first retrieval video short_a . The short segment feature C short_b Input to the initial retrieval model to obtain the second video-level feature V corresponding to the second retrieval video short_b .

[0137] Long fragment feature C long_a The processing process of long segment feature C long_b , short segment feature C short_a and short segment feature C short_b The processing process is similar and will not be repeated here.

[0138] The long segment feature C can be retrieved through the fully connected layer of the initial retrieval modellong_a Perform dimensionality reduction to obtain the reduced-dimensionality long features. Use activation function to activate the reduced-dimensionality long features to obtain activated long features. Input the position encoding corresponding to the activated long features and long segment features into the Transformer network layer to obtain frame-level features. Pool the frame-level features to obtain the first video-level features V long_a .

[0139] Step S32: long segment feature C long_a Input to the teacher retrieval model (teacher model) to obtain the third frame-level feature F corresponding to the first retrieval video long_a . The long segment feature C long_b Input to the teacher retrieval model to obtain the third frame-level feature F corresponding to the second retrieval video long_b . The short segment feature C short_a Input to the teacher retrieval model to obtain the fourth frame-level feature F corresponding to the first retrieval video short_a . The short segment feature C short_b Input to the teacher retrieval model to obtain the fourth frame-level feature F corresponding to the second retrieval video short_b .

[0140] Long fragment feature C long_a and short segment feature C short_a The processing process of long segment feature C long_b and short segment feature C short_b The processing process is similar and will not be repeated here.

[0141] The long segment feature C can be retrieved through the fully connected layer of the teacher retrieval model long_a Perform dimensionality reduction operation to obtain the long feature after dimensionality reduction. Use activation function to activate the long feature after dimensionality reduction to obtain the activated long feature. long_a The corresponding position encoding is input to the Transformer network layer to obtain frame-level features, and this frame-level feature is the third frame-level feature F corresponding to the first retrieval video long_a .

[0142] The short segment feature C can be retrieved through the fully connected layer of the teacher retrieval model short_b Perform dimensionality reduction operation to obtain the short features after dimensionality reduction. Use activation function to activate the short features after dimensionality reduction to obtain the activated short features. short_b The corresponding position code is input to the Transformer network layer to obtain the frame-level feature, and this frame-level feature is the fourth frame-level feature F corresponding to the first retrieval video. short_a .

[0143] For example, for the frame-level feature branch, we can use The fully connected layer of the activation function converts the long segment feature C long_a and short segment feature C short_b The features are mapped to a higher feature dimension than the video feature branch, and then the features are positionally embedded and encoded and input into the Transformer network layer to capture their context information. In the Transformer network layer, the features are successively passed through the multi-head self-attention layer with residual connection and layer normalization and the feed-forward layer. The frame-level features of the long and short clips after further encoding by the Transformer network layer are represented as , .

[0144] For example, the above process can be expressed as: and .

[0145] from Figure 5 It can be seen that the teacher retrieval model also includes a fully connected layer and a Transformer network layer. However, when obtaining the third frame-level feature F long_a and the fourth frame-level feature F short_a Afterwards, unlike the processing of the initial retrieval model, the third frame-level feature F long_a and the fourth frame-level feature F short_a Pooling operation is performed, that is, no video-level features are obtained, and there is no operation to convert frame-level features into video-level features.

[0146] Exemplarily, the network structure of the teacher retrieval model is the same as that of the initial retrieval model, such as both the teacher retrieval model and the initial retrieval model include a fully connected layer and a Transformer network layer, and the network structure of the fully connected layer of the teacher retrieval model is the same as that of the fully connected layer of the initial retrieval model, and the network structure of the Transformer network layer of the teacher retrieval model is the same as that of the Transformer network layer of the initial retrieval model. The accuracy of the teacher retrieval model is higher than that of the initial retrieval model, for example, the accuracy of the data processed by the teacher retrieval model is higher than that of the data processed by the initial retrieval model, and the accuracy of the network weights of the teacher retrieval model is higher than that of the network weights of the initial retrieval model.

[0147] The feature dimension of the third frame-level feature of the first sample video (output of the teacher retrieval model) is higher than that of the first frame-level feature of the first sample video (output of the initial retrieval model). For example, the feature dimension of the third frame-level feature is 1024 dimensions, while the feature dimension of the first frame-level feature is 128 dimensions. The feature dimension of the fourth frame-level feature of the first sample video (output of the teacher retrieval model) is higher than that of the second frame-level feature of the first sample video (output of the initial retrieval model). The feature dimension of the third frame-level feature of the second sample video is higher than that of the first frame-level feature of the second sample video. The feature dimension of the fourth frame-level feature of the second sample video is higher than that of the second frame-level feature of the second sample video.

[0148] Step S33: Calculate the first video level feature V long_a With the second video level feature V short_a The similarity of (similarity of positive sample pairs), the second video-level feature V short_a (or the first video level feature V long_a ) and the first video level feature V long_b (or the second video level feature V short_b ) (the similarity of negative sample pairs).

[0149] Exemplary video-level features based on the output of the initial retrieval model and , cosine similarity calculation can be performed to obtain the similarity of long-short video pairs ,Right now: In the above formula, Can be V short_a or V long_b , Can be V short_a or V short_b , The first video level feature V long_a With the second video level feature V short_a The similarity of the second video level feature V short_a (or the first video level feature V long_a ) and the first video level feature V long_b (or the second video level feature V short_b ) similarity.

[0150] Step S34: Calculate the third frame-level feature F long_a With the fourth frame-level feature F short_a The similarity of (i.e., the similarity of the positive sample pair), the fourth frame-level feature F short_a (or the third frame-level feature F long_a ) and the third frame-level feature F long_b (or the fourth frame-level feature F short_b) (the similarity of negative sample pairs).

[0151] Regarding similarity measurement, since frame-level features contain rich semantic information, these semantic information are crucial for accurately understanding video content. In order to fully capture the subtle differences and complex relationships of these features, this embodiment introduces chamfer similarity ( ) to measure the similarity between frame-level features. Chamfer similarity not only considers the spatial distance between feature points, but also comprehensively considers the density and shape differences of feature point distribution, thereby more comprehensively evaluating the similarities and differences between video frames. In this way, subtle changes in video content can be captured more accurately, improving the understanding of video content.

[0152] In summary, based on the third frame-level feature F long_a With the fourth frame-level feature F short_a , the chamfer similarity algorithm can be used to calculate the third frame-level feature F long_a With the fourth frame-level feature F short_a Similarly, based on the fourth frame-level feature F short_a And the third frame level feature F long_b (or the fourth frame-level feature F short_b ), the chamfer similarity algorithm can be used to calculate the fourth frame-level feature F short_a And the third frame level feature F long_b (or the fourth frame-level feature F short_b ) (i.e. chamfer similarity).

[0153] For example, based on the frame-level features output by the teacher retrieval model and , perform chamfer similarity ( ) to obtain the similarity of the long-short video pair , similarity The calculation formula can be: In the above formula, Can be F long_a , F short_a , is the third frame-level feature F long_a With the fourth frame-level feature F short_a The similarity of Can be used for chamfer similarity calculation. Can be F long_b , F short_a , is the fourth frame-level feature F short_a And the third frame level feature F long_b The similarity.

[0154] Step S35: based on the first video-level feature V of the first sample video long_a With the second video level feature V short_a similarity, the reference video-level features of the first sample video (such as the second video-level features V short_a Or the first video level feature V long_a ) and the reference video-level features of the second sample video (such as the first video-level features V long_b Or the second video level feature V short_b ), and determine the first loss value.

[0155] For example, the first loss value can be determined using formula (2): Represents the first video-level feature V long_a With the second video level feature V short_a The similarity of Represents the similarity between the reference video-level features of the first sample video and the reference video-level features of the second sample video.

[0156] Step S36: Based on the third frame-level feature F of the first sample video long_a And the fourth frame-level feature F of the first sample video short_a similarity, the reference frame-level features of the first sample video (such as the fourth frame-level feature F short_a Or the third frame-level feature F long_a ) and the similarity of the reference frame-level features of the second sample video (such as the third frame-level feature F long_b Or the fourth frame-level feature F short_b , determine the second loss value.

[0157] For example, the second loss value can be determined using the following formula (3):

[0158] Formula (3)

[0159] represents the second loss value, Represents the third frame-level feature F long_a With the fourth frame-level feature F short_a The similarity of represents the similarity between the reference frame-level features of the first sample video and the reference frame-level features of the second sample video, Represents the configured control factor, also called the temperature coefficient, used to amplify the differences between distributions for better analysis. Divergence loss learning.

[0160] Step S37: Based on the first video level feature V long_a With the second video level feature V short_a The similarity of the third frame-level feature Flong_a With the fourth frame-level feature F short_a The similarity of is used to determine the third loss value.

[0161] Exemplarily, based on the first video level feature V long_a With the second video level feature V short_a The similarity of the third frame-level feature F long_a With the fourth frame-level feature F short_a The similarity of The divergence loss determines the third loss value, which is Divergence loss (Kullback-Leibler Divergence Loss) is used as the third loss value.

[0162] For example, by adding Divergence loss is used to make the similarity distribution calculated by the initial retrieval model (student model) branch Similarity distribution calculated with the teacher retrieval model branch Similarity distribution is the similarity between the first video-level feature Vlong_a and the second video-level feature Vshort_a. The similarity distribution is the similarity between the third frame-level feature Flong_a and the fourth frame-level feature Fshort_a. As shown in formula (4), The calculation formula of divergence loss is:

[0163] Formula (4)

[0164] In formula (4), express Divergence loss value, that is, the third loss value, Represents the calculation of similarity distribution Similarity distribution of Divergence loss value, that is, based on the similarity distribution Similarity distribution calculate Divergence loss value, no restrictions are placed on this calculation process.

[0165] Step S38: determine a target loss value based on the first loss value, the second loss value and the third loss value.

[0166] For example, the comparative learning loss value may be calculated based on the first loss value and the second loss value. For example, the comparative learning loss value may be calculated using the following formula: + .in, represents the contrastive learning loss value, represents the first loss value, Represents the second loss value.

[0167] Then, the target loss value can be calculated based on the contrastive learning loss value and the third loss value. For example, the target loss value can be calculated using the following formula: .in, represents the standard loss value, represents the contrastive learning loss value, Represents the third loss value. and It is used to balance the initial weight of each loss during model training, that is, the weight of the comparative learning loss value and the weight of the third loss value.

[0168] Step S39: Optimize the initial retrieval model based on the target loss value to obtain an optimized retrieval model, and determine the target retrieval model (i.e., the retrieval model that is finally output) based on the optimized retrieval model.

[0169] After obtaining the target loss value, the initial retrieval model can be optimized based on the target loss value to obtain an optimized retrieval model. For example, the initial retrieval model can be optimized by using a gradient descent method. The optimization goal of the initial retrieval model is to make the target loss value smaller and smaller by adjusting the network parameters of the initial retrieval model, such as the network parameters of the fully connected layer and the Transformer network layer.

[0170] Each time the initial retrieval model is optimized based on the target loss value, the teacher retrieval model also needs to be optimized based on the target loss value to obtain the optimized teacher retrieval model. For example, the teacher retrieval model can be optimized by using methods such as gradient descent, that is, by adjusting the network parameters of the teacher retrieval model, such as the network parameters of the fully connected layer and the Transformer network layer, so that the target loss value becomes smaller and smaller.

[0171] After obtaining the optimized retrieval model, if the convergence conditions are met, such as the number of optimizations of the initial retrieval model has reached the number threshold, or the optimization time of the initial retrieval model has reached the time threshold, or the target loss value is less than the preset threshold, the optimized retrieval model will be used as the target retrieval model.

[0172] After obtaining the optimized retrieval model, if the convergence condition is not met, the optimized retrieval model is used as the initial retrieval model, and the optimized teacher retrieval model is used as the teacher retrieval model, and the process of returning to execute the long clip features input into the initial retrieval model to obtain the first video-level features, the short clip features input into the initial retrieval model to obtain the second video-level features, the long clip features input into the teacher retrieval model to obtain the third frame-level features, and the short clip features input into the teacher retrieval model to obtain the fourth frame-level features.

[0173] Exemplarily, after obtaining the target retrieval model, the target retrieval model is used to retrieve the target video that matches the video to be detected. For example, for the video to be detected (i.e., the target video for which the video to be detected needs to be retrieved), the video to be detected can be input into the target retrieval model, and the target retrieval model outputs the features corresponding to the video to be detected. For example, after extracting features from the video to be detected, the fully connected layer and the Transformer network layer of the target retrieval model can process the input features in turn to obtain output features (i.e., the features of the video to be detected). In addition, each video in the video database can be input into the target retrieval model, and the target retrieval model outputs the features corresponding to the video.

[0174] After obtaining the features of the video to be detected and the features of each video in the video database, a target video matching the video to be detected can be found from all the features in the video database based on similarity.

[0175] It can be seen from the above technical solution that in the embodiment of the present application, the target video matching the video to be detected is retrieved based on the target retrieval model, that is, the video to be detected and the videos in the video database are input into the target retrieval model, and the similarity between the video to be detected and each video in the video database can be obtained. This process only requires a small amount of computing resources and a short time to complete the comparison process.

[0176] When training the target retrieval model, the positive samples are composed of the long clip features and short clip features of the first sample video, and the negative samples are composed of the long clip features (or short clip features) of the first sample video and the long clip features (or short clip features) of the second sample video. The long clip features and short clip features are obtained based on the sample video. In this way, there is no need to manually calibrate the positive and negative samples, that is, the training process of the target retrieval model does not rely on manually labeled data. By mining the characteristics of the video itself, the unsupervised retrieval model training can be achieved. The rich background content of the long clip features and the local fine-grained information of the short clip features are combined to guide the retrieval model to effectively learn the video representation, improve the retrieval efficiency of the retrieval model, improve the accuracy and reliability of the retrieval, improve the performance of the retrieval model, and ensure the retrieval accuracy of the retrieval model.

[0177] In order to solve the problem of using unlabeled data, in this embodiment, based on the idea of ​​contrastive learning, a long-short dynamic sampling strategy is designed by mining the structural characteristics of the video itself. This dynamic sampling strategy aims to combine the rich background content of long clips and the local fine-grained information of short clips to guide the model to effectively learn video representation. This strategy is not only applicable to completely unlabeled self-supervised scenarios, but also can make full use of limited labeled data and a large amount of unlabeled data in semi-supervised environments to improve the performance of the model.

[0178] In contrastive learning, the diversity of samples in the training dataset is crucial, and data augmentation is a key means to achieve this goal. To this end, in this embodiment, a content-aware feature-level data augmentation is designed. -Compared with image-level data enhancement, the data enhancement of the nearest neighbor algorithm can avoid repeated and tedious operations in the pixel space, while increasing the diversity of data, thereby reducing the time overhead in the training process and improving the training efficiency of the model training process.

[0179] Although the aggregation strategy of video-level features helps to speed up retrieval and reduce storage requirements, it will inevitably sacrifice some details and semantic information. In contrast, although frame-level features can preserve detailed visual content and rich semantics, they have huge demands on computing resources and storage space. To this end, in this embodiment, a similarity complementary self-distillation learning method is proposed, which transfers the similarity obtained based on dense frame-level features to the similarity based on video-level features through self-distillation learning. While ensuring performance, video retrieval based on video-level features is realized, the retrieval efficiency of the model is improved, and significant optimization of feature storage space is achieved, reducing memory consumption, and improving system performance while ensuring retrieval accuracy.

[0180] Based on the same application concept as the above method, an unsupervised efficient video retrieval device based on contrastive learning is proposed in the embodiment of the present application, see Figure 6 FIG. 1 is a schematic diagram of the structure of the unsupervised efficient video retrieval device based on contrastive learning, and the device may include:

[0181] The acquisition module 61 is used to perform data enhancement on the initial features corresponding to the first sample video to obtain enhanced features, wherein the enhanced features include multiple frame-level feature values; based on the enhanced features, a long segment feature and a short segment feature corresponding to the first sample video are obtained; wherein the long segment feature includes part or all of the frame-level feature values ​​of the multiple frame-level feature values ​​of the enhanced features, and the short segment feature includes part of the frame-level feature values ​​of the multiple frame-level feature values ​​of the long segment feature;

[0182] A processing module 62, configured to input the long segment feature into an initial retrieval model to obtain a first video-level feature, and input the short segment feature into the initial retrieval model to obtain a second video-level feature;

[0183] A determination module 63, configured to determine a first loss value based on the similarity between the first video-level feature and the second video-level feature, and the similarity between the reference video-level feature of the first sample video and the reference video-level feature of the second sample video; the reference video-level feature is the first video-level feature or the second video-level feature;

[0184] A training module 64 is used to optimize the initial retrieval model based on the first loss value to obtain an optimized retrieval model, and determine a target retrieval model based on the optimized retrieval model;

[0185] The target retrieval model is used to retrieve a target video that matches the video to be detected.

[0186] Exemplarily, when the acquisition module 61 performs data enhancement on the initial features corresponding to the first sample video to obtain enhanced features, it is specifically used to: generate a mask feature for the initial feature, the initial feature includes multiple initial feature values, and the mask feature includes multiple mask values ​​corresponding one-to-one to the multiple initial feature values; based on the mask feature, the multiple initial feature values ​​are divided into first-category feature values ​​and second-category feature values; if the mask value corresponding to the initial feature value is a first value, then the initial feature value is a first-category feature value, and if the mask value corresponding to the initial feature value is a second value, then the initial feature value is a second-category feature value; for each first-category feature value, the first-category feature value is used as an enhanced frame-level feature value; for each second-category feature value, K neighboring feature values ​​are selected from multiple initial feature values; based on the second-category feature value and the K neighboring feature values, an enhanced frame-level feature value is determined; and the enhanced frame-level feature values ​​corresponding to all first-category feature values ​​and all second-category feature values ​​are combined to obtain an enhanced feature.

[0187] Exemplarily, when the acquisition module 61 acquires the long fragment feature and the short fragment feature based on the enhanced feature, it is specifically used to: determine the first number corresponding to the long fragment feature based on the total number of frame-level feature values ​​of the enhanced feature and the configured long fragment scale factor, randomly select a first number of frame-level feature values ​​from all frame-level feature values ​​of the enhanced feature, and generate the long fragment feature based on the first number of frame-level feature values; wherein the long fragment scale factor is greater than 0, and the long fragment scale factor is less than or equal to 1; determine the second number corresponding to the short fragment feature based on the total number of frame-level feature values ​​of the long fragment feature and the configured short fragment scale factor, randomly select a second number of frame-level feature values ​​from all frame-level feature values ​​of the long fragment feature, and generate the short fragment feature based on the second number of frame-level feature values; wherein the short fragment scale factor is greater than 0, and the short fragment scale factor is less than 1.

[0188] Exemplarily, the initial retrieval model includes a fully connected layer and a Transformer network layer; the processing module 62 inputs the long segment feature to the initial retrieval model to obtain the first video-level feature, and inputs the short segment feature to the initial retrieval model to obtain the second video-level feature, and is specifically used for: performing a dimensionality reduction operation on the long segment feature through the fully connected layer to obtain a long feature after dimensionality reduction; using an activation function to activate the long feature after dimensionality reduction to obtain an activated long feature; inputting the position encoding corresponding to the activated long feature and the long segment feature to the Transformer network layer to obtain a first frame-level feature; performing a pooling operation on the first frame-level feature to obtain the first video-level feature; performing a dimensionality reduction operation on the short segment feature through the fully connected layer to obtain a short feature after dimensionality reduction; using an activation function to activate the short feature after dimensionality reduction to obtain an activated short feature; inputting the position encoding corresponding to the activated short feature and the short segment feature to the Transformer network layer to obtain a second frame-level feature; performing a pooling operation on the second frame-level feature to obtain the second video-level feature.

[0189] Exemplarily, the determination module 63 determines the first loss value based on the similarity between the first video-level feature and the second video-level feature, and the similarity between the reference video-level feature of the first sample video and the reference video-level feature of the second sample video. If the reference video-level feature of the first sample video is the second video-level feature of the first sample video, and the reference video-level feature of the second sample video is the first video-level feature or the second video-level feature of the second sample video, the following formula is used to determine the first loss value: ;in, represents the first loss value, represents the similarity between the first video-level feature and the second video-level feature, represents the similarity between the reference video-level features of the first sample video and the reference video-level features of the second sample video, represents the configured control factor, represents the similarity function, and .

[0190] Exemplarily, the training module 64 optimizes the initial retrieval model based on the first loss value, and when the optimized retrieval model is obtained, it is specifically used for: inputting the long segment feature into the teacher retrieval model to obtain the third frame-level feature, and inputting the short segment feature into the teacher retrieval model to obtain the fourth frame-level feature; wherein the network structure of the teacher retrieval model is the same as the network structure of the initial retrieval model, and the accuracy of the teacher retrieval model is higher than the accuracy of the initial retrieval model; the feature dimension of the third frame-level feature is higher than the feature dimension of the first frame-level feature, and the feature dimension of the fourth frame-level feature is higher than the feature dimension of the second frame-level feature; the feature dimension of the third frame-level feature is higher than the feature dimension of the first video-level feature, and the feature dimension of the fourth frame-level feature is higher than the feature dimension of the first video-level feature. Based on the similarity between the third frame-level feature and the fourth frame-level feature, and the similarity between the reference frame-level feature of the first sample video and the reference frame-level feature of the second sample video, a second loss value is determined; wherein the reference frame-level feature is the third frame-level feature or the fourth frame-level feature; based on the similarity between the first video-level feature and the second video-level feature, and the similarity between the third frame-level feature and the fourth frame-level feature, a third loss value is determined; based on the first loss value, the second loss value and the third loss value, a target loss value is determined, and based on the target loss value, the initial retrieval model is optimized to obtain an optimized retrieval model.

[0191] Exemplarily, the teacher retrieval model includes a fully connected layer and a Transformer network layer; the training module 64 inputs the long segment feature to the teacher retrieval model to obtain a third frame-level feature, and inputs the short segment feature to the teacher retrieval model to obtain a fourth frame-level feature, and is specifically used for: performing a dimensionality reduction operation on the long segment feature through a fully connected layer to obtain a long feature after dimensionality reduction; using an activation function to activate the long feature after dimensionality reduction to obtain an activated long feature; inputting the position coding corresponding to the activated long feature and the long segment feature to the Transformer network layer to obtain a third frame-level feature; performing a dimensionality reduction operation on the short segment feature through a fully connected layer to obtain a short feature after dimensionality reduction; using an activation function to activate the short feature after dimensionality reduction to obtain an activated short feature; inputting the position coding corresponding to the activated short feature and the short segment feature to the Transformer network layer to obtain a fourth frame-level feature.

[0192] Exemplarily, the training module 64 is further used to calculate the similarity between the third frame-level feature and the fourth frame-level feature by using a chamfer similarity algorithm based on the third frame-level feature and the fourth frame-level feature; the training module 64 is specifically used to determine the third loss value based on the similarity between the first video-level feature and the second video-level feature, and the similarity between the third frame-level feature and the fourth frame-level feature: based on the similarity between the first video-level feature and the second video-level feature, and the similarity between the third frame-level feature and the fourth frame-level feature, using The divergence loss determines the third loss value.

[0193] Based on the same application concept as the above method, an electronic device is proposed in the embodiment of the present application, see Figure 7 As shown, it includes: a processor 71 and a machine-readable storage medium 72, the machine-readable storage medium 72 stores machine-executable instructions that can be executed by the processor 71; the processor 71 is used to execute the machine-executable instructions to implement the above-mentioned example of the present application based on contrastive learning unsupervised efficient video retrieval method.

[0194] Based on the same application concept as the above method, an embodiment of the present application also provides a machine-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed by a processor, the unsupervised and efficient video retrieval method based on contrastive learning in the above example of the present application can be implemented.

[0195] The above-mentioned machine-readable storage medium may be any electronic, magnetic, optical or other physical storage device, which may contain or store information, such as executable instructions, data, etc. For example, the machine-readable storage medium may be: RAM (Radom Access Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as optical disk, DVD, etc.), or similar storage medium, or a combination thereof.

[0196] Based on the same application concept as the above method, an embodiment of the present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the above-mentioned unsupervised and efficient video retrieval method based on contrastive learning.

Claims

1. An unsupervised and efficient video retrieval method based on contrastive learning, characterized in that: include: Performing data enhancement on initial features corresponding to the first sample video to obtain enhanced features, wherein the enhanced features include multiple frame-level feature values; Acquire a long segment feature and a short segment feature based on the enhanced feature, wherein the long segment feature includes part or all of the frame-level feature values ​​of the multiple frame-level feature values ​​of the enhanced feature, and the short segment feature includes part of the frame-level feature values ​​of the multiple frame-level feature values ​​of the long segment feature; Inputting the long segment feature into the initial retrieval model to obtain a first video-level feature, and inputting the short segment feature into the initial retrieval model to obtain a second video-level feature; A first loss value is determined based on the similarity between the first video-level feature and the second video-level feature, and the similarity between the reference video-level feature of the first sample video and the reference video-level feature of the second sample video; wherein the second sample video is a sample video other than the first sample video; the similarity between the reference video-level feature of the first sample video and the reference video-level feature of the second sample video includes: the similarity between the first video-level feature and the first video-level feature of the second sample video, or the similarity between the first video-level feature and the second video-level feature of the second sample video, or the similarity between the second video-level feature and the first video-level feature of the second sample video, or the similarity between the second video-level feature and the second video-level feature of the second sample video; Optimizing the initial retrieval model based on the first loss value to obtain an optimized retrieval model, and determining a target retrieval model based on the optimized retrieval model; The target retrieval model is used to retrieve a target video that matches the video to be detected.

2. The method according to claim 1, characterized in that The step of performing data enhancement on the initial features corresponding to the first sample video to obtain enhanced features includes: Generating a mask feature for the initial feature, the initial feature comprising a plurality of initial feature values, the mask feature comprising a plurality of mask values ​​corresponding one-to-one to the plurality of initial feature values; Based on the mask feature, multiple initial feature values ​​are divided into first-category feature values ​​and second-category feature values; wherein, if the mask value corresponding to the initial feature value is a first value, then the initial feature value is a first-category feature value, and if the mask value corresponding to the initial feature value is a second value, then the initial feature value is a second-category feature value; For each first-category feature value, use the first-category feature value as an enhanced frame-level feature value; For each second-class eigenvalue, select K neighboring eigenvalues ​​from the multiple initial eigenvalues; determine an enhanced frame-level eigenvalue based on the second-class eigenvalue and the K neighboring eigenvalues; The enhanced features are obtained by combining the enhanced frame-level feature values ​​corresponding to all first-category feature values ​​and the enhanced frame-level feature values ​​corresponding to all second-category feature values.

3. The method according to claim 1, characterized in that The acquiring of long segment features and short segment features based on the enhanced features includes: Based on the total number of frame-level feature values ​​of the enhanced feature and the configured long segment scale factor, determine a first number corresponding to the long segment feature, randomly select a first number of frame-level feature values ​​from all frame-level feature values ​​of the enhanced feature, and generate a long segment feature based on the first number of frame-level feature values; wherein the long segment scale factor is greater than 0 and less than or equal to 1; Based on the total number of frame-level feature values ​​of the long segment feature and the configured short segment scaling factor, determine the second number of short segment features corresponding to the short segment features, randomly select a second number of frame-level feature values ​​from all frame-level feature values ​​of the long segment feature, and generate short segment features based on the second number of frame-level feature values; wherein the short segment scaling factor is greater than 0 and less than 1.

4. The method according to claim 1, characterized in that The initial retrieval model includes a fully connected layer and a Transformer network layer; The step of inputting the long segment feature into the initial retrieval model to obtain the first video-level feature, and inputting the short segment feature into the initial retrieval model to obtain the second video-level feature, comprises: Performing a dimension reduction operation on the long segment feature through the fully connected layer to obtain a reduced dimension long feature; performing an activation operation on the reduced dimension long feature using an activation function to obtain an activated long feature; inputting the position encoding corresponding to the activated long feature and the long segment feature into the Transformer network layer to obtain a first frame-level feature; performing a pooling operation on the first frame-level feature to obtain the first video-level feature; The short segment features are subjected to dimensionality reduction operation through the fully connected layer to obtain the reduced short features; the reduced short features are activated by using an activation function to obtain the activated short features; the position codes corresponding to the activated short features and the short segment features are input into the Transformer network layer to obtain the second frame-level features; the second frame-level features are subjected to pooling operation to obtain the second video-level features.

5. The method according to claim 1, characterized in that The determining a first loss value based on the similarity between the first video-level feature and the second video-level feature and the similarity between the reference video-level feature of the first sample video and the reference video-level feature of the second sample video includes: If the similarity between the reference video-level feature of the first sample video and the reference video-level feature of the second sample video is: the similarity between the second video-level feature and the first video-level feature of the second sample video, or the similarity between the second video-level feature and the second video-level feature of the second sample video, the first loss value is determined by the following formula: ; in, represents the first loss value, represents the similarity between the first video-level feature and the second video-level feature, represents the similarity between the reference video-level features of the first sample video and the reference video-level features of the second sample video, represents the configured control factor, represents the similarity function, and .

6. The method according to claim 4, characterized in that The step of optimizing the initial retrieval model based on the first loss value to obtain an optimized retrieval model includes: The long segment feature is input into the teacher retrieval model to obtain a third frame-level feature, and the short segment feature is input into the teacher retrieval model to obtain a fourth frame-level feature; wherein the network structure of the teacher retrieval model is the same as the network structure of the initial retrieval model, and the accuracy of the teacher retrieval model is higher than the accuracy of the initial retrieval model; the feature dimension of the third frame-level feature is higher than the feature dimension of the first frame-level feature, and the feature dimension of the fourth frame-level feature is higher than the feature dimension of the second frame-level feature; the feature dimension of the third frame-level feature is higher than the feature dimension of the first video-level feature, and the feature dimension of the fourth frame-level feature is higher than the feature dimension of the first video-level feature; Determine a second loss value based on the similarity between the third frame-level feature and the fourth frame-level feature, and the similarity between the reference frame-level feature of the first sample video and the reference frame-level feature of the second sample video; wherein the reference frame-level feature is the third frame-level feature or the fourth frame-level feature; Determining a third loss value based on a similarity between the first video-level feature and the second video-level feature, and a similarity between the third frame-level feature and the fourth frame-level feature; A target loss value is determined based on the first loss value, the second loss value, and the third loss value, and the initial retrieval model is optimized based on the target loss value to obtain an optimized retrieval model.

7. The method according to claim 6, characterized in that The teacher retrieval model includes a fully connected layer and a Transformer network layer; The step of inputting the long segment feature to the teacher retrieval model to obtain the third frame-level feature, and inputting the short segment feature to the teacher retrieval model to obtain the fourth frame-level feature, comprises: Performing a dimension reduction operation on the long segment feature through a fully connected layer to obtain a reduced-dimensional long feature; performing an activation operation on the reduced-dimensional long feature using an activation function to obtain an activated long feature; inputting the position encoding corresponding to the activated long feature and the long segment feature into the Transformer network layer to obtain a third frame-level feature; The short segment features are reduced in dimension through a fully connected layer to obtain reduced short features; the reduced short features are activated using an activation function to obtain activated short features; the position codes corresponding to the activated short features and the short segment features are input into the Transformer network layer to obtain the fourth frame-level features.

8. The method according to claim 6, characterized in that Before determining the second loss value based on the similarity between the third frame-level feature and the fourth frame-level feature, and the similarity between the reference frame-level feature of the first sample video and the reference frame-level feature of the second sample video, the method further includes: calculating the similarity between the third frame-level feature and the fourth frame-level feature using a chamfer similarity algorithm based on the third frame-level feature and the fourth frame-level feature; The determining of a third loss value based on the similarity between the first video-level feature and the second video-level feature and the similarity between the third frame-level feature and the fourth frame-level feature comprises: Based on the similarity between the first video-level feature and the second video-level feature, and the similarity between the third frame-level feature and the fourth frame-level feature, The divergence loss determines the third loss value.

9. An unsupervised and efficient video retrieval device based on contrastive learning, characterized in that: include: An acquisition module, configured to perform data enhancement on the initial features corresponding to the first sample video to obtain enhanced features, wherein the enhanced features include a plurality of frame-level feature values; Based on the enhanced feature, a long segment feature and a short segment feature corresponding to the first sample video are obtained; wherein the long segment feature includes part or all of the frame-level feature values ​​of the multiple frame-level feature values ​​of the enhanced feature, and the short segment feature includes part of the frame-level feature values ​​of the multiple frame-level feature values ​​of the long segment feature; A processing module, used for inputting the long segment feature into an initial retrieval model to obtain a first video-level feature, and inputting the short segment feature into the initial retrieval model to obtain a second video-level feature; A determination module, used to determine a first loss value based on the similarity between the first video-level feature and the second video-level feature, and the similarity between the reference video-level feature of the first sample video and the reference video-level feature of the second sample video; wherein the second sample video is a sample video other than the first sample video; the similarity between the reference video-level feature of the first sample video and the reference video-level feature of the second sample video includes: the similarity between the first video-level feature and the first video-level feature of the second sample video, or the similarity between the first video-level feature and the second video-level feature of the second sample video, or the similarity between the second video-level feature and the first video-level feature of the second sample video, or the similarity between the second video-level feature and the second video-level feature of the second sample video; A training module, configured to optimize the initial retrieval model based on the first loss value to obtain an optimized retrieval model, and determine a target retrieval model based on the optimized retrieval model; The target retrieval model is used to retrieve a target video that matches the video to be detected.

10. An electronic device, characterized in that: include: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; The processor is used to execute machine executable instructions to implement the method described in any one of claims 1-8.

Citation Information

Patent Citations

  • Video spatio-temporal feature learning and extracting method and device, equipment and storage medium

    CN112507990A

  • Video quick retrieval method and system and video quick recommendation method

    CN113742524A

  • Video detection method and device, electronic equipment and storage medium

    CN115858860A

  • Video representation method and device based on unsupervised pre-training model

    CN116226450A

  • Video retrieval method and device, medium and computing equipment

    CN116680442A