Image recognition method and device, equipment, medium and product

Through the image recognition method, using the prototype network model and edge perception module, combined with the baseline loss function and the quaternary loss function, the problem of manual recognition errors is solved and the accurate identification of important customers is achieved, especially in large bank branches.

CN118570835APending Publication Date: 2024-08-30INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410440995.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-12
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

When existing bank branches manually identify important customers, identification errors are prone to occur. Especially in large branches, it is difficult to accurately identify all important customers.

Method used

An image recognition method is adopted, by obtaining multiple sample images and user tags of the initial preset user, randomly selecting the target user, dividing the support image and the query image, and training based on the prototype network model, using the convolution layer and edge perception module. The joint loss function that combines the baseline loss function and the quaternion loss function improves the recognition accuracy.

Benefits of technology

It effectively improves the identification accuracy of important customers and improves the identification ability of the identification system. Especially in large outlets, it can more accurately identify all important customers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570835A
    Figure CN118570835A
Patent Text Reader

Abstract

The invention relates to an image recognition method, device and equipment, a medium and a product, and relates to the technical field of biological recognition. The method comprises the following steps: acquiring a plurality of initial sample images of each user in a plurality of initial preset users and a user label of each initial sample image; randomly selecting a plurality of target preset users from the plurality of initial preset users, and randomly selecting a plurality of target sample images from the plurality of initial sample images of each target preset user; for each target preset user, dividing the target sample image into a support image and a query image according to a preset proportion; training the initial prototype network model into a target prototype network model based on the support image, the query image and the user tag; and inputting a target image of the target user into the target prototype network model to obtain an identification result for the target user. According to the method provided by the invention, the accuracy of identifying the target image can be effectively improved, and the method has higher identification capability on the target image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of biometric identification technology, and in particular to an image recognition method, device, equipment, medium and product. Background Art

[0002] It is very important for commercial bank branches to identify important visiting customers in real time, which is related to whether they can provide important customers with excellent services in a timely manner and thus efficiently maintain existing customers.

[0003] At present, the vast majority of bank branches adopt manual identification methods. However, whether this method can identify important customers depends entirely on the work experience and personal ability of the branch employees themselves. It is easy to misidentify important customers. In addition, this method can usually better identify important customers in small branches with fewer important customers, but in large branches, it is difficult to accurately identify all important customers based on manual memory alone. Summary of the invention

[0004] Based on this, it is necessary to provide an image recognition method, device, equipment, medium and product that can improve the accuracy of identifying important customers in response to the above technical problems.

[0005] In a first aspect, the present application provides an image recognition method, the method comprising:

[0006] Acquire multiple initial sample images of each user among multiple initial preset users and a user label of each initial sample image;

[0007] Randomly selecting a first preset number of target preset users from the multiple initial preset users, and randomly selecting a second preset number of target sample images from the multiple initial sample images of each target preset user;

[0008] For each target preset user, dividing the target sample image into a support image and a query image according to a preset ratio;

[0009] Based on the support image, the query image, and the user label, an initial prototype network model is trained to obtain a target prototype network model, wherein the embedding network of the prototype network model includes a first convolutional layer, a second convolutional layer, a first edge perception module, a third convolutional layer, a second edge perception module, and a fourth convolutional layer connected in sequence, and a loss function of the prototype network model is a joint loss function composed of a benchmark loss function and a quaternary loss function;

[0010] The target image of the target user is input into the target prototype network model to obtain a recognition result for the target user.

[0011] In one embodiment, before randomly selecting a first preset number of target preset users from the plurality of initial preset users, the method further includes:

[0012] For each initial sample image, adjusting the size of the initial sample image to a preset size;

[0013] Based on the result of the size adjustment, a pixel value of each pixel in the initial sample image is obtained;

[0014] Based on the maximum pixel value and the minimum pixel value among all pixel values, normalizing the pixel values ​​in the initial sample image;

[0015] The pixel values ​​in the initial sample image are standardized based on the corresponding average values ​​and standard deviations of all pixel values.

[0016] In one embodiment, the training of the initial prototype network model based on the support image, the query image, and the user label to obtain the target prototype network model includes:

[0017] Inputting the supporting images and corresponding user labels into the initial prototype network model to obtain an intermediate prototype network model;

[0018] Inputting the query image into the intermediate prototype network model to obtain the loss value of the joint loss function;

[0019] When the loss value is within a preset loss value range or the current training times are not less than a preset training times, the intermediate prototype network model is determined as the target prototype network model.

[0020] In one embodiment, the method further comprises:

[0021] When the loss value is not within the preset loss value range and the current training number is less than the preset training number, updating the model parameters of the initial prototype network model, and determining the prototype network model after parameter update as a new initial prototype network model;

[0022] Selecting a first preset number of new target preset users from the remaining initial preset users who have not been determined as target preset users;

[0023] Execute the step of randomly selecting a second preset number of target sample images from multiple initial sample images of each target preset user, and continue to execute until the loss value is within the preset loss value range, or the current training number is not less than the preset training number.

[0024] In one embodiment, the parameter list of the intermediate prototype network model stores a prototype vector corresponding to each target preset user, and the prototype vector is an average vector of feature vectors of the support image corresponding to each target preset user, and the feature vector is generated by the initial prototype network model based on the input support image.

[0025] In one of the embodiments, the loss value represents the similarity between the predicted user corresponding to the query image and the target preset user corresponding to the query image, and the predicted user is determined based on the Euclidean distance between the feature vector of the query image and each prototype vector.

[0026] In a second aspect, the present application further provides an image recognition device, the device comprising:

[0027] An acquisition module, used to acquire a plurality of initial sample images of each user among a plurality of initial preset users and a user label of each initial sample image;

[0028] A selection module, configured to randomly select a first preset number of target preset users from the plurality of initial preset users, and randomly select a second preset number of target sample images from the plurality of initial sample images of each target preset user;

[0029] A division module, for dividing the target sample image into a support image and a query image according to a preset ratio for each target preset user;

[0030] A training module is used to train an initial prototype network model based on the support image, the query image, and the user label to obtain a target prototype network model, wherein the embedding network of the prototype network model includes a first convolutional layer, a second convolutional layer, a first edge perception module, a third convolutional layer, a second edge perception module, and a fourth convolutional layer connected in sequence, and the loss function of the prototype network model is a joint loss function composed of a benchmark loss function and a quaternary loss function;

[0031] The recognition module is used to input the target image of the target user into the target prototype network model to obtain a recognition result for the target user.

[0032] In a third aspect, the present application further provides a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method in any one of the above embodiments when executing the computer program.

[0033] In a fourth aspect, the present application further provides a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method in any one of the above embodiments are implemented.

[0034] In a fifth aspect, the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the method in any one of the above embodiments are implemented.

[0035] The above-mentioned image recognition method, device, equipment, medium and product obtain multiple initial sample images of each user among multiple initial preset users and the user label of each initial sample image; randomly select a first preset number of target preset users from the multiple initial preset users, and randomly select a second preset number of target sample images from the multiple initial sample images of each target preset user; for each target preset user, divide the target sample image into a support image and a query image according to a preset ratio; based on the support image, the query image, and the user label, train the initial prototype network model to obtain a target prototype network model, the embedded network of the prototype network model includes a first convolutional layer, a second convolutional layer, a first edge perception module, a third convolutional layer, a second edge perception module and a fourth convolutional layer connected in sequence, and the loss function of the prototype network model is a joint loss function composed of a baseline loss function and a four-element loss function; input the target image of the target user into the target prototype network model to obtain a recognition result for the target user. The method provided in the present application trains an initial prototype network model based on sample images of preset users, and uses the target prototype network model obtained after training to recognize the target image of the target user, which can effectively improve the accuracy of recognizing the target image; the embedded network of the prototype network model includes two layers of edge perception modules, and the loss function of the prototype network model is a combined loss function composed of a baseline loss function and a four-element loss function. Such a prototype network model has a higher recognition ability for the target image. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0037] FIG1 is a diagram of an application environment of an image recognition method in one embodiment;

[0038] FIG2 is a schematic diagram of a flow chart of an image recognition method in one embodiment;

[0039] FIG3 is a schematic diagram of an embedded network of a prototype network model in one embodiment;

[0040] FIG4 is a schematic diagram of an EPM module in one embodiment;

[0041] FIG5 is a diagram of the overall architecture of EPSA-block in one embodiment;

[0042] FIG6 is a schematic diagram of an SPC module in one embodiment;

[0043] FIG7 is a schematic diagram of an SE module in one embodiment;

[0044] FIG8 is a schematic diagram of a spatial attention module SAM in one embodiment;

[0045] FIG9 is a schematic diagram of a flow chart of a pretreatment process in one embodiment;

[0046] FIG10 is a schematic flow chart of an image recognition method in another embodiment;

[0047] FIG11 is a block diagram of an image recognition device according to an embodiment;

[0048] FIG. 12 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0049] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0050] The image recognition method provided in the embodiment of the present application can be applied in the application environment shown in Figure 1. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server 104 obtains multiple initial sample images of each user in multiple initial preset users and the user label of each initial sample image from the terminal 102, and trains the initial prototype network model based on the obtained initial sample images and user labels, and recognizes the target image based on the trained target prototype network model. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.

[0051] In an exemplary embodiment, as shown in FIG2 , an image recognition method is provided, which is described by taking the method applied to the server in FIG1 as an example, and includes the following steps 202 to 210. Among them:

[0052] S202: Acquire a plurality of initial sample images of each user among a plurality of initial preset users and a user label of each initial sample image.

[0053] Among them, in the banking or financial field, the initial preset user may be an important customer, and the initial sample image may be a picture of the important customer. In other embodiments, the initial preset user and the initial sample image may also be other, and the embodiments of the present application do not specifically limit this; the user label represents the correspondence between the initial sample image and the initial preset user.

[0054] The information collected in this application is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data comply with the relevant laws, regulations and standards of relevant countries and regions, take necessary confidentiality measures, do not violate public order and good customs, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0055] S204: randomly selecting a first preset number of target preset users from a plurality of initial preset users, and randomly selecting a second preset number of target sample images from a plurality of initial sample images of each target preset user.

[0056] Among them, different from ordinary image recognition tasks, the small sample learning field to which the prototype network model belongs usually uses batches (episodes) as training units. During the training process of each batch, the model is trained based on the samples corresponding to the current batch. In this embodiment, the second preset number of target sample images of each user among the first preset number of target preset users selected are the samples corresponding to the current batch.

[0057] S206 . For each target preset user, divide the target sample image into a support image and a query image according to a preset ratio.

[0058] The total number of initially preset users can be represented by K, the total number of initial sample images can be represented by N, and the first preset number can be represented by express, For each target preset user, the second preset number can be used It indicates that, To support the number of images, is the number of query images. Therefore, in each batch of training, the total number of target sample images of all target preset users is ,in, is the total number of supported images, is the total number of query images.

[0059] S208. Based on the support image, the query image, and the user label, the initial prototype network model is trained to obtain the target prototype network model. The embedded network of the prototype network model includes a first convolutional layer, a second convolutional layer, a first edge perception module, a third convolutional layer, a second edge perception module and a fourth convolutional layer connected in sequence. The loss function of the prototype network model is a joint loss function composed of a baseline loss function and a four-element loss function.

[0060] The embedding network of the prototype network model is shown in Figure 3. The embedding network in Figure 3 contains 4 convolutional layers and 2 edge perception modules (EPM). The first EPM module is inserted after the second convolutional layer, and the second EPM module is inserted after the third convolutional layer. Each convolutional layer contains 64 convolution kernels of size 3×3. The convolution kernel is used for convolution operation. The convolution operation first obtains the feature vector, normalizes the feature vector, and then uses the ReLU activation function for activation. Finally, the maximum pooling operation is used to reduce the parameters. The internal operations of the four convolutional layers are exactly the same.

[0061] As shown in Figure 4, the EPM module is composed of the EPSA-block (Enhanced Pyramid Split Attention Block, a special attention module) in EPSANet (Enhanced Pyramid Split Attention Network) and the SAM (Segment Anything Model, an image segmentation model) module in CBAM (Channel-wise Attention and Spatial Attention, an attention mechanism for enhancing the performance of deep neural networks). In the EPM module, the feature vector is sequentially input into an EPSA-block and a SAM spatial attention module, so that the output feature is the mixed domain multi-scale attention weighted feature after multi-scale channel attention weighting and spatial attention weighting.

[0062] The overall architecture of EPSA-block is shown in Figure 5. In EPSA-block, first, the SPC (Squeeze-and-Excitation) module is used to divide the feature map of each channel into several small blocks, and then different features are extracted for each small block; secondly, the SE (SENet) module is used to calculate the importance of each small block in the features of different channels, and a vector representing the importance is obtained; then, these vectors are normalized using the Softmax function to obtain a weight vector; finally, the weight vector is multiplied by the corresponding feature, and all the small blocks are pieced together to obtain a feature map that integrates multi-scale information. This feature map can better express the details and global information of the image.

[0063] The most important modules in EPSA-block are SPC module and SE module. The schematic diagram of SPC module is shown in Figure 6: The input image is X, and it is first split into S parts. , and then extract different scale features from different parts. The above process can be simply described by the following formula:

[0064]

[0065] After extracting features of different scales from different parts, the extracted multi-scale features are concatenated through Concat. On this basis, the SE module is used to extract the attention weights for the concatenated features of different parts. The schematic diagram of the SE module is shown in Figure 7. The operation of the SE module is to first obtain the input image features through a global average pooling. The feature vector is then output through two fully connected layers The feature vector of The formula for obtaining the feature vector of global average pooling is as follows:

[0066]

[0067] In the formula, H and W represent the height and width of the input feature respectively. Represents the input features.

[0068] The formula for the channel attention weight obtained after two more fully connected layers is as follows:

[0069]

[0070] In the formula, and There are two fully connected layer operations respectively.

[0071] In order to establish long-term channel attention dependency and realize information interaction between multi-scale channel attention, Softmax is further used to recalibrate the weights of channel attention information. As shown in the following formula:

[0072]

[0073] Then, the feature map of the corresponding scale Multiply the weighted attention vector channel-wise, as shown in the following formula:

[0074]

[0075] Finally, the feature maps obtained after multi-scale channel attention weighting are concatenated, that is, arrive All of them are concatenated, and finally a feature map with richer multi-scale information is output.

[0076] However, EPSA-block is only a channel attention module and lacks attention to features in space. Therefore, EPSA-block and SAM are combined to form a hybrid domain attention module to enhance feature extraction capabilities. The spatial attention module SAM is shown in Figure 8.

[0077] The feature map output by the channel attention is also subjected to global maximum pooling and global average pooling based on the width and height of the feature map to obtain two feature maps with compressed height and width. Then, these two feature maps are pieced together to form a new feature map. Next, a small convolution kernel is used. And an activation function ReLU to reduce the length of the vector; then, use another convolution kernel to restore the length of the vector, and use the sigmoid function to convert it to a value between 0 and 1. ; Finally, this value Multiply it by the original feature map F to get the feature map after spatial attention weighting. The calculation formula is as follows:

[0078]

[0079] In the above formula represents the sigmoid activation function, and Represent global average pooling and global maximum pooling respectively, The convolution kernel is Convolution operation, F represents the input feature.

[0080] Finally, the embedded network of the prototype network model in this embodiment can also pay attention to the characteristics of space and channel at the same time on its own basis, and automatically weight the characteristics of channel and space, so that the network can pay attention to more critical features and ignore invalid features.

[0081] After the target prototype network model is obtained through training, the initial sample images of all users are input into the target prototype network model, and the corresponding feature vectors are extracted, and the corresponding prototype vectors are calculated and saved.

[0082] S210: Input the target image of the target user into the target prototype network model to obtain a recognition result for the target user.

[0083] Among them, a target image captured and sent by a camera is obtained. For example, in the banking or financial field, the camera can be a dedicated camera at the door of a bank branch. The target image is pre-processed and then input into the target prototype network model. The target prototype network model calculates a feature vector corresponding to the target image, and calculates the Euclidean distance between the feature vector and each prototype vector stored in the target prototype network model. The user represented by the prototype vector corresponding to the minimum Euclidean distance is determined as the user corresponding to the target image, thereby determining the identity of the target user.

[0084] In the above-mentioned image recognition method, multiple initial sample images of each user among multiple initial preset users and the user label of each initial sample image are obtained; a first preset number of target preset users are randomly selected from the multiple initial preset users, and a second preset number of target sample images are randomly selected from the multiple initial sample images of each target preset user; for each target preset user, the target sample image is divided into a support image and a query image according to a preset ratio; based on the support image, the query image, and the user label, the initial prototype network model is trained to obtain a target prototype network model, the embedded network of the prototype network model includes a first convolutional layer, a second convolutional layer, a first edge perception module, a third convolutional layer, a second edge perception module and a fourth convolutional layer connected in sequence, and the loss function of the prototype network model is a joint loss function composed of a baseline loss function and a four-element loss function; the target image of the target user is input into the target prototype network model to obtain a recognition result for the target user. The method provided in the present application trains an initial prototype network model based on sample images of preset users, and uses the target prototype network model obtained after training to recognize the target image of the target user, which can effectively improve the accuracy of recognizing the target image; the embedded network of the prototype network model includes two layers of edge perception modules, and the loss function of the prototype network model is a combined loss function composed of a baseline loss function and a four-element loss function. Such a prototype network model has a higher recognition ability for the target image.

[0085] In some embodiments, as shown in FIG9 , before randomly selecting a first preset number of target preset users from a plurality of initial preset users, the method further includes:

[0086] S902: For each initial sample image, adjust the size of the initial sample image to a preset size.

[0087] S904: Based on the result of the size adjustment, obtain the pixel value of each pixel in the initial sample image.

[0088] S906: Normalize the pixel values ​​in the initial sample image based on the maximum pixel value and the minimum pixel value among all pixel values.

[0089] S908 , performing standardization processing on the pixel values ​​in the initial sample image based on the corresponding average values ​​and standard deviations of all pixel values.

[0090] Among them, the preset size can be 84×84 pixels. In other embodiments, the preset size can also be other sizes, which is not specifically limited in the embodiments of the present application.

[0091] The formula for normalizing each initial sample image is as follows:

[0092]

[0093] In the formula, x represents the input image pixel value, , Represent the maximum and minimum values ​​of the input pixels respectively.

[0094] The formula for normalization of each initial sample image is as follows:

[0095]

[0096] In the formula, represents the pixel mean of the input image, Represents the standard deviation of the input image pixels.

[0097] After normalization, the pixel values ​​of the initial sample images are all in the range of -1 to 1.

[0098] In this embodiment, the initial sample images are resized, normalized, and standardized, which can accelerate the convergence of the prototype network model.

[0099] In some embodiments, based on the supporting image, the query image, and the user label, the initial prototype network model is trained to obtain the target prototype network model, including: inputting the supporting image and the corresponding user label into the initial prototype network model to obtain an intermediate prototype network model; inputting the query image into the intermediate prototype network model to obtain the loss value of the joint loss function; when the loss value is within the preset loss value range, or the current training number is not less than the preset training number, the intermediate prototype network model is determined as the target prototype network model.

[0100] Among them, after the support image and the corresponding user label are input into the initial prototype network model, the initial prototype network model will generate the corresponding feature vector of each support image, and generate the corresponding prototype vector of each target preset user based on the user label and the feature vector. The initial prototype network model after generating the prototype vector is the intermediate prototype network model; after the query image is input into the intermediate prototype network model, the intermediate prototype network model will first generate the corresponding feature vector of each query image, and calculate the Euclidean distance between the feature vector of the query image and each prototype vector, and determine the target preset user represented by the prototype vector with the minimum Euclidean distance as the predicted user, and calculate the loss value of the joint loss function based on the predicted user and the real target preset user of the corresponding query image. The SoftMax function can be used to determine the predicted user, and the process of determining the predicted user is shown in the following formula:

[0101]

[0102] In the formula, is the predicted user, x is the query image, Represents the measurement method. Here we use the Euclidean distance measurement method.

[0103] The prototype network learns by minimizing the negative log probability of the true class k through SGD. The loss function is shown in the following formula:

[0104]

[0105] The quaternary loss function is an improved function based on the ternary loss function. The main idea is that after the sample is extracted from the feature map through a deep neural network, the feature embeddings of the same category are made as close as possible, and the feature embeddings of different categories are made as far apart as possible, and the minimum inter-class distance is made greater than the maximum intra-class distance. The specific process is: in the traditional quaternary loss function, we will select a quaternary, first select a sample from the training set as the anchor point, and then randomly select a sample that belongs to the same category as the anchor point as the positive sample, and finally randomly select one from each of the other two different categories as negative sample 1 and negative sample 2. Here, the feature map of the sample is denoted by x. Symbol Represents the anchor point, is a positive sample, is negative sample 1, is negative sample 2. , Represents two hyperparameter interval thresholds, which are set to 1 and 0.5 respectively in the present invention. , a basic quadruple loss function is as follows:

[0106]

[0107] Due to the particularity of the prototype network, this application improves the four-tuple into a four-tuple loss function suitable for the prototype network. The specific improvements are as follows: In a batch (episode), after both the support image and the query image are feature extracted, there are usually N (the number of target preset users) (The number of query images corresponding to each target preset user) query features, first the anchor data randomly selects one of the N target preset users, and then the M query images of this target preset user are selected as the anchor data of this batch, which is defined as the query set. Then the positive sample uses the prototype of the same category as the anchor sample, and the negative sample uses two random prototypes that are different from the positive sample category. Therefore, a batch has multiple samples for training. The formula of the improved quadruple loss function is as follows:

[0108]

[0109] In the formula, represents a query feature corresponding to one of the N target preset users. This query feature is the anchor point. express The prototype vector corresponding to the target preset user is the positive sample. Represents a randomly selected A prototype vector of a target preset user other than the corresponding target preset user is negative sample 1. Represents a randomly selected The second prototype vector of the target preset user other than the corresponding target preset user, and not equal to , as negative sample 2. Therefore, the final joint loss function formula is as follows:

[0110]

[0111] In the formula, is the prototype network loss function, is the quaternion loss function, is the balancing factor, which is set to 1 in this application.

[0112] In this embodiment, a combined loss function consisting of a baseline loss function and a quaternion loss function is used as the loss function of the prototype network model, which can effectively improve the accuracy of the prototype network model in recognizing the target image.

[0113] In some embodiments, the method also includes: when the loss value is not within a preset loss value range and the current number of training times is less than a preset number of training times, updating the model parameters of the initial prototype network model, and determining the prototype network model after parameter update as a new initial prototype network model; selecting a first preset number of new target preset users from the remaining initial preset users who have not been determined as target preset users; executing the step of randomly selecting a second preset number of target sample images from multiple initial sample images of each target preset user, and continuing to execute until the loss value is within the preset loss value range, or the current number of training times is not less than the preset number of training times.

[0114] Among them, in the repeated iteration process, the optimizer uses Adam for training, and the learning update strategy selects the cosine annealing strategy. The specific implementation formula is as follows:

[0115]

[0116] In the formula, the symbol Represents the current learning rate, symbol represents the maximum learning rate (initial learning rate), symbol represents the minimum learning rate, symbol Indicates the current epoch number, symbol Indicates the maximum number of epochs, where the initial learning rate (maximum learning rate) Set to 0.001, the minimum learning rate Set it to 0.000001, restart the learning rate every 50 epochs, and set the maximum epoch to 200.

[0117] In this embodiment, when the loss value is not within the preset loss value range and the current training times are less than the preset training times, the model parameters of the initial prototype network model are updated, so that the prototype network model after the parameter update can recognize the target image more accurately.

[0118] In some embodiments, the parameter list of the intermediate prototype network model stores a prototype vector corresponding to each target preset user, where the prototype vector is an average vector of feature vectors of the support image corresponding to each target preset user, and the feature vector is generated by the initial prototype network model based on the input support image.

[0119] The prototype vector can be calculated using the following formula:

[0120]

[0121] In the formula, i represents a target preset user, represents the embedding network function, Representative support image The characteristic vector of Represents the final calculated prototype vector.

[0122] In this embodiment, by calculating the prototype vector corresponding to each target preset user, the training process of the prototype network model can be made more accurate, so that the target prototype network model can recognize the target image more accurately.

[0123] In some embodiments, the loss value represents the similarity between the predicted user corresponding to the query image and the target preset user corresponding to the query image, and the predicted user is determined based on the Euclidean distance between the feature vector of the query image and each prototype vector.

[0124] Among them, Euclidean distance is a metric in Euclidean space, which is a commonly used distance metric in many fields, including mathematics, physics, computer science, statistics, etc. In computer vision and machine learning, Euclidean distance is often used to calculate the similarity between images, feature matching, image recognition and other fields.

[0125] In this embodiment, the predicted user is determined based on the Euclidean distance between the feature vector of the query image and each prototype vector, so that the determination of the predicted user is more accurate, thereby making the training of the prototype network model more accurate.

[0126] In one embodiment, as shown in FIG10 , another image recognition method is provided, the method comprising the following contents:

[0127] S1: Collect pictures of important customers in the current bank and label them.

[0128] S2: Preprocess the images and divide them into training set and validation set.

[0129] S3: Put the pictures into the model for training until the specified training batch is reached. After using the model with the best classification accuracy in the validation set, save the trained model.

[0130] S4: Put all training images into the model to obtain embedded features and calculate the category prototypes of all customers, and save all prototypes.

[0131] S5: The lobby camera collects pictures of customers entering the lobby and puts them into the backend server.

[0132] S6: Put the image into the trained model to obtain the image embedding features, and calculate the Euclidean distance with all prototypes. The one with the closest distance belongs to the type of prototype to complete customer identification.

[0133] S7: After completing customer identification, the customer-related information is transmitted to the bank branch lobby manager through the background program, and the lobby manager provides corresponding customer service.

[0134] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0135] Based on the same inventive concept, the embodiment of the present application also provides an image recognition device for implementing the above-mentioned image recognition method. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above-mentioned method, so the specific limitations in one or more image recognition device embodiments provided below can refer to the limitations on the image recognition method above, and will not be repeated here.

[0136] In an exemplary embodiment, as shown in FIG. 11 , an image recognition device 1100 is provided, comprising: an acquisition module 1101, a selection module 1102, a division module 1103, a training module 1104 and a recognition module 1105, wherein:

[0137] The acquisition module 1101 is used to acquire a plurality of initial sample images of each user among a plurality of initial preset users and a user label of each initial sample image.

[0138] The selection module 1102 is used to randomly select a first preset number of target preset users from the multiple initial preset users, and randomly select a second preset number of target sample images from the multiple initial sample images of each target preset user.

[0139] The division module 1103 is used to divide the target sample image into a support image and a query image according to a preset ratio for each target preset user.

[0140] The training module 1104 is used to train the initial prototype network model based on the supporting image, the query image, and the user label to obtain a target prototype network model. The embedded network of the prototype network model includes a first convolutional layer, a second convolutional layer, a first edge perception module, a third convolutional layer, a second edge perception module and a fourth convolutional layer connected in sequence. The loss function of the prototype network model is a joint loss function composed of a baseline loss function and a four-element loss function.

[0141] The recognition module 1105 is used to input the target image of the target user into the target prototype network model to obtain a recognition result for the target user.

[0142] In some embodiments, the image recognition device 1100 is specifically used to: for each initial sample image, adjust the size of the initial sample image to a preset size; based on the result of the size adjustment, obtain the pixel value of each pixel point in the initial sample image; based on the maximum pixel value and the minimum pixel value of all pixel values, normalize the pixel values ​​in the initial sample image; based on the corresponding average value and standard deviation of all pixel values, standardize the pixel values ​​in the initial sample image.

[0143] In some embodiments, the training module 1104 is also used to input the supporting image and the corresponding user label into the initial prototype network model to obtain an intermediate prototype network model; input the query image into the intermediate prototype network model to obtain the loss value of the joint loss function; and when the loss value is within a preset loss value range or the current training number is not less than a preset training number, determine the intermediate prototype network model as the target prototype network model.

[0144] In some embodiments, the training module 1104 is also used to update the model parameters of the initial prototype network model and determine the prototype network model after parameter update as the new initial prototype network model when the loss value is not within the preset loss value range and the current training number is less than the preset training number; select a first preset number of new target preset users from the remaining initial preset users who have not been determined as target preset users; execute the step of randomly selecting a second preset number of target sample images from multiple initial sample images of each target preset user, and continue to execute until the loss value is within the preset loss value range or the current training number is not less than the preset training number.

[0145] In some embodiments, the training module 1104 is also used to store a prototype vector corresponding to each target preset user in the parameter list of the intermediate prototype network model, and the prototype vector is the average vector of the feature vector of the support image corresponding to each target preset user, and the feature vector is generated by the initial prototype network model based on the input support image.

[0146] In some embodiments, the training module 1104 is also used to characterize the degree of similarity between the predicted user corresponding to the query image and the target preset user corresponding to the query image using a loss value, wherein the predicted user is determined based on the Euclidean distance between the feature vector of the query image and each prototype vector.

[0147] Each module in the above-mentioned image recognition device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.

[0148] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG12. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store image data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, an image recognition method is implemented.

[0149] Those skilled in the art will understand that the structure shown in FIG. 12 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0150] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the following steps when executing the computer program: obtaining multiple initial sample images of each user among multiple initial preset users and a user label of each initial sample image; randomly selecting a first preset number of target preset users from the multiple initial preset users, and randomly selecting a second preset number of target sample images from the multiple initial sample images of each target preset user; for each target preset user, dividing the target sample image into a support image and a query image according to a preset ratio; based on the support image, the query image, and the user label, training an initial prototype network model to obtain a target prototype network model, wherein an embedded network of the prototype network model includes a first convolutional layer, a second convolutional layer, a first edge perception module, a third convolutional layer, a second edge perception module, and a fourth convolutional layer connected in sequence, and a loss function of the prototype network model is a joint loss function composed of a baseline loss function and a quaternary loss function; inputting a target image of the target user into the target prototype network model to obtain a recognition result for the target user.

[0151] In one embodiment, before the processor executes the computer program to randomly select a first preset number of target preset users from the multiple initial preset users, it also includes: for each initial sample image, adjusting the size of the initial sample image to a preset size; based on the result of the size adjustment, obtaining the pixel value of each pixel point in the initial sample image; based on the maximum pixel value and the minimum pixel value of all pixel values, normalizing the pixel values ​​in the initial sample image; based on the corresponding average value and standard deviation of all pixel values, standardizing the pixel values ​​in the initial sample image.

[0152] In one embodiment, the processor executes a computer program to train an initial prototype network model based on the supporting image, the query image, and the user label to obtain a target prototype network model, including: inputting the supporting image and the corresponding user label into the initial prototype network model to obtain an intermediate prototype network model; inputting the query image into the intermediate prototype network model to obtain a loss value of the joint loss function; and determining the intermediate prototype network model as the target prototype network model when the loss value is within a preset loss value range or the current training number is not less than a preset training number.

[0153] In one embodiment, the method implemented when the processor executes the computer program also includes: when the loss value is not within the preset loss value range and the current training number is less than the preset training number, updating the model parameters of the initial prototype network model, and determining the prototype network model after the parameter update as the new initial prototype network model; selecting a first preset number of new target preset users from the remaining initial preset users who have not been determined as target preset users; executing the step of randomly selecting a second preset number of target sample images from multiple initial sample images of each target preset user, and continuing to execute until the loss value is within the preset loss value range, or the current training number is not less than the preset training number.

[0154] In one embodiment, a parameter list of an intermediate prototype network model implemented when a processor executes a computer program stores a prototype vector corresponding to each target preset user, wherein the prototype vector is an average vector of a feature vector of a support image corresponding to each target preset user, and the feature vector is generated by the initial prototype network model based on an input support image.

[0155] In one embodiment, the loss value achieved when the processor executes the computer program represents the similarity between the predicted user corresponding to the query image and the target preset user corresponding to the query image, and the predicted user is determined based on the Euclidean distance between the feature vector of the query image and each prototype vector.

[0156] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: obtaining multiple initial sample images of each user among multiple initial preset users and a user label of each initial sample image; randomly selecting a first preset number of target preset users from the multiple initial preset users, and randomly selecting a second preset number of target sample images from the multiple initial sample images of each target preset user; for each target preset user, dividing the target sample images into support images and query images according to a preset ratio; based on the support images, the query images, and the user labels, training an initial prototype network model to obtain a target prototype network model, the embedded network of the prototype network model includes a first convolutional layer, a second convolutional layer, a first edge perception module, a third convolutional layer, a second edge perception module, and a fourth convolutional layer connected in sequence, and the loss function of the prototype network model is a joint loss function composed of a baseline loss function and a quaternary loss function; inputting the target image of the target user into the target prototype network model to obtain a recognition result for the target user.

[0157] In one embodiment, before the computer program is executed by the processor and the first preset number of target preset users are randomly selected from the multiple initial preset users, the program also includes: for each initial sample image, adjusting the size of the initial sample image to a preset size; based on the result of the size adjustment, obtaining the pixel value of each pixel in the initial sample image; based on the maximum pixel value and the minimum pixel value among all the pixel values, normalizing the pixel values ​​in the initial sample image; based on the corresponding average value and standard deviation of all the pixel values, standardizing the pixel values ​​in the initial sample image.

[0158] In one embodiment, the computer program implemented when executed by the processor trains the initial prototype network model based on the supporting image, the query image, and the user label to obtain a target prototype network model, including: inputting the supporting image and the corresponding user label into the initial prototype network model to obtain an intermediate prototype network model; inputting the query image into the intermediate prototype network model to obtain the loss value of the joint loss function; and determining the intermediate prototype network model as the target prototype network model when the loss value is within a preset loss value range or the current training number is not less than the preset training number.

[0159] In one embodiment, the method implemented when the computer program is executed by the processor also includes: when the loss value is not within the preset loss value range and the current training number is less than the preset training number, updating the model parameters of the initial prototype network model, and determining the prototype network model after the parameter update as the new initial prototype network model; selecting a first preset number of new target preset users from the remaining initial preset users who have not been determined as target preset users; executing the step of randomly selecting a second preset number of target sample images from multiple initial sample images of each target preset user, and continuing to execute until the loss value is within the preset loss value range, or the current training number is not less than the preset training number.

[0160] In one embodiment, a parameter list of an intermediate prototype network model implemented when a computer program is executed by a processor stores a prototype vector corresponding to each target preset user, wherein the prototype vector is an average vector of feature vectors of a support image corresponding to each target preset user, and the feature vector is generated by the initial prototype network model based on an input support image.

[0161] In one embodiment, the loss value achieved when the computer program is executed by a processor represents the degree of similarity between the predicted user corresponding to the query image and the target preset user corresponding to the query image, and the predicted user is determined based on the Euclidean distance between the feature vector of the query image and each prototype vector.

[0162] In one embodiment, a computer program product is provided, including a computer program, which implements the following steps when executed by a processor: obtaining multiple initial sample images of each user among multiple initial preset users and a user label of each initial sample image; randomly selecting a first preset number of target preset users from the multiple initial preset users, and randomly selecting a second preset number of target sample images from the multiple initial sample images of each target preset user; for each target preset user, dividing the target sample images into support images and query images according to a preset ratio; based on the support images, the query images, and the user labels, training an initial prototype network model to obtain a target prototype network model, the embedded network of the prototype network model includes a first convolutional layer, a second convolutional layer, a first edge perception module, a third convolutional layer, a second edge perception module, and a fourth convolutional layer connected in sequence, and the loss function of the prototype network model is a joint loss function composed of a baseline loss function and a quaternary loss function; inputting the target image of the target user into the target prototype network model to obtain a recognition result for the target user.

[0163] In one embodiment, before the computer program is executed by the processor and the first preset number of target preset users are randomly selected from the multiple initial preset users, the program also includes: for each initial sample image, adjusting the size of the initial sample image to a preset size; based on the result of the size adjustment, obtaining the pixel value of each pixel in the initial sample image; based on the maximum pixel value and the minimum pixel value among all the pixel values, normalizing the pixel values ​​in the initial sample image; based on the corresponding average value and standard deviation of all the pixel values, standardizing the pixel values ​​in the initial sample image.

[0164] In one embodiment, the computer program implemented when executed by the processor trains the initial prototype network model based on the supporting image, the query image, and the user label to obtain a target prototype network model, including: inputting the supporting image and the corresponding user label into the initial prototype network model to obtain an intermediate prototype network model; inputting the query image into the intermediate prototype network model to obtain the loss value of the joint loss function; and determining the intermediate prototype network model as the target prototype network model when the loss value is within a preset loss value range or the current training number is not less than the preset training number.

[0165] In one embodiment, the method implemented when the computer program is executed by the processor also includes: when the loss value is not within the preset loss value range and the current training number is less than the preset training number, updating the model parameters of the initial prototype network model, and determining the prototype network model after the parameter update as the new initial prototype network model; selecting a first preset number of new target preset users from the remaining initial preset users who have not been determined as target preset users; executing the step of randomly selecting a second preset number of target sample images from multiple initial sample images of each target preset user, and continuing to execute until the loss value is within the preset loss value range, or the current training number is not less than the preset training number.

[0166] In one embodiment, a parameter list of an intermediate prototype network model implemented when a computer program is executed by a processor stores a prototype vector corresponding to each target preset user, wherein the prototype vector is an average vector of feature vectors of a support image corresponding to each target preset user, and the feature vector is generated by the initial prototype network model based on an input support image.

[0167] In one embodiment, the loss value achieved when the computer program is executed by a processor represents the degree of similarity between the predicted user corresponding to the query image and the target preset user corresponding to the query image, and the predicted user is determined based on the Euclidean distance between the feature vector of the query image and each prototype vector.

[0168] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0169] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0170] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0171] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. An image recognition method, It is characterized in that The method comprises: Acquire multiple initial sample images of each user among multiple initial preset users and a user label of each initial sample image; Randomly selecting a first preset number of target preset users from the multiple initial preset users, and randomly selecting a second preset number of target sample images from the multiple initial sample images of each target preset user; For each target preset user, dividing the target sample image into a support image and a query image according to a preset ratio; Based on the support image, the query image, and the user label, an initial prototype network model is trained to obtain a target prototype network model, wherein the embedding network of the prototype network model includes a first convolutional layer, a second convolutional layer, a first edge perception module, a third convolutional layer, a second edge perception module, and a fourth convolutional layer connected in sequence, and a loss function of the prototype network model is a joint loss function composed of a benchmark loss function and a quaternary loss function; The target image of the target user is input into the target prototype network model to obtain a recognition result for the target user.

2. The method according to claim 1, It is characterized in that Before randomly selecting a first preset number of target preset users from the plurality of initial preset users, the method further includes: For each initial sample image, adjusting the size of the initial sample image to a preset size; Based on the result of the size adjustment, a pixel value of each pixel in the initial sample image is obtained; Based on the maximum pixel value and the minimum pixel value among all pixel values, normalizing the pixel values ​​in the initial sample image; The pixel values ​​in the initial sample image are standardized based on the corresponding average values ​​and standard deviations of all pixel values.

3. The method according to claim 1, It is characterized in that The training of the initial prototype network model based on the support image, the query image, and the user label to obtain a target prototype network model includes: Inputting the supporting images and corresponding user labels into the initial prototype network model to obtain an intermediate prototype network model; Inputting the query image into the intermediate prototype network model to obtain the loss value of the joint loss function; When the loss value is within a preset loss value range or the current training times are not less than a preset training times, the intermediate prototype network model is determined as the target prototype network model.

4. The method according to claim 3, It is characterized in that The method further comprises: When the loss value is not within the preset loss value range and the current training number is less than the preset training number, updating the model parameters of the initial prototype network model, and determining the prototype network model after parameter update as a new initial prototype network model; Selecting a first preset number of new target preset users from the remaining initial preset users who have not been determined as target preset users; Execute the step of randomly selecting a second preset number of target sample images from multiple initial sample images of each target preset user, and continue to execute until the loss value is within the preset loss value range, or the current training number is not less than the preset training number.

5. The method according to claim 3, It is characterized in that The parameter list of the intermediate prototype network model stores a prototype vector corresponding to each target preset user, and the prototype vector is an average vector of feature vectors of the support image corresponding to each target preset user, and the feature vector is generated by the initial prototype network model based on the input support image.

6. The method according to claim 5, It is characterized in that The loss value represents the similarity between the predicted user corresponding to the query image and the target preset user corresponding to the query image, and the predicted user is determined based on the Euclidean distance between the feature vector of the query image and each prototype vector.

7. An image recognition device, It is characterized in that The device comprises: An acquisition module, used to acquire a plurality of initial sample images of each user among a plurality of initial preset users and a user label of each initial sample image; A selection module, configured to randomly select a first preset number of target preset users from the plurality of initial preset users, and randomly select a second preset number of target sample images from the plurality of initial sample images of each target preset user; A division module, for dividing the target sample image into a support image and a query image according to a preset ratio for each target preset user; A training module is used to train an initial prototype network model based on the support image, the query image, and the user label to obtain a target prototype network model, wherein the embedding network of the prototype network model includes a first convolutional layer, a second convolutional layer, a first edge perception module, a third convolutional layer, a second edge perception module, and a fourth convolutional layer connected in sequence, and the loss function of the prototype network model is a joint loss function composed of a benchmark loss function and a quaternary loss function; The recognition module is used to input the target image of the target user into the target prototype network model to obtain a recognition result for the target user.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Cited By

  • Ship identification method and device, storage medium and computer program product

    CN121392320A