Image classification method and apparatus, electronic device, and storage medium
Through the image and text feature matching module and multi-modal pre-training model knowledge distillation technology, the problem of difficulty in identifying new false face attacks in silent live detection is solved, rapid identification and defense are achieved, and system security risks are reduced.
Patent Information
- Application Number
- PCT/CN2024/079144
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-07
- Filing Date
- 2024-02-28
- Publication Date
- 2024-09-12
AI Technical Summary
When facing new types of false face attacks, the existing silent liveness detection algorithm has a long iteration process and cannot quickly identify new attacks, resulting in high system security risks.
By extracting the characteristics of the image to be classified and the characteristics of the description text, the image category is determined based on the image-text feature matching module to achieve rapid recognition of new image categories. Multi-modal pre-training models are used for knowledge distillation, reducing the algorithm iteration process and improving calculations. efficiency.
It achieves rapid identification and defense of new image categories, reduces system security risks, and improves defense capabilities against new attacks.
Smart Images

Figure CN2024079144_12092024_PF_FP_ABST
Abstract
Description
Image classification method, device, electronic device and storage medium
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on March 7, 2023, with application number 202310254832.5 and invention name “A method, device, electronic device and storage medium for image classification”, the entire contents of which are incorporated by reference into this application. Technical Field
[0003] The embodiments of the present disclosure relate to the field of data processing technology, and in particular to an image classification method, device, electronic device, and storage medium. Background Art
[0004] Silent liveness detection can be considered a technology that directly determines whether the user in front of the camera is real, without the user having to complete prompts. Silent liveness detection is currently often implemented through data-driven deep learning algorithms. The training data used for model learning is considered to be the determining factor in the algorithm's performance.
[0005] Currently, when algorithms encounter new types of fake face attacks, the algorithm iteration process (including the design / collection and processing of attack data, model training based on attack data, and model updates) takes a long time. Existing methods are unable to quickly identify new attacks, which leads to higher security risks for the systems that support the algorithms and the potential for significant losses when faced with new attacks.
[0006] Summary of the Invention
[0007] The embodiments of the present disclosure provide an image classification method, apparatus, electronic device, and storage medium, which can realize rapid recognition of new image categories.
[0008] In a first aspect, an embodiment of the present disclosure provides an image classification method, comprising:
[0009] Extracting a first image feature of the image to be classified;
[0010] Extracting a first text feature of each description text in a description text set; wherein the description text set corresponds to a target image classification task, and each description text is used to describe each image category under the target image classification task; and the description text set is updated as the image category is updated;
[0011] Determining a target text feature that matches the first image feature from each of the first text features;
[0012] Based on the image category corresponding to the target text feature, a target category of the image to be classified is determined.
[0013] In a second aspect, the present disclosure further provides an image classification device, comprising:
[0014] An image feature extraction module, configured to extract a first image feature of an image to be classified;
[0015] a text feature extraction module configured to extract a first text feature of each description text in a description text set; wherein the description text set corresponds to a target image classification task, and each description text is used to describe each image category under the target image classification task; and wherein the description text set is updated as the image category is updated;
[0016] An image-text feature matching module, configured to determine a target text feature that matches the first image feature from each of the first text features;
[0017] The classification module is used to determine the target category of the image to be classified based on the image category corresponding to the target text feature.
[0018] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0019] one or more processors;
[0020] a storage device for storing one or more programs,
[0021] When the one or more programs are executed by the one or more processors, the one or more processors implement the image classification method as described in any one of the embodiments of the present disclosure.
[0022] In a fourth aspect, an embodiment of the present disclosure further provides a storage medium comprising computer-executable instructions, which, when executed by a computer processor, are used to execute the image classification method as described in any one of the embodiments of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.
[0024] FIG1 is a schematic diagram of a flow chart of an image classification method provided by an embodiment of the present disclosure;
[0025] FIG2 is a framework diagram of an image classification method provided by an embodiment of the present disclosure, wherein the image classification method is executed based on an image classification model;
[0026] FIG3 is a framework diagram of a training process of a first image encoder of an image classification model in an image classification method provided by an embodiment of the present disclosure;
[0027] FIG4 is a framework diagram of the training process of a text encoder and a feature matching layer of an image classification model in an image classification method provided by an embodiment of the present disclosure;
[0028] FIG5 is a schematic structural diagram of an image classification device provided by an embodiment of the present disclosure;
[0029] FIG6 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0030] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0031] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0032] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.
[0033] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0034] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0035] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0036] It is understandable that before using the technical solutions disclosed in the various embodiments of this disclosure, the type, scope of use, usage scenarios, etc. of the personal information involved in this disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0037] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) must comply with the requirements of relevant laws, regulations and relevant provisions.
[0038] Figure 1 is a flow chart illustrating an image classification method provided by an embodiment of the present disclosure. This embodiment of the present disclosure is applicable to image classification scenarios, such as classifying facial images into real and fake facial images in silent liveness detection. This method can be performed by an image classification device, which can be implemented in software and / or hardware and can be configured in an electronic device, such as a mobile phone or computer.
[0039] As shown in FIG1 , the image classification method provided in this embodiment may include:
[0040] S110, extracting a first image feature of the image to be classified;
[0041] S120, extracting a first text feature of each description text in the description text set; wherein the description text set corresponds to the target image classification task, and each description text is used to describe each image category under the target image classification task; and the description text set is updated as the image category is updated;
[0042] S130, determining a target text feature that matches the first image feature from each first text feature;
[0043] S140 : Determine a target category of the image to be classified based on the image category corresponding to the target text feature.
[0044] The image classification method provided in this embodiment can be implemented using a trained deep learning model. The deep learning model can include at least a network structure for extracting image features, a network structure for extracting text features, and a network structure for matching image and text features, and each of these network structures can be built based on existing related network structures.
[0045] Correspondingly, the first image features of the image to be classified can be extracted through the network structure for extracting image features; the first text features of each descriptive text can be extracted through the network structure for extracting text features; the matching degree between each first text feature and the first image feature can be determined through the network structure for matching image and text features, and the first text feature with the highest matching degree can be used as the target text feature to match the first image feature.
[0046] Different image classification tasks may correspond to different description text sets. The description text set in the embodiment of the present disclosure may correspond to a target image classification task performed on an image to be classified. The target image classification task may include a task of dividing the image to be classified into at least two image categories; accordingly, the description text set may include description texts for describing at least two image categories under the target image classification task. The description text set may be updated as the image category is updated. For example, when an image category under the target image classification task is added, deleted, or modified, the description text in the description text set may be added, deleted, or modified accordingly.
[0047] For example, Table 1 shows the description text set corresponding to the liveness detection task. The image categories under the liveness detection task can include subcategories within the parent category, the real face category, and subcategories within the parent category, the fake face category. Accordingly, the description text set can include description text for subcategories of the real face category and subcategories of the fake face category.
[0048] Table 1
[0049] As shown in Table 1, each subcategory can be considered an image category, and each image category can correspond to at least one descriptive text. The descriptive text can be considered explanatory text for the corresponding image category and can be constructed based on experience or experimentation. In some implementations, each image category can also correspond to at least two descriptive texts. This allows for multi-faceted textual descriptions of image categories, which can help improve subsequent image classification.
[0050] Furthermore, for any parent category of the target image classification task, there may be only one subcategory under that parent category. For example, in Table 1, the parent category of real faces does not necessarily have multiple corresponding subcategories. It can be treated as its only subcategory and provided with a corresponding text description.
[0051] After the first text features of the descriptive text are initially extracted, they can be stored in a preset storage space. Furthermore, the first text features in the preset storage space can be updated as the descriptive text in the descriptive text set is updated. Accordingly, when the first image features of the image to be classified are extracted, the first text features corresponding to each descriptive text can also be directly retrieved from the preset storage space. This allows for feature matching with the first image features of multiple images to be classified by performing feature extraction only once for each currently updated descriptive text, thereby saving computing resources.
[0052] After determining the target text feature that matches the first image feature, the target category of the image to be classified can be determined based on the image category corresponding to the extracted description text of the target text feature. For example, the subcategory corresponding to the extracted description text of the target text feature can be used as the target category for the facial image; alternatively, the parent category of the subcategory corresponding to the extracted description text of the target text feature can be used as the target category for the facial image.
[0053] In the disclosed embodiment, the update of the image category may occur during any step of the image classification method; accordingly, the descriptive text set can be updated synchronously with the update of the image category. In addition, when the descriptive text set is updated (for example, the descriptive text inside it is added, deleted, changed, etc.), the first text feature corresponding to the descriptive text can also be updated in the preset storage space. Therefore, in the image classification process after the image category is updated, the first image feature of the image to be classified can be matched with the first text feature in the latest updated preset storage space to determine the target category of the image to be classified. In the case where the target category is the latest updated image category, it is achieved to quickly model a new image category using the descriptive text, and complete zero-sample prediction through cross-modal feature matching, thereby achieving rapid recognition of the new image category.
[0054] In some optional implementations, the method is applied to an image classification model, and at least a portion of the image classification model can be obtained based on knowledge distillation of a multimodal pre-trained model; wherein the multimodal pre-trained model is used to process data in at least image modality and text modality.
[0055] The deep learning model used to perform the image classification method of the present disclosure can be referred to as an image classification model. For example, FIG2 is a framework diagram of a classification method based on an image classification model in an image classification method provided by an embodiment of the present disclosure.
[0056] Referring to FIG2 , the image classification model may include at least a first network structure for extracting image features, a second network structure for extracting text features, and a third network structure for matching image and text features. Among them, the image to be classified can be input into the first network structure so that it extracts the first image features; the most recently updated description text in the description text set can be input into the second network structure so that it extracts each first text feature. The first image features and the first text features can be input into the third network structure so that it outputs the degree of matching between each first text feature and the first image feature (such as a similarity vector), and the first text feature with the highest degree of matching can be used as the target text feature that matches the first image feature (such as text feature 0 in FIG2 ). Furthermore, the target category can be determined based on the image category corresponding to the target text feature. For example, in FIG2 , subcategory 0 or parent category 0 can be determined as the target category.
[0057] The multimodal pre-trained model can be pre-trained based on large-scale, multimodal general sample data to obtain the ability to extract data features from at least the image modality and text modality, as well as the ability to match cross-modal features, including at least image-text feature matching. In other words, the multimodal pre-trained model can be used to process data from at least the image modality and text modality. It can be considered that if the multimodal pre-trained model is trained for downstream tasks based on training data related to the target image classification task, then the trained multimodal pre-trained model can also be called an image classification model, and can also implement the image classification method of the present disclosure.
[0058] Furthermore, referring again to the image classification model in FIG2 , at least portions of the first, second, and third network structures in the model can be obtained through knowledge distillation based on a multimodal pre-training model. For example, the first network structure can be obtained through knowledge distillation based on a network structure for extracting image features in a multimodal pre-training model; another example is that the second and third network structures can be obtained through knowledge distillation based on a network structure for extracting text features and a network structure for matching image and text features in a multimodal pre-training model, respectively; another example is that the first, second, and third network structures can all be obtained through knowledge distillation based on corresponding network structures in a multimodal pre-training model.
[0059] Among these optional implementations, for some image classification tasks, such as liveness detection tasks, the amount of training data is usually very limited, and the multimodal pre-training model is trained based on large-scale general sample data. The image classification model obtained on this basis (for example, the image classification model obtained through downstream task training, knowledge distillation, etc.) will also have a more generalized cross-modal feature matching capability. For target image classification tasks with limited training data, when encountering new image categories, it is also possible to accurately match the new image categories with the new description texts while establishing new descriptions, and complete the recognition of the new image categories. In addition, the image classification model obtained by knowledge distillation is more lightweight than the multimodal pre-training model, which is conducive to improving computational efficiency and model deployment.
[0060] The technical solution of the embodiment of the present disclosure is to extract the first image feature of the image to be classified; extract the first text feature of each description text in the description text set; wherein the description text set corresponds to the target image classification task, and each description text is used to describe each image category under the target image classification task; and the description text set is updated as the image category is updated; determine the target text feature that matches the first image feature from each first text feature; and determine the target category of the image to be classified based on the image category corresponding to the target text feature. By using a method based on image-text feature matching, when a new image category appears, it is possible to quickly identify the new image category by simply updating the relevant description text without the need for an algorithm iteration process.
[0061] The embodiments of the present disclosure can be combined with the various optional solutions in the image classification method provided in the above embodiments. This embodiment describes in detail the training steps of the image classification model for executing the image classification method.
[0062] In an embodiment of the present disclosure, the image classification model may include a first image encoder, the multimodal pre-training model may include a second image encoder, and the number of parameters of the first image encoder is smaller than the number of parameters of the second image encoder.
[0063] In this embodiment, the network structure for extracting image features in the image classification model can be referred to as the first image encoder, and the network structure for extracting image features in the multimodal pre-training model can be referred to as the second image encoder. The first image encoder may have fewer parameters than the second image encoder, which may include the first image encoder having fewer network layers than the second image encoder, and / or the number of channels in each network layer being smaller than the second image encoder. Therefore, by performing knowledge distillation training on the first image encoder, not only can the image encoding capabilities of the second image encoder be transferred to the first image encoder, but a more lightweight image feature extraction network can also be obtained.
[0064] For example, FIG3 is a framework diagram of the training process of the first image encoder of the image classification model in an image classification method provided by an embodiment of the present disclosure. As shown in FIG3, in the image classification method provided by this embodiment, the training process of the first image encoder may include:
[0065] The first sample image is encoded using a first image encoder to obtain second image features. The first sample image includes a second sample image related to the target image classification task and may also include general sample images, such as images from open source databases such as ImageNet. The general sample images may be unrelated to the target image classification task. By using general sample images and second sample images related to the target image classification task to perform distillation training on the image encoder of the image classification model, the versatility of feature extraction by the image encoder in the image classification model can be improved.
[0066] The first sample image is encoded by the second image encoder to obtain a third image feature. The encoding processes of the first image encoder and the second image encoder do not have a strict time sequence relationship.
[0067] A distillation loss is determined based on the second image features and the third image features, and the first image encoder is trained based on the distillation loss. The distillation loss can be determined using an existing feature-image loss algorithm, such as mean absolute value loss (L1Loss). Backpropagation can be performed based on the distillation loss to adjust parameters of the first image encoder, thereby achieving distillation training for the first image encoder.
[0068] The training framework shown in Figure 3 is considered to be effective only during the first image encoder training phase. After training is complete, only the first image encoder portion is retained to extract the first image features of the image to be classified. Since the image encoder in image classification tasks requires a large amount of computation, knowledge distillation of the image encoder used in multimodal pre-training can be used to obtain the image encoder used in the image classification model. This can significantly reduce the computational load of the image encoder in the image classification model, thereby improving computational efficiency.
[0069] In the disclosed embodiment, the image classification model may further include a text encoder and a feature matching layer of a multimodal pre-trained model.
[0070] After pre-training the multimodal pre-trained model on large-scale, multimodal, general sample data, the parameters of its internal text encoder and feature matching layer can be assigned to the text encoder and feature matching layer of the image classification model, respectively. Subsequently, the parameters of the text encoder and feature matching layer of the image classification model can be adjusted based on second sample data related to the image classification task to adapt them to the image classification task.
[0071] For example, FIG4 is a framework diagram of the training process of the text encoder and feature matching layer of the image classification model in an image classification method provided by an embodiment of the present disclosure. As shown in FIG4 , in the image classification method provided by this embodiment, the training process of the text encoder and feature matching layer may include:
[0072] Extracting fourth image features of a second sample image relevant to the target image classification task. The first image encoder in the image classification model can be trained first, and the trained first image encoder can be used to extract the fourth image features of the second sample image. Alternatively, the first image encoder and the text encoder and feature matching layer in the image classification model can be trained simultaneously, so that the trained first image encoder can be used to extract the fourth image features of the second sample image.
[0073] The description texts corresponding to the image categories in the target image classification task are encoded using a text encoder to obtain second text features. The description texts in the description text set can be pre-constructed for each image category in the target image classification task. Accordingly, the description texts can be encoded using a text encoder to obtain second text features.
[0074] The similarity between each second text feature and the fourth image feature is determined through the feature matching layer. The similarity can represent the degree of matching between the image and text features, and the greater the similarity, the higher the degree of image and text matching.
[0075] The predicted category of the second sample image is determined based on the similarities. Typically, the predicted category of the second sample image can be determined based on the image category corresponding to the second text feature with the greatest similarity.
[0076] The supervised loss is determined based on the predicted category and the category label corresponding to the second sample image, and the feature matching layer and the text encoder are trained based on the supervised loss. The predicted category of each second sample image can constitute a predicted category vector, and the category label corresponding to the second sample image can constitute a label vector. The supervised loss can be determined by an existing inter-vector loss algorithm, such as Cross Entropy Loss (CE Loss). Backpropagation can be performed based on the supervised loss to adjust the parameters of the text encoder and feature matching layer of the image classification model, thereby achieving supervised training of the text encoder and feature matching layer of the image classification model.
[0077] Since the text encoder requires less computation in image classification tasks, by adjusting the parameters of the text encoder and feature matching layer in multimodal pre-training using only sample images related to the image classification task, it can not only adapt to the image classification task but also avoid the resource loss caused by this part of distillation training.
[0078] In some optional implementations, each image category under the target image classification task belongs to a subcategory of a binary classification parent category, and the category label corresponding to the second sample image is a binary classification label; accordingly, determining the predicted category of the second sample image based on each similarity can include: fusing the similarities corresponding to each image category belonging to the same parent category to obtain a binary classification predicted category.
[0079] Referring to the example in Table 1, if the target image classification task is liveness detection, each subcategory can be an image category, and can belong to two parent categories: a fake face category and a real face category. The category label corresponding to the second sample image is a binary label, which can include both fake face and real face categories.
[0080] Referring to Figure 4 again, in these cases, an additional aggregation layer can be added during the model training process to fuse the similarities corresponding to the image categories belonging to the same parent category to obtain the predicted category of the two categories. In these optional implementations, by fusing the similarities under the same parent category, supervised training of the model based on the two-category labels can be achieved. Among them, similarity fusion can be considered to be performed only in the training phase, but not in the prediction phase, that is, the aggregation layer set in the model can only participate in the training process of the image classification model as an auxiliary module to facilitate the determination of the loss, and is not a module that needs to be included in the inference of the image classification model.
[0081] The technical solution of the embodiment of the present disclosure describes in detail the training steps of the image classification model for executing the image classification method. Since the image encoder has a large amount of computation in the image classification task, the image encoder in the image classification model is obtained by performing knowledge distillation on the image encoder in the multimodal pre-training, which can greatly reduce the amount of computation of the image encoder in the image classification model and help improve computational efficiency. Since the text encoder has a small amount of computation in the image classification task, by adjusting the parameters of the text encoder and feature matching layer in the multimodal pre-training using only sample images related to the image classification task, it can not only adapt to the image classification task, but also avoid the resource loss caused by this part of the distillation training.
[0082] In addition, the image classification method provided in the embodiment of the present disclosure and the image classification method provided in the above embodiment belong to the same public concept. Technical details not fully described in this embodiment can be referred to the above embodiment, and the same technical features have the same beneficial effects in this embodiment and the above embodiment.
[0083] The various optional schemes in the image classification method provided in the embodiment of the present disclosure and the above embodiment can be combined. In the image classification method provided in this embodiment, the target image classification task may include silent liveness detection, and the image category may include subcategories of real face categories and subcategories of false face categories. By classifying facial images into real face images and false face images, it can provide a basis for whether the system executes subsequent business (such as account login, financial payment, access control verification, etc.).
[0084] The image classification method provided in this embodiment, when applied to the scenario of silent living body detection, may include:
[0085] First, a facial image is acquired. In this embodiment, the facial image can be considered as an image to be classified, and the facial image can be collected by a camera of the system.
[0086] Next, a first image feature of the facial image is extracted. The first image feature can be extracted from the facial image by an image encoder in a living body detection model (ie, an image classification model).
[0087] Secondly, the first text features of each description text in the description text set are extracted. The description text set corresponds to silent liveness detection, and each description text in the description text set can be used to describe subcategories of the real face category and subcategories of the fake face category under silent liveness detection. Furthermore, the description text set can be updated as the image category is updated. That is, once the subcategories of the real face category and / or the subcategories of the fake face category are updated, the description text set is updated accordingly. For example, in some implementations, the description text corresponding to the subcategories of the real face category / virtual face category in the description text set can be updated accordingly in response to an update instruction (such as an update instruction to add, delete, or modify) for a subcategory of the real face category / virtual face category. After each update of the description text set, the first text features of each description text in the updated description text set can be extracted by the text encoder in the liveness detection model and stored together with the description text in a preset storage space. Accordingly, the first text features of each description text can be directly obtained from the preset storage space to save computing resources.
[0088] Next, a target text feature that matches the first image feature is determined from each of the first text features. The degree of matching between each of the first text features and the first image feature can be determined using a feature matching layer in the liveness detection model, and the first text feature with the highest degree of matching can be used as the target text feature that matches the first image feature.
[0089] Finally, the target category of the image to be classified is determined based on the subcategory corresponding to the target text feature.
[0090] In these optional implementations, when a new type of fake face attack appears, a subcategory of the fake face category can be added for the new attack, and a description text of the newly added subcategory can be constructed accordingly. The newly added description text can obtain the corresponding first text feature through the text encoder in the liveness detection model, and then can be matched with the first image feature of the facial image obtained subsequently to detect whether the facial image belongs to the new subcategory. In the absence of training data for the new attack, it is possible to efficiently generate the feature center of the corresponding attack by simply describing the attack, and recall such attacks through feature matching, which can greatly improve the defense capability against the image category of the new attack in the liveness detection task.
[0091] The technical solution of the embodiment of the present disclosure, the target image classification task may include silent liveness detection, and the image category includes subcategories of real face categories and subcategories of fake face categories. By classifying facial images into real face images and fake face images, it can provide a basis for whether the system executes subsequent services (such as account login, financial payment, access control verification, etc.). The image classification method provided by the embodiment of the present disclosure and the image classification method provided by the above embodiment belong to the same public concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and the same technical features have the same beneficial effects in this embodiment and the above embodiment.
[0092] Figure 5 is a schematic diagram of the structure of an image classification device provided by an embodiment of the present disclosure. The image classification device provided by this embodiment is applicable to image classification scenarios, such as classification of facial images into real facial images and false facial images in silent liveness detection.
[0093] As shown in FIG5 , the image classification device provided by the embodiment of the present disclosure may include:
[0094] An image feature extraction module 510 is used to extract a first image feature of an image to be classified;
[0095] A text feature extraction module 520 is configured to extract a first text feature of each description text in a description text set; wherein the description text set corresponds to a target image classification task, and each description text is used to describe each image category under the target image classification task; and the description text set is updated as the image category is updated;
[0096] An image-text feature matching module 530 is configured to determine a target text feature that matches the first image feature from each first text feature;
[0097] The classification module 540 is configured to determine a target category of the image to be classified based on the image category corresponding to the target text feature.
[0098] In some optional implementations, the method is applied to an image classification model, and at least part of the image classification model is obtained based on knowledge distillation of a multimodal pre-trained model; wherein the multimodal pre-trained model is used to process data in at least image modality and text modality.
[0099] In some optional implementations, the image classification model may include a first image encoder, the multimodal pre-trained model may include a second image encoder, and the number of parameters of the first image encoder is smaller than the number of parameters of the second image encoder;
[0100] Accordingly, the image classification device may further include:
[0101] A model training module is configured to train a first image encoder based on the following steps:
[0102] Encoding the first sample image by a first image encoder to obtain a second image feature; the first sample image includes a second sample image related to the target image classification task;
[0103] encoding the first sample image by a second image encoder to obtain a third image feature;
[0104] A distillation loss is determined based on the second image features and the third image features, and the first image encoder is trained based on the distillation loss.
[0105] In some optional implementations, the image classification model may include a text encoder and feature matching layer of a multimodal pre-trained model;
[0106] The model training module can be used to train the text encoder and feature matching layer based on the following steps:
[0107] extracting a fourth image feature of the second sample image related to the target image classification task;
[0108] Encode each description text corresponding to each image category under the target image classification task through a text encoder to obtain each second text feature;
[0109] Determining, through a feature matching layer, a similarity between each second text feature and the fourth image feature;
[0110] determining a predicted category of the second sample image according to each similarity;
[0111] A supervision loss is determined according to the predicted category and the category label corresponding to the second sample image, and the feature matching module and the text encoder are trained according to the supervision loss.
[0112] In some optional implementations, each image category under the target image classification task is a subcategory of a binary classification parent category, and the category label is a binary classification label;
[0113] Correspondingly, the model training module can be used to: fuse the similarities corresponding to each image category belonging to the same parent category to obtain a binary classification prediction category.
[0114] In some optional implementations, each image category corresponds to at least two description texts.
[0115] In some optional implementations, the target image classification task may include silent living body detection, and the image category may include subcategories of a real face category and subcategories of a fake face category.
[0116] The image classification device provided in the embodiments of the present disclosure can execute the image classification method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0117] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0118] Reference is now made to FIG6 , which illustrates a schematic diagram of the structure of an electronic device (e.g., a terminal device or server in FIG6 ) 600 suitable for implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. The electronic device illustrated in FIG6 is merely an example and should not limit the functionality and scope of use of the embodiments of the present disclosure.
[0119] As shown in Figure 6, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. Various programs and data required for the operation of the electronic device 600 are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0120] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although FIG. 6 shows the electronic device 600 with various devices, it should be understood that not all of the devices shown are required to be implemented or present. More or fewer devices may alternatively be implemented or present.
[0121] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the image classification method of the embodiment of the present disclosure are performed.
[0122] The electronic device provided by the embodiment of the present disclosure and the image classification method provided by the above embodiment belong to the same disclosed concept. For technical details not fully described in this embodiment, please refer to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0123] An embodiment of the present disclosure provides a computer storage medium having a computer program stored thereon. When the program is executed by a processor, the image classification method provided by the above embodiment is implemented.
[0124] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM) or flash memory (FLASH), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0125] In some embodiments, the client and server can communicate using any currently known or later developed network protocol, such as HTTP (Hypertext Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or later developed network.
[0126] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0127] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0128] Extract the first image feature of the image to be classified; extract the first text feature of each description text in the description text set; wherein the description text set corresponds to the target image classification task, and each description text is used to describe each image category under the target image classification task; and the description text set is updated as the image category is updated; determine the target text feature that matches the first image feature from each first text feature; and determine the target category of the image to be classified based on the image category corresponding to the target text feature.
[0129] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0130] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0131] The units involved in the embodiments described in this disclosure may be implemented in software or hardware, wherein the names of the units and modules do not, in certain circumstances, limit the units and modules themselves.
[0132] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: Field Programmable Gate Array (FPGA), Application Specific Integrated Circuit (ASIC), Application Specific Standard Parts (ASSP), System on Chip (SOC), Complex Programmable Logic Device (CPLD), and the like.
[0133] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0134] According to one or more embodiments of the present disclosure, there is provided an image classification method, the method comprising:
[0135] Extracting a first image feature of the image to be classified;
[0136] Extracting a first text feature of each description text in a description text set; wherein the description text set corresponds to a target image classification task, and each description text is used to describe each image category under the target image classification task; and the description text set is updated as the image category is updated;
[0137] Determining a target text feature that matches the first image feature from each of the first text features;
[0138] Based on the image category corresponding to the target text feature, a target category of the image to be classified is determined.
[0139] According to one or more embodiments of the present disclosure, there is provided an image classification method, further comprising:
[0140] In some optional implementations, the method is applied to an image classification model, and at least part of the image classification model is obtained based on knowledge distillation of a multimodal pre-trained model; wherein the multimodal pre-trained model is used to process data in at least image modality and text modality.
[0141] According to one or more embodiments of the present disclosure, there is provided an image classification method, further comprising:
[0142] In some optional implementations, the image classification model includes a first image encoder, the multimodal pre-trained model includes a second image encoder, and the number of parameters of the first image encoder is smaller than the number of parameters of the second image encoder;
[0143] The training step of the first image encoder includes:
[0144] encoding a first sample image by the first image encoder to obtain a second image feature; wherein the first sample image includes a second sample image related to the target image classification task;
[0145] encoding the first sample image by using the second image encoder to obtain a third image feature;
[0146] A distillation loss is determined based on the second image feature and the third image feature, and the first image encoder is trained based on the distillation loss.
[0147] According to one or more embodiments of the present disclosure, there is provided an image classification method, further comprising:
[0148] In some optional implementations, the image classification model includes a text encoder and a feature matching layer of the multimodal pre-trained model;
[0149] The training steps of the text encoder and the feature matching layer include:
[0150] extracting a fourth image feature of the second sample image related to the target image classification task;
[0151] Encoding each description text corresponding to each image category under the target image classification task by the text encoder to obtain each second text feature;
[0152] Determining, through the feature matching layer, the similarity between each of the second text features and the fourth image feature;
[0153] determining a predicted category of the second sample image according to each of the similarities;
[0154] A supervision loss is determined according to the predicted category and a category label corresponding to the second sample image, and the feature matching module and the text encoder are trained according to the supervision loss.
[0155] According to one or more embodiments of the present disclosure, there is provided an image classification method, further comprising:
[0156] In some optional implementations, each image category under the target image classification task belongs to a subcategory of a binary classification parent category, and the category label is a binary classification label;
[0157] Correspondingly, determining the predicted category of the second sample image according to the similarities includes: fusing the similarities corresponding to the image categories belonging to the same parent category to obtain a binary predicted category.
[0158] According to one or more embodiments of the present disclosure, there is provided an image classification method, further comprising:
[0159] In some optional implementations, each image category corresponds to at least two description texts.
[0160] According to one or more embodiments of the present disclosure, there is provided an image classification method, further comprising:
[0161] In some optional implementations, the target image classification task includes silent living body detection, and the image category includes subcategories of a real face category and subcategories of a fake face category.
[0162] According to one or more embodiments of the present disclosure, there is provided an image classification apparatus, the apparatus comprising:
[0163] An image feature extraction module, configured to extract a first image feature of an image to be classified;
[0164] a text feature extraction module configured to extract a first text feature of each description text in a description text set; wherein the description text set corresponds to a target image classification task, and each description text is used to describe each image category under the target image classification task; and wherein the description text set is updated as the image category is updated;
[0165] An image-text feature matching module, configured to determine a target text feature that matches the first image feature from each of the first text features;
[0166] The classification module is used to determine the target category of the image to be classified based on the image category corresponding to the target text feature.
[0167] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.
[0168] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0169] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. An image classification method, comprising: Extracting a first image feature of the image to be classified; Extracting the first text feature of each description text in the description text set; wherein the description text set corresponds to a target image classification task, and each description text is used to describe each image category under the target image classification task; and the description text set is updated as the image category is updated; Determining a target text feature that matches the first image feature from each of the first text features; Based on the image category corresponding to the target text feature, a target category of the image to be classified is determined.
2. The method according to claim 1, wherein: The method is applied to an image classification model, and at least part of the image classification model is obtained based on knowledge distillation of a multimodal pre-trained model; wherein the multimodal pre-trained model is at least used to process data in image modality and text modality.
3. The method according to claim 2, wherein: The image classification model includes a first image encoder, the multimodal pre-training model includes a second image encoder, and the parameter amount of the first image encoder is smaller than the parameter amount of the second image encoder; The training step of the first image encoder includes: The first sample image is encoded by the first image encoder to obtain a second image feature; the first sample image includes a second sample image related to the target image classification task; encoding the first sample image by using the second image encoder to obtain a third image feature; A distillation loss is determined according to the second image feature and the third image feature, and the first image encoder is trained according to the distillation loss.
4. The method according to claim 2, wherein: The image classification model includes a text encoder and a feature matching layer of the multimodal pre-trained model; The training steps of the text encoder and the feature matching layer include: Extracting a fourth image feature of the second sample image related to the target image classification task; Encoding each description text corresponding to each image category under the target image classification task by the text encoder to obtain each second text feature; Determining the similarity between each of the second text features and the fourth image feature through the feature matching layer; Determining a predicted category of the second sample image according to each of the similarities; A supervision loss is determined according to the predicted category and a category label corresponding to the second sample image, and the feature matching module and the text encoder are trained according to the supervision loss.
5. The method according to claim 4, wherein: Each image category under the target image classification task belongs to a subcategory of a binary classification parent category, and the category label is a binary classification label; Correspondingly, determining the predicted category of the second sample image according to the similarities includes: fusing the similarities corresponding to the image categories belonging to the same parent category to obtain a binary predicted category.
6. The method according to claim 1, wherein: Each of the image categories corresponds to at least two description texts.
7. The method according to any one of claims 1 to 6, wherein: The target image classification task includes silent living body detection, and the image categories include subcategories of real face categories and subcategories of false face categories.
8. An image classification device, comprising: An image feature extraction module, used to extract a first image feature of an image to be classified; A text feature extraction module, used to extract the first text feature of each description text in a description text set; wherein the description text set corresponds to a target image classification task, and each description text is used to describe each image category under the target image classification task; and the description text set is updated as the image category is updated; An image-text feature matching module, used to determine a target text feature that matches the first image feature from each of the first text features; The classification module is used to determine the target category of the image to be classified based on the image category corresponding to the target text feature.
9. An electronic device, comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the image classification method as described in any one of claims 1-7.
10. A storage medium comprising computer executable instructions, wherein the computer executable instructions are used to perform the image classification method according to any one of claims 1 to 7 when executed by a computer processor.
Citation Information
Patent Citations
Human face living body detection method and device, computer equipment and storage medium
CN111767900A
Image classification method and device, computer equipment and medium
CN114741581A
Multi-modal data-based heavy balance long-tail image data classification method
CN115205592A
Image recognition method and device, electronic equipment and storage medium
CN115331150A
Detection model training method and device, detection model classification method and device and electronic equipment
CN116129224A
Cited By
Cross-modal fusion-guided CLIP domain generalization face anti-counterfeiting method
CN119339447A
Image detection method and device, electronic equipment and storage medium
CN119445549A
Image labeling method and device, storage medium and computer equipment
CN120544201A
