Object recognition method and device, electronic equipment and storage medium
By using the combination technology of cache space and search tree in the object recognition method, preprocessing words are searched to determine the object recognition results, solving the problem of low recognition accuracy in traditional methods, and achieving more efficient and accurate object recognition.
Patent Information
- Application Number
- CN202411775548.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-04-25
AI Technical Summary
In the traditional method of taking pictures and recognizing images, the output object recognition words are relatively random, resulting in a low accuracy of the recognition results.
The first search process is performed in the preset cache space by preprocessing words, and if there is a target word, the recognition result is directly determined; if there is no, the second search process is performed based on the search tree, the second target word is determined and the cache space is updated, and the recognition result is finally determined.
It improves the recognition accuracy of object recognition while maintaining an efficient recognition process.
Smart Images

Figure CN119888733A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image recognition, and in particular to an object recognition method, device, electronic equipment and storage medium. Background Art
[0002] With the advancement of image recognition technology, the use of functions such as photo recognition in life is also increasing. However, the object recognition words output in traditional photo recognition are often directly output by the image recognition model without any processing, resulting in a large randomness of object recognition words, which in turn leads to a low recognition accuracy. Therefore, how to provide an object recognition method that can improve recognition accuracy has become an urgent problem to be solved. Summary of the invention
[0003] The embodiment of the present invention provides an object recognition method, which aims to solve the problem of low recognition accuracy of existing object recognition methods. By performing a first search process on a pre-processed word in a preset cache space, it is possible to quickly determine whether a first target word exists in the cache space. If the first target word exists, the final recognition result of the image to be recognized can be directly determined based on the first target word in the cache space to improve the object recognition efficiency. If the first target word does not exist in the cache space, a second search process can be performed based on a search tree to determine the second target word to determine the final recognition result of the image to be recognized. The combined use of the cache space and the search tree can further improve the recognition accuracy of object recognition while ensuring the efficiency of object recognition.
[0004] In a first aspect, an embodiment of the present invention provides an object recognition method, the method comprising the following steps:
[0005] Get the object recognition word corresponding to the image to be recognized;
[0006] Performing preprocessing based on the object recognition word to obtain a preprocessing word corresponding to the object recognition word;
[0007] Performing a first search process in a preset cache space based on the preprocessed word to determine whether a first target word corresponding to the object recognition word exists in the preset cache space;
[0008] If the first target word exists in the preset cache space, determining a final recognition result of the image to be recognized based on the first target word;
[0009] If the first target word does not exist in the preset cache space, a second search process is performed based on the preprocessing word and a preset search tree to obtain a search word corresponding to the preprocessing word;
[0010] Based on the search term, determining a second target word corresponding to the object recognition word, and updating the preset cache space based on the second target word;
[0011] Based on the second target word, a final recognition result of the image to be recognized is determined.
[0012] Optionally, the preprocessing based on the object recognition word to obtain a preprocessed word corresponding to the object recognition word includes:
[0013] Performing text preprocessing based on the object recognition word to obtain a first preprocessing word;
[0014] Performing pinyin conversion processing based on the first preprocessed word to obtain a second preprocessed word;
[0015] Performing word form conversion processing based on the first preprocessed word to obtain a third preprocessed word;
[0016] At least one of the first preprocessing word, the second preprocessing word and the third preprocessing word is used as the preprocessing word.
[0017] Optionally, performing a first search process in a preset cache space based on the preprocessed word to determine whether a first target word corresponding to the object recognition word exists in the preset cache space includes:
[0018] Performing synonym search processing in a preset word library based on the preprocessed words, and determining whether there are synonyms of the text to be classified in the word library;
[0019] If the synonym exists, a search process is performed in a preset cache space based on the synonym to determine whether the first target word exists in the preset cache space.
[0020] Optionally, the preprocessed word includes at least one of a first preprocessed word, a second preprocessed word, and a third preprocessed word, the preset search tree includes a Chinese search tree and a Pinyin search tree, and the second search process is performed based on the preprocessed word and the preset search tree to obtain the search word corresponding to the preprocessed word, including:
[0021] Based on the first preprocessing word and the third preprocessing word, a first search word corresponding to the first preprocessing word and a third search word corresponding to the third preprocessing word are matched in the Chinese search tree;
[0022] Matching a second search term corresponding to the second preprocessed term in the pinyin search tree based on the second preprocessed term;
[0023] At least one of the first search term, the third search term, and the second search term is used as the search term.
[0024] Optionally, determining the second target word corresponding to the object recognition word based on the search word includes:
[0025] Calculating the text similarity between the search term and each word vector in a preset word library;
[0026] Based on the text similarity and a preset text similarity threshold, determining a first target word vector in the preset word library;
[0027] In the first target word vector, the second target word is determined.
[0028] Optionally, the search term includes at least one of a first search term, a second search term and a third search term, the text similarity includes at least one of a first text similarity between the first search term and each of the word vectors, a second text similarity between the second search term and each of the word vectors, and a third text similarity between the third search term and each of the word vectors, and determining a first target word vector in the preset word library based on the text similarities and a preset text similarity threshold comprises:
[0029] Based on the preset text similarity threshold, determining a first word vector corresponding to a first target text similarity among all the first text similarities;
[0030] Based on the preset text similarity threshold, determining a second word vector corresponding to the second target text similarity among all the second text similarities;
[0031] Based on the preset text similarity threshold, determining a third word vector corresponding to a third target text similarity among all the first text similarities;
[0032] At least one of the first word vector, the second word vector, and the third word vector is determined as the first target word vector.
[0033] Optionally, determining the second target word in the first target word vector includes:
[0034] Determining a first score of the first word vector based on the first search term and a preset first coefficient;
[0035] Determining a second score of the second word vector based on the second search term and a preset second coefficient;
[0036] Determining a third score of the third word vector based on the third search term and a preset third coefficient;
[0037] Based on the first score, the second score, and the third score, the second target word is determined from among the first word vector, the second word vector, and the third word vector.
[0038] In a second aspect, an embodiment of the present invention further provides an object recognition device, the object recognition device comprising:
[0039] The first acquisition module is used to acquire the object recognition word corresponding to the image to be recognized;
[0040] A preprocessing module, used for performing preprocessing based on the object recognition word to obtain a preprocessing word corresponding to the object recognition word;
[0041] A first retrieval module, configured to perform a first retrieval process in a preset cache space based on the preprocessed word, and determine whether a first target word corresponding to the object recognition word exists in the preset cache space;
[0042] A first determination module, configured to determine a final recognition result of the image to be recognized based on the first target word if the first target word exists in the preset cache space;
[0043] A second search module, configured to perform a second search process based on the preprocessing word and a preset search tree to obtain a search word corresponding to the preprocessing word if the first target word does not exist in the preset cache space;
[0044] A second determination module, configured to determine a second target word corresponding to the object recognition word based on the search word, and update the preset cache space based on the second target word;
[0045] The third determination module is used to determine a final recognition result of the image to be recognized based on the second target word.
[0046] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the object recognition method provided in the embodiment of the present invention when executing the computer program.
[0047] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the object recognition method provided in the embodiment of the invention are implemented.
[0048] In an embodiment of the present invention, an object recognition word corresponding to a picture to be recognized is obtained; preprocessing is performed based on the object recognition word to obtain a preprocessing word corresponding to the object recognition word; a first retrieval process is performed in a preset cache space based on the preprocessing word to determine whether a first target word corresponding to the object recognition word exists in the preset cache space; if the first target word exists in the preset cache space, a final recognition result of the picture to be recognized is determined based on the first target word; if the first target word does not exist in the preset cache space, a second retrieval process is performed based on the preprocessing word and a preset retrieval tree to obtain a retrieval word corresponding to the preprocessing word; based on the retrieval word, a second target word corresponding to the object recognition word is determined, and the preset cache space is updated based on the second target word; based on the second target word, a final recognition result of the picture to be recognized is determined. By performing the first search process in the preset cache space with the preprocessed word, it is possible to quickly determine whether the first target word exists in the cache space. If the first target word exists, the final recognition result of the image to be recognized can be directly determined based on the first target word in the cache space to improve the object recognition efficiency. If the first target word does not exist in the cache space, a second search process can be performed based on the search tree to further determine the second target word to determine the final recognition result of the image to be recognized. The comprehensive use of the cache space and the search tree can further improve the recognition accuracy of object recognition while ensuring the efficiency of object recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0050] Figure 1 is a flow chart of an object recognition method provided by an embodiment of the present invention;
[0051] Figure 2 is a flow chart of a text preprocessing method provided by an embodiment of the present invention;
[0052] Figure 3 is a flowchart of a first retrieval processing method provided by an embodiment of the present invention;
[0053] Figure 4 is a flow chart of a second search processing method provided by an embodiment of the present invention;
[0054] Figure 5 is a flow chart of another object recognition method provided by an embodiment of the present invention;
[0055] Figure 6 is a schematic diagram of the structure of an object recognition device provided in an embodiment of the present invention;
[0056] Figure 7 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0058] like Figure 1 As shown, Figure 1 is a flow chart of an object recognition method provided by an embodiment of the present invention, including:
[0059] 101. Obtain the object recognition word corresponding to the image to be recognized.
[0060] In an embodiment of the present invention, the object recognition method can be applied to an object recognition platform, which can be constructed by a server or a server cluster, and the server or server cluster can be any electronic device with functions such as image recognition, text processing, text analysis, data transmission, and data storage. The object recognition platform can be deployed by an object recognition model, which can be constructed by any image recognition algorithm framework, and the image recognition algorithm can be a random forest, an R-CNN series algorithm, a YOLO series algorithm, a visual semantic large model, a multimodal large model, etc.
[0061] Specifically, when the user needs to use functions such as photo recognition, he can use a photography machine, smart camera, smart phone or other smart terminal to take pictures and process them to obtain the above-mentioned pictures to be recognized, and the above-mentioned pictures to be recognized are uploaded to the above-mentioned object recognition platform through the above-mentioned data transmission function. The above-mentioned object recognition platform can use the above-mentioned object recognition model to perform object recognition processing on the above-mentioned pictures to be recognized, and obtain the object recognition words corresponding to the above-mentioned pictures to be recognized. The above-mentioned object recognition platform implements the above-mentioned object recognition method based on the object recognition words corresponding to the above-mentioned pictures to be recognized, and determines the final recognition result of the above-mentioned pictures to be recognized.
[0062] 102. Perform preprocessing based on the object recognition word to obtain a preprocessing word corresponding to the object recognition word.
[0063] In an embodiment of the present invention, the above-mentioned object recognition word may exist in the form of Chinese data, and the above-mentioned preprocessing may include at least one of text normalization processing, pinyin conversion processing and word form conversion processing. The above-mentioned text normalization processing may be a unified text format, symbol, font and other processing, the above-mentioned pinyin conversion processing may be to convert the above-mentioned object recognition word from Chinese form to pinyin form, and the above-mentioned word form conversion processing may, for example, convert "runnig" into "run", "China" into "China" and other forms.
[0064] Specifically, a text preprocessing project can be constructed by any programming language, and the object recognition words can be provided to the text preprocessing project to implement the preprocessing and obtain the preprocessing words corresponding to the object recognition words. It can be understood that the text normalization processing, pinyin conversion processing, and word form conversion processing can be integrated into one text preprocessing project, or text preprocessing projects corresponding to each preprocessing can be constructed separately.
[0065] 103. Perform a first search process in a preset cache space based on the preprocessed word to determine whether a first target word corresponding to the object recognition word exists in the preset cache space.
[0066] In an embodiment of the present invention, the preset cache space may be a cache space based on LFU (least used elimination strategy), and words and basic information corresponding to the words may be stored in the cache space, and the basic information may include classification information.
[0067] Specifically, the preprocessed word may be used as a search target, and a word successfully matching the preprocessed word may be searched in the preset cache space as the first target word. If the word is not found, it can be determined that the first target word does not exist in the cache space.
[0068] 104. If the first target word exists in the preset cache space, a final recognition result of the image to be recognized is determined based on the first target word.
[0069] In an embodiment of the present invention, the above-mentioned first target word may include basic information (similarly, in the above-mentioned preset cache space, each word corresponds to a basic information). After determining the above-mentioned first target word, the basic information of the above-mentioned first target word can be applied to the above-mentioned picture to be recognized and the above-mentioned object recognition word to obtain the above-mentioned final recognition result.
[0070] For example, assuming that the word for identifying the above-mentioned image to be identified or the above-mentioned object is "Quiet Night Thoughts", and the above-mentioned first target word can also be "Quiet Night Thoughts", then the basic information corresponding to the above-mentioned first target word can be extracted, and the basic information can include the corresponding classification information "Ancient Poetry". At this time, according to the above-mentioned classification information, the final recognition result of the above-mentioned image to be identified can be determined as "images containing ancient poetry", and finally, according to the above-mentioned final recognition result, the above-mentioned image to be identified can be more accurately classified into general item themes.
[0071] 105. If the first target word does not exist in the preset cache space, a second search process is performed based on the preprocessing word and the preset search tree to obtain a search word corresponding to the preprocessing word.
[0072] In an embodiment of the present invention, the above-mentioned preset retrieval tree (or understood as a prefix tree) can be a data result for prefix matching and full word matching, wherein each node corresponds to a character, and the node path from the root to the leaf node can represent a string. If multiple characters have the same prefix, these strings will share the same partial path, wherein the root node (i.e., the starting point of the retrieval tree) is usually represented as an empty string, and its own store represents the subsequent possible path of a certain character, and some nodes will be marked with the end mark of a certain vocabulary.
[0073] Specifically, if the first target word does not exist in the cache space, it means that the final recognition result of the image to be recognized cannot be determined based on the first cache space. At this time, the preprocessing word can be used to perform a second search process in the search tree to obtain the search word corresponding to the preprocessing word, wherein the search word can be a word that is exactly the same as the preprocessing word (that is, the whole word matches successfully), or a partially identical word (or can be understood as a word with the same partial prefix, that is, prefix match).
[0074] 106. Determine a second target word corresponding to the object recognition word based on the search word, and update a preset cache space based on the second target word.
[0075] In the embodiment of the present invention, a search process may be performed in a preset word library based on the search word to determine the second target word, and the preset cache space may be updated based on the second target word.
[0076] Specifically, the above-mentioned preset vocabulary is similar to the above-mentioned cache space, and can also store vocabulary and basic information corresponding to the vocabulary, but the difference is that, due to the differences in storage media and data structures, the access speed of the above-mentioned vocabulary is slower than the access speed of the above-mentioned cache space, and the access delay of the above-mentioned vocabulary is also higher than the access delay of the above-mentioned cache space. The data volume of the vocabulary stored in the above-mentioned vocabulary is greater than the data volume of the vocabulary stored in the above-mentioned cache space.
[0077] Therefore, when the first target word cannot be found through the above-mentioned cache space, the above-mentioned search word can be used as the search target to find the second target word in the above-mentioned vocabulary, and the above-mentioned second target word can be updated to the above-mentioned cache space at the same time, so that the next time a picture similar to the above-mentioned picture to be identified appears, the first target word can be quickly found in the cache space without having to find the second target word in the vocabulary.
[0078] 107. Determine a final recognition result of the image to be recognized based on the second target word.
[0079] In the embodiment of the present invention, similarly, after obtaining the second target word, similarly to the first target word, the final recognition result of the image to be recognized can be determined based on the basic information of the second target word (of which the classification information is mainly used) and the classification information. And similarly, the image to be recognized and the object recognition word can be classified according to the final recognition result, that is, classified into the corresponding general theme classification.
[0080] It is understandable that, under normal circumstances, since the words stored in the cache space are updated by the words in the vocabulary, whether it is based on the first target word determined in the cache space or the second target word determined in the vocabulary, the final recognition results determined by the two are usually consistent, which can ensure the consistency of the recognition effect of object recognition and the recognition accuracy of object recognition. Then, when classifying the image to be recognized according to the final recognition result, the accuracy of identifying and matching multi-level general item theme classification can be improved. To improve the user experience. At the same time, due to the characteristics of the storage medium and data structure of the cache space, the first target word is determined in the cache space first, and only after the first target word cannot be determined, the second target word will be determined in the vocabulary, which can effectively improve the overall retrieval performance.
[0081] In an embodiment of the present invention, an object recognition word corresponding to a picture to be recognized is obtained; preprocessing is performed based on the object recognition word to obtain a preprocessing word corresponding to the object recognition word; a first retrieval process is performed in a preset cache space based on the preprocessing word to determine whether a first target word corresponding to the object recognition word exists in the preset cache space; if the first target word exists in the preset cache space, a final recognition result of the picture to be recognized is determined based on the first target word; if the first target word does not exist in the preset cache space, a second retrieval process is performed based on the preprocessing word and a preset retrieval tree to obtain a retrieval word corresponding to the preprocessing word; based on the retrieval word, a second target word corresponding to the object recognition word is determined, and the preset cache space is updated based on the second target word; based on the second target word, a final recognition result of the picture to be recognized is determined. By performing the first search process in the preset cache space with the preprocessed word, it is possible to quickly determine whether the first target word exists in the cache space. If the first target word exists, the final recognition result of the image to be recognized can be directly determined based on the first target word in the cache space to improve the object recognition efficiency. If the first target word does not exist in the cache space, a second search process can be performed based on the search tree to further determine the second target word to determine the final recognition result of the image to be recognized. The comprehensive use of the cache space and the search tree can further improve the recognition accuracy of object recognition while ensuring the efficiency of object recognition.
[0082] It is understandable that in the specific implementation of this application, related data such as pictures to be identified are involved. When the embodiments in this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data, as well as the construction, training and use of tools such as retrieval trees and cache spaces, need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0083] It should be noted that the object recognition method provided in the embodiment of the present invention can be applied to devices such as computers and servers that can perform object recognition.
[0084] Optionally, in the step of performing preprocessing based on the object recognition word to obtain a preprocessed word corresponding to the object recognition word, text preprocessing can also be performed based on the object recognition word to obtain a first preprocessed word; pinyin conversion processing can be performed based on the first preprocessed word to obtain a second preprocessed word; word form conversion processing can be performed based on the first preprocessed word to obtain a third preprocessed word; and at least one of the first preprocessed word, the second preprocessed word and the third preprocessed word can be used as a preprocessed word.
[0085] In an embodiment of the present invention, the above text preprocessing can be simply understood as normalizing it, which may include removing redundant spaces, removing meaningless symbols, and unifying the text form, etc.
[0086] Specifically, it is possible to remove spaces with more than one space in the object recognition word (i.e., redundant spaces), and remove redundant meaningless symbols in the object recognition word, such as special symbols like #_`, etc. At the same time, digital standardization processing is performed (i.e., unifying the text form). For example, dates, times, currencies, etc. are converted into standard formats.
[0087] The above pinyin conversion processing can be, for example, converting "中国" to "zhong guo" and the like. The above word form conversion processing can be converting "running" to "run", or converting "中国地" to "中国" and the like.
[0088] More specifically, the above preprocessing can be further illustrated by a flowchart of a text preprocessing method as shown in Figure 2 which:
[0089] In the first step, it can be to input the to-be-processed image obtained by the user taking a photo into the object recognition model for object recognition processing, and then the object recognition word can be obtained;
[0090] In the second step, it can be to perform text normalization processing (i.e., the above text preprocessing) on the object recognition word (or understood as the to-be-processed text), and then the text normalization result (i.e., the above first preprocessing word) can be obtained;
[0091] In the third step, perform pinyin conversion processing on the text normalization result to obtain the second preprocessing word;
[0092] In the fourth step, perform word form conversion processing on the text normalization result to obtain the third preprocessing word.
[0093] Optionally, in the step of performing the first retrieval processing in the preset cache space based on the preprocessing word to determine whether there is a first target word corresponding to the object recognition word in the preset cache space, it is also possible to perform a synonym retrieval processing on the preprocessing word in the preset thesaurus to determine whether there is a synonym of the to-be-classified text in the thesaurus; if there is a synonym, then perform a retrieval processing in the preset cache space based on the synonym to determine whether there is a first target word in the preset cache space.
[0094] In an embodiment of the present invention, the synonyms corresponding to the preprocessed words can be retrieved through the dictionary (Word2Vec). It should be noted that if the synonyms corresponding to the preprocessed words cannot be retrieved through the dictionary, the subsequent steps of the first search process can be directly terminated, that is, the first search process cannot determine the first target word, and the final recognition result cannot be determined based on the first target word. The second search process needs to be performed and the final recognition result is finally determined.
[0095] If the synonyms can be retrieved through the dictionary, a search process can be performed in the cache space according to the synonyms to determine the words that successfully match the synonyms as the first target words. If the words that successfully match the synonyms cannot be determined, it means that the subsequent steps of the first search process can be terminated directly, that is, the first search process cannot determine the first target word, and the final recognition result cannot be determined based on the first target word. The second search process needs to be performed to finally determine the final recognition result.
[0096] Specifically, the synonym search process and the search process can be performed as follows: Figure 3 The flowchart of a first search processing method shown further illustrates:
[0097] In the first step, the text normalization result (i.e., the first preprocessing word in the preprocessing words) and the word form restoration result (i.e., the third preprocessing word in the preprocessing words) are input into the Word2Vec dictionary for synonym search processing.
[0098] In the second step, if no result is found, no subsequent processing is performed and the second search process is directly performed;
[0099] The third step is, if a hit result is found, the hit result (i.e., synonym) is input into the LFU word cache (i.e., the above-mentioned preset cache space) for retrieval processing;
[0100] Step 4: If the corresponding first target word is retrieved, the above-mentioned final recognition result can be determined according to the first target word;
[0101] In the fifth step, if the corresponding first target word is not found, the word search can be repeated (ie, the second search process described above).
[0102] Optionally, in the step of performing a second retrieval process based on the preprocessed word and the preset retrieval tree to obtain the retrieval word corresponding to the preprocessed word, it is also possible to match the first retrieval word corresponding to the first preprocessed word and the third retrieval word corresponding to the third preprocessed word in the Chinese retrieval tree based on the first preprocessed word and the third preprocessed word; match the second retrieval word corresponding to the second preprocessed word in the pinyin retrieval tree based on the second preprocessed word; and use at least one of the first retrieval word, the third retrieval word, and the second retrieval word as the retrieval word.
[0103] In an embodiment of the present invention, the above-mentioned preprocessed word includes at least one of the first preprocessed word, the second preprocessed word, and the third preprocessed word, the above-mentioned preset retrieval tree includes a Chinese retrieval tree and a pinyin retrieval tree. In the above-mentioned Chinese retrieval tree, a node can correspond to a Chinese character, while in the above-mentioned pinyin retrieval tree, a node can correspond to a pinyin letter or can also correspond to a complete pinyin syllable.
[0104] Specifically, due to the characteristics of Chinese characters and pinyin, Chinese characters (i.e., the first preprocessed word and the third preprocessed word) can only be retrieved in the Chinese retrieval tree, while pinyin (i.e., the second preprocessed word) can only be retrieved in the pinyin retrieval tree.
[0105] It should be noted that if the first preprocessed word, the second preprocessed word, and the third preprocessed word all match the first retrieval word, the second retrieval word, and the third retrieval word in the above-mentioned Chinese retrieval tree and pinyin retrieval tree, then the first retrieval word, the second retrieval word, and the third retrieval word can be used as the above-mentioned retrieval words at the same time. The accuracy rate of the second target word determined by integrating the first retrieval word, the second retrieval word, and the third retrieval word is higher.
[0106] If only one or more of the above-mentioned first retrieval word, the second retrieval word, and the third retrieval word are matched, then one or more of the matched first retrieval word, the second retrieval word, and the third retrieval word can be used as the above-mentioned retrieval word.
[0107] More specifically, the use of the above-mentioned Chinese retrieval tree can be further illustrated by a flowchart of a second retrieval processing method as shown in Figure 4 the following:
[0108] Among them, assuming that the first preprocessed word or the third preprocessed word is "Thoughts in the Silent Night", then the characters "静", "夜", and "思" can be sequentially matched to the first-level child node "静", the second-level child node "夜", and the third-level child node "思" in the Chinese retrieval tree in order.
[0109] It should be noted that, for the matching process in either the above Chinese retrieval tree or the above pinyin retrieval tree, the matching strategy can be full-match (for example, all three characters of "Jing Ye Si" can find corresponding nodes in the retrieval tree) or fuzzy match (for example, only the nodes corresponding to the two characters "Jing Ye" of "Jing Ye Si" can be found in the retrieval tree). When full-match can be hit, full-match is adopted; if full-match cannot be hit, fuzzy match can be adopted.
[0110] Optionally, in the step of determining the second target word corresponding to the object recognition word based on the retrieval word, the text similarity between the retrieval word and each word vector in the preset word library can also be calculated; based on the text similarity and the preset text similarity threshold, the first target word vector is determined in the preset word library; and the second target word is determined from the first target word vectors.
[0111] In the embodiments of the present invention, the words stored in the above preset word library can all exist in the form of vector data, that is, word vectors. The above preset word library can be a vectorized retrieval library based on Word2Vec. Specifically, the above retrieval word can be directly provided to the word library, and the word library can convert the above retrieval word into a corresponding retrieval vector and calculate the text similarity between the retrieval vector and the word vector, that is, the text similarity between the above retrieval word and each word vector in the preset word library. The specific text similarity can be obtained by calculating the cosine similarity between the retrieval vector and the word vector through the above word library.
[0112] After calculating the text similarity, each text similarity (that is, the text similarity between the retrieval word and each word vector) can be compared with the above preset text similarity threshold (for example, it can be 0.6). The word vectors corresponding to the text similarities lower than the above text similarity threshold are directly discarded, and among the remaining word vectors, the first target word vector is determined, so as to determine the second target word from the first target word vectors.
[0113] Optionally, in the step of determining the first target word vector in the preset word library based on the text similarity and the preset text similarity threshold, the first word vector corresponding to the first target text similarity can also be determined from all the first text similarities based on the preset text similarity threshold; the second word vector corresponding to the second target text similarity can be determined from all the second text similarities based on the preset text similarity threshold; the third word vector corresponding to the third target text similarity can be determined from all the first text similarities based on the preset text similarity threshold; at least one of the first word vector, the second word vector, and the third word vector is determined as the first target word vector.
[0114] In an embodiment of the present invention, the above-mentioned search terms may include at least one of the above-mentioned first search terms, second search terms and third search terms, and the text similarity includes at least one of the first text similarity between the first search term and each word vector, the second text similarity between the second search term and each word vector, and the third text similarity between the third search term and each word vector.
[0115] Specifically, the first text similarity, the second text similarity and the third text similarity can be screened respectively by the above-mentioned preset text similarity threshold, and the first text similarity, the second text similarity and the third text similarity that are lower than the above-mentioned preset text similarity threshold are eliminated, and the retained text similarities are used as the corresponding first target text similarity, the second target text similarity and the third target text similarity, wherein the first target text similarity, the second target text similarity and the third target text similarity each correspond to a word vector in the vocabulary, namely the above-mentioned first word vector, the second word vector and the third word vector.
[0116] Specifically, during the screening process, if all first text similarities are lower than the above text similarity threshold, the above first target text similarity is empty, and its corresponding first word vector is also empty. Similarly, if all second text similarities are lower than the above text similarity threshold, the above second target text similarity is empty, and its corresponding second word vector is also empty. Similarly, if all third text similarities are lower than the above text similarity threshold, the above third target text similarity is empty, and its corresponding third word vector is also empty.
[0117] Assuming that the first word vector is empty, only the second word vector and the third word vector can be determined as the first target word vector. Similarly, if the second word vector or the third word vector is empty, the second word vector or the third word vector can also be not used as the first target word vector.
[0118] It should be noted that, by filtering through the above-mentioned text similarity threshold, word vectors with low text similarity can be quickly eliminated to obtain a first target word vector with a relatively smaller data volume, thereby improving the efficiency of determining the second target word based on the first target word vector.
[0119] Optionally, in the step of determining the second target word in the first target word vector, the first score of the first word vector can be determined based on the first search term and a preset first coefficient; the second score of the second word vector can be determined based on the second search term and a preset second coefficient; the third score of the third word vector can be determined based on the third search term and a preset third coefficient; and the second target word can be determined from the first word vector, the second word vector and the third word vector based on the first score, the second score and the third score.
[0120] In an embodiment of the present invention, the above-mentioned first coefficient, second coefficient, and third coefficient can be set according to historical object recognition experience or obtained through a limited number of trials. Specifically, the above-mentioned first coefficient, second coefficient, and third coefficient can be weight coefficients and need to satisfy the property of adding up to 1.
[0121] For example, assuming that the above-mentioned first coefficient is set to 0.5, the above-mentioned second coefficient can be set to 0.2, and the above-mentioned third coefficient can be set to 0.3.
[0122] Specifically, the number of characters in the first retrieval term that contain the object recognition term, the number of characters in the second retrieval term that contain the object recognition term, and the number of characters in the third retrieval term that contain the object recognition term can be calculated. (For example, if the retrieval term is "Jing Ye" and the object recognition term is "Jing Ye Si", then the number of characters is 2).
[0123] Furthermore, the number of characters in the first term can be multiplied by the above-mentioned first coefficient to obtain the above-mentioned first score, the number of characters in the second term can be multiplied by the above-mentioned second coefficient to obtain the above-mentioned second score, and the number of characters in the third term can be multiplied by the above-mentioned third coefficient to obtain the above-mentioned third score.
[0124] Among the first score, the second score, and the third score, the score with the largest value is determined as the target score, and the word vector corresponding to the target score (i.e., the first word vector, the second word vector, or the third word vector) is converted into a Chinese data form as the above-mentioned second target word. Or the word vector corresponding to the above-mentioned target score can also be directly used as the above-mentioned second target word in the form of a vector data.
[0125] As Figure 5 shown, it is a flowchart of another object recognition method provided by an embodiment of the present invention, which specifically may include the following steps:
[0126] The first step: Based on the text normalization result (i.e., the first preprocessed word) and the lemma result (i.e., the third preprocessed word), perform a first retrieval process in the LFU word cache (i.e., a preset cache space) to determine whether a hit occurs (i.e., whether the first target word is hit);
[0127] The second step, if the LFU cache is hit, directly return the result and output the final matching word (i.e., the final recognition result);
[0128] The third step, if not hit, use the first preprocessed word and the third preprocessed word as matching targets to match the first retrieval term and the third retrieval term in the Chinese retrieval tree, and use the second preprocessed word as the matching target to match the second retrieval term in the pinyin retrieval tree;
[0129] The fourth step is to use the first search term, the second search term and the third search term as search targets for search processing in the preset vocabulary (i.e., the Word2Vec vocabulary) to determine whether they are hit (i.e., whether the second target term is hit). If the second target term is hit, the final matching term (i.e., the final recognition result) is output.
[0130] like Figure 6 As shown, an embodiment of the present invention further provides an object recognition device, comprising:
[0131] The first acquisition module 601 is used to acquire the object recognition word corresponding to the image to be recognized;
[0132] A preprocessing module 602, configured to perform preprocessing based on the object recognition word to obtain a preprocessing word corresponding to the object recognition word;
[0133] A first search module 603 is used to perform a first search process in a preset cache space based on the pre-processed word to determine whether a first target word corresponding to the object recognition word exists in the preset cache space;
[0134] A first determination module 604 is configured to determine a final recognition result of the image to be recognized based on the first target word if the first target word exists in the preset cache space;
[0135] A second search module 605 is configured to perform a second search process based on the preprocessed word and a preset search tree to obtain a search word corresponding to the preprocessed word if the first target word does not exist in the preset cache space;
[0136] A second determination module 606, configured to determine a second target word corresponding to the object recognition word based on the search word, and update the preset cache space based on the second target word;
[0137] The third determination module 607 is used to determine a final recognition result of the image to be recognized based on the second target word.
[0138] Optionally, the preprocessing module 602 includes:
[0139] A first preprocessing submodule, configured to perform text preprocessing based on the object recognition word to obtain a first preprocessing word;
[0140] A second preprocessing submodule, configured to perform pinyin conversion processing based on the first preprocessing word to obtain a second preprocessing word;
[0141] A third preprocessing submodule, configured to perform word form conversion processing based on the first preprocessing word to obtain a third preprocessing word;
[0142] The first processing submodule is used to use at least one of the first preprocessing word, the second preprocessing word and the third preprocessing word as the preprocessing word.
[0143] Optionally, the first retrieval module 603 includes:
[0144] A first search submodule is used to perform synonym search processing in a preset word library based on the pre-processed word, and determine whether there are synonyms of the text to be classified in the word library;
[0145] The second search submodule is used for, if the synonym exists, performing a search process in a preset cache space based on the synonym, to determine whether the first target word exists in the preset cache space.
[0146] Optionally, the preprocessed word includes at least one of a first preprocessed word, a second preprocessed word and a third preprocessed word, the preset search tree includes a Chinese search tree and a Pinyin search tree, and the second search module 605 includes:
[0147] A first matching submodule, configured to match a first search term corresponding to the first preprocessing term and a third search term corresponding to the third preprocessing term in the Chinese search tree based on the first preprocessing term and the third preprocessing term;
[0148] A second matching submodule, used for matching a second search term corresponding to the second preprocessing term in the pinyin search tree based on the second preprocessing term;
[0149] The second processing submodule is used to use at least one of the first search term, the third search term and the second search term as the search term.
[0150] Optionally, the second determining module 606 includes:
[0151] A first calculation submodule is used to calculate the text similarity between the search term and each word vector in a preset word library;
[0152] A first determination submodule, configured to determine a first target word vector in the preset word library based on the text similarity and a preset text similarity threshold;
[0153] The second determination submodule is used to determine the second target word in the first target word vector.
[0154] Optionally, the search term includes at least one of a first search term, a second search term and a third search term, the text similarity includes at least one of a first text similarity between the first search term and each of the word vectors, a second text similarity between the second search term and each of the word vectors, and a third text similarity between the third search term and each of the word vectors, and the first determining submodule includes:
[0155] A first determining unit, configured to determine a first word vector corresponding to a first target text similarity among all the first text similarities based on the preset text similarity threshold;
[0156] A second determining unit, configured to determine a second word vector corresponding to a second target text similarity among all the second text similarities based on the preset text similarity threshold;
[0157] A third determining unit, configured to determine a third word vector corresponding to a third target text similarity among all the first text similarities based on the preset text similarity threshold;
[0158] The fourth determination unit is used to determine at least one of the first word vector, the second word vector and the third word vector as the first target word vector.
[0159] Optionally, the second determining submodule includes:
[0160] a fifth determining unit, configured to determine a first score of the first word vector based on the first search term and a preset first coefficient;
[0161] a sixth determining unit, configured to determine a second score of the second word vector based on the second search term and a preset second coefficient;
[0162] a seventh determining unit, configured to determine a third score of the third word vector based on the third search term and a preset third coefficient;
[0163] An eighth determination unit is used to determine the second target word from among the first word vector, the second word vector and the third word vector based on the first score, the second score and the third score.
[0164] like Figure 7 As shown, an embodiment of the present invention further provides an electronic device, characterized in that it includes a processor, and the processor can execute any one of the above-mentioned object recognition methods.
[0165] Specifically, it includes a processor 701 and a memory 702, and a computer program for executing the object recognition method stored in the memory 702 and capable of running on the processor 701, wherein:
[0166] The processor 701 runs the computer program of the object recognition method stored in the memory 702 to perform the following steps:
[0167] Get the object recognition word corresponding to the image to be recognized;
[0168] Performing preprocessing based on the object recognition word to obtain a preprocessing word corresponding to the object recognition word;
[0169] Performing a first search process in a preset cache space based on the preprocessed word to determine whether a first target word corresponding to the object recognition word exists in the preset cache space;
[0170] If the first target word exists in the preset cache space, determining a final recognition result of the image to be recognized based on the first target word;
[0171] If the first target word does not exist in the preset cache space, a second search process is performed based on the preprocessing word and a preset search tree to obtain a search word corresponding to the preprocessing word;
[0172] Based on the search term, determining a second target word corresponding to the object recognition word, and updating the preset cache space based on the second target word;
[0173] Based on the second target word, a final recognition result of the image to be recognized is determined.
[0174] Optionally, the preprocessing based on the object recognition word performed by the processor 701 to obtain a preprocessed word corresponding to the object recognition word includes:
[0175] Performing text preprocessing based on the object recognition word to obtain a first preprocessing word;
[0176] Performing pinyin conversion processing based on the first preprocessed word to obtain a second preprocessed word;
[0177] Performing word form conversion processing based on the first preprocessed word to obtain a third preprocessed word;
[0178] At least one of the first preprocessing word, the second preprocessing word and the third preprocessing word is used as the preprocessing word.
[0179] Optionally, the processor 701 performs a first search process in a preset cache space based on the preprocessed word to determine whether a first target word corresponding to the object recognition word exists in the preset cache space, including:
[0180] Performing synonym search processing in a preset word library based on the preprocessed words, and determining whether there are synonyms of the text to be classified in the word library;
[0181] If the synonym exists, a search process is performed in a preset cache space based on the synonym to determine whether the first target word exists in the preset cache space.
[0182] Optionally, the preprocessed word includes at least one of a first preprocessed word, a second preprocessed word, and a third preprocessed word, the preset search tree includes a Chinese search tree and a Pinyin search tree, and the processor 701 performs the second search processing based on the preprocessed word and the preset search tree to obtain the search word corresponding to the preprocessed word, including:
[0183] Based on the first preprocessing word and the third preprocessing word, a first search word corresponding to the first preprocessing word and a third search word corresponding to the third preprocessing word are matched in the Chinese search tree;
[0184] Matching a second search term corresponding to the second preprocessed term in the pinyin search tree based on the second preprocessed term;
[0185] At least one of the first search term, the third search term, and the second search term is used as the search term.
[0186] Optionally, the determining, based on the search term, a second target term corresponding to the object recognition term performed by the processor 701 includes:
[0187] Calculating the text similarity between the search term and each word vector in a preset word library;
[0188] Based on the text similarity and a preset text similarity threshold, determining a first target word vector in the preset word library;
[0189] In the first target word vector, the second target word is determined.
[0190] Optionally, the search term includes at least one of a first search term, a second search term and a third search term, the text similarity includes at least one of a first text similarity between the first search term and each of the word vectors, a second text similarity between the second search term and each of the word vectors, and a third text similarity between the third search term and each of the word vectors, and the processor 701 determines the first target word vector in the preset word library based on the text similarity and a preset text similarity threshold, including:
[0191] Based on the preset text similarity threshold, determining a first word vector corresponding to a first target text similarity among all the first text similarities;
[0192] Based on the preset text similarity threshold, determining a second word vector corresponding to the second target text similarity among all the second text similarities;
[0193] Based on the preset text similarity threshold, determining a third word vector corresponding to a third target text similarity among all the first text similarities;
[0194] At least one of the first word vector, the second word vector, and the third word vector is determined as the first target word vector.
[0195] Optionally, the determining, in the first target word vector, of the second target word performed by the processor 701 includes:
[0196] Determining a first score of the first word vector based on the first search term and a preset first coefficient;
[0197] Determining a second score of the second word vector based on the second search term and a preset second coefficient;
[0198] Determining a third score of the third word vector based on the third search term and a preset third coefficient;
[0199] Based on the first score, the second score, and the third score, the second target word is determined from among the first word vector, the second word vector, and the third word vector.
[0200] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the computer program implements the various processes of the object recognition method or the application-side object recognition method provided in the embodiment of the present invention, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0201] 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 above-mentioned computer program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the above-mentioned computer-readable storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0202] The above disclosure is only the preferred embodiment of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.
Claims
1. An object recognition method, characterized in that: The method comprises the following steps: Get the object recognition word corresponding to the image to be recognized; Performing preprocessing based on the object recognition word to obtain a preprocessing word corresponding to the object recognition word; Performing a first search process in a preset cache space based on the preprocessed word to determine whether a first target word corresponding to the object recognition word exists in the preset cache space; If the first target word exists in the preset cache space, determining a final recognition result of the image to be recognized based on the first target word; If the first target word does not exist in the preset cache space, a second search process is performed based on the preprocessing word and a preset search tree to obtain a search word corresponding to the preprocessing word; Based on the search term, determining a second target word corresponding to the object recognition word, and updating the preset cache space based on the second target word; Based on the second target word, a final recognition result of the image to be recognized is determined.
2. The object recognition method according to claim 1, characterized in that: The preprocessing based on the object recognition word to obtain a preprocessed word corresponding to the object recognition word includes: Performing text preprocessing based on the object recognition word to obtain a first preprocessing word; Performing pinyin conversion processing based on the first preprocessed word to obtain a second preprocessed word; Performing word form conversion processing based on the first preprocessed word to obtain a third preprocessed word; At least one of the first preprocessing word, the second preprocessing word and the third preprocessing word is used as the preprocessing word.
3. The object recognition method according to claim 1, characterized in that: The first retrieval process is performed in a preset cache space based on the preprocessed word to determine whether a first target word corresponding to the object recognition word exists in the preset cache space, including: Performing synonym search processing in a preset word library based on the preprocessed words, and determining whether there are synonyms of the text to be classified in the word library; If the synonym exists, a search process is performed in a preset cache space based on the synonym to determine whether the first target word exists in the preset cache space.
4. The object recognition method according to claim 1, characterized in that: The preprocessed word includes at least one of a first preprocessed word, a second preprocessed word, and a third preprocessed word, the preset search tree includes a Chinese search tree and a Pinyin search tree, and the second search process is performed based on the preprocessed word and the preset search tree to obtain the search word corresponding to the preprocessed word, including: Based on the first preprocessing word and the third preprocessing word, a first search word corresponding to the first preprocessing word and a third search word corresponding to the third preprocessing word are matched in the Chinese search tree; Matching a second search term corresponding to the second preprocessed term in the pinyin search tree based on the second preprocessed term; At least one of the first search term, the third search term, and the second search term is used as the search term.
5. The object recognition method according to claim 1, characterized in that: The determining, based on the search term, a second target term corresponding to the object recognition term includes: Calculating the text similarity between the search term and each word vector in a preset word library; Based on the text similarity and a preset text similarity threshold, determining a first target word vector in the preset word library; In the first target word vector, the second target word is determined.
6. The object recognition method according to claim 5, characterized in that: The search term includes at least one of a first search term, a second search term, and a third search term, the text similarity includes at least one of a first text similarity between the first search term and each of the word vectors, a second text similarity between the second search term and each of the word vectors, and a third text similarity between the third search term and each of the word vectors, and determining a first target word vector in the preset word library based on the text similarities and a preset text similarity threshold includes: Based on the preset text similarity threshold, determining a first word vector corresponding to a first target text similarity among all the first text similarities; Based on the preset text similarity threshold, determining a second word vector corresponding to the second target text similarity among all the second text similarities; Based on the preset text similarity threshold, determining a third word vector corresponding to a third target text similarity among all the first text similarities; At least one of the first word vector, the second word vector, and the third word vector is determined as the first target word vector.
7. The object recognition method according to claim 6, characterized in that: Determining the second target word in the first target word vector includes: Determining a first score of the first word vector based on the first search term and a preset first coefficient; Determining a second score of the second word vector based on the second search term and a preset second coefficient; Determining a third score of the third word vector based on the third search term and a preset third coefficient; Based on the first score, the second score, and the third score, the second target word is determined from among the first word vector, the second word vector, and the third word vector.
8. An object recognition device, characterized in that: The object recognition device comprises: The first acquisition module is used to acquire the object recognition word corresponding to the image to be recognized; A preprocessing module, used for performing preprocessing based on the object recognition word to obtain a preprocessing word corresponding to the object recognition word; A first retrieval module, configured to perform a first retrieval process in a preset cache space based on the preprocessed word, and determine whether a first target word corresponding to the object recognition word exists in the preset cache space; A first determination module, configured to determine a final recognition result of the image to be recognized based on the first target word if the first target word exists in the preset cache space; A second search module, configured to perform a second search process based on the preprocessing word and a preset search tree to obtain a search word corresponding to the preprocessing word if the first target word does not exist in the preset cache space; A second determination module, configured to determine a second target word corresponding to the object recognition word based on the search word, and update the preset cache space based on the second target word; The third determination module is used to determine a final recognition result of the image to be recognized based on the second target word.
9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the object recognition method according to any one of claims 1 to 7 when executing the computer program.
10. 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 steps in the object recognition method according to any one of claims 1 to 7 are implemented.