An image classification method and related equipment
By using the classification results of reference images in the image classification model to be adjusted, the problem that new categories of images are misjudged as basic categories in the prior art is solved, and the accuracy of image classification is improved.
Patent Information
- Application Number
- CN202110745619.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-30
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2041-06-30
AI Technical Summary
The existing small sample object detection technology is prone to ignore the reference images of new categories during image classification, resulting in the images to be classified being misjudged as basic categories, reducing the accuracy of image classification.
By introducing the first classification result of the reference image into the image classification model, the third feature of the image to be classified is generated, and the final classification result of the image to be classified is adjusted using the feature and the classification result of the reference image to be classified is to ensure that the new category image is not misjudged as the basic category.
Improve the accuracy of image classification, ensure that new category images can be accurately identified, and avoid misjudgment of new categories being fitted to basic categories.
Smart Images

Figure CN113627422B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence (AI) technology, and in particular to an image classification method and related equipment. Background Art
[0002] Image object detection is one of the important tasks of computer vision, and has important applications in fields such as autonomous driving and industrial vision. For the detection task of certain types of objects (for example, industrial machinery, power grid equipment, etc.), the cost of obtaining images of such objects is huge, so usually only a relatively small number of images can be obtained. Therefore, small sample object detection technology came into being.
[0003] The neural network model used in small sample object detection technology contains two branches, one of which is input as a reference image (also called a support image), and the other is input as an image to be classified (also called a query image). When the model classifies an image to be classified, it usually inputs a large number of reference images belonging to the basic category and a small number of reference images belonging to the new category. With the help of these reference images, the model can detect whether the category of the image to be classified is the basic category or the new category.
[0004] During the image classification process, the number of reference images belonging to the basic category is very different from the number of reference images belonging to the new category. The model tends to ignore the impact of the reference images of the new category. When the category of the image to be classified is actually a new category, the model tends to misjudge it as a basic category, resulting in low image classification accuracy. Summary of the invention
[0005] The embodiments of the present application provide an image classification method and related equipment, which can accurately identify images belonging to a new category and will not misjudge images belonging to the new category as images belonging to a basic category, thereby improving the accuracy of image classification.
[0006] A first aspect of an embodiment of the present application provides an image classification method, which is implemented by an image classification model. The method includes:
[0007] When it is necessary to determine the category of an image to be classified, a reference image related to the image to be classified may be obtained first.
[0008] After obtaining the image to be classified and the reference image, the reference image and the image to be classified may be input into an image classification model to obtain a first feature of the reference image and a second feature of the image to be classified through the image classification model.
[0009] Next, the image classification model generates a third feature of the image to be classified according to the first feature of the reference image and the second feature of the image to be classified.
[0010] Then, the image classification model generates a first classification result of the reference image according to the first feature of the reference image, and generates a second classification result of the image to be classified according to the third feature of the image to be classified. The first classification result can be considered as the final classification result of the reference image (i.e., one of the outputs of the image classification model), so the category of the reference image can be determined based on the first classification result, and the second classification result can be considered as the preliminary classification result of the image to be classified. This application does not use this result to determine the category of the image to be classified.
[0011] Finally, the image classification model generates a third classification result (i.e., another output of the image classification model) based on the first classification result of the reference image and the second classification result of the image to be classified. The third classification result can be considered as the final classification result of the image to be classified. Therefore, the category of the image to be classified can be determined based on the third classification result.
[0012] It can be seen from the above method that after the reference image and the image to be classified are input into the image classification model, the image classification model can implement the following steps: obtain the first feature of the reference image and the second feature of the image to be classified. Then, based on the first feature and the second feature, generate the third feature. Then, generate a first classification result based on the first feature, the first classification result can be used to determine the category of the reference image, and generate a second classification result based on the third feature. Finally, generate a third classification result based on the first classification result and the second classification result. After obtaining the third classification result, the category of the image to be classified can be determined based on the result. It can be seen that in the process of the image classification model generating the third classification result of the image to be classified, the first classification result of the reference image is integrated, which is equivalent to the image classification model focusing on the category information of the reference image. Regardless of whether the category of the reference image belongs to a new category or a basic category, the model can notice the influence of the category of the reference image in the classification process of the image to be classified. Therefore, the model will not fit the new category to the basic category. That is, when the image to be classified belongs to a new category, the image classification model can accurately judge that the category of the image to be classified is a category in the new category, and will not misjudge the category of the image to be classified as a category in the basic category, thereby improving the accuracy of image classification.
[0013] In a possible implementation, generating a third classification result according to the first classification result and the second classification result includes: adding the first classification result and the second classification result to obtain a fourth classification result; adding the first classification result and the model parameter of the image classification model to obtain a fifth classification result; multiplying the fifth classification result and the preset weight parameter to obtain a sixth classification result; subtracting the fourth classification result from the sixth classification result to obtain a third classification result. In the above implementation, the second classification result of the image to be classified is adjusted by using the first classification result of the reference image (i.e., adding the two), and the fourth classification result of the image to be classified can be obtained. However, if the category of the reference image is the same as the category of the image to be classified, the adjustment effect of the first classification result of the reference image on the second classification result of the image to be classified is positive, and if the category of the reference image is different from the category of the image to be classified, the adjustment effect of the first classification result of the reference image on the second classification result of the image to be classified is negative. In order to make the final classification result of the image to be classified sufficiently accurate, it is necessary to balance the impact of these two situations. Specifically, after obtaining the fourth classification result of the image to be classified, a series of processing can be performed: the first classification result of the reference image is added to the model parameters of the image classification model to obtain the fifth classification result of the reference image; the fifth classification result of the reference image is multiplied by the preset weight parameter to obtain the sixth classification result of the reference image; the fourth classification result of the image to be classified is subtracted from the sixth classification result of the reference image to obtain the third classification result of the image to be classified. In this way, the third classification result of the image to be classified has sufficient accuracy and can be considered as the final classification result of the image to be classified, so the category of the image to be classified can be determined based on the third classification result.
[0014] In one possible implementation, generating a third classification result based on the first classification result and the second classification result includes: the image classification model directly adds the first classification result of the reference image and the second classification result of the image to be classified to obtain the third classification result of the image to be classified. The third classification result of the image to be classified can be considered as the final classification result of the image to be classified, so the category of the image to be classified can be determined based on the third classification result.
[0015] In a possible implementation, generating a first classification result according to the first feature includes: calculating the probability that the reference image belongs to each category according to the first feature of the reference image, and obtaining a first classification result of the reference image. Since the first classification result of the reference image includes the probability that the reference image belongs to each category (i.e., the probability that the target object presented by the reference image belongs to each category), the category of the reference image can be determined according to the first classification result. Furthermore, the first classification result can also include the position information of the target object in the reference image.
[0016] Generating a second classification result according to the third feature includes: calculating the probability that the image to be classified belongs to each category according to the third feature of the image to be classified, and obtaining a second classification result of the image to be classified. Since the second classification result of the image to be classified includes the probability that the image to be classified belongs to each category (that is, the probability that the target object presented by the image to be classified belongs to each category), the second classification result can be used to determine the category of the image to be classified (but the embodiment of the present application does not use the second classification result to determine the category of the image to be classified). Furthermore, the second classification result may also include the location information of the target object in the image to be classified.
[0017] In a possible implementation, generating a third feature according to the first feature and the second feature includes: performing feature fusion processing on the first feature of the reference image and the second feature of the image to be classified to obtain the third feature of the image to be classified.
[0018] In a possible implementation, the feature fusion processing includes at least one of addition processing, multiplication processing, subtraction processing, cascade processing and cascade convolution processing.
[0019] In a possible implementation, obtaining the first feature of the reference image and the second feature of the image to be classified includes: performing feature extraction processing on the reference image to obtain the first feature of the reference image; performing feature extraction processing on the image to be classified to obtain the second feature of the image to be classified.
[0020] A second aspect of an embodiment of the present application provides a model training method, the method comprising: obtaining a reference image and an image to be classified; inputting the reference image and the image to be classified into a model to be trained to obtain a third classification result of the image to be classified, wherein the model to be trained is used to: obtain a first feature of the reference image and a second feature of the image to be classified; generate a third feature based on the first feature and the second feature; generate a first classification result based on the first feature; generate a second classification result based on the third feature; generate a third classification result based on the first classification result and the second classification result; determine a first predicted category of the reference image based on the first classification result, and determine a second predicted category of the image to be classified based on the third classification result; obtain a target loss based on the first real category and the first predicted category of the reference image, the second real category and the second predicted category of the image to be classified, the target loss being used to indicate the difference between the first real category and the first predicted category, and the difference between the second real category and the second predicted category; update the model parameters of the model to be trained based on the target loss until the model training conditions are met to obtain an image classification model.
[0021] The image classification model obtained based on the above method has the ability to classify the image to be classified using the reference image. In the process of image classification, the image classification model can focus on the category information of the reference image. Regardless of whether the category of the reference image is a new category or a basic category, the model can notice the influence of the category of the reference image in the classification process of the image to be classified. Therefore, the model will not fit the new category to the basic category. That is, when the image to be classified belongs to a new category, the image classification model can accurately judge that the category of the image to be classified is a category in the new category, and will not misjudge the category of the image to be classified as a category in the basic category, thereby improving the accuracy of image classification.
[0022] In a possible implementation, obtaining a target loss according to a first true category and a first predicted category of a reference image, a second true category and a second predicted category of an image to be classified includes: obtaining a first sub-loss according to the first true category and the first predicted category of the reference image, the first sub-loss being used to indicate a difference between the first true category and the first predicted category; obtaining a second sub-loss according to the second true category and the second predicted category of the image to be classified, the second sub-loss being used to indicate a difference between the second true category and the second predicted category; and adding the first sub-loss and the second sub-loss to obtain a target loss.
[0023] In a possible implementation, the model to be trained is used to add the first classification result and the second classification result to obtain a third classification result.
[0024] In a possible implementation, the model to be trained is used to: calculate the probability that the reference image belongs to each category based on the first feature to obtain a first classification result; calculate the probability that the image to be classified belongs to each category based on the third feature to obtain a second classification result.
[0025] In a possible implementation, the model to be trained is used to perform feature fusion processing on the first feature and the second feature to obtain a third feature.
[0026] In a possible implementation, the feature fusion processing includes at least one of addition processing, multiplication processing, subtraction processing, cascade processing and cascade convolution processing.
[0027] In a possible implementation, the model to be trained is used to: perform feature extraction processing on the reference image to obtain a first feature; and perform feature extraction processing on the image to be classified to obtain a second feature.
[0028] A third aspect of an embodiment of the present application provides an image classification device, which includes: a feature extraction module, used to obtain a first feature of a reference image and a second feature of an image to be classified; a feature fusion module, used to generate a third feature based on the first feature and the second feature; a first classification module, used to generate a first classification result based on the first feature, and the first classification result is used to determine the category of the reference image; a second classification module, used to generate a second classification result based on the third feature; and a classification result adjustment module, used to generate a third classification result based on the first classification result and the second classification result, and the third classification result is used to determine the category of the image to be classified.
[0029] It can be seen from the above device that after the reference image and the image to be classified are input into the image classification model, the image classification model can implement the following steps: obtain the first feature of the reference image and the second feature of the image to be classified. Then, generate the third feature according to the first feature and the second feature. Then, generate the first classification result according to the first feature, the first classification result can be used to determine the category of the reference image, and generate the second classification result according to the third feature. Finally, generate the third classification result according to the first classification result and the second classification result. The third classification result is obtained, and the category of the image to be classified can be determined based on the result. It can be seen that in the process of the image classification model generating the third classification result of the image to be classified, the first classification result of the reference image is integrated, which is equivalent to the image classification model focusing on the category information of the reference image. Regardless of whether the category of the reference image is a new category or a basic category, the model can notice the influence of the category of the reference image in the classification process of the image to be classified. Therefore, the model will not fit the new category to the basic category, that is, when the image to be classified is an image belonging to a new category, the image classification model can accurately judge that the category of the image to be classified is a category in the new category, and will not misjudge the category of the image to be classified as a category in the basic category, thereby improving the accuracy of image classification.
[0030] In a possible implementation, the classification result adjustment module is used to add the first classification result and the second classification result to obtain a third classification result.
[0031] In one possible implementation, the classification result adjustment module is used to: add the first classification result and the second classification result to obtain a fourth classification result; add the first classification result and the model parameters of the image classification model to obtain a fifth classification result; multiply the fifth classification result and the preset weight parameter to obtain a sixth classification result; subtract the fourth classification result from the sixth classification result to obtain a third classification result.
[0032] In one possible implementation, the first classification module is used to calculate the probability that the reference image belongs to each category based on the first feature to obtain a first classification result; the second classification module is used to calculate the probability that the image to be classified belongs to each category based on the third feature to obtain a second classification result.
[0033] In a possible implementation, the feature fusion module is used to perform feature fusion processing on the first feature and the second feature to obtain a third feature.
[0034] In a possible implementation, the feature fusion processing includes at least one of addition processing, multiplication processing, subtraction processing, cascade processing and cascade convolution processing.
[0035] In a possible implementation, the feature extraction module includes a first feature extraction module and a second feature extraction module, wherein the first feature extraction module is used to perform feature extraction processing on the reference image to obtain the first feature; and the second feature extraction module is used to perform feature extraction processing on the image to be classified to obtain the second feature.
[0036] A fourth aspect of an embodiment of the present application provides a model training device, which includes: an acquisition module, which is used to acquire a reference image and an image to be classified; a processing module, which is used to input the reference image and the image to be classified into a model to be trained to obtain a third classification result of the image to be classified, and the model to be trained is used to: acquire a first feature of the reference image and a second feature of the image to be classified; generate a third feature according to the first feature and the second feature; generate a first classification result according to the first feature; generate a second classification result according to the third feature; generate a third classification result according to the first classification result and the second classification result; a determination module, which is used to determine a first predicted category of the reference image according to the first classification result, and determine a second predicted category of the image to be classified according to the third classification result; a calculation module, which is used to obtain a target loss according to the first real category and the first predicted category of the reference image, the second real category and the second predicted category of the image to be classified, and the target loss is used to indicate the difference between the first real category and the first predicted category, and the difference between the second real category and the second predicted category; an update module, which is used to update the model parameters of the model to be trained according to the target loss until the model training conditions are met to obtain an image classification model.
[0037] The image classification model obtained based on the above device has the ability to classify the image to be classified using the reference image. In the process of image classification, the image classification model can focus on the category information of the reference image. Regardless of whether the category of the reference image is a new category or a basic category, the model can notice the influence of the category of the reference image in the classification process of the image to be classified. Therefore, the model will not fit the new category to the basic category, that is, when the image to be classified is an image belonging to a new category, the image classification model can accurately judge that the category of the image to be classified is a category in the new category, and will not misjudge the category of the image to be classified as a category in the basic category, thereby improving the accuracy of image classification.
[0038] In a possible implementation, a calculation module is used to obtain a first sub-loss according to a first true category and a first predicted category of a reference image, where the first sub-loss is used to indicate a difference between the first true category and the first predicted category; obtain a second sub-loss according to a second true category and a second predicted category of the image to be classified, where the second sub-loss is used to indicate a difference between the second true category and the second predicted category; and add the first sub-loss and the second sub-loss to obtain a target loss.
[0039] In a possible implementation, the model to be trained is used to add the first classification result and the second classification result to obtain a third classification result.
[0040] In a possible implementation, the model to be trained is used to: calculate the probability that the reference image belongs to each category based on the first feature to obtain a first classification result; calculate the probability that the image to be classified belongs to each category based on the third feature to obtain a second classification result.
[0041] In a possible implementation, the model to be trained is used to perform feature fusion processing on the first feature and the second feature to obtain a third feature.
[0042] In a possible implementation, the feature fusion processing includes at least one of addition processing, multiplication processing, subtraction processing, cascade processing and cascade convolution processing.
[0043] In a possible implementation, the model to be trained is used to: perform feature extraction processing on the reference image to obtain a first feature; and perform feature extraction processing on the image to be classified to obtain a second feature.
[0044] A fifth aspect of an embodiment of the present application provides an image classification device, which includes a memory and a processor; the memory stores code, and the processor is configured to execute the code. When the code is executed, the image classification device executes the method described in the first aspect or any possible implementation method of the first aspect.
[0045] A sixth aspect of an embodiment of the present application provides a model training device, which includes a memory and a processor; the memory stores code, and the processor is configured to execute the code. When the code is executed, the model training device executes the method described in the second aspect or any possible implementation method of the second aspect.
[0046] A seventh aspect of an embodiment of the present application provides a circuit system, which includes a processing circuit, and the processing circuit is configured to execute a method as described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0047] An eighth aspect of an embodiment of the present application provides a chip system, which includes a processor for calling a computer program or computer instructions stored in a memory so that the processor executes a method as described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0048] In a possible implementation manner, the processor is coupled to the memory through an interface.
[0049] In a possible implementation, the chip system also includes a memory, in which a computer program or computer instructions are stored.
[0050] A ninth aspect of an embodiment of the present application provides a computer storage medium storing a computer program, which, when executed by a computer, enables the computer to implement the method described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0051] The tenth aspect of the embodiments of the present application provides a computer program product, which stores instructions, which, when executed by a computer, enable the computer to implement the method described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0052] In the embodiment of the present application, after the reference image and the image to be classified are input into the image classification model, the image classification model can implement the following steps: obtain the first feature of the reference image and the second feature of the image to be classified. Then, generate the third feature according to the first feature and the second feature. Then, generate the first classification result according to the first feature, the first classification result can be used to determine the category of the reference image, and generate the second classification result according to the third feature. Finally, generate the third classification result according to the first classification result and the second classification result. The third classification result is obtained, and the category of the image to be classified can be determined based on the result. It can be seen that in the process of the image classification model generating the third classification result of the image to be classified, the first classification result of the reference image is integrated, which is equivalent to the image classification model focusing on the category information of the reference image. Regardless of whether the category of the reference image is a new category or a basic category, the model can notice the influence of the category of the reference image in the classification process of the image to be classified, so the model will not fit the new category to the basic category, that is, when the image to be classified is an image belonging to a new category, the image classification model can accurately judge that the category of the image to be classified is a category in the new category, and will not misjudge the category of the image to be classified as a category in the basic category, thereby improving the accuracy of image classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 A structural diagram of the main framework of artificial intelligence;
[0054] Figure 2a A schematic diagram of the structure of an image processing system provided in an embodiment of the present application;
[0055] Figure 2b Another structural schematic diagram of the image processing system provided in an embodiment of the present application;
[0056] Figure 2c A schematic diagram of an image processing device provided in an embodiment of the present application;
[0057] Figure 3 A schematic diagram of the system 100 architecture provided in an embodiment of the present application;
[0058] Figure 4 A schematic diagram of a flow chart of an image classification method provided in an embodiment of the present application;
[0059] Figure 5 A structural diagram of an image classification model provided in an embodiment of the present application;
[0060] Figure 6 A schematic diagram of a cause-and-effect diagram provided in an embodiment of the present application;
[0061] Figure 7 A schematic diagram of a flow chart of a model training method provided in an embodiment of the present application;
[0062] Figure 8 A schematic diagram of the structure of an image classification device provided in an embodiment of the present application;
[0063] Fig. 9 A schematic diagram of the structure of a model training device provided in an embodiment of the present application;
[0064] Fig.10 A schematic diagram of the structure of an execution device provided in an embodiment of the present application;
[0065] Fig.11 A schematic diagram of the structure of the training device provided in the embodiment of the present application;
[0066] Fig.12 A schematic diagram of the structure of the chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0067] The embodiments of the present application provide an image classification method and related equipment, which can accurately identify images belonging to a new category and will not misjudge images belonging to the new category as images belonging to a basic category, thereby improving the accuracy of image classification.
[0068] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0069] Object detection in images is one of the important tasks of computer vision, and has important applications in fields such as autonomous driving and industrial vision. For the detection task of certain types of objects (for example, industrial machinery, power grid equipment, etc.), the cost of obtaining images of such objects is huge, so usually only a relatively small number of images can be obtained. Therefore, small sample object detection technology came into being.
[0070] The neural network model used in image object detection technology contains two branches, one of which takes a reference image as input (also called a support image) and the other takes an image to be classified as input (also called a query image). During the training process of the model, the reference image usually contains a large number of images belonging to the basic category and a small number of images belonging to the new category. By jointly training the model with the reference image and the image to be classified, the trained model can be equipped with the ability to detect whether the image belongs to the basic category or the new category. For example, the basic category can be common means of transportation, including cars, bicycles, motorcycles, etc., and the new category is a rare means of transportation, including airplanes, high-speed trains, etc.
[0071] In the above training process, since a large number of images of the basic category are used, and a small number of images of the new category are used, the trained model is likely to misjudge images belonging to the new category as images of the basic category when performing image classification, resulting in poor image classification results. Still as in the above example, since a large number of car images, bicycle images, and motorcycle images are used in the model training process, and only a small number of airplane images are used. Then, when a certain airplane image is input into the trained model for classification, the model is likely to misjudge the category of the image as one of the car, bicycle, and motorcycle.
[0072] In order to solve the above problems, the present application provides an image classification method, which can be implemented in combination with artificial intelligence (AI) technology. AI technology is a technical discipline that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence. AI technology obtains the best results by sensing the environment, acquiring knowledge and using knowledge. In other words, artificial intelligence technology is a branch of 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. Using artificial intelligence for image processing is a common application of artificial intelligence.
[0073] First, the overall workflow of the artificial intelligence system is described. Figure 1 , Figure 1It is a structural diagram of the main framework of artificial intelligence. The following is an explanation of the above artificial intelligence theme framework from two dimensions: "intelligent information chain" (horizontal axis) and "IT value chain" (vertical axis). Among them, the "intelligent information chain" reflects a series of processes from data acquisition to processing. For example, it can be a general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, the data has undergone a condensation process of "data-information-knowledge-wisdom". The "IT value chain" reflects the value that artificial intelligence brings to the information technology industry from the underlying infrastructure of human intelligence, information (providing and processing technology implementation) to the industrial ecology process of the system.
[0074] (1) Infrastructure
[0075] The infrastructure provides computing power support for the AI system, enables communication with the outside world, and supports it through the basic platform. It communicates with the outside world through sensors; computing power is provided by smart chips (CPU, NPU, GPU, ASIC, FPGA and other hardware acceleration chips); the basic platform includes distributed computing frameworks and networks and other related platform guarantees and support, which can include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to obtain data, and these data are provided to the smart chips in the distributed computing system provided by the basic platform for calculation.
[0076] (2) Data
[0077] The data on the upper layer of the infrastructure is used to represent the data sources in the field of artificial intelligence. The data involves graphics, images, voice, text, and IoT data of traditional devices, including business data of existing systems and perception data such as force, displacement, liquid level, temperature, and humidity.
[0078] (3) Data processing
[0079] Data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making and other methods.
[0080] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.
[0081] Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formalized information to perform machine thinking and solve problems based on reasoning control strategies. Typical functions are search and matching.
[0082] Decision-making refers to the process of making decisions after intelligent information is reasoned, usually providing functions such as classification, sorting, and prediction.
[0083] (4) General ability
[0084] After the data has undergone the data processing mentioned above, some general capabilities can be further formed based on the results of the data processing, such as an algorithm or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
[0085] (5) Smart products and industry applications
[0086] Smart products and industry applications refer to the products and applications of artificial intelligence systems in various fields. They are the encapsulation of the overall artificial intelligence solution, which productizes intelligent information decision-making and realizes practical applications. Its application areas mainly include: smart terminals, smart transportation, smart medical care, autonomous driving, smart cities, etc.
[0087] Next, several application scenarios of this application are introduced.
[0088] Figure 2a A schematic diagram of the structure of an image processing system provided in an embodiment of the present application, the image processing system includes a user device and a data processing device. The user device includes an intelligent terminal such as a mobile phone, a personal computer or an information processing center. The user device is the initiator of image processing, and as the initiator of the image processing request, the request is usually initiated by the user through the user device.
[0089] The above-mentioned data processing device can be a device or server with data processing function such as a cloud server, a network server, an application server and a management server. The data processing device receives the image processing request from the intelligent terminal through the interactive interface, and then performs image processing in the form of machine learning, deep learning, search, reasoning, decision-making, etc. through the memory for storing data and the processor link for data processing. The memory in the data processing device can be a general term, including local storage and databases for storing historical data. The database can be on the data processing device or on other network servers.
[0090] exist Figure 2a In the image processing system shown, the user device can receive the user's instructions. For example, the user device can obtain an image input / selected by the user, and then initiate a request to the data processing device, so that the data processing device executes an image processing application (for example, image object detection, etc.) for the image obtained by the user device, thereby obtaining a corresponding processing result for the image. Exemplarily, the user device can obtain an image input by the user, and then initiate an image object detection request to the data processing device, so that the data processing device classifies the image, thereby obtaining the category to which the image belongs, that is, the category to which the object presented in the image belongs.
[0091] exist Figure 2aIn the embodiment of the present application, the data processing device can execute the image processing method of the embodiment of the present application.
[0092] Figure 2b Another structural diagram of the image processing system provided in the embodiment of the present application is shown in FIG. Figure 2b In the process, the user device directly acts as a data processing device. The user device can directly obtain input from the user and directly process it by the hardware of the user device itself. The specific process is similar to Figure 2a Similarly, please refer to the above description and will not repeat them here.
[0093] exist Figure 2b In the image processing system shown, the user device can receive instructions from the user. For example, the user device can obtain an image selected by the user in the user device, and then the user device itself executes an image processing application (such as image target detection, etc.) on the image to obtain a corresponding processing result for the image.
[0094] exist Figure 2b In the embodiment of the present application, the user equipment itself can execute the image processing method.
[0095] Figure 2c A schematic diagram of image processing related equipment provided in an embodiment of the present application.
[0096] Above Figure 2a and Figure 2b The user equipment in the example may specifically be Figure 2c The local device 301 or the local device 302 in Figure 2a The data processing device in the embodiment may be Figure 2c The execution device 210 in the embodiment, wherein the data storage system 250 can store the data to be processed by the execution device 210, and the data storage system 250 can be integrated on the execution device 210, or can be set on the cloud or other network servers.
[0097] Figure 2a and Figure 2b The processor in the image processing apparatus can perform data training / machine learning / deep learning through a neural network model or other models (for example, a model based on a support vector machine), and use the model finally trained or learned from the data to execute image processing applications on the image, thereby obtaining corresponding processing results.
[0098] Figure 3 A schematic diagram of the system 100 architecture provided in an embodiment of the present application, in Figure 3In the embodiment, the execution device 110 is configured with an input / output (I / O) interface 112 for data interaction with an external device. The user can input data to the I / O interface 112 through the client device 140. The input data may include: various tasks to be scheduled, callable resources and other parameters in the embodiment of the application.
[0099] When the execution device 110 preprocesses the input data, or when the computing module 111 of the execution device 110 performs calculation and other related processing (such as implementing the function of the neural network in the present application), the execution device 110 can call the data, code, etc. in the data storage system 150 for the corresponding processing, and can also store the data, instructions, etc. obtained by the corresponding processing in the data storage system 150.
[0100] Finally, the I / O interface 112 returns the processing result to the client device 140 so as to provide it to the user.
[0101] It is worth noting that the training device 120 can generate corresponding target models / rules based on different training data for different goals or tasks, and the corresponding target models / rules can be used to achieve the above goals or complete the above tasks, thereby providing the user with the desired results. The training data can be stored in the database 130 and come from the training samples collected by the data collection device 160.
[0102] exist Figure 3 In the case shown in the figure, the user can manually give input data, and the manual giving can be operated through the interface provided by the I / O interface 112. In another case, the client device 140 can automatically send input data to the I / O interface 112. If the client device 140 is required to automatically send input data and needs to obtain the user's authorization, the user can set the corresponding authority in the client device 140. The user can view the results output by the execution device 110 on the client device 140, and the specific presentation form can be a specific method such as display, sound, action, etc. The client device 140 can also be used as a data acquisition terminal to collect the input data of the input I / O interface 112 and the output results of the output I / O interface 112 as shown in the figure as new sample data, and store them in the database 130. Of course, it is also possible not to collect through the client device 140, but the I / O interface 112 directly stores the input data of the input I / O interface 112 and the output results of the output I / O interface 112 as new sample data in the database 130.
[0103] It is worth noting that Figure 3 This is only a schematic diagram of a system architecture provided by an embodiment of the present application. The positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. For example, in Figure 3 In the embodiment, the data storage system 150 is an external memory relative to the execution device 110. In other cases, the data storage system 150 may also be placed in the execution device 110. Figure 3 As shown, a neural network can be obtained by training according to the training device 120.
[0104] The present application also provides a chip including a neural network processor NPU. The chip can be arranged in Figure 3 The execution device 110 shown in FIG. 1 is used to complete the calculation work of the calculation module 111. The chip can also be set in Figure 3 The training device 120 shown is used to complete the training work of the training device 120 and output the target model / rule.
[0105] Neural network processor NPU, NPU is mounted on the main central processing unit (CPU) (host CPU) as a coprocessor, and the main CPU assigns tasks. The core part of NPU is the operation circuit, and the controller controls the operation circuit to extract data from the memory (weight memory or input memory) and perform operations.
[0106] In some implementations, the arithmetic circuit includes multiple processing units (process engines, PEs) inside. In some implementations, the arithmetic circuit is a two-dimensional systolic array. The arithmetic circuit can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit is a general-purpose matrix processor.
[0107] For example, suppose there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit takes the corresponding data of matrix B from the weight memory and caches it on each PE in the operation circuit. The operation circuit takes the matrix A data from the input memory and performs matrix operations with matrix B. The partial results or final results of the matrix are stored in the accumulator.
[0108] The vector computing unit can further process the output of the operation circuit, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. For example, the vector computing unit can be used for network calculations of non-convolutional / non-FC layers in neural networks, such as pooling, batch normalization, local response normalization, etc.
[0109] In some implementations, the vector computation unit can store the processed output vector to a unified buffer. For example, the vector computation unit can apply a nonlinear function to the output of the computation circuit, such as a vector of accumulated values, to generate an activation value. In some implementations, the vector computation unit generates a normalized value, a merged value, or both. In some implementations, the processed output vector can be used as an activation input to the computation circuit, such as for use in a subsequent layer in a neural network.
[0110] The unified memory is used to store input data and output data.
[0111] The weight data is directly transferred from the external memory to the input memory and / or the unified memory through the direct memory access controller (DMAC), the weight data in the external memory is stored in the weight memory, and the data in the unified memory is stored in the external memory.
[0112] The bus interface unit (BIU) is used to implement interaction between the main CPU, DMAC and instruction fetch memory through the bus.
[0113] An instruction fetch buffer connected to the controller, used to store instructions used by the controller;
[0114] The controller is used to call the instructions cached in the memory to control the working process of the computing accelerator.
[0115] Generally, the unified memory, input memory, weight memory and instruction fetch memory are all on-chip memories, and the external memory is a memory outside the NPU, which can be a double data rate synchronous dynamic random access memory (DDRSDRAM), a high bandwidth memory (HBM) or other readable and writable memory.
[0116] Since the embodiments of the present application involve the application of a large number of neural networks, in order to facilitate understanding, the relevant terms and related concepts such as neural networks involved in the embodiments of the present application are first introduced below.
[0117] (1) Neural Network
[0118] A neural network may be composed of neural units, and a neural unit may refer to an operation unit with xs and intercept 1 as input, and the output of the operation unit may be:
[0119]
[0120] Where s=1, 2, ...n, n is a natural number greater than 1, Ws is the weight of xs, and b is the bias of the neural unit. f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into the output signal. The output signal of the activation function can be used as the input of the next convolution layer. The activation function can be a sigmoid function. A neural network is a network formed by connecting many of the above-mentioned single neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the characteristics of the local receptive field. The local receptive field can be an area composed of several neural units.
[0121] The work of each layer in the neural network can be described by the mathematical expression y=a(Wx+b): From a physical level, the work of each layer in the neural network can be understood as completing the transformation from the input space to the output space (i.e., the row space to the column space of the matrix) through five operations on the input space (the set of input vectors). These five operations include: 1. Dimension increase / reduction; 2. Zoom in / out; 3. Rotation; 4. Translation; 5. "Bending". Among them, operations 1, 2, and 3 are completed by Wx, operation 4 is completed by +b, and operation 5 is implemented by a(). The word "space" is used here because the classified object is not a single thing, but a class of things, and space refers to the collection of all individuals of this class of things. Among them, W is a weight vector, and each value in the vector represents the weight value of a neuron in the neural network of this layer. The vector W determines the spatial transformation from the input space to the output space described above, that is, the weight W of each layer controls how to transform the space. The purpose of training a neural network is to finally obtain the weight matrix of all layers of the trained neural network (the weight matrix formed by many layers of vectors W). Therefore, the training process of a neural network is essentially about learning how to control spatial transformations, or more specifically, learning the weight matrix.
[0122] Because we want the output of the neural network to be as close as possible to the value we really want to predict, we can compare the current network's predicted value with the target value we really want, and then update the weight vector of each layer of the neural network based on the difference between the two (of course, there is usually an initialization process before the first update, that is, pre-configuring parameters for each layer in the neural network). For example, if the network's predicted value is high, adjust the weight vector to make it predict a lower value, and keep adjusting until the neural network can predict the target value we really want. Therefore, it is necessary to predefine "how to compare the difference between the predicted value and the target value", which is the loss function or objective function, which are important equations used to measure the difference between the predicted value and the target value. Among them, taking the loss function as an example, the higher the output value (loss) of the loss function, the greater the difference, so the training of the neural network becomes a process of minimizing this loss as much as possible.
[0123] (2) Back propagation algorithm
[0124] Neural networks can use the error back propagation (BP) algorithm to correct the size of the parameters in the initial neural network model during the training process, so that the reconstruction error loss of the neural network model becomes smaller and smaller. Specifically, the forward transmission of the input signal to the output will generate error loss, and the parameters in the initial neural network model are updated by back propagating the error loss information, so that the error loss converges. The back propagation algorithm is a back propagation movement dominated by error loss, which aims to obtain the optimal parameters of the neural network model, such as the weight matrix.
[0125] The method provided in the present application is described below from the training side of the neural network and the application side of the neural network.
[0126] The model training method provided in the embodiment of the present application involves image processing, and can be specifically applied to data training, machine learning, deep learning and other data processing methods, and symbolizes and formalizes intelligent information modeling, extraction, preprocessing, training, etc. for the training data (such as the reference image and the image to be classified in the present application), and finally obtains a trained neural network (such as the image classification model in the present application); and the image processing method provided in the embodiment of the present application can use the above-mentioned trained neural network to input the input data (such as the reference image and the image to be classified in the present application) into the trained neural network to obtain output data (such as the first classification result of the reference image in the present application, the third classification result of the image to be classified, etc.). It should be noted that the model training method and image processing method provided in the embodiment of the present application are inventions based on the same concept, and can also be understood as two parts in a system, or two stages of an overall process: such as the model training stage and the model application stage.
[0127] Figure 4 This is a flow chart of an image classification method provided in an embodiment of the present application. The method can use an image classification model to process a reference image and an image to be classified, thereby determining the category of the image to be classified, that is, the category to which the object presented in the image to be classified belongs. The structure of the image classification model is as follows: Figure 5 As shown ( Figure 5 A structural diagram of an image classification model provided in an embodiment of the present application) The image classification model includes two branches, one of which includes a first feature extraction module and a first classification module, and the other branch includes a second feature extraction module, a feature fusion module, a second classification module, and a classification result adjustment module. Figure 4 and Figure 5 , the image classification method provided by this application is specifically introduced, and the method includes:
[0128] 401. Obtain a first feature of a reference image and a second feature of an image to be classified.
[0129] When it is necessary to determine the category of an image to be classified, reference images related to the image to be classified can be obtained first. It should be noted that the number of reference images is generally greater than the number of images to be classified, and the categories of different reference images are usually different (i.e., different reference images present objects of different categories). The number of reference images belonging to the basic category is usually large, and the number of reference images belonging to the new category is usually small. The category to which the image to be classified belongs is usually one of the categories to which multiple reference images belong. For example, Figure 5 As shown, the multiple reference images may be images showing cars, images showing airplanes, etc., respectively, and the image to be classified may be an image showing airplanes, wherein the car category is one of the basic categories, the airplane category is one of the new categories, and the basic categories may also include Figure 5 Bicycle categories, motorcycle categories, etc. not shown, new categories may also include Figure 5 High-speed rail categories not shown, etc.
[0130] Then, the reference image is input into the first feature extraction module of the image classification model, so that the first feature extraction module can perform feature extraction processing on the reference image to obtain the first feature of the reference image. Similarly, the image to be classified is input into the second feature extraction module of the image classification model, so that the second feature extraction module can perform feature extraction processing on the image to be classified to obtain the second feature of the image to be classified.
[0131] Specifically, multiple reference images can be input into the first feature extraction module E s For any reference image S i (i.e., the i-th reference image), the first feature extraction module E s The reference image S i Perform feature extraction to obtain the reference image S i The first characteristic E s (S i ). Similarly, the image to be classified Q can be input into the second feature extraction module E q , the second feature extraction module E q The image to be classified can be divided into multiple sub-image blocks. For any sub-image block Q j (i.e., the jth image block), the second feature extraction module E q Features can be extracted to obtain the sub-image block Q of the image to be classified Q j The second characteristic E q (Q j ).
[0132] 402. Generate a third feature based on the first feature and the second feature.
[0133] After the first feature extraction module obtains the first feature of the reference image, the first feature of the reference image can be sent to the feature fusion module. Similarly, after the second feature extraction module obtains the second feature of the image to be classified, the second feature of the image to be classified can be input into the feature fusion module. In this way, the feature fusion module can perform feature fusion processing on the first feature and the second feature, thereby obtaining the third feature of the image to be classified. The feature fusion processing may include at least one of addition processing, multiplication processing, subtraction processing, cascade processing and cascade convolution processing.
[0134] Specifically, the first feature extraction module E s The first features of all reference images can be input into the feature fusion module T, and the second feature extraction module E qThe second features of all sub-image blocks of the image to be classified can be input into the feature fusion module T. Therefore, the feature fusion module T can perform feature fusion on the first features of all reference images and the second features of all sub-image blocks of the image to be classified to obtain multiple third features. i The first characteristic E s (S i ) and sub-image block Q j The second characteristic E q (Q j ) to perform feature fusion and obtain the third feature T(S i , Q j Then, the third feature T(S i , Q j ) can be considered as a sub-image block Q of the image to be classified j In the reference image S i In addition, the sub-image block Q of the image to be classified Q can also be obtained. j The third feature obtained under the influence of the remaining reference images. Therefore, the sub-image block Q of the image to be classified Q j The third feature obtained under the action of each reference image can be considered as a sub-image block Q of the image to be classified Q j In this way, the third feature of each sub-image block in the image to be classified Q (ie, the third feature of the image to be classified Q) can be obtained.
[0135] 403. Generate a first classification result according to the first feature, where the first classification result is used to determine a category of the reference image.
[0136] After the first feature extraction module obtains the first feature of the reference image, it can also input the first feature of the reference image into the first classification module. Then, the first classification module can calculate the probability that the reference image belongs to each category based on the first feature of the reference image, and obtain the first classification result (i.e., the final classification result of the reference image). Since the first classification result includes the probability that the reference image belongs to each category (i.e., the probability that the target object presented in the reference image belongs to each category), the category of the reference image can be determined based on the first classification result. In addition, the first classification result can also include the location information of the target object in the reference image (e.g., two-dimensional coordinates, etc.).
[0137] For example, assuming that the reference image is an image showing a bicycle, after the first classification module obtains the first feature of the image, it can calculate the probability that the image belongs to each category such as car, airplane, train, bicycle, etc. based on the first feature of the image, and obtain the first classification result of the image. The classification result includes the probability that the image belongs to the car category, the probability that the image belongs to the airplane category, the probability that the image belongs to the train category, the probability that the image belongs to the bicycle category, etc. Therefore, based on the size of these probabilities, the category to which the image belongs can be determined (generally, in the classification result, the probability that the image belongs to the bicycle is the largest, so it can be determined that the image belongs to the bicycle category). In addition, the classification result may also include the two-dimensional coordinates of the bicycle in the image.
[0138] Specifically, the first feature extraction module E s The first features of all reference images can be input into the first classification module P s For any reference image S i The first characteristic E s (S i ), the first classification module P s It can be calculated to obtain the reference image S i The first classification result in, is the reference image S i The target object in the reference image S i The coordinates in is the reference image S i The probability of belonging to each category (i.e., the reference image S i Then, from Determine the reference image S i When the probability of belonging to a certain category is the largest, the reference image S can be determined i belongs to this category.
[0139] 404. Generate a second classification result according to the third feature.
[0140] After the feature fusion module obtains the third feature of the image to be classified, the third feature can be sent to the second classification module. Then, the second classification module can calculate the probability that the image to be classified belongs to each category based on the third feature of the image to be classified, and obtain a second classification result. Since the second classification result includes the probability that the image to be classified belongs to each category (that is, the probability that the target object presented by the image to be classified belongs to each category), the second classification result can be used to determine the category of the image to be classified (but the embodiment of the present application does not use the second classification result to determine the category of the image to be classified, which will not be expanded here). In addition, the second classification result may also include the position information of the target object in the image to be classified (for example, two-dimensional coordinates, etc.).
[0141] For example, suppose the image to be classified is an image showing an airplane. After the second classification module obtains the third feature of the image, it can calculate the probability that the image belongs to each category such as car, airplane, train, bicycle, etc. according to the third feature of the image, and obtain the second classification result of the image. The classification result includes the probability that the image belongs to the car category, the probability that the image belongs to the airplane category, the probability that the image belongs to the train category, the probability that the image belongs to the bicycle category, etc. Therefore, the classification result can be used to determine the category to which the image belongs (but the embodiment of the present application does not operate in this way, so it will not be expanded here). In addition, the classification result may also include the two-dimensional coordinates of the airplane in the image.
[0142] Specifically, the feature fusion module T can send the third features of all sub-image blocks to the second classification module P q , for any sub-image block Q j In the reference image S i The third characteristic T(S i , Q j ), the second classification module P q It can be calculated to obtain the sub-image block Q j In the reference image S i The second classification results under the effect of is the sub-image block Q j The coordinates in the image to be classified Q, is the sub-image block Q j The probability of belonging to each category. Then, we can get the sub-image block Q j The second classification result under the action of each reference image (i.e., the sub-image block Q j Similarly, the second classification results of the remaining image blocks under the effect of each reference image (i.e., the second classification results of the remaining image blocks) can also be obtained. After the second classification results of all image blocks are obtained, it is equivalent to obtaining the second classification result of the image to be classified Q.
[0143] However, in the training process of the model of the related technology, since there are more images of basic categories (e.g., cars, bicycles, etc.) and fewer images of new categories (e.g., airplanes, etc.) in the reference images used for training, the model trained based on these reference images is prone to fitting the new categories to the basic categories during the image classification process, that is, when the model classifies the images to be classified belonging to the new categories, it is easy to misjudge the images to be classified as belonging to the basic categories. Therefore, if the second classification result of the image to be classified is directly used to determine the category of the image to be classified, it is not accurate enough, so the second classification result of the image to be classified needs to be adjusted.
[0144] 405. Generate a third classification result according to the first classification result and the second classification result, where the third classification result is used to determine the category of the image to be classified.
[0145] After the first classification module obtains the first classification result of the reference image, the first classification result of the reference image can be sent to the classification result adjustment module. Similarly, after the second classification module obtains the second classification result of the image to be classified, the second classification result of the image to be classified can be sent to the classification result adjustment module. Then, the classification result adjustment module can use the first classification result of the reference image to adjust the second classification result of the image to be classified to obtain the third classification result of the image to be classified (i.e., the final classification result of the image to be classified), and then the category of the image to be classified can be determined based on the third classification result of the image to be classified. The classification result adjustment module can adjust the second classification result in a variety of ways, which will be introduced below:
[0146] In a possible implementation manner, the classification result adjustment module adds the first classification result of the reference image and the second classification result of the image to be classified to obtain a third classification result of the image to be classified.
[0147] Specifically, for the sub-image block Q j In the reference image S i The second classification results under the effect of It can be compared with the reference image S i The first classification result Adding, we can get the sub-image block Q j In the reference image S i The third classification results under the effect of Right now:
[0148]
[0149] Through the above formula, we can get the sub-image block Q j The third classification results under the effect of each reference image are based on which the sub-image block Q can be determined. j By analogy, the third classification result of each sub-image block under the action of each reference image can be obtained (equivalent to obtaining the third classification result of all sub-image blocks, that is, the third classification result of the image to be classified Q). In this way, the category of each sub-image block in the image to be classified Q can be determined. Since the target objects presented in the image to be classified Q are distributed on the sub-image blocks, when the categories of most of the sub-image blocks are the same category, the categories of these sub-image blocks are the categories of the image to be classified Q (that is, the categories of the target objects presented in the image to be classified Q), and the coordinates of these sub-image blocks in the image to be classified Q are the coordinates of the target objects in the image to be classified Q.
[0150] In another possible implementation, the classification result adjustment module may first add the first classification result of the reference image and the second classification result of the image to be classified to obtain a fourth classification result of the image to be classified. Then, the classification result adjustment module adds the first classification result of the reference image and the model parameters of the image classification model to obtain a fifth classification result of the reference image. Next, the classification result adjustment module multiplies the fifth classification result of the reference image with a preset weight parameter to obtain a sixth classification result of the reference image. Finally, the classification result adjustment module subtracts the fourth classification result of the image to be classified from the sixth classification result of the reference image to obtain a third classification result of the image to be classified.
[0151] Specifically, for the sub-image block Q j In the reference image S i The second classification results under the effect of It can be compared with the reference image S i The first classification result Adding, we can get the sub-image block Q j In the reference image S i The fourth classification results under the effect of It is worth noting that when the reference image S i When the category of the image to be classified is the same as that of the image Q, the reference image S i The first classification result For the sub-image block Q j In the reference image S i The second classification results under the effect of The adjustment effect is positive. i When the category of the image to be classified is different from that of the image Q, the reference image S i The first classification result For the sub-image block Q j In the reference image S i The second classification results under the effect of The adjustment effect is negative. It can be seen that in order to make the final classification result accurate enough, it is necessary to balance the impact of these two situations.
[0152] The following will combine Figure 6 The above balance process is introduced. Figure 6 A schematic diagram of a cause-effect diagram provided in an embodiment of the present application. Figure 6 As shown in Figure 1, the image classification model is transformed into a causal graph, where S represents the features of the reference image, Q represents the features of the image to be classified, F represents the fusion features of the reference image and the image to be classified, and P is the final classification result of the image to be classified. Among them, S→P means that S is the cause of P, and P is the result of S.
[0153] Assume that s, p, and f are valid values of S, Q, and F (obtained by calculating the image), and s*, p*, and f* are invalid values of S, Q, and F (that is, S, Q, and F are all set to 0). By calculating the difference in the final classification results when each variable is a valid value and an invalid value, the causal effect of each variable on the final classification result can be analyzed.
[0154] The total causal effect (TE) of S on P can be expressed as:
[0155] TE=P s,q,f -P s*,q*,f* (3)
[0156] In the above formula, P s,q,f The final classification result obtained when S, Q and F are all valid values. s*,q*,f* The final classification result is obtained when S, Q and F are all invalid values.
[0157] The natural direct effect (NDE) of S on P can be expressed as:
[0158] NDE=P s,q*,f* -P s*,q*,f* (4)
[0159] In the above formula, P s,q*,f* is the final classification result when S is a valid value and Q and F are both invalid values. Then, the indirect causal effect (total indirect effect, TIE) of S on P is:
[0160] TIE=TE-NDE=P s,q,f -P s,q*,f* (5)
[0161] Since the TE of S to P is equal to the sum of the TIE of S to P and the NDE of S to P, then, based on TE and P s,q,f The relationship between (i.e., formula (5)) can be obtained:
[0162] NDE+TIE+P s*,q*,f* =P s,q,f (6)
[0163] In order to weaken the impact of S's NDE on P on the final classification result, NDE can be appropriately reduced to obtain a new final classification result:
[0164]
[0165] In the formula, α is usually greater than 0 and less than 1, and its specific value can be set according to actual needs. is the new final classification result. In this way, substituting formula (4) and formula (5) into formula (7) yields:
[0166]
[0167] After obtaining formula (8), the sub-image block Q j In the reference image S i The fourth classification results under the effect of As the original final classification result (that is, P in formula (8) s,q,f ). Correspondingly, P s,q*,f* for and A is the model parameter of the feature fusion module and the classification result adjustment module in the trained image classification model (which can be considered as a constant). s*,q*,f* is B, B is the model parameter of the entire trained image classification model (also a constant). Then, the corresponding new final classification result (i.e., sub-image block Q j In the reference image S i The third classification results under the effect of
[0168]
[0169] Based on formula (9), we can get the sub-image block Q j In the reference image S i The third classification result under the action of , and so on, we can get the sub-image block Q j The third classification result under the action of all reference images (equivalent to obtaining the sub-image block Q j Based on these classification results, the sub-image block Q can be determined. j Similarly, the third classification result of each sub-image block under the effect of all reference images can be obtained (equivalent to obtaining the third classification result of each sub-image block, that is, the third classification result of the image to be classified Q). In this way, the category of each sub-image block in the image to be classified Q can be determined. Since the target objects presented in the image to be classified Q are distributed on the sub-image blocks, when the categories of most of the sub-image blocks are the same category, the categories of these sub-image blocks are the categories of the image to be classified Q (that is, the categories of the target objects presented in the image to be classified Q), and the coordinates of these sub-image blocks in the image to be classified Q are the coordinates of the target objects in the image to be classified Q.
[0170] It should be noted that in formula (9), (1-α) is equivalent to the aforementioned preset weight parameter, AB is equivalent to the model parameter of the aforementioned image classification model, as well as Equivalent to the fifth classification result of the aforementioned reference image, as well as Equivalent to the sixth classification result of the aforementioned reference image.
[0171] In addition, the image classification model provided in the embodiment of the present application can be compared with the image classification model of the related art. Specifically, the same test sample (including reference images and images to be classified) can be used to input the image classification model provided in the embodiment of the present application and the image classification model of the related art for testing, and the results obtained are shown in Tables 1 to 4. Among them, there are 10 reference images belonging to the new category in the first test sample, and 30 reference images belonging to the new category in the second test sample, and the reference images belonging to the basic category in the first test sample and the second test sample are much larger than 30.
[0172] In Tables 1 and 3, the average precision under six conditions is shown, and the six conditions are: IoU from 0.5 to 0.95 (step size is 0.05), IoU equals 0.5, IoU equals 0.75, detecting large-scale objects (containing more pixels), detecting medium-scale objects (containing moderate pixels), and detecting small-scale objects (containing fewer pixels). Among them, the IoU represents the ratio between the predicted position of the target object in the image to be classified (i.e., the predicted detection box containing the target object) and the true position (i.e., the true detection box containing the target object). In Tables 2 and 4, the average recall rate under six conditions is shown, and the six conditions are: setting one detection box, setting 10 detection boxes, setting 100 detection boxes, detecting large-scale objects, detecting medium-scale objects, and detecting small-scale objects. Tables 1 to 4 are respectively:
[0173] Table 1
[0174]
[0175] Table 2
[0176]
[0177] Table 3
[0178]
[0179] Table 4
[0180]
[0181] It can be seen that the performance of the model provided by the embodiment of the present application is significantly better than the performance of the model of the related art.
[0182] In the embodiment of the present application, after the reference image and the image to be classified are input into the image classification model, the image classification model can implement the following steps: obtain the first feature of the reference image and the second feature of the image to be classified. Then, generate the third feature according to the first feature and the second feature. Then, generate the first classification result according to the first feature, the first classification result can be used to determine the category of the reference image, and generate the second classification result according to the third feature. Finally, generate the third classification result according to the first classification result and the second classification result. The third classification result is obtained, and the category of the image to be classified can be determined based on the result. It can be seen that in the process of the image classification model generating the third classification result of the image to be classified, the first classification result of the reference image is integrated, which is equivalent to the image classification model focusing on the category information of the reference image. Regardless of whether the category of the reference image is a new category or a basic category, the model can notice the influence of the category of the reference image in the classification process of the image to be classified, so the model will not fit the new category to the basic category, that is, when the image to be classified is an image belonging to a new category, the image classification model can accurately judge that the category of the image to be classified is a category in the new category, and will not misjudge the category of the image to be classified as a category in the basic category, thereby improving the accuracy of image classification.
[0183] The above is a detailed description of the image classification method provided in the embodiment of the present application. The following is an introduction to the model training method provided in the embodiment of the present application. Figure 7 A flow chart of the model training method provided in the embodiment of the present application. Figure 7 As shown, the method includes:
[0184] 701. Obtain a reference image and an image to be classified.
[0185] When it is necessary to train the model to be trained, a batch of training samples can be obtained, namely, the reference images and the images to be classified for training. The model to be trained includes two branches, one of which includes a first feature extraction module and a first classification module, and the other includes a second feature extraction module, a feature fusion module, a second classification module, and a classification result adjustment module. It is worth noting that the first true category of the reference image and the second true category of the image to be classified are known. For an introduction to the reference image and the image to be classified, please refer to Figure 4 The relevant description of step 401 in the illustrated embodiment will not be repeated here.
[0186] 702. Input the reference image and the image to be classified into the model to be trained to obtain a third classification result of the image to be classified. The model to be trained is used to: obtain a first feature of the reference image and a second feature of the image to be classified; generate a third feature according to the first feature and the second feature; generate a first classification result according to the first feature; generate a second classification result according to the third feature; generate a third classification result according to the first classification result and the second classification result.
[0187] After obtaining the reference image and the image to be classified, the reference image can be input into the first feature module, so that the first feature extraction module can perform feature extraction processing on the reference image to obtain the first feature of the reference image. Similarly, the image to be classified is input into the second feature module, so that the second feature extraction module can perform feature extraction processing on the image to be classified to obtain the second feature of the image to be classified.
[0188] After the first feature extraction module obtains the first feature of the reference image, the first feature of the reference image can be sent to the feature fusion module. Similarly, after the second feature extraction module obtains the second feature of the image to be classified, the second feature of the image to be classified can be input to the feature fusion module. In this way, the feature fusion module can perform feature fusion processing on the first feature and the second feature, thereby obtaining the third feature of the image to be classified.
[0189] After the first feature extraction module obtains the first feature of the reference image, it can also input the first feature of the reference image into the first classification module. Then, the first classification module can calculate the probability that the reference image belongs to each category according to the first feature of the reference image to obtain a first classification result.
[0190] After the feature fusion module obtains the third feature of the image to be classified, the third feature can be sent to the second classification module. Then, the second classification module can calculate the probability that the image to be classified belongs to each category according to the third feature of the image to be classified, and obtain a second classification result.
[0191] After the first classification module obtains the first classification result of the reference image, the first classification result of the reference image can be sent to the classification result adjustment module. Similarly, after the second classification module obtains the second classification result of the image to be classified, the second classification result of the image to be classified can be sent to the classification result adjustment module. Then, the classification result adjustment module can use the first classification result of the reference image to adjust the second classification result of the image to be classified to obtain a third classification result of the image to be classified. Specifically, the classification result adjustment module can obtain the third classification result in a variety of ways:
[0192] In a possible implementation manner, the classification result adjustment module adds the first classification result of the reference image and the second classification result of the image to be classified to obtain a third classification result of the image to be classified.
[0193] It should be understood that in the process of training the model, it is not necessary to balance the positive and negative effects of the first classification result of the reference image on the second classification result of the to-be-classified image. However, in the actual application of the model (i.e. Figure 4 In the embodiment shown), both effects can be balanced.
[0194] For the process of obtaining the first classification result of the reference image and the third classification result of the image to be classified by the model to be trained, please refer to the aforementioned Figure 4 The relevant description parts of steps 401 to 405 in the illustrated embodiment will not be repeated here.
[0195] 703. Determine a first predicted category of the reference image according to the first classification result, and determine a second predicted category of the image to be classified according to the third classification result.
[0196] After obtaining the first classification result of the reference image and the third classification result of the image to be classified through the model to be trained, the first predicted category of the reference image can be determined according to the first classification result of the reference image, and the second predicted category of the image to be classified can be determined according to the third classification result of the image to be classified.
[0197] 704. Obtain a target loss according to the first true category and the first predicted category of the reference image, the second true category and the second predicted category of the image to be classified, where the target loss is used to indicate the difference between the first true category and the first predicted category, and the difference between the second true category and the second predicted category.
[0198] After obtaining the first predicted category of the reference image and the second predicted category of the image to be classified, the target loss can be obtained by calculation based on the first true category and the first predicted category of the reference image, the second true category and the second predicted category of the image to be classified. Specifically, the target loss can be obtained in a variety of ways:
[0199] In a possible implementation, a first predicted category and a first true category of a reference image are calculated by a first objective function to obtain a first sub-loss, which is used to indicate the difference between the first true category and the first predicted category, and a second predicted category and a second true category of the image to be classified are calculated by a second objective function to obtain a second sub-loss, which is used to indicate the difference between the second true category and the second predicted category. After obtaining the first sub-loss and the second sub-loss, the first sub-loss and the second sub-loss are added to obtain the target loss.
[0200] 705. Update the model parameters of the model to be trained according to the target loss until the model training conditions are met to obtain an image classification model.
[0201] After obtaining the target loss, the model parameters of the model to be trained can be updated based on the target loss, and the model to be trained with the updated parameters can be trained using the next batch of training samples (i.e., re-executing steps 702 to 705) until the model training conditions are met (for example, the target loss reaches convergence, etc.), and an image classification model can be obtained.
[0202] The image classification model trained by the embodiment of the present application has the ability to classify the image to be classified using the reference image. In the process of image classification, the image classification model can focus on the category information of the reference image. Regardless of whether the category of the reference image is a new category or a basic category, the model can notice the influence of the category of the reference image in the classification process of the image to be classified. Therefore, the model will not fit the new category to the basic category, that is, when the image to be classified is an image belonging to a new category, the image classification model can accurately judge that the category of the image to be classified is a category in the new category, and will not misjudge the category of the image to be classified as a category in the basic category, thereby improving the accuracy of image classification.
[0203] The above is a detailed description of the model training method provided in the embodiment of the present application. The image classification device and model training device provided in the embodiment of the present application will be introduced respectively below. Figure 8 A schematic diagram of the structure of the image classification device provided in the embodiment of the present application. Figure 8 As shown, the device comprises:
[0204] A feature extraction module 801 is used to obtain a first feature of a reference image and a second feature of an image to be classified;
[0205] A feature fusion module 802, configured to generate a third feature based on the first feature and the second feature;
[0206] A first classification module 803, used to generate a first classification result according to the first feature, and the first classification result is used to determine the category of the reference image;
[0207] A second classification module 804, configured to generate a second classification result according to the third feature;
[0208] The classification result adjustment module 805 is used to generate a third classification result according to the first classification result and the second classification result, and the third classification result is used to determine the category of the image to be classified.
[0209] In a possible implementation, the classification result adjustment module 805 is used to add the first classification result and the second classification result to obtain a third classification result.
[0210] In one possible implementation, the classification result adjustment module 805 is used to: add the first classification result and the second classification result to obtain a fourth classification result; add the first classification result and the model parameters of the image classification model to obtain a fifth classification result; multiply the fifth classification result and the preset weight parameter to obtain a sixth classification result; subtract the fourth classification result from the sixth classification result to obtain a third classification result.
[0211] In one possible implementation, the first classification module 803 is used to calculate the probability that the reference image belongs to each category based on the first feature to obtain a first classification result; the second classification module 804 is used to calculate the probability that the image to be classified belongs to each category based on the third feature to obtain a second classification result.
[0212] In a possible implementation, the feature fusion module 802 is used to perform feature fusion processing on the first feature and the second feature to obtain a third feature.
[0213] In a possible implementation, the feature fusion processing includes at least one of addition processing, multiplication processing, subtraction processing, cascade processing and cascade convolution processing.
[0214] In a possible implementation, the feature extraction module 801 includes a first feature extraction module and a second feature extraction module, wherein the first feature extraction module is used to perform feature extraction processing on the reference image to obtain the first feature; and the second feature extraction module is used to perform feature extraction processing on the image to be classified to obtain the second feature.
[0215] Fig. 9 A schematic diagram of the structure of the model training device provided in the embodiment of the present application. Fig. 9 As shown, the device comprises:
[0216] An acquisition module 901 is used to acquire a reference image and an image to be classified;
[0217] The processing module 902 is used to input the reference image and the image to be classified into the model to be trained to obtain a third classification result of the image to be classified, and the model to be trained is used to: obtain a first feature of the reference image and a second feature of the image to be classified; generate a third feature according to the first feature and the second feature; generate a first classification result according to the first feature; generate a second classification result according to the third feature; generate a third classification result according to the first classification result and the second classification result;
[0218] A determination module 903, configured to determine a first predicted category of the reference image according to the first classification result, and to determine a second predicted category of the image to be classified according to the third classification result;
[0219] A calculation module 904 is used to obtain a target loss according to the first true category and the first predicted category of the reference image, the second true category and the second predicted category of the image to be classified, where the target loss is used to indicate the difference between the first true category and the first predicted category, and the difference between the second true category and the second predicted category;
[0220] The updating module 905 is used to update the model parameters of the to-be-trained model according to the target loss until the model training conditions are met to obtain an image classification model.
[0221] In a possible implementation, the calculation module 904 is used to obtain a first sub-loss based on a first true category and a first predicted category of a reference image, where the first sub-loss is used to indicate the difference between the first true category and the first predicted category; obtain a second sub-loss based on a second true category and a second predicted category of the image to be classified, where the second sub-loss is used to indicate the difference between the second true category and the second predicted category; and add the first sub-loss and the second sub-loss to obtain a target loss.
[0222] In a possible implementation, the model to be trained is used to add the first classification result and the second classification result to obtain a third classification result.
[0223] In a possible implementation, the model to be trained is used to: calculate the probability that the reference image belongs to each category based on the first feature to obtain a first classification result; calculate the probability that the image to be classified belongs to each category based on the third feature to obtain a second classification result.
[0224] In a possible implementation, the model to be trained is used to perform feature fusion processing on the first feature and the second feature to obtain a third feature.
[0225] In a possible implementation, the feature fusion processing includes at least one of addition processing, multiplication processing, subtraction processing, cascade processing and cascade convolution processing.
[0226] In a possible implementation, the model to be trained is used to: perform feature extraction processing on the reference image to obtain a first feature; and perform feature extraction processing on the image to be classified to obtain a second feature.
[0227] It should be noted that the information interaction, execution process, etc. between the modules / units of the above-mentioned device are based on the same concept as the method embodiment of the present application, and the technical effects they bring are the same as those of the method embodiment of the present application. For specific contents, please refer to the description in the method embodiment shown above in the embodiment of the present application, and will not be repeated here.
[0228] The embodiment of the present application also relates to an execution device, Fig.10A schematic diagram of the structure of the execution device provided in the embodiment of the present application. Fig.10 As shown, the execution device 1000 can be specifically a mobile phone, a tablet, a laptop, a smart wearable device, a server, etc., which is not limited here. Figure 8 The image classification device described in the corresponding embodiment is used to implement Figure 4 The image classification function in the corresponding embodiment. Specifically, the execution device 1000 includes: a receiver 1001, a transmitter 1002, a processor 1003 and a memory 1004 (wherein the number of the processor 1003 in the execution device 1000 can be one or more, Fig.10 In the example of FIG. 1003 , the processor 1003 may include an application processor 10031 and a communication processor 10032. In some embodiments of the present application, the receiver 1001, the transmitter 1002, the processor 1003 and the memory 1004 may be connected via a bus or other means.
[0229] The memory 1004 may include a read-only memory and a random access memory, and provides instructions and data to the processor 1003. A portion of the memory 1004 may also include a non-volatile random access memory (NVRAM). The memory 1004 stores processor and operation instructions, executable modules or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.
[0230] The processor 1003 controls the operation of the execution device. In a specific application, the various components of the execution device are coupled together through a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus, and a status signal bus, etc. However, for the sake of clarity, various buses are referred to as bus systems in the figure.
[0231] The method disclosed in the above embodiment of the present application can be applied to the processor 1003, or implemented by the processor 1003. The processor 1003 can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 1003. The above processor 1003 can be a general processor, a digital signal processor (digital signal processing, DSP), a microprocessor or a microcontroller, and can further include an application specific integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The processor 1003 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor are combined to execute. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 1004, and the processor 1003 reads the information in the memory 1004 and completes the steps of the above method in combination with its hardware.
[0232] The receiver 1001 can be used to receive input digital or character information and generate signal input related to the relevant settings and function control of the execution device. The transmitter 1002 can be used to output digital or character information through the first interface; the transmitter 1002 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; the transmitter 1002 can also include a display device such as a display screen.
[0233] In one embodiment of the present application, the processor 1003 is configured to: Figure 4 The image classification model in the corresponding embodiment performs image object detection on the image.
[0234] The present application also relates to a training device. Fig.11 A schematic diagram of the structure of the training device provided in the embodiment of the present application. Fig.11As shown, the training device 1100 is implemented by one or more servers. The training device 1100 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1114 (for example, one or more processors) and memory 1132, one or more storage media 1130 (for example, one or more mass storage devices) storing application programs 1142 or data 1144. Among them, the memory 1132 and the storage medium 1130 can be short-term storage or permanent storage. The program stored in the storage medium 1130 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the training device. Furthermore, the central processing unit 1114 can be configured to communicate with the storage medium 1130 to execute a series of instruction operations in the storage medium 1130 on the training device 1100.
[0235] The training device 1100 may also include one or more power supplies 1126, one or more wired or wireless network interfaces 1150, one or more input and output interfaces 1158; or, one or more operating systems 1141, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0236] Specifically, the training device can perform Figure 7 The model training method in the corresponding embodiment.
[0237] An embodiment of the present application also relates to a computer storage medium, in which a program for signal processing is stored. When the program is run on a computer, the computer executes the steps executed by the aforementioned execution device, or the computer executes the steps executed by the aforementioned training device.
[0238] An embodiment of the present application also relates to a computer program product, which stores instructions, which, when executed by a computer, enable the computer to execute the steps executed by the aforementioned execution device, or enable the computer to execute the steps executed by the aforementioned training device.
[0239] The execution device, training device or terminal device provided in the embodiments of the present application may specifically be a chip, and the chip includes: a processing unit and a communication unit, wherein the processing unit may be, for example, a processor, and the communication unit may be, for example, an input / output interface, a pin or a circuit, etc. The processing unit may execute the computer execution instructions stored in the storage unit so that the chip in the execution device executes the data processing method described in the above embodiment, or so that the chip in the training device executes the data processing method described in the above embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit may also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0240] For details, please refer to Fig.12 , Fig.12 A schematic diagram of the structure of a chip provided in an embodiment of the present application, the chip can be expressed as a neural network processor NPU 1200, NPU 1200 is mounted on the host CPU (Host CPU) as a coprocessor, and the host CPU assigns tasks. The core part of the NPU is the operation circuit 1203, which is controlled by the controller 1204 to extract matrix data from the memory and perform multiplication operations.
[0241] In some implementations, the operation circuit 1203 includes multiple processing units (Process Engine, PE) inside. In some implementations, the operation circuit 1203 is a two-dimensional systolic array. The operation circuit 1203 can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the operation circuit 1203 is a general-purpose matrix processor.
[0242] For example, assume there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit takes the corresponding data of matrix B from the weight memory 1202 and caches it on each PE in the operation circuit. The operation circuit takes the matrix A data from the input memory 1201 and performs matrix operation with matrix B, and the partial result or final result of the matrix is stored in the accumulator 1208.
[0243] The unified memory 1206 is used to store input data and output data. The weight data is directly transferred to the weight memory 1202 through the direct memory access controller (DMAC) 1205. The input data is also transferred to the unified memory 1206 through the DMAC.
[0244] BIU stands for Bus Interface Unit, i.e., bus interface unit 1213 , which is used for the interaction between AXI bus and DMAC and instruction fetch buffer (IFB) 1209 .
[0245] The bus interface unit 1213 (Bus Interface Unit, BIU for short) is used for the instruction fetch memory 1209 to obtain instructions from the external memory, and is also used for the storage unit access controller 1205 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
[0246] DMAC is mainly used to transfer input data in the external memory DDR to the unified memory 1206 or to transfer weight data to the weight memory 1202 or to transfer input data to the input memory 1201.
[0247] The vector calculation unit 1207 includes multiple operation processing units, and further processes the output of the operation circuit 1203 when necessary, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional / fully connected layer network calculations in neural networks, such as Batch Normalization, pixel-level summation, upsampling of predicted label planes, etc.
[0248] In some implementations, the vector calculation unit 1207 can store the processed output vector to the unified memory 1206. For example, the vector calculation unit 1207 can apply a linear function; or a nonlinear function to the output of the operation circuit 1203, such as linear interpolation of the predicted label plane extracted by the convolution layer, and then, for example, a vector of accumulated values to generate an activation value. In some implementations, the vector calculation unit 1207 generates a normalized value, a pixel-level summed value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 1203, for example, for use in a subsequent layer in a neural network.
[0249] An instruction fetch buffer 1209 connected to the controller 1204 is used to store instructions used by the controller 1204;
[0250] Unified memory 1206, input memory 1201, weight memory 1202 and instruction fetch memory 1209 are all on-chip memories. External memories are private to the NPU hardware architecture.
[0251] The processor mentioned in any of the above places may be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the above programs.
[0252] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0253] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0254] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0255] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. An image classification method, characterized in that: The method is implemented by an image classification model, and the method comprises: Obtaining a first feature of a reference image and a second feature of an image to be classified; generating a third feature according to the first feature and the second feature; generating a first classification result according to the first feature, wherein the first classification result is used to determine a category of the reference image; generating a second classification result according to the third feature; Adding the first classification result and the second classification result to obtain a fourth classification result; Adding the first classification result to the model parameters of the image classification model to obtain a fifth classification result; Multiplying the fifth classification result by a preset weight parameter to obtain a sixth classification result; The fourth classification result is subtracted from the sixth classification result to obtain a third classification result; the third classification result is used to determine the category of the image to be classified.
2. The method according to claim 1, characterized in that Generating a first classification result according to the first feature includes: Calculate the probability that the reference image belongs to each category according to the first feature to obtain a first classification result; Generating a second classification result according to the third feature includes: The probability that the image to be classified belongs to each category is calculated according to the third feature to obtain a second classification result.
3. The method according to claim 1 or 2, characterized in that: The generating a third feature according to the first feature and the second feature includes: The first feature and the second feature are subjected to feature fusion processing to obtain the third feature.
4. The method according to claim 3, characterized in that: The feature fusion processing includes at least one of addition processing, multiplication processing, subtraction processing, cascade processing and cascade convolution processing.
5. The method according to claim 1 or 2, characterized in that: The obtaining of the first feature of the reference image and the second feature of the image to be classified comprises: Performing feature extraction processing on the reference image to obtain a first feature; Perform feature extraction processing on the image to be classified to obtain the second feature.
6. A model training method, characterized in that: The method comprises: Obtain a reference image and an image to be classified; The reference image and the image to be classified are input into the model to be trained to obtain a third classification result of the image to be classified, and the model to be trained is used to: obtain a first feature of the reference image and a second feature of the image to be classified; generate a third feature according to the first feature and the second feature; generate a first classification result according to the first feature; generate a second classification result according to the third feature; add the first classification result and the second classification result to obtain a fourth classification result; add the first classification result and the model parameter of the model to be trained to obtain a fifth classification result; multiply the fifth classification result and the preset weight parameter to obtain a sixth classification result; subtract the fourth classification result from the sixth classification result to obtain a third classification result; Determining a first predicted category of the reference image according to the first classification result, and determining a second predicted category of the image to be classified according to the third classification result; According to a first true category of the reference image, the first predicted category, a second true category of the image to be classified, and the second predicted category, obtaining a target loss, wherein the target loss is used to indicate a difference between the first true category and the first predicted category, and a difference between the second true category and the second predicted category; The model parameters of the model to be trained are updated according to the target loss until the model training conditions are met to obtain an image classification model.
7. The method according to claim 6, characterized in that The acquiring the target loss according to the first true category of the reference image, the first predicted category, the second true category of the image to be classified, and the second predicted category comprises: According to a first true category of the reference image and the first predicted category, obtaining a first sub-loss, where the first sub-loss is used to indicate a difference between the first true category and the first predicted category; According to a second true category of the image to be classified and the second predicted category, obtaining a second sub-loss, where the second sub-loss is used to indicate a difference between the second true category and the second predicted category; The first sub-loss and the second sub-loss are added to obtain a target loss.
8. The method according to claim 6 or 7, characterized in that: The model to be trained is used for: Calculate the probability that the reference image belongs to each category according to the first feature to obtain a first classification result; The probability that the image to be classified belongs to each category is calculated according to the third feature to obtain a second classification result.
9. The method according to claim 6 or 7, characterized in that: The model to be trained is used to perform feature fusion processing on the first feature and the second feature to obtain the third feature.
10. The method according to claim 9, characterized in that The feature fusion processing includes at least one of addition processing, multiplication processing, subtraction processing, cascade processing and cascade convolution processing.
11. The method according to claim 6 or 7, characterized in that: The model to be trained is used for: Performing feature extraction processing on the reference image to obtain a first feature; Perform feature extraction processing on the image to be classified to obtain the second feature.
12. An image classification device, characterized in that: The device comprises: A feature extraction module, used for obtaining a first feature of a reference image and a second feature of an image to be classified; A feature fusion module, used for generating a third feature according to the first feature and the second feature; a first classification module, configured to generate a first classification result according to the first feature, wherein the first classification result is used to determine a category of the reference image; A second classification module, used to generate a second classification result according to the third feature; A classification result adjustment module is used to add the first classification result and the second classification result to obtain a fourth classification result; add the first classification result and the model parameter of the image classification model to obtain a fifth classification result; multiply the fifth classification result and the preset weight parameter to obtain a sixth classification result; subtract the fourth classification result from the sixth classification result to obtain a third classification result; the third classification result is used to determine the category of the image to be classified.
13. A model training device, characterized in that: The device comprises: An acquisition module, used for acquiring a reference image and an image to be classified; a processing module, configured to input the reference image and the image to be classified into a model to be trained to obtain a third classification result of the image to be classified, wherein the model to be trained is configured to: obtain a first feature of the reference image and a second feature of the image to be classified; generate a third feature according to the first feature and the second feature; generate a first classification result according to the first feature; generate a second classification result according to the third feature; add the first classification result and the second classification result to obtain a fourth classification result; add the first classification result and the model parameter of the model to be trained to obtain a fifth classification result; multiply the fifth classification result and a preset weight parameter to obtain a sixth classification result; and subtract the fourth classification result from the sixth classification result to obtain a third classification result; a determination module, configured to determine a first predicted category of the reference image according to the first classification result, and to determine a second predicted category of the image to be classified according to the third classification result; a calculation module, configured to obtain a target loss according to a first true category of the reference image, the first predicted category, a second true category of the image to be classified, and the second predicted category, wherein the target loss is used to indicate a difference between the first true category and the first predicted category, and a difference between the second true category and the second predicted category; The updating module is used to update the model parameters of the model to be trained according to the target loss until the model training conditions are met to obtain an image classification model.
14. An image classification device, characterized in that: The device comprises a memory and a processor; the memory stores codes, and the processor is configured to execute the codes. When the codes are executed, the image processing device performs the method according to any one of claims 1 to 11.
15. A computer storage medium, characterized in that: The computer storage medium stores one or more instructions, which, when executed by one or more computers, enable the one or more computers to implement the method of any one of claims 1 to 11.
16. A computer program product, characterized in that The computer program product stores instructions, which, when executed by a computer, enable the computer to implement the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Image classification method, device and equipment, storage medium and medical electronic equipment
CN110276411A