Animal identification method and device, electronic equipment and readable storage medium
Patent Information
- Application Number
- CN202611072034.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-17
- Publication Date
- 2026-10-13
AI Technical Summary
具体缺陷包括:第一,鼻纹识别对图像采集要求严苛,需要用户近距离、正对鼻部拍摄专属特写图像,采集操作繁琐,用户使用体验差;第二,该方案适配物种单一,仅可实现犬类识别,无法适用于猫咪等主流宠物,且猫咪鼻纹纹理特征稳定性差、辨识度低,无法作为独立识别依据;第三,现有鼻纹识别技术未设置前置图像质量筛选机制,对于模糊、逆光、畸变、遮挡的低质量鼻纹图像,无法有效过滤,极易造成后续特征提取失败,导致识别失效;第四,该技术缺乏活体检测机制,无法抵御照片、视频复刻等非活体攻击,识别安全性与防伪性能不足
本方案通过先确定待识别动物的动物种类,再根据种类差异,智能化地为第一种类动物和第二种类动物分别调用适配的识别模型,有效克服了现有单一模型难以兼顾不同物种差异化生物特征表达的问题。例如,针对猫等面部精细纹理丰富的动物,调用专为捕获浅层细节而改进了网络结构的第一面部识别模型;针对犬等面部纹理粗犷或鼻纹特征显著的动物,调用感受野更大、非线性表达能力更强的第二面部识别模型,或对沟壑纹理敏感的鼻纹识别模型,从而显著提升了跨物种识别的整体精度和适应性。
Smart Images

Figure CN122906718A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of biometric identification and computer vision technology, and in particular to an animal identification method, device, electronic device and readable storage medium. Background Technology
[0002] With the rapid upgrading of China's pet economy and the continuous expansion of pet ownership, the demand for intelligent and accurate pet identification is becoming increasingly urgent. Pet identification technology can be widely used in many business scenarios such as pet medical treatment, pet boarding and care, pet insurance claims, and finding lost pets. It is a core foundational technology for ensuring standardized and intelligent pet management.
[0003] Currently, the publicly available pet identification solutions mainly include RFID chip implantation identification, single facial image recognition, single nose print recognition, and general neural network fusion identification. However, practical application verification has shown that all of the above identification solutions have significant technical defects and cannot simultaneously meet the practical application requirements of high accuracy, high security, high adaptability, and ease of operation. The specific technical defects are detailed below.
[0004] One of the current mainstream identification methods is the implantation of RFID chips in pets. This method involves surgically placing an RFID chip inside the pet's body, storing the pet's unique identification data, and then using a dedicated reading device to complete the identification process. However, this method has several inherent drawbacks: First, chip implantation is an invasive procedure that can cause trauma to the pet, and there are postoperative risks such as wound infection and rejection. Second, the procurement and maintenance costs of chip implantation surgery and dedicated reading devices are high, resulting in significant costs for widespread adoption. Third, this method requires dedicated reading devices to complete identification and cannot achieve remote, contactless identification using general-purpose cameras, resulting in poor scenario adaptability and greatly limiting the application scope of the technology.
[0005] Current technologies generally employ single-face pet recognition schemes based on computer vision. This non-invasive method involves acquiring pet facial images and extracting facial features to perform feature comparison and identification. However, this approach has significant shortcomings in stability and accuracy: Firstly, pets have a high degree of freedom of movement, with large variations in head posture, such as tilting and turning, which can easily lead to missing or shifted facial image features, resulting in inaccurate feature extraction and a significant decrease in recognition accuracy. Secondly, dogs have dense facial fur, which can easily obscure key facial feature areas, further reducing the effectiveness and completeness of feature information. Furthermore, existing facial recognition models do not have differentiated designs or specific optimizations for the facial feature differences between cats and dogs. Using the same recognition model for both cats and dogs fails to adapt to the feature distribution patterns of different species, resulting in poor performance in specific recognition tasks.
[0006] To address the shortcomings of facial recognition, some existing technologies propose a single recognition scheme based on canine nasal prints. While canine nasal prints possess unique characteristics similar to human fingerprints, making them a viable basis for pet identification, this scheme has significant technical limitations and lacks universal applicability. Specific drawbacks include: First, nasal print recognition has stringent image acquisition requirements, necessitating close-up, head-on images of the nose, making the process cumbersome and resulting in a poor user experience. Second, this scheme is only applicable to dogs, not cats or other mainstream pets. Furthermore, cat nasal print textures have poor stability and low recognizability, making them unsuitable as independent identification criteria. Third, existing nasal print recognition technologies lack a pre-image quality screening mechanism, failing to effectively filter out low-quality nasal print images that are blurry, backlit, distorted, or occluded, easily leading to subsequent feature extraction failures and recognition ineffectiveness. Fourth, this technology lacks a liveness detection mechanism, making it vulnerable to attacks such as photo / video replication, resulting in insufficient security and anti-spoofing performance.
[0007] At the algorithmic model level, existing technologies generally employ the generic ArcFace network for unified feature extraction and recognition of three types of images: cat faces, dog faces, and dog nose prints. This network fails to design differentiated backbone network structures and corresponding specialized training strategies to address the textural differences among the three types of objects, resulting in mixed and insufficiently targeted feature extraction. Specifically, the model struggles to effectively preserve the subtle texture features of cat faces, while exhibiting low accuracy in extracting the horizontal groove details of dog nose prints. Ultimately, this leads to low feature differentiation among similar pets, a high mismatch rate, and a lack of layered and differentiated refined network design logic, making it difficult to guarantee recognition accuracy.
[0008] In addition, existing pet identification technologies suffer from common technical problems. On the one hand, the existing model architecture lacks a caching and reuse mechanism, requiring the complete model to be reloaded every time a recognition task is performed, resulting in low model loading efficiency and high system response latency, which cannot meet the application requirements of real-time recognition. On the other hand, existing technologies have low automation levels, requiring users to manually identify pet types and select recognition methods, which has a high operational threshold and poor usability, making it difficult for ordinary users to quickly get started and hindering the practical application of the technology.
[0009] In summary, current mainstream pet identification technologies generally suffer from multiple drawbacks, including low accuracy, poor species compatibility, insufficient anti-counterfeiting security, slow response speed, cumbersome operation, and weak practical applicability. They fail to simultaneously meet the practical application requirements of high precision, high security, high versatility, and ease of use. Therefore, the industry urgently needs to propose a new pet identification solution to address the numerous technical shortcomings of existing technologies. Summary of the Invention
[0010] To address the aforementioned technical problems, this application provides an animal identification method, apparatus, electronic device, and readable storage medium.
[0011] According to a first aspect of this application, an animal identification method is provided, the method comprising: determining the animal species to be identified; in response to the animal species being a first species, identifying the animal species using a corresponding first facial recognition model; and in response to the animal species being a second species, identifying the animal species using a corresponding nose print recognition model and / or a second facial recognition model.
[0012] In one embodiment, determining the animal species of the animal to be identified further includes: acquiring an image of the animal to be identified and retrieving a preset first detection model; using the first detection model to identify the image and determine the animal species of the animal to be identified.
[0013] In one embodiment, the first type of animal includes felines, and the second type of animal includes canines. The method further includes, after determining the animal species to be identified, performing the following steps: In response to the animal species being the first type, locating the left corner of the eye, the right corner of the eye, and the tip of the nose within the image; calculating a facial rotation angle based on the line connecting the left and right corners of the eye, and performing rotation correction on the facial region in the image based on the facial rotation angle to correct a tilted face to a standard frontal face; In response to the animal species being the second type, locating the left corner of the eye, the right corner of the eye, and the tip of the nose within the image, calculating a facial rotation angle based on the line connecting the left and right corners of the eye, and performing rotation correction on the facial region in the image based on the facial rotation angle to correct a tilted face to a standard frontal face; and / or locating the left nasal margin, the right nasal margin, and the upper nasal margin within the image, calculating a nasal wrinkle rotation angle based on the line connecting the left and right nasal margins, and using the nasal wrinkle rotation angle to correct the nasal wrinkle region.
[0014] In one embodiment, the first face recognition model is obtained by performing a first improvement on a second detection model; the second detection model includes an initial backbone network and an initial pooling layer; the initial backbone network includes four levels of residual blocks and convolutional branches connected in series; the initial pooling layer is a global average pooling layer; the first improvement includes a first improvement on the initial backbone network and an improvement on the initial pooling layer: the first improvement on the initial backbone network includes: reducing the number of channels in the third-level and fourth-level residual blocks in the initial backbone network to a preset first ratio of the original number of channels, and removing [something] from the initial backbone network. The convolutional branch includes a newly added shallow fusion branch network. The input of this shallow fusion branch network is the input of the initial backbone network. This shallow fusion branch network extracts the shallow, fine texture features of the face of the first animal species and concatenates them with the output feature map of the third-level residual block before inputting them into the fourth-level residual block for processing. The improvement to the initial pooling layer includes adding a global max-pooling layer. This global max-pooling layer is used to obtain significant extreme texture information of the feature map while simultaneously acquiring the global mean information of the feature map from the global average pooling layer, thereby enhancing the expression of key facial features of the first animal species.
[0015] In one embodiment, the second facial recognition model is obtained by performing a second improvement on the second detection model; the second improvement includes a second improvement on the initial backbone network; the second improvement on the initial backbone network includes: widening the basic channels of the residual blocks in the initial backbone network by a preset second ratio, stacking the convolutional branches in the initial backbone network multiple times, and adding a deep dilated convolution enhancement module; wherein, the input of the deep dilated convolution enhancement module is the output feature of the last-level residual block, and the deep dilated convolution enhancement module is used to expand the feature receptive field based on the output feature, extract a large range of continuous texture features of the second type of animal, so as to enhance the expression of the key facial features of the second type of animal.
[0016] In one embodiment, the nasal print recognition model is obtained by a third improvement on the second detection model; the third improvement includes adding a pre-gradient filtering preprocessing layer and a third improvement on the initial backbone network; the pre-gradient filtering preprocessing layer is used to perform sharpness detection and texture enhancement on the nasal print image of the second type of animal through a gradient enhancement algorithm; the third improvement on the initial backbone network includes: reducing the level of the residual blocks in the initial backbone network by a preset third ratio, and replacing the convolutional branches in the initial backbone network with asymmetric strip convolutions.
[0017] In one implementation, the loss head structure of the first facial recognition model is a dual-branch loss head structure, and the loss function consists of a main loss branch and an auxiliary loss branch. The main loss branch is used to increase the angular distance between the feature vectors of different first-type animal individuals, reduce the feature differences between first-type animals of the same kind, and strengthen the ability to distinguish identities. The auxiliary loss branch is used to constrain the feature distance of the fine texture of the first-type animal by introducing shallow feature regression loss, so as to avoid the loss of shallow fine texture features.
[0018] In one implementation, the loss head structure of the second face recognition model is a single loss head structure; the loss function used is to increase the inter-class angular distance of feature vectors between different second-type animals by increasing the classification interval, while compressing the intra-class distribution differences of features of the same second-type animal.
[0019] In one embodiment, the loss head structure of the nasal print recognition model is a dual-branch loss head structure, and the loss function consists of a main loss branch and an auxiliary loss branch. The main loss branch is used to increase the inter-class angular distance between nasal print feature vectors of different second-type animals and compress the intra-class differences in nasal print features of the same second-type animal. The auxiliary loss branch is used to increase the feature distance between the light and dark textures of the nasal print grooves of the second-type animals and strengthen the discriminative texture representation of the nasal print grooves.
[0020] According to a second aspect of this application, an animal identification device is provided, the device comprising: a determining module configured to determine the animal species of the animal to be identified; a responding module configured to, in response to the animal species being a first species, identify the animal using a corresponding first facial recognition model; and in response to the animal species being a second species, identify the animal using a corresponding nose print recognition model and / or a second facial recognition model.
[0021] In one embodiment, the determining module is further configured to: acquire an image of the animal to be identified and retrieve a preset first detection model; use the first detection model to identify the image and determine the animal species of the animal to be identified.
[0022] In one embodiment, the first facial recognition model is obtained by performing a first improvement on the second detection model; the first improvement includes a first improvement on the initial backbone network and an improvement on the initial pooling layer: the first improvement on the initial backbone network includes: reducing the number of channels in the third-level residual block and the fourth-level residual block in the initial backbone network to a preset first ratio of the original number of channels, removing the convolutional branches in the initial backbone network, and adding a shallow fusion branch network; wherein, the input of the shallow fusion branch network is the input of the initial backbone network, and the shallow fusion branch network is used to extract the shallow fine texture features of the face of the first type of animal, and concatenate it with the output feature map of the third-level residual block before inputting it into the fourth-level residual block for processing; the improvement on the initial pooling layer includes: adding a global max pooling layer; wherein, the global max pooling layer is used to obtain significant extreme value texture information of the feature map while the global average pooling layer obtains the global mean information of the feature map, so as to enhance the expression of the key facial features of the first type of animal.
[0023] In one embodiment, the second facial recognition model is obtained by performing a second improvement on the second detection model; the second improvement includes a second improvement on the initial backbone network; the second improvement on the initial backbone network includes: widening the basic channels of the residual blocks in the initial backbone network by a preset second ratio, stacking the convolutional branches in the initial backbone network multiple times, and adding a deep dilated convolution enhancement module; wherein, the input of the deep dilated convolution enhancement module is the output feature of the last-level residual block, and the deep dilated convolution enhancement module is used to expand the feature receptive field based on the output feature, extract a large range of continuous texture features of the second type of animal, so as to enhance the expression of the key facial features of the second type of animal.
[0024] In one embodiment, the nasal print recognition model is obtained by a third improvement on the second detection model; the third improvement includes adding a pre-gradient filtering preprocessing layer and a third improvement on the initial backbone network; the pre-gradient filtering preprocessing layer is used to perform sharpness detection and texture enhancement on the nasal print image of the second type of animal through a gradient enhancement algorithm; the third improvement on the initial backbone network includes: reducing the level of the residual blocks in the initial backbone network by a preset third ratio, and replacing the convolutional branches in the initial backbone network with asymmetric strip convolutions.
[0025] According to a third aspect of this application, an electronic device is provided, the electronic device comprising: a processor and a memory storing computer program instructions; wherein the processor executes the computer program instructions to implement the steps of the method described above.
[0026] According to a fourth aspect of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the method described above.
[0027] Compared with the prior art, the beneficial effects of this application are as follows: This solution first determines the species of the animal to be identified, and then intelligently calls appropriate recognition models for the first and second species based on species differences. This effectively overcomes the problem that existing single models cannot adequately capture the diverse biological characteristics of different species. For example, for animals with rich facial textures, such as cats, a first facial recognition model with an improved network structure specifically designed to capture shallow details is used; for animals with coarse facial textures or prominent nasal markings, such as dogs, a second facial recognition model with a larger receptive field and stronger nonlinear expression capabilities, or a nasal marking recognition model sensitive to groove textures, is used, thereby significantly improving the overall accuracy and adaptability of cross-species recognition. Attached Figure Description
[0028] To more clearly illustrate the specific embodiments of this application or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0029] Figure 1 This is a flowchart illustrating an animal identification method according to an embodiment of the present invention; Figure 2 This is a schematic diagram illustrating the image pose correction effect according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of a first facial recognition model according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of a second facial recognition model according to an embodiment of the present invention; Figure 5 This is a schematic diagram of the structure of a nose print recognition model according to an embodiment of the present invention; Figure 6 This is a schematic diagram of an animal registration process according to an embodiment of the present invention; Figure 7 This is a schematic diagram of an animal verification process according to an embodiment of the present invention; Figure 8 This is a schematic diagram of the structure of an animal identification device according to an embodiment of the present invention; Figure 9 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0030] To make the above and other features and advantages of this application clearer, the application is further described below with reference to the accompanying drawings. It should be understood that the specific embodiments given herein are for the purpose of explanation to those skilled in the art, and are exemplary only, not restrictive.
[0031] In the following description, numerous specific details are set forth to provide a thorough understanding of this application. However, it will be apparent to those skilled in the art that the specific details are not required to practice this application. In other instances, well-known steps or operations have not been described in detail to avoid obscuring this application.
[0032] The animal identification method provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.
[0033] This application provides an animal identification method, such as... Figure 1 As shown, the method includes the following steps S101-S103.
[0034] Step S101: Determine the animal species of the animal to be identified; Step S102: In response to the animal species being the first type of animal, the corresponding first facial recognition model is used to identify the animal to be identified; Step S103: In response to the animal being a second type of animal, the corresponding nose print recognition model and / or second facial recognition model are used to identify the animal.
[0035] This solution first determines the species of the animal to be identified, and then intelligently calls appropriate recognition models for the first and second species based on species differences. This effectively overcomes the problem that existing single models cannot adequately capture the diverse biological characteristics of different species. For example, for animals with rich facial textures, such as cats, a first facial recognition model with an improved network structure specifically designed to capture shallow details is used; for animals with coarse facial textures or prominent nasal markings, such as dogs, a second facial recognition model with a larger receptive field and stronger nonlinear expression capabilities, or a nasal marking recognition model sensitive to groove textures, is used, thereby significantly improving the overall accuracy and adaptability of cross-species recognition.
[0036] Specifically, in step S101, this embodiment can achieve fully automatic species classification and identification of the target animal through a preset first detection model, without the need for manual intervention in feature annotation and species judgment, resulting in a high degree of automation in the identification process. In one implementation scheme, the YOLO detection model can be preferred as the first detection model. This model has the characteristics of fast detection speed, lightweight design, and strong deployment compatibility. It can simultaneously achieve the dual functions of target localization and species classification, and can be widely adapted to animal identification needs in multiple scenarios.
[0037] The specific recognition process of the YOLO detection model is as follows: First, an image including at least part of the body (e.g., face) of the animal to be identified is acquired through an image acquisition device (e.g., smartphone camera, surveillance camera, etc.). Then, a pre-trained first detection model is invoked, and the image is input into the first detection model. The first detection model automatically extracts multi-dimensional visual features such as animal contours from the image through multi-layer convolution and pooling operations, and converts them into a fixed-dimensional one-dimensional feature vector. This feature vector is fed into a fully connected layer and a Softmax classifier, which outputs the probability that the image belongs to each preset animal species. In this embodiment, the preset species include a first type of animal and a second type of animal. Specifically, the first type of animal mainly includes felines, and the second type of animal mainly includes canines.
[0038] After determining the animal species, to improve the accuracy of subsequent identity recognition, the method in this embodiment may optionally include a step of geometric correction of the image. When the animal species is determined to be a first-category animal, the following steps are performed: Locating the key points of the animal in the image, such as the left corner of the eye, the right corner of the eye, and the tip of the nose. After obtaining the coordinates of the three key points, using the line connecting the left and right corners of the eye as a baseline, the angle between this line and the horizontal line is calculated as the facial rotation angle. Based on this facial rotation angle, a rotation correction operation is performed on the entire image or the cropped facial area to make the line connecting the eyes horizontal, thereby correcting the tilted face to a standard frontal face and effectively eliminating the interference of planar rotation on the extraction of facial features of first-category animals such as cats.
[0039] When the animal species is determined to be a second-category animal, steps 1 and / or 2 can be selectively executed depending on the specific recognition mode used (face only, nasal print only, or a fusion of both). Step 1 is facial correction: similar to the first-category animal, key points such as the left and right corners of the eyes and the tip of the nose are located, the facial rotation angle is calculated, and facial correction is completed. Step 2 is nasal print region correction: the three key points of the left, right, and upper nasal margins are located within the image. The left and right nasal margins usually refer to the outermost contour points of the nose tip, and the upper nasal margin refers to the starting point of the bridge of the nose. Using the line connecting the left and right nasal margins as a reference, the nasal print rotation angle is calculated, and this angle is used to rotate and correct the nasal region image block, resulting in a positively distributed nasal print region image, such as... Figure 2As shown. This separate correction ensures the alignment of the data input to the subsequent recognition model.
[0040] In addition, during the image cropping and correction stage, image boundaries can be protected to prevent operations from exceeding the boundaries and causing blank areas in local images.
[0041] If the animal species is classified as Category 1, the first facial recognition model is used to identify the identified Category 1 animal (e.g., a cat). The first facial recognition model can use 1.2 million images as a training dataset, covering short-haired, long-haired, and hairless cats, kittens, adult cats, and various shooting postures such as side profile, head tilt, and upward angle. It can also be equipped with dedicated data augmentation strategies, including whisker occlusion simulation, partial ear cropping, and low-light blur enhancement to recreate realistic indoor low-light shooting scenes. Simultaneously, negative sample construction follows specific rules, using only cats of different breeds to achieve inter-class differentiation, excluding irrelevant images such as dogs or nose prints.
[0042] The first facial recognition model is based on the second detection model and improved upon it. The second detection model includes an initial backbone network and initial pooling layers. The initial backbone network consists of four levels of residual blocks connected in series, along with convolutional branches: first-level residual blocks, second-level residual blocks, third-level residual blocks, and fourth-level residual blocks, as well as convolutional branches located between each level to adjust the feature map size and number of channels. The four-level residual structure is used to extract multi-level features from shallow edge textures to high-level semantic concepts. The initial pooling layer can be set as a global average pooling layer to perform averaging on the global information of the feature map, filtering out spatial redundancy.
[0043] Specifically, the first improvement includes improvements to the initial backbone network and improvements to the initial pooling layer.
[0044] The first improvement to the initial backbone network includes reducing the number of channels in both the third- and fourth-level residual blocks to a preset first proportion of the original number of channels. In one example, this first proportion is 70%. This setting moderately compresses the high-level semantic feature dimensions, preventing the network from excessively discarding shallow, fine features crucial for individual identification, such as cat fur texture and subtle color variations. Simultaneously, completely removing convolutional branches from the initial backbone network further reduces information clutter during feature map downsampling.
[0045] Additionally, a shallow fusion branch network was added. This shallow fusion branch network's input does not come from the output of the previous residual block, but directly receives the original input image from the initial backbone network—that is, the corrected standard frontal image of the first animal species. The shallow fusion branch network is a relatively lightweight convolutional network whose function is to directly operate on the original input, extracting minute texture features containing a large amount of fine high-frequency information, such as the ears, whiskers, and pupils. The feature map extracted by this shallow fusion branch network is designed to be concatenated with the output feature map of the third-level residual block (which has undergone channel reduction) along the channel dimension. The concatenated fusion feature map simultaneously contains mid-level semantic information (from the third-level residual block) and rich shallow fine texture information (from the shallow fusion branch), and is then fed together into the fourth-level residual block for further processing and integration. Because cats have small facial features and intricate fur textures, shallow fine textures are crucial for distinguishing breeds / individuals; this setup avoids losing shallow texture details.
[0046] The improvement to the initial pooling layer is reflected in the following: abandoning the single global average pooling structure, a parallel global max pooling layer is added on top of the original global average pooling layer. The global average pooling layer is responsible for capturing the global mean response of the feature channels, representing the facial texture background information; the global max pooling layer is responsible for capturing the extreme response points of each channel, accurately locking key recognizable features such as the cat's stripe ridges and color block cores. By splicing and fusing the two types of pooling features, the expression of key cat face features is strengthened, effectively adapting to complex recognition scenarios where cat faces have small undulations and frequent hair occlusion, and avoiding the loss of subtle facial markers.
[0047] The improved first facial recognition model employs a dual-branch loss head structure during training. This loss function consists of a weighted main loss branch and an auxiliary loss branch. The main loss branch can use a large-margin classification loss function such as ArcFace, primarily to increase the angular distance between feature vectors of different cat individuals (inter-class distance) while reducing the difference in feature vectors of the same cat in different images (intra-class distance), directly strengthening the ability to distinguish identities. The auxiliary loss branch is a shallow feature regression loss, such as using mean squared error loss (MSE Loss) applied to the output feature map of the shallow fusion branch network. By constraining the subtle texture features extracted by the shallow branch to maintain sufficiently close feature distances under different lighting and angles, the network is forced to retain its ability to represent subtle texture details while learning identity features. Under the joint supervision of the two loss branches, the model achieves excellent cat individual recognition accuracy. Adding a shallow feature regression loss constrains the distance between subtle facial texture features of the cat. The initial learning rate can be set to 1e-4, with 120 iterations, allowing for accurate convergence and adaptation to cat individual recognition scenarios.
[0048] See Figure 3 The complete recognition process of the first facial recognition model can be as follows: Taking a 224×224×3 RGB cat face image as input, after standardization preprocessing (normalization / centering), preliminary feature extraction is completed through a 7×7 convolution (stride 2, 64 channels) and a 3×3 max pooling (stride 2); then, it enters a shallow feature splitting branch, which is divided into a main backbone (composed of 4 levels of residual blocks: Block 1 contains 3 residual units, 64 channels; Block 2 contains 4 residual units, 128 channels; Block 3 contains 6 residual units, 192 channels <70% of the original size>; Block 4 contains 3 residual units, 256 channels <70% of the original size>) and a shallow fusion branch (after 1×1 convolution dimensionality reduction and upsampling to the original size). Figure 1 After being squared by 4, the features are concatenated to the main Block 3 output. Then, the features are further compressed through a dual-branch hybrid pooling module (global average pooling GAP + global max pooling GMP) and two 3×3 max pooling operations (step size 2). Finally, the loss head enters the dual-branch loss: the main loss head uses ArcFace Loss (margin=0.5) to optimize identity discrimination, and the auxiliary loss head uses fine texture MSELoss to enhance detail learning, outputting 512-dimensional normalized features of the cat face.
[0049] In this embodiment, the first facial recognition model improves the second detection model by reducing the number of channels in high-level residual blocks and removing side convolutional branches, thereby lowering the abstract compression ratio of the deep network on the input image and freeing up space to preserve fine features. Simultaneously, a shallow fusion branch network is innovatively added, which concatenates the shallow fine texture features directly extracted from the original image input with the mid-level feature map before feeding it into the deep network, effectively preventing the irreversible loss of shallow detail information during the forward propagation of the deep network. Combined with the added global max pooling layer, which complements the original global average pooling layer, it can simultaneously focus on the global background mean information and the local most significant extremum response of the texture, doubly enhancing the expressive ability of features such as cat faces.
[0050] After an animal is identified as belonging to the second category, the second facial recognition model, the nose print recognition model, or both models can be used simultaneously in parallel to perform the recognition operation. The recognition results from both models are then fused. In practical applications, the method of use can be flexibly selected based on the image quality of the animal to be identified: if the image contains both a clear face and nose area, both models are used simultaneously; if only a clear face image is available, the second facial recognition model is used alone; if only a clear nose image is available, the nose print recognition model is used alone. If possible, parallel recognition using both models should be prioritized, achieving high-precision pet identification by fusing facial and nose print features.
[0051] (I) Second facial recognition model The training dataset for the second facial recognition model contains up to 1.5 million images, comprehensively covering small, medium, and large dog breeds, with a focus on long-haired dogs with their mouths and noses obscured, closely matching real-world application scenarios. During the training phase, proprietary data augmentation strategies are employed, including mouth and nose hair occlusion masks and long-distance perspective zoom enhancement. Additionally, hard negative sample mining is performed on different individuals of the same breed to effectively improve the model's ability to distinguish between similar dogs.
[0052] The second facial recognition model is a second improvement on the second detection model.
[0053] The second improvement includes a second improvement to the initial backbone network, specifically including the following aspects: (1) Widen the basic channel of each residual block in the initial backbone network by a preset second ratio. For example, widen it by 1.2 times to improve the feature carrying capacity.
[0054] (2) Stack the convolutional branches in the initial backbone network multiple times. The original convolutional branch may be just a simple 3×3 convolution. Stacking the convolutional branches multiple times can achieve feature map downsampling while completing more thorough local feature fusion and retaining more effective facial features.
[0055] (3) After the last residual block (i.e., the fourth residual block after stacking and widening), a deep dilated convolution enhancement module is added. The input of this module is the output feature of the last residual block. Stacking two layers of dilated convolution (dilation=2) expands the receptive field. This allows each neuron in the deep feature map to perceive a larger area on the input image, thus capturing large-scale continuous texture features such as mottled patches and overall contour structure of canine faces very well. This large receptive field feature makes up for the shortcomings of standard convolution, which focuses on local details and lacks macro-texture correlation, and significantly enhances the expression of key facial features of the second type of animal.
[0056] Correspondingly, the loss head structure of the second face recognition model can adopt a single loss head structure. Because the core of the second face recognition model lies in capturing macroscopic and robust semantic features through wide channels and large receptive fields, unlike the cat face model which heavily relies on shallow details, the loss function focuses on the discrimination of global feature vectors. The loss function used can be ArcFace loss (margin=0.6), which directly increases the inter-class angular distance between feature vectors of different dogs by introducing an angular margin penalty term, while compressing the intra-class distribution differences of features from different photos of the same dog. The single loss head structure is simple and efficient, with fast training convergence, directly optimizing the global identity recognition capability. The initial learning rate of the model can be set to 1e-3, with 100 iterations, resulting in fast convergence and strong global discrimination ability.
[0057] See Figure 4 The complete recognition process of the second face recognition model can be summarized as follows: Taking a 224×224×3 RGB large face image as input, after standardization preprocessing (normalization / centering), initial feature extraction is completed through a 7×7 convolution (stride 2, 76 channels, widened by 1.2 times) and a 3×3 max pooling (stride 2); then, it enters a backbone network composed of 4 levels of residual blocks (Block 1 contains 3 residual units, 128 channels; Block 2 contains 4 residual units, 256 channels; Block 3 contains 6 residual units, 512 channels; Block 4 contains 3 residual units, 1024 channels); next, the receptive field is expanded through a deep dilated convolution processing module (dilation=2), and features are compressed through a single-path global average pooling (GAP), and the original 512-dimensional features are output through a fully connected layer (FC); finally, a 512-dimensional feature vector is generated through an L2 normalization layer and input into a single loss head (ArcFace). Loss (margin=0.6) optimizes identity discriminativeness, and finally outputs 512-dimensional normalized features of the large face.
[0058] In this embodiment, the second face recognition model improves the initial backbone network by widening the basic network channels and stacking the convolutional branches multiple times, which greatly enhances the basic feature extraction capacity of the model. At the same time, a deep dilated convolution enhancement module is introduced at the final stage. Through dilated convolution, the receptive field of neurons is greatly expanded without increasing too many parameters, enabling the model to better capture large-scale continuous color blocks and patterns on the canine face, thereby improving the model's recognition of canine facial structure and texture.
[0059] (II) Nasal Print Recognition Model The nose print recognition model is designed for the linear grooves and textures of canine nose prints. The training dataset consists of 800,000 high-resolution close-up images of canine nose prints. Before training, the Tenengrad algorithm was used to remove low-quality samples with a sharpness score below 900, retaining only high-quality images for training. Simultaneously, proprietary data augmentation strategies such as lateral stretching, slight lateral distortion, and strong light reflection coverage were introduced to simulate complex scenarios such as canine nose compression deformation and outdoor strong light photography, thereby improving the model's robustness.
[0060] The nose print recognition model is derived by making a third improvement to the second detection model.
[0061] The third improvement includes adding a pre-processing layer for gradient filtering and a third improvement to the initial backbone network.
[0062] The pre-gradient filtering layer is the first processing module of the nasal print recognition model. Its input is the nasal print region image obtained after the aforementioned nasal print region correction. This layer addresses the high image sharpness requirements of nasal print recognition by implementing a dedicated sharpness detection mechanism: first, it extracts the core ROI from the corrected nasal print region, selecting the central area with a height of 20%–80% and a width of 10%–90% to avoid edge noise; then, it uses the Tenengrad gradient method to calculate sharpness, employing the Sobel operator to obtain the gradients in the x and y directions, and using the average of the squared gradients as the sharpness score; subsequently, it sets a sharpness threshold T to perform image quality filtering. For blurry images with values below the threshold, it determines that the nasal print image has motion blur or is out of focus, prompting the user to re-acquire or automatically discarding the frame. Images with scores in the range (T, T+400) are retained for recognition, while simultaneously reminding the user to improve image sharpness during subsequent shooting to ensure the integrity and effectiveness of the nasal print features.
[0063] The third improvement to the initial backbone network includes the following aspects: First, the levels of the residual blocks in the initial backbone network are reduced by a preset third ratio. For example, from the original four levels, only the first three levels are retained, and the deepest fourth level is removed. This operation is based on the fact that nasal veins are essentially linear textures composed of grooves and ridges on a two-dimensional plane. Their semantic level is relatively shallow, and a deep network is unnecessary to extract high-level abstract concepts. Too many levels would increase the risk of overfitting and computational cost. Reducing the number of levels allows the model to focus more on the physical morphological features of the nasal veins.
[0064] Second, all standard convolutional branches (e.g., 3x3 convolutional kernels) in the initial backbone network are replaced with asymmetric strip convolutions. In this embodiment, a combination of 1×3 and 3×1 convolutions is preferred. This asymmetric form significantly reduces parameters and computational cost compared to 3x3 convolutions. Furthermore, its strip receptive field is naturally suitable for capturing groove textures with a clear, consistent orientation, such as nasal lines. Vertical strip convolutions are sensitive to herringbone-shaped, vertical nasal line grooves, while horizontal strip convolutions are sensitive to horizontally arranged grooves. The combination of these two approaches enables the model to achieve efficient and accurate encoding of rugged nasal line textures with extremely low computational cost.
[0065] The nasal print recognition model can also be trained using a dual-branch loss head structure. The main loss branch uses ArcFace and other losses to widen the inter-class angle between nasal print feature vectors from different dogs and compress intra-class differences. The auxiliary loss branch can use texture contrast loss, specifically designed to widen the feature distance between the light and dark textures of the nasal print grooves. Specifically, it performs contrast loss calculations on the feature maps representing the groove regions (light) and the skin surface regions (dark) output by the intermediate layer, forcing the model to encode "light texture" and "dark texture" to points far apart in the feature space, thus strengthening the discriminative texture representation of the nasal print grooves. This makes the trained model extremely sensitive to the geometric shape and depth contrast of the texture, maintaining relatively accurate individual discrimination even with interference from dust or minor scratches. The initial learning rate of the model can be set to 5e-4, with 150 iterations, slowly fitting subtle nasal print texture features with a small learning rate to ensure recognition accuracy.
[0066] See Figure 5 The complete recognition process of the nose print recognition model can be summarized as follows: Taking a 224×224×3 RGB close-up image of a dog's nose print as input, it first passes through a dedicated pre-processing layer with gradient filtering (using the Tenengrad gradient enhancement algorithm) to highlight texture details. Then, preliminary feature extraction is performed through parallel dual-channel convolution (a combination of 3×1 and 1×3 strip convolutions) and 3×3 max pooling with a stride of 2. Next, it enters a lightweight micro-residual backbone network, containing two modules: Block1-Nose and Block2-Nose (each containing two micro-residual units, and using strip convolutions instead of standard 3×3 convolutions), explicitly discarding deep Block3 and Block4 layers to achieve a micro-lightweight design. After feature extraction, it is mapped to 512-dimensional original features through global average pooling (GAP) and fully connected layers (FC), and then a standard feature vector is generated through an L2 normalization layer. Finally, joint optimization is performed through dual loss branches: the main loss uses ArcFace. Loss (margin=0.7) enhances identity recognition, and auxiliary loss introduces texture contrast loss to enhance the robustness of nose print details, ultimately outputting 512-dimensional normalized features of dog nose prints.
[0067] In this embodiment, the nasal print recognition model makes a third improvement to the initial detection model by setting a pre-gradient filtering preprocessing layer at the input end to adaptively sharpen and evaluate the clarity of the nasal print image, effectively eliminating texture degradation interference caused by motion blur or uneven lighting. The traditional square convolutional kernel in the backbone network is replaced with an asymmetric elongated convolutional kernel, which is specifically designed for efficient extraction of linear groove textures with obvious directionality, such as nasal prints. The number of network layers is reduced accordingly, making the model lighter and more focused on the core features of nasal prints, resulting in excellent recognition speed and accuracy.
[0068] This scheme uses the canine identity feature vector obtained by the second facial recognition model and / or the nose print identity feature vector obtained by the nose print recognition model to compare the similarity (such as cosine similarity) with the legal canine feature database that is pre-registered and stored in the database. If the similarity exceeds the judgment threshold, the registered identity identifier of the dog is output, and the identification is completed.
[0069] This solution designs differentiated backbone networks, differentiated training datasets, differentiated loss functions, and dedicated training parameter tuning strategies for three types of recognition objects. It achieves differentiation from three layers: the underlying network structure, training data, and training logic, which greatly improves the discrimination within the same category and the robustness against different categories.
[0070] Based on the above identification process and model structure, this embodiment also designs a complete registration and verification mechanism. The registration and verification processes will be described in detail below.
[0071] See Figure 6 The registration process includes the following: (1) Input stage: The user inputs the pet ID and pet type, and uploads images (cats need to upload 3 facial images, and dogs need to upload 3 facial images and 3 nose print images).
[0072] (2) Image preprocessing: The uploaded images are preprocessed (for each image, the YOLO algorithm is used to automatically identify the pet type in the image, locate the facial or nose texture area and key points; the detected areas are rotated and corrected).
[0073] (3) Sharpness filtering: Determine whether the image is clear. If it is not clear, throw an exception and terminate the registration process.
[0074] (4) Liveness detection: Determine whether the image is a live object. If it is not a live object, throw an exception and terminate the registration process.
[0075] (5) Feature extraction and fusion: Feature extraction and fusion processing is performed on the detected regions.
[0076] (6) Branch verification processing: Edit verification: If it is in edit mode, it must pass the edit verification; if the verification fails, an exception is thrown and the registration process is terminated. Duplicate registration check: If it is in registration mode, it must check whether there is duplicate registration; if there are similar pets, an exception is thrown and the registration process is terminated (for facial features, a higher similarity threshold is used; for nose print features, a lower similarity threshold is used).
[0077] (7) Differentiated entry: After the verification is passed, the baseline features and registration information are saved to the database.
[0078] See Figure 7The verification process specifically includes the following: (1) Input parameters: The user enters the pet ID and uploads the image to be verified.
[0079] (2) Species detection: Detect the image and determine whether it is a cat or a dog; if it is not a cat or a dog, throw an exception and terminate the verification process.
[0080] (3) Liveness detection: Determine whether the image is a live object; if it is not a live object, throw an exception and terminate the verification process.
[0081] (4) Feature extraction: Perform feature extraction based on species (cat feature extraction or dog feature extraction).
[0082] (5) Feature comparison: Load the baseline features of the pet from the database and compare them with the test features. Cosine similarity can be calculated and compared with a threshold to obtain the verification result.
[0083] (6) Verification result output: If the comparison fails, return "Verification failed". If the comparison succeeds, return "Verification successful".
[0084] To prevent attacks using photos, videos, etc., this embodiment incorporates a liveness detection mechanism: before recognition, a specialized liveness detection model is used to detect the input image, distinguishing between real live pets and forged images such as photos and screen captures; forged images are directly rejected to prevent malicious attacks and ensure system security.
[0085] This application also provides an animal identification device. Figure 8 This is a schematic diagram of an animal identification device according to an embodiment of the present invention. (Reference) Figure 8 The animal identification device 800 includes: The determination module 810 is configured to determine the animal species of the animal to be identified; The response module 820 is configured to identify the animal to be identified using a corresponding first facial recognition model in response to the animal being a first type of animal; and to identify the animal to be identified using a corresponding nose print recognition model and / or a second facial recognition model in response to the animal being a second type of animal.
[0086] In one embodiment, the determining module 810 is further configured to: acquire an image of the animal to be identified and retrieve a preset first detection model; use the first detection model to identify the image and determine the animal species of the animal to be identified.
[0087] In one embodiment, the first face recognition model is obtained by performing a first improvement on a second detection model; the second detection model includes an initial backbone network and an initial pooling layer; the initial backbone network includes four levels of residual blocks and convolutional branches connected in series; the initial pooling layer is a global average pooling layer; the first improvement includes a first improvement on the initial backbone network and an improvement on the initial pooling layer: the first improvement on the initial backbone network includes: reducing the number of channels in the third-level and fourth-level residual blocks in the initial backbone network to a preset first ratio of the original number of channels, and removing [illegible text - likely related to removing channels in the initial backbone network]. The convolutional branch includes a newly added shallow fusion branch network. The input of this shallow fusion branch network is the input of the initial backbone network. This shallow fusion branch network extracts the shallow, fine texture features of the face of the first animal species and concatenates them with the output feature map of the third-level residual block before inputting them into the fourth-level residual block for processing. The improvement to the initial pooling layer includes adding a global max-pooling layer. This global max-pooling layer is used to obtain significant extreme texture information of the feature map while simultaneously acquiring the global mean information of the feature map from the global average pooling layer, thereby enhancing the expression of key facial features of the first animal species.
[0088] In one embodiment, the second facial recognition model is obtained by performing a second improvement on the second detection model; the second improvement includes a second improvement on the initial backbone network; the second improvement on the initial backbone network includes: widening the basic channels of the residual blocks in the initial backbone network by a preset second ratio, stacking the convolutional branches in the initial backbone network multiple times, and adding a deep dilated convolution enhancement module; wherein, the input of the deep dilated convolution enhancement module is the output feature of the last-level residual block, and the deep dilated convolution enhancement module is used to expand the feature receptive field based on the output feature, extract a large range of continuous texture features of the second type of animal, so as to enhance the expression of the key facial features of the second type of animal.
[0089] In one embodiment, the nasal print recognition model is obtained by performing a third improvement on the second detection model; the third improvement includes adding a pre-gradient filtering preprocessing layer and a third improvement on the initial backbone network; the pre-gradient filtering preprocessing layer is used to perform sharpness detection and texture enhancement on the nasal print image of the second type of animal through a gradient enhancement algorithm; the third improvement on the initial backbone network includes: reducing the level of the residual blocks in the initial backbone network by a preset third ratio, and replacing the convolutional branches in the initial backbone network with asymmetric strip convolutions.
[0090] By adopting the above solution, this embodiment has the following beneficial effects: 1. Significantly improved recognition accuracy: For dogs, the recognition accuracy is improved by 32% compared to single facial recognition by fusing facial and nasal print features, solving the problems of facial hair occlusion and posture changes, with an accuracy of over 99.5%; For cats, the recognition accuracy also reaches over 98% through a specialized facial model.
[0091] 2. Highly adaptable and supports posture changes: Through a rotation correction mechanism, it supports ±45° posture changes of the pet's head, eliminating the need for users to strictly capture frontal images and significantly reducing the difficulty of shooting; the differentiated species adaptation strategy supports the recognition of both cats and dogs, covering mainstream pet types.
[0092] 3. High security and attack prevention: The liveness detection mechanism effectively prevents attacks using photos, videos, etc., and prevents identity theft; the clarity detection mechanism filters out invalid and blurry images, ensuring the reliability of recognition.
[0093] 4. High ease of use and good user experience: Automatic strategy selection means users do not need to manually select pet type and recognition method; they only need to upload images, which lowers the barrier to entry. It supports shooting with ordinary cameras, so no special equipment is required. Users can complete registration and recognition with their mobile phones, making it suitable for a wide range of applications.
[0094] 5. A three-layer differentiated model architecture and dedicated training scheme creatively distinguish the facial features of cats, dogs, and dog nose prints: a lightweight shallow fusion network for cats accurately captures subtle whisker and pupil features, reducing the confusion rate of multi-breed cat recognition by 27%; a widened deep network for dogs adapts to large-area facial occlusion, improving the recognition accuracy of long-haired dogs by 31%; (a dedicated long convolutional network for nose prints is optimized for horizontal groove textures, reducing the false recognition rate of nose print comparison by 42%; independent datasets + differentiated loss functions completely decouple the distribution of the three types of feature vectors, avoiding the problem of mutual interference between cat, dog, and nose print features, and improving the retrieval speed of multi-pet mixed databases by 35%.
[0095] It should be understood that the specific features, operations, and details described herein with respect to the methods of this application can also be similarly applied to the apparatus and system of this application, or vice versa. Furthermore, each step of the methods of this application described above can be performed by a corresponding component or unit of the apparatus or system of this application.
[0096] It should be understood that the various modules / units of the device of this application can be implemented wholly or partially through software, hardware, firmware, or a combination thereof. Each module / unit can be embedded in the processor of the electronic device in hardware or firmware form or independent of the processor, or it can be stored in the memory of the electronic device in software form for the processor to call to execute the operation of each module / unit. Each module / unit can be implemented as an independent component or module, or two or more modules / units can be implemented as a single component or module.
[0097] The embodiments of this application also provide an electronic device, such as Figure 9 As shown, the electronic device 10 includes a processor 20 and a memory 30 storing computer program instructions. The processor 20 executes the computer program instructions to implement the steps of the above-described method.
[0098] In one embodiment, the electronic device 10 may include a network interface, a communication interface, etc., connected via a system bus. The network interface and communication interface of the electronic device 10 can be used to connect and communicate with external devices via a network.
[0099] This application provides a computer-readable storage medium storing computer program instructions, which, when executed by a processor, implement the above-described method.
[0100] Those skilled in the art will understand that the method steps of this application can be performed by a computer program instructing related hardware, such as a processor. The computer program can be stored in a non-transitory computer-readable storage medium, and its execution causes the steps of this application to be performed. Depending on the context, any reference herein to memory, storage, or other media may include non-volatile or volatile memory. Examples of non-volatile memory include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), flash memory, magnetic tape, floppy disk, magneto-optical data storage device, optical data storage device, hard disk, solid-state drive, etc. Examples of volatile memory include random access memory (RAM), external cache memory, etc.
[0101] The technical features described above can be combined arbitrarily. Although not all possible combinations of these technical features are described, any combination of these technical features should be considered to be covered by this specification, provided that such combination does not contain contradictions.
[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A method for animal identification, characterized in that, The method includes: Determine the species of the animal to be identified; In response to the animal species being a first type of animal, the corresponding first facial recognition model is used to identify the animal to be identified; In response to the animal being classified as a second type of animal, the corresponding nose print recognition model and / or second facial recognition model are used to identify the animal.
2. The animal identification method according to claim 1, characterized in that, The determination of the animal species to be identified further includes: Acquire an image of the animal to be identified and retrieve the preset first detection model; The first detection model is used to identify the image and determine the species of the animal to be identified.
3. The animal identification method according to claim 2, characterized in that, The first type of animal includes felines, the second type of animal includes canines, and the method further includes, after determining the animal species of the animal to be identified, performing the following steps: In response to the animal species being the first type of animal, the positions of the left corner of the eye, the right corner of the eye, and the tip of the nose in the image are located; the facial rotation angle is calculated based on the line connecting the left corner of the eye and the right corner of the eye, and the facial area in the image is rotated and corrected according to the facial rotation angle to correct the tilted face to a standard frontal face; In response to the animal species being a second type of animal, the positions of the left corner of the eye, the right corner of the eye, and the tip of the nose in the image are located. The facial rotation angle is calculated using the line connecting the left corner of the eye and the right corner of the eye. Based on the facial rotation angle, the facial region in the image is rotated and corrected to a standard frontal face. And / or the positions of the left nasal margin, the right nasal margin, and the upper nasal margin in the image are located. The nasal wrinkle rotation angle is calculated using the line connecting the left nasal margin and the right nasal margin. The nasal wrinkle region is corrected using the nasal wrinkle rotation angle.
4. The animal identification method according to claim 1, characterized in that, The first facial recognition model is obtained by performing a first improvement on the second detection model; the second detection model includes an initial backbone network and an initial pooling layer; the initial backbone network includes four levels of residual blocks and convolutional branches connected in series; the initial pooling layer is a global average pooling layer; the first improvement includes a first improvement on the initial backbone network and an improvement on the initial pooling layer: The first improvement to the initial backbone network includes: reducing the number of channels in the third-level and fourth-level residual blocks of the initial backbone network to a preset first ratio of the original number of channels, removing the convolutional branches in the initial backbone network, and adding a shallow fusion branch network; wherein, the input of the shallow fusion branch network is the input of the initial backbone network, and the shallow fusion branch network is used to extract the shallow fine texture features of the face of the first type of animal, and concatenate it with the output feature map of the third-level residual block before inputting it into the fourth-level residual block for processing; The improvement to the initial pooling layer includes: adding a global max pooling layer; wherein, the global max pooling layer is used to obtain significant extreme value texture information of the feature map while the global average pooling layer obtains the global mean information of the feature map, so as to enhance the expression of key facial features of the first type of animal.
5. The animal identification method according to claim 4, characterized in that, The second facial recognition model is obtained by performing a second improvement on the second detection model; the second improvement includes a second improvement on the initial backbone network; The second improvement to the initial backbone network includes: widening the basic channels of the residual blocks in the initial backbone network by a preset second ratio, stacking the convolutional branches in the initial backbone network multiple times, and adding a deep dilated convolution enhancement module; wherein, the input of the deep dilated convolution enhancement module is the output feature of the last-level residual block, and the deep dilated convolution enhancement module is used to expand the feature receptive field based on the output feature, extract a large range of continuous texture features of the second type of animal, so as to enhance the expression of key facial features of the second type of animal.
6. The animal identification method according to claim 4, characterized in that, The nose print recognition model is obtained by making a third improvement to the second detection model; the third improvement includes adding a pre-processing layer of gradient filtering and a third improvement to the initial backbone network; The pre-gradient filtering preprocessing layer is used to perform sharpness detection and texture enhancement on the nose print image of the second type of animal using a gradient enhancement algorithm; The third improvement to the initial backbone network includes: reducing the number of levels of the residual blocks in the initial backbone network by a preset third ratio, and replacing the convolutional branches in the initial backbone network with asymmetric strip convolutions.
7. The pet animal identification method according to claim 4, characterized in that, The loss head structure of the first face recognition model is a two-branch loss head structure, and the loss function consists of a main loss branch and an auxiliary loss branch; The main loss branch is used to increase the angular distance between the feature vectors of different first-type animal individuals, reduce the feature differences between first-type animals of the same kind, and strengthen the ability to distinguish identities. The auxiliary loss branch is used to constrain the feature distance of the fine texture of the first type of animal by introducing shallow feature regression loss, so as to avoid the loss of shallow fine texture features.
8. The animal identification method according to claim 5, characterized in that, The loss head structure of the second face recognition model is a single loss head structure; the loss function used is to increase the inter-class angular distance of feature vectors between different second-type animals by increasing the classification interval, while compressing the intra-class distribution differences of features of the same second-type animal.
9. The animal identification method according to claim 6, characterized in that, The loss head structure of the nose print recognition model is a two-branch loss head structure, and the loss function consists of a main loss branch and an auxiliary loss branch. The main loss branch is used to increase the inter-class angular distance between nasal print feature vectors of different second-class animals and compress the intra-class differences in nasal print features of the same second-class animal. The auxiliary loss branch is used to widen the feature distance between the light and dark textures of the nasal grooves of the second type of animal, thereby enhancing the distinguishable texture representation of the nasal grooves.
10. An animal identification device, characterized in that, The device includes: The determination module is configured to determine the animal species of the animal to be identified; The response module is configured to identify the animal to be identified using a corresponding first facial recognition model in response to the animal being a first type of animal; and to identify the animal to be identified using a corresponding nose print recognition model and / or a second facial recognition model in response to the animal being a second type of animal.
11. The animal identification device according to claim 10, characterized in that, The determining module is further configured to: Acquire an image of the animal to be identified and retrieve the preset first detection model; The first detection model is used to identify the image and determine the species of the animal to be identified.
12. The animal identification device according to claim 11, characterized in that, The first facial recognition model is obtained by performing a first improvement on the second detection model; the second detection model includes an initial backbone network and an initial pooling layer; the initial backbone network includes four levels of residual blocks and convolutional branches connected in series; the initial pooling layer is a global average pooling layer; the first improvement includes a first improvement on the initial backbone network and an improvement on the initial pooling layer: The first improvement to the initial backbone network includes: reducing the number of channels in the third-level and fourth-level residual blocks of the initial backbone network to a preset first ratio of the original number of channels, removing the convolutional branches in the initial backbone network, and adding a shallow fusion branch network; wherein, the input of the shallow fusion branch network is the input of the initial backbone network, and the shallow fusion branch network is used to extract the shallow fine texture features of the face of the first type of animal, and concatenate it with the output feature map of the third-level residual block before inputting it into the fourth-level residual block for processing; The improvement to the initial pooling layer includes: adding a global max pooling layer; wherein, the global max pooling layer is used to obtain significant extreme value texture information of the feature map while the global average pooling layer obtains the global mean information of the feature map, so as to enhance the expression of key facial features of the first type of animal.
13. The animal identification device according to claim 12, characterized in that, The second facial recognition model is obtained by performing a second improvement on the second detection model; the second improvement includes a second improvement on the initial backbone network; The second improvement to the initial backbone network includes: widening the basic channels of the residual blocks in the initial backbone network by a preset second ratio, stacking the convolutional branches in the initial backbone network multiple times, and adding a deep dilated convolution enhancement module; wherein, the input of the deep dilated convolution enhancement module is the output feature of the last-level residual block, and the deep dilated convolution enhancement module is used to expand the feature receptive field based on the output feature, extract a large range of continuous texture features of the second type of animal, so as to enhance the expression of key facial features of the second type of animal.
14. The animal identification device according to claim 12, characterized in that, The nose print recognition model is obtained by making a third improvement to the second detection model; the third improvement includes adding a pre-processing layer of gradient filtering and a third improvement to the initial backbone network; The pre-gradient filtering preprocessing layer is used to perform sharpness detection and texture enhancement on the nose print image of the second type of animal using a gradient enhancement algorithm; The third improvement to the initial backbone network includes: reducing the number of levels of the residual blocks in the initial backbone network by a preset third ratio, and replacing the convolutional branches in the initial backbone network with asymmetric strip convolutions.
15. An electronic device, characterized in that, The electronic device includes: a processor and a memory storing computer program instructions; the processor, when executing the computer program instructions, implements the steps of the method according to any one of claims 1 to 9.
16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method as described in any one of claims 1 to 9.