CN113743176A - Image recognition method, device and computer readable storage medium - Google Patents

Image recognition method, device and computer readable storage medium Download PDF

Info

Publication number
CN113743176A
CN113743176A CN202110130080.2A CN202110130080A CN113743176A CN 113743176 A CN113743176 A CN 113743176A CN 202110130080 A CN202110130080 A CN 202110130080A CN 113743176 A CN113743176 A CN 113743176A
Authority
CN
China
Prior art keywords
image
trained
feature vector
face
feature
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110130080.2A
Other languages
Chinese (zh)
Inventor
周彬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202110130080.2A priority Critical patent/CN113743176A/en
Publication of CN113743176A publication Critical patent/CN113743176A/en
Pending legal-status Critical Current

Links

Images

Abstract

The embodiment of the application discloses an image identification method, which comprises the following steps: acquiring a first image to be trained with a portrait; the first image to be trained comprises at least two images with the same portrait; processing a first image to be trained by adopting a face position detection model and a face recognition model to obtain a first feature vector of the first image to be trained; labeling the first feature vector, and constructing a feature vector library based on the first feature vector and the label; the label is used for uniquely identifying the first feature vector; acquiring a first image to be identified with a portrait; processing the first image to be recognized by adopting a face position detection model and a face recognition model to obtain a second feature vector of the first image to be recognized; and identifying the first image to be identified based on the feature vector library and the second feature vector to obtain portrait information in the first image to be identified. Embodiments of the application also disclose an image recognition device and a computer-readable storage medium.

Description

Image recognition method, device and computer readable storage medium
Technical Field
The present application relates to image recognition technology in the field of communications, and in particular, to an image recognition method, an apparatus, and a computer-readable storage medium.
Background
With the improvement of living standard, people have higher and higher requirements on material life, and online shopping gradually becomes an important mode for people to shop. However, the shopping experience of the user is greatly influenced by the ecological problem on the online shopping platform. An effective way to increase the confidence of a good is to have a star parlor and it has been proven that a significant number of viewers will actually purchase a product because of their favorite star parlor. Based on this, many commodities will add star elements when the commodities are publicized. Since star publicizing a certain product often requires a high introduction fee, some merchants can steal the use of star portraits for the introduction of the product because of the cost saving, which infringes the benefits of the star, causes damage to consumers if the consumers buy the product, and is very disadvantageous to the star image.
This poor shopping experience is a significant hurdle to online shopping platforms. To find out such violations, web shopping platforms tend to do little, in addition to enhancing the assent to merchants. But illegal merchants neglect the rules of the platform and exploit this vulnerability to make their own profit. In order to purify the environment of the online shopping platform, a method for screening illegal commodities by business personnel in a manual screening mode appears in the related art, but the manual screening mode has low efficiency and high labor cost.
Disclosure of Invention
In order to solve the above technical problems, embodiments of the present application desirably provide an image recognition method, an image recognition device, and a computer-readable storage medium, so as to solve the problem in the related art that a manual screening manner is adopted to screen which commodities use star portraits, reduce labor cost, and improve screening efficiency.
The technical scheme of the application is realized as follows:
an image recognition method, the method comprising:
acquiring a first image to be trained with a portrait; the first image to be trained comprises at least two images with the same portrait;
processing the first image to be trained by adopting a face position detection model and a face recognition model to obtain a first feature vector of the first image to be trained;
labeling the first feature vector, and constructing a feature vector library based on the first feature vector and the label; wherein the tag is used to uniquely identify the first feature vector;
acquiring a first image to be identified with a portrait;
processing the first image to be recognized by adopting the face position detection model and the face recognition model to obtain a second feature vector of the first image to be recognized;
and identifying the first image to be identified based on the feature vector library and the second feature vector to obtain portrait information in the image to be identified.
In the foregoing solution, the processing the first image to be trained by using the face position detection model and the face recognition model to obtain the first feature vector of the first image to be trained includes:
detecting the first image to be trained by adopting the face position detection model to obtain a detection result;
and when the first image to be trained is determined to have a face based on the detection result, carrying out face recognition on the first image to be trained by adopting the face recognition model to obtain a first feature vector of the first image to be trained.
In the foregoing solution, the detecting the first image to be trained by using the face position detection model to obtain a detection result includes:
and inputting the first image to be trained into the face position detection model in a preset format, and detecting the first image to be trained by adopting the face position detection model to obtain the detection result.
In the foregoing solution, when it is determined that the first image to be trained has a face based on the detection result, performing face recognition on the first image to be trained by using the face recognition model to obtain a first feature vector of the first image to be trained, includes:
when the first image to be trained is determined to have a face based on the detection result, acquiring position information of each feature point of the face in the first image to be trained based on the detection result;
if the position information of the feature points does not meet the preset condition, carrying out face alignment on the first image to be trained to obtain a corrected image to be trained;
and carrying out face recognition on the corrected image to be trained by adopting the face recognition model to obtain the characteristic vector of the first image to be trained.
In the foregoing scheme, the performing face recognition on the corrected image to be trained by using the face recognition model to obtain the feature vector of the first image to be trained includes:
inputting the corrected image to be trained into the face recognition model in a preset format, and training an initial face recognition model by using the corrected image to be trained to obtain the face recognition model;
and carrying out face recognition on the corrected image to be trained by adopting the face recognition model to obtain the first characteristic vector.
In the foregoing solution, the acquiring a first image to be recognized with a portrait includes:
acquiring a second image to be identified with a portrait;
performing character recognition on the second image to be recognized by adopting a character recognition algorithm to obtain key information of the second image to be recognized;
and screening the second image to be identified based on the key information to obtain the first image to be identified.
In the foregoing solution, the identifying the first image to be identified based on the feature vector library and the second feature vector to obtain portrait information in the image to be identified includes:
determining second feature information of the second feature vector and first feature information of each of the first feature vectors in the feature vector library;
determining, in the feature vector library, a similarity between each of the first feature vectors and the second feature vectors based on the first feature information and the second feature information;
screening the first feature vectors to obtain target feature vectors based on the similarity;
and acquiring portrait information in the first image to be recognized based on the label of the target feature vector.
In the foregoing solution, the screening the first feature vector to obtain a target feature vector based on the similarity includes:
sorting the first feature vectors in a descending order based on the similarity, and acquiring K feature vectors before sorting from the first feature vectors;
and acquiring the feature vectors with the similarity larger than a preset threshold value from the feature vectors of the K before sorting to obtain the target feature vectors.
In the above scheme, the method further comprises:
acquiring a second image to be trained with a portrait;
processing the second image to be trained by adopting the face position detection model and the face recognition model to obtain a third feature vector of the second image to be trained;
setting an initial K value and an initial threshold value;
and training the initial K value and the initial threshold value by adopting a neural network algorithm based on the third feature vector, the feature vector library, the accuracy and the recall rate to obtain the K value and the preset threshold value.
An image recognition apparatus, the apparatus comprising: a processor, a memory, and a communication bus;
the communication bus is used for realizing communication connection between the processor and the memory;
the processor is configured to execute an image recognition program stored in the memory to implement the steps of:
acquiring a first image to be trained with a portrait; the first image to be trained comprises at least two images with the same portrait;
processing the first image to be trained by adopting a face position detection model and a face recognition model to obtain a first feature vector of the first image to be trained;
labeling the first feature vector, and constructing a feature vector library based on the first feature vector and the label; wherein the tag is used to uniquely identify the first feature vector;
acquiring a first image to be identified with a portrait;
processing the first image to be recognized by adopting the face position detection model and the face recognition model to obtain a second feature vector of the first image to be recognized;
and identifying the first image to be identified based on the feature vector library and the second feature vector to obtain portrait information in the image to be identified.
A computer readable storage medium storing one or more programs, the one or more programs being executable by one or more processors to implement the steps of the image recognition method of any of the above.
Because a first image to be trained comprising at least two images with the same portrait can be obtained; processing a first image to be trained by adopting a face position detection model and a face recognition model to obtain a first feature vector of the first image to be trained; labeling the first feature vector, and constructing a feature vector library based on the first feature vector and the label; the face position detection model and the face recognition model are adopted to process a first image to be recognized with a portrait to obtain a second feature vector of the first image to be recognized, then the first image to be recognized is recognized based on the feature vector library and the second feature vector to obtain portrait information in the first image to be recognized, so that the portrait information in the first image to be recognized can be recognized based on the feature vector library constructed by processing the first image to be trained and the second feature vector obtained by processing the first image to be recognized, further the commodity using the star portrait can be determined, and the commodity using the star portrait is determined by adopting a manual screening method instead of adopting the manual screening method as in the related technology, so that the problem that the commodity using the star portrait is screened by adopting the manual screening method in the related technology is solved, the labor cost is reduced and the screening efficiency is improved.
Drawings
Fig. 1 is a schematic flowchart of an image recognition method according to an embodiment of the present application;
fig. 2 is a schematic flowchart of another image recognition method provided in an embodiment of the present application;
fig. 3a and fig. 3b are schematic diagrams illustrating comparison between before and after image alignment in an image recognition method according to an embodiment of the present application;
fig. 4 is a schematic flowchart of another image recognition method provided in an embodiment of the present application;
fig. 5 is a schematic diagram illustrating image recognition accuracy in an image recognition method according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an image recognition apparatus according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
An embodiment of the present application provides an image recognition method, which may be applied to an image recognition device, and as shown in fig. 1, the method includes the following steps:
step 101, obtaining a first image to be trained with a portrait.
The first image to be trained comprises at least two images with the same portrait.
In the embodiment of the application, the first image to be trained may be a plurality of images with face information acquired in advance, and the first image to be trained includes at least two pieces of same face information; that is to say, the first image to be trained may be a face image or a portrait image; in one possible implementation, the first image to be trained may be an image with face information of stars.
Step 102, processing the first image to be trained by adopting a face position detection model and a face recognition model to obtain a first feature vector of the first image to be trained.
In the embodiment of the application, a face position detection model can be adopted to determine whether the first image to be trained has face information; and then, when the first image to be trained is determined to have face information, a face recognition model is adopted to carry out face recognition on the first image to be trained to obtain a first feature vector. It should be noted that, the face position detection model is used for processing before the face recognition is performed on the first image to be trained, so that the recognition effectiveness can be ensured, and the situation that the feature vector library cannot be finally generated due to the fact that the first image to be trained does not have face information is avoided. The first feature vector may be a vector corresponding to a feature in each of the first images to be trained.
And 103, labeling the first feature vector, and constructing a feature vector library based on the first feature vector and the label.
Wherein the tag is used to uniquely identify the first feature vector.
In an embodiment of the present application, tagging the first feature vectors may refer to identifying each first feature vector; the feature vector library may be generated by establishing a mapping relationship between the label and the first feature vector.
And 104, processing the first image to be recognized by adopting the face position detection model and the face recognition model to obtain a second feature vector of the first image to be recognized.
In the embodiment of the application, a face position detection model can be adopted to determine whether the first image to be recognized has face information; and then, when the first image to be recognized is determined to have face information, the face recognition model is adopted to perform face recognition on the first image to be recognized to obtain a second feature vector. It should be noted that, the face position detection model is adopted to process the first image to be recognized before the face recognition is performed on the first image to be recognized, so that the recognition effectiveness can be ensured, and the situation that the first image to be recognized does not have face information, which results in the final failure to generate the second feature vector, is avoided. The second feature vector may be a vector corresponding to a feature in each of the first images to be recognized.
And 105, identifying the first image to be identified based on the feature vector library and the second feature vector to obtain portrait information in the first image to be identified.
The portrait information in the first image to be recognized can be determined by matching the second feature vector with the first feature vector in the feature vector library and according to the matching degree of the second feature vector and the first feature vector; in a feasible implementation manner, the image recognition device may determine the label of the target feature vector according to the second feature vector and the matching degree between each first feature vector and the matching degree between the second feature vector and each first feature vector, and further determine the portrait information in the first image to be recognized according to the label of the target feature vector.
The image identification method provided by the embodiment of the application can be used for acquiring a first image to be trained, which has a portrait and comprises at least two images with the same portrait; processing a first image to be trained by adopting a face position detection model and a face recognition model to obtain a first feature vector of the first image to be trained; labeling the first feature vector, and constructing a feature vector library based on the first feature vector and the label; the face position detection model and the face recognition model are adopted to process a first image to be recognized with a portrait to obtain a second feature vector of the first image to be recognized, then the first image to be recognized is recognized based on the feature vector library and the second feature vector to obtain portrait information in the first image to be recognized, so that the portrait information in the first image to be recognized can be recognized based on the feature vector library constructed by processing the first image to be trained and the second feature vector obtained by processing the first image to be recognized, further the commodity using the star portrait can be determined, and the commodity using the star portrait is determined by adopting a manual screening method instead of adopting the manual screening method as in the related technology, so that the problem that the commodity using the star portrait is screened by adopting the manual screening method in the related technology is solved, the labor cost is reduced and the screening efficiency is improved.
Based on the foregoing embodiments, an embodiment of the present application provides an image recognition method, which is shown in fig. 3 and includes the following steps:
step 201, an image recognition device acquires a first image to be trained with a portrait.
The first image to be trained comprises at least two images with the same portrait.
In the embodiment of the present application, the first image to be trained may be obtained by: firstly, screening pictures on a Jingdong master station, and further selecting a picture of a specific star as a first sample; then, picture screening is carried out on the whole network, and a specific star picture is selected as a second sample; finally, combining the first sample and the second sample to obtain a first image to be trained; that is, the first image to be trained may be a picture of a star acquired from a different source.
Step 202, the image recognition device detects the first image to be trained by using the face position detection model to obtain a detection result.
Wherein, step 202 can be implemented by:
step 202a, inputting a first image to be trained into a face position detection model in a preset format by the image recognition equipment, and detecting the first image to be trained by using the face position detection model to obtain a detection result.
Before the image recognition device detects the first image to be trained by using the face position detection model, the input format of the first image to be trained can be converted, that is, the input format of the first image to be trained is converted into a preset format; in one possible implementation, the preset format may include a string format of base 64.
In the embodiment of the application, the face position detection model can be a retinaFace model; it should be noted that, when the retinaFace model is used to detect the first image to be trained, a resnet or mobilenetv2 network model may be used as an algorithm.
Before the face recognition model is used for carrying out face recognition on the first image to be trained, the face position detection model is firstly used for determining that the first image to be trained has a face, and then the face position detection model is used for carrying out face recognition; if the first image to be trained is determined not to have the face, subsequent processing steps are not carried out, so that the images subjected to face recognition are all images with face information, effective recognition of the first image to be trained is ensured, and the accuracy of the recognition is ensured.
Step 203, when the image recognition device determines that the first image to be trained has a face based on the detection result, the image recognition device performs face recognition on the first image to be trained by using the face recognition model to obtain a first feature vector of the first image to be trained.
Wherein, step 203 can be implemented by the following steps:
step 203a, when the image recognition device determines that the first image to be trained has a face based on the detection result, the image recognition device obtains the position information of each feature point of the face in the first image to be trained based on the detection result.
The feature points can refer to key points which can uniquely identify face information of the first image to be trained; in one possible implementation, the feature points may refer to two eyes, a nose, and two mouth angles of a mouth in the face information of the first image to be trained. That is, it is necessary to acquire the positions of two eyes, a nose, and two mouth corners of a mouth of a human face.
And 203b, if the position information of the feature points does not meet the preset conditions, the image recognition equipment aligns the face of the first image to be trained to obtain a corrected image to be trained.
The face alignment of the first image to be trained may be implemented by affine transformation of a matrix. In the embodiment of the application, the matching relationship between the position information of each feature point of the face in the first image to be trained and the preset position information can be obtained by comparison, so as to determine whether the position information of the feature point meets the preset condition; the preset position information can be determined in advance according to the positions of eyes, a nose and a mouth corner in standard face information; of course, whether the preset condition is met or not may be determined by judging the relationship between the position information of each two feature points of the first image to be trained in the position information of each feature point of the face; in one possible implementation, whether the preset condition is met may be determined by determining whether the positions of the two eyes correspond and the positions of the two mouth corners correspond based on the position of the nose as a reference. Fig. 3a shows the face image before alignment, and fig. 3b shows the face image after alignment.
It should be noted that, because the face angles of the stars in the first image to be trained are various, if the face angles are not unified to a fixed angle, the output face features cannot be compared well. In order to unify the comparison standards, the face needs to be aligned, so as to ensure the accuracy of subsequent face recognition.
And 203c, the image recognition equipment performs face recognition on the corrected image to be trained by adopting a face recognition model to obtain a feature vector of the first image to be trained.
In the embodiment of the application, the initial face recognition model can be firstly subjected to model training to generate a face recognition model, and then the generated face recognition model is adopted to perform face recognition on the corrected image to be trained; it should be noted that the corrected image to be trained may be used to train the initial face recognition model; of course, the initial face recognition model may also be trained with other newly acquired images to be trained. In one possible implementation, the initial face recognition model may be an arcFace model.
And 204, labeling the first feature vector, and constructing a feature vector library based on the first feature vector and the label.
Wherein the tag is used to uniquely identify the first feature vector.
In the embodiment of the present application, the label may be used to indicate which star the image corresponding to the first feature vector is, and indicate only; that is, the label may indicate which star the first feature vector represents.
Step 205, the image recognition device obtains a first image to be recognized with a portrait.
In one possible implementation, step 205 may be implemented by:
step 205a, the image recognition device obtains a second image to be recognized with a portrait.
The second image to be recognized may be an image with a star face, which needs to be subjected to face recognition.
And step 205b, the image recognition equipment performs character recognition on the second image to be recognized by adopting a character recognition algorithm to obtain key information of the second image to be recognized.
Wherein, the second image to be recognized may be subjected to Optical Character Recognition (OCR) processing to obtain key information of the second image to be recognized; the key information of the second image to be recognized may refer to a keyword in a text in the second image to be recognized.
And step 205c, the image recognition device filters the second image to be recognized based on the key information to obtain the first image to be recognized.
In the embodiment of the application, OCR processing is performed on the second image to be recognized to obtain character information in the second image to be recognized, and then a keyword is obtained from the obtained character information, so that whether the keyword exists in a keyword library is judged; finally, screening out images with keywords in a keyword library from the second image to be recognized to obtain a first image to be recognized; wherein, the keyword library can be some words which are created in advance and related to the star information.
It should be noted that, in the present application, the second image to be recognized may not be screened, and the second image to be recognized is directly processed by using the face position detection model and the face recognition model, so as to obtain the second feature vector.
Step 206, the image recognition device processes the first image to be recognized by using the face position detection model and the face recognition model to obtain a second feature vector of the first image to be recognized.
In the embodiment of the application, the specific implementation process of obtaining the second feature vector of the first image to be recognized by processing the first image to be recognized by using the face position detection model and the face recognition model may be the same as the implementation process of obtaining the first feature vector of the first image to be trained by processing the first image to be trained by using the face position detection model and the face recognition model, and details are not repeated here; that is, the face position detection model and the face recognition model are identical to the face position detection model and the face recognition model, and the processing procedure is also identical.
Step 207, the image recognition device determines second feature information of the second feature vector and first feature information of each first feature vector in the feature vector library.
In the embodiment of the present application, the feature vector library may refer to a faiss library; wherein, the characteristic information may be some information that can refer to and characterize the corresponding image; in one possible implementation, the feature information may include: how the star is, facial expressions, environmental parameters of the environment in which the star is located in the image, and the like.
Step 208, the image recognition device determines the similarity between each first feature vector and the second feature vector in the feature vector library based on the first feature information and the second feature information.
The similarity between each first feature vector and each second feature vector can be determined by adopting the first feature information and the second feature information aiming at the feature vector library. It should be noted that, when determining the similarity between the first feature vector and the second feature vector, the similarity may be determined according to a distance between the first feature vector and the second feature vector, and of course, the similarity may refer to a cosine distance between the first feature vector and the second feature vector.
And step 209, the image recognition device screens the first feature vectors to obtain target feature vectors based on the similarity.
The first feature vectors may be ranked according to the perceptual similarity, and the target feature vectors are obtained by screening from the first feature vectors according to the ranking result.
Step 210, the image recognition device obtains portrait information in the first image to be recognized based on the label of the target feature vector.
In the embodiment of the application, after the target feature vector is determined, the label of the target feature vector needs to be acquired, and then which star the target feature vector represents can be known according to the label of the target feature vector, that is, the portrait information in the first image to be recognized can be acquired.
It should be noted that, for the descriptions of the same steps and the same contents in this embodiment as those in other embodiments, reference may be made to the descriptions in other embodiments, which are not described herein again.
The image identification method provided by the embodiment of the application can identify portrait information in the first image to be identified based on the feature vector library constructed by processing the first image to be trained and the second feature vector obtained by processing the first image to be identified, and further can determine which commodities use the star portrait, rather than determining which commodities use the star portrait by adopting a manual screening method as in the related art, so that the problem that the commodities use the star portrait in a manual screening mode in the related art is solved, the labor cost is reduced, and the screening efficiency is improved.
Based on the foregoing embodiments, an embodiment of the present application provides an image recognition method, which is shown in fig. 4 and includes the following steps:
step 301, an image recognition device obtains a first image to be trained with a portrait.
The first image to be trained comprises at least two images with the same portrait.
In this embodiment, the second identification image to be trained may be a binary identification image generated by a computer and defined by black and white standard.
Step 302, inputting the first image to be trained into the face position detection model in a preset format by the image recognition device, and detecting the first image to be trained by using the face position detection model to obtain a detection result.
Step 303, when the image recognition device determines that the first image to be trained has a face based on the detection result, the image recognition device obtains the position information of each feature point of the face in the first image to be trained based on the detection result.
And step 304, if the position information of the feature points does not meet the preset conditions, the image recognition equipment aligns the face of the first image to be trained to obtain a corrected image to be trained.
And 305, inputting the corrected image to be trained into the initial face recognition model in a preset format by the image recognition equipment, and training the initial face recognition model by using the corrected image to be trained to obtain the face recognition model.
Before the image recognition device recognizes the corrected image to be trained by adopting the face recognition model, the image recognition device can firstly convert the input format of the corrected image to be trained, namely, the input format of the corrected image to be trained is converted into a preset format; in one possible implementation, the preset format may include a string format of base 64.
In the embodiment of the present application, the initial face recognition model may refer to an arcFace model; the arcFace model is retrained on the data set of the corrected image to be trained, so that the arcFace model is more consistent with the practical application condition, and the extracted features can be more suitable for specific scenes. The recognition accuracy of the image is low before the arcFace model is retrained; as shown in fig. 5, both images are of the face of a star of wu, but the similarity is only 67% in the different images. This shows that the generalization capability of the arcFace model is not particularly good, and the arcFace model has high limitation on feature extraction of the star face. Therefore, the arcFace model is trained again, the effect is better, the obtained trained latest model is used for predicting the two images in the image 4 again, and the obtained similarity is greatly improved.
Before changing the input format of the corrected image to be trained, the following process is required to input the image into the trained arcFace model: image- > numpy- > model; however, the flow after the input format of the corrected image to be trained is changed is: image- > numpy- > base64- > model. It seems that one more step is added after the change, and more time is spent, but otherwise, in real online service, the model is deployed at the server, and when the model is called, the model is often called through a hypertext transfer protocol (http), and at this time, the format of the array (numpy) needs to be converted into json, which is time-consuming, and at this time, the model is converted into the format of base64, so that the time is saved greatly. This time saving is often more apparent as the picture is larger.
Step 306, the image recognition device performs face recognition on the corrected image to be trained by using the face recognition model to obtain a first feature vector of the first image to be trained.
And 307, labeling the first feature vector, and constructing a feature vector library based on the first feature vector and the label.
Wherein the tag is used to uniquely identify the first feature vector.
Step 308, the image recognition device obtains a first image to be recognized with a portrait.
Step 309, the image recognition device processes the first image to be recognized by using the face position detection model and the face recognition model to obtain a second feature vector of the first image to be recognized.
Step 310, the image recognition device determines second feature information of the second feature vector and first feature information of each first feature vector in the feature vector library.
Step 311, the image recognition device determines the similarity between each first feature vector and the second feature vector in the feature vector library based on the first feature information and the second feature information.
And step 312, the image recognition device ranks the first feature vectors in descending order based on the similarity, and obtains K feature vectors before ranking from the first feature vectors.
Step 313, the image recognition device obtains the feature vectors with the similarity greater than the preset threshold from the feature vectors of the K before sorting to obtain the target feature vectors.
In the embodiment of the application, the feature vectors ranked at the top K names can be obtained from all the first feature vectors, and the feature vectors with the similarity greater than a preset threshold are obtained from the feature vectors ranked at the top K names to obtain the target feature vector. It should be noted that K and the preset threshold may be obtained by training with reference to the idea of gradient descent of neural network training. And, the k value is different from the preset threshold value for different stars.
And step 314, the image recognition device acquires portrait information in the first image to be recognized based on the label of the target feature vector.
It should be noted that if there are a plurality of target feature vectors and there are a plurality of tags, a voting mechanism is adopted to obtain the tag with the largest occurrence number from all tags, and then it is determined that the tag with the largest occurrence number is portrait information in the first image to be recognized.
Based on the foregoing embodiments, in other embodiments of the present application, K and the feature vector in the foregoing steps may be implemented by:
and step A, the image recognition equipment acquires a second image to be trained with a portrait.
And step B, the image recognition equipment processes the second image to be trained by adopting the face position detection model and the face recognition model to obtain a third feature vector of the second image to be trained.
It should be noted that, the specific implementation process of obtaining the third feature vector of the second image to be trained by processing the second image to be trained by using the face position detection model and the face recognition model may be the same as the implementation process of obtaining the first feature vector of the first image to be trained by processing the first image to be trained by using the face position detection model and the face recognition model, and details are not repeated here; that is, the face position detection model and the face recognition model are identical to the face position detection model and the face recognition model, and the processing procedure is also identical.
And step C, setting an initial K value and an initial threshold value by the image recognition device.
Wherein, the initial K and the initial threshold may be randomly set.
And step D, training the initial K value and the initial threshold value by the image recognition equipment by adopting a neural network algorithm based on the third feature vector, the feature vector library, the accuracy and the recall rate to obtain the K value and the preset threshold value.
It should be noted that, the accuracy and recall rate of the test result are evaluated; where accuracy and recall are required to be taken into account, we used f1 as the evaluation criterion. Increasing or decreasing k and a preset threshold for performance of f 1; this process 2-4 is repeated until f1 remains almost unchanged or f1 fluctuates within a very small range. Of course, the user may also configure K and the preset threshold value according to the actual needs of the user. In addition, the image identification method provided by the application identifies the public people by using multi-model and multi-stage information, so that the accuracy rate is greatly improved. And as the model is iteratively upgraded, the model can be replaced into a higher-level model version without influence on other models.
It should be noted that, for the descriptions of the same steps and the same contents in this embodiment as those in other embodiments, reference may be made to the descriptions in other embodiments, which are not described herein again.
The image identification method provided by the embodiment of the application can identify portrait information in the first image to be identified based on the feature vector library constructed by processing the first image to be trained and the second feature vector obtained by processing the first image to be identified, and further can determine which commodities use the star portrait, rather than determining which commodities use the star portrait by adopting a manual screening method as in the related art, so that the problem that the commodities use the star portrait in a manual screening mode in the related art is solved, the labor cost is reduced, and the screening efficiency is improved.
Based on the foregoing embodiments, an embodiment of the present application provides an image recognition apparatus, which may be applied to the image recognition methods provided in the embodiments corresponding to fig. 1, 2, and 4, and as shown in fig. 6, the apparatus may include: a processor 41, a memory 42, and a communication bus 43, wherein:
the communication bus 43 is used for realizing communication connection between the processor 41 and the memory 42;
the processor 41 is configured to execute an image processing program stored in the memory 42 to implement the steps of:
acquiring a first image to be trained with a portrait; the first image to be trained comprises at least two images with the same portrait;
processing a first image to be trained by adopting a face position detection model and a face recognition model to obtain a first feature vector of the first image to be trained;
labeling the first feature vector, and constructing a feature vector library based on the first feature vector and the label; wherein the tag is used for uniquely identifying the first feature vector;
acquiring a first image to be identified with a portrait;
processing the first image to be recognized by adopting a face position detection model and a face recognition model to obtain a second feature vector of the first image to be recognized;
and identifying the first image to be identified based on the feature vector library and the second feature vector to obtain portrait information in the first image to be identified.
In other embodiments of the present application, the processor 41 is configured to execute the step of obtaining the first identification image to be trained stored in the memory 42 to implement the following steps:
acquiring a second identification image to be trained;
the second identification image to be trained is an identification image with clear image quality;
and reducing the quality of the second identification image to be trained to obtain the first identification image to be trained.
In other embodiments of the present application, the processor 41 is configured to execute the following steps to process the first image to be trained by using the face position detection model and the face recognition model stored in the memory 42 to obtain the first feature vector of the first image to be trained:
detecting the first image to be trained by adopting a face position detection model to obtain a detection result;
and when the first image to be trained is determined to have the face based on the detection result, carrying out face recognition on the first image to be trained by adopting a face recognition model to obtain a first feature vector of the first image to be trained.
In other embodiments of the present application, the processor 41 is configured to execute the following steps to detect the first image to be trained by using the face position detection model stored in the memory 42, and obtain a detection result:
and inputting the first image to be trained into the face position detection model in a preset format, and detecting the first image to be trained by adopting the face position detection model to obtain a detection result.
In other embodiments of the present application, the processor 41 is configured to perform, when it is determined that the first image to be trained has a face based on the detection result stored in the memory 42, a face recognition model is used to perform face recognition on the first image to be trained, so as to obtain a first feature vector of the first image to be trained, so as to implement the following steps:
when the first image to be trained is determined to have the face based on the detection result, acquiring the position information of each feature point of the face in the first image to be trained based on the detection result;
if the position information of the feature points does not accord with the preset condition, carrying out face alignment on the first image to be trained to obtain a corrected image to be trained;
and carrying out face recognition on the corrected image to be trained by adopting a face recognition model to obtain a feature vector of the first image to be trained.
In other embodiments of the present application, the processor 41 is configured to execute the face recognition module stored in the memory 42 to perform face recognition on the corrected image to be trained to obtain a feature vector of the first image to be trained, so as to implement the following steps:
inputting the corrected image to be trained into a face recognition model in a preset format, and training the initial face recognition model by adopting the corrected image to be trained to obtain a face recognition model;
and carrying out face recognition on the corrected image to be trained by adopting a face recognition model to obtain a first feature vector.
In other embodiments of the present application, the processor 41 is configured to execute the step of obtaining the first to-be-recognized image with a portrait stored in the memory 42 to implement the following steps:
acquiring a second image to be identified with a portrait;
performing character recognition on the second image to be recognized by adopting a character recognition algorithm to obtain key information of the second image to be recognized;
and screening the second image to be identified based on the key information to obtain the first image to be identified.
In other embodiments of the present application, the processor 41 is configured to execute the recognition processing on the first image to be recognized based on the feature vector library and the second feature vector stored in the memory 42, to obtain portrait information in the first image to be recognized, so as to implement the following steps:
determining second feature information of the second feature vector and first feature information of each first feature vector in a feature vector library;
determining the similarity between each first feature vector and each second feature vector based on the first feature information and the second feature information in a feature vector library;
screening the first feature vectors to obtain target feature vectors based on the similarity;
and acquiring portrait information in the first image to be recognized based on the label of the target feature vector.
In other embodiments of the present application, the processor 41 is configured to perform the following steps by filtering the first feature vector to obtain a target feature vector based on the similarity stored in the memory 42:
sorting the first feature vectors in a descending order based on the similarity, and acquiring K feature vectors before sorting from the first feature vectors;
and acquiring the feature vectors with the similarity larger than a preset threshold value from the feature vectors of the K before sorting to obtain the target feature vectors.
In other embodiments of the present application, processor 41 is configured to execute an image recognition program stored in memory 42 to implement the steps of:
acquiring a second image to be trained with a portrait;
processing the second image to be trained by adopting a face position detection model and a face recognition model to obtain a third feature vector of the second image to be trained;
setting an initial K value and an initial threshold value;
and training the initial K value and the initial threshold value by adopting a neural network algorithm based on the third feature vector, the feature vector library, the accuracy and the recall rate to obtain the K value and the preset threshold value.
It should be noted that, for a specific implementation process of the step executed by the processor in this embodiment, reference may be made to an implementation process in the image recognition method provided in the embodiments corresponding to fig. 1, 2, and 4, and details are not described here again.
The image recognition device provided by the embodiment of the application can recognize portrait information in the first image to be recognized based on the feature vector library constructed by processing the first image to be trained and the second feature vector obtained by processing the first image to be recognized, and further can determine which commodities use the star portrait, rather than determining which commodities use the star portrait by adopting a manual screening method as in the related art, so that the problem that the star portrait is used in which commodities are screened by adopting a manual screening method in the related art is solved, the labor cost is reduced, and the screening efficiency is improved.
Based on the foregoing embodiments, embodiments of the present application provide a computer-readable storage medium storing one or more programs, which are executable by one or more processors to implement steps in an image recognition method provided by the embodiments corresponding to fig. 1, 2 and 4.
It should be appreciated that reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure or characteristic described in connection with the embodiment is included in at least one embodiment of the present application. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. It should be understood that, in the various embodiments of the present application, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application. The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described device embodiments are merely illustrative, for example, the division of a unit is only one logical function division, and there may be other division ways in actual implementation, such as: multiple units or components may be combined, or may be integrated into another system, or some features may be omitted, or not implemented. In addition, the coupling, direct coupling or communication connection between the components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between the devices or units may be electrical, mechanical or other forms.
In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be separately regarded as one unit, or two or more units may be integrated into one unit; the integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
Those of ordinary skill in the art will understand that: all or part of the steps for realizing the method embodiments can be completed by hardware related to program instructions, the program can be stored in a computer readable storage medium, and the program executes the steps comprising the method embodiments when executed; and the aforementioned storage medium includes: various media that can store program codes, such as a removable Memory device, a Read Only Memory (ROM), a magnetic disk, or an optical disk.
Alternatively, the integrated units described above in the present application may be stored in a computer-readable storage medium if they are implemented in the form of software functional modules and sold or used as independent products. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially implemented or portions thereof contributing to the prior art may be embodied in the form of a software product stored in a storage medium, and including several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a removable storage device, a ROM, a magnetic or optical disk, or other various media that can store program code.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (11)

1. An image recognition method, characterized in that the method comprises:
acquiring a first image to be trained with a portrait; the first image to be trained comprises at least two images with the same portrait;
processing the first image to be trained by adopting a face position detection model and a face recognition model to obtain a first feature vector of the first image to be trained;
labeling the first feature vector, and constructing a feature vector library based on the first feature vector and the label; wherein the tag is used to uniquely identify the first feature vector;
acquiring a first image to be identified with a portrait;
processing the first image to be recognized by adopting the face position detection model and the face recognition model to obtain a second feature vector of the first image to be recognized;
and identifying the first image to be identified based on the feature vector library and the second feature vector to obtain portrait information in the first image to be identified.
2. The method according to claim 1, wherein the processing the first image to be trained by using the face position detection model and the face recognition model to obtain the first feature vector of the first image to be trained comprises:
detecting the first image to be trained by adopting the face position detection model to obtain a detection result;
and when the first image to be trained is determined to have a face based on the detection result, carrying out face recognition on the first image to be trained by adopting the face recognition model to obtain a first feature vector of the first image to be trained.
3. The method according to claim 2, wherein the detecting the first image to be trained by using the face position detection model to obtain a detection result comprises:
and inputting the first image to be trained into the face position detection model in a preset format, and detecting the first image to be trained by adopting the face position detection model to obtain the detection result.
4. The method according to claim 2 or 3, wherein when it is determined that the first image to be trained has a face based on the detection result, performing face recognition on the first image to be trained by using the face recognition model to obtain a first feature vector of the first image to be trained, includes:
when the first image to be trained is determined to have a face based on the detection result, acquiring position information of each feature point of the face in the first image to be trained based on the detection result;
if the position information of the feature points does not meet the preset condition, carrying out face alignment on the first image to be trained to obtain a corrected first image to be trained;
and carrying out face recognition on the corrected image to be trained by adopting the face recognition model to obtain the characteristic vector of the first image to be trained.
5. The method according to claim 4, wherein the performing face recognition on the corrected image to be trained by using the face recognition model to obtain the first feature vector of the first image to be trained comprises:
inputting the corrected image to be trained into the initial face recognition model in a preset format, and training the initial face recognition model by adopting the corrected image to be trained to obtain the face recognition model;
and carrying out face recognition on the corrected image to be trained by adopting the face recognition model to obtain the first characteristic vector.
6. The method of claim 1, wherein the obtaining a first to-be-recognized image having a portrait includes:
acquiring a second image to be identified with a portrait;
performing character recognition on the second image to be recognized by adopting a character recognition algorithm to obtain key information of the second image to be recognized;
and screening the second image to be identified based on the key information to obtain the first image to be identified.
7. The method according to claim 1, wherein the performing recognition processing on the first image to be recognized based on the feature vector library and the second feature vector to obtain portrait information in the first image to be recognized comprises:
determining second feature information of the second feature vector and first feature information of each of the first feature vectors in the feature vector library;
determining, in the feature vector library, a similarity between each of the first feature vectors and the second feature vectors based on the first feature information and the second feature information;
screening the first feature vectors to obtain target feature vectors based on the similarity;
and acquiring portrait information in the first image to be recognized based on the label of the target feature vector.
8. The method of claim 7, wherein the filtering a target feature vector from the first feature vectors based on the similarity comprises:
sorting the first feature vectors in a descending order based on the similarity, and acquiring K feature vectors before sorting from the first feature vectors;
and acquiring the feature vectors with the similarity larger than a preset threshold value from the feature vectors of the K before sorting to obtain the target feature vectors.
9. The method of claim 8, further comprising:
acquiring a second image to be trained with a portrait;
processing the second image to be trained by adopting the face position detection model and the face recognition model to obtain a third feature vector of the second image to be trained;
setting an initial K value and an initial threshold value;
and training the initial K value and the initial threshold value by adopting a neural network algorithm based on the third feature vector, the feature vector library, the accuracy and the recall rate to obtain the K value and the preset threshold value.
10. An image recognition apparatus, characterized in that the apparatus comprises: a processor, a memory, and a communication bus;
the communication bus is used for realizing communication connection between the processor and the memory;
the processor is configured to execute an image recognition program stored in the memory to implement the steps of:
acquiring a first image to be trained with a portrait; the first image to be trained comprises at least two images with the same portrait;
processing the first image to be trained by adopting a face position detection model and a face recognition model to obtain a first feature vector of the first image to be trained;
labeling the first feature vector, and constructing a feature vector library based on the first feature vector and the label; wherein the tag is used to uniquely identify the first feature vector;
acquiring a first image to be identified with a portrait;
processing the first image to be recognized by adopting the face position detection model and the face recognition model to obtain a second feature vector of the first image to be recognized;
and identifying the first image to be identified based on the feature vector library and the second feature vector to obtain portrait information in the first image to be identified.
11. A computer-readable storage medium, characterized in that the computer-readable storage medium stores one or more programs which are executable by one or more processors to implement the steps of the image recognition method according to any one of claims 1 to 9.
CN202110130080.2A 2021-01-29 2021-01-29 Image recognition method, device and computer readable storage medium Pending CN113743176A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110130080.2A CN113743176A (en) 2021-01-29 2021-01-29 Image recognition method, device and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110130080.2A CN113743176A (en) 2021-01-29 2021-01-29 Image recognition method, device and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN113743176A true CN113743176A (en) 2021-12-03

Family

ID=78728150

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110130080.2A Pending CN113743176A (en) 2021-01-29 2021-01-29 Image recognition method, device and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN113743176A (en)

Similar Documents

Publication Publication Date Title
CN105426356B (en) A kind of target information recognition methods and device
US11625805B2 (en) Learning systems and methods
US10817615B2 (en) Method and apparatus for verifying images based on image verification codes
US20190188729A1 (en) System and method for detecting counterfeit product based on deep learning
EP4099217A1 (en) Image processing model training method and apparatus, device, and storage medium
US10769399B2 (en) Method for improper product barcode detection
CN108491866B (en) Pornographic picture identification method, electronic device and readable storage medium
CN111107048A (en) Phishing website detection method and device and storage medium
WO2020164278A1 (en) Image processing method and device, electronic equipment and readable storage medium
US20220405528A1 (en) Task-based image masking
CN113449725B (en) Object classification method, device, equipment and storage medium
CN114419363A (en) Target classification model training method and device based on label-free sample data
CN111868709A (en) Automatic batch sorting
CN113887438A (en) Watermark detection method, device, equipment and medium for face image
Gong et al. A novel unified deep neural networks methodology for use by date recognition in retail food package image
CN112396079A (en) Number recognition model training method, number recognition method and device
JP5480008B2 (en) Summary manga image generation apparatus, program and method for generating manga content summary
CN103748611A (en) Method for retrieving associated information using image
CN113743176A (en) Image recognition method, device and computer readable storage medium
CN113888760B (en) Method, device, equipment and medium for monitoring violation information based on software application
Fernández et al. Implementation of a face recognition system as experimental practices in an artificial intelligence and pattern recognition course
CN112380369B (en) Training method, device, equipment and storage medium of image retrieval model
CN114238968A (en) Application program detection method and device, storage medium and electronic equipment
CN112990147A (en) Method and device for identifying administrative-related images, electronic equipment and storage medium
CN111259385A (en) Application program identification method and device and neural network system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination