Model training, image classification method and device
By acquiring and fusing local features in small sample learning and constructing a similarity loss function, the limitations of feature extraction in LDR technology are solved and the accuracy and generalization ability of the model are improved.
Patent Information
- Application Number
- CN202111271211.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-10-29
AI Technical Summary
Existing feature extraction methods based on LDR technology have inconsistencies between local features and the overall semantic information of the sample and feature overlap in small sample learning, resulting in limited model prediction performance.
By acquiring a first sample image set and a second sample image set containing a preset number of sample categories, fusion features are obtained based on fusion extraction of local features, and a loss function based on similarity is constructed to train a classification model.
It effectively improves the accuracy and generalization ability of the classification model, reduces the discreteness of features, and enhances the accuracy and comprehensiveness of fused features.
Smart Images

Figure CN113989562B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, specifically to the field of image processing technology, and in particular to a model training, image classification method and device. Background Art
[0002] Existing small sample learning often uses feature extraction methods based on LDR (Local Descriptor-based Representations) technology. This method has two main disadvantages:
[0003] (1) The semantic information of some local features extracted by LDR technology may not be consistent with the semantic information of the sample as a whole (i.e., the category of the sample);
[0004] (2) The local features with different semantic information extracted by LDR technology may overlap with each other.
[0005] These defects may cause the local features obtained using the LDR feature extractor to fail to reflect the similarity between different data samples well, thereby limiting the prediction performance of the current small sample learning model based on LDR feature extraction technology. Summary of the invention
[0006] The embodiments of the present application provide a model training method, apparatus, device and storage medium.
[0007] According to the first aspect, an embodiment of the present application provides a model training method, which includes: obtaining a first sample image set and a second sample image set, wherein the first sample image set includes sample images of a preset number of sample categories; for each category of sample images in the first sample image set, based on the fusion features of at least one sample image in the sample image of the category, obtaining a first fusion feature corresponding to the sample image of the category, wherein the fusion feature is a feature obtained by fusing local features of the image; for each sample image in the second sample image set, extracting the fusion feature of the sample to obtain a second fusion feature of the sample image; based on the similarity between the second fusion feature and the first fusion feature corresponding to the sample images of each category in the first sample image set, constructing a loss function to train a classification model.
[0008] According to the second aspect, an embodiment of the present application provides an image classification method, the method comprising: obtaining an image to be classified; inputting the image to be classified into a classification model to obtain an image category corresponding to the image to be classified, wherein the classification model is a classification model obtained by the method described in any implementation method of the first aspect above.
[0009] According to the third aspect, an embodiment of the present application provides a model training device, which includes: a data acquisition module, configured to acquire a first sample image set and a second sample image set, wherein the first sample image set includes sample images of a preset number of sample categories; a first extraction module, configured to obtain, for each category of sample image in the first sample image set, a first fusion feature corresponding to the sample image of the category based on a fusion feature of at least one sample image in the sample image of the category, wherein the fusion feature is a feature obtained by fusing local features of the image; a second extraction module, configured to extract, for each sample image in the second sample image set, the fusion feature of the sample, to obtain a second fusion feature of the sample image; and a training model module, configured to construct a loss function based on the similarity between the second fusion feature and the first fusion feature corresponding to the sample image of each category in the first sample image set, so as to train a classification model.
[0010] According to the fourth aspect, an embodiment of the present application provides an image classification device, which includes: an image acquisition module, configured to acquire an image to be classified; an image classification module, configured to input the image to be classified into a classification model to obtain an image category corresponding to the image to be classified, wherein the classification model is a classification model obtained by the method described in any implementation method of the first aspect above.
[0011] According to the fifth aspect, an embodiment of the present application provides an electronic device, which includes one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation method of the first aspect or the second aspect.
[0012] According to the sixth aspect, an embodiment of the present application provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any implementation manner of the first aspect or the second aspect.
[0013] The present application obtains a first sample image set and a second sample image set, wherein the first sample image set includes sample images of a preset number of sample categories; for each category of sample images in the first sample image set, based on the fusion features of at least one sample image in the sample image of the category, a first fusion feature corresponding to the sample image of the category is obtained, and the fusion feature is a feature obtained by fusing local features of the image; for each sample image in the second sample image set, the fusion feature of the sample is extracted to obtain a second fusion feature of the sample image; based on the similarity between the second fusion feature and the first fusion feature corresponding to the sample images of each category in the first sample image set, a loss function is constructed to train a classification model, thereby effectively improving the accuracy and generalization ability of the trained classification model.
[0014] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0016] Figure 2 is a flow chart of an embodiment of a model training method according to the present application;
[0017] Figure 3 is a schematic diagram of an application scenario of the model training method according to the present application;
[0018] Figure 4 is a flowchart of another embodiment of the model training method according to the present application;
[0019] Figure 5 is a flowchart of another embodiment of the image classification method according to the present application;
[0020] Figure 6 is a schematic diagram of an embodiment of a model training device according to the present application;
[0021] Figure 7 is a schematic diagram of an embodiment of an image classification device according to the present application;
[0022] Figure 8 It is a structural diagram of a computer system suitable for implementing a server of an embodiment of the present application. DETAILED DESCRIPTION
[0023] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0024] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0025] Figure 1 An exemplary system architecture 100 is shown to which an embodiment of the model training method of the present application can be applied.
[0026] like Figure 1As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0027] The terminal devices 101, 102, 103 interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications, such as image recognition applications, communication applications, etc., may be installed on the terminal devices 101, 102, 103.
[0028] Terminal devices 101, 102, 103 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be various electronic devices with display screens, including but not limited to mobile phones and laptops. When terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, to provide services for model training), or it can be implemented as a single software or software module. No specific limitation is made here.
[0029] The server 105 may be a server that provides various services, for example, obtaining a first sample image set and a second sample image set; for each category of sample images in the first sample image set, obtaining a first fusion feature corresponding to the category of sample images based on a fusion feature of at least one sample image in the category of sample images; for each sample image in the second sample image set, extracting the fusion feature of the sample to obtain a second fusion feature of the sample image; constructing a loss function based on the similarity between the second fusion feature and the first fusion feature corresponding to each category of sample images in the first sample image set, so as to train a classification model.
[0030] It should be noted that the server 105 can be hardware or software. When the server 105 is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, for providing services for training models), or it can be implemented as a single software or software module. No specific limitation is made here.
[0031] It should be noted that the model training method provided in the embodiments of the present disclosure can be executed by the server 105, or by the terminal devices 101, 102, 103, or by the server 105 and the terminal devices 101, 102, 103 in cooperation with each other. Accordingly, the various parts (such as various units, sub-units, modules, sub-modules) included in the model training device can be all set in the server 105, or all set in the terminal devices 101, 102, 103, or respectively set in the server 105 and the terminal devices 101, 102, 103.
[0032] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0033] Figure 2 A flow chart 200 of an embodiment of a model training method that can be applied to the present application is shown. In this embodiment, the model training method includes the following steps:
[0034] Step 201: Acquire a first sample image set and a second sample image set.
[0035] In this embodiment, the execution subject (such as Figure 1 The server 105 or the terminal devices 101, 102, 103) shown in the figure can obtain the first sample image set and the second sample image set from a local or remote server storing sample images.
[0036] The first sample image set and the second sample image set include a small number of sample images, and the sample images are all labeled with image categories. The first sample image set may also be called a support set, and the second sample image set may also be called a query set.
[0037] Here, the first sample image set includes sample images of a preset number of sample categories. The preset number can be set according to actual needs, for example, 5, 10, etc., and this application does not limit this.
[0038] Specifically, a sample image set includes sample images that are all labeled with image categories, and each sample image belongs to one of M categories, but the total number of sample images is very small (for example, no more than 100 images). The execution subject can re-divide the sample image set into a first sample image set and a second sample image set according to the sample image set. The first sample image set, i.e., the support set, is It consists of MN samples, and each category contains N samples. The second sample image set, namely the query set, is It consists of MT samples, and each category contains T samples. It should be noted that here, N and T are very small (for example, no more than 10).
[0039] Step 202: for each category of sample images in the first sample image set, based on the fusion feature of at least one sample image in the category of sample images, obtain a first fusion feature corresponding to the category of sample images.
[0040] In this embodiment, for each category of sample images in the first sample image set, the executing entity can obtain the first fusion feature corresponding to the sample image of the category based on the fusion feature of a sample image in the sample image of the category, that is, directly determine the fusion feature of the sample image as the first fusion feature corresponding to the sample image of the category; it can also obtain the first fusion feature corresponding to the sample image of the category based on the fusion features of multiple sample images in the sample image of the category, and the present application does not limit this.
[0041] The fusion feature is a feature obtained by fusing multiple local features of the image.
[0042] Here, the execution entity may first adopt an algorithm for extracting local features of a sample image in existing technology or future development technology, such as an LDR algorithm, to extract multiple local features of the sample image, and then fuse the multiple local features of the sample image to obtain a fused feature.
[0043] Among them, local features are usually represented in the form of vectors. The execution entity can directly add the vectors of each local feature bit by bit to obtain the average to obtain a fused feature. A local feature can be input into a preset neural network for iterative calculation to obtain a fused feature. A local feature can also be input into a neural network based on an attention mechanism to obtain a fused feature. This application does not limit this.
[0044] In some optional methods, for each category of sample images in the first sample image set, a first fusion feature corresponding to the sample image of the category is obtained based on the fusion features of at least one sample image in the category of sample images, including: for each category of sample images in the first sample image set, a first fusion feature corresponding to the sample image of the category is obtained based on the fusion features of at least two sample images in the category of sample images.
[0045] In this implementation, for each category of sample images in the first sample image set, the execution subject may obtain the first fusion feature corresponding to the sample image of the category according to the fusion features of multiple sample images in the sample image of the category.
[0046] Specifically, let the fusion feature of the nth sample (a total of N samples) image in the mth category in the first sample image set be The first fusion feature representation corresponding to the mth category is Then each (i=1, 2...H) can be expressed by the following formula:
[0047]
[0048] This implementation method obtains the first fusion feature corresponding to each category of sample images in the first sample image set based on the fusion features of at least two sample images in each category of sample images in the first sample image set, which helps to reduce the impact of discrete values on the first fusion feature and improve the accuracy of the first fusion feature. Furthermore, a classification model is trained based on the first fusion feature and the second fusion feature, thereby improving the accuracy of the trained classification model.
[0049] In some optional methods, the fusion feature is obtained in the following manner: for each sample image, the fusion feature is obtained based on the local features of the sample image and a preset neural network model based on the attention mechanism.
[0050] In this implementation, for each sample image, the execution subject may input the local features of the sample image into a preset neural network model based on the attention mechanism to obtain fusion features.
[0051] Specifically, the fusion feature is obtained as shown in the following formula:
[0052]
[0053] in, is the fusion feature, a ji is the attention weight, is a trainable parameter matrix. The attention weight can be calculated by the following formula:
[0054]
[0055] Among them, P K , are two trainable parameter matrices, and the operator “·” represents the inner product operation.
[0056] This implementation method obtains a fusion feature for each sample image based on the local features of the sample image and a preset neural network model based on the attention mechanism, that is, a fusion feature rich in global semantic information. The feature fully considers the weight of each local feature, further improves the accuracy and comprehensiveness of the fusion feature, and further improves the accuracy and generalization ability of the classification model trained based on the fusion feature.
[0057] Step 203: for each sample image in the second sample image set, extract the fusion feature of the sample to obtain the second fusion feature of the sample image.
[0058] In this embodiment, for each sample image in the second sample image set, the execution entity may extract multiple local features of the sample image, fuse the local features to obtain a fused feature, and determine the fused feature as the second fused feature of the sample image.
[0059] Here, the execution subject may first adopt an algorithm for extracting local features of a sample image in existing technology or future development technology, such as an LDR algorithm, to extract multiple local features of the sample image.
[0060] Step 204: construct a loss function based on the similarity between the second fused feature and the first fused feature corresponding to each category of sample images in the first sample image set, so as to train and obtain a classification model.
[0061] In this embodiment, after obtaining the second fusion feature and the first fusion feature corresponding to each category of sample images in the first sample image set, the execution entity can calculate the similarity between the second fusion feature and the first fusion feature corresponding to each category of samples, and obtain a preset number of similarities, and then construct a loss function based on the preset number of similarities, train the initial classification model by minimizing the loss function, and obtain a trained classification model in response to reaching the preset training end condition.
[0062] Among them, the preset conditions for the end of training may include but are not limited to at least one of the following: the training time exceeds the preset duration; the number of training times exceeds the preset number of times; the loss value calculated using the loss function is less than the preset loss value threshold.
[0063] Here, the trained classification model is used to identify the image category.
[0064] In some optional methods, based on the similarity between the second fusion feature and the first fusion feature corresponding to each category of sample images in the first sample image set, a loss function is constructed to train a classification model, including: using a voting method to measure the similarity between the second fusion feature and the first fusion feature corresponding to each category of sample images in the first sample image set; generating a prediction confidence based on the similarity; and constructing a loss function based on the prediction confidence to train a classification model.
[0065] In this implementation, the execution entity can use a voting method to measure the similarity between the second fusion features of each sample image in the second sample image set and the first fusion features of each category of sample images in the first sample image set, and generate a prediction confidence based on the measured similarity, and then construct a loss function based on the prediction confidence to train a classification model.
[0066] Specifically, the first fusion feature representation corresponding to the mth category in the first sample image set (a total of M categories, N samples in each category) is: Samples in the second sample image set (a total of M categories, T samples in each category) The second fusion feature is The voting method is used to measure the similarity between the second fusion feature of the sample image and the first fusion feature of the mth category, which is expressed by the following formula:
[0067]
[0068] Furthermore, using the above similarity {s 1 ,…,s M}Generate prediction confidence, as shown in the following formula:
[0069]
[0070] in, It is a scaling factor that can be set according to specific experimental data and actual needs.
[0071] Based on the prediction confidence given in the above formula, a loss function is constructed, as shown in the following formula:
[0072]
[0073] Where I[·] represents the indicator function.
[0074] Continue to see Figure 3 , Figure 3 It is a schematic diagram of an application scenario of the model training method according to this embodiment.
[0075] exist Figure 3 In the application scenario, the execution subject 301 divides a sample image set into a first sample image set 302 and a second sample image set 303, wherein the first sample image set 302, i.e., the support set, is It consists of MN samples, M categories, and each category contains N samples. The second sample image set 303, i.e. the query set, is It is composed of MT samples, M categories, and each category contains T samples. It should be pointed out that here, N and T are very small (for example, not more than 10). For each category of sample images in the first sample image set 302, based on the fusion features of at least one sample image in the sample image of the category, for example, a sample image, a first fusion feature 304 corresponding to the sample image of the category is obtained, and the fusion feature is a feature obtained by fusing the local features of the image; for each sample image in the second sample image set, the fusion feature of the sample is extracted to obtain the second fusion feature 305 of the sample image; based on the similarity between the second fusion feature 305 and the first fusion feature 304 corresponding to the sample images of each category in the first sample image set, a loss function 306 is constructed to train and obtain a classification model 307.
[0076] The model training method disclosed in the present invention obtains a first sample image set and a second sample image set, wherein the first sample image set includes sample images of a preset number of sample categories; for each category of sample images in the first sample image set, based on the fusion feature of at least one sample image in the sample image of the category, a first fusion feature corresponding to the sample image of the category is obtained, and the fusion feature is a feature obtained by fusing local features of the image; for each sample image in the second sample image set, the fusion feature of the sample is extracted to obtain a second fusion feature of the sample image; based on the similarity between the second fusion feature and the first fusion feature corresponding to the sample images of each category in the first sample image set, a loss function is constructed to train a classification model, thereby effectively improving the accuracy and generalization ability of the trained classification model.
[0077] Further references Figure 4 , which shows Figure 2 A process 400 of another embodiment of the model training method is shown. In this embodiment, the process 400 of obtaining the fusion feature may include the following steps:
[0078] Step 401: for each sample image, a local feature of the sample image is used as an initial local feature, and iterative calculation is performed based on the initial local feature and a preset neural network model.
[0079] In this embodiment, for each sample image, the execution subject may select any one of the multiple local features of the sample image as an initial local feature, and input the initial local feature into a preset neural network model for iterative calculation.
[0080] Among them, the preset neural network model is used to calculate based on the initial local features and the local features closest to the initial local features to obtain the initial fusion features.
[0081] Here, the iterative operation includes: inputting the initial local features into a preset neural network model to obtain initial fusion features; using the initial fusion features as initial local features, and continuing to perform iterative operations.
[0082] Specifically, the execution subject can use LDR technology to extract H local features of the sample image {l 1 ,…,l H}, each local feature is a D-dimensional real vector, that is The specific iterative process is shown as follows:
[0083]
[0084] Among them, t means that it is currently in the tth iteration step, γ (t) and φ (t) are two differentiable functions, is a differentiable permutation invariant function, and Represents the subscript set of the nearest local feature points of the i-th initial local feature.
[0085] Step 402, in response to determining that the iterative operation satisfies a preset condition, a fusion feature is obtained.
[0086] In this embodiment, the execution entity performs iterative calculation based on the initial local features and the preset neural network model, and determines whether the iterative calculation meets the preset conditions. If the iterative calculation meets the preset conditions, the initial fusion features output by the preset neural network model are determined as the fusion features.
[0087] Among them, the preset conditions can be set according to actual needs, for example, the number of iterations of the iterative operation reaches a preset iteration number threshold, such as 1000 times, 2000 times, etc.; the iteration time of the iterative operation reaches a preset iteration time threshold, etc.
[0088] from Figure 4 As can be seen from the figure, this embodiment mainly describes the method for obtaining Figure 2 The process of fusion features shown. This embodiment uses a local feature of each sample image as the initial local feature, and performs iterative calculations based on the initial local feature and a preset neural network model. The iterative operation includes: inputting the initial local feature into the preset neural network model to obtain an initial fusion feature; using the initial fusion feature as the initial local feature, continuing to perform iterative operations, and obtaining fusion features in response to determining that the iterative operation meets the preset conditions. The iterative operation prompts each local position to continuously absorb and fuse other adjacent local features, thereby obtaining a fusion feature rich in the global semantic information of the sample, and then obtaining a classification model based on the fusion feature, which helps to further improve the accuracy and generalization ability of the obtained classification model.
[0089] Continue to refer Figure 5 , shows a process 500 of an embodiment of an image classification method according to the present application. The image classification method comprises the following steps:
[0090] Step 501: Obtain an image to be classified.
[0091] In this embodiment, the execution subject may obtain the image to be classified through a wired or wireless connection.
[0092] The wireless connection method may include but is not limited to 3G / 4G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.
[0093] Step 502: input the image to be classified into the classification model to obtain the image category corresponding to the image to be classified.
[0094] In this embodiment, after obtaining the image to be classified, the execution subject may input the image to be classified into the classification model to obtain the image category corresponding to the image to be classified. Figure 2 The classification model obtained by the method described in the corresponding embodiment will not be described in detail here.
[0095] The image classification method provided by the embodiment of the present disclosure obtains an image to be classified; inputs the image to be classified into a classification model to obtain an image category corresponding to the image to be classified, wherein the classification model is as follows: Figure 2 The classification model obtained by the method described in the embodiment helps to improve the accuracy of classifying images to be classified.
[0096] Further references Figure 6 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a model training device, which is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0097] like Figure 6 As shown, the model training device 600 of this embodiment includes: a data acquisition module 601, a first extraction module 602, a second extraction module 603 and a model training module 604.
[0098] The data acquisition module 601 may be configured to acquire a first sample image set and a second sample image set.
[0099] The first extraction module 602 may be configured to obtain, for each category of sample images in the first sample image set, a first fused feature corresponding to the category of sample images based on a fused feature of at least one sample image in the category of sample images.
[0100] The second extraction module 603 may be configured to extract the fusion feature of each sample image in the second sample image set to obtain the second fusion feature of the sample image.
[0101] The training model module 604 may be configured to construct a loss function based on the similarity between the second fused feature and the first fused feature corresponding to each category of sample images in the first sample image set, so as to train and obtain a classification model.
[0102] In some optional methods of this embodiment, the fusion feature is obtained in the following manner: for each sample image, a local feature of the sample image is used as an initial local feature, and iterative calculation is performed based on the initial local feature and a preset neural network model; in response to determining that the iterative operation satisfies a preset condition, a fusion feature is obtained.
[0103] In some optional methods of this embodiment, the fusion feature is obtained in the following manner: for each sample image, the fusion feature is obtained based on the local features of the sample image and a preset neural network model based on the attention mechanism.
[0104] In some optional embodiments of this embodiment, the model training module is further configured to: use a voting method to measure the similarity between the second fusion feature and the first fusion feature corresponding to each category of sample images in the first sample image set; generate a prediction confidence based on the similarity; and construct a loss function based on the prediction confidence to train a classification model.
[0105] Further references Figure 7 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an image classification device, which is similar to Figure 5 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0106] like Figure 7 As shown, the image classification device 700 of this embodiment includes: an image acquisition module 701 and an image classification module 702 .
[0107] The image acquisition module 701 may be configured to acquire an image to be classified.
[0108] The image classification module 702 may be configured to input the image to be classified into a classification model to obtain an image category corresponding to the image to be classified.
[0109] According to an embodiment of the present application, the present application also provides an electronic device and a readable storage medium.
[0110] like Figure 8 As shown, it is a block diagram of an electronic device according to the model training method of an embodiment of the present application.
[0111] 800 is a block diagram of an electronic device according to the method of model training of an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices and other similar computing devices. The components shown herein, their connections and relationships, and their functions are only examples, and are not intended to limit the implementation of the present application described and / or required herein.
[0112] like Figure 8 As shown, the electronic device includes: one or more processors 801, memory 802, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are interconnected using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 8 A processor 801 is taken as an example.
[0113] The memory 802 is a non-transitory computer-readable storage medium provided in the present application. The memory stores instructions executable by at least one processor to enable the at least one processor to perform the model training method provided in the present application. The non-transitory computer-readable storage medium of the present application stores computer instructions, which are used to enable a computer to perform the model training method provided in the present application.
[0114] The memory 802 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the model training method in the embodiment of the present application (for example, the attached Figure 6The processor 801 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 802, that is, the model training method in the above method embodiment is implemented.
[0115] The memory 802 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the use of the electronic device for model training, etc. In addition, the memory 802 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 802 may optionally include a memory remotely disposed relative to the processor 801, and these remote memories may be connected to the electronic device for model training via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0116] The electronic device of the model training method may further include: an input device 803 and an output device 804. The processor 801, the memory 802, the input device 803 and the output device 804 may be connected via a bus or other means. Figure 8 The example of connecting through bus is taken in the following.
[0117] The input device 803 can receive input digital or character information, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a track ball, a joystick, and other input devices. The output device 804 may include a display device, an auxiliary lighting device (e.g., an LED), and a tactile feedback device (e.g., a vibration motor). The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display, and a plasma display. In some embodiments, the display device may be a touch screen.
[0118] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0119] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for programmable processors and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or means (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0120] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0121] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0122] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
[0123] According to the technical solution of the embodiment of the present application, the accuracy and generalization ability of the trained classification model are effectively improved.
[0124] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in this application can be achieved, and this document is not limited here.
[0125] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A model training method, the method include: Acquire a first sample image set and a second sample image set, wherein the first sample image set includes sample images of a preset number of sample categories; For each category of sample images in the first sample image set, based on the fusion feature of at least one sample image in the category of sample images, a first fusion feature corresponding to the category of sample images is obtained, where the fusion feature is a feature obtained by fusing local features of the image; For each sample image in the second sample image set, extract the fusion feature of the sample to obtain a second fusion feature of the sample image; Based on the similarity between the second fused feature and the first fused feature corresponding to each category of sample images in the first sample image set, a loss function is constructed to train a classification model.
2. The method according to claim 1, in, The fusion features are obtained in the following way: For each sample image, a local feature of the sample image is used as an initial local feature, and an iterative operation is performed based on the initial local feature and a preset neural network model, wherein the preset neural network model is used to perform calculations based on the initial local feature and the local feature closest to the initial local feature to obtain an initial fused feature, and the iterative operation includes: inputting the initial local feature into the preset neural network model to obtain an initial fused feature, using the initial fused feature as the initial local feature, and continuing to perform the iterative operation; In response to determining that the iterative operation satisfies a preset condition, a fusion feature is obtained.
3. The method according to claim 1, in, The fusion features are obtained in the following way: For each sample image, a fusion feature is obtained based on the local features of the sample image and a preset neural network model based on the attention mechanism.
4. The method according to claim 1, in, The step of obtaining, for each category of sample images in the first sample image set, a first fusion feature corresponding to the sample image of the category based on the fusion feature of at least one sample image in the sample image of the category, comprises: For each category of sample images in the first sample image set, a first fusion feature corresponding to the sample image of the category is obtained based on fusion features of at least two sample images in the sample image of the category.
5. The method according to any one of claims 1 to 4, in, The constructing a loss function based on the similarity between the second fused feature and the first fused feature corresponding to each category of sample images in the first sample image set to train a classification model includes: The similarity between the second fused feature and the first fused feature corresponding to each category of sample images in the first sample image set is measured by voting; Generate prediction confidence based on similarity; Based on the prediction confidence, a loss function is constructed to train the classification model.
6. A method for image classification, include: Get the image to be classified; The image to be classified is input into a classification model to obtain an image category corresponding to the image to be classified, wherein the classification model is a classification model obtained by the method according to any one of claims 1 to 5.
7. A model training device, include: A data acquisition module is configured to acquire a first sample image set and a second sample image set, wherein the first sample image set includes sample images of a preset number of sample categories; a first extraction module configured to obtain, for each category of sample images in the first sample image set, a first fused feature corresponding to the sample image of the category based on a fused feature of at least one sample image in the sample image of the category, wherein the fused feature is a feature obtained by fusing local features of the image; A second extraction module is configured to extract, for each sample image in the second sample image set, a fusion feature of the sample to obtain a second fusion feature of the sample image; The training model module is configured to construct a loss function based on the similarity between the second fusion feature and the first fusion feature corresponding to each category of sample images in the first sample image set, so as to train a classification model.
8. The device according to claim 7, in, The fusion feature is obtained by: For each sample image, a local feature of the sample image is used as an initial local feature, and an iterative operation is performed based on the initial local feature and a preset neural network model, wherein the preset neural network model is used to perform calculations based on the initial local feature and the local feature closest to the initial local feature to obtain an initial fused feature, and the iterative operation includes: inputting the initial local feature into the preset neural network model to obtain an initial fused feature, using the initial fused feature as the initial local feature, and continuing to perform the iterative operation; In response to determining that the iterative operation satisfies a preset condition, a fusion feature is obtained.
9. The device according to claim 7, in, The fusion feature is obtained by: For each sample image, a fusion feature is obtained based on the local features of the sample image and a preset neural network model based on the attention mechanism.
10. The device according to claim 7, in, The first extraction module is further configured to: For each category of sample images in the first sample image set, a first fusion feature corresponding to the sample image of the category is obtained based on fusion features of at least two sample images in the sample image of the category.
11. The device according to any one of claims 7 to 10, in, The model training module is further configured to: The similarity between the second fused feature and the first fused feature corresponding to each category of sample images in the first sample image set is measured by voting; Generate prediction confidence based on similarity; Based on the prediction confidence, a loss function is constructed to train the classification model.
12. An image classification device, include: An image acquisition module is configured to acquire an image to be classified; The image classification module is configured to input the image to be classified into a classification model to obtain an image category corresponding to the image to be classified, wherein the classification model is a classification model obtained by the method according to any one of claims 1-5.
13. An electronic device, It is characterized in that include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor so that the at least one processor can perform the method according to any one of claims 1 to 6.
14. A non-transitory computer-readable storage medium storing computer instructions, It is characterized in that The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 6.
