Image processing method and device, image recognition method and device and storage medium
By constructing a tree structure of category feature vectors and spatial feature vectors, and updating the prototype feature vector, the problem of feature loss in the face recognition model when domain features are aligned is solved, and the model's accuracy and resistance to forged face attacks are improved. .
Patent Information
- Application Number
- CN202410566703.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-08
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-05-08
AI Technical Summary
Face recognition models will cause feature loss when aligning domain features, causing the accuracy of image recognition models to enter a bottleneck, especially when faced with forged face attacks, which are difficult to effectively resist.
By constructing a tree structure between multiple categories of prototype feature vectors and M spatial feature vectors, the prototype feature vectors and spatial feature vectors are updated to reduce feature loss during the learning process and improve the accuracy of the image recognition model.
It improves the accuracy of the image recognition model, can more effectively determine the category of the target image, enhances resistance to forged face attacks, and breaks through the accuracy bottleneck.
Smart Images

Figure CN118609178A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an image processing method, an image recognition method, a device and a storage medium. Background Art
[0002] With the continuous development of image recognition technology, face recognition is becoming more and more popular as a verification method for identity verification. As social media continues to develop, more and more users will upload their daily photos to social media, so face images and facial features have become relatively easy to obtain information. Image recognition models used for face recognition are also vulnerable to attacks by forged faces, such as photo attacks or video attacks.
[0003] In order to improve the security of the image recognition model and successfully resist these face attacks, domain adversarial or metric learning methods are used to align features of different domains to achieve liveness detection of face images used by the image recognition model. The alignment of domain features will also lead to feature loss. For example, directly aligning the feature differences introduced by the different light intensities in the photo environment will lead to the loss of brightness features or affine features, causing the accuracy of the image recognition model to reach a bottleneck. Summary of the invention
[0004] The embodiments of the present application provide an image processing method, an image recognition method, an apparatus, and a storage medium for breaking through the analysis accuracy bottleneck of the image recognition model.
[0005] In view of this, the first aspect of the present application provides an image processing method, comprising:
[0006] Acquire a feature vector of a training image, prototype feature vectors of multiple categories, and M spatial feature vectors, wherein the prototype feature vectors of multiple categories and the M spatial feature vectors form a tree structure, each of the multiple categories has one or more prototype feature vectors, the prototype feature vectors are represented by leaf nodes of the tree structure, the spatial feature vectors are represented by non-leaf nodes of the tree structure, and M is a positive integer;
[0007] According to the similarity between the feature vector of the training image and the prototype feature vectors of the multiple categories, the prototype feature vectors of the multiple categories are updated;
[0008] According to the relationship between leaf nodes and non-leaf nodes, the prototype feature vectors of multiple categories and M spatial feature vectors are updated;
[0009] The updated prototype feature vectors of multiple categories are used to determine the category of the target image.
[0010] A second aspect of the present application provides an image recognition method, comprising:
[0011] Get the target image;
[0012] The category of the target image is determined according to the similarity between the target image and prototype feature vectors of multiple categories, wherein the prototype feature vectors of multiple categories are obtained according to the image processing method provided in the first aspect.
[0013] A third aspect of the present application provides an image processing device, comprising:
[0014] An acquisition unit is used to acquire a feature vector of a training image, prototype feature vectors of multiple categories, and M spatial feature vectors, wherein the prototype feature vectors of multiple categories and the M spatial feature vectors form a tree structure, each of the multiple categories has one or more prototype feature vectors, the prototype feature vector is represented by a leaf node of the tree structure, the spatial feature vector is represented by a non-leaf node of the tree structure, and M is a positive integer;
[0015] An updating unit, used for updating the prototype feature vectors of the multiple categories according to the similarity between the feature vector of the training image and the prototype feature vectors of the multiple categories;
[0016] The updating unit is further used to update the prototype feature vectors and M spatial feature vectors of multiple categories according to the relationship between the leaf nodes and the non-leaf nodes;
[0017] The updated prototype feature vectors of multiple categories are used to determine the category of the target image.
[0018] In a possible implementation manner of the third aspect, the updating unit is specifically configured to:
[0019] According to the similarity between the feature vector of the training image and the prototype feature vectors of multiple categories, a target prototype feature vector is determined, where the target prototype feature vector is the prototype feature vector with the highest similarity to the feature vector of the training image among the prototype feature vectors of multiple categories;
[0020] The target prototype feature vector is updated by improving the similarity between the feature vector of the training image and the feature vector of the target prototype.
[0021] In a possible implementation of the third aspect, the updating unit is also used to update the prototype feature vectors of multiple categories by reducing the difference between the first similarity and the second similarity, the first similarity being the similarity between the feature vector of the training image and any one of the prototype feature vectors of the multiple categories, the second similarity being the similarity between the feature vector of the enhanced image and any one of the prototype feature vectors, and the enhanced image is obtained after data enhancement processing is performed on the training image.
[0022] In a possible implementation manner of the third aspect, the updating unit is specifically configured to:
[0023] Determine a first non-leaf node from the non-leaf nodes, the first non-leaf node represents the nearest common parent node of the leaf node of the first prototype feature vector and the leaf node representing the second prototype feature vector, the first prototype feature vector is the K nearest neighbor feature vector of the second prototype feature vector, the second prototype feature vector is the K nearest neighbor feature vector of the first prototype feature vector, the first prototype feature vector and the second prototype feature vector both belong to the prototype feature vector, and K is a positive integer;
[0024] The prototype feature vectors of multiple categories and the M spatial feature vectors are updated by improving the similarity between the first prototype feature vector and the spatial feature vector represented by the first non-leaf node.
[0025] In a possible implementation manner of the third aspect, the updating unit is further configured to:
[0026] Determine a second non-leaf node from the non-leaf nodes, the second non-leaf node being the nearest common parent node of the leaf node representing the first prototype feature vector, the leaf node representing the second prototype feature vector, and the leaf node representing the third prototype feature vector, the third prototype feature vector does not belong to the K nearest neighbor feature vectors of the first prototype feature vector, and belongs to the K nearest neighbor feature vectors of the second prototype feature vector;
[0027] The prototype feature vectors of multiple categories and M spatial feature vectors are updated by reducing at least one of the following similarities: the similarity between the first prototype feature vector and the spatial feature vector represented by the second non-leaf node, the similarity between the second prototype feature vector and the spatial feature vector represented by the second non-leaf node, and the similarity between the third prototype feature vector and the spatial feature vector represented by the first non-leaf node.
[0028] In a possible implementation of the third aspect, the updating unit is also used to update the prototype feature vectors of multiple categories and M spatial feature vectors by reducing the similarity between the prototype feature vector represented by the leaf node and the spatial feature vector represented by the root node, where the root node is one of the non-leaf nodes.
[0029] In a possible implementation of the third aspect, the updating unit is further configured to update the prototype feature vectors of multiple categories and the M spatial feature vectors by reducing the similarity between the prototype feature vectors represented by any two leaf nodes.
[0030] In a possible implementation manner of the third aspect, the updating unit is specifically configured to:
[0031] Determine a prediction probability of each non-leaf node, the prediction probability being the probability that the non-leaf node is the nearest common parent node of the leaf node representing the first prototype feature vector and the leaf node representing the second prototype feature vector;
[0032] Determine the sampling result of each non-leaf node, the sampling result is the sum of the predicted probability and the random probability;
[0033] A first non-leaf node is determined from the non-leaf nodes according to the sampling results of the non-leaf nodes.
[0034] In a possible implementation of the third aspect, the updating unit is further configured to update the feature vector of the training image and the feature vector of the enhanced image by improving the similarity between the feature vector of the enhanced image and the feature vector of the training image.
[0035] In a possible implementation manner of the third aspect, the acquisition unit is further used to acquire a true category of the training image;
[0036] The analyzing unit is further used to use a classifier to analyze the similarity between the feature vector of the training image and the prototype feature vectors of the multiple categories to determine the predicted category of the training image;
[0037] The updating unit is further used to update the classifier based on the true category of the training image and the predicted category of the training image.
[0038] The updating unit is further used to determine the predicted category of the training image according to the similarity between the feature vector of the training image and the prototype feature vectors of multiple categories.
[0039] A fourth aspect of the present application provides an image recognition device, comprising:
[0040] An acquisition unit, used for acquiring a target image;
[0041] An analysis unit is used to determine the category of the target image according to the similarity between the target image and prototype feature vectors of multiple categories, wherein the prototype feature vectors of multiple categories are obtained according to the image processing method provided in the first aspect.
[0042] A fifth aspect of the present application provides a computer device, including: a memory, a processor, and a bus system;
[0043] Wherein, the memory is used to store programs;
[0044] The processor is used to execute the program in the memory, and the processor is used to execute the above-mentioned methods according to the instructions in the program code;
[0045] The bus system is used to connect the memory and the processor so that the memory and the processor can communicate with each other.
[0046] In a sixth aspect, the present application provides a computer-readable storage medium, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the methods in the above aspects.
[0047] In a seventh aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in the above aspects.
[0048] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0049] In an embodiment of the present application, after acquiring the feature vector of the training image, the prototype feature vectors of multiple categories and M spatial feature vectors, the prototype feature vectors of multiple categories are updated according to the similarity between the feature vector of the training image and the prototype feature vectors of multiple categories, wherein the prototype feature vectors of multiple categories and the M spatial feature vectors form a tree structure, each of the multiple categories has one or more prototype feature vectors, the prototype feature vector is represented by a leaf node in the tree structure, the spatial feature vector is represented by a non-leaf node in the tree structure, M is a positive integer, and then based on the relationship between the leaf node (prototype feature vector) and the non-leaf node (space feature vector) in the tree structure, the prototype feature vectors of multiple categories and the M spatial feature vectors are updated, and the updated prototype feature vectors of multiple categories are used to determine the category of the target image. By constructing a tree structure between the prototype feature vectors of multiple categories and the M spatial feature vectors, hierarchical modeling is performed, so that the prototype feature vector learns the hierarchical relationship between different training images, forms a more effective feature space expression, and improves the generalization ability of the prototype feature vector, so as to be applicable to the determination of the category of target images of a larger number or category. And because of the effective feature space expression of the prototype feature vector, it helps to improve the accuracy of the image recognition model, thereby breaking through the accuracy bottleneck of the image recognition model. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 A schematic diagram of an application scenario of the image recognition model in an embodiment of the present application;
[0051] Figure 2 A schematic diagram of an application architecture of the image processing method in an embodiment of the present application;
[0052] Figure 3 A schematic diagram of an image processing network to be trained in an embodiment of the present application;
[0053] Figure 4 A schematic diagram of an embodiment of an image processing method in an embodiment of the present application;
[0054] Figure 5aA schematic diagram of a training image to be processed in an embodiment of the present application;
[0055] Figure 5b A schematic diagram of a training image in an embodiment of the present application;
[0056] Figure 6a A schematic diagram of an encoding module in an embodiment of the present application;
[0057] Figure 6b This is another schematic diagram of the encoding module in the embodiment of the present application;
[0058] Figure 7a A schematic diagram of a spatial feature vector in an embodiment of the present application;
[0059] Figure 7b Another schematic diagram of the spatial feature vector in the embodiment of the present application;
[0060] Figure 8 This is an embodiment of the method for detecting live faces in the embodiment of the present application;
[0061] Fig. 9 This is a schematic diagram of an embodiment of an image processing device in an embodiment of the present application;
[0062] Fig.10 A schematic diagram of an embodiment of an image recognition device in an embodiment of the present application;
[0063] Fig.11 It is a schematic diagram of another embodiment of the image processing device or image recognition device in the embodiments of the present application;
[0064] Fig.12 Schematic diagram of another embodiment of an image processing device or an image recognition device in an embodiment of the present application. DETAILED DESCRIPTION
[0065] The embodiments of the present application provide an image processing method, an image recognition method, an apparatus, and a storage medium for breaking through the analysis accuracy bottleneck of the image recognition model.
[0066] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "corresponding to" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0067] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0068] With the continuous development of image recognition technology, face liveness detection is becoming more and more popular as a verification method for identity verification. Due to the continuous development of social media, more and more users will upload their daily photos to social media. Therefore, face images and face features have become relatively easy to obtain information. In this way, the probability of face recognition systems being attacked based on face images and face features is greatly increased. In order to improve the security of face recognition systems and successfully resist these face attacks, the artificial intelligence (AI) model set in the face recognition system uses domain adversarial or metric learning methods to align different domain features to achieve liveness detection of face images used for face recognition. When the image recognition model aligns domain features, it will cause feature loss. For example, directly aligning the feature differences introduced by different light intensities in the photo environment will result in the loss of brightness features or affine features, causing the accuracy of face liveness detection to enter a bottleneck.
[0069] To address this problem, the present application proposes that, after acquiring the feature vector of a training image, prototype feature vectors of multiple categories and M spatial feature vectors, the prototype feature vectors of the multiple categories are updated according to the similarity between the feature vector of the training image and the prototype feature vectors of the multiple categories, wherein the prototype feature vectors of the multiple categories and the M spatial feature vectors form a tree structure, each of the multiple categories has one or more prototype feature vectors, the prototype feature vectors are represented by leaf nodes in the tree structure, the spatial feature vectors are represented by non-leaf nodes in the tree structure, M is a positive integer, and then based on the relationship between leaf nodes (prototype feature vectors) and non-leaf nodes (spatial feature vectors) in the tree structure, the prototype feature vectors of the multiple categories and the M spatial feature vectors are updated, and the updated prototype feature vectors of the multiple categories are used to determine the category of the target image. By constructing a tree structure between prototype feature vectors of multiple categories and M spatial feature vectors, a more effective feature space expression is formed. By utilizing the tree structure between prototype feature vectors of multiple categories and M spatial feature vectors, the prototype feature vectors of multiple categories and M spatial feature vectors are updated, which reduces the feature loss in the learning process, improves the accuracy of the image recognition model, and thus breaks through the accuracy bottleneck of the image recognition model.
[0070] The image processing method or image recognition method of each optional embodiment of the present application is implemented based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that the machines have the functions of perception, reasoning and decision-making.
[0071] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. Basic artificial intelligence technologies generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operating / interactive systems, mechatronics and other technologies. Artificial intelligence software technologies mainly include computer vision technology, speech processing technology, natural language processing technology, as well as machine learning / deep learning, autonomous driving, smart transportation and other major directions.
[0072] Computer Vision (CV) is a science that studies how to make machines "see". To put it more specifically, it refers to machine vision such as using cameras and computers to replace human eyes to identify and measure targets, and further processing graphics so that the computer processing becomes an image that is more suitable for human eye observation or transmission to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multi-dimensional data. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, optical character recognition (OCR), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, three-dimensional (3D) technology, virtual reality, augmented reality, simultaneous positioning and mapping, autonomous driving, smart transportation and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition.
[0073] The present application also involves cloud technology, which refers to a hosting technology that unifies system resources such as hardware, software, and networks within a wide area network or a local area network to achieve data computing, storage, processing, and sharing.
[0074] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of Internet behavior, each item may have its own identification mark in the future, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately, and all kinds of industry data require strong system backing support, which can only be achieved through cloud computing. The cloud technology involved in this application mainly refers to the image recognition that may be performed through the "cloud" between terminal devices or servers.
[0075] For ease of understanding, some nouns in this application are explained below.
[0076] Machine Learning (ML) is a multi-disciplinary interdisciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and teaching learning. With the research and progress of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, drones, robots, smart medical care, smart customer service, etc. It is believed that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0077] Neural Network: Artificial Neural Networks (ANN) are composed of a large number of neurons connected by adjustable connection weights. They have the characteristics of large-scale parallel processing, distributed information storage, and good self-organization and self-learning capabilities.
[0078] A convolutional layer (Conv) refers to a layered structure composed of several convolutional units in a convolutional neural network layer. A convolutional neural network (CNN) is a feedforward neural network. A convolutional neural network includes at least two neural network layers, each of which contains several neurons. Each neuron is arranged in layers. Neurons in the same layer are not connected to each other, and information between layers is transmitted in only one direction.
[0079] Back propagation: Forward propagation refers to the feedforward processing of the model, while back propagation is the opposite of forward propagation, which refers to updating the weight parameters of each layer of the model according to the output of the model. For example, if the model includes input layer, hidden layer and output layer, then forward propagation refers to processing in the order of input layer-hidden layer-output layer, and back propagation refers to updating the weight parameters of each layer in the order of output layer-hidden layer-input layer.
[0080] U-Net network: Unet is a variant of the fully convolutional network, so the U-net network structure is similar to the FCN network structure, which is divided into downsampling stage and upsampling stage. There are only convolutional layers and pooling layers in the network structure, and no fully connected layers. The shallower high-resolution layers in the network are used to solve the problem of pixel positioning, and the deeper layers are used to solve the problem of pixel classification, thereby realizing image semantic level segmentation.
[0081] DenseNet network: DenseNet is a classification network after ResNet. Its network structure is similar to ResNet at the beginning, first performing a large-scale convolution, then a pooling layer; then connecting several consecutive submodules (DenseBlock and TransitinLayer); and finally connecting a pooling and full connection. Take DenseNet-121 as an example, let's look at its network structure: DenseNet-121 consists of 121 weight layers, including 4 Denseblocks, a total of 2×(6+12+24+16)=116 weight layers, plus 1 convolution layer of initial input + 3 transition layers + the final output fully connected layer, a total of 121 layers; DenseNet-BC structure was used for training, with a compression factor of 0.5 and a growth rate of k=32; the initial convolution layer has 2k channels, and the 224×224 input image is reduced to 112×112 after 7×7 convolution; Denseblock blocks are stacked by layers, and the size of the layers is the same: two layers of 1×1+3×3 conv (each layer of conv=BN+ReLU+Conv); Denseblocks are composed of transition layers, which use 1×1 convolution layers to reduce the number of channels, and use an average pooling layer with a stride of 2 to halve the height and width. Finally, the output is obtained through global average pooling + 1000-way softmax of the fully connected layer.
[0082] ResNet network: Its network structure is usually a large-scale convolution, followed by a pooling layer; followed by several consecutive submodules (DenseBlock and TransitinLayer); and finally a pooling and full connection. Take ResNet101 as an example to explain its network structure: ResNet101 has 3+4+23+3=33 building blocks, each block has 3 layers, so there are 33x3=99 layers, plus the first layer of convolution conv1, and the final fully connected layer (for classification), a total of 99+1+1=101 layers.
[0083] Supervised learning: A training method in machine learning, which refers to the process of adjusting the parameters of the classifier using a set of samples of known categories to achieve the required performance. It is also called supervised training or teacher learning. It is a machine learning task to infer a function from labeled training data. There are usually two types of supervised learning models. The first is classified by model form: probabilistic model (ProbabilisticModel) and non-probabilistic model (Non-probabilisticModel); the second is classified by whether the distribution of observed variables is modeled: discriminative model (DiscriminativeModel) and generative model (GenerativeModel).
[0084] Semi-supervised learning: A training method in machine learning. The basic idea is to train on labeled data and then predict unlabeled data. Take the samples with the highest prediction confidence and directly define their labels. Then, include these samples in the current training samples and continue training until the model's prediction results no longer change.
[0085] Since this application involves some professional terms, these professional terms will be introduced below.
[0086] Liveness detection: A method for determining the real physiological characteristics of an object in some identity verification scenarios. In face recognition applications, liveness detection can verify whether the user is the real live person through a combination of actions such as blinking, opening the mouth, shaking the head, and nodding, using technologies such as facial key point positioning and face detection. It can effectively resist common attack methods such as photos, videos, face swapping, masks, occlusion, 3D animation, and screen reshoots, thereby helping users identify fraudulent behavior and protecting their interests.
[0087] Face attacks: Facial recognition systems can be tricked by presenting a photo, video, or 3D mask of the target person to the camera. Or by using makeup or plastic surgery. However, due to the high exposure and low cost of high-resolution digital cameras, using photos and videos is the most common type of attack.
[0088] Photo attack: A photo attack involves showing a photo of the attacked identity to the sensor of the facial recognition system.
[0089] Video Attack: An attacker can play the video of the legitimate user in any device that copies the video and then presents it to the sensor / camera.
[0090] 3D Mask Attack: In this type of attack, the attacker builds a 3D reconstruction of the face and presents it to the sensor / camera.
[0091] Other attacks: Makeup, plastic surgery, and other attacks that mimic the victim.
[0092] The method provided in this application is applied to Figure 1 The communication system shown.
[0093] Figure 1 A schematic diagram of an application scenario of the image recognition model provided in an embodiment of the present application, in which a front-end device A, a back-end device and a front-end device B are included. The front-end device A is used to obtain a target image and upload the target image to the back-end device, which runs the image recognition model proposed in the present application to obtain the category of the target image, and the back-end device sends the category of the target image to the front-end device B.
[0094] It is understandable that the front-end device A, the back-end device and the front-end device B can be the same device or different devices, and there is no limitation here.
[0095] See also Figure 2 , Figure 2It is an optional architecture diagram under an application scenario of the image processing solution provided by the embodiment of the present application. In order to realize and support an image processing solution, the terminal device 100 is connected to the server 300 through the network 200, and the server 300 is connected to the database 400. The network 200 can be a wide area network or a local area network, or a combination of the two. The client for implementing the image processing solution is deployed on the terminal device 100, wherein the client can be run on the terminal device 100 in the form of a browser, or can be run on the terminal device 100 in the form of an independent application (application, APP), etc. The specific presentation form of the client is not limited here. The server 300 involved in the present application can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal device 100 can be a smart phone, a tablet computer, a laptop, a PDA, a personal computer, a smart TV, a smart watch, a vehicle-mounted device, a wearable device, etc., but is not limited thereto. The terminal device 100 and the server 300 can be directly or indirectly connected through the network 200 by wired or wireless communication, and this application does not limit this. The number of servers 300 and terminal devices 100 is also not limited. The solution provided in this application can be completed independently by the terminal device 100, or by the server 300, or by the terminal device 100 and the server 300 in cooperation, and this application does not make specific limitations. Among them, the database 400, in short, can be regarded as an electronic filing cabinet-a place for storing electronic files, and users can add, query, update, delete, and other operations on the data in the file. The so-called "database" is a collection of data that is stored together in a certain way, can be shared with multiple users, has as little redundancy as possible, and is independent of the application program. A database management system (DBMS) is a computer software system designed for managing databases, generally with basic functions such as storage, interception, security, and backup.Database management systems can be classified according to the database models they support, such as relational, Extensible Markup Language (XML); or according to the types of computers they support, such as server clusters, mobile phones; or according to the query language used, such as Structured Query Language (SQL), XQuery; or according to performance impulse focus, such as maximum scale, maximum operating speed; or other classification methods. Regardless of the classification method used, some DBMSs can cross categories, for example, supporting multiple query languages at the same time. In the present application, the database 400 can be used to store feature vectors of training images, prototype feature vectors of multiple categories, and M spatial feature vectors or target images. Of course, the storage location of the feature vectors of training images, prototype feature vectors of multiple categories, and M spatial feature vectors or target images is not limited to the database, for example, it can also be stored in the terminal device 100, the blockchain or the distributed file system of the server 300.
[0096] In some embodiments, the server 300 and the terminal device 100 can both execute the image processing method and the image recognition method provided in the embodiments of the present application.
[0097] In this embodiment, the specific process can be as follows: the terminal device 10 obtains the feature vector of the training image, the prototype feature vectors of multiple categories and M spatial feature vectors; then the terminal device 100 stores the feature vector of the training image, the prototype feature vectors of multiple categories and M spatial feature vectors in the database 400 or in the memory of the terminal device 100; the server 300 obtains the feature vector of the training image, the prototype feature vectors of multiple categories and M spatial feature vectors from the database 400 or the terminal device 100; then, according to the similarity between the feature vector of the training image and the prototype feature vectors of multiple categories, the prototype feature vectors of multiple categories are updated; according to the relationship between leaf nodes and non-leaf nodes, the prototype feature vectors of multiple categories and M spatial feature vectors are updated; wherein the updated prototype feature vectors of multiple categories are used to determine the category of the target image. Finally, the server 300 can deploy the image recognition model to the terminal device 100 so that the terminal device 100 can call the image recognition model to classify the target image; or, the server 300 deploys the image recognition model on the image recognition server so that the image recognition server calls the image recognition model to classify the target image.
[0098] In another embodiment, the terminal device 100 independently executes the image processing method provided by the embodiment of the present application. In this embodiment, the specific process can be as follows: the terminal device 100 obtains the feature vector of the training image, the prototype feature vectors of multiple categories, and M spatial feature vectors; then the terminal device 100 updates the prototype feature vectors of multiple categories according to the similarity between the feature vector of the training image and the prototype feature vectors of multiple categories; according to the relationship between the leaf node and the non-leaf node, the prototype feature vectors of multiple categories and M spatial feature vectors are updated; wherein the updated prototype feature vectors of multiple categories are used to determine the category of the target image. Finally, the terminal device 100 can deploy the image recognition model to the terminal device 100, so that the terminal device 100 can call the image recognition model to classify the target image; or, the terminal device 100 deploys the image recognition model on the image recognition server, so that the image recognition server calls the image recognition model to classify the target image.
[0099] It can be understood that in the specific implementation of the present application, the training images or target images involved are face images and / or portrait-related data. When the above embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0100] The solution provided in this application is applied to image processing. In order to facilitate intuitive understanding of the structure of the image recognition model proposed in this application, Figure 3 Introduction to image recognition model:
[0101] The image recognition model includes an encoding module, a feature learning module and a classification module.
[0102] The encoding module is used to encode the input image processing image to obtain the feature vector of the training image, and input the feature vector of the training image into the feature learning module.
[0103] The feature learning module has multiple categories of prototype feature vectors and M spatial feature vectors built in. The feature learning module processes the feature vectors of the training image using multiple types of prototype feature vectors and M spatial feature vectors and then inputs them into the classification model. The prototype feature vectors of multiple categories and the M spatial feature vectors form a tree structure, each of the multiple categories has one or more prototype feature vectors, the prototype feature vectors are represented by the leaf nodes of the tree structure, and the spatial feature vectors are represented by the non-leaf nodes of the tree structure.
[0104] The classification module is used to determine the predicted label of the training image by using the similarity between the feature vector of the training image and the prototype feature vectors of multiple categories based on the classifier, and to update the classifier based on the predicted label of the training image and the true label of the training image.
[0105] The image processing method mentioned in this application is used to train the feature learning module and classification module in the image recognition model. In some possible scenarios, it can also be used to train the encoding module of the image recognition model, which is not limited here.
[0106] The foregoing Figure 3 In the mentioned image recognition model, three different learning objectives can be set in the feature learning module, for example:
[0107] Learning objective one is to perform feature enhancement on a training image to obtain an enhanced image, and in the process of enhancing the training image, ensure the similarity between the enhanced image and the training image by shortening the distance between the feature vector of the enhanced image and the feature vector of the training image; in addition, ensure that the distribution of the feature vector of the enhanced image in the vector space is similar to the distribution of the feature vector of the training image in the vector space by narrowing the difference between the first similarity and the second similarity, wherein the first similarity is the similarity between the feature vector of the training image and any one of the prototype feature vectors of multiple categories, and the second similarity is the similarity between the feature vector of the enhanced image and any one of the prototype feature vectors of multiple categories, and the second similarity is the similarity between the feature vector of the enhanced image and the feature vector of the training image.
[0108] The second learning goal is to improve the similarity between the feature vector of the training image and the feature vector of the target prototype, so as to shorten the distance between the feature vector of the training image and the feature vector of the target prototype. The target prototype feature vector is the prototype feature vector that is most similar to the feature vector of the training image among the prototype feature vectors of multiple categories.
[0109] Learning objective three is used to update the prototype feature vectors and M spatial feature vectors of multiple categories, thereby updating the tree structure.
[0110] The image processing method and image recognition method provided in the present application can be applied to the training of quality inspection models for industrial parts, and the quality inspection model for industrial parts is used to distinguish whether industrial parts have defects; in addition, the image processing method and image recognition method provided in the present application can also be applied to the training of image recognition models, and the image recognition model is used to distinguish whether the face in the image is a living face, and there is no limitation here.
[0111] In combination with the above introduction, the training method of the image recognition model in this application will be introduced below by taking the solution provided by this application for the training of the image recognition model as an example. When this application is applied to the face liveness detection scenario, the multiple categories in this application include two categories: liveness and non-liveness. Therefore, the following will be specifically described using the two categories of liveness and non-liveness as examples.
[0112] See also Figure 4 , an embodiment of the image recognition training method in the embodiment of the present application includes:
[0113] S101, obtaining a feature vector of a training image, prototype feature vectors of multiple categories, and M spatial feature vectors;
[0114] Among them, the feature vector of the training image can be a feature vector obtained by collecting features of the training image, the prototype feature vectors of multiple categories and M spatial feature vectors form a tree structure, each of the multiple categories has one or more prototype feature vectors, the prototype feature vector is represented by the leaf node of the tree structure, the spatial feature vector is represented by the non-leaf node of the tree structure, and M is a positive integer.
[0115] Specifically, based on the above Figure 3 In the image recognition model shown, obtaining the feature vector of the training image can be implemented in the encoding module of the image recognition model. When the encoding module obtains the feature vector of the training image, the training image can be a pre-processed image.
[0116] When the training image may be a preprocessed image, the encoding module specifically implements the following steps:
[0117] First, the training images to be processed are collected. Figure 5a After the training image to be processed is shown, the area where the face is located in the training image to be processed is determined, such as Figure 5a The area a (white frame) shown in the figure is enlarged by 1.7 times with area a as the center, and the following is obtained: Figure 5a The training image to be processed is cropped along the frame of region b, and the cropped result is reduced to a size of 255*255 to obtain the following: Figure 5b The training images shown.
[0118] It is understandable that the description of the preprocessing method here is only an example. In actual application, it should be set in combination with specific application scenarios and is not limited here.
[0119] Then, the training image is encoded to obtain the feature vector of the training image.
[0120] Among them, since the image recognition model provided in this application can perform correlation analysis based on Euclidean space and can also perform correlation analysis based on hyperbolic space, the feature vector of the training image can be a Euclidean space vector or a hyperbolic space vector, and there is no limitation here.
[0121] When the image recognition model is a model based on Euclidean space analysis, the training image is encoded as follows Figure 6a As shown, feature extraction is performed on the training image to obtain a feature vector of the training image, and the feature vector of the training image is a Euclidean space vector.
[0122] When the image recognition model is a model based on hyperbolic space analysis, the training image is encoded as follows Figure 6b As shown, after feature extraction is performed on the training image to obtain the feature vector of the training image in the Euclidean space, spatial transformation is performed on the feature vector of the training image in the Euclidean space to obtain the feature vector of the training image in the hyperbolic space.
[0123] It is understandable that the description of the preprocessing module here is only an example. In actual applications, the specific structure and execution content of the encoding module should be set in combination with the specific application scenario, and no limitation is made here.
[0124] Specifically, based on the above Figure 3 The image recognition model shown in the figure, obtaining the prototype feature vectors of multiple categories and M spatial feature vectors can also be implemented in the feature encoding module. When obtaining the prototype feature vectors of multiple categories and M spatial feature vectors, the prototype feature vectors of multiple categories and M spatial feature vectors are obtained by analyzing the feature vectors of the training image;
[0125] In addition to obtaining the prototype feature vectors of multiple categories and the M spatial feature vectors, the preset prototype feature vectors of multiple categories and the M spatial feature vectors can also be directly obtained.
[0126] The at least two preset prototype feature vectors to be trained and the M spatial feature vectors to be trained are feature vectors determined by a set of randomly set numbers of prototype feature vectors and spatial feature vectors.
[0127] Among them, the prototype feature vectors of multiple categories and M spatial feature vectors are a set of feature vectors in the target space. The prototype feature vector is expressed as Among them, i∈{0,1} indicates whether the prototype feature vector is a feature vector of a living person portrait, which can also be understood as the label of the prototype feature vector, j={0,1,…,K i-1}, representing different prototype feature vectors. The prototype feature vectors of multiple categories include |P| preset prototype feature vectors to be trained, where |P|=K=K 0 +K 1 .
[0128] The M spatial eigenvectors can be expressed as P none-leaf ={p k |k∈{0,1,…,K′-1}}. Where M is a positive integer, the M spatial feature vectors and the prototype feature vectors of multiple categories form a tree structure, the prototype feature vectors of multiple categories are the leaf nodes of the tree structure, and the M spatial feature vectors are the non-leaf nodes of the tree structure.
[0129] Specifically, in facial recognition detection, the facial recognition system can be deceived by presenting a photo, video or 3D mask of the target person to the camera. Or use makeup or plastic surgery. These photos, videos or 3D masks used to deceive facial recognition systems are all called face attacks.
[0130] For ease of understanding, please refer to Figure 7a , M spatial feature vectors and prototype feature vectors of multiple categories are introduced respectively. The M spatial feature vectors can represent the types of face attacks that have appeared in the training images. For example, the M spatial feature vectors can represent whether there is face covering in the training images (full face covering / partial covering), or the material used for face attacks in the training images (paper / silicone / electronics / plastic), or the type of face attacks in the training images (2D attacks / 3D attacks), etc., which are not limited here.
[0131] Correspondingly, the prototype feature vectors of multiple categories include Figure 7a Feature vectors for multiple images shown in .
[0132] against Figure 7a The M spatial feature vectors introduced in the previous section are set up in a tree structure to obtain Figure 7b The tree structure shown first divides the types of face attacks in the training images, then divides the materials used in the face attacks in the training images, and finally divides the training images based on whether there is face cover, and obtains a set of prototype feature vectors corresponding to multiple categories. Figure 7a and Figure 7b The face images shown in refer to the images corresponding to the prototype feature vectors.
[0133] S102, updating the prototype feature vectors of the multiple categories and the feature vectors of the training image according to the similarity between the feature vector of the training image and the prototype feature vectors of the multiple categories;
[0134] Among them, the feature vectors of the training images and the prototype feature vectors of multiple categories are both vector representations in the target space. In order to make the prototype feature vector better represent the feature vector of the training image, the prototype feature vectors of multiple categories and the feature vectors of the training images are updated by comparative learning.
[0135] Step S102 is as follows: Figure 3 The feature learning module shown in the figure is executed. The following will introduce the learning objectives 1 and 2 of the three different learning objectives in combination with the specific implementation method:
[0136] Learning Objective 1:
[0137] Optionally, while constraining the distance between the feature vector of the training image and at least two preset prototype feature vectors to be trained, an enhanced image of the training image can be introduced, and the target prototype feature vector can be updated using the feature vector of the enhanced image and the feature vector of the training image.
[0138] Exemplarily, firstly, feature enhancement is performed on the training image to obtain an enhanced image.
[0139] Among them, feature enhancement may include random cutting of the portrait corresponding to the training feature vector, brightness contrast enhancement / reduction adjustment of the portrait corresponding to the training feature vector, flipping the portrait corresponding to the training feature vector, or affine transformation of the portrait corresponding to the training feature vector, etc., and there is no limitation here.
[0140] The feature learning module to be trained can enhance the features of the training feature vector by randomly selecting feature enhancement means from the feature enhancement list, or can enhance the features of the training feature vector by selecting feature enhancement means from the feature enhancement list in sequence, or can call the code to select feature enhancement means according to certain rules to enhance the features of the training feature vector. There is no restriction here.
[0141] It is understandable that the description of the means of implementing feature enhancement here is only an example. In actual applications, the training feature vector should be enhanced in combination with specific application scenarios, and no limitation is made here.
[0142] Among them, learning goal one can ensure the similarity between the enhanced image and the training image from two different dimensions.
[0143] Dimension 1: The training images and augmented images should be similar;
[0144] Based on the fact that the enhanced image obtained after feature enhancement of the training image should be similar to the training image, the feature vector of the enhanced image should be similar to the feature vector of the training image.
[0145] Therefore, the loss function between the updated feature vector of the enhanced image and the feature vector of the training image can be expressed as:
[0146] L II-feat =||detach(z)-z aug ||2;
[0147] Among them, detach(z) represents the feature vector of the training image, z aug The feature vector representing the enhanced image.
[0148] On this basis, since the enhanced image is obtained by performing feature enhancement based on the training image, the similarity between the feature vector of the enhanced image and the feature vector of the target prototype should be consistent with the similarity between the feature vector of the training image and the feature vector of the target prototype.
[0149] In an embodiment of the present application, by limiting the similarity between the feature vector of the training image and the feature vector of the enhanced image, strong support is provided for performing feature enhancement on the training image to obtain the enhanced image while retaining the features of the training image, thereby avoiding the situation where the key features of the training image are lost during the feature enhancement process.
[0150] Dimension 2: The distribution of the feature vector of the enhanced image in space should be consistent with the distribution of the feature vector of the training image in vector space.
[0151] Based on the fact that the enhanced image obtained after feature enhancement of the training image should be similar to the training image, the similarity between the feature vector of the enhanced image and any prototype feature vector of multiple categories should be consistent with the similarity between the feature vector of the training image and any prototype feature vector of multiple categories.
[0152] That is, when the distance between the feature vector of the training image X and the prototype feature vector X is A, the distance between the feature vector of the enhanced image Y and the prototype feature vector X should be close to A.
[0153] Specifically, the similarity between the feature vector of the training image and any one of the prototype feature vectors of the multiple categories is called the first similarity, and the similarity between the feature vector of the enhanced image and any one of the prototype feature vectors of the multiple categories is called the second similarity. The feature vector of the enhanced image, the feature vector of the training image, and the target prototype feature vector are updated by updating the feature vector of the enhanced image, the feature vector of the training image, and the prototype feature vectors of the multiple categories in a manner that reduces the difference between the first similarity and the second similarity.
[0154] Its loss function can be expressed as:
[0155] LII-dist =||d H (detach(z),Ρ leaf )-d H (z aug ,P leaf )||2;
[0156] Among them, detach(z) represents the feature vector of the training image, z aug represents the feature vector of the enhanced image, Ρ leaf represents the target prototype feature vector, d H (detach(z),Ρ leaf ) represents the distance between the feature vector of the training image and any prototype feature vector of multiple categories, d H (z aug ,P leaf ) represents the distance between the feature vector of the enhanced image and any prototype feature vector of multiple categories.
[0157] It is understandable that the description of the prototype feature vectors of multiple categories and the feature vectors of training images here is only an example. In specific application scenarios, they should be set according to actual needs and are not limited here.
[0158] In an embodiment of the present application, in order to ensure that the enhanced image obtained by performing feature enhancement on the training image is similar to the training image, the prototype feature vectors of multiple categories are updated by reducing the difference between the first similarity and the second similarity, so that the feature vectors corresponding to the enhanced image and the training image are consistent in similarity with any of the prototype feature vectors of the multiple categories, thereby avoiding the situation where the enhanced image and the training image are inconsistently distributed in the vector space.
[0159] Learning Objective 2:
[0160] Specifically, in order to enable the prototype feature vector to more effectively express the feature space composed of at least two preset prototype feature vectors to be trained, the distance between the feature vector of the training image and at least two preset prototype feature vectors to be trained is constrained by using a contrastive learning method.
[0161] Exemplarily, here, taking the prototype feature vectors of multiple categories as S prototype feature vectors as an example, the distance constraint between the feature vector of the training image and at least two preset prototype feature vectors to be trained is explained, where S is an integer greater than 1.
[0162] The feature vector 1 of the training image is any feature vector in the feature vector of the training image. The similarity between the feature vector 1 of the training image and the S prototype feature vectors is calculated to obtain S first similarities, and the prototype feature vector 1 with the highest similarity to the feature vector 1 of the training image is selected as the target prototype feature vector. The feature vector 1 of the training image is similar to the prototype feature vector 1, so that the feature vector 1 of the training image and the prototype feature vector 1 are updated simultaneously in a manner of improving the similarity between the feature vector 1 of the training image and the preset prototype feature vector 1 to be trained.
[0163] Furthermore, the distance between two feature vectors is used in this application to describe the similarity between the two feature vectors, that is, d H (x, y) represents the distance between feature vector x and feature vector y, that is, the similarity between feature vector x and feature vector y, and there is no restriction here.
[0164] The loss function for updating the feature vector of the training image and the prototype feature vector can be expressed as:
[0165]
[0166] Among them, z n represents the feature vector of the training image; p ck is one of the S prototype feature vectors, and z n The preset prototype feature vector to be trained with the smallest distance is the target reduction feature vector; p ij is the j-th prototype feature vector with label i.
[0167] In an embodiment of the present application, the similarity between the feature vector of the training image and the prototype feature vectors of multiple categories is used to determine the target prototype feature vector that is most similar to the feature vector of the training image, and then the target prototype feature vector is updated by improving the similarity between the feature vector of the training image and the target prototype feature vector. The target prototype feature vector can be effectively updated with the current training feature vector, so that the updated target prototype feature vector can more accurately and effectively divide the feature vector of the training image.
[0168] Optionally, while constraining the distance between the feature vector of the training image and at least two preset prototype feature vectors to be trained, an enhanced image of the training image can be introduced, and the target prototype feature vector can be updated using the feature vector of the enhanced image and the feature vector of the training image.
[0169] Exemplarily, firstly, feature enhancement is performed on the training image to obtain an enhanced image.
[0170] Among them, feature enhancement may include random cutting of the portrait corresponding to the training feature vector, brightness contrast enhancement / reduction adjustment of the portrait corresponding to the training feature vector, flipping the portrait corresponding to the training feature vector, or affine transformation of the portrait corresponding to the training feature vector, etc., and there is no limitation here.
[0171] The feature learning module to be trained can enhance the features of the training feature vector by randomly selecting feature enhancement means from the feature enhancement list, or can enhance the features of the training feature vector by selecting feature enhancement means from the feature enhancement list in sequence, or can call the code to select feature enhancement means according to certain rules to enhance the features of the training feature vector. There is no restriction here.
[0172] It is understandable that the description of the means of implementing feature enhancement here is only an example. In actual applications, the training feature vector should be enhanced in combination with specific application scenarios, and no limitation is made here.
[0173] The enhanced image obtained after feature enhancement of the training image should be similar to the training image. Therefore, the loss function between the feature vector of the updated enhanced image and the feature vector of the training image can be expressed as:
[0174] L II-feat =||detach(z)-z aug ||2;
[0175] Among them, detach(z) represents the feature vector of the training image, z aug The feature vector representing the enhanced image.
[0176] On this basis, since the enhanced image is obtained by performing feature enhancement based on the training image, the similarity between the feature vector of the enhanced image and the feature vector of the target prototype should be consistent with the similarity between the feature vector of the training image and the feature vector of the target prototype.
[0177] In an embodiment of the present application, by improving the similarity between the feature vector of the training image and the feature vector of the enhanced image, strong support is provided for obtaining an enhanced image by performing feature enhancement on the training image while retaining the features of the training image, thereby avoiding the situation where key features of the training image are lost during the feature enhancement process.
[0178] The similarity between the feature vector of the training image and the feature vector of the target prototype is called the first similarity, and the similarity between the feature vector of the enhanced image and the feature vector of the target prototype is called the second similarity. The feature vector of the enhanced image, the feature vector of the training image, and the feature vector of the target prototype are updated in such a way as to reduce the difference between the first similarity and the second similarity.
[0179] Its loss function can be expressed as:
[0180] L II-dist =||d H (detach(z),Ρ leaf )-d H (z aug ,P leaf )||2;
[0181] Among them, detach(z) represents the feature vector of the training image, z aug represents the feature vector of the enhanced image, Ρ leaf represents the target prototype feature vector, d H (detach(z),Ρ leaf ) represents the distance between the feature vector of the training image and the feature vector of the target prototype, d H (z aug ,P leaf ) represents the distance between the feature vector of the enhanced image and the feature vector of the target prototype.
[0182] It is understandable that the description of the prototype feature vectors of multiple categories and the feature vectors of training images here is only an example. In specific application scenarios, they should be set according to actual needs and are not limited here.
[0183] In an embodiment of the present application, in order to ensure that the enhanced image obtained by feature enhancement of the training image is similar to the training image, the target prototype feature vector is updated by reducing the difference between the first similarity and the second similarity, so that the feature vectors corresponding to the enhanced image and the training image are consistent in similarity with the target prototype feature vector, thereby avoiding the situation where the enhanced image and the training image are similar to different prototype feature vectors.
[0184] S103, updating prototype feature vectors and M spatial feature vectors of multiple categories according to the relationship between leaf nodes and non-leaf nodes;
[0185] Among them, the leaf nodes are prototype feature vectors, and the non-leaf nodes are spatial feature vectors.
[0186] Step S103 is also mentioned above Figure 3The feature learning module shown in the figure is executed. The following will introduce the learning goal 3 among the three different learning goals in combination with the specific implementation method:
[0187] Since the M spatial feature vectors are used to help the prototype feature vectors of multiple categories to perform hierarchical modeling, and there is a tree structure between the prototype feature vectors of multiple categories and the M spatial feature vectors, the present application proposes to constrain the distance between the lowest common parent node between features and samples by constructing triples, so as to optimize the distance between the prototype feature vectors of multiple categories and the M spatial feature vectors.
[0188] Specifically, first select the lowest common parent node of the first prototype feature vector and the second prototype feature vector from M spatial feature vectors (non-leaf nodes) as the first spatial feature vector (first non-leaf node), wherein the first prototype feature vector and the second prototype feature vector are in positive pairs.
[0189] Exemplarily, a triple is constructed based on M spatial feature vectors and prototype feature vectors of multiple categories. For prototype feature vectors of multiple categories, it is assumed that there are N prototype feature vectors, where any two prototype feature vectors p i and p j , p i For p j The K nearest neighbor samples, and p j Also p i K nearest neighbor samples, then we think p i and p j is positive, otherwise p i and p j is a negative pair, recorded as:
[0190]
[0191] Among them, pi is the i-th prototype feature vector, p j is the jth prototype feature vector, N k (p j ) is p j The K nearest neighbor feature vectors, N k (p i ) is p i The K nearest neighbor feature vectors of .
[0192] In sampling the first spatial feature vector, the non-leaf node corresponding to the first spatial feature vector in the tree structure is the first prototype feature vector (p i ) and the second prototype eigenvector (p j) is the nearest common parent node of the corresponding leaf node in the tree structure, the first spatial feature vector is considered to be the common parent node of the first prototype feature vector and the second prototype feature vector, and the probability of sampling to obtain the common parent node of the first prototype feature vector and the second prototype feature vector can be expressed as:
[0193]
[0194] Among them, ρ represents the first spatial eigenvector, d H (p i ,ρ) represents the first prototype feature vector p i The distance from the first spatial eigenvector ρ, d H (p j ,ρ) represents the second prototype feature vector p j The distance from the first spatial eigenvector ρ.
[0195] The actual sampling result can be expressed as:
[0196]
[0197] Among them, ρ ij Indicates that for the spatial feature vector to be trained, p i and p j The lowest common parent node (preset prototype feature vector), g ij is random noise (random probability).
[0198] In the sampling process, several spatial feature vectors may be repeatedly sampled. In order to avoid the overfitting problem caused by this situation, random noise is introduced as disturbance in the sampling process to adjust the sampling probability and avoid the occurrence of overfitting.
[0199] In the embodiment of the present application, the prediction probability of each non-leaf node is introduced to achieve sampling from the prototype feature vectors corresponding to multiple non-leaf nodes. The probability that the leaf node obtained by sampling is the first leaf node is the prediction probability. Based on the risk of overfitting due to multiple samplings, multiple samplings result in the collection of several fixed non-leaf nodes. In order to avoid this situation, random probability is introduced as a disturbance, and the sum of the prediction probability of the non-leaf node and the random probability is used to indicate whether the sampling result of the non-leaf node is the first leaf node, thereby reducing the probability of overfitting during the sampling process. This avoids the situation in which only a few fixed non-leaf nodes can be collected during the sampling of the first non-leaf node, resulting in the inability to comprehensively update the M spatial feature vectors and multiple prototype feature vectors.
[0200] Based on the collected first spatial feature vector, when the first prototype feature vector and the second prototype feature vector are in positive alignment, the first spatial feature vector, the first prototype feature vector and the second prototype feature vector are updated by improving the similarity between the first prototype feature vector and the first spatial feature vector.
[0201] Furthermore, a second spatial feature vector (feature vector corresponding to the second non-leaf node) can also be collected from the M spatial feature vectors, and the non-leaf node corresponding to the second spatial feature vector in the tree structure is the nearest common parent node of the leaf nodes corresponding to the first prototype feature vector, the second prototype feature vector and the third prototype feature vector in the tree structure; the third prototype feature vector does not belong to the K nearest neighbor feature vectors of the first prototype feature vector, and the third prototype feature vector belongs to the K nearest neighbor feature vectors of the second prototype feature vector.
[0202] At this time, the prototype feature vectors of multiple categories and M spatial feature vectors can be updated by reducing at least one of the similarity between the first prototype feature vector and the second spatial feature vector, reducing the similarity between the second prototype feature vector and the second spatial feature vector, or the similarity between the third prototype feature vector and the first spatial feature vector.
[0203] It can be understood that the description here of the relationship between the third prototype feature vector and the second prototype feature vector and the first prototype feature vector is only an example. In actual applications, the third prototype feature vector and the second prototype feature vector and the third prototype feature vector and the first prototype feature vector can all be negative pairs, and there is no limitation here.
[0204] Therefore, according to the relationship between leaf nodes and non-leaf nodes, when updating the prototype feature vectors of multiple categories and M spatial feature vectors, the loss function can be expressed as:
[0205]
[0206] Among them, pi is the first prototype eigenvector, p j is the second prototype eigenvector, pi and p j are the preset prototype feature vectors that are opposite to each other, ρ ij For p i and p j The lowest common parent node (first spatial eigenvector), p k is the third prototype eigenvector, ρ ijk For p k 、p i and p j The lowest common parent node (the second spatial eigenvector) of , δ is the optimized boundary range, which is used to limit the distance between nodes.
[0207] Based on the aforementioned update of prototype feature vectors of multiple categories and M spatial feature vectors, when the solution provided in the present application is implemented in a hyperbolic space, based on the spatial characteristics of the hyperbolic space, the leaf nodes (prototype feature vectors) need to be away from the root node; in order for the preset prototype feature vector to be trained to fully represent the possible distribution of the training feature vector, it is also necessary to show the greatest possible difference between the leaf nodes (prototype feature vectors).
[0208] In an embodiment of the present application, when the first non-leaf node is the nearest common parent node of the leaf nodes corresponding to the first prototype feature vector and the second prototype feature vector, and the first prototype feature vector and the second prototype feature vector are each other's K nearest neighbor feature vectors, the similarity between the first prototype feature vector and the first non-leaf node (first spatial feature vector) is improved, providing a direction for reasonably and effectively updating the M spatial feature vectors.
[0209] Specifically, the prototype feature vectors of multiple categories and M spatial feature vectors may be updated by reducing the similarity between the prototype feature vector identified by the leaf node and the spatial feature vector represented by the root node, wherein the root node is a non-leaf node.
[0210] In an embodiment of the present application, when the second non-leaf node is the nearest common parent node of the leaf nodes corresponding to the first prototype feature vector, the second prototype feature vector and the third prototype feature vector, the first prototype feature vector and the second prototype feature vector are each other's nearest K nearest neighbor feature vectors, and the third prototype feature vector and the second prototype feature vector are not each other's nearest K nearest neighbor feature vectors, the similarity between the first prototype feature vector, the second prototype feature vector and the second leaf node is reduced, or the similarity between the third prototype feature vector and the first leaf node is reduced, so that the prototype feature vector represented by the leaf node is far away from the spatial feature vector represented by the non-leaf node, so that in the representation of prototype feature vectors of multiple categories and M spatial feature vectors, the prototype feature vector corresponding to the parent node of the leaf node among the M spatial feature vectors can have a richer expression.
[0211] The loss function for updating the prototype feature vectors of multiple categories and M spatial feature vectors can also be expressed as:
[0212]
[0213] Among them, d H (p i ,0) represents the distance between the leaf node and the root node.
[0214] In an embodiment of the present application, it is also proposed that the distance between the prototype feature vector represented by the leaf node and the spatial feature vector represented by the root node can be increased, thereby reducing the similarity between the prototype feature vector represented by the leaf node and the spatial feature vector represented by the root node, and further achieving M spatial feature vectors with richer expressions when having the same number of levels.
[0215] Specifically, the prototype feature vectors of multiple categories and the M spatial feature vectors may be updated by reducing the similarity between the prototype feature vectors identified by any two leaf nodes.
[0216] In an exemplary solution, the following formula can be used:
[0217]
[0218] Among them, d H (p i ,p j ) represents the distance between two different prototype feature vectors.
[0219] In an embodiment of the present application, it is also proposed to reduce the similarity between the prototype feature vectors represented by any two leaf nodes by increasing the distance between the prototype feature vectors represented by the leaf nodes, thereby avoiding the situation where the prototype feature vectors are too concentrated and difficult to effectively represent all the features of the training image, so that the training images can be fully classified based on the prototype feature vectors.
[0220] When updating the prototype feature vectors of multiple categories and the M spatial feature vectors, the above L II-feat , L II-dist , L PI , L PP-LCA , L P-Origin and L PP-leaf At least one loss value is achieved.
[0221] It is understandable that in the specific implementation of the training method of the image recognition model, the aforementioned multiple losses can be directly summed, or different weights can be configured for the aforementioned multiple losses to implement the training of the image recognition model, and there is no limitation here.
[0222] S104: Determine the predicted category of the training image according to the similarity between the feature vector of the training image and prototype features of multiple categories.
[0223] Step S104 is as follows: Figure 3 The classification module shown is executed, and a classifier is set in the classification model. The classifier analyzes the predicted category of the training image based on the similarity between the feature vector of the training image and the prototype features of multiple categories.
[0224] Specifically, through adaptively adjusted weights, similarity mapping is performed between the feature vector of the training image and the prototype features of multiple categories to obtain the predicted category of the training image:
[0225] Where W is the weight of the similarity between the feature vector of the training image and each prototype feature vector in the prototype feature vectors of multiple categories, S(z i ) is the similarity between the feature vector of the training image and the prototype features of multiple categories, and σ(·) is the activation function.
[0226] For example, for the feature vector Q1 of the training image, the prototype feature vectors of multiple categories include prototype feature vector Y1, prototype feature vector Y2, ..., prototype feature vector Yz. The classifier calculates the similarity between the feature vector Q1 of the training image and the prototype feature vector Y1, prototype feature vector Y2, ..., prototype feature vector Yz, respectively. W represents the weight corresponding to each prototype feature vector in the prototype feature vector Y1, prototype feature vector Y2, ..., prototype feature vector Yz. The similarity between the feature vector Q1 of the training image and the prototype feature vector Y1 is weighted using the weight corresponding to the prototype feature vector Y1. Since the prototype feature vectors of multiple categories include z prototype feature vectors, the similarity between the feature vector Q1 of the training image and the z prototype feature vectors is calculated respectively, and after weighting, the z results are summed to obtain the score corresponding to the feature vector Q1 of the training image. When the score is greater than or equal to the threshold, the training image is considered to be a living face image; when the score is less than the threshold, the training image is considered to be a non-living face image, and there is no restriction here.
[0227] Furthermore, since W can be an adaptive weight in the analysis of the predicted category of the training image, W can be modified by the following loss function:
[0228]
[0229] Among them, y i is the true category of the training image, σ(W·S(z i )) is the predicted category of the training image, σ(·) is the activation function, (x i ,y i ) is a pair consisting of the feature vector of the training image and the true category of the training image.
[0230] In an embodiment of the present application, the prediction category corresponding to the training image is determined by analyzing the similarity between multiple training images and prototype feature vectors of multiple categories, and combining the weight of each prototype feature vector in the prototype feature vectors of multiple categories. In the process of model training, the prediction category of the training image is analyzed by utilizing the similarity between the prototype feature vectors of multiple categories and the training image. In the process of determining the prototype feature vector, it is necessary to utilize the tree structure composed of multiple types of prototype feature vectors and M spatial feature vectors for analysis, and the M spatial feature vectors fully express the hierarchical structure between multiple types of prototype feature vectors, and fully utilize the hierarchical features of multiple training images, thereby effectively improving the analysis accuracy of the scheme.
[0231] Exemplarily, in a solution for face liveness detection, the true category of a training image indicates whether the training sample is a live person portrait, and the predicted category of a training image indicates whether the training sample is a live person portrait.
[0232] It is understandable that the description here of the method of determining the predicted category of a training image based on the similarity between the feature vector of the training image and the prototype features of multiple categories is only an example. In actual application, it should be set in combination with the specific application scenario and is not limited here.
[0233] In an embodiment of the present application, after acquiring the feature vector of the training image, the prototype feature vectors of multiple categories and M spatial feature vectors, the prototype feature vectors of multiple categories are updated according to the similarity between the feature vector of the training image and the prototype feature vectors of multiple categories, wherein the prototype feature vectors of multiple categories and the M spatial feature vectors form a tree structure, each of the multiple categories has one or more prototype feature vectors, the prototype feature vector is represented by a leaf node in the tree structure, the spatial feature vector is represented by a non-leaf node in the tree structure, M is a positive integer, and then based on the relationship between the leaf node (prototype feature vector) and the non-leaf node (space feature vector) in the tree structure, the prototype feature vectors of multiple categories and the M spatial feature vectors are updated, and the updated prototype feature vectors of multiple categories are used to determine the category of the target image. By constructing a tree structure between the prototype feature vectors of multiple categories and the M spatial feature vectors, a more effective feature space expression is formed, and the prototype feature vectors of multiple categories and the M spatial feature vectors are updated by using the tree structure between the prototype feature vectors of multiple categories and the M spatial feature vectors, the feature loss in the learning process is reduced, the accuracy of the image recognition model is improved, and the accuracy bottleneck of the image recognition model is broken through.
[0234] Based on the aforementioned Figure 3 The image recognition model structure shown and the aforementioned Figure 4The training method shown and the image recognition model introduced in this application can be used in different scenarios, for example, verifying the identity of the object when remotely operating banking services, verifying the identity of the payment object as a payment password, verifying the identity of the object when clocking in and out, or verifying the identity of the object in the access control system, without any limitation here.
[0235] Based on the image recognition model obtained by the above training method, the following describes the image recognition method with the terminal device as the execution subject. For details, please refer to Figure 8 As shown, an embodiment of the image recognition method includes:
[0236] S201, acquiring a target image;
[0237] The terminal device receives an image sent by a third party or an image photographed by the terminal device itself as the target image.
[0238] Optionally, the type of the target image should be consistent with the type of training samples in the image recognition model to achieve better analysis results. For example, if the image recognition model is trained with two-dimensional images, the target image is a two-dimensional image or a two-dimensional image obtained after processing; if the image recognition model is trained with three-dimensional images, the target image is a three-dimensional image or a three-dimensional image obtained after processing.
[0239] S202: Determine the category of the target image based on the similarity between the target image and prototype feature vectors of multiple categories.
[0240] The category of the target image is used to describe whether the target image is a living person portrait or a non-living person portrait.
[0241] The target image is transmitted to the input network of the image recognition model through a corresponding interface, and then the category of the target image is determined by using the similarity between the prototype feature vector in the image recognition model and the target image.
[0242] It can be understood that the image recognition model and prototype feature vector in this embodiment are based on the above Figure 4 The technical solution shown is obtained by training, and the details will not be repeated here.
[0243] The following is a detailed description of the training device for the image recognition model in this application. Fig. 9 , Fig. 9 This is a schematic diagram of an embodiment of an image processing device in an embodiment of the present application. The image processing device 20 includes:
[0244] An acquisition unit 210 is used to acquire a feature vector of a training image, prototype feature vectors of multiple categories, and M spatial feature vectors, wherein the prototype feature vectors of multiple categories and the M spatial feature vectors form a tree structure, each of the multiple categories has one or more prototype feature vectors, the prototype feature vectors are represented by leaf nodes of the tree structure, the spatial feature vectors are represented by non-leaf nodes of the tree structure, and M is a positive integer;
[0245] An updating unit 220, configured to update the prototype feature vectors of the multiple categories according to the similarity between the feature vector of the training image and the prototype feature vectors of the multiple categories;
[0246] The updating unit 220 is further used to update the prototype feature vectors and the M spatial feature vectors of the multiple categories according to the relationship between the leaf nodes and the non-leaf nodes;
[0247] The updated prototype feature vectors of multiple categories are used to determine the category of the target image.
[0248] In an embodiment of the present application, after acquiring the feature vector of a training image, prototype feature vectors of multiple categories and M spatial feature vectors, the image processing device updates the prototype feature vectors of multiple categories according to the similarity between the feature vector of the training image and the prototype feature vectors of multiple categories, wherein the prototype feature vectors of multiple categories and the M spatial feature vectors form a tree structure, each of the multiple categories has one or more prototype feature vectors, the prototype feature vectors are represented by leaf nodes in the tree structure, and the spatial feature vectors are represented by non-leaf nodes in the tree structure, M is a positive integer, and then based on the relationship between leaf nodes (prototype feature vectors) and non-leaf nodes (spatial feature vectors) in the tree structure, the prototype feature vectors of multiple categories and the M spatial feature vectors are updated, and the updated prototype feature vectors of multiple categories are used to determine the category of the target image. By constructing a tree structure between prototype feature vectors of multiple categories and M spatial feature vectors, a more effective feature space expression is formed. By utilizing the tree structure between prototype feature vectors of multiple categories and M spatial feature vectors, the prototype feature vectors of multiple categories and M spatial feature vectors are updated, which reduces the feature loss in the learning process, improves the accuracy of the image recognition model, and thus breaks through the accuracy bottleneck of the image recognition model.
[0249] Optionally, the updating unit 220 is specifically configured to:
[0250] According to the similarity between the feature vector of the training image and the prototype feature vectors of multiple categories, a target prototype feature vector is determined, where the target prototype feature vector is the prototype feature vector with the highest similarity to the feature vector of the training image among the prototype feature vectors of multiple categories;
[0251] The target prototype feature vector is updated by improving the similarity between the feature vector of the training image and the feature vector of the target prototype.
[0252] In an embodiment of the present application, the similarity between the feature vector of the training image and the prototype feature vectors of multiple categories is used to determine the target prototype feature vector that is most similar to the feature vector of the training image, and then the target prototype feature vector is updated by improving the similarity between the feature vector of the training image and the target prototype feature vector. The target prototype feature vector can be effectively updated with the current training feature vector, so that the updated target prototype feature vector can more accurately and effectively divide the feature vector of the training image.
[0253] Optionally, the updating unit 220 is further used to update the prototype feature vectors of multiple categories by reducing the difference between the first similarity and the second similarity, the first similarity being the similarity between the feature vector of the training image and any one of the prototype feature vectors of the multiple categories, the second similarity being the similarity between the feature vector of the enhanced image and any one of the prototype feature vectors, and the enhanced image is obtained after data enhancement processing is performed on the training image.
[0254] In an embodiment of the present application, in order to ensure that the enhanced image obtained by performing feature enhancement on the training image is similar to the training image, the prototype feature vectors of multiple categories are updated by reducing the difference between the first similarity and the second similarity, so that the feature vectors corresponding to the enhanced image and the training image are consistent in similarity with any of the prototype feature vectors of the multiple categories, thereby avoiding the situation where the enhanced image and the training image are inconsistently distributed in the vector space.
[0255] Optionally, the updating unit 220 is specifically configured to:
[0256] Determine a first non-leaf node from the non-leaf nodes, the first non-leaf node represents the nearest common parent node of the leaf node of the first prototype feature vector and the leaf node representing the second prototype feature vector, the first prototype feature vector is the K nearest neighbor feature vector of the second prototype feature vector, the second prototype feature vector is the K nearest neighbor feature vector of the first prototype feature vector, the first prototype feature vector and the second prototype feature vector both belong to the prototype feature vector, and K is a positive integer;
[0257] The prototype feature vectors of multiple categories and the M spatial feature vectors are updated by improving the similarity between the first prototype feature vector and the spatial feature vector represented by the first non-leaf node.
[0258] In an embodiment of the present application, when the first non-leaf node is the nearest common parent node of the leaf nodes corresponding to the first prototype feature vector and the second prototype feature vector, and the first prototype feature vector and the second prototype feature vector are each other's K nearest neighbor feature vectors, the similarity between the first prototype feature vector and the first non-leaf node (first spatial feature vector) is improved, providing a direction for reasonably and effectively updating the M spatial feature vectors.
[0259] Optionally, the updating unit 220 is further configured to:
[0260] Determine a second non-leaf node from the non-leaf nodes, the second non-leaf node being the nearest common parent node of the leaf node representing the first prototype feature vector, the leaf node representing the second prototype feature vector, and the leaf node representing the third prototype feature vector, the third prototype feature vector does not belong to the K nearest neighbor feature vectors of the first prototype feature vector, and belongs to the K nearest neighbor feature vectors of the second prototype feature vector;
[0261] The prototype feature vectors of multiple categories and M spatial feature vectors are updated by reducing at least one of the following similarities: the similarity between the first prototype feature vector and the spatial feature vector represented by the second non-leaf node, the similarity between the second prototype feature vector and the spatial feature vector represented by the second non-leaf node, and the similarity between the third prototype feature vector and the spatial feature vector represented by the first non-leaf node.
[0262] In an embodiment of the present application, when the second non-leaf node is the nearest common parent node of the leaf nodes corresponding to the first prototype feature vector, the second prototype feature vector and the third prototype feature vector, the first prototype feature vector and the second prototype feature vector are each other's nearest K nearest neighbor feature vectors, and the third prototype feature vector and the second prototype feature vector are not each other's nearest K nearest neighbor feature vectors, the similarity between the first prototype feature vector, the second prototype feature vector and the second leaf node is reduced, or the similarity between the third prototype feature vector and the first leaf node is reduced, so that the prototype feature vector represented by the leaf node is far away from the spatial feature vector represented by the non-leaf node, so that in the representation of prototype feature vectors of multiple categories and M spatial feature vectors, the prototype feature vector corresponding to the parent node of the leaf node among the M spatial feature vectors can have a richer expression.
[0263] Optionally, the updating unit 220 is further used to update the prototype feature vectors of multiple categories and M spatial feature vectors by reducing the similarity between the prototype feature vector represented by the leaf node and the spatial feature vector represented by the root node, where the root node is one of the non-leaf nodes.
[0264] In an embodiment of the present application, it is also proposed that the distance between the prototype feature vector represented by the leaf node and the spatial feature vector represented by the root node can be increased, thereby reducing the similarity between the prototype feature vector represented by the leaf node and the spatial feature vector represented by the root node, and further achieving M spatial feature vectors with richer expressions when having the same number of levels.
[0265] Optionally, the updating unit 220 is further configured to update the prototype feature vectors of multiple categories and the M spatial feature vectors by reducing the similarity between the prototype feature vectors represented by any two leaf nodes.
[0266] In an embodiment of the present application, it is also proposed to reduce the similarity between the prototype feature vectors represented by any two leaf nodes by increasing the distance between the prototype feature vectors represented by the leaf nodes, thereby avoiding the situation where the prototype feature vectors are too concentrated and difficult to effectively represent all the features of the training image, so that the training images can be fully classified based on the prototype feature vectors.
[0267] Optionally, the updating unit 220 is specifically configured to:
[0268] Determine a prediction probability of each non-leaf node, the prediction probability being the probability that the non-leaf node is the nearest common parent node of the leaf node representing the first prototype feature vector and the leaf node representing the second prototype feature vector;
[0269] Determine the sampling result of each non-leaf node, the sampling result is the sum of the predicted probability and the random probability;
[0270] A first non-leaf node is determined from the non-leaf nodes according to the sampling results of the non-leaf nodes.
[0271] In the embodiment of the present application, the prediction probability of each non-leaf node is introduced to achieve sampling from the prototype feature vectors corresponding to multiple non-leaf nodes. The probability that the leaf node obtained by sampling is the first leaf node is the prediction probability. Based on the risk of overfitting due to multiple samplings, multiple samplings result in the collection of several fixed non-leaf nodes. In order to avoid this situation, random probability is introduced as a disturbance, and the sum of the prediction probability of the non-leaf node and the random probability is used to indicate whether the sampling result of the non-leaf node is the first leaf node, thereby reducing the probability of overfitting during the sampling process. This avoids the situation in which only a few fixed non-leaf nodes can be collected during the sampling of the first non-leaf node, resulting in the inability to comprehensively update the M spatial feature vectors and multiple prototype feature vectors.
[0272] Optionally, the updating unit 220 is further configured to update the feature vector of the training image and the feature vector of the enhanced image by improving the similarity between the feature vector of the enhanced image and the feature vector of the training image.
[0273] In an embodiment of the present application, by improving the similarity between the feature vector of the training image and the feature vector of the enhanced image, strong support is provided for performing feature enhancement on the training image to obtain the enhanced image while retaining the features of the training image, thereby avoiding the situation where the key features of the training image are lost during the feature enhancement process.
[0274] Optionally, the acquisition unit 210 is further configured to acquire the true category of the training image;
[0275] The image analysis device further includes an analysis unit 230, which is further configured to use a classifier to analyze the similarity between the feature vector of the training image and the prototype feature vectors of the multiple categories to determine the predicted category of the training image;
[0276] The updating unit 220 is further configured to update the classifier based on the true category of the training image and the predicted category of the training image.
[0277] In an embodiment of the present application, the prediction category corresponding to the training image is determined by analyzing the similarity between multiple training images and prototype feature vectors of multiple categories. In the process of model training, the prediction category of the training image is analyzed by utilizing the similarity between the prototype feature vectors of multiple categories and the training image. Since in the process of determining the prototype feature vector, it is necessary to utilize the tree structure composed of multiple types of prototype feature vectors and M spatial feature vectors for analysis, and the M spatial feature vectors fully express the hierarchical structure between the multiple types of prototype feature vectors, the hierarchical features of multiple training images are fully utilized, thereby effectively improving the analysis accuracy of the scheme.
[0278] The image recognition device in this application is described in detail below. Fig.10 , Fig.10 This is a schematic diagram of an embodiment of an image recognition device in an embodiment of the present application. The image recognition device 30 includes:
[0279] An acquisition unit 310, configured to acquire a target image;
[0280] The analyzing unit 320 is used to determine the category of the target image according to the similarity between the target image and the prototype feature vectors of multiple categories, wherein the prototype feature vectors of multiple categories are based on the aforementioned Figure 4 The image processing method introduced in .
[0281] The image recognition device provided in this application can be used in a server, see Fig.11 , Fig.114 is a schematic diagram of a server structure provided in an embodiment of the present application. The server 400 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 422 (for example, one or more processors) and a memory 432, and one or more storage media 430 (for example, one or more mass storage devices) storing application programs 442 or data 444. Among them, the memory 432 and the storage medium 430 may be short-term storage or permanent storage. The program stored in the storage medium 430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 422 may be configured to communicate with the storage medium 430 to execute a series of instruction operations in the storage medium 440 on the server 400.
[0282] The server 400 may also include one or more power supplies 426, one or more wired or wireless network interfaces 450, one or more input and output interfaces 458, and / or one or more operating systems 441, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0283] The steps performed by the server in the above embodiment can be based on the Fig.11 The server structure shown.
[0284] The image recognition device provided in this application can be used in terminal equipment. Fig.12 For the sake of convenience, only the parts related to the embodiments of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiments of the present application. In the embodiments of the present application, the terminal device is a smart phone as an example for explanation:
[0285] Fig.12 The block diagram shows a partial structure of a smart phone related to the terminal device provided in the embodiment of the present application. Fig.12 The smart phone includes: a radio frequency (RF) circuit 510, a memory 520, an input unit 530, a display unit 540, a sensor 550, an audio circuit 560, a wireless fidelity (WiFi) module 570, a processor 580, and a power supply 590. Those skilled in the art will appreciate that Fig.12 The structure of the smartphone shown in the figure does not constitute a limitation of the smartphone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0286] Combine the following Fig.12 A detailed introduction to the various components of a smartphone:
[0287] The RF circuit 510 can be used for receiving and sending signals during information transmission or calls. In particular, after receiving the downlink information of the base station, it is sent to the processor 580 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit 510 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF circuit 510 can also communicate with the network and other devices through wireless communication. The above wireless communication can use any communication standard or protocol, including but not limited to the global system of mobile communication (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), long term evolution (LTE), email, short messaging service (SMS), etc.
[0288] The memory 520 can be used to store software programs and modules. The processor 580 executes various functional applications and data processing of the smartphone by running the software programs and modules stored in the memory 520. The memory 520 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the smartphone (such as audio data, a phone book, etc.), etc. In addition, the memory 520 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0289] The input unit 530 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the smart phone. Specifically, the input unit 530 may include a touch panel 531 and other input devices 532. The touch panel 531, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 531 or near the touch panel 531 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 531 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 580, and can receive and execute commands sent by the processor 580. In addition, the touch panel 531 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 531, the input unit 530 may also include other input devices 532. Specifically, other input devices 532 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.
[0290] The display unit 540 can be used to display information input by the user or information provided to the user and various menus of the smartphone. The display unit 540 may include a display panel 541. Optionally, the display panel 541 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like. Further, the touch panel 531 may cover the display panel 541. When the touch panel 531 detects a touch operation on or near it, it is transmitted to the processor 580 to determine the type of touch event. Subsequently, the processor 580 provides a corresponding visual output on the display panel 541 according to the type of touch event. Although in Fig.12 In the embodiment, the touch panel 531 and the display panel 541 are used as two independent components to implement the input and output functions of the smartphone, but in some embodiments, the touch panel 531 and the display panel 541 can be integrated to implement the input and output functions of the smartphone.
[0291] The smartphone may also include at least one sensor 550, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 541 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 541 and / or the backlight when the smartphone is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the smartphone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in smartphones, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.
[0292] The audio circuit 560, the speaker 561, and the microphone 562 can provide an audio interface between the user and the smartphone. The audio circuit 560 can transmit the received audio data to the speaker 561 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 562 converts the collected sound signal into an electrical signal, which is received by the audio circuit 560 and converted into audio data, and then the audio data is output to the processor 580 for processing, and then sent to another smartphone through the RF circuit 510, or the audio data is output to the memory 520 for further processing.
[0293] WiFi is a short-range wireless transmission technology. Smartphones can help users send and receive emails, browse web pages, and access streaming media through WiFi module 570, which provides users with wireless broadband Internet access. Fig.12 A WiFi module 570 is shown, but it is understandable that it is not an essential component of the smartphone and can be omitted as needed without changing the essence of the invention.
[0294] The processor 580 is the control center of the smartphone, which uses various interfaces and lines to connect various parts of the entire smartphone, and executes various functions of the smartphone and processes data by running or executing software programs and / or modules stored in the memory 520, and calling data stored in the memory 520, so as to monitor the smartphone as a whole. Optionally, the processor 580 may include one or more processing units; optionally, the processor 580 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 580.
[0295] The smart phone also includes a power source 590 (such as a battery) for supplying power to various components. Optionally, the power source can be logically connected to the processor 580 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption management.
[0296] Although not shown, the smartphone may also include a camera, a Bluetooth module, etc., which will not be described in detail here.
[0297] The steps performed by the terminal device in the above embodiment can be based on the Fig.12 The terminal device structure shown.
[0298] A computer-readable storage medium is also provided in an embodiment of the present application. The computer-readable storage medium stores a computer program, which, when executed on a computer, enables the computer to execute the methods described in the aforementioned embodiments.
[0299] The present application also provides a computer program product including a program, which, when executed on a computer, enables the computer to execute the methods described in the aforementioned embodiments.
[0300] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0301] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0302] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0303] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0304] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application 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 computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0305] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. An image processing method, It is characterized in that include: Acquire a feature vector of a training image, prototype feature vectors of multiple categories, and M spatial feature vectors, wherein the prototype feature vectors of the multiple categories and the M spatial feature vectors form a tree structure, each of the multiple categories has one or more prototype feature vectors, the prototype feature vectors are represented by leaf nodes of the tree structure, the spatial feature vectors are represented by non-leaf nodes of the tree structure, and M is a positive integer; updating the prototype feature vectors of the multiple categories according to the similarity between the feature vector of the training image and the prototype feature vectors of the multiple categories; According to the relationship between the leaf node and the non-leaf node, updating the prototype feature vectors of the multiple categories and the M spatial feature vectors; The updated prototype feature vectors of the multiple categories are used to determine the category of the target image.
2. The method according to claim 1, It is characterized in that The updating of the prototype feature vectors of the multiple categories according to the similarity between the feature vector of the training image and the prototype feature vectors of the multiple categories comprises: Determine a target prototype feature vector according to the similarity between the feature vector of the training image and the prototype feature vectors of the multiple categories, wherein the target prototype feature vector is a prototype feature vector having the highest similarity with the feature vector of the training image among the prototype feature vectors of the multiple categories; The target prototype feature vector is updated by improving the similarity between the feature vector of the training image and the target prototype feature vector.
3. The method according to claim 2, It is characterized in that The method further comprises: The prototype feature vectors of the multiple categories are updated by narrowing the difference between the first similarity and the second similarity, wherein the first similarity is the similarity between the feature vector of the training image and any one of the prototype feature vectors of the multiple categories, and the second similarity is the similarity between the feature vector of the enhanced image and any one of the prototype feature vectors, wherein the enhanced image is obtained after data enhancement processing is performed on the training image.
4. The method according to claim 1, It is characterized in that The updating of the prototype feature vectors of the multiple categories and the M spatial feature vectors according to the relationship between the leaf node and the non-leaf node comprises: Determine a first non-leaf node from the non-leaf nodes, the first non-leaf node represents the nearest common parent node of the leaf node of the first prototype feature vector and the leaf node representing the second prototype feature vector, the first prototype feature vector is the K nearest neighbor feature vector of the second prototype feature vector, the second prototype feature vector is the K nearest neighbor feature vector of the first prototype feature vector, the first prototype feature vector and the second prototype feature vector both belong to the prototype feature vector, and K is a positive integer; The prototype feature vectors of the multiple categories and the M spatial feature vectors are updated by improving the similarity between the first prototype feature vector and the spatial feature vector represented by the first non-leaf node.
5. The method according to claim 4, It is characterized in that The method further comprises: Determine a second non-leaf node from the non-leaf nodes, the second non-leaf node being the nearest common parent node of the leaf node representing the first prototype feature vector, the leaf node representing the second prototype feature vector, and the leaf node representing the third prototype feature vector, the third prototype feature vector does not belong to the K nearest neighbor feature vectors of the first prototype feature vector, and belongs to the K nearest neighbor feature vectors of the second prototype feature vector; The prototype feature vectors of the multiple categories and the M spatial feature vectors are updated by reducing at least one of the following similarities: the similarity between the first prototype feature vector and the spatial feature vector represented by the second non-leaf node, the similarity between the second prototype feature vector and the spatial feature vector represented by the second non-leaf node, and the similarity between the third prototype feature vector and the spatial feature vector represented by the first non-leaf node.
6. The method according to claim 4, It is characterized in that The method further comprises: The prototype feature vectors of the multiple categories and the M spatial feature vectors are updated by reducing the similarity between the prototype feature vector represented by the leaf node and the spatial feature vector represented by the root node, wherein the root node is one of the non-leaf nodes.
7. The method according to claim 4, It is characterized in that The method further comprises: The prototype feature vectors of the multiple categories and the M spatial feature vectors are updated by reducing the similarity between the prototype feature vectors represented by any two of the leaf nodes.
8. The method according to claim 4, It is characterized in that Determining the first non-leaf node from the non-leaf nodes comprises: Determine a prediction probability of each non-leaf node, the prediction probability being a probability that the non-leaf node is a nearest common parent node of a leaf node representing a first prototype feature vector and a leaf node representing a second prototype feature vector; Determine a sampling result of each non-leaf node, wherein the sampling result is the sum of the predicted probability and the random probability; The first non-leaf node is determined from the non-leaf nodes according to the sampling results of the non-leaf nodes.
9. The method according to claim 3, It is characterized in that The method further comprises: The feature vector of the training image and the feature vector of the enhanced image are updated by improving the similarity between the feature vector of the enhanced image and the feature vector of the training image.
10. The method according to any one of claims 1 to 9, It is characterized in that The method further comprises: Obtaining the true category of the training image; Using a classifier to analyze the similarity between the feature vector of the training image and the prototype feature vectors of the multiple categories, and determine the predicted category of the training image; The classifier is updated based on the true category of the training image and the predicted category of the training image.
11. An image recognition method, It is characterized in that include: Get the target image; The category of the target image is determined according to the similarity between the target image and prototype feature vectors of multiple categories, wherein the prototype feature vectors of the multiple categories are obtained according to the method of weights 1-10.
12. An image processing device, It is characterized in that include: An acquisition unit, used to acquire a feature vector of a training image, prototype feature vectors of multiple categories, and M spatial feature vectors, wherein the prototype feature vectors of the multiple categories and the M spatial feature vectors form a tree structure, each of the multiple categories has one or more prototype feature vectors, the prototype feature vector is represented by a leaf node of the tree structure, the spatial feature vector is represented by a non-leaf node of the tree structure, and M is a positive integer; An updating unit, configured to update the prototype feature vectors of the multiple categories according to the similarity between the feature vector of the training image and the prototype feature vectors of the multiple categories; The updating unit is further used to update the prototype feature vectors of the multiple categories and the M spatial feature vectors according to the relationship between the leaf node and the non-leaf node; The updated prototype feature vectors of the multiple categories are used to determine the category of the target image.
13. An image recognition device, It is characterized in that include: An acquisition unit, used for acquiring a target image; An analyzing unit is used to determine the category of the target image according to the similarity between the target image and prototype feature vectors of multiple categories, wherein the prototype feature vectors of the multiple categories are obtained according to the method of weights 1-10.
14. A computer device, It is characterized in that include: Memory, processor, and bus system; Wherein, the memory is used to store programs; The processor is used to execute the program in the memory, and the processor is used to execute the method according to any one of claims 1 to 10 or claim 11 according to the instructions in the program code; The bus system is used to connect the memory and the processor so that the memory and the processor can communicate with each other.
15. A computer-readable storage medium comprising instructions, which, when executed on a computer, causes the computer to perform the method according to any one of claims 1 to 10 or claim 11.
16. A computer program product comprising a computer program, It is characterized in that The computer program is used by a processor to execute the method according to any one of claims 1 to 10 or claim 11.
Citation Information
Patent Citations
Image processing method, device and equipment and computer readable storage medium
CN111402143A
Webpage data extraction method and apparatus, computer device, and storage medium
WO2023155303A1
