CN112926479A - Cat face identification method and system, electronic device and storage medium - Google Patents

Cat face identification method and system, electronic device and storage medium Download PDF

Info

Publication number
CN112926479A
CN112926479A CN202110253387.1A CN202110253387A CN112926479A CN 112926479 A CN112926479 A CN 112926479A CN 202110253387 A CN202110253387 A CN 202110253387A CN 112926479 A CN112926479 A CN 112926479A
Authority
CN
China
Prior art keywords
cat
face
face recognition
recognition model
cat face
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
CN202110253387.1A
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.)
Xinjiang Aiwinn Information Technology Co Ltd
Original Assignee
Xinjiang Aiwinn 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 Xinjiang Aiwinn Information Technology Co Ltd filed Critical Xinjiang Aiwinn Information Technology Co Ltd
Priority to CN202110253387.1A priority Critical patent/CN112926479A/en
Publication of CN112926479A publication Critical patent/CN112926479A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • G06F18/2415Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on parametric or probabilistic models, e.g. based on likelihood ratio or false acceptance rate versus a false rejection rate
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N7/00Computing arrangements based on specific mathematical models
    • G06N7/01Probabilistic graphical models, e.g. probabilistic networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/10Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/10Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
    • G06V40/16Human faces, e.g. facial parts, sketches or expressions
    • G06V40/172Classification, e.g. identification

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Probability & Statistics with Applications (AREA)
  • Multimedia (AREA)
  • Artificial Intelligence (AREA)
  • Human Computer Interaction (AREA)
  • Evolutionary Computation (AREA)
  • Algebra (AREA)
  • Mathematical Physics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Computing Systems (AREA)
  • Evolutionary Biology (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Oral & Maxillofacial Surgery (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Image Analysis (AREA)

Abstract

本申请公开一种猫脸识别方法、系统、电子装置及存储介质,方法包括:获取在预定地点采集的猫的正脸图像;对正脸图像进行猫脸关键点提取;对猫脸关键点进行仿射变换,得到固定点;将固定点输入预先训练的猫脸识别模型,得到猫脸识别模型的输出结果,输出结果至少包含一个猫脸标签,不同猫的猫脸标签不同;获取猫在预定地点的行为信息、时间信息,并与猫脸标签关联,并记录保存。通过对在预定地点采集的猫的正脸图像进行猫脸识别,能够准确地识别到出现在预定地点的猫的标签,通过将猫的标签、猫在预定地点的行为信息、时间信息进行关联,能够构成猫在预定地点做的事情,以及做事情的时间,这即为猫的生活习惯,从而准确地记录每只猫的生活习惯。

Figure 202110253387

The present application discloses a cat face recognition method, system, electronic device and storage medium. The method includes: acquiring a frontal face image of a cat collected at a predetermined location; extracting key points of the cat's face on the frontal image; Affine transformation to obtain a fixed point; input the fixed point into the pre-trained cat face recognition model to obtain the output result of the cat face recognition model, the output result contains at least one cat face label, and the cat face label of different cats is different; The behavior information and time information of the location are associated with the cat face tag and recorded. By performing cat face recognition on the front face image of the cat collected at the predetermined location, the label of the cat appearing at the predetermined location can be accurately identified. It can constitute what the cat does at the predetermined place and the time of doing it, which is the cat's living habits, so as to accurately record the living habits of each cat.

Figure 202110253387

Description

猫脸识别方法、系统、电子装置及存储介质Cat face recognition method, system, electronic device and storage medium

技术领域technical field

本申请涉及猫脸识别技术领域,具体涉及一种猫脸识别方法、系统、电子装置及存储介质。The present application relates to the technical field of cat face recognition, and in particular to a method, system, electronic device and storage medium for cat face recognition.

背景技术Background technique

在人们养的宠物中,猫占了很大的比重,在猫生病时,生活习惯(例如进食、喝水、排泄的时间等)会发生异常,因此对猫的生活习惯进行记录很有必要。Among the pets raised by people, cats account for a large proportion. When cats are sick, their living habits (such as eating, drinking, excretion time, etc.) will be abnormal, so it is necessary to record the living habits of cats.

但是,一些猫主人养有较多数量的猫,猫主人可能没有足够精力去记录猫的生活习惯,也就无法发现猫的生活习惯是否异常。However, some cat owners have a large number of cats, and the cat owners may not have enough energy to record the cats' living habits, so they cannot find out whether the cats' living habits are abnormal.

目前有一些技术会通过人脸识别模型来识别猫脸,虽然现在有脸部识别模型能够进行人脸识别,但是和人脸相比,猫脸存在毛发等影响,使得脸部识别模型对猫脸识别困难,因此使用现有的脸部识别方法来识别猫脸,也不能准确识别每只猫,并进一步导致不能准确记录每只猫的生活习惯。At present, there are some technologies that recognize cat faces through face recognition models. Although there are face recognition models that can perform face recognition, compared with human faces, cat faces have hair and other influences, which makes the face recognition model more sensitive to cat faces. Recognition is difficult, so using existing face recognition methods to recognize cat faces cannot accurately identify each cat, and further results in inability to accurately record each cat's living habits.

发明内容SUMMARY OF THE INVENTION

鉴于此,本申请提供一种猫脸识别方法、系统、电子装置及存储介质,以解决现有的脸部识别方法来识别猫脸,不能准确识别每只猫并记录每只猫的生活习惯的问题。In view of this, the application provides a cat face recognition method, system, electronic device and storage medium, to solve the problem that the existing face recognition method to recognize the cat face cannot accurately identify each cat and record the living habits of each cat question.

本申请第一方面提供一种猫脸识别方法,包括:获取在预定地点采集的猫的正脸图像;对所述正脸图像进行猫脸关键点提取,所述猫脸关键点包括猫的两只眼睛及鼻头的关键点;对所述猫脸关键点进行仿射变换,得到固定点;将所述固定点输入预先训练的猫脸识别模型,得到所述猫脸识别模型的输出结果,所述输出结果至少包含一个猫脸标签,不同猫的猫脸标签不同;获取所述猫在所述预定地点的行为信息、时间信息,并与所述猫脸标签关联,并记录保存。A first aspect of the present application provides a method for cat face recognition, including: acquiring a frontal face image of a cat collected at a predetermined location; extracting key points of a cat face on the frontal face image, where the key points of the cat face include two parts of the cat's face. The key points of the eyes and nose; perform affine transformation on the key points of the cat face to obtain fixed points; input the fixed points into the pre-trained cat face recognition model to obtain the output result of the cat face recognition model, so The output result contains at least one cat face tag, and the cat face tags of different cats are different; the behavior information and time information of the cat at the predetermined location are obtained, associated with the cat face tag, and recorded and saved.

其中,猫脸识别模型的训练方法包括:建立万量级特征库的原始人脸识别模型,原始人脸识别模型至少包括一个全连接层及一个特征层;对原始人脸识别模型进行优化;将猫脸样本数据输入原始人脸识别模型进行训练,得到猫脸识别模型,猫脸样本数据至少包括猫的猫脸特征及猫脸标签。Among them, the training method of the cat face recognition model includes: establishing an original face recognition model with a feature database of tens of thousands, the original face recognition model including at least one fully connected layer and one feature layer; optimizing the original face recognition model; The cat face sample data is input into the original face recognition model for training, and the cat face recognition model is obtained. The cat face sample data at least includes the cat face features and cat face labels of cats.

其中,对原始人脸识别模型进行优化包括:构建交叉熵损失函数;获取特征层输出的特征向量,以及分类网络输出的权重;将特征向量与权重进行L2范数归一化,以将特征向量间的距离表现为余弦相似度,完成对原始人脸识别模型的优化。Among them, the optimization of the original face recognition model includes: constructing a cross entropy loss function; obtaining the feature vector output by the feature layer and the weight output by the classification network; The distance between them is expressed as cosine similarity, which completes the optimization of the original face recognition model.

其中,对原始人脸识别模型进行优化还包括:筛选猫脸样本数据中的困难样本,并构建三元组损失函数;利用三元组损失函数计算困难样本的余弦相似度,完成对原始人脸识别模型的优化。Among them, the optimization of the original face recognition model also includes: screening the difficult samples in the cat face sample data, and constructing a triple loss function; using the triple loss function to calculate the cosine similarity of the difficult samples to complete the original face Recognition model optimization.

其中,困难样本包括:具有相同猫脸标签,且余弦相似度相差最大的N个样本数据,以及具有不同猫脸标签,且余弦相似度相差最小的N个样本数据,N大于或等于二。Among them, the difficult samples include: N sample data with the same cat face label and the largest difference in cosine similarity, and N sample data with different cat face labels and the smallest difference in cosine similarity, where N is greater than or equal to two.

其中,对原始人脸识别模型进行优化包括:向原始人脸识别模型输入两组猫脸样本数据,并在所述特征层构建交叉熵损失函数、三元组损失函数;利用交叉熵损失函数计算第一组猫脸样本数据与猫脸标签的交叉熵损失值;利用原始人脸识别模型筛选出第二组猫脸样本数据中的困难样本;对困难样本使用三元组损失函数计算三元组损失值;将三元组损失值及交叉熵损失值进行相加求和,得到原始人脸识别模型的最终损失值,完成对原始人脸识别模型的优化。Wherein, optimizing the original face recognition model includes: inputting two sets of cat face sample data into the original face recognition model, and constructing a cross-entropy loss function and a triplet loss function in the feature layer; using the cross-entropy loss function to calculate Cross-entropy loss value of the first group of cat face sample data and cat face labels; use the original face recognition model to filter out the difficult samples in the second group of cat face sample data; use triplet loss function for difficult samples to calculate triples Loss value; the triple loss value and the cross entropy loss value are added and summed to obtain the final loss value of the original face recognition model, and the optimization of the original face recognition model is completed.

其中,交叉熵损失函数计算的数据量级为三元组损失函数计算的数据量级的十倍。Among them, the data magnitude calculated by the cross-entropy loss function is ten times the data magnitude calculated by the triple loss function.

本申请第二方面提供一种猫脸识别系统,包括:图像获取模块,用于获取在预定地点采集的猫的正脸图像;猫脸关键点提取模块,用于正脸图像进行猫脸关键点提取,猫脸关键点包括猫的两只眼睛及鼻头的关键点;仿射变换模块,用于将猫脸关键点提取模块提取的猫脸关键点进行仿射变换,得到固定点;猫脸识别模块,用于集成预先使用猫脸样本数据训练出能够识别猫脸的猫脸识别模型,猫脸识别模型的输出结果至少包含一个猫脸标签,不同猫的猫脸标签不同;数据交互模块,用于将仿射变换模块得到的固定点输入猫脸识别模块,并获取猫脸识别模块中的猫脸识别模型的输出结果;关联记录模块,用于获取猫在预定地点的行为信息、时间信息,并与猫脸标签关联,并记录保存。A second aspect of the present application provides a cat face recognition system, including: an image acquisition module for acquiring a frontal face image of a cat collected at a predetermined location; a cat face key point extraction module for performing key point analysis on the cat face from the frontal image Extraction, the key points of the cat face include the key points of the cat's two eyes and nose; the affine transformation module is used to perform affine transformation on the key points of the cat face extracted by the cat face key point extraction module to obtain fixed points; cat face recognition The module is used to integrate a cat face recognition model that can recognize cat faces by using cat face sample data in advance. The output of the cat face recognition model contains at least one cat face label, and different cats have different cat face labels; data interaction module, use The fixed point obtained by the affine transformation module is input into the cat face recognition module, and the output result of the cat face recognition model in the cat face recognition module is obtained; the associated recording module is used to obtain the behavior information and time information of the cat at the predetermined location, And associated with the cat face tag, and record keeping.

本申请第三方面提供一种电子装置,包括:包括存储器和处理器,所述存储器上存储有程序,其特征在于,所述程序用于被所述处理器执行时,实现上述中的任意一项所述猫脸识别方法。A third aspect of the present application provides an electronic device, comprising: a memory and a processor, wherein a program is stored on the memory, wherein the program is used to implement any one of the above when executed by the processor The cat face recognition method described in item.

本申请第四方面提供一种可读存储介质,其上存储有程序,其特征在于,所述程序用于被处理器执行时,实现上述中的任意一项所述猫脸识别方法。A fourth aspect of the present application provides a readable storage medium on which a program is stored, wherein the program is configured to implement any one of the above methods for cat face recognition when executed by a processor.

本申请上述的猫脸识别方法,一方面通过预先训练的猫脸识别模型来识别猫脸,可以减少毛发等对识别的影响,从而降低对猫脸识别的难度;另一方面,通过对在预定地点采集的猫的正脸图像进行猫脸识别,能够准确地识别到出现在预定地点的猫的标签,而应用至预定地点为猫的进食、喝水、排泄等地点的场景时,通过将猫的标签,以及猫在预定地点的行为信息、时间信息进行关联,并记录保存,因此能准确地记录每只猫的生活习惯。The above-mentioned cat face recognition method of the present application, on the one hand, uses a pre-trained cat face recognition model to recognize cat faces, which can reduce the influence of hair on recognition, thereby reducing the difficulty of cat face recognition; Cat face recognition from the front face image of the cat collected at the location can accurately identify the label of the cat appearing at the predetermined location. The label of the cat is associated with the behavior information and time information of the cat at the predetermined location, and is recorded and saved, so the living habits of each cat can be accurately recorded.

附图说明Description of drawings

为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions in the embodiments of the present application more clearly, the following briefly introduces the drawings that are used in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those skilled in the art, other drawings can also be obtained from these drawings without creative effort.

图1是本申请一实施例的猫脸识别方法流程示意图;1 is a schematic flowchart of a method for cat face recognition according to an embodiment of the present application;

图2是本申请一实施例的猫脸识别方法的对原始人脸识别模型的优化流程示意图;FIG. 2 is a schematic flow chart of an optimization process for an original face recognition model of a cat face recognition method according to an embodiment of the present application;

图3是本申请一实施例的猫脸识别方法的对原始人脸识别模型的另一种优化流程示意图;3 is a schematic flow diagram of another optimization process for the original face recognition model of the cat face recognition method according to an embodiment of the present application;

图4是本申请一实施例的猫脸识别系统的结构示意框图;4 is a schematic structural block diagram of a cat face recognition system according to an embodiment of the present application;

图5是本申请一实施例的电子装置的结构示意框图。FIG. 5 is a schematic structural block diagram of an electronic device according to an embodiment of the present application.

具体实施方式Detailed ways

下面结合附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅是本申请一部分实施例,而非全部实施例。基于本申请中的实施例,本领域技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。在不冲突的情况下,下述各个实施例及其技术特征可以相互组合。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of this application. In the case of no conflict, the following various embodiments and their technical features can be combined with each other.

请参阅图1,为本申请实施例提供的一种猫脸识别方法,包括:S1、获取在预定地点采集的猫的正脸图像;S2、对正脸图像进行猫脸关键点提取;S3、对猫脸关键点进行仿射变换,得到固定点;S4、将固定点输入预先训练的猫脸识别模型,得到猫脸识别模型的输出结果,输出结果至少包含一个猫脸标签,不同猫的猫脸标签不同;S5、获取猫在预定地点的行为信息、时间信息,并与猫脸标签关联,并保存。Referring to FIG. 1, a method for recognizing a cat face provided in an embodiment of the present application includes: S1, acquiring a frontal face image of a cat collected at a predetermined location; S2, extracting key points of the cat's face on the frontal face image; S3, Perform affine transformation on the key points of the cat face to obtain the fixed point; S4, input the fixed point into the pre-trained cat face recognition model, and obtain the output result of the cat face recognition model, the output result contains at least one cat face label, cats of different cats The face tags are different; S5, obtain the behavior information and time information of the cat at the predetermined place, associate with the cat face tag, and save it.

在该实施例中,猫脸关键点为猫的两只眼睛及鼻头的关键点。预定地点为猫的生活习惯的执行地点,每个预定地点与一个猫的生活习惯相匹配;预定地点可以为猫砂盆、猫粮盆、猫水盆、猫爬架、猫窝等,分别对应猫的生活习惯为排泄、进食、喝水、休闲、睡觉,采集正脸图像的时间则为时间信息,在本实施例中,预定地点为猫砂盆,对应猫的生活习惯为猫的排泄,时间信息为猫进入猫砂盆时采集正脸图像的时间。In this embodiment, the key points of the cat's face are the key points of the cat's two eyes and the tip of the nose. The predetermined location is the execution location of the cat's living habits, and each predetermined location matches the living habits of a cat; the predetermined location can be a cat litter box, a cat food basin, a cat water basin, a cat climbing frame, a cat litter, etc., corresponding to The cat’s living habits are excretion, eating, drinking, leisure, and sleeping, and the time when the frontal face image is collected is the time information. In this embodiment, the predetermined location is the cat litter box, and the corresponding cat’s living habits are the cat’s excretion, The time information is the time when the frontal face image was collected when the cat entered the litter box.

猫砂盆旁可以设置摄像装置,以采集猫的正脸图像,还可以使用封闭式的猫砂盆,在封闭式的猫砂盆内设置摄像装置,这样猫进入封闭式的猫砂盆内时,由于面部要始终朝内,因此可以在对应的方向上获取猫的正脸图像。A camera device can be set next to the cat litter box to capture the cat's face image, and a closed cat litter box can also be used. , since the face is always facing inward, the frontal face image of the cat can be obtained in the corresponding direction.

在获取猫的正脸图像后,即开始对猫脸进行识别,由于猫的嘴和鼻头是相连的,在嘴和鼻头中,只用其中一个作为关键点即可,本实施例中,使用的关键点有三个,分别为鼻头以及两只眼睛的关键点。After obtaining the cat's frontal face image, the cat's face is recognized. Since the cat's mouth and nose are connected, only one of the mouth and nose can be used as a key point. In this embodiment, the There are three key points, namely the nose and the key points of the two eyes.

提取猫脸关键点后,将猫脸关键点仿射变换到固定点,预先训练的猫脸识别模型,则能够将固定点作为输入,然后输出结果,输出结果中包含了猫脸标签,因此能够根据猫脸标签判断出在猫砂盆处进行排泄的是哪只猫,从而可以记录下该只猫的生活习惯,在该实施例中,还可以将图像的采集时间作为猫的排泄时间,从而可以便于猫主人查看哪只猫在猫砂盆处进行了排泄,排泄时间是否正常,或者哪只猫没有去猫砂盆处进行排泄,而猫的排泄习惯也是生活习惯的一种,因此猫主人能够通过记录查看猫的排泄习惯是否异常,从而及时判断出猫是否生病。After extracting the key points of the cat face, the key points of the cat face are affine transformed to fixed points. The pre-trained cat face recognition model can use the fixed points as input, and then output the result. The output result contains the cat face label, so it can According to the cat face label, it is determined which cat is excreting at the litter box, so that the cat's living habits can be recorded. It is convenient for cat owners to check which cat has excreted in the litter box, whether the excretion time is normal, or which cat has not gone to the litter box for excretion, and the cat's excretion habit is also a kind of living habit, so the cat owner It is possible to check whether the cat's excretion habits are abnormal through records, so as to timely determine whether the cat is sick.

在一个实施例中,猫脸识别模型的训练方法包括:建立万量级特征库的原始人脸识别模型,原始人脸识别模型至少包括一个全连接层及一个特征层;对原始人脸识别模型进行优化;将猫脸样本数据输入原始人脸识别模型进行训练,得到能够识别猫脸的猫脸识别模型,猫脸样本数据至少包括猫的猫脸特征及猫脸标签。In one embodiment, the training method of the cat face recognition model includes: establishing an original face recognition model with a feature library of tens of thousands, the original face recognition model including at least one fully connected layer and one feature layer; Carry out optimization; input the cat face sample data into the original face recognition model for training, and obtain a cat face recognition model capable of recognizing cat faces. The cat face sample data includes at least the cat face features and cat face labels of cats.

在该实施例中,使用的原始人脸模型,可以使用现有技术中任意的一种相关模型,例如残差网络模型、Mobilenetv3等网络模型,原始人脸识模型经过训练后为猫脸识别模型,而万量级的特征库能够确保猫脸识别模型进行特征提取的能力,通过对原始人脸模型进行优化,则能够提升原始人脸模型的性能,从而在后续使用猫脸样本数据进行训练时,能够训练出性能更加优越的猫脸识别模型。In this embodiment, the original face model used can use any relevant model in the prior art, such as residual network model, Mobilenetv3 and other network models, and the original face recognition model is a cat face recognition model after training , and the feature library of tens of thousands can ensure the ability of the cat face recognition model to perform feature extraction. By optimizing the original face model, the performance of the original face model can be improved, so that the cat face sample data can be used for subsequent training. , which can train a cat face recognition model with better performance.

在一个实施例中,对原始人脸识别模型进行优化包括:构建交叉熵损失函数;获取特征层输出的特征向量,以及分类网络输出的权重;将特征向量与权重进行L2范数归一化,以将特征向量间的距离表现为余弦相似度,完成对原始人脸识别模型的优化。In one embodiment, optimizing the original face recognition model includes: constructing a cross-entropy loss function; acquiring the feature vector output by the feature layer and the weight output by the classification network; performing L2 norm normalization on the feature vector and the weight, The optimization of the original face recognition model is completed by expressing the distance between feature vectors as cosine similarity.

将特征向量的优化方向表现为向量之间余弦相似度,能够更加清晰的表现损失值,从而更加便于原始人脸识别模型的使用和增强与其它损失函数结合后优化方向的一致性。The optimization direction of the feature vector is expressed as the cosine similarity between the vectors, which can express the loss value more clearly, which is more convenient for the use of the original face recognition model and enhances the consistency of the optimization direction after combining with other loss functions.

在该实施例中,交叉熵损失函数先输出一个概率值Pj,可用公式1表达:In this embodiment, the cross-entropy loss function first outputs a probability value P j , which can be expressed by formula 1:

Figure BDA0002966497940000061
Figure BDA0002966497940000061

其中,zj表示原始人脸识别模型计算出的特征向量与权重进行归一化的值,zj=w*x,w表示分类网络中全连接层L2范数归一化后的权重,x是特征层L2范数归一化的特征向量,K表示样本集的样本数量,j表示样本集中的第j个样本,zk表示样本集中样本真实的特征向量与权重归一化的值,zk可用样本集的真实分布模型计算得到。Among them, z j represents the normalized value of the feature vector and the weight calculated by the original face recognition model, z j =w*x, w represents the weight after the normalization of the L2 norm of the fully connected layer in the classification network, x is the eigenvector normalized by the L2 norm of the feature layer, K represents the number of samples in the sample set, j represents the jth sample in the sample set, z k represents the real eigenvector of the sample in the sample set and the normalized value of the weight, z k can be calculated using the true distribution model of the sample set.

随后交叉熵损失函数输出度量损失值,可用公式2表达:Then the cross-entropy loss function outputs the metric loss value, which can be expressed by Equation 2:

Figure BDA0002966497940000062
Figure BDA0002966497940000062

其中,

Figure BDA0002966497940000063
表示样本集的真实分布模型,p表示概率值,K表示样本集的样本数量,
Figure BDA0002966497940000064
表示第j个样本在真实分布模型中的标签值,pj表示第j个样本的概率值。in,
Figure BDA0002966497940000063
Represents the true distribution model of the sample set, p represents the probability value, K represents the number of samples in the sample set,
Figure BDA0002966497940000064
represents the label value of the jth sample in the true distribution model, and p j represents the probability value of the jth sample.

在该实施例中,交叉熵是直接衡量两个模型之间的分布差异,其中一个为原始人脸识别模型,一个为样本集的真实分布模型,使用交叉熵损失函数则是解释以原始人脸识别模型的输出与样本集的真实分布模型对样本集的解释程度,样本集的真实分布模型为常规模型,在该实施例中不再进行描述。In this embodiment, the cross-entropy directly measures the distribution difference between the two models, one of which is the original face recognition model and the other is the real distribution model of the sample set, and the cross-entropy loss function is used to explain the original face recognition model. The output of the identification model and the degree of interpretation of the sample set by the real distribution model of the sample set. The real distribution model of the sample set is a conventional model, which will not be described in this embodiment.

上述的标签值为0或1,当对应类别的预测输出越接近真实标签值,则交叉熵损失函数的值越小,识别出的结果越接近样本,即模型识别正确率越高,当对应类别的预测输出越偏离真实标签值,则交叉熵损失函数的值越大,识别出的结果越远离样本,即模型识别正确率越低。The above label value is 0 or 1. When the predicted output of the corresponding category is closer to the true label value, the value of the cross-entropy loss function is smaller, and the recognized result is closer to the sample, that is, the model recognition accuracy rate is higher. The more the predicted output deviates from the true label value, the larger the value of the cross-entropy loss function, and the farther the recognized result is from the sample, that is, the lower the model recognition accuracy rate is.

在一个实施例中,对原始人脸识别模型进行优化还包括:筛选猫脸样本数据中的困难样本,并构建三元组损失函数;利用三元组损失函数计算困难样本的余弦相似度,完成对原始人脸识别模型的优化。In one embodiment, optimizing the original face recognition model further includes: screening difficult samples in the cat face sample data, and constructing a triplet loss function; using the triplet loss function to calculate the cosine similarity of the difficult samples to complete Optimization of the original face recognition model.

在使用交叉熵损失函数后,使用三元组损失函数,能够将交叉熵损失函数不能够对困难样本进行处理的数据进行处理,从而提升训练出的猫脸识别模型的性能,在该实施例中,使用三元组损失函数对困难样本单独进行余弦相似度计算,即困难样本不再使用交叉熵损失函数进行余弦相似度计算。After using the cross-entropy loss function, the triplet loss function can be used to process the data that the cross-entropy loss function cannot process on difficult samples, thereby improving the performance of the trained cat face recognition model. In this embodiment , using the triple loss function to calculate the cosine similarity of the difficult samples separately, that is, the difficult samples no longer use the cross entropy loss function to calculate the cosine similarity.

请参阅图2,在该实施例中,依次使用交叉熵损失函数及三元组损失函数,分别进行普通样本余弦相似度计算、困难样本余弦相似度计算,从而对原始人脸识别模型进行优化,普通样本即为训练集包含的全部样本,在此过程中,由于交叉熵损失函数并无需对全连接层的权重和特征层特征进行归一化,因此当后续再使用交叉熵损失函数及基于余弦相似度的三元组损失函数时,会导致优化方向的一致性有差异。为确保这种优化方向的一致性并让原始人脸识别模型的训练能够更好的收敛,在使用交叉熵损失函数时,需将特征层得到的特征向量与全连接层的权重进行L2归一化,最终使得特征向量间的距离表现为余弦相似度。之后,选出此批猫脸样本数据中的困难样本,用三元组损失函数单独对困难样本的余弦相似度进行优化,从而使得困难样本也能够被原始人脸识别模型学习,最终使得训练出的猫脸识别模型能够适应更多情况下的猫脸图像识别。Referring to FIG. 2, in this embodiment, the cross-entropy loss function and the triplet loss function are used in turn to perform the calculation of the cosine similarity of ordinary samples and the calculation of cosine similarity of difficult samples, so as to optimize the original face recognition model, Ordinary samples are all samples contained in the training set. In this process, since the cross-entropy loss function does not need to normalize the weights and feature layer features of the fully-connected layer, when the cross-entropy loss function and cosine-based loss function are used later When using the triple loss function of similarity, it will lead to differences in the consistency of the optimization direction. In order to ensure the consistency of this optimization direction and allow the training of the original face recognition model to converge better, when using the cross entropy loss function, it is necessary to perform L2 normalization between the feature vector obtained by the feature layer and the weight of the fully connected layer. Finally, the distance between feature vectors is expressed as cosine similarity. After that, select the difficult samples in this batch of cat face sample data, and use the triple loss function to optimize the cosine similarity of the difficult samples alone, so that the difficult samples can also be learned by the original face recognition model, and finally make the training result. The cat face recognition model is able to adapt to cat face image recognition in more situations.

在一个实施例中,困难样本包括:具有相同猫脸标签,余弦相似度相差最大的N个样本数据,以及具有不同猫脸标签,余弦相似度相差最小的N个样本数据,N大于或等于二。In one embodiment, the difficult samples include: N sample data with the same cat face label and the largest difference in cosine similarity, and N sample data with different cat face labels and the smallest difference in cosine similarity, where N is greater than or equal to two .

具有相同猫脸标签,余弦相似度相差最大的N个样本数据,这样的样本数据表示同一只猫,但猫脸在不同情况下具有细微变化的情况,例如猫生病时,五官会有细微的变化,猫叫的时候鼻头及眼睛也会有相应的变化,因此在猫脸发生变化时,表现在余弦相似度上就会与正常猫脸的余弦相似度相差较大,能够将这样的样本作为正样本来让原始人脸识别模型进行学习,增强模型对同一猫脸内类间距的包容性。N sample data with the same cat face label and the largest difference in cosine similarity. Such sample data represent the same cat, but the cat face has subtle changes in different situations. For example, when the cat is sick, the facial features will have subtle changes. , when the cat meows, the nose and eyes will also change accordingly. Therefore, when the cat face changes, the cosine similarity will be greatly different from that of the normal cat face. Such a sample can be used as a positive Samples are used to let the original face recognition model learn, and the model's inclusiveness of the class spacing within the same cat face is enhanced.

当具有不同猫脸标签,余弦相似度相差最小的N个样本数据,这样的样本数据表示不同的猫,能够将这样的样本作为负样本让原始人脸识别模型进行学习,增强模型对不同猫脸类间差异的辨别力。When there are N sample data with different cat face labels and the smallest difference in cosine similarity, such sample data represents different cats. Such samples can be used as negative samples for the original face recognition model to learn, and the model can be enhanced for different cat faces. Discrimination of between-class differences.

因此原始人脸识别模型学习正样本后,训练出的猫脸识别模型能够增加识别出图像中的同一猫脸的几率,学习负样本后,能够增加过滤出图像中不是同一猫脸的几率,从而进一步增加了猫脸识别模型识别正确的几率。Therefore, after the original face recognition model learns positive samples, the trained cat face recognition model can increase the probability of identifying the same cat face in the image, and after learning negative samples, it can increase the probability of filtering out images that are not the same cat face, so that This further increases the probability of correct recognition by the cat face recognition model.

在其他实施例中,对原始人脸识别模型进行优化还可以通过以下步骤实现:向原始人脸识别模型输入两组猫脸样本数据,并在特征层构建交叉熵损失函数、三元组损失函数;利用交叉熵损失函数计算第一组猫脸样本数据与猫脸标签的交叉熵损失值;利用原始人脸识别模型筛选出第二组猫脸样本数据中的困难样本;对困难样本使用三元组损失函数计算三元组损失值;将三元组损失值及交叉熵损失值进行相加求和,得到原始人脸识别模型的最终损失值,完成对原始人脸识别模型的优化。在该实施例中,交叉熵损失函数计算的数据量级为三元组损失函数计算的数据量级的十倍。另外,困难样本的定义与选取,与上述实施例相同,详情请参阅上述实施例,这里不再赘述。In other embodiments, the optimization of the original face recognition model can also be achieved by the following steps: inputting two groups of cat face sample data into the original face recognition model, and constructing a cross-entropy loss function and a triplet loss function in the feature layer ;Use the cross-entropy loss function to calculate the cross-entropy loss value of the first set of cat face sample data and the cat face label; use the original face recognition model to filter out the difficult samples in the second set of cat face sample data; use ternary for difficult samples The group loss function calculates the triple loss value; the triple loss value and the cross entropy loss value are added and summed to obtain the final loss value of the original face recognition model, and the optimization of the original face recognition model is completed. In this embodiment, the data magnitude calculated by the cross-entropy loss function is ten times the data magnitude calculated by the triplet loss function. In addition, the definition and selection of difficult samples are the same as the above-mentioned embodiments. For details, please refer to the above-mentioned embodiments, which will not be repeated here.

请参阅图3,在该实施例中,同时使用交叉熵损失函数及三元组损失函数,分别进行普通样本余弦相似度计算、困难样本余弦相似度计算,从而对原始人脸识别模型进行优化,普通样本即为交叉熵损失函数能够计算余弦相似度的样本,在此过程中,交叉熵损失函数与三元组损失函数同时使用,具体是基于余弦相似度的交叉熵损失函数为主损失函数,保持了猫脸识别模型与在独立交叉熵损失函数上训练的结果相似性,同时使用三元组损失函数作为辅助损失函数对困难样本进行学习,优化了原始人脸识别模型对困难样本的学习能力,使得训练出的猫脸识别模型能够更好的适用于猫的面部识别的场景。Referring to FIG. 3, in this embodiment, the cross-entropy loss function and the triplet loss function are used simultaneously to calculate the cosine similarity of common samples and the cosine similarity of difficult samples, so as to optimize the original face recognition model, Ordinary samples are samples whose cross-entropy loss function can calculate cosine similarity. In this process, cross-entropy loss function and triplet loss function are used at the same time. Specifically, the cross-entropy loss function based on cosine similarity is the main loss function. The similarity between the cat face recognition model and the results trained on the independent cross-entropy loss function is maintained, and the triple loss function is used as the auxiliary loss function to learn the difficult samples, which optimizes the learning ability of the original face recognition model for difficult samples. , so that the trained cat face recognition model can be better applied to the scene of cat face recognition.

在上述的任意实施例中,猫脸识别方法还可以包括:使用猫脸识别模型记录猫的面部特征,并将面部特征录入特征库。这样在猫进入猫砂盆后,就能够采集图像,并提取猫脸的关键点对猫进行识别,计算与已记录的面部特征的余弦相似度,从而识别出猫的标签、名称或代号等。In any of the above-mentioned embodiments, the cat face recognition method may further include: recording the facial features of the cat by using the cat face recognition model, and recording the facial features into the feature database. In this way, after the cat enters the litter box, the image can be collected, and the key points of the cat's face can be extracted to identify the cat, and the cosine similarity with the recorded facial features can be calculated to identify the cat's label, name or code.

一方面通过预先训练的猫脸识别模型来识别猫脸,可以减少毛发等对识别的影响,从而降低对猫脸识别的难度;另一方面,通过对在预定地点采集的猫的正脸图像进行猫脸识别,能够准确地识别到出现在预定地点的猫的标签,而应用至预定地点为猫的进食、喝水、排泄等地点的场景时,通过将猫的标签,以及猫在预定地点的行为信息、时间信息进行关联,并记录保存,因此能准确地记录每只猫的生活习惯。On the one hand, recognizing cat faces through a pre-trained cat face recognition model can reduce the impact of hair on recognition, thereby reducing the difficulty of cat face recognition; Cat face recognition can accurately identify the cat's label that appears at the predetermined location, and when applied to the scene where the predetermined location is where the cat eats, drinks, excretion, etc. Behavior information and time information are correlated and recorded, so the living habits of each cat can be accurately recorded.

请参阅图4,为本申请实施例提供的一种猫脸识别系统,包括:图像获取模块1、猫脸关键点提取模块2、仿射变换模块3、猫脸识别模块4、数据交互模块5及关联记录模块6。Referring to FIG. 4 , a cat face recognition system provided in an embodiment of the present application includes: an image acquisition module 1, a cat face key point extraction module 2, an affine transformation module 3, a cat face recognition module 4, and a data interaction module 5 and associated recording module 6.

图像获取模块1用于获取在预定地点采集的猫的正脸图像;The image acquisition module 1 is used to acquire the frontal face image of the cat collected at a predetermined location;

猫脸关键点提取模块2用于正脸图像进行猫脸关键点提取,猫脸关键点包括猫的两只眼睛及鼻头的关键点;仿射变换模块3用于将猫脸关键点提取模块2提取的猫脸关键点进行仿射变换,得到固定点;猫脸识别模块4用于集成预先使用猫脸样本数据训练出能够识别猫脸的猫脸识别模型,猫脸识别模型的输出结果至少包含一个猫脸标签,不同猫的猫脸标签不同;数据交互模块5用于将仿射变换模块3得到的固定点输入猫脸识别模型模块,并获取猫脸识别模型模块中的猫脸识别模型的输出结果;关联记录模块6用于获取猫在预定地点的行为信息、时间信息,并与猫脸标签关联,并记录保存。The cat face key point extraction module 2 is used to extract the cat face key points from the frontal image, and the cat face key points include the key points of the cat's two eyes and nose; the affine transformation module 3 is used to extract the cat face key points. Module 2 The extracted cat face key points are subjected to affine transformation to obtain fixed points; the cat face recognition module 4 is used to integrate the pre-trained cat face recognition model capable of recognizing cat faces using cat face sample data, and the output result of the cat face recognition model contains at least A cat face label, different cats have different cat face labels; the data interaction module 5 is used to input the fixed point obtained by the affine transformation module 3 into the cat face recognition model module, and obtain the cat face recognition model in the cat face recognition model module. Output the result; the association recording module 6 is used to obtain the behavior information and time information of the cat at the predetermined location, associate it with the cat face tag, and record and save it.

在该实施例中,猫脸关键点为猫的两只眼睛及鼻头的关键点。预定地点为猫的生活习惯的执行地点,每个预定地点与一个猫的生活习惯相匹配;预定地点可以为猫砂盆、猫粮盆、猫水盆、猫爬架、猫窝等,分别对应猫的生活习惯为排泄、进食、喝水、休闲、睡觉,采集正脸图像的时间则为时间信息,在本实施例中,预定地点为猫砂盆,对应猫的生活习惯为猫的排泄,时间信息为猫进入猫砂盆时采集正脸图像的时间。In this embodiment, the key points of the cat's face are the key points of the cat's two eyes and the tip of the nose. The predetermined location is the execution location of the cat's living habits, and each predetermined location matches the living habits of a cat; the predetermined location can be a cat litter box, a cat food basin, a cat water basin, a cat climbing frame, a cat litter, etc., corresponding to The cat’s living habits are excretion, eating, drinking, leisure, and sleeping, and the time when the frontal face image is collected is the time information. In this embodiment, the predetermined location is the cat litter box, and the corresponding cat’s living habits are the cat’s excretion, The time information is the time when the frontal face image was collected when the cat entered the litter box.

在一个实施例中,猫脸识别模块4包括:原始人脸识别模型建立单元、优化单元及训练单元;原始人脸识别模型建立单元用于建立万量级特征库的原始人脸识别模型,原始人脸识别模型至少包括一个全连接层及一个特征层;优化单元用于对原始人脸识别模型进行优化;训练单元用于将猫脸样本数据输入原始人脸识别模型进行训练,得到能够识别猫脸的猫脸识别模型,猫脸样本数据至少包括猫的猫脸特征及猫脸标签。In one embodiment, the cat face recognition module 4 includes: an original face recognition model establishment unit, an optimization unit and a training unit; the original face recognition model establishment unit is used to establish an original face recognition model of a ten-thousand-level feature library, the original face recognition model The face recognition model includes at least one fully connected layer and one feature layer; the optimization unit is used to optimize the original face recognition model; the training unit is used to input the cat face sample data into the original face recognition model for training, and get the ability to recognize cats The cat face recognition model of the face, the cat face sample data includes at least the cat face features and cat face labels of the cat.

在一个实施例中,优化单元包括:第一函数构建子单元、数据获取子单元及归一化子单元;第一函数构建子单元用于构建交叉熵损失函数;数据获取子单元用于获取特征层输出的特征向量,以及分类网络输出的权重;归一化子单元用于将特征向量与权重进行L2范数归一化,以将特征向量间的距离表现为余弦相似度,完成对原始人脸识别模型的优化。In one embodiment, the optimization unit includes: a first function construction subunit, a data acquisition subunit, and a normalization subunit; the first function construction subunit is used to construct a cross-entropy loss function; the data acquisition subunit is used to acquire features The feature vector output by the layer, and the weight output by the classification network; the normalization subunit is used to normalize the feature vector and the weight with the L2 norm, so as to express the distance between the feature vectors as cosine similarity, and complete the analysis of primitive people. Optimization of face recognition models.

在一个实施例中,优化单元还包括:第二函数构建子单元及困难样本优化单元,第二函数构建子单元用于筛选猫脸样本数据中的困难样本,并构建三元组损失函数;困难样本优化单元用于利用三元组损失函数单独计算及优化困难样本的余弦相似度,完成对原始人脸识别模型的优化。In one embodiment, the optimization unit further includes: a second function construction subunit and a difficult sample optimization unit, the second function construction subunit is used for screening difficult samples in the cat face sample data, and constructing a triplet loss function; The sample optimization unit is used to separately calculate and optimize the cosine similarity of difficult samples by using the triple loss function to complete the optimization of the original face recognition model.

在该实施例中,困难样本包括:具有相同猫脸标签,且余弦相似度相差最大的N个样本数据,以及具有不同猫脸标签,且余弦相似度相差最小的N个样本数据,N大于或等于二。In this embodiment, the difficult samples include: N sample data with the same cat face label and the largest difference in cosine similarity, and N sample data with different cat face labels and the smallest difference in cosine similarity, where N is greater than or equals two.

在其他实施例中,优化单元还可以包括:第三函数构建子单元、交叉熵损失值计算子单元、困难样本筛选子单元、三元组损失值计算子单元及求和子单元,第三函数构建子单元用于向原始人脸识别模型输入两组猫脸样本数据,并在特征层构建交叉熵损失函数、三元组损失函数;交叉熵损失值计算子单元用于利用交叉熵损失函数计算第一组猫脸样本数据与猫脸标签的交叉熵损失值;困难样本筛选子单元用于利用原始人脸识别模型筛选出第二组猫脸样本数据中的困难样本;三元组损失值计算子单元用于对困难样本使用三元组损失函数计算三元组损失值;求和子单元用于将三元组损失值及交叉熵损失值进行相加求和,得到原始人脸识别模型的最终损失值,完成对原始人脸识别模型的优化。在该实施例中,困难样本与上述实施例的定义相同,详情请参阅上述实施例,这里不再赘述。In other embodiments, the optimization unit may further include: a third function construction subunit, a cross entropy loss value calculation subunit, a difficult sample screening subunit, a triple loss value calculation subunit, and a summation subunit, the third function construction subunit The subunit is used to input two sets of cat face sample data to the original face recognition model, and constructs the cross-entropy loss function and triplet loss function in the feature layer; the cross-entropy loss value calculation sub-unit is used to use the cross-entropy loss function to calculate the first The cross entropy loss value of a set of cat face sample data and cat face labels; the difficult sample screening subunit is used to use the original face recognition model to screen out the difficult samples in the second set of cat face sample data; triple loss value calculator The unit is used to use the triple loss function to calculate the triple loss value for difficult samples; the summation subunit is used to add and sum the triple loss value and the cross entropy loss value to obtain the final loss of the original face recognition model. value to complete the optimization of the original face recognition model. In this embodiment, the definition of the difficult sample is the same as that in the above-mentioned embodiment. For details, please refer to the above-mentioned embodiment, which will not be repeated here.

另外,在该实施例中,交叉熵损失函数计算的数据量级为三元组损失函数计算的数据量级的十倍。In addition, in this embodiment, the data magnitude calculated by the cross-entropy loss function is ten times the data magnitude calculated by the triplet loss function.

本实施例提供的猫脸识别系统,一方面通过预先训练的猫脸识别模型来识别猫脸,可以减少毛发等对识别的影响,从而降低对猫脸识别的难度;另一方面,通过对在预定地点采集的猫的正脸图像进行猫脸识别,能够准确地识别到出现在预定地点的猫的标签,而应用至预定地点为猫的进食、喝水、排泄等地点的场景时,通过将猫的标签,以及猫在预定地点的行为信息、时间信息进行关联,并记录保存,因此能准确地记录每只猫的生活习惯。The cat face recognition system provided in this embodiment, on the one hand, uses a pre-trained cat face recognition model to recognize cat faces, which can reduce the influence of hair on recognition, thereby reducing the difficulty of cat face recognition; Cat face recognition is performed on the front face image of the cat collected at the predetermined location, and the label of the cat that appears at the predetermined location can be accurately recognized. The cat's label is associated with the cat's behavior information and time information at the predetermined location, and is recorded and saved, so the living habits of each cat can be accurately recorded.

请参阅图5,本申请实施例提供一种电子装置,该电子装置包括:存储器601、处理器602,存储器601上存储有可在处理器602上运行的程序,程序用于被处理器602执行时,实现前述中描述的猫脸识别方法。Referring to FIG. 5 , an embodiment of the present application provides an electronic device. The electronic device includes: a memory 601 and a processor 602 . The memory 601 stores a program that can be executed on the processor 602 , and the program is used to be executed by the processor 602 . , implement the cat face recognition method described above.

进一步的,该电子装置还包括:至少一个输入设备603以及至少一个输出设备604。Further, the electronic device further includes: at least one input device 603 and at least one output device 604 .

上述存储器601、处理器602、输入设备603以及输出设备604,通过总线605连接。The above-mentioned memory 601 , processor 602 , input device 603 and output device 604 are connected through a bus 605 .

其中,输入设备603具体可为摄像头、触控面板、物理按键或者鼠标等等。输出设备604具体可为显示屏。The input device 603 may specifically be a camera, a touch panel, a physical button, a mouse, or the like. The output device 604 may specifically be a display screen.

存储器601可以是高速随机存取记忆体(RAM,Random Access Memory)存储器,也可为非不稳定的存储器(non-volatile memory),例如磁盘存储器。存储器601用于存储一组可执行程序代码,处理器602与存储器601耦合。The memory 601 may be a high-speed random access memory (RAM, Random Access Memory) memory, or may be a non-volatile memory (non-volatile memory), such as a disk memory. Memory 601 is used to store a set of executable program codes, and processor 602 is coupled to memory 601 .

进一步的,本申请实施例还提供了一种可读存储介质,该可读存储介质可以是设置于上述各实施例中的电子装置中,该可读存储介质可以是前述中的存储器601。该可读存储介质上存储有程序,该程序用于被处理器602执行时,实现前述实施例中描述的猫脸识别方法。Further, an embodiment of the present application further provides a readable storage medium. The readable storage medium may be provided in the electronic device in each of the foregoing embodiments, and the readable storage medium may be the aforementioned memory 601 . A program is stored on the readable storage medium, and when the program is executed by the processor 602, the method for recognizing the cat face described in the foregoing embodiments is implemented.

进一步的,该可存储介质还可以是U盘、移动硬盘、只读存储器601(ROM,Read-OnlyMemory)、RAM、磁碟或者光盘等各种可以存储程序代码的介质。Further, the storable medium may also be a USB flash drive, a removable hard disk, a read-only memory 601 (ROM, Read-Only Memory), a RAM, a magnetic disk or an optical disk and other media that can store program codes.

在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个模块或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或模块的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are only illustrative. For example, the division of the modules is only a logical function division. In actual implementation, there may be other division methods. For example, multiple modules or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or modules, and may be in electrical, mechanical or other forms.

所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络模块上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, may be located in one place, or may be distributed to multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment.

另外,在本发明各个实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically alone, or two or more modules may be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware, and can also be implemented in the form of software function modules.

所述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一台·设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。If the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they may be stored in a readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the software product is stored in a storage medium, Several instructions are included to cause a device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.

需要说明的是,对于前述的各方法实施例,为了简便描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明并不受所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其它顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定都是本发明所必须的。It should be noted that, for the convenience of description, the foregoing method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence. As in accordance with the present invention, certain steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily all necessary to the present invention.

在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其它实施例的相关描述。In the above-mentioned embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.

在以上描述中,为了解释的目的而列出了各个细节。应当明白的是,本领域普通技术人员可以认识到,在不使用这些特定细节的情况下也可以实现本申请。在其它实施例中,不会对公知的结构和过程进行详细阐述,以避免不必要的细节使本申请的描述变得晦涩。因此,本申请并非旨在限于所示的实施例,而是与符合本申请所公开的原理和特征的最广范围相一致。In the above description, various details are set forth for the purpose of explanation. It is to be understood that one of ordinary skill in the art can realize that the present application may be practiced without the use of these specific details. In other instances, well-known structures and procedures have not been described in detail so as not to obscure the description of the present application with unnecessary detail. Therefore, this application is not intended to be limited to the embodiments shown but is to be accorded the widest scope consistent with the principles and features disclosed herein.

以上为对本发明所提供的一种猫脸识别方法、系统、电子装置及存储介质的描述,对于本领域的技术人员,依据本发明实施例的思想,在具体实施方式及应用范围上均会有改变之处,综上,本说明书内容不应理解为对本发明的限制。The above is a description of a cat face recognition method, system, electronic device and storage medium provided by the present invention. For those skilled in the art, based on the idea of the embodiments of the present invention, there will be Changes, in conclusion, the content of this specification should not be construed as a limitation to the present invention.

Claims (10)

1. A cat face identification method, comprising:
acquiring a front face image of a cat collected at a predetermined place;
extracting key points of a cat face from the front face image, wherein the key points of the cat face comprise key points of two eyes and a nose of a cat;
carrying out affine transformation on the key points of the cat face to obtain fixed points;
inputting the fixed point into a pre-trained cat face recognition model to obtain an output result of the cat face recognition model, wherein the output result at least comprises one cat face label, and the cat face labels of different cats are different;
and acquiring behavior information and time information of the cat in the preset place, associating the behavior information and the time information with the cat face label, and recording and storing the behavior information and the time information.
2. The cat face recognition method according to claim 1,
the training method of the cat face recognition model comprises the following steps:
establishing an original face recognition model of a ten-thousand-level feature library, wherein the original face recognition model at least comprises a full connection layer and a feature layer;
optimizing the original face recognition model;
and inputting cat face sample data into the original face recognition model for training to obtain a cat face recognition model, wherein the cat face sample data at least comprises cat face characteristics and cat face labels of cats.
3. The cat face recognition method according to claim 2,
the optimizing the original face recognition model comprises:
constructing a cross entropy loss function;
acquiring a feature vector output by the feature layer and the weight output by the classification network;
and performing L2 norm normalization on the feature vectors and the weights to express the distance between the feature vectors as cosine similarity, and completing the optimization of the original face recognition model.
4. The cat face recognition method according to claim 3,
the optimizing the original face recognition model further comprises:
screening difficult samples in the cat face sample data, and constructing a triple loss function;
and calculating the cosine similarity of the difficult samples by using the triple loss function, and finishing the optimization of the original face recognition model.
5. The cat face recognition method according to claim 4,
the difficult samples include: the method comprises the steps of providing N sample data with the same cat face label and the largest cosine similarity difference, providing N sample data with different cat face labels and the smallest cosine similarity difference, wherein N is larger than or equal to two.
6. The cat face recognition method according to claim 2,
the optimizing the original face recognition model comprises:
inputting two groups of cat face sample data into the original face recognition model, and constructing a cross entropy loss function and a triple loss function on the feature layer;
calculating a cross entropy loss value of the first group of cat face sample data and the cat face label by using the cross entropy loss function;
screening out difficult samples in the second group of cat face sample data by using the original face recognition model;
calculating a triplet loss value using the triplet loss function for the difficult sample;
and adding and summing the triple loss values and the cross entropy loss values to obtain a final loss value of the original face recognition model, and finishing the optimization of the original face recognition model.
7. The cat face recognition method according to claim 6,
the data magnitude calculated by the cross entropy loss function is ten times that calculated by the triplet loss function.
8. A cat face identification system comprising:
the image acquisition module is used for acquiring a front face image of the cat acquired at a preset place;
the face image processing module is used for processing the face image, and the face image processing module is used for processing the face image;
the affine transformation module is used for carrying out affine transformation on the cat face key points extracted by the cat face key point extraction module to obtain fixed points;
the cat face identification module is used for training a cat face identification model capable of identifying a cat face by integrating and using cat face sample data in advance, the output result of the cat face identification model at least comprises a cat face label, and the cat face labels of different cats are different;
the data interaction module is used for inputting the fixed point obtained by the affine transformation module into the cat face recognition module and obtaining an output result of a cat face recognition model in the cat face recognition module;
and the association recording module is used for acquiring behavior information and time information of the cat in the preset place, associating the behavior information and the time information with the cat face tag, and recording and storing the behavior information and the time information.
9. An electronic device, comprising: comprising a memory and a processor, said memory having stored thereon a program, characterized in that said program is adapted to carry out the method of any one of claims 1 to 7 when executed by said processor.
10. A readable storage medium on which a program is stored, the program being adapted to carry out the method of any one of claims 1 to 7 when executed by a processor.
CN202110253387.1A 2021-03-08 2021-03-08 Cat face identification method and system, electronic device and storage medium Pending CN112926479A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110253387.1A CN112926479A (en) 2021-03-08 2021-03-08 Cat face identification method and system, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110253387.1A CN112926479A (en) 2021-03-08 2021-03-08 Cat face identification method and system, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN112926479A true CN112926479A (en) 2021-06-08

Family

ID=76171995

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110253387.1A Pending CN112926479A (en) 2021-03-08 2021-03-08 Cat face identification method and system, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN112926479A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114626438A (en) * 2022-02-15 2022-06-14 深圳市优必选科技股份有限公司 Multi-cat identification method, device, cat litter machine, and computer-readable storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060088207A1 (en) * 2004-10-22 2006-04-27 Henry Schneiderman Object recognizer and detector for two-dimensional images using bayesian network based classifier
US20150085139A1 (en) * 2010-07-02 2015-03-26 Sony Corporation Image processing device and image processing method
CN109614928A (en) * 2018-12-07 2019-04-12 成都大熊猫繁育研究基地 Panda recognition algorithms based on limited training data
JP2019062436A (en) * 2017-09-27 2019-04-18 キヤノン株式会社 Image processing apparatus, image processing method, and program
CN109670440A (en) * 2018-12-14 2019-04-23 央视国际网络无锡有限公司 The recognition methods of giant panda face and device
CN109858435A (en) * 2019-01-29 2019-06-07 四川大学 A kind of lesser panda individual discrimination method based on face image
WO2020019591A1 (en) * 2018-07-27 2020-01-30 北京字节跳动网络技术有限公司 Method and device used for generating information
CN110909618A (en) * 2019-10-29 2020-03-24 泰康保险集团股份有限公司 Pet identity recognition method and device
CN110956149A (en) * 2019-12-06 2020-04-03 中国平安财产保险股份有限公司 Pet identity verification method, device and equipment and computer readable storage medium
CN112241723A (en) * 2020-10-27 2021-01-19 新疆爱华盈通信息技术有限公司 Sex and age identification method, system, electronic device and storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060088207A1 (en) * 2004-10-22 2006-04-27 Henry Schneiderman Object recognizer and detector for two-dimensional images using bayesian network based classifier
US20150085139A1 (en) * 2010-07-02 2015-03-26 Sony Corporation Image processing device and image processing method
JP2019062436A (en) * 2017-09-27 2019-04-18 キヤノン株式会社 Image processing apparatus, image processing method, and program
WO2020019591A1 (en) * 2018-07-27 2020-01-30 北京字节跳动网络技术有限公司 Method and device used for generating information
CN109614928A (en) * 2018-12-07 2019-04-12 成都大熊猫繁育研究基地 Panda recognition algorithms based on limited training data
CN109670440A (en) * 2018-12-14 2019-04-23 央视国际网络无锡有限公司 The recognition methods of giant panda face and device
CN109858435A (en) * 2019-01-29 2019-06-07 四川大学 A kind of lesser panda individual discrimination method based on face image
CN110909618A (en) * 2019-10-29 2020-03-24 泰康保险集团股份有限公司 Pet identity recognition method and device
CN110956149A (en) * 2019-12-06 2020-04-03 中国平安财产保险股份有限公司 Pet identity verification method, device and equipment and computer readable storage medium
CN112241723A (en) * 2020-10-27 2021-01-19 新疆爱华盈通信息技术有限公司 Sex and age identification method, system, electronic device and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
MAHEEN RASHID ET.AL: "Interspecies Knowledge Transfer for Facial Keypoint Detection", 2017 IEEE CONFERENCE ON COMPUTER VISION AND PATTERN RECOGNITION (CVPR) *
喜欢打酱油的老鸟: "猫脸关键点检测大赛:三种方法,轻松实现猫脸识别!", pages 5, Retrieved from the Internet <URL:https://blog.csdn.net/weixin_42137700/article/details/103723324/> *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114626438A (en) * 2022-02-15 2022-06-14 深圳市优必选科技股份有限公司 Multi-cat identification method, device, cat litter machine, and computer-readable storage medium

Similar Documents

Publication Publication Date Title
CN111291809B (en) A processing device, method and storage medium
CN107169454B (en) Face image age estimation method and device and terminal equipment thereof
CN110837846B (en) An image recognition model construction method, image recognition method and device
CN110909618B (en) Method and device for identifying identity of pet
CN112784763A (en) Expression recognition method and system based on local and overall feature adaptive fusion
CN112395979B (en) Image-based health state identification method, device, equipment and storage medium
CN108388876A (en) A kind of image-recognizing method, device and relevant device
CN110414541B (en) Method, apparatus, and computer-readable storage medium for identifying an object
CN113205017B (en) Cross-age face recognition method and device
CN107341447A (en) A kind of face verification mechanism based on depth convolutional neural networks and evidence k nearest neighbor
CN112749737A (en) Image classification method and device, electronic equipment and storage medium
CN110222718A (en) The method and device of image procossing
CN113420709A (en) Cattle face feature extraction model training method and system and cattle insurance method and system
Savio et al. Image processing for face recognition using HAAR, HOG, and SVM algorithms
CN114187632A (en) Facial expression recognition method and device based on graph convolution neural network
Srigurulekha et al. Food image recognition using CNN
Pang et al. Sheep face recognition and classification based on an improved MobilenetV2 neural network
CN109508640A (en) Crowd emotion analysis method and device and storage medium
Bouguila On multivariate binary data clustering and feature weighting
CN117011577A (en) Image classification method, apparatus, computer device and storage medium
US20240249547A1 (en) Pedestrian attribute recognition method based on a pedestrian attribute recognition system and method for training the same
CN112926479A (en) Cat face identification method and system, electronic device and storage medium
Prasetyo et al. The implementation of CNN on website-based rice plant disease detection
CN118430024B (en) A method and system for gastric part recognition in capsule gastroscopy based on deep learning
CN118628813A (en) Passive domain adaptive image recognition method based on transferable semantic knowledge

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210608