Image classification method, device, electronic device and storage medium

By dynamically generating mixing parameters in an iterative manner and performing multiple rounds of mixing processing on image features, the problem of the inability of image classification models to adapt to different image features in the existing technology is solved, and the classification accuracy is significantly improved.

CN114494774BActive Publication Date: 2024-09-06TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210078318.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-24
Publication Date
2024-09-06
Estimated Expiration
2042-01-24

AI Technical Summary

Technical Problem

The existing image classification model based on multi-layer perceptron (MLP) cannot effectively adapt to the characteristics of different images due to the use of static mixing parameters, resulting in low classification accuracy.

Method used

Iteratively dynamically generates mixing parameters and performs multiple rounds of mixing processing on image features to improve the mixing performance of the image classification model and adapt to different image features.

Benefits of technology

The classification accuracy of the image classification model is significantly improved, and the dynamically generated mixing parameters can better adapt to different image features and improve the performance of the image classification model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114494774B
    Figure CN114494774B
Patent Text Reader

Abstract

The present application discloses an image classification method, device, electronic device and storage medium, which relates to the field of artificial intelligence technology and can be applied to various scenarios such as cloud technology, artificial intelligence, smart transportation, and assisted driving. The method includes: dividing the image to be classified into multiple image blocks through a trained target image classification model, and extracting the image features of each of the multiple image blocks; based on the multiple image features, performing hybrid processing in an iterative manner to obtain corresponding multiple target hybrid features; wherein one round of hybrid processing includes: generating hybrid parameters based on the multiple image features input in this round, and outputting multiple intermediate hybrid features based on the hybrid parameters and the multiple image features, and obtaining multiple new image features based on the multiple intermediate hybrid features; performing classification prediction on the image to be classified based on the multiple target hybrid features to obtain the classification result of the image to be classified. The present application can effectively improve the accuracy of image classification.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] With the continuous development of computer vision technology in artificial intelligence, image classification technology based on computer vision has been widely used. Image classification technology refers to distinguishing different categories of images based on the high-level semantics of the image.

[0003] In related technologies, image classification technology can use an image classification model based on a multilayer perceptron (MLP) to achieve image classification; where MLP is a basic network in deep learning. When classifying an image, the MLP-based image classification model can divide the image into multiple blocks of a specified size and extract the features of each block; then use the trained parameter matrix to mix multiple features to exchange information in space; and then output the classification result based on the mixed features.

[0004] However, since different images have different characteristics, the above parameter matrix cannot adapt to the characteristics of all images, thereby limiting the classification performance of the image classification model and making the classification accuracy of the image classification model low. Summary of the invention

[0005] The embodiments of the present application provide an image classification method, device, electronic device and storage medium for improving the classification accuracy of an image classification model.

[0006] On the one hand, an embodiment of the present application provides an image classification method, comprising:

[0007] Using the trained target image classification model, the image to be classified is divided into a plurality of image blocks, and image features of each of the plurality of image blocks are extracted;

[0008] By using the target image classification model, based on multiple image features, a mixing process is performed in an iterative manner to obtain a corresponding multiple target mixed features; wherein one round of mixing process includes: generating mixing parameters based on multiple image features input in this round, and outputting multiple intermediate mixed features based on the mixing parameters and the multiple image features, and obtaining multiple new image features based on the multiple intermediate mixed features;

[0009] The target image classification model is used to perform classification prediction on the image to be classified based on the multiple target mixed features to obtain a classification result of the image to be classified.

[0010] On the one hand, an embodiment of the present application provides an image classification device, including:

[0011] A feature extraction module, used to divide the image to be classified into a plurality of image blocks by using a trained target image classification model, and to extract image features of each of the plurality of image blocks;

[0012] A feature mixing module, used to perform mixing processing in an iterative manner based on multiple image features through the target image classification model to obtain multiple corresponding target mixed features; wherein one round of mixing processing includes: generating mixing parameters based on multiple image features input in this round, and outputting multiple intermediate mixed features based on the mixing parameters and the multiple image features, and obtaining multiple new image features based on the multiple intermediate mixed features;

[0013] The classification module is used to perform classification prediction on the image to be classified based on the multiple target mixed features through the target image classification model to obtain the classification result of the image to be classified.

[0014] Optionally, when generating the mixing parameters based on the multiple image features, the feature mixing module is further used to:

[0015] dividing the plurality of image features into at least one image feature set, wherein different image feature sets have the same number of image features;

[0016] For the at least one image feature set, the following operations are respectively performed: generating a mixing matrix based on an image feature set;

[0017] The mixing matrix corresponding to each of the at least one image feature set is used as the mixing parameter.

[0018] Optionally, each image feature corresponds to a multidimensional vector including multiple feature dimensions, and when generating a mixing matrix based on an image feature set, the feature mixing module is further used to:

[0019] Performing dimensionality reduction processing on each image feature in an image feature set to obtain a corresponding plurality of first dimensionality reduction vectors;

[0020] The multiple first dimension reduction vectors are concatenated into a first fused feature vector, and the first fused feature vector is converted into the mixing matrix.

[0021] Optionally, each image feature corresponds to a multidimensional vector including multiple feature dimensions, and when generating a mixing matrix based on an image feature set, the feature mixing module is further used to:

[0022] For each image feature in the one image feature set, the following operations are performed respectively: multiple feature dimensions of one image feature are divided into multiple segments to obtain segment features corresponding to each of the multiple segments; wherein each segment corresponds to at least one feature dimension, and different segments have the same number of feature dimensions;

[0023] For each of the plurality of segment features corresponding to each of the image features, a corresponding sub-mixing matrix is ​​generated based on each of the segment features corresponding to the same segment, so as to obtain a sub-mixing matrix corresponding to each of the plurality of segments;

[0024] The obtained multiple sub-mixing matrices are used as the mixing matrix.

[0025] Optionally, when generating corresponding sub-mixing matrices based on the segment features corresponding to the same segment to obtain the sub-mixing matrices corresponding to the multiple segments, the feature mixing module is further used to:

[0026] For multiple segments, perform the following operations:

[0027] Perform dimensionality reduction processing on each segment feature corresponding to a segment to obtain a corresponding plurality of second dimensionality reduction vectors;

[0028] The multiple second dimensionality reduction vectors are concatenated into a second fused feature vector, and the second fused feature vector is converted into the sub-mixing matrix.

[0029] Optionally, when outputting the multiple intermediate mixed features based on the mixing parameter and the multiple image features, the feature mixing module is further used to:

[0030] Obtaining a plurality of candidate mixed features according to the mixed parameter and the plurality of image features;

[0031] Based on the multiple candidate mixed features, the following operations are performed in an iterative manner: generating new mixed parameters based on the multiple candidate mixed features input this time, and obtaining new multiple candidate mixed features according to the new mixed parameters and the multiple candidate mixed features;

[0032] The multiple candidate mixed features outputted last time are used as the multiple intermediate mixed features.

[0033] Optionally, when obtaining a plurality of candidate mixed features according to the mixing parameter and the plurality of image features, the feature mixing module is further used to:

[0034] Obtaining a corresponding plurality of spatial mixing features according to the at least one image feature set and respective mixing matrices;

[0035] Based on the multiple spatial mixture features, the multiple candidate mixture features are output through a fully connected layer.

[0036] Optionally, the mixing matrix includes a plurality of sub-mixing matrices, and each image feature in each image feature set includes: segment features corresponding to a plurality of segments, each segment corresponding to a sub-mixing matrix;

[0037] When obtaining the corresponding plurality of spatial mixing features according to the at least one image feature set and the respective mixing matrices, the feature mixing module is further used for:

[0038] For the at least one image feature set, the following operations are performed respectively:

[0039] Based on a plurality of segment features corresponding to each image feature in an image feature set, each segment feature corresponding to the same segment is multiplied with a corresponding sub-mixing matrix to obtain a plurality of segment mixed features corresponding to each of the plurality of segments;

[0040] For the multiple segmentation mixed features corresponding to the multiple segments, the multiple segmentation mixed features corresponding to the same image feature are fused to obtain multiple fused features corresponding to the one image feature set;

[0041] The multiple spatial mixed features are obtained according to the multiple fusion features respectively corresponding to the at least one image feature set.

[0042] Optionally, when dividing the multiple image features into at least one image feature set, the feature mixing module is further used to:

[0043] Dividing the plurality of image features into a plurality of row image feature sets by row and into a plurality of column image feature sets by column to obtain at least one image feature set; wherein the plurality of image features are arranged into a plurality of rows and columns, and the number of rows and the number of columns are the same;

[0044] When the plurality of spatial mixed features are obtained according to the plurality of fusion features respectively corresponding to the at least one image feature set, the feature mixing module is further used for:

[0045] Obtaining a row fusion feature set according to the plurality of fusion features corresponding to each of the plurality of row image feature sets, and obtaining a column fusion feature set according to the plurality of fusion features corresponding to each of the plurality of column image feature sets;

[0046] The plurality of spatial mixed features are obtained based on the row fusion feature set and the column fusion feature set.

[0047] Optionally, when obtaining a plurality of new image features based on the plurality of intermediate mixed features, the feature mixing module is further used to:

[0048] The multiple intermediate mixed features are subjected to a convolution operation to obtain the multiple new image features.

[0049] Optionally, the classification module is further used for:

[0050] By using the target image classification model, the plurality of target mixed features are averagely pooled to obtain pooled features;

[0051] The target image classification model is used to perform classification prediction on the image to be classified based on the pooling features to obtain a classification result of the image to be classified.

[0052] On the one hand, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores a program code, and when the program code is executed by the processor, the processor performs the steps of any one of the above-mentioned image classification methods.

[0053] On the one hand, an embodiment of the present application provides a computer storage medium, which stores computer instructions. When the computer instructions are executed on a computer, the computer executes the steps of any one of the above-mentioned image classification methods.

[0054] On the one hand, an embodiment of the present application provides a computer program product, which includes computer instructions, and the computer instructions are stored in a computer-readable storage medium; when a processor of an electronic device reads the computer instructions from the computer-readable storage medium, the processor executes the computer instructions, so that the electronic device performs the steps of any one of the above-mentioned image classification methods.

[0055] Since the embodiment of the present application adopts the above technical solution, it has at least the following technical effects:

[0056] When the embodiment of the present application classifies the image to be classified through the target image classification model, after extracting the image features of multiple image blocks of the image to be classified, multiple rounds of mixing processing are performed on the multiple image features in an iterative manner to obtain multiple corresponding target mixed features, and finally the classification prediction of the image to be classified is performed based on the multiple target mixed features to obtain the classification result of the image to be classified. In each round of the above mixing processing, mixing parameters can be dynamically generated based on the input multiple image features, and the multiple image features can be mixed using the dynamically generated mixing parameters, thereby improving the mixing performance of the target image classification model to better adapt to different images to be classified, and effectively improve the classification accuracy of the image classification model.

[0057] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be 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 labor.

[0059] Figure 1 A schematic diagram of an application scenario of an image classification method provided in an embodiment of the present application;

[0060] Figure 2 A flowchart of an image classification method provided in an embodiment of the present application;

[0061] Figure 3 A schematic diagram of image division provided in an embodiment of the present application;

[0062] Figure 4 A schematic diagram of feature extraction of image blocks provided in an embodiment of the present application;

[0063] Figure 5 A flowchart of another image classification method provided in an embodiment of the present application;

[0064] Figure 6 A schematic diagram of a block diagram of an MLP-based image classification model provided in an embodiment of the present application;

[0065] Figure 7 A schematic diagram of the structure of a target image classification model provided in an embodiment of the present application;

[0066] Figure 8 A flowchart of another image classification method provided in an embodiment of the present application;

[0067] Fig. 9 A schematic diagram of dividing an image feature set provided in an embodiment of the present application;

[0068] Fig.10 A schematic diagram of segmented dynamic mixing provided in an embodiment of the present application;

[0069] Fig.11 A schematic diagram of the structure of another target image classification model provided in an embodiment of the present application;

[0070] Fig.12 A schematic diagram of a specific scenario of an image classification method provided in an embodiment of the present application;

[0071] Fig.13 A structural block diagram of an image classification device provided in an embodiment of the present application;

[0072] Fig.14 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0073] Fig.15 It is a schematic diagram of the structure of another electronic device in an embodiment of the present application. DETAILED DESCRIPTION

[0074] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0075] In order to help those skilled in the art better understand the technical solution of the present application, some concepts involved in the present application are introduced below.

[0076] Image classification: Image classification is a common task in computer vision, which distinguishes images of different categories based on their high-level semantics. Image classification is not only the most important basic problem in computer vision, but also the basis of many computer vision tasks. It is also widely used in other tasks such as object detection and semantic segmentation. Specifically, in image classification tasks, the deep learning network accepts RGB images as input, obtains the features of the image through the deep learning network, and then obtains the classification scores of the image in each category based on the features of the image. The class with the highest score is the classification of the image.

[0077] Multilayer Perceptron MLP: It is a basic network in deep learning. A typical MLP consists of three layers: input layer, hidden layer and output layer. The different layers of the MLP neural network are fully connected, that is, the neurons in the next layer are connected to all the neurons in the previous layer. The simplest MLP network is a fully connected layer, which includes weights and biases. Assume that the input of a fully connected layer is X1∈R m×1 , the output is Y1∈R n×1 , then this fully connected layer can be expressed as:

[0078] Y1=W1X1+b

[0079] Where W1∈R n×m is the weight, b∈Rn×1 For bias.

[0080] Visual Tokens: refers to dividing an image into several image blocks of specified sizes. After each image block passes through a fully connected layer, a representation vector of the image block is obtained. This representation vector is called a visual token.

[0081] Mixing Matrix: The image classification model based on the multi-layer perceptron usually exchanges information in space by mixing all or part of the visual tags of the image through the mixing matrix. The process of mixing the visual tags of the image can be achieved by matrix multiplication of the visual tags and the mixing matrix. Assuming that N visual tags with a dimension of m need to be mixed, the process can be expressed as:

[0082] Y2=W2X2

[0083] Where X2∈R N×m is a set of N visual labels, Y2∈R N×m is the mixed result, W2∈R N×N is the mixing matrix.

[0084] The word “exemplary” is used hereinafter to mean “serving as an example, example, or illustration.” Any embodiment described as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.

[0085] The terms "first" and "second" in this document are used for descriptive purposes only and should not be understood as explicitly or implicitly indicating relative importance or implicitly indicating the number of technical features indicated. Therefore, features defined as "first" and "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of this application, unless otherwise specified, "plurality" means two or more.

[0086] The following is a brief introduction to the design concept of the embodiment of the present application:

[0087] In the related art, when classifying an image, an MLP-based image classification model can divide the image into multiple blocks of specified sizes and extract the features of each block; then use the trained mixing parameters to mix the multiple features to exchange information in space; and then output the classification result based on the mixed features. However, since different images have different features, using trainable static mixing parameters to mix multiple features of an image cannot adapt to images with large differences, thereby limiting the performance of the image classification model and making the classification accuracy of the image classification model low. Therefore, it is possible to consider dynamically generating mixing parameters based on multiple features of the image to adapt to different images.

[0088] In view of this, the embodiments of the present application provide an image classification method, device, electronic device and storage medium. When classifying an image to be classified through a target image classification model, a mixing parameter can be dynamically generated based on multiple input image features, and the multiple image features can be mixed using the dynamically generated mixing parameters, thereby improving the mixing performance of the target image classification model to better adapt to different images to be classified and effectively improve the classification accuracy of the image classification model.

[0089] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.

[0090] The embodiments of the present application relate to the field of artificial intelligence technology and are designed based on computer vision (CV) technology and machine learning (ML) technology in artificial intelligence.

[0091] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence software technology mainly includes several major directions such as computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0092] Computer Vision Technology (Computer Vision, CV) Computer vision is a science that studies how to make machines "see". To put it more concretely, it refers to machine vision such as using cameras and computers to replace human eyes to identify, track and measure targets, and further do graphic processing to make computer processing more suitable for human eye observation or transmission to instrument detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multidimensional data. Computer vision technology generally includes image processing, image recognition, image semantic understanding, image retrieval, OCR (Optical Character Recognition, optical character recognition), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, synchronous positioning and map construction, and also includes common biometric recognition technologies such as face recognition and fingerprint recognition. Image classification in the embodiment of the present application is a common task in computer vision, which is not only the most important basic problem in computer vision, but also the basis of many computer vision tasks.

[0093] Machine Learning (ML) is a multi-disciplinary interdisciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithmic complexity theory and other disciplines. It specializes in how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning generally include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning by teaching. In the embodiments of the present application, an image classification model based on machine learning or deep learning can be used to classify images.

[0094] The embodiments of the present application also relate to the field of cloud technology. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and network in a wide area network or a local area network to realize the calculation, storage, processing, and sharing of data. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model application, which can form a resource pool, which is used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites, and more portal websites. With the high development and application of the Internet industry, each item may have its own identification mark in the future, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately, and all kinds of industry data require strong system backing support, which can only be achieved through cloud computing. In the embodiments of the present application, image classification based on the image classification model can be achieved through cloud computing.

[0095] In order to better understand the technical solutions provided in the embodiments of the present application, the following briefly introduces the application scenarios to which the technical solutions provided in the embodiments of the present application are applicable. It should be noted that the application scenarios introduced below are only used to illustrate the embodiments of the present application and are not limited thereto. In specific implementation, the technical solutions provided in the embodiments of the present application can be flexibly applied according to actual needs.

[0096] The solution provided in the embodiments of the present application can be applied to cloud technology, artificial intelligence, smart transportation, assisted driving and other scenarios, and is applicable to any specific scenario involving image classification, such as image retrieval scenarios, environmental detection scenarios in assisted driving, face recognition scenarios, medical image recognition scenarios, security video detection scenarios, etc. Figure 1 As shown, a schematic diagram of an application scenario provided by an embodiment of the present application is provided, and the application scenario diagram includes a terminal device 100 and a server 200. The terminal device 100 and the server 200 can be directly or indirectly connected via a communication network. The communication network can be a wired network or a wireless network, which is not limited in the embodiment of the present application.

[0097] The terminal device 100 includes but is not limited to a mobile phone, a computer, an intelligent voice interaction device, an intelligent home appliance, a vehicle terminal, an aircraft, etc. The terminal device 100 may be installed with an application that can perform image classification services, such as a browser or a client, etc. The application involved in the embodiment of the present application may be a software client, or a client such as a web page or a small program, without limiting the specific type of the client.

[0098] The server 200 may be a background server corresponding to an application installed on the terminal device 100, or it may be another server; for example, the server may be an independent physical server, or it may be a server cluster or distributed system composed of multiple physical servers, or it may be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), as well as big data and artificial intelligence platforms.

[0099] It should be noted that in the embodiment of the present application, the number of terminal devices 100 can be one or more, and similarly, the number of servers 200 can be one or more, that is, there is no limitation on the number of terminal devices 100 or servers 200.

[0100] The image classification method of the embodiment of the present application can be executed by a terminal device or a server alone, or can be executed by a terminal device and a server together. For example, the image classification model is trained by the server to obtain a target image classification model, and the target image classification model is used in the terminal device to perform image classification.

[0101] In one possible implementation, the image classification method of the embodiment of the present application can be applied to an image retrieval scenario, so the application installed on the terminal device 100 can be an image retrieval application. For each image to be retrieved in the image retrieval application input by the user, the server can use the image classification method of the embodiment of the present application to output the category of the object contained in the image to be retrieved, thereby retrieving similar images from the image library based on the category of the object.

[0102] In another possible implementation, the image classification method of the embodiment of the present application can be applied to the environmental detection scenario in assisted driving. Then the application installed on the terminal device 100 can be an environmental detection application, and the image classification method of the embodiment of the present application can be used to classify the detected environmental images and output the categories of objects contained in the environmental images, so as to make assisted driving decisions based on the categories of the objects.

[0103] The image classification method of the embodiment of the present application can also be applied to various other scenarios, which are not listed here one by one. The image classification method provided by the exemplary embodiment of the present application is described below in combination with the application scenarios described above, with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of the present application, and the implementation of the present application is not limited in this respect.

[0104] Figure 2 An image classification method provided by an embodiment of the present application is shown. The method can be Figure 1 The image classification method of the embodiment of the present application may be executed by the server 200, or by the terminal device 100, or by the server 200 and the terminal device 100. For example, the specific implementation process of the image classification method of the embodiment of the present application is described below with the server as the execution subject.

[0105] See also Figure 2 As shown, an image classification method provided in an embodiment of the present application includes the following steps:

[0106] S201, dividing the image to be classified into multiple image blocks through the trained target image classification model, and extracting image features of each of the multiple image blocks.

[0107] The target image classification model can be based on a deep learning network, for example, the deep learning network is a multi-layer perceptron MLP or other neural network, which is not limited here. The target image classification model can be obtained by training a sample image set, and each sample image in the sample image set is marked with an object category. The loss function in the training process is a classification loss, for example, a cross entropy loss function can be used.

[0108] In the embodiment of the present application, the target image classification model can divide the image to be classified into multiple image blocks, which can be divided according to the resolution. For example, the resolution of the image to be classified is 224*224. Figure 3 As shown, it can be divided into non-overlapping image blocks with a resolution of 7*7, resulting in 32*32 image blocks. Furthermore, the target image classification model can extract image features of each image block.

[0109] For example Figure 4 As shown in the figure, for an image block with a resolution of 7*7, it can be represented as a 7*7 matrix. The 7*7 matrix is ​​converted into a 49-dimensional vector. Specifically, multiple rows of the 7*7 matrix can be concatenated to obtain a 49-dimensional vector. The 49-dimensional vector is then input into a fully connected layer to output a 192-dimensional embedding vector, which is then used as the image feature of the image block. In this way, the image to be classified with a resolution of 224*224 can be encoded into 32*32 image features.

[0110] S202, through the target image classification model, based on multiple image features, adopting an iterative method to perform mixing processing to obtain corresponding multiple target mixed features; wherein one round of mixing processing includes: generating mixing parameters based on multiple image features input in this round, and outputting multiple intermediate mixed features based on the mixing parameters and multiple image features, and obtaining new multiple image features based on the multiple intermediate mixed features.

[0111] In this step, the target image classification model can iteratively perform multiple rounds of mixing processing on the input multiple image features. Specifically, in the first round of mixing processing, mixing parameters are generated based on the input multiple image features, and the multiple image features are mixed based on the mixing parameters to output multiple intermediate mixed features, and then new multiple image features are obtained based on the multiple intermediate mixed features, and the new multiple image features are used as input for the second round of mixing processing, and so on, to obtain multiple target mixed features output by the last round of mixing processing.

[0112] In a round of mixing processing, the input multiple image features can be processed by corresponding preset processing to obtain mixing parameters. Mixing multiple image features based on the mixing parameters can include spatial mixing and channel mixing; wherein, spatial mixing refers to mixing the spatial information of multiple image features; channel mixing can be: inputting multiple image features into a fully connected layer with the same input and output dimensions. Since each image feature can include multiple dimensions, each dimension corresponds to a channel, and the fully connected layer can mix the information of different channels.

[0113] For example, when multiple image features are spatially mixed based on a mixing parameter, the target image classification model can multiply the mixing parameter with the multiple image features to obtain multiple spatial mixed features. For example, the mixing parameter is represented as P, and the processed multiple image features are represented as X. Then, after spatial mixing based on P and X, Y is obtained, and Y=PX.

[0114] Furthermore, multiple spatial mixed features can be input into the fully connected layer for channel mixing to obtain multiple intermediate mixed features. Here, multiple spatial mixed features can also be added to the initial multiple image features, that is, each spatial mixed feature is added to the corresponding image feature and then input into the fully connected layer.

[0115] In an embodiment of the present application, in each round of mixing processing, mixing parameters can be dynamically generated based on multiple input image features, and the multiple image features can be mixed based on the dynamically generated mixing parameters, so that the mixing parameters can be more adapted to the multiple image features to better perform spatial mixing of the multiple image features.

[0116] It should be noted that in each round of mixing processing, not only can a mixing operation be performed on the multiple input image features (including generating mixing parameters based on the multiple input image features, and mixing the multiple image features based on the mixing parameters), but multiple mixing operations can also be iteratively performed. Each mixing operation can generate new mixing parameters based on multiple candidate mixed features obtained in the previous mixing operation, and mix the multiple candidate mixed features based on the new mixing parameters, until multiple intermediate mixed features output by the last mixing operation are obtained.

[0117] Optionally, when obtaining multiple new image features based on multiple intermediate mixed features, the target image classification model may perform a convolution operation on the multiple intermediate mixed features to obtain multiple new image features.

[0118] S203, using a target image classification model, performing classification prediction on the image to be classified based on multiple target mixed features to obtain a classification result of the image to be classified.

[0119] In this step, the target image classification model can obtain a feature vector based on multiple target mixed features, and perform classification prediction on the image to be classified based on the feature vector, obtain the classification scores of the image to be classified in each preset category, and take the category with the highest score as the classification result; wherein the preset categories are categories that can be predicted by the target image classification model, for example, the categories include various object categories such as cats, dogs, people, tables, chairs, etc.

[0120] In a possible implementation, Figure 5 As shown, S203 may include the following steps:

[0121] S2031, through the target image classification model, multiple target mixed features are averaged and pooled to obtain pooled features.

[0122] Here, the target image classification model can perform average pooling on multiple target mixed features through the average pooling module. For example, multiple target mixed features are 384-dimensional feature vectors. After summing and averaging the multiple target mixed features, a pooled feature is obtained, which is also a 384-dimensional feature vector.

[0123] S2032, using the target image classification model, performing classification prediction on the image to be classified based on the pooling features to obtain a classification result of the image to be classified.

[0124] In this step, the target image classification model can input the pooled features into a fully connected layer, output a feature vector with the dimension of the number of categories, and then pass the feature vector through the softmax layer to output the classification scores of each category, and take the category with the highest score as the classification result. Among them, the softmax layer can map each dimension of the feature vector to a probability value between [0,1], and the sum of the probability values ​​of all dimensions is equal to 1.

[0125] Exemplarily, the pooled feature is a 384-dimensional feature vector with 1000 categories. The feature vector is input into a fully connected layer, and a feature vector with a dimension of 1000 is output. After passing through a softmax layer, the classification scores of the 1000 categories are output, and the category with the largest classification score is taken as the classification result.

[0126] In an embodiment of the present application, since each round of mixing processing can dynamically generate mixing parameters based on multiple input image features, and use the dynamically generated mixing parameters to mix multiple image features, the mixing performance of the target image classification model is improved to better adapt to different images to be classified, and effectively improve the classification accuracy of the image classification model.

[0127] The following takes the target image classification model as an MLP-based image classification model as an example for explanation. Figure 3 The framework of the MLP-based image classification model is shown.

[0128] like Figure 6 As shown, the MLP-based image classification model framework may include a visual marker encoding module, multiple mixing layers and an average pooling module, wherein each mixing layer may include a first layer normalization module, a spatial mixing module, a second layer normalization module and a channel mixing module.

[0129] The visual marker encoding module can divide the image into multiple image blocks, and encode each image block into a visual marker to obtain multiple visual markers, each of which can be used as the image feature of the corresponding image block. These visual markers are input into multiple mixing layers to iteratively perform multiple spatial mixing and channel mixing. Finally, these visual markers are output as a feature vector through the average pooling module, and the image is classified and predicted through the feature vector to obtain the classification result.

[0130] Assume that multiple visual markers are represented as Z, and Z is input into the first mixing layer for one spatial mixing and one channel mixing. Specifically, firstly, Z is layer-normalized by the first layer normalization module; wherein, layer normalization is a common operation in deep learning, which is to calculate the mean and variance of multiple input visual markers and normalize multiple visual markers by the mean and variance; then, the layer-normalized Z is spatially mixed by the spatial mixing module to obtain Z1, and Z1 is added to Z to obtain Z2; then, Z2 is layer-normalized by the second layer normalization module; Z2 is channel-mixed by the channel mixing module to obtain Z3, and Z3 is added to Z2 to obtain Z4, which is the output of the first mixing layer; next, the output of the first mixing layer is used as the input of the second mixing layer, and so on.

[0131] In the present application embodiment, Figure 7As shown, the target image classification model can include a visual tag encoding module, at least one stage network and an average pooling module based on the above-mentioned MLP-based image classification model framework; each stage network can include at least one continuous mixing layer and a convolutional layer, and each mixing layer can include a first-layer normalization module, a spatial mixing module, a second-layer normalization module and a channel mixing module. The number of stage networks can be set as needed, and the number of mixing layers of each stage network can also be set as needed, which is not limited here.

[0132] The visual marker encoding module is used to extract visual markers of multiple image blocks of the image to be classified, and use the visual markers as image features; each stage network is used to perform a round of mixing processing on the input multiple image features, and the output of each stage network can be used as the input of the next stage network until the output of the last stage network is obtained.

[0133] In some embodiments, based on the structure of the target image classification model, such as Figure 8 As shown, the above S202 may include the following steps:

[0134] S2021, execute the following S2022-S2023 in an iterative manner until multiple target mixed features output by the network in the last stage are obtained.

[0135] S2022, generating a mixing parameter based on the input multiple image features through at least one mixing layer of the first stage network, and outputting multiple intermediate mixing features based on the mixing parameters and the multiple image features.

[0136] S2023, input the multiple intermediate mixed features into the convolution layer of the first stage network, output new multiple image features, and use the new multiple image features as input of the next stage network.

[0137] In some optional embodiments, when a stage network includes a mixing layer, the above S2022 generates a mixing parameter based on multiple input image features through a mixing layer of the stage network, and outputs multiple intermediate mixing features based on the mixing parameter and the multiple image features, which may specifically include the following steps:

[0138] A1. The input multiple image features are sequentially passed through the first layer normalization module and the spatial mixing module in the mixing layer to spatially mix the multiple image features to obtain multiple spatial mixing features.

[0139] In this step, the first layer normalization module can first perform layer normalization processing on multiple image features, and then the spatial mixing module generates mixing parameters based on the processed multiple image features, and uses the mixing parameters to spatially mix the processed multiple image features to obtain multiple spatial mixing features.

[0140] A2. Input the multiple spatial mixed features into the second-layer normalization module and the channel mixing module in sequence, perform channel mixing on the multiple spatial mixed features, and obtain multiple intermediate mixed features.

[0141] Among them, the second layer normalization module can first perform layer normalization processing on multiple spatial mixed features, and then the channel mixing module can perform channel mixing on the processed multiple spatial mixed features to obtain multiple intermediate mixed features. In addition, multiple spatial mixed features can be added to multiple input image features, that is, each spatial mixed feature is added to the corresponding image feature to obtain multiple added spatial mixed features; the multiple added spatial mixed features are then input into the second layer normalization module and the channel mixing module in sequence, and then the obtained multiple channel mixed features are added to the input multiple spatial mixed features, that is, each channel mixed feature is added to the corresponding spatial mixed feature to obtain multiple intermediate mixed features.

[0142] In some other optional embodiments, when a stage network includes multiple mixing layers, the above S2022 generates mixing parameters based on multiple input image features through the multiple mixing layers of the stage network, and outputs multiple intermediate mixing features based on the mixing parameters and the multiple image features, which may include the following steps:

[0143] B1. Generate a mixing parameter based on multiple input image features through the first mixing layer, and obtain multiple candidate mixing features based on the mixing parameter and the multiple image features.

[0144] In this step, the plurality of image features may be subjected to corresponding preset processing to obtain mixing parameters. For example, a mixing matrix may be generated based on the plurality of image features, or a mixing matrix may be generated based on partial image features of the plurality of image features.

[0145] B2. Through the remaining multiple mixing layers, based on the multiple candidate mixing features, the following operations are performed in an iterative manner: through a mixing layer, new mixing parameters are generated based on the input multiple candidate mixing features, and according to the new mixing parameters and the multiple candidate mixing features, new multiple candidate mixing features are obtained and input into the next mixing layer.

[0146] The process of generating new mixing parameters based on the input multiple candidate mixing features, and obtaining new multiple candidate mixing features according to the new mixing parameters and the multiple candidate mixing features is similar to the above step B1.

[0147] B3. Use the multiple candidate mixed features output by the last mixed layer as multiple intermediate mixed features.

[0148] In some embodiments, considering that the data volume of the above-mentioned multiple image features may be relatively large, in order to improve the mixing speed and mixing performance of the multiple image features, the multiple image features can be divided into multiple image feature sets, and then the multiple image feature sets are mixed separately.

[0149] In the above step S2022, when generating the mixing parameters based on multiple image features, the following steps may be specifically included:

[0150] C1. Divide the plurality of image features into at least one image feature set, where different image feature sets have the same number of image features.

[0151] Among them, multiple image features can be arranged in multiple rows and columns, and the number of rows and columns is the same. This is because when the image to be classified is divided into multiple image blocks according to the resolution, the multiple image blocks obtained are arranged in multiple rows and columns. After extracting the image features of each image block, multiple rows and columns of image features can be obtained. Therefore, when grouping multiple rows and columns of image features, they can be divided according to rows and columns; specifically, each image feature of each row is divided into a row image feature set, and each image feature of each column is divided into a column image feature set, thereby obtaining multiple image feature sets.

[0152] For example, Fig. 9 As shown, assuming that multiple image features are arranged into 32 rows and 32 columns, the 32 image features in each row are divided into a row image feature set, and the 32 image features in each column are divided into a column image feature set, thereby obtaining a 32*32 image feature set.

[0153] C2. For at least one image feature set, perform the following operations respectively: Generate a mixing matrix based on one image feature set.

[0154] Optionally, each image feature corresponds to a multidimensional vector containing multiple feature dimensions, and the generation of a mixing matrix based on an image feature set in the above step C2 may include the following steps:

[0155] C21. Perform dimensionality reduction processing on each image feature in an image feature set to obtain a corresponding plurality of first dimensionality reduction vectors.

[0156] In this step, multiple feature dimensions of each image feature can be reduced to fewer feature dimensions to obtain multiple first reduced dimension vectors. For example, assuming that an image feature set includes N image features with feature dimensions m, X∈RN×m It means that, firstly, the m-dimensionality of each image feature can be reduced to d-dimensionality through formula (1), and we can obtain

[0157]

[0158] In order to facilitate efficient calculation, d can be a smaller number, such as 1 or 2.

[0159] C22. Concatenate the multiple first dimension reduction vectors into a first fused feature vector, and convert the first fused feature vector into a mixing matrix.

[0160] In this step, multiple first dimension reduction vectors can be concatenated into a row to obtain a first fused feature vector; then the first fused feature vector is passed through a fully connected layer to generate a vector of a set dimension and reshaped into a sub-mixing matrix.

[0161] For example, in obtaining the above After that, you can Flattened into a one-dimensional vector, Multiple rows of are concatenated into one row, and then a vector of set dimension is generated through a fully connected layer, and then reshaped into a mixing matrix P through formula (2):

[0162]

[0163] in, Indicates that Flattened into a one-dimensional vector, W is the weight of the fully connected layer.

[0164] Through formula (3), the above mixing matrix P is used to mix multiple image features to obtain the output Y:

[0165] Y=PX,Y∈R N×m (3)

[0166] C3. Using the mixing matrix corresponding to at least one image feature set as a mixing parameter.

[0167] In the embodiment itself, generating a mixing matrix based on each image feature set can not only improve the mixing speed, but also make the mixing matrix adapt to the image features at different positions of the image to be classified, improve the mixing performance of the image features, and thus improve the classification accuracy of the image classification model.

[0168] Furthermore, after obtaining the mixing matrix corresponding to at least one image feature set, the target image classification model can perform spatial mixing on each image feature set through a spatial mixing module, and perform channel mixing on the obtained multiple spatial mixing modules through a channel mixing module.

[0169] Optionally, in the above step B1, obtaining multiple candidate mixed features according to the mixed parameters and multiple image features may include the following steps:

[0170] B11. Obtain corresponding multiple spatial mixing features according to at least one image feature set and respective mixing matrices.

[0171] Here, each image feature set may be multiplied by the corresponding mixing matrix to obtain a plurality of spatial mixing features, and then a plurality of corresponding spatial mixing features may be obtained based on the plurality of spatial mixing features corresponding to each of the plurality of image feature sets.

[0172] B12. Based on multiple spatial mixed features, multiple candidate mixed features are output through a fully connected layer.

[0173] Here, multiple spatial mixed features can be mixed through channels through the fully connected layer to obtain multiple candidate mixed features. In addition, multiple spatial mixed features can be added to the corresponding initial input image features respectively, and then mixed through channels through the fully connected layer.

[0174] In some embodiments, each image feature corresponds to a multidimensional vector containing multiple feature dimensions. In order to enhance feature diversity, each image feature can be divided into multiple segments, and the same segments of different image features are used together to generate a sub-mixing matrix for spatial mixing. Different segments of the same image feature can share the parameters of the sub-mixing matrix generation process, but due to the different input segment features, different sub-mixing matrices can be generated.

[0175] Therefore, after segmenting each image feature in an image feature set, generating a mixing matrix based on an image feature set in the above step C2 may further include the following steps:

[0176] D1. For each image feature in an image feature set, the following operations are performed respectively: multiple feature dimensions of an image feature are divided into multiple segments to obtain segment features corresponding to each of the multiple segments; wherein each segment corresponds to at least one feature dimension, and different segments have the same number of feature dimensions.

[0177] For example, taking a feature vector with 192 dimensions as an example, the 192-dimensional feature vector can be divided into 8 segments, that is, the feature vector is divided into 8 segments on the dimension of 192, and the dimension of each segment is 192 / 8=24 dimensions, and the segment features corresponding to each segment (that is, a 24-dimensional feature vector) are obtained.

[0178] D2. For each of the multiple segment features corresponding to each image feature, a corresponding sub-mixing matrix is ​​generated based on each of the segment features corresponding to the same segment, so as to obtain a sub-mixing matrix corresponding to each of the multiple segments.

[0179] In this step, you can perform the following operations for multiple segments:

[0180] D21. Perform dimensionality reduction processing on each segment feature corresponding to a segment to obtain a corresponding plurality of second dimensionality reduction vectors.

[0181] This step is similar to the above step C21. Each segment feature includes multiple feature dimensions. The multiple feature dimensions of each segment feature are reduced to fewer feature dimensions to obtain multiple second reduced-dimensionality vectors.

[0182] D22. Concatenate the multiple second dimension reduction vectors into a second fused feature vector, and convert the second fused feature vector into a sub-mixing matrix.

[0183] This step is similar to the above step C22, and multiple second dimensionality reduction vectors can be concatenated into a row to obtain a second fused feature vector; then the second fused feature vector is passed through a fully connected layer to generate a vector of a set dimension and reshaped into a sub-mixing matrix. For details, please refer to the above formula (2).

[0184] D3. Use the obtained multiple sub-mixing matrices as mixing matrices.

[0185] In the above steps, the same segments of different image features are used together to generate sub-mixing matrices and mix the image features. Different segments of the same image feature share the parameters of the mixing matrix generation process, but different sub-mixing matrices can be generated due to different input segment features. In this way, each segment of each image feature can be mixed using different sub-mixing matrices to enhance feature diversity.

[0186] For example, Fig.10 As shown, it is assumed that an image feature set includes 32 image features, each of which includes 192 feature dimensions. When generating a mixing matrix based on an image feature set, each of the image features is divided into 8 segments according to the 192 feature dimensions, and each segment corresponds to 24 feature dimensions. After obtaining 8 segment features of each of the 32 image features, the 32 segment features of the same segment of the 32 image features are used to generate a sub-mixing matrix to obtain sub-mixing matrices corresponding to each of the 8 segments.

[0187] Based on the above embodiments of the present application, it can be known that the mixing matrix includes multiple sub-mixing matrices, and each image feature in each image feature set includes: segment features corresponding to multiple segments, each segment corresponds to a sub-mixing matrix.

[0188] In some optional embodiments, the target image classification model can spatially mix each image feature set by a spatial mixing module in a multi-segment dynamic mixing manner. Therefore, the above-mentioned obtaining of corresponding multiple spatial mixing features based on at least one image feature set and respective mixing matrices can include the following steps:

[0189] E1. For at least one image feature set, perform the following E11-E12 respectively:

[0190] E11. Based on a plurality of segment features corresponding to each image feature in an image feature set, each segment feature corresponding to the same segment is multiplied with a corresponding sub-mixing matrix to obtain a plurality of segment mixed features corresponding to each of the plurality of segments.

[0191] It is assumed that each image feature is a 192-dimensional feature vector, which is divided into 8 segments, each of which corresponds to a 24-dimensional feature vector. The same segment of different image features, such as the second segment, actually corresponds to the 24th to 47th dimensions of the 192-dimensional feature vector. When the same segments of different image features are mixed, for example, the first segments of m image features are mixed together, and the sub-mixing matrix is ​​jointly generated by the m first segments. The parameters in this generation process can be shared with the parameters of the sub-mixing matrix jointly generated by the m second segments.

[0192] E12. For the multiple segmented mixed features corresponding to the multiple segments, the multiple segmented mixed features corresponding to the same image feature are fused to obtain multiple fused features corresponding to an image feature set.

[0193] In this step, the set of the i-th segment of all image features can be expressed as X i ∈R N×t , where t is the dimension of each segment, that is, m = t*S. Finally, we can use a full connection

[0194] The segmented mixed features of multiple segments are fused by layers, as shown in formula (4):

[0195] Y=[P0X0,P1X1,…,P S-1 X S-1 ]W o ,Y∈R N×m (4)

[0196] Among them, P0, P1...P S-1 Represents the sub-mixing matrix of each segment, W o represents the weight of the fully connected layer.

[0197] Thus, we get the output after mixing an image feature set. Assume that an input image feature set is N image features with dimension m, and use X∈R N×m Represented as, then the output is also a set of N image features with dimension m, using Y∈R N×m express.

[0198] E2. Obtain multiple spatial mixed features according to multiple fusion features corresponding to at least one image feature set.

[0199] It can be seen from the above embodiments of the present application that when dividing multiple image features into at least one image feature set, the multiple image features can be divided into multiple row image feature sets by row, and divided into multiple column image feature sets by column.

[0200] Then, in step E, when obtaining multiple spatial mixed features according to multiple fusion features corresponding to at least one image feature set, the following steps may be included:

[0201] E21. Obtain a row fusion feature set based on a plurality of fusion features corresponding to each of a plurality of row image feature sets, and obtain a column fusion feature set based on a plurality of fusion features corresponding to each of a plurality of column image feature sets.

[0202] E22. Based on the row fusion feature set and the column fusion feature set, multiple spatial mixed features are obtained.

[0203] For example, for an image to be classified, after being divided into multiple image blocks according to resolution, r*r image features can be extracted. Assuming that each image feature contains m dimensions, the size of r*r image features is R r×r×m ,In order to reduce the amount of calculation, multi-segment dynamic mixing can be ,performed in rows and columns.

[0204] First, each row of r*r image features is taken as a set of r image features with dimension m, and each row is mixed by multi-segment dynamic mixing to obtain the output X W ∈R r×r×m , that is, the row fusion feature set, and then each column of the feature is used as a set of r image features with dimension m, and each column is mixed using a multi-segment dynamic mixer to obtain the output X H ∈R r×r×m , that is, the column fusion feature set, and the r*r image features are mixed on the channel through a fully connected layer to obtain a size of R r×r×m The output is marked as X C , for X W , X H and X C The final output X is obtained by averaging SC :X SC =(XW +X H +X C ) / 3.

[0205] Combine the following Fig.11 The image classification method of the embodiment of the present application is exemplarily introduced.

[0206] like Fig.11 As shown, the target image classification model includes a visual tag encoding module, a four-stage network and an average pooling module. The first-stage network consists of 4 consecutive mixing layers and one convolutional layer, the first-stage network consists of 3 consecutive mixing layers and one convolutional layer, the first-stage network consists of 8 consecutive mixing layers and one convolutional layer, and the first-stage network consists of 3 consecutive mixing layers and one convolutional layer.

[0207] Among them, each mixing layer can adopt a dynamic mixing method to generate a mixing matrix based on a set of input image features, and use the mixing matrix to mix multiple image features; it can also adopt a multi-segment dynamic mixing method to generate a sub-mixing matrix based on the same segment of a set of input image features, and use the sub-mixing matrix to mix multiple segment features.

[0208] It should be noted that the number of the above-mentioned stage networks and the number of hybrid layers of each stage network are only exemplary and can be set according to specific needs and are not limited here.

[0209] Exemplarily, for an image to be classified with a resolution of 224*224, the process of image classification based on the above target image classification model includes:

[0210] 1. For the image to be classified with a resolution of 224*224, the visual tag encoding module can divide it into non-overlapping image blocks of size 7*7, flatten each 7*7 image block into a 49-dimensional vector and send it to a fully connected layer to obtain a 192-dimensional embedding vector of this image block. Thus, the image is encoded into 32*32 192-dimensional embedding vectors, each of which is used as an image feature.

[0211] 2. Input the 32*32 192-dimensional image features generated in step 1 into a continuous 4-stage network and output 16*16 384-dimensional image features.

[0212] Specifically, 32*32 192-dimensional image features are input into the 4 mixing layers of the first-stage network, and 32*32 192-dimensional image features are output. Then, a convolution layer with a convolution kernel size of 2*2, a step size of 2*2, an input dimension of 192, and an output dimension of 384 is passed to obtain 16*16 384-dimensional image features.

[0213] The 16*16 384-dimensional image features output by the first-stage network are input into the three mixed layers of the second-stage network, and 16*16 384-dimensional image features are output. Then, a convolution layer with a convolution kernel size of 1*1, a step size of 1*1, an input dimension of 384, and an output dimension of 384 is used to obtain 16*16 384-dimensional image features.

[0214] The 16*16 384-dimensional image features output by the second-stage network are input into the 8 mixed layers of the third-stage network, and 16*16 384-dimensional image features are output. Then, a convolution layer with a convolution kernel size of 1*1, a step size of 1*1, an input dimension of 384, and an output dimension of 384 is used to obtain 16*16 384-dimensional image features.

[0215] The 16*16 384-dimensional image features output by the third-stage network are input into the three mixed layers of the fourth-stage network, and 16*16 384-dimensional image features are output. Then, the 16*16 384-dimensional image features are obtained by passing through a convolution layer with a convolution kernel size of 1*1, a step size of 1*1, an input dimension of 384, and an output dimension of 384.

[0216] 3. Perform average pooling on the 16*16 384-dimensional image features generated in step 2 to obtain a 384-dimensional vector. Input this vector into a fully connected layer with the output dimension being the number of classifications, and then pass it through the softmax layer to obtain the classification score.

[0217] It should be noted that the specific numerical values ​​involved in the above image classification process are only exemplary and are not intended to limit the embodiments of the present application.

[0218] The image classification method of the embodiment of the present application can be applied to various scenarios that require image classification, including but not limited to image retrieval scenarios, face recognition scenarios, medical image recognition scenarios, assisted driving scenarios, security scenarios, etc.

[0219] Take the image retrieval scenario as an example. Fig.12 As shown, when the user inputs an image to be retrieved containing a cat in the image retrieval application of the terminal device, the terminal device can send the image to be retrieved to the background server of the image retrieval application; the background server can adopt the image classification method of the embodiment of the present application, input the image to be retrieved into the target image classification model, and output the classification result as follows: the probability of a cat is 0.7, the probability of a dog is 0.2, and the probability of a cat is 0.1, then it is determined that the image to be retrieved contains a cat; then, the background server can retrieve multiple images containing cats from the image library, and send the retrieved multiple images to the terminal device, so that the terminal device displays the retrieved multiple images in the image retrieval application.

[0220] Based on the same inventive concept as the above-mentioned method embodiment of the present application, an image classification device is also provided in the embodiment of the present application. The principle of solving the problem by the device is similar to that of the method in the above-mentioned embodiment. Therefore, the implementation of the device can refer to the implementation of the above-mentioned method, and the repeated parts will not be repeated.

[0221] like Fig.13 As shown, the embodiment of the present application provides an image classification device, comprising:

[0222] The feature extraction module 131 is used to divide the image to be classified into multiple image blocks through the trained target image classification model, and extract the image features of each of the multiple image blocks;

[0223] The feature mixing module 132 is used to perform mixing processing in an iterative manner based on multiple image features through a target image classification model to obtain a corresponding multiple target mixed features; wherein one round of mixing processing includes: generating mixing parameters based on multiple image features input in this round, and outputting multiple intermediate mixed features based on the mixing parameters and multiple image features, and obtaining multiple new image features based on the multiple intermediate mixed features;

[0224] The classification module 133 is used to perform classification prediction on the image to be classified based on multiple target mixed features through a target image classification model to obtain a classification result of the image to be classified.

[0225] In an embodiment of the present application, in each round of the above-mentioned mixing processing, mixing parameters can be dynamically generated based on multiple input image features, and the multiple image features can be mixed using the dynamically generated mixing parameters, thereby improving the mixing performance of the target image classification model, so as to better adapt to different images to be classified, and effectively improve the classification accuracy of the image classification model.

[0226] Optionally, when generating mixing parameters based on multiple image features, the feature mixing module 132 is further used to:

[0227] Dividing the plurality of image features into at least one image feature set, wherein different image feature sets have the same number of image features;

[0228] For at least one image feature set, the following operations are respectively performed: generating a mixing matrix based on the image feature set;

[0229] The mixing matrix corresponding to each of the at least one image feature set is used as a mixing parameter.

[0230] Optionally, each image feature corresponds to a multidimensional vector including multiple feature dimensions. When a mixing matrix is ​​generated based on an image feature set, the feature mixing module 132 is further used to:

[0231] Performing dimensionality reduction processing on each image feature in an image feature set to obtain a corresponding plurality of first dimensionality reduction vectors;

[0232] The plurality of first dimension reduction vectors are concatenated into a first fused feature vector, and the first fused feature vector is converted into a mixing matrix.

[0233] Optionally, each image feature corresponds to a multidimensional vector including multiple feature dimensions. When a mixing matrix is ​​generated based on an image feature set, the feature mixing module 132 is further used to:

[0234] For each image feature in an image feature set, the following operations are performed respectively: multiple feature dimensions of an image feature are divided into multiple segments to obtain segment features corresponding to each of the multiple segments; wherein each segment corresponds to at least one feature dimension, and different segments have the same number of feature dimensions;

[0235] For each of the multiple segment features corresponding to each of the image features, a corresponding sub-mixing matrix is ​​generated based on each of the segment features corresponding to the same segment, so as to obtain a sub-mixing matrix corresponding to each of the multiple segments;

[0236] The obtained multiple sub-mixing matrices are used as mixing matrices.

[0237] Optionally, when generating corresponding sub-mixing matrices based on the segment features corresponding to the same segment and obtaining the sub-mixing matrices corresponding to the multiple segments, the feature mixing module 132 is further used to:

[0238] For multiple segments, perform the following operations:

[0239] Perform dimensionality reduction processing on each segment feature corresponding to a segment to obtain a corresponding plurality of second dimensionality reduction vectors;

[0240] The plurality of second dimension reduction vectors are concatenated into a second fused feature vector, and the second fused feature vector is converted into a sub-mixing matrix.

[0241] Optionally, when outputting a plurality of intermediate mixed features based on the mixing parameters and the plurality of image features, the feature mixing module 132 is further used to:

[0242] According to the mixing parameter and the multiple image features, multiple candidate mixing features are obtained;

[0243] Based on the multiple candidate mixed features, the following operations are performed in an iterative manner: generating new mixed parameters based on the multiple candidate mixed features input this time, and obtaining new multiple candidate mixed features according to the new mixed parameters and the multiple candidate mixed features;

[0244] The multiple candidate mixed features outputted last time are used as multiple intermediate mixed features.

[0245] Optionally, when a plurality of candidate mixed features are obtained according to the mixing parameter and the plurality of image features, the feature mixing module 132 is further used to:

[0246] Obtaining a corresponding plurality of spatial mixing features according to at least one image feature set and respective mixing matrices;

[0247] Based on multiple spatial mixture features, multiple candidate mixture features are output through a fully connected layer.

[0248] Optionally, the mixing matrix includes a plurality of sub-mixing matrices, and each image feature in each image feature set includes: segment features corresponding to each of a plurality of segments, and each segment corresponds to a sub-mixing matrix;

[0249] When obtaining corresponding multiple spatial mixed features according to at least one image feature set and respective mixing matrices, the feature mixing module 132 is further used to:

[0250] For at least one image feature set, perform the following operations:

[0251] Based on a plurality of segment features corresponding to each image feature in an image feature set, each segment feature corresponding to the same segment is multiplied with a corresponding sub-mixing matrix to obtain a plurality of segment mixed features corresponding to each of the plurality of segments;

[0252] For the multiple segmented mixed features corresponding to the multiple segments, the multiple segmented mixed features corresponding to the same image feature are fused to obtain multiple fused features corresponding to an image feature set;

[0253] A plurality of spatial mixed features are obtained according to a plurality of fused features respectively corresponding to at least one image feature set.

[0254] Optionally, when dividing the multiple image features into at least one image feature set, the feature mixing module 132 is further used to:

[0255] Dividing the multiple image features into multiple row image feature sets by row and multiple column image feature sets by column to obtain at least one image feature set; wherein the multiple image features are arranged into multiple rows and multiple columns, and the number of rows and the number of columns are the same;

[0256] When a plurality of spatial mixed features are obtained according to a plurality of fusion features corresponding to at least one image feature set, the feature mixing module 132 is further used to:

[0257] Obtain a row fusion feature set according to a plurality of fusion features corresponding to each of the plurality of row image feature sets, and obtain a column fusion feature set according to a plurality of fusion features corresponding to each of the plurality of column image feature sets;

[0258] Based on the row fusion feature set and the column fusion feature set, multiple spatial mixed features are obtained.

[0259] Optionally, when obtaining multiple new image features based on multiple intermediate mixed features, the feature mixing module 132 is further used to:

[0260] The multiple intermediate mixed features are convolved to obtain multiple new image features.

[0261] Optionally, the classification module 133 is further used for:

[0262] Through the target image classification model, multiple target mixed features are averaged and pooled to obtain pooled features;

[0263] Through the target image classification model, the classification prediction of the image to be classified is performed based on the pooling features to obtain the classification result of the image to be classified.

[0264] For the convenience of description, the above parts are divided into modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.

[0265] After introducing the image classification method and device according to the exemplary embodiment of the present application, next, an image classification device according to another exemplary embodiment of the present application is introduced.

[0266] Those skilled in the art will appreciate that various aspects of the present application may be implemented as a system, method or program product. Therefore, various aspects of the present application may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "system" herein.

[0267] In some possible implementations, the image classification device according to the present application may include at least a processor and a memory. The memory stores program code, and when the program code is executed by the processor, the processor executes the steps of the image classification method according to various exemplary implementations of the present application described in this specification. For example, the processor may execute the following steps: Figure 2 Follow the steps shown in .

[0268] After introducing the image classification method and apparatus according to the exemplary embodiment of the present application, next, an electronic device according to another exemplary embodiment of the present application is introduced.

[0269] Based on the same inventive concept as the above method embodiments of the present application, an electronic device is also provided in the embodiments of the present application. The principle of solving the problem by the electronic device is similar to the method of the above embodiment. Therefore, the implementation of the electronic device can refer to the implementation of the above method, and the repeated parts will not be repeated.

[0270] See also Fig.14 As shown, the electronic device 140 may include at least a processor 141 and a memory 142. The memory 142 stores program codes, and when the program codes are executed by the processor 141, the processor 141 executes the steps in any one of the above-mentioned image classification methods.

[0271] In some possible implementations, the electronic device according to the present application may include at least one processor and at least one memory. The memory stores program code, and when the program code is executed by the processor, the processor executes the steps of the image classification method according to various exemplary implementations of the present application described above in this specification. For example, the processor may execute Figure 2 Follow the steps shown in .

[0272] In an exemplary embodiment, the present application further provides a storage medium including a program code, such as a memory 142 including the program code, and the program code can be executed by a processor 141 of an electronic device 140 to complete the above-mentioned image classification method. Optionally, the storage medium can be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0273] Refer to the following Fig.15 An electronic device 150 according to an embodiment of the present application is described. Fig.15 The electronic device 150 is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0274] like Fig.15 The electronic device 150 is in the form of a general electronic device. The components of the electronic device 150 may include but are not limited to: at least one processing unit 151, at least one storage unit 152, and a bus 153 connecting different system components (including the storage unit 152 and the processing unit 151).

[0275] Bus 153 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a processor, or a local bus using any of a variety of bus architectures.

[0276] The storage unit 152 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 1521 and / or a cache memory 1522 , and may further include a read-only memory (ROM) 1523 .

[0277] The storage unit 152 may also include a program / utility 1525 having a set (at least one) of program modules 1524, such program modules 1524 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0278] The electronic device 150 may also communicate with one or more external devices 154 (e.g., keyboards, pointing devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 150, and / or may communicate with any device that enables the electronic device 150 to communicate with one or more other electronic devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 155. Furthermore, the electronic device 150 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 156. As shown, the network adapter 156 communicates with other modules for the electronic device 150 via a bus 153. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 150, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0279] In some possible implementations, various aspects of the image classification method provided by the present application may also be implemented in the form of a program product, which includes a program code. When the program product is run on an electronic device, the program code is used to enable the electronic device to execute the steps of the image classification method according to various exemplary implementations of the present application described above in this specification. For example, the electronic device may execute the following steps: Figure 2 Follow the steps shown in .

[0280] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable 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 above.

[0281] The program product of the embodiment of the present application can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a computing device. However, the program product of the present application is not limited to this. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with a command execution system, device or device.

[0282] The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein the readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with a command execution system, apparatus, or device.

[0283] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0284] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.

[0285] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0286] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0287] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0288] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. An image classification method, characterized in that: include: Using the trained target image classification model, the image to be classified is divided into a plurality of image blocks, and image features of each of the plurality of image blocks are extracted; By using the target image classification model, based on multiple image features, a mixing process is performed in an iterative manner to obtain a corresponding multiple target mixed features; wherein one round of mixing process includes: generating mixing parameters based on multiple image features input in this round, and outputting multiple intermediate mixed features based on the mixing parameters and the multiple image features, and obtaining multiple new image features based on the multiple intermediate mixed features; By using the target image classification model, classification prediction is performed on the image to be classified based on the multiple target mixed features to obtain a classification result of the image to be classified; The generating of the mixed parameters based on the multiple image features input in this round includes: dividing the plurality of image features into at least one image feature set, wherein different image feature sets have the same number of image features; For the at least one image feature set, the following operations are respectively performed: generating a mixing matrix based on an image feature set; Using the mixing matrix corresponding to each of the at least one image feature set as the mixing parameter; The outputting a plurality of intermediate mixed features based on the mixed parameter and the plurality of image features comprises: According to the at least one image feature set and the respective mixing matrices, a corresponding plurality of spatial mixing features are obtained, and based on the plurality of spatial mixing features, a plurality of candidate mixing features are output through a fully connected layer; Based on the multiple candidate mixed features, the following operations are performed in an iterative manner: generating new mixed parameters based on the multiple candidate mixed features input this time, and obtaining new multiple candidate mixed features according to the new mixed parameters and the multiple candidate mixed features; The multiple candidate mixed features outputted last time are used as the multiple intermediate mixed features.

2. The method according to claim 1, characterized in that Each image feature corresponds to a multidimensional vector containing multiple feature dimensions. The generating of a mixing matrix based on an image feature set includes: Performing dimensionality reduction processing on each image feature in an image feature set to obtain a corresponding plurality of first dimensionality reduction vectors; The multiple first dimension reduction vectors are concatenated into a first fused feature vector, and the first fused feature vector is converted into the mixing matrix.

3. The method according to claim 1, characterized in that Each image feature corresponds to a multidimensional vector containing multiple feature dimensions. The generating of a mixing matrix based on an image feature set includes: For each image feature in the one image feature set, the following operations are performed respectively: multiple feature dimensions of one image feature are divided into multiple segments to obtain segment features corresponding to each of the multiple segments; wherein each segment corresponds to at least one feature dimension, and different segments have the same number of feature dimensions; For each of the plurality of segment features corresponding to each of the image features, a corresponding sub-mixing matrix is ​​generated based on each of the segment features corresponding to the same segment, so as to obtain a sub-mixing matrix corresponding to each of the plurality of segments; The obtained multiple sub-mixing matrices are used as the mixing matrix.

4. The method according to claim 3, characterized in that The step of generating corresponding sub-mixing matrices based on the segment features corresponding to the same segment, and obtaining sub-mixing matrices corresponding to the multiple segments, comprises: For multiple segments, perform the following operations: Perform dimensionality reduction processing on each segment feature corresponding to a segment to obtain a corresponding plurality of second dimensionality reduction vectors; The multiple second dimensionality reduction vectors are concatenated into a second fused feature vector, and the second fused feature vector is converted into the sub-mixing matrix.

5. The method according to claim 1, characterized in that The mixing matrix includes a plurality of sub-mixing matrices, each image feature in each image feature set includes: segment features corresponding to a plurality of segments, each segment corresponding to a sub-mixing matrix; Then, obtaining corresponding multiple spatial mixing features according to the at least one image feature set and the respective mixing matrices includes: For the at least one image feature set, the following operations are performed respectively: Based on a plurality of segment features corresponding to each image feature in an image feature set, each segment feature corresponding to the same segment is multiplied with a corresponding sub-mixing matrix to obtain a plurality of segment mixed features corresponding to each of the plurality of segments; For the multiple segmentation mixed features corresponding to the multiple segments, the multiple segmentation mixed features corresponding to the same image feature are fused to obtain multiple fused features corresponding to the one image feature set; The multiple spatial mixed features are obtained according to the multiple fusion features respectively corresponding to the at least one image feature set.

6. The method according to claim 5, characterized in that The dividing the plurality of image features into at least one image feature set comprises: Dividing the plurality of image features into a plurality of row image feature sets by row and into a plurality of column image feature sets by column to obtain at least one image feature set; wherein the plurality of image features are arranged into a plurality of rows and columns, and the number of rows and the number of columns are the same; Then, obtaining the plurality of spatial mixed features according to the plurality of fusion features respectively corresponding to the at least one image feature set comprises: Obtaining a row fusion feature set according to the plurality of fusion features corresponding to each of the plurality of row image feature sets, and obtaining a column fusion feature set according to the plurality of fusion features corresponding to each of the plurality of column image feature sets; The plurality of spatial mixed features are obtained based on the row fusion feature set and the column fusion feature set.

7. The method according to any one of claims 1 to 4, characterized in that: The obtaining of multiple new image features based on the multiple intermediate mixed features comprises: The multiple intermediate mixed features are subjected to a convolution operation to obtain the multiple new image features.

8. The method according to any one of claims 1 to 4, characterized in that: The step of performing classification prediction on the image to be classified based on the multiple target mixed features through the target image classification model to obtain the classification result of the image to be classified includes: By using the target image classification model, the plurality of target mixed features are averagely pooled to obtain pooled features; The target image classification model is used to perform classification prediction on the image to be classified based on the pooling features to obtain a classification result of the image to be classified.

9. An image classification device, characterized in that: include: A feature extraction module, used to divide the image to be classified into a plurality of image blocks by using a trained target image classification model, and to extract image features of each of the plurality of image blocks; A feature mixing module, used to perform mixing processing in an iterative manner based on multiple image features through the target image classification model to obtain multiple corresponding target mixed features; wherein one round of mixing processing includes: generating mixing parameters based on multiple image features input in this round, and outputting multiple intermediate mixed features based on the mixing parameters and the multiple image features, and obtaining multiple new image features based on the multiple intermediate mixed features; A classification module, used to perform classification prediction on the image to be classified based on the multiple target mixed features through the target image classification model to obtain a classification result of the image to be classified; When generating the mixing parameters based on the multiple image features input in this round, the feature mixing module is specifically used for: dividing the plurality of image features into at least one image feature set, wherein different image feature sets have the same number of image features; For the at least one image feature set, the following operations are respectively performed: generating a mixing matrix based on an image feature set; Using the mixing matrix corresponding to each of the at least one image feature set as the mixing parameter; When outputting a plurality of intermediate mixed features based on the mixing parameter and the plurality of image features, the feature mixing module is specifically used for: According to the at least one image feature set and the respective mixing matrices, a corresponding plurality of spatial mixing features are obtained, and based on the plurality of spatial mixing features, a plurality of candidate mixing features are output through a fully connected layer; Based on the multiple candidate mixed features, the following operations are performed in an iterative manner: generating new mixed parameters based on the multiple candidate mixed features input this time, and obtaining new multiple candidate mixed features according to the new mixed parameters and the multiple candidate mixed features; The multiple candidate mixed features outputted last time are used as the multiple intermediate mixed features.

10. An electronic device, characterized in that: It includes a processor and a memory, wherein the memory stores program code, and when the program code is executed by the processor, the processor executes the steps of any one of the methods described in claims 1 to 8.

11. A computer-readable storage medium, characterized in that: It includes program code, and when the program code is run on an electronic device, the program code is used to enable the electronic device to execute the steps of any method described in claims 1 to 8.

12. A computer program product, characterized in that It includes computer instructions, which are stored in a computer-readable storage medium; when a processor of an electronic device reads the computer instructions from the computer-readable storage medium, the processor executes the computer instructions, so that the electronic device performs the steps of any method described in claims 1 to 8.