A file attribute-based adaptive compression method, system and storage medium
By loading the classification table and feature extraction model, and selecting an appropriate compression algorithm according to the file type, the problem of low compression rate caused by differences in file types in the existing technology is solved, and more efficient file compression and storage are achieved.
Patent Information
- Application Number
- CN202410775156.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2023-12-07
- Filing Date
- 2024-06-17
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-06-17
AI Technical Summary
The existing technology lacks the ability to select appropriate compression algorithms based on specific document types and document characteristics, resulting in low compression rates for different types of files.
By loading the pre-configured classification table and feature extraction model, selecting an appropriate compression algorithm according to the file type, using the feature extraction model to extract file features and selecting the compression algorithm combined with the algorithm selection model, adaptive compression is achieved.
It improves the compression rate of different file types, improves the utilization efficiency of file storage space, realizes the automatic generation of text file labels through text file vectorization, and improves the training efficiency of feature extraction models.
Smart Images

Figure CN118349528B_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the technical field of compression algorithms, and in particular to a method, system and storage medium for adaptive compression based on file attributes. Background Art
[0002] A compression algorithm refers to an algorithm for data compression. In the field of electronics and communications, it is often referred to as signal coding, which includes two steps: compression and restoration (or decoding and encoding). Since multimedia signals have a huge amount of data, they need to be compressed; at the same time, since there are various redundancies in multimedia data, they can be compressed. Compression algorithms include lossless compression and lossy compression. Among them, lossless compression can reconstruct the compressed data without distortion and accurately restore the original data. It can be used in situations where the accuracy of data is strictly required, such as the compression of executable files and ordinary files, the compression of disks, and the compression of multimedia data. The compression of this method is relatively small. For example, differential coding, RLE, Huffman coding, LZW coding, and arithmetic coding. Lossy compression has distortion and cannot completely and accurately restore the original data. The reconstructed data is only an approximation of the original data. It can be used in situations where the accuracy of data is not required, such as the compression of multimedia data. The compression of this method is relatively large. For example, predictive coding, sound perception coding, fractal compression, wavelet compression, JPEG / MPEG. There are many algorithmic approaches to compression algorithms. For different document types, different compression algorithms have different compression effects and compression efficiencies. Moreover, for a document type, different specific documents have different compression algorithms suitable for them. However, there is currently a lack of solutions that can select a suitable compression algorithm based on specific document types and document characteristics. Summary of the invention
[0003] One or more embodiments of this specification describe a method, system and storage medium for adaptive compression based on file attributes, which improves the compression ratio of different types of files and helps reduce the space occupied by file storage.
[0004] In a first aspect, an embodiment of the present specification provides a method for adaptive compression based on file attributes, comprising the steps of:
[0005] Loading a pre-configured classification table, wherein the classification table records a plurality of file types and at least one corresponding compression algorithm;
[0006] Inputting the file to be compressed into a pre-established feature extraction model corresponding to the file type to obtain file features;
[0007] Based on the response of a pre-established algorithm selection model corresponding to the file type to the file feature, a corresponding compression algorithm is selected to compress the file to be compressed, and a compression algorithm identifier is associated.
[0008] In a second aspect, an embodiment of the present specification provides a file attribute-based adaptive compression system, including:
[0009] A recording component, used for loading a pre-configured classification table, wherein the classification table records a plurality of file types and at least one corresponding compression algorithm;
[0010] A feature component, used for inputting the file to be compressed into a pre-established feature extraction model corresponding to the file type to obtain file features;
[0011] A compression component is used to select a corresponding compression algorithm to compress the to-be-compressed file based on the response of a pre-established algorithm selection model corresponding to the file type to the file feature, and associate a compression algorithm identifier. In a third aspect, an embodiment of this specification provides an electronic device, including a processor and a memory;
[0012] The processor is connected to the memory;
[0013] The memory is used to store executable program code;
[0014] The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the aforementioned file attribute-based adaptive compression method.
[0015] In a fourth aspect, an embodiment of the present specification provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the adaptive compression method based on file attributes as described above is implemented.
[0016] The beneficial technical effects of one or more embodiments of the present specification include: selecting a compression algorithm through a feature extraction model and an algorithm selection model, which helps to improve the compression rate of different file types; extracting content features of the file to be compressed with the help of the feature extraction model, and selecting a more suitable compression algorithm based on content features with the help of the algorithm selection model, thereby further improving the compression rate of the file; automating the generation of text file labels with the help of text file vectorization, and extracting content features of the text file at the same time, thereby improving the training efficiency of the feature extraction model.
[0017] Other features and advantages of one or more embodiments of the present specification will be disclosed in detail in the following specific implementations and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The following is a further description of this specification in conjunction with the accompanying drawings:
[0019] Figure 1This is a panoramic view of the application scenario of the adaptive compression method of the embodiment of this specification.
[0020] Figure 2 This is a flow chart of the adaptive compression method according to an embodiment of this specification.
[0021] Figure 3 This is a schematic diagram of algorithm selection for the embodiments of this specification.
[0022] Figure 4 The embodiment of this specification is a flow chart of a method for training a feature extraction model for a text file.
[0023] Figure 5 The embodiment of this specification is a schematic diagram of a feature extraction model for text file training.
[0024] Figure 6 The embodiment of this specification is a flow chart of a method for training a feature extraction model for an audio file.
[0025] Figure 7 The embodiment of this specification is a schematic diagram of a feature extraction model for audio file training.
[0026] Figure 8 This is a schematic diagram of text recognition of a sample audio file according to an embodiment of this specification.
[0027] Fig. 9 The embodiment of this specification is a flow chart of a method for training a feature extraction model for a video file.
[0028] Fig.10 The embodiment of this specification is a schematic diagram of a feature extraction model for video file training.
[0029] Fig.11 This is a flow chart of the model selection method for the training algorithm of the embodiment of this specification.
[0030] Fig.12 This is a schematic diagram of the structure of the adaptive compression system according to the embodiment of this specification.
[0031] Fig.13 This is a schematic diagram of the characteristic component structure of the embodiments of this specification.
[0032] Fig.14 This is a schematic diagram of the structure of an electronic device according to an embodiment of this specification.
[0033] Among them: 11. file to be compressed, 12. compressed file, 13. text vector, 14. recognized text, 121. compression algorithm identifier, 21. recording component, 31. feature component, 32. feature extraction model, 33. algorithm selection model, 41. compression component, 311. text model subcomponent, 312. audio model subcomponent, 313. algorithm selection subcomponent, 314. video model subcomponent, 321. first neural network model, 322. second neural network model, 323. third neural network model, 50. electronic device, 51. processor, 52. communication bus, 53. user interface, 54. network interface, 55. memory, 111. text file, 1111. text feature, 112. audio file, 1121. audio feature, 113. image track, 1131. image stream feature, 114. audio track, 1141. audio track feature, 1151. video feature. DETAILED DESCRIPTION
[0034] The following is an explanation and description of the technical solutions of the embodiments of this specification in conjunction with the drawings of the embodiments of this specification, but the following embodiments are only preferred embodiments of this specification, not all. Based on the embodiments in the implementation mode, other embodiments obtained by those skilled in the art without creative work are all within the scope of protection of this specification.
[0035] In the following description, terms such as "inside", "outside", "up", "down", "left", "right", etc. that indicate directions or positional relationships are only used to facilitate the description of the embodiments and simplify the description, and do not indicate or imply that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore should not be understood as a limitation of this specification.
[0036] Glossary:
[0037] Compression Algorithm
[0038] The compression algorithm referred to in this specification is an algorithm for re-encoding files or data. The size relationship between the compressed file 12 and the original file after executing the compression algorithm does not affect the identification of the compression algorithm concept in this specification, nor does it affect the expected beneficial technical effects achieved by this specification. That is, after executing the compression algorithm, the compressed file 12 is less than or equal to the size of the original file, and belongs to the compression algorithm referred to in this specification. Exemplarily, the compression algorithm includes Huffman coding, which reduces the storage space of data by encoding characters or symbols with higher frequency of occurrence in a shorter manner. Lempel-Ziv-Welch algorithm, a lossless compression algorithm, reduces the size of data by establishing a dictionary to replace repeated sequences. Deflate compression algorithm, an algorithm that combines LZ77 and Huffman coding, is commonly used for ZIP file compression. Run-Length Encoding algorithm, a simple lossless compression algorithm, reduces the size of data by counting consecutively repeated data. Burrows-Wheeler Transform algorithm, rearranges the character sequence so that the repeated characters are adjacent, and then uses other compression algorithms to further compress the data. The LZ77 algorithm reduces the size of data by referencing the same string that has appeared before.
[0039] File Type
[0040] The file types involved in this specification include binary files, text files 111, image files, audio files 112 and video files. Exemplarily, binary files include data files, executable program files, script files, encrypted ciphertext files, etc.
[0041] Before introducing the technical solutions of the embodiments of this specification, the application scenarios of the embodiments of this specification are introduced.
[0042] This specification discloses a file attribute-based adaptive compression method for file transmission or file storage. When used for file transmission, it can reduce the size of information to be transmitted and save transmission time. When used for file storage, it can reduce the storage space occupied. The implementation subject can be the party sending the file in the information transmission, or the single party performing file storage.
[0043] The indicators for measuring the advantages and disadvantages of compression algorithms include compression rate and compression efficiency. Compared with compression efficiency, this specification is more inclined to consider the advantages and disadvantages of compression algorithm selection from the perspective of compression rate. The compression rate of a compression algorithm is not only related to the compression algorithm itself, but also to the specific content of the specific file 11 to be compressed. For example, if there is a large amount of repeated or redundant information in the data, the compression algorithm can usually make better use of these characteristics to obtain a higher compression rate. That is, some algorithms may perform better on certain data types, but have poor effects on other data types. Therefore, choosing a suitable compression algorithm is crucial to obtaining a higher compression rate. Some compression algorithms allow the compression level to be set, such as the compression level in the Deflate compression algorithm. A higher compression level may result in a higher compression rate, but it will also increase the compression time and computing resource consumption. Before applying the compression algorithm, preprocessing the data may affect the compression rate. For example, removing unnecessary spaces, duplicate lines or other redundant information may help improve the compression rate. Different compression levels of the same compression algorithm are a balance between compression rate and compression efficiency. This specification discloses a technical solution for selecting between different compression algorithms for files of different types and contents. That is, the selection of different compression levels is not within the scope of this specification, so this specification does not consider the compression level of the compression algorithm. However, as a workaround, the same compression algorithm with different compression levels can be regarded as two independent compression algorithms in the technical solution disclosed in this specification, and participate in the selection of the compression algorithm. For example, please refer to the attached Figure 1 Different compression algorithms are used for different types of files. The text file 111 uses the huffman coding compression algorithm and the gzip compression algorithm, the audio file 112 uses the acc compression algorithm and the opus compression algorithm, and the video file uses the avc compression algorithm and the hevc compression algorithm. For the same file type, such as the same text file 111, different text files 111 use the huffman coding compression algorithm and the gzip compression algorithm respectively. The specific compression algorithm to be used is determined by the adaptive compression method disclosed in this specification.
[0044] For example, in a commercial activity of bidding, the bidder needs to send the bidding document to the bidding party. The bidding document includes a text file 111, a picture file, an audio file 112, a video file, a binary file, etc., and usually occupies a large storage space. In order to improve the transmission efficiency of the bidding document, the bidder needs to compress the bidding document. When the bidder compresses the bidding document, the compression algorithm selected has an important impact on the final compression effect. If the bidder compresses all files using a compression algorithm, the compression rates of different file types will be different, which will eventually affect the compression rate. However, if different compression algorithms are used for files of different file types, it is not considered that the files of the same file type will also have different compression rates due to the differences in their specific contents. For this reason, the bidder uses the file attribute-based adaptive compression method disclosed in this specification to select the best compression algorithm for files of different file types and different contents to obtain a better compression effect.
[0045] First, this specification provides a method for adaptive compression based on file attributes. Figure 2 , including the steps of:
[0046] Step S102) loading a pre-configured classification table, wherein the classification table records a number of file types and at least one corresponding compression algorithm;
[0047] Step S104) inputting the file to be compressed into a pre-established feature extraction model 32 corresponding to the file type to obtain file features;
[0048] Step S106) Based on the response of the pre-established algorithm selection model 33 corresponding to the file type to the file feature, a corresponding compression algorithm is selected to compress the file to be compressed, and a compression algorithm identifier is associated.
[0049] In this embodiment, the feature extraction model 32 is used to extract the features of the file content to achieve the representation of the file content. Then, the features of the file content and the algorithm selection model 33 are used to select the best compression algorithm under the condition of considering the features of the file content. Figure 3 In this embodiment, for different file types, different feature extraction models 32 and algorithm selection models 33 are trained. For the text file 111, the compression algorithm mainly considers that a large amount of text in the text file 111 is repeated, and the compression of the text file 111 is achieved with the help of technologies such as Huffman coding. For pictures, audio and video, the use of lossy compression can achieve better compression effects, and the use of lossless compression can retain comprehensive information. This specification does not consider the issue of whether pictures, audio and video lose information after compression. Because the current lossy compression algorithm can still guarantee the availability of pictures, audio and video, this specification does not impose any restrictions.
[0050] On the other hand, in another embodiment, the file type recorded in the classification table includes a text file 111. Figure 4 , when the feature extraction model 32 is pre-established for the text file 111, the following steps are performed:
[0051] Step S202) establishing a first neural network model 321, wherein the response of the first neural network model 321 to the text file 111 is used as a text feature 1111;
[0052] Step S204) receiving a sample text file, and vectorizing the sample text file to obtain a text vector 13;
[0053] Step S206) expressing the text feature 1111 of the sample text file in a vector form, and determining the value of the loss function based on the vector distance between the text feature 1111 and the text vector 13;
[0054] Step S208) adjusting the parameters of the first neural network model 321 until the training stop condition is reached;
[0055] Step S210 ) Obtain a feature extraction model 32 of the text file 111 based on the first neural network model 321 .
[0056] In the process of vectorizing the sample text file, this embodiment provides a solution for calculating word weights, including the steps of:
[0057] Calculate the number of times the words in the vocabulary appear in the sample text file to be vectorized, and record it as the word count;
[0058] Calculate the quotient of the number of words and the number of words contained in the sample text file, and record it as the word frequency;
[0059] receiving a plurality of sample text files as reference documents, counting the number of reference documents containing the word, calculating the quotient of the number of reference documents and the number of reference documents containing the word, and calculating the natural logarithm of the quotient as the inverse document word frequency;
[0060] The product of word frequency and inverse document word frequency is used as the word weight.
[0061] Interval words such as "of, is, can, one, when, time" do not have any pointing characteristics and should be excluded from the thesaurus. When a word appears frequently not only in the current sample text file but also in other sample text files, it indicates that the word has no pointing property and its weight should be reduced, which can be achieved through inverse document frequency. The product of word frequency and inverse document frequency as the weight of the word has a high characteristic representation effect. In this embodiment, the dimension of the vector after vectorizing the sample text file corresponds to the number of words in the thesaurus. The elements in the vector represent the weights of the words in the corresponding order in the thesaurus in the sample text file. For example, if the vector after vectorizing the sample text file is [0.716, 0.107, 0.307, 0.199, 0.530,...], it means that the weight of the word in the first order in the thesaurus in the sample text file is 0.716, and the weight of the word in the second order in the thesaurus in the sample text file is 0.107, and so on.
[0062] On the other hand, in another embodiment, a pre-trained language processing model is used to complete the vectorization of the sample text file. This pre-trained language processing model can complete the task of text vectorization, that is, represent text (including words, sentences, paragraphs) as a vector matrix. This pre-trained language processing model is also known as a text vector representation model in the public technology. For example, Word2Vec, SBERT (Sentence-BERT), CoSENT (Cosine Sentence), BGE (BAAI general embedding) can all be used to complete the task of vectorizing the sample text file required by the solution disclosed in this specification.
[0063] Please refer to the appendix Figure 5 In this embodiment, the text feature 1111 of the sample text file is represented in vector form, and the text feature 1111 is obtained from the response of the first neural network model to the sample text file. Calculate the vector distance between the text feature 1111 and the text vector 13. Exemplarily, the Euclidean distance, Mahalanobis distance, cosine distance, etc. between vectors can be used. Use the vector distance directly as the value of the loss function, or after the operation of an increasing function, as the value of the loss function. Use this loss function to guide the training of the first neural network model 321. Text vectorization can map text to a high-dimensional space and realize the expression of text content features. At the same time, after text vectorization, it can exactly reflect the situation of the same text repetition that will affect the selection of text compression algorithms. This embodiment uses the result of text vectorization as the label of the sample text file, avoiding the cumbersome manual labeling of labels. At the same time, it also realizes a good representation of the text feature 1111.
[0064] This embodiment does not directly use the vectorization result of the text file 111 as the text feature 1111 of the text file 111, but establishes a first neural network model 321 to generate text features 1111. This is because vectorization requires a more comprehensive vocabulary, which will result in the final text feature 1111 being too high in dimension. And using a neural network model will have better generalization performance. When using the first neural network model 321, its output length is fixed. Assuming that the first neural network model 321 is trained on set A, the first neural network has a better representation capability for the text files 111 on set A. For the text files 111 on set B, after extraction using the first neural network model 321, the extraction result representation accuracy of the text features 1111 is slightly worse than that of the text files 111 on set A. However, it is still sufficient for the subsequent algorithm selection model 33 to select the compression algorithm. Its essence is that after the file text1 on set B is input into the first neural network model 321, the response of the first neural network model 321 will be closest to the file text2 in set A, which is the most similar to the file text1. It is sufficient to characterize the repetition of the same text in the file text1.
[0065] On the other hand, in another embodiment, when the file type of the to-be-compressed file is a text file, before inputting the to-be-compressed file into a pre-established feature extraction model corresponding to the file type to obtain file features, the following steps are performed:
[0066] Loading a pre-established file segmentation model, and splitting the file to be compressed into one or more sub-files based on a response of the file segmentation model to the file to be compressed;
[0067] Each sub-file is regarded as a file to be compressed and the subsequent steps are performed.
[0068] In this embodiment, the method for pre-establishing a file segmentation model comprises the following steps:
[0069] Load multiple sample text files, vectorize each sample text file respectively, and obtain sample vectors;
[0070] Cluster multiple sample vectors to obtain several vector classes;
[0071] Each sample text file is truncated into a plurality of segments of preset lengths as sub-files of the sample text file, and the sub-files are vectorized to obtain sub-vectors;
[0072] Calculate the vector distance between each sub-vector and other sub-vectors in the vector class, and select the sub-vectors based on all the vector distances to obtain a plurality of target sub-vectors;
[0073] Establishing a comparison module that cuts the file to be compressed into several segments of preset lengths and calculates the vector distance with each target sub-vector respectively;
[0074] Establishing a segmentation module for generating segmentation results of the file to be compressed based on the response of the comparison module;
[0075] A file segmentation model is established based on the comparison module and the segmentation module.
[0076] Vector clustering can be implemented by using the disclosed technology in the art, for example, using the disclosed text vector model that can simultaneously complete clustering or using the k-nearest neighbor algorithm. After clustering, text files with similar content characteristics are classified into one category. The vector distance between each sub-vector and other sub-vectors in the vector class is calculated, and the sub-vectors with sufficiently small distances to other sub-vectors are selected.
[0077] Specifically include:
[0078] The vector distance between each sub-vector and other sub-vectors in the vector class is calculated to obtain the minimum value of the distance. When the minimum value is less than the preset threshold, the sub-vector will be used as the target sub-vector.
[0079] Alternatively, the average value of the vector distances between each sub-vector and other sub-vectors in the vector class is calculated, and when the average value is less than a preset threshold, the sub-vector will be used as the target sub-vector.
[0080] Alternatively, the average of the vector distances between each sub-vector and other sub-vectors in the vector class is calculated, all sub-vectors are arranged in ascending order according to the average value, and the sub-vectors that are ranked in the top predetermined number or the top percentage are taken as the target sub-vectors.
[0081] When a sample text file is truncated into segments of a preset length, the preset length is obtained through testing. The specific process is as follows:
[0082] Within the set length interval, several segment lengths are set according to the predetermined step length;
[0083] The sample text file is truncated using each segment length as a preset length in turn;
[0084] The number of target sub-vectors finally obtained is used as a label to associate with the corresponding segment length;
[0085] The segment length with the largest number of target sub-vectors finally obtained is used as the final preset length.
[0086] The comparison module truncates the file to be compressed into several segments of preset lengths, and respectively calculates the vector distances with each target sub-vector. The segmentation module generates a segmentation module of the segmentation result of the file to be compressed based on the response of the comparison module. Specifically, the segmentation module obtains the vector distances between the segment of the file to be compressed obtained by the comparison module and each target sub-vector, and then obtains the minimum value of the vector distances between the segment of the file to be compressed and each target sub-vector. If the minimum value is less than a preset threshold, the segment is determined to be marked as a segment recommended as a sub-file.
[0087] By traversing all the segments of the file to be compressed, the segmentation module will obtain all the segments marked as recommended as sub-files. If all the segments marked as recommended as sub-files account for more than a preset percentage of all the segments (for example, more than 40%, more than 50%, more than 60%), the response of the file segmentation model is an instruction to segment the file to be compressed, and the segment length is the aforementioned preset length.
[0088] On the other hand, in another embodiment, the file types recorded in the classification table include audio files 112. Figure 6 , when the feature extraction model 32 is pre-established for the audio file 112, the following steps are performed:
[0089] Step S302) establishing a second neural network model 322, wherein the response of the second neural network model 322 to the audio file 112 is used as the audio feature 1121;
[0090] Step S304) receiving a sample audio file 112, and obtaining a recognition text 14 of the sample audio file 112 based on an audio recognition model;
[0091] Step S306) inputting the recognized text 14 into the first neural network model 321, and determining the value of the loss function based on the audio feature 1121 and the response of the first neural network model 321;
[0092] Step S308) adjusting the parameters of the second neural network model 322 until the training stop condition is reached;
[0093] Step S310 ) Obtain a feature extraction model 32 of the audio file 112 based on the second neural network model 322 .
[0094] In this embodiment, the audio recognition model is used to recognize the text in the audio, that is, the recognized text 14. The recognized text 14 is input into the first neural network model 321 to obtain the text features 1111 of the recognized text 14. Figure 7, establish a second neural network model 322, and the output of the second neural network model 322 is used as the audio feature 1121. Use the text feature 1111 to supervise the training of the second neural network model 322. The annotation of the audio sample can be directly realized with the help of the first neural network model 321. Manual annotation is avoided, and the annotation efficiency and accuracy of the audio sample are high. The audio recognition model adopts an end-to-end model based on deep learning. This model uses convolutional neural networks (CNN) or recurrent neural networks (RNN) to directly extract features from the original audio signal, and finally generates text by connecting the fully connected layer. For example, a model based on CTC (Connectionist Temporal Classification), a Listen, Attend and Spell (LAS) model, etc. A Transformer model can also be used. The Transformer model is a model based on the self-attention mechanism, which was originally used for natural language processing tasks such as machine translation and speech recognition. The Transformer model is also widely used in audio recognition. It achieves audio-to-text conversion by dividing the audio signal into time steps and using the self-attention mechanism to model each time step. Figure 8 , is the text in the audio after the audio recognition model is used for recognition. In this embodiment, the audio text includes both the text corresponding to the recognized voice and the annotated text of the recognized sound features. Figure 8 The three words "the phone is ringing" in the text also fall within the scope of recognized text 14.
[0095] On the other hand, in another embodiment, the file types recorded in the classification table include video files. Fig. 9 , when pre-establishing a feature extraction model 32 for a video file, the following steps are performed:
[0096] Step S402) splitting the video file into an audio track 114 and an image track 113, and using the response of the second neural network model 322 to the audio track 114 as an audio track feature 1141;
[0097] Step S404) establishing a third neural network model 323, wherein the response of the third neural network model 323 to the image track 113 is used as an image flow feature 1131;
[0098] Step S406) receiving a sample image track 113 file, and obtaining a recognition text 14 of the sample image track 113 file based on a video recognition model;
[0099] Step S408) inputting the recognized text 14 into the first neural network model 321, and determining the value of the loss function based on the image flow feature 1131 and the response of the first neural network model 321;
[0100] Step S410) adjusting the parameters of the third neural network model 323 until the training stop condition is reached;
[0101] Step S412) Based on the third neural network model 323, the image stream feature 1131 of the video file is obtained, and based on the second neural network model 322 and the third neural network model 323, the feature extraction model 32 of the video file is obtained.
[0102] The video file involves an audio track 114 and an image track 113. The response of the second neural network model 322 to the audio track 114 is used as the audio track feature 1141. Then a third neural network model 323 is established, and the response of the third neural network model 323 to the image track 113 is used as the image stream feature 1131. Based on the video recognition model, the recognition text 14 of the sample image track 113 file is obtained, and then the response of the first neural network model 321 to the recognition text 14 is obtained, and then the value of the loss function is determined. Please refer to the attached Fig.10 After the training of the third neural network model 323 is completed, the image stream feature 1131 of the image track 113 in the video file is obtained based on the third neural network model 323. Combining the image stream feature 1131 and the audio feature 1121, the video feature 1151 is obtained, that is, the feature extraction model 32 of the video file is obtained.
[0103] For feature extraction of image files, an image feature extraction model 32 disclosed in the art can be used. For example, a convolutional neural network (CNN) learns local and global features in an image through a series of convolution, pooling and fully connected layers. Common CNN models include LeNet, AlexNet, VGGNet, GoogLeNet, ResNet, etc. Feature Pyramid Networks (FPN) is a model for multi-scale image feature extraction. It extracts features of different scales by combining multiple branch networks from top to bottom and bottom to top. FPN can help the model better understand features at different levels in an image. Region-based Convolutional Neural Networks (R-CNN) is a model for target detection and image segmentation. It first generates candidate regions, then extracts features from each candidate region and classifies or segments them. Common R-CNN models include R-CNN, Fast R-CNN, Faster R-CNN, Mask R-CNN, etc. Autoencoder is an unsupervised learning model used to learn low-dimensional representations of data. It compresses the input data into a low-dimensional space and then decodes it back to the original input. Autoencoders can be used for image feature extraction, where the encoder part learns meaningful feature representations of the image. Pre-trained models are models that are pre-trained using large-scale image datasets and are often used for transfer learning. These models can convert image data into high-level semantic feature representations, such as models pre-trained using the ImageNet dataset, such as VGGNet, ResNet, Inception, etc.
[0104] On the other hand, in another embodiment, please refer to the attached Fig.11 , the method for selecting a model 33 for each file type training algorithm comprises the steps of:
[0105] Step S502) receiving a sample file of each file type, and compressing the sample file using each compression algorithm of the corresponding file type recorded in the classification table;
[0106] Step S504) Select the compression algorithm with the highest compression rate as the label of the corresponding sample file;
[0107] Step S506) Use the labeled sample files to train the algorithm selection model 33 until the training stop condition is reached.
[0108] By automatically comparing the compression rates of compression algorithms and obtaining a trained supervision signal, the algorithm selection model 33 for each file type can be completed. The input of the algorithm selection model 33 in this embodiment is the output of the feature extraction model 32. One of the technical contributions of the technical solution disclosed in this specification is that it can automatically complete the feature extraction process of text files 111, image files, audio files 112, and video files, that is, automatically complete the establishment and training of the feature extraction model 32 for each file type. Combining the feature extraction model 32 with the algorithm selection model 33, the compression algorithm obtained can not only adapt to different types of files, but also consider the selection of the compression algorithm according to the specific file content.
[0109] In the second aspect, the embodiment of this specification provides a file attribute-based adaptive compression system, see the attached Fig.12 ,include:
[0110] A recording component 21, used to establish a classification table of file types, wherein the classification table records a plurality of file types and at least one corresponding compression algorithm;
[0111] A feature component 31, used to pre-establish a feature extraction model 32 and an algorithm selection model 33 for each file type;
[0112] The compression component 41 is used to input the response of the feature extraction model 32 to the file to be compressed 11 into the algorithm selection model 33, and based on the response of the algorithm selection model 33, select a corresponding compression algorithm to compress the file to be compressed 11 and associate a compression algorithm identifier 121.
[0113] On the other hand, in another embodiment, please refer to the attached Fig.13 The feature component 31 includes a text model subcomponent 311, an audio model subcomponent 312 and a video model subcomponent 314. The text model subcomponent 311 is used to pre-establish a feature extraction model 32 for a text file 111 type, the audio model subcomponent 312 is used to pre-establish a feature extraction model 32 for an audio file 112 type, and the video model subcomponent 314 is used to pre-establish a feature extraction model 32 for a video file type. The feature component 31 also includes an algorithm selection subcomponent 313, the algorithm selection subcomponent 313 is used to establish a training algorithm selection model 33 for each file type, and receive a sample file of each file type, respectively compress the sample file using each compression algorithm of the corresponding file type recorded in the classification table, select the compression algorithm with the highest compression rate as the label of the corresponding sample file, and use the labeled sample file to train the algorithm selection model 33 until the training stop condition is reached.
[0114] See also Fig.14A schematic diagram of the structure of an electronic device 50 provided in an embodiment of this specification is shown.
[0115] like Fig.14 As shown, the electronic device 50 may include: at least one processor 51, at least one network interface 54, a user interface 53, a memory 55 and at least one communication bus 52. Among them, the communication bus 52 can be used to realize the connection and communication of the above-mentioned components. Among them, the user interface 53 may include a button, and the optional user interface 53 may also include a standard wired interface and a wireless interface. Among them, the network interface 54 may include but is not limited to a Bluetooth module, an NFC module, a Wi-Fi module, etc. Among them, the processor 51 may include one or more processing cores. The processor 51 uses various interfaces and lines to connect the various parts of the entire processor 51, and executes various functions and processes data of the electronic device 50 by running or executing instructions, programs, code sets or instruction sets stored in the memory 55, and calling data stored in the memory 55. Optionally, the processor 51 can be implemented in at least one hardware form of DSP, FPGA, PLA. The processor 51 can integrate one or a combination of CPU, GPU and modem, etc. Among them, the CPU mainly processes the operating system, user interface and application program, etc.; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communication.
[0116] It is understandable that the above-mentioned modem may not be integrated into the processor 51, but may be implemented by a separate chip.
[0117] The memory 55 may include RAM or ROM. Optionally, the memory 55 includes a non-transitory computer-readable medium. The memory 55 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 55 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 55 may also be at least one storage device located away from the aforementioned processor 51. The memory 55 as a computer storage medium may include an operating system, a network communication module, a user interface 53 module and an application. The processor 51 may be used to call the application stored in the memory 55 and execute the method in one or more of the above-mentioned embodiments.
[0118] The embodiments of this specification also provide a computer-readable storage medium, which stores instructions, and when the instructions are executed on the computer or processor 51, the computer or processor 51 executes one or more steps in the above embodiments. If the components of the electronic device 50 are implemented in the form of software functional units and sold or used as independent products, they can be stored in the computer-readable storage medium.
[0119] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of this specification is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (Digital Subscriber Line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital versatile disc (DVD)), or a semiconductor medium (eg, a solid state drive (SSD)).
[0120] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
[0121] In the absence of conflict, the technical features in this embodiment and implementation scheme can be combined arbitrarily.
[0122] The embodiments described above are merely preferred embodiments of this specification and are not intended to limit the scope of this specification. Without departing from the design spirit of this specification, various modifications and improvements made to the technical solutions of this specification by ordinary technicians in this field should fall within the scope of protection determined by the claims of this specification.
Claims
1. The adaptive compression method based on file attributes is characterized in that: Includes steps: Loading a pre-configured classification table, wherein the classification table records a plurality of file types and at least one corresponding compression algorithm; Inputting the file to be compressed into a pre-established feature extraction model corresponding to the file type to obtain file features; Based on the response of the pre-established algorithm selection model corresponding to the file type to the file feature, select a corresponding compression algorithm to compress the to-be-compressed file, and associate a compression algorithm identifier; The file types recorded in the classification table include text files. When a feature extraction model is pre-established for a text file, the following steps are performed: Establishing a first neural network model, wherein the response of the first neural network model to the text file is used as a text feature; Receiving a sample text file, and vectorizing the sample text file to obtain a text vector; Representing the text features of the sample text file in a vector form, and determining the value of a loss function based on the vector distance between the text features and the text vector; Adjusting the parameters of the first neural network model until a training stop condition is reached; Obtaining a feature extraction model for the text file based on the first neural network model; The file types recorded in the classification table include audio files. When a feature extraction model is pre-established for the audio files, the following steps are performed: Establishing a second neural network model, wherein the response of the second neural network model to the audio file is used as an audio feature; Receiving a sample audio file, and obtaining a recognition text of the sample audio file based on an audio recognition model; Inputting the recognized text into the first neural network model, and determining a value of a loss function based on the audio features and a response of the first neural network model; Adjusting the parameters of the second neural network model until a training stop condition is reached; Obtaining a feature extraction model of the audio file based on the second neural network model; The file types recorded in the classification table include video files. When a feature extraction model is pre-established for the video files, the following steps are performed: Splitting the video file into an audio track and an image track, and using the response of the second neural network model to the audio track as an audio track feature; Establishing a third neural network model, wherein the response of the third neural network model to the image track is used as an image flow feature; receiving a sample image track file, and obtaining a recognition text of the sample image track file based on a video recognition model; Inputting the recognized text into the first neural network model, and determining a value of a loss function based on the image stream features and a response of the first neural network model; Adjusting the parameters of the third neural network model until a training stop condition is reached; An image stream feature of a video file is obtained based on the third neural network model, and a feature extraction model of the video file is obtained based on the second neural network model and the third neural network model.
2. The file attribute-based adaptive compression method according to claim 1, characterized in that: When the file type of the to-be-compressed file is a text file, before the to-be-compressed file is input into a pre-established feature extraction model corresponding to the file type to obtain file features, the following steps are performed: Loading a pre-established file segmentation model, and splitting the file to be compressed into one or more sub-files based on a response of the file segmentation model to the file to be compressed; Each sub-file is regarded as a file to be compressed and the subsequent steps are performed.
3. The file attribute-based adaptive compression method according to claim 2, characterized in that: The method for pre-establishing a file segmentation model comprises the steps of: Load multiple sample text files, vectorize each sample text file respectively, and obtain sample vectors; Cluster multiple sample vectors to obtain several vector classes; Each sample text file is truncated into a plurality of segments of preset lengths as sub-files of the sample text file, and the sub-files are vectorized to obtain sub-vectors; Calculate the vector distance between each sub-vector and other sub-vectors in the vector class, and select the sub-vectors based on all the vector distances to obtain a plurality of target sub-vectors; Establishing a comparison module that cuts the file to be compressed into several segments of preset lengths and calculates the vector distance with each target sub-vector respectively; Establishing a segmentation module for generating segmentation results of the file to be compressed based on the response of the comparison module; A file segmentation model is established based on the comparison module and the segmentation module.
4. A file attribute-based adaptive compression system, using the adaptive compression method according to any one of claims 1 to 3, characterized in that: include: A recording component, used for loading a pre-configured classification table, wherein the classification table records a plurality of file types and at least one corresponding compression algorithm; A feature component, used for inputting the file to be compressed into a pre-established feature extraction model corresponding to the file type to obtain file features; The compression component is used to select a corresponding compression algorithm to compress the to-be-compressed file based on the response of a pre-established algorithm selection model corresponding to the file type to the file feature, and associate a compression algorithm identifier.
5. The file attribute-based adaptive compression system according to claim 4, characterized in that: The feature component includes a text model subcomponent, an audio model subcomponent and a video model subcomponent, wherein the text model subcomponent is used to pre-establish a feature extraction model for a text file type, the audio model subcomponent is used to pre-establish a feature extraction model for an audio file type, and the video model subcomponent is used to pre-establish a feature extraction model for a video file type; The feature component also includes an algorithm selection subcomponent, which is used to pre-establish an algorithm selection model for each file type, receive sample files of each file type, compress the sample files using each compression algorithm of the corresponding file type recorded in the classification table, select the compression algorithm with the highest compression rate as the label of the corresponding sample file, and use the labeled sample files to train the algorithm selection model until the training stop condition is reached.
6. An electronic device, characterized in that including a processor and a memory; The processor is connected to the memory; The memory is used to store executable program code; The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the file attribute-based adaptive compression method according to any one of claims 1 to 3.
7. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the file attribute-based adaptive compression method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Self-supervised conversation text abstracting method and system
CN111639175A
Multi-modal data feature extraction and association method for public opinion analysis
CN112417097A
File processing method and device, storage medium and electronic equipment
CN115098456A
Computer resource management system and method based on big data
CN115952140A
Design simulation software data adaptive compression method
CN116318172A
