Image classification method and device

By using the target neural network in computer vision technology, combining the loss function and collaborative loss function of the target area and the background area, the feature maps of the target area and the background area are separated, which solves the problem of the target area feature map being affected by background noise, and improves Image classification accuracy.

CN112446398BActive Publication Date: 2024-09-10HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910824602.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-09-02
Publication Date
2024-09-10
Estimated Expiration
2039-09-02

AI Technical Summary

Technical Problem

In existing computer vision technology, the target area feature map is easily affected by the noise of the background area feature map during image classification, resulting in a reduction in the accuracy of the classification results.

Method used

The target neural network trained based on the target area classification loss function, background area classification loss function and collaborative loss function is used to separate the target area feature map and the background area feature map, and suppress the influence of background noise on the target area feature map.

Benefits of technology

The accuracy of the target area classification results is improved, the segmentation accuracy of the target area feature map and the background area feature map is enhanced, and the influence of background noise on the target area feature map is avoided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112446398B
    Figure CN112446398B
Patent Text Reader

Abstract

The present application discloses an image classification method and device in the field of computer vision in the field of artificial intelligence, the image classification method comprising: obtaining an image to be processed, the image to be processed comprising a target area to be identified and a background area; classifying the image to be processed according to a target neural network, and obtaining a classification result of the target area and a classification result of the background area of ​​the image to be processed; wherein the target neural network is trained based on a target area classification loss function, a background area classification loss function and a collaborative loss function, and the collaborative loss function is used to separate a target area feature map of a sample image from a background area feature map of the sample image. The technical solution of the present application can suppress the influence of background area noise on the target area feature map, thereby improving the accuracy of the target area classification result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and more specifically, to an image classification method and device in the field of computer vision. Background Art

[0002] Computer vision is an integral part of various intelligent / autonomous systems in various application fields, such as manufacturing, inspection, document analysis, medical diagnosis, and military. It is a discipline about how to use cameras / camcorders and computers to obtain the data and information we need about the objects being photographed. Figuratively speaking, it is to equip computers with eyes (cameras / camcorders) and brains (algorithms) to replace human eyes in identifying, tracking, and measuring targets, so that computers can perceive the environment. Because perception can be seen as extracting information from sensory signals, computer vision can also be seen as a science that studies how to make artificial systems "perceive" from images or multidimensional data. In general, computer vision uses various imaging systems to replace visual organs to obtain input information, and then computers replace the brain to complete the processing and interpretation of these input information. The ultimate research goal of computer vision is to enable computers to observe and understand the world through vision like humans, and have the ability to adapt to the environment autonomously.

[0003] Recognition technology is one of the classic problems in computer vision. For example, pedestrian re-identification technology can be a technology that uses computer vision technology to determine whether a specific pedestrian exists in an image or video sequence. For example, given a pedestrian image, pedestrian re-identification technology can be used to retrieve the image of the pedestrian across devices and generate the pedestrian's behavior trajectory. Therefore, recognition technology can be widely used in intelligent video surveillance, intelligent security and other fields.

[0004] At present, the recognition technology is mainly based on the global feature map of the input image for classification. The global feature map includes the feature map of the target area to be identified and the feature map of the background area. Since the feature map of the target area to be identified is easily affected by the noise of the background area feature map during classification, the accuracy of the target area classification result is reduced. Therefore, how to improve the accuracy of the target area classification result has become an urgent problem to be solved. Summary of the invention

[0005] The present application provides an image classification method and device, which can separate the target area features from the background area features in the image to be processed, and improve the accuracy of the target area classification result by suppressing the influence of background area noise on the target area feature map.

[0006] In a first aspect, an image classification method is provided, comprising: obtaining an image to be processed, the image to be processed comprising a target area to be identified and a background area; classifying the image to be processed according to a target neural network to obtain a classification result of the target area and a classification result of the background area of ​​the image to be processed;

[0007] Among them, the target neural network is trained based on the target area classification loss function, the background area classification loss function and the collaborative loss function. The target area classification loss function is used to represent the loss value between the predicted classification result corresponding to the target area feature map of the sample image and the target area annotation classification result. The background area classification loss function is used to represent the loss value between the predicted classification result corresponding to the background area feature map of the sample image and the background area annotation classification result. The collaborative loss function is used to separate the target area feature map of the sample image from the background area feature map of the sample image.

[0008] The target area to be identified may be regarded as a foreground area including a target object. The target object may be an object with motion properties, or the target object may be other objects.

[0009] For example, the target area may refer to an area where any one of pedestrians, animals, and vehicles are located, that is, the target area may be any one of human images, animal images, and vehicle images.

[0010] Exemplarily, when the target area in the image to be processed is a portrait, the classification result of the target area may refer to the identification of the pedestrian, where the identification of the pedestrian may refer to the name of the pedestrian, the number of the pedestrian, or the ID number of the pedestrian; the classification result of the background area may refer to the identification of the camera that acquired the image to be processed, such as the number of the camera and the location information of the camera.

[0011] It should be noted that the above is an example of pedestrian identification and camera identification. The pedestrian identification is used to distinguish different behaviors. For the same camera, it can be approximately regarded as the background area image it obtains remains unchanged, that is, the classification result of the background area image can be determined by the camera identification. The specific implementation form of the pedestrian identification and the camera identification is not limited in this application. In the present application, the target neural network is obtained by training the target area classification loss function, the background area loss function and the collaborative loss function, so that the pre-trained target neural network can accurately separate the target area feature map and the background area feature map in the image to be processed. Therefore, when the target neural network classifies the image to be processed, by separating the target area feature map and the background area feature map in the image to be processed, it can not only obtain the classification result of the target area and the classification result of the background area, but also avoid the influence of the background area when obtaining the feature map of the target area, thereby improving the accuracy of the classification result of the target area in the image to be processed.

[0012] In a possible implementation, the image to be processed may refer to an image captured by a camera of the electronic device, or the image to be processed may also be an image obtained from inside the electronic device (for example, an image stored in an album of the electronic device, or an image obtained by the electronic device from the cloud). For example, the image to be processed may be an image in the acquired monitoring data.

[0013] In a possible implementation, the target area mask and the background area mask of the sample image can be made complementary through the collaborative loss function.

[0014] For example, when the value range of the mask is [0,1], the sum of the target area mask and the background area mask can be 1, that is, the background area mask = 1-target area mask. The target area mask is used to represent the probability value of each pixel point in the target area feature map belonging to the target area; the background area mask is used to represent the probability value of each pixel point in the background area feature map belonging to the background area.

[0015] In another possible implementation, the above-mentioned collaborative loss function can make the overlapping area of ​​the target area image corresponding to the target area feature map in the sample image and the background area image corresponding to the background area feature map in the sample image almost zero, that is, the collaborative loss function can make the boundary between the target area feature map and the background area feature map extracted by the target neural network in the sample image clear, thereby avoiding the influence of the background area noise on the target area feature map.

[0016] In combination with the first aspect, in certain implementations of the first aspect, the collaborative loss function is obtained by weighted processing of a first collaborative loss function and a second collaborative loss function, wherein the first collaborative loss function is obtained based on the multiplication of a target area feature map of the sample image and a background area mask of the sample image; and the second collaborative loss function is obtained based on the multiplication of a background area feature map of the sample image and a target area mask of the sample image.

[0017] In a possible implementation, the target region mask is obtained by training through the extracted target region feature map; and the background region mask is obtained by training through the extracted background region feature map.

[0018] The above target area mask is equivalent to the target area attention map; the above background area mask is equivalent to the background area attention map.

[0019] It should be noted that in the present application, the scales of any two of the target region feature map, the background region feature map, the target region mask and the background region mask of the image are the same.

[0020] In the present application, the first loss function obtained by multiplying the target area feature map with the corresponding pixel points in the background area mask can be used to represent the overlapping part of the extracted target area feature and the background area, that is, the range size of the target area feature map affected by the background area noise; the second loss function obtained by multiplying the background area feature map with the corresponding pixel points in the target area mask can be used to represent the overlapping part of the extracted background area feature map and the target area, that is, the range size of the background area feature map affected by the current area noise. The collaborative loss function is obtained by weighted processing of the first collaborative loss function and the second loss function, so that the target area features and the background area features are separated when training the target neural network, so that the accuracy of the target area feature map and the accuracy of the background area feature map can promote each other and improve synergistically.

[0021] In combination with the first aspect, in some implementations of the first aspect, the target neural network includes a first branch and a second branch, wherein the first branch is used to process the target area of ​​the sample image to obtain a target area feature map of the sample image and a target area mask of the sample image;

[0022] The second branch is used to process the background area of ​​the sample image to obtain a background area feature map of the sample image and a background area mask of the sample image.

[0023] In the present application, in order to facilitate the training of a neural network through a foreground area classification loss function, a background area classification loss function, and a collaborative loss function to obtain a target neural network for image classification. The target neural network may include two branches, the first branch may be used to process the target area of ​​the sample image, and the second branch may be used to process the background area of ​​the sample image. The collaborative loss function may be used to coordinate the training of the first branch and the second branch, so that the accuracy of the extracted target area feature map and the accuracy of the background area feature map promote each other and improve synergistically.

[0024] In combination with the first aspect, in some implementations of the first aspect, the collaborative loss function is obtained by the following equation:

[0025]

[0026] Among them, L t represents the collaborative loss function, N represents the number of pixels in the sample image, and F i represents the i-th pixel in the target area of ​​the sample image, represents the probability value of the i-th pixel in the target area mask of the sample image, and B i represents the i-th pixel in the background area of ​​the sample image, represents the probability value of the i-th pixel in the background area mask of the sample image, N is an integer greater than 1, and i is an integer greater than or equal to 1 and less than or equal to N.

[0027] In a possible implementation, the overall loss function includes the above classification loss function, the above background area classification loss function and the above collaborative loss function, and the overall loss function is obtained by the following equation:

[0028]

[0029] Among them, L f It can represent the target area classification loss function, L b It can represent the background area classification loss function, L t It can represent the collaborative loss function.

[0030] In combination with the first aspect, in certain implementations of the first aspect, the image to be processed is classified according to the target neural network to obtain a classification result of the target area of ​​the image to be processed and a classification result of the background area, including: processing the target area of ​​the image to be processed by the first branch of the target neural network to obtain an enhanced feature map of the target area of ​​the image to be processed, wherein the enhanced feature map of the target area is obtained by multiplying the target area feature map of the image to be processed and the target area mask of the image to be processed; processing the background area of ​​the image to be processed by the second branch of the target neural network to obtain an enhanced feature map of the background area of ​​the image to be processed, wherein the enhanced feature map of the background area is obtained by multiplying the background area feature map of the image to be processed and the background area mask of the image to be processed; classification is performed based on the enhanced feature map of the target area of ​​the image to be processed and the enhanced feature map of the background area to obtain the classification result of the target area of ​​the image to be processed and the classification result of the background area.

[0031] In combination with the first aspect, in some implementations of the first aspect, the classification result of the background area of ​​the image to be processed refers to an identifier of a camera that acquires the image to be processed.

[0032] It should be understood that the background area acquired by the same camera can be approximately regarded as unchanged, and the identification information corresponding to the background area image can be determined by the identification of the camera.

[0033] In a second aspect, a training method for an image classification model is provided, comprising: obtaining training data, wherein the training data comprises a sample image, a target area annotation classification result of the sample image, and a background area annotation classification result of the sample image; obtaining a target area prediction classification result of the sample image based on a target area feature map of the sample image extracted by a neural network; obtaining a background area prediction classification result of the sample image based on a background area feature map of the sample image extracted by the neural network; determining parameters of the neural network based on a target area classification loss function, a background area classification loss function, and a collaborative loss function, wherein the target area classification loss function is used to represent a loss value between a target area prediction classification result and a target area annotation classification result of the sample image, the background area classification loss function is used to represent a loss value between a background area prediction classification result and a background area annotation classification result of the sample image, and the collaborative loss function is used to separate the target area feature map of the sample image from the background area feature map of the sample image.

[0034] For example, the target area labeling classification result may refer to the labeling classification result of the area where the target object is located, and the target object may be an object with motion attributes, for example, the target object may be any one of pedestrians, animals, and vehicles, etc. Alternatively, the target object may also be other objects.

[0035] In a possible implementation, the target area prediction classification result of the sample image refers to an identifier of a camera that acquires the sample image.

[0036] Exemplarily, when the target area in the image to be processed is a portrait, the classification result of the target area may refer to the identification of the pedestrian, where the identification of the pedestrian may refer to the name of the pedestrian, the number of the pedestrian, or the ID number of the pedestrian; the classification result of the background area may refer to the identification of the camera that acquired the image to be processed, such as the number of the camera and the location information of the camera.

[0037] It should be noted that the above are examples of pedestrian identification and camera identification. The pedestrian identification is used to distinguish different behaviors. For the same camera, it can be approximately regarded as the background area image it obtains remains unchanged, that is, the classification result of the background area image can be determined by the camera identification. This application does not impose any limitation on the specific implementation form of the pedestrian identification and the camera identification.

[0038] In the present application, the segmentation accuracy of the target region feature map extracted by the target neural network and the feature map of the background region can be improved through the collaborative loss function, that is, the influence of the background region can be avoided when obtaining the feature map of the target region. That is, the parameters of the network are continuously adjusted through the overall training of the target region classification loss function, the background region loss function and the collaborative loss function, so that when the target neural network classifies the image to be processed, the accuracy of the extracted target region feature map and the accuracy of the background region feature map can promote each other and improve synergistically.

[0039] In a possible implementation, the target area mask and the background area mask of the sample image can be made complementary through the collaborative loss function.

[0040] For example, when the value range of the mask is [0,1], the sum of the target area mask and the background area mask can be 1, that is, the background area mask = 1-target area mask. The target area mask is used to represent the probability value of each pixel point in the target area feature map belonging to the target area; the background area mask is used to represent the probability value of each pixel point in the background area feature map belonging to the background area.

[0041] In another possible implementation, the above-mentioned collaborative loss function can make the overlapping area of ​​the target area image corresponding to the target area feature map in the sample image and the background area image corresponding to the background area feature map in the sample image almost zero, that is, the collaborative loss function can make the boundary between the target area feature map and the background area feature map extracted by the target neural network in the sample image clear, thereby avoiding the influence of the background area noise on the target area feature map.

[0042] In combination with the second aspect, in certain implementations of the second aspect, the collaborative loss function is obtained by weighted processing of a first collaborative loss function and a second collaborative loss function, wherein the first collaborative loss function is obtained based on the multiplication of a target area feature map of the sample image and a background area mask of the sample image; the second collaborative loss function is obtained based on the multiplication of a background area feature map of the sample image and a target area mask of the sample image.

[0043] In a possible implementation, the target region mask is obtained by training through the extracted target region feature map; and the background region mask is obtained by training through the extracted background region feature map.

[0044] The above target area mask is equivalent to the target area attention map; the above background area mask is equivalent to the background area attention map.

[0045] It should be noted that in the present application, the scales of any two of the target region feature map, the background region feature map, the target region mask and the background region mask of the image are the same.

[0046] In the present application, the first loss function obtained by multiplying the target area feature map with the corresponding pixel points in the background area mask can be used to represent the overlapping part of the extracted target area feature and the background area, that is, the range size of the target area feature map affected by the background area noise; the second loss function obtained by multiplying the background area feature map with the corresponding pixel points in the target area mask can be used to represent the overlapping part of the extracted background area feature map and the target area, that is, the range size of the background area feature map affected by the current area noise. The collaborative loss function is obtained by weighted processing of the first collaborative loss function and the second loss function, so that the target area features and the background area features are separated when training the target neural network, so that the accuracy of the target area feature map and the accuracy of the background area feature map can promote each other and improve synergistically.

[0047] In combination with the second aspect, in certain implementations of the second aspect, the neural network includes a first branch and a second branch, the first branch being used to process a target area of ​​the sample image to obtain a target area feature map of the sample image and a target area mask of the sample image; the second branch being used to process a background area of ​​the sample image to obtain a background area feature map of the sample image and a background area mask of the sample image.

[0048] In the present application, in order to facilitate the training of a neural network through a foreground area classification loss function, a background area classification loss function, and a collaborative loss function to obtain a target neural network for image classification. The target neural network may include two branches, the first branch may be used to process the target area of ​​the sample image, and the second branch may be used to process the background area of ​​the sample image. The collaborative loss function may be used to coordinate the training of the first branch and the second branch, so that the accuracy of the extracted target area feature map and the accuracy of the background area feature map promote each other and improve synergistically.

[0049] In a possible implementation, a target area prediction and classification result of the sample image is obtained based on a target area feature map of the sample image extracted by a neural network, including: processing the target area of ​​the sample image through the first branch of the target neural network to obtain an enhanced target area feature map of the sample image, wherein the enhanced target area feature map is obtained by multiplying the target area feature map of the sample image and a target area mask of the sample image; and obtaining a predicted classification result of the target area of ​​the sample image based on the enhanced target area feature map of the sample image.

[0050] In a possible implementation, obtaining a background region prediction classification result of the sample image according to the background region feature map of the sample image extracted by the neural network includes: processing the background region of the sample image by the second branch of the target neural network to obtain a background region enhancement feature map of the sample image, wherein the background region enhancement feature map is obtained by multiplying the background region feature map of the sample image by a background region mask of the sample image;

[0051] Based on the background region enhancement feature map of the sample image, a prediction classification result of the background region of the sample image is obtained.

[0052] In conjunction with the second aspect, in some implementations of the second aspect, the collaborative loss function is obtained by the following equation:

[0053]

[0054] Among them, L t represents the collaborative loss function, N represents the number of pixels in the sample image, and F i represents the i-th pixel in the target area of ​​the sample image, represents the probability value of the i-th pixel in the target area mask of the sample image, B i represents the i-th pixel in the background area of ​​the sample image, Represents the probability value of the i-th pixel in the background area mask of the sample image, where N is an integer greater than 1, and i is an integer greater than or equal to 1 and less than or equal to N.

[0055] In a possible implementation, the overall loss function includes the above classification loss function, the above background area classification loss function and the above collaborative loss function, and the overall loss function is obtained by the following equation:

[0056]

[0057] Among them, L f It can represent the target area classification loss function, L b It can represent the background area classification loss function, L t It can represent the collaborative loss function.

[0058] In a third aspect, an image classification method is provided, comprising: obtaining an image to be processed, the image to be processed comprising a target area to be identified and a background area; performing feature extraction on the image to be processed through a target neural network to obtain a feature map of the target area and a feature map of the background area; classifying the feature map of the target area and the feature map of the background area through the target neural network to obtain a classification result of the target area and a classification result of the background area;

[0059] Among them, the target neural network is trained based on the target area classification loss function, the background area classification loss function and the collaborative loss function. The target area classification loss function is used to represent the loss value between the predicted classification result corresponding to the target area feature map of the sample image and the target area annotation classification result. The background area classification loss function is used to represent the loss value between the predicted classification result corresponding to the background area feature map of the sample image and the background area annotation classification result. The collaborative loss function is used to separate the target area feature map of the sample image from the background area feature map of the sample image.

[0060] In the present application, the target neural network is trained by the target area classification loss function, the background area loss function and the collaborative loss function, so that the pre-trained target neural network can accurately separate the feature map of the target area and the feature map of the background area in the image to be processed. Therefore, when the target neural network classifies the image to be processed, by separating the feature map of the target area and the feature map of the background area in the image to be processed, it can not only obtain the classification result of the target area and the classification result of the background area, but also avoid the influence of the background area when obtaining the feature map of the target area, thereby improving the accuracy of the classification result of the target area in the image to be processed.

[0061] In combination with the third aspect, in some implementations of the third aspect, the target neural network includes a first branch and a second branch, and the target neural network is used to extract features of the image to be processed to obtain the target area feature map and the background area feature map, including:

[0062] Performing feature extraction on the target region of the image to be processed by the first branch of the target neural network to obtain an enhanced feature map of the target region of the image to be processed, wherein the enhanced feature map of the target region is obtained by multiplying the feature map of the target region of the image to be processed and a mask of the target region of the image to be processed;

[0063] The second branch of the target neural network is used to perform feature extraction on the background area of ​​the image to be processed to obtain a background area enhanced feature map of the image to be processed, wherein the background area enhanced feature map is obtained by multiplying the background area feature map of the image to be processed and the background area mask of the image to be processed.

[0064] In combination with the third aspect, in some implementations of the third aspect, the target region feature map and the background region feature map are classified by the target neural network to obtain a classification result of the target region and a classification result of the background region, including:

[0065] Classification is performed based on the target region enhancement feature map and the background region enhancement feature map of the image to be processed to obtain a classification result of the target region and a classification result of the background region of the image to be processed.

[0066] It should be noted that the first branch and the second branch in the above-mentioned target neural network can classify the image to be processed at the same time, or the target neural network can classify the image to be processed in the order of the first branch first and the second branch, or the target neural network can classify the image to be processed in the order of the second branch first and the first branch.

[0067] In combination with the third aspect, in certain implementations of the third aspect, the classification result of the background area of ​​the image to be processed refers to the identifier of the camera that acquired the image to be processed.

[0068] In combination with the third aspect, in certain implementations of the third aspect, the collaborative loss function is obtained by weighted processing of a first collaborative loss function and a second collaborative loss function, wherein the first collaborative loss function is based on the multiplication of a target area feature map of the sample image and a background area mask of the sample image; the second collaborative loss function is based on the multiplication of a background area feature map of the sample image and a target area mask of the sample image.

[0069] In combination with the third aspect, in certain implementations of the third aspect, the target neural network includes a first branch and a second branch, wherein the first branch is used to process the target area of ​​the sample image to obtain a target area feature map of the sample image and a target area mask of the sample image; the second branch is used to process the background area of ​​the sample image to obtain a background area feature map of the sample image and a background area mask of the sample image.

[0070] In conjunction with the third aspect, in certain implementations of the third aspect, the collaborative loss function is obtained by the following equation:

[0071]

[0072] Among them, L t represents the collaborative loss function, N represents the number of pixels in the sample image, and F i represents the i-th pixel in the target area of ​​the sample image, represents the probability value of the i-th pixel in the target area mask of the sample image, B i represents the i-th pixel in the background area of ​​the sample image, represents the probability value of the i-th pixel in the background area mask of the sample image, N is an integer greater than 1, and i is an integer greater than or equal to 1 and less than or equal to N.

[0073] In a possible implementation, the overall loss function includes the above classification loss function, the above background area classification loss function and the above collaborative loss function, and the overall loss function is obtained by the following equation:

[0074]

[0075] Among them, L f It can represent the target area classification loss function, L b It can represent the background area classification loss function, L t It can represent the collaborative loss function.

[0076] In combination with the third aspect, in certain implementations of the third aspect, the classification result of the background area of ​​the image to be processed refers to the identifier of the camera that acquired the image to be processed.

[0077] In a fourth aspect, an image classification device is provided, comprising: an acquisition unit, configured to acquire an image to be processed, the image to be processed comprising a target area to be identified and a background area; a processing unit, configured to classify the image to be processed according to a target neural network, and obtain a classification result of the target area and a classification result of the background area of ​​the image to be processed;

[0078] Among them, the target neural network is trained based on the target area classification loss function, the background area classification loss function and the collaborative loss function. The target area classification loss function is used to represent the loss value between the predicted classification result corresponding to the target area feature map of the sample image and the target area annotation classification result. The background area classification loss function is used to represent the loss value between the predicted classification result corresponding to the background area feature map of the sample image and the background area annotation classification result. The collaborative loss function is used to separate the target area feature map of the sample image from the background area feature map of the sample image.

[0079] In a possible implementation manner, the image classification device includes a functional unit / module further configured to execute the method in the first aspect and any one of the implementation manners of the first aspect.

[0080] It should be understood that the expansion, limitation, explanation and description of the relevant contents in the above-mentioned first aspect also apply to the same contents in the fourth aspect.

[0081] In a fifth aspect, a training device for an image classification model is provided, comprising: an acquisition unit, used to acquire training data, wherein the training data comprises a sample image, a target region annotation classification result of the sample image, and a background region annotation classification result of the sample image; a processing unit, used to obtain a target region prediction classification result of the sample image according to a target region feature map of the sample image extracted by a neural network; obtain a background region prediction classification result of the sample image according to a background region feature map of the sample image extracted by the neural network; and determine the parameters of the neural network based on a target region classification loss function, a background region classification loss function, and a collaborative loss function;

[0082] Among them, the target area classification loss function is used to represent the loss value between the target area prediction classification result and the target area annotation classification result of the sample image, the background area classification loss function is used to represent the loss value between the background area prediction classification result and the background area annotation classification result of the sample image, and the collaborative loss function is used to separate the target area feature map of the sample image and the background area feature map of the sample image.

[0083] In a possible implementation manner, the training device includes a functional unit / module that is also used to execute the training method in the second aspect and any one of the implementation manners of the second aspect.

[0084] It should be understood that the expansion, limitation, explanation and description of the relevant contents in the above-mentioned second aspect also apply to the same contents in the fifth aspect.

[0085] In a sixth aspect, an image classification device is provided, comprising: an acquisition unit, configured to acquire an image to be processed, wherein the image to be processed includes a target area to be identified and a background area; a processing unit, configured to perform feature extraction on the image to be processed through a target neural network to obtain a feature map of the target area and a feature map of the background area; and classify the feature map of the target area and the feature map of the background area through the target neural network to obtain a classification result of the target area and a classification result of the background area.

[0086] Among them, the target neural network is trained based on the target area classification loss function, the background area classification loss function and the collaborative loss function. The target area classification loss function is used to represent the loss value between the predicted classification result corresponding to the target area feature map of the sample image and the target area annotation classification result. The background area classification loss function is used to represent the loss value between the predicted classification result corresponding to the background area feature map of the sample image and the background area annotation classification result. The collaborative loss function is used to separate the target area feature map of the sample image from the background area feature map of the sample image.

[0087] In a possible implementation, the training device includes a functional unit / module that is also used to execute the method in the third aspect and any one of the implementations of the third aspect.

[0088] It should be understood that the expansion, limitation, explanation and description of the relevant contents in the above-mentioned third aspect also apply to the same contents in the sixth aspect.

[0089] In a seventh aspect, an image classification device is provided, the device comprising: a memory for storing a program; a processor for executing the program stored in the memory, and when the program stored in the memory is executed, the processor is used to perform: obtaining an image to be processed, the image to be processed comprising a target area to be identified and a background area; classifying the image to be processed according to a target neural network to obtain a classification result of the target area and a classification result of the background area of ​​the image to be processed;

[0090] Among them, the target neural network is trained based on the target area classification loss function, the background area classification loss function and the collaborative loss function. The target area classification loss function is used to represent the loss value between the predicted classification result corresponding to the target area feature map of the sample image and the target area annotation classification result. The background area classification loss function is used to represent the loss value between the predicted classification result corresponding to the background area feature map of the sample image and the background area annotation classification result. The collaborative loss function is used to separate the target area feature map of the sample image from the background area feature map of the sample image.

[0091] In a possible implementation manner, the processor included in the above-mentioned image classification device is also used to execute the method in any implementation manner in the first aspect.

[0092] It should be understood that the expansion, limitation, explanation and description of the relevant contents in the above-mentioned first aspect also apply to the same contents in the seventh aspect.

[0093] In an eighth aspect, a training device for an image classification model is provided, the device comprising: a memory for storing a program; a processor for executing the program stored in the memory, and when the program stored in the memory is executed, the processor is used to execute: obtaining training data, wherein the training data comprises a sample image, a target area annotation classification result of the sample image, and a background area annotation classification result of the sample image; obtaining a target area prediction classification result of the sample image according to a target area feature map of the sample image extracted by a neural network; obtaining a background area prediction classification result of the sample image according to a background area feature map of the sample image extracted by the neural network; determining the parameters of the neural network based on a target area classification loss function, a background area classification loss function, and a collaborative loss function;

[0094] Among them, the target area classification loss function is used to represent the loss value between the target area prediction classification result and the target area annotation classification result of the sample image, the background area classification loss function is used to represent the loss value between the background area prediction classification result and the background area annotation classification result of the sample image, and the collaborative loss function is used to separate the target area feature map of the sample image and the background area feature map of the sample image.

[0095] In a possible implementation manner, the processor included in the above-mentioned training device is also used to execute the training method in any implementation manner of the second aspect.

[0096] It should be understood that the expansion, limitation, explanation and description of the relevant contents in the above-mentioned second aspect also apply to the same contents in the eighth aspect.

[0097] In a ninth aspect, an image classification device is provided, the device comprising: a memory for storing a program; a processor for executing the program stored in the memory, and when the program stored in the memory is executed, the processor is used to perform the following steps: obtaining an image to be processed, the image to be processed comprising a target area to be identified and a background area; performing feature extraction on the image to be processed through a target neural network to obtain a feature map of the target area and a feature map of the background area; classifying the feature map of the target area and the feature map of the background area through the target neural network to obtain a classification result of the target area and a classification result of the background area.

[0098] Among them, the target neural network is trained based on the target area classification loss function, the background area classification loss function and the collaborative loss function. The target area classification loss function is used to represent the loss value between the predicted classification result corresponding to the target area feature map of the sample image and the target area annotation classification result. The background area classification loss function is used to represent the loss value between the predicted classification result corresponding to the background area feature map of the sample image and the background area annotation classification result. The collaborative loss function is used to separate the target area feature map of the sample image from the background area feature map of the sample image.

[0099] In a possible implementation manner, the processor included in the above-mentioned image classification device is also used to execute the method in any implementation manner in the third aspect.

[0100] It should be understood that the expansion, limitation, explanation and description of the relevant contents in the above-mentioned third aspect also apply to the same contents in the ninth aspect.

[0101] In a tenth aspect, a computer-readable medium is provided, which stores a program code for execution by a device, wherein the program code includes a method for executing the above-mentioned first to third aspects and any one of the implementation methods of the first to third aspects.

[0102] In the eleventh aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the method in any one of the implementations of the first to third aspects and the first to third aspects.

[0103] In the twelfth aspect, a chip is provided, comprising a processor and a data interface, wherein the processor reads instructions stored in a memory through the data interface to execute the method in any one of the implementation methods of the first to third aspects and the first to third aspects.

[0104] Optionally, as an implementation method, the chip may also include a memory, in which instructions are stored, and the processor is used to execute the instructions stored in the memory. When the instructions are executed, the processor is used to execute the method in the above-mentioned first to third aspects and any one of the implementation methods of the first to third aspects. BRIEF DESCRIPTION OF THE DRAWINGS

[0105] Figure 1 This is a schematic diagram of an artificial intelligence main framework provided by an embodiment of the present application;

[0106] Figure 2 It is a schematic diagram of an application scenario provided by an embodiment of the present application;

[0107] Figure 3 It is a schematic diagram of an application scenario provided by an embodiment of the present application;

[0108] Figure 4 It is a schematic diagram of an application scenario provided by an embodiment of the present application;

[0109] Figure 5 It is a structural diagram of the system architecture provided by the embodiment of the present application;

[0110] Figure 6 It is a schematic diagram of a convolutional neural network structure provided in an embodiment of the present application;

[0111] Figure 7 It is a schematic diagram of a chip hardware structure provided in an embodiment of the present application;

[0112] Figure 8 It is a schematic diagram of a system architecture provided by an embodiment of the present application;

[0113] Fig. 9 is a schematic flow chart of an image classification method provided in an embodiment of the present application;

[0114] Fig.10 is a schematic flow chart of a training method for an image classification model provided in an embodiment of the present application;

[0115] Fig.11 is a schematic flow chart of a training method for an image classification model provided in an embodiment of the present application;

[0116] Fig.12 is a schematic diagram of a training method for an image classification model provided in an embodiment of the present application;

[0117] Fig.13 is a schematic block diagram of an image classification device provided in an embodiment of the present application;

[0118] Fig.14 is a schematic block diagram of a training device for an image classification model provided in an embodiment of the present application;

[0119] Fig.15 is a schematic block diagram of an image classification device provided in an embodiment of the present application;

[0120] Fig.16 It is a schematic block diagram of a training device for an image classification model provided in an embodiment of the present application. DETAILED DESCRIPTION

[0121] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0122] Figure 1 A schematic diagram of an artificial intelligence main framework is shown, which describes the overall workflow of the artificial intelligence system and is applicable to general artificial intelligence field requirements.

[0123] The above artificial intelligence theme framework 100 is elaborated in detail below from two dimensions: "intelligent information chain" (horizontal axis) and "information technology (IT) value chain" (vertical axis).

[0124] 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, data undergoes a condensed process of "data-information-knowledge-wisdom".

[0125] 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 system's industrial ecological process.

[0126] (1) Infrastructure 110

[0127] Infrastructure provides computing power support for artificial intelligence systems, enables communication with the outside world, and provides support through a basic platform.

[0128] The infrastructure can communicate with the outside world through sensors, and the computing power of the infrastructure can be provided by smart chips.

[0129] The smart chips here can be hardware acceleration chips such as central processing unit (CPU), neural-network processing unit (NPU), graphics processing unit (GPU), application specific integrated circuit (ASIC) and field programmable gate array (FPGA).

[0130] The basic platform of the infrastructure can include related platform guarantees and support such as distributed computing frameworks and networks, and can include cloud storage and computing, interconnected networks, etc.

[0131] For example, for infrastructure, data can be obtained through sensors and external communication, and then provided to the smart chips in the distributed computing system provided by the basic platform for calculation.

[0132] (2) Data 120

[0133] The data on the upper layer of the infrastructure is used to represent the data sources in the field of artificial intelligence. This 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.

[0134] (3) Data processing 130

[0135] The above data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making and other processing methods.

[0136] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.

[0137] 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.

[0138] Decision-making refers to the process of making decisions after intelligent information is reasoned, usually providing functions such as classification, sorting, and prediction.

[0139] (4) General ability 140

[0140] 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.

[0141] (5) Smart products and industry applications 150

[0142] 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 application. Its application areas mainly include: smart manufacturing, smart transportation, smart home, smart medical care, smart security, autonomous driving, safe cities, smart terminals, etc.

[0143] Application scenario 1: Smart security

[0144] In one embodiment, Figure 2 As shown, the image classification method of the embodiment of the present application can be applied to the field of security. For example, the images (or videos) collected by monitoring equipment in public places can be classified and processed by the target neural network to identify the information of pedestrians in the images, providing important clues for case detection.

[0145] For example, you can use a photo of a specific person and obtain his or her movement trajectory through surveillance video. Pedestrian re-identification technology uses the photo of a specific person to match the video segment in which the specific person appears in the surveillance video library. In this way, the trajectory of a specific person in each camera can be connected. Once this trajectory is connected, it will be of great help to the police in solving cases and investigating crimes. Specifically, based on the provided photo of a specific person, it is possible to retrieve the image of the pedestrian across devices and form the pedestrian's behavior trajectory given a surveillance pedestrian image, such as Figure 2 As shown, the behavior trajectory of the specific person in backgrounds 1 to 4 can be retrieved through the target neural network in the present application, wherein backgrounds 1 to 4 can be images acquired through different cameras.

[0146] Exemplarily, when the image classification method of the present application is applied in the security field, a specific person image (for example, a picture or photo of a suspect) is obtained, and the specific person image includes a specific portrait area and a street view area; the specific person image is classified according to a pre-trained target neural network to obtain a classification result of the specific portrait and a classification result of the street view area.

[0147] For example, a pre-trained target neural network can extract a portrait feature map and a street view feature map from an image of a specific person, and perform classification based on the portrait feature map and the street view feature map. For example, the portrait feature map is classified to obtain the identification of the specific person, and the street view feature map is classified to obtain the identification of the camera that acquired the street view. The location of the street view can be determined by the identification of the camera, and then the behavior trajectory of the specific person can be determined. For example, when the image classification method of the present application is applied in the field of security, the training data used to train the target neural network may include sample images of different persons in the public security system, identification of the persons, and identification of each camera that acquired the sample image.

[0148] It should be understood that for the same camera, the images of the background area of ​​the captured picture can be regarded as approximately the same, that is, the images of different background areas can be distinguished by the camera ID.

[0149] It should be noted that the target neural network applied to the field of intelligent security provided in the embodiment of the present application is also applicable to the following Figures 5 to 12The expansion, limitation, explanation and description of the target neural network related contents in the relevant embodiments will not be repeated here.

[0150] Application scenario 2: Intelligent search system

[0151] In one embodiment, Figure 3 As shown, by inputting a pedestrian photo (for example, a photo of a lost child) into the intelligent search system, the target neural network of the embodiment of the present application can realize real-time search for images matching the child's photo in all surveillance cameras, thereby realizing pedestrian recognition technology in public places with relatively high pedestrian density.

[0152] Exemplarily, when the image classification method of the present application is applied to an intelligent person searching system, an image of a specific person (for example, a picture or photo of a missing person) is obtained, and the image of the specific person includes a specific portrait area and a street view area; the image of the specific person is classified according to a pre-trained target neural network to obtain a classification result of the specific portrait and a classification result of the street view area.

[0153] For example, a pre-trained target neural network can be used to extract portrait feature maps and street view feature maps from images of specific persons, and classification can be performed based on the portrait feature maps and the street view feature maps. For example, the portrait identification can be obtained by classifying the portrait feature map, and the street view feature map can be classified to obtain the identification of the camera that acquired the street view. The location of the street view can be determined through the identification of the camera, and then the behavior trajectory of the lost person can be determined.

[0154] For example, when the image classification method of the present application is applied to an intelligent person-searching system, the training data used to train the target neural network may include sample images of missing persons, identification of the missing persons, and identification of each camera that acquired the sample images.

[0155] It should be understood that for the same camera, the images of the background area of ​​the captured picture can be regarded as approximately the same, that is, the images of different background areas can be distinguished by the camera ID.

[0156] It should be noted that the target neural network of the application intelligent search system provided in the embodiment of the present application is also applicable to the following Figures 5 to 12 The expansion, limitation, explanation and description of the target neural network related contents in the relevant embodiments will not be repeated here.

[0157] In one possible implementation, the intelligent search system may refer to searching for specific persons in crowded public areas, such as airports, stations, amusement parks and other public areas. The target neural network of the embodiment of the present application can quickly find and construct trajectories of lost children by calling the surveillance video library.

[0158] In one possible implementation, the intelligent person-searching system may also be applied in an intelligent home robot, where the pedestrian re-identification technology is implemented through a target neural network, thereby helping the intelligent home robot to better identify family members.

[0159] In a possible implementation, the intelligent search system can also be applied in unmanned supermarkets. For example, the target neural network of the embodiment of the present application can dynamically track the user's trajectory in real time based on the photos of the pedestrian's appearance, and convert the trajectory into information that the administrator can understand, so as to help the operator obtain effective customer trajectories and further explore the commercial value. For example, the user's interests can be understood through the behavior trajectory in order to optimize the user experience.

[0160] Application scenario three: Album classification

[0161] In one embodiment, Figure 4 As shown, the target neural network of the embodiment of the present application can be used to classify pictures, so as to label pictures of different categories (for example, pictures classified based on different users) to facilitate users to view and search. In addition, the classification labels of these pictures can also be provided to the album management system for classification management, saving users' management time, improving the efficiency of album management, and enhancing user experience.

[0162] For example, the target neural network of the embodiment of the present application can classify and label images of different users. For example, when the target neural network of the embodiment of the present application is applied in a smart terminal, the photo album in the smart terminal can be classified by person, that is, the photo including user A can be marked with the label of user A; the photo including user B can be marked with the label of user B, so as to realize the classification of the photo album based on different users.

[0163] Exemplarily, when the image classification method of the present application is applied to album classification, an image to be processed (for example, a picture or photo of user A) is obtained, and the image to be processed includes a portrait area and a street view area; the portrait is classified according to a pre-trained target neural network to obtain a classification result of the portrait and a classification result of the street view area.

[0164] For example, a pre-trained target neural network can be used to extract the portrait feature map and street view feature map of user A in the image to be processed, and classification is performed based on the portrait feature map and the street view feature map. For example, the portrait identification is obtained by classifying the portrait feature map, and the street view feature map is classified to obtain the identification of the camera that acquired the street view. Furthermore, images with the same portrait identification can be stored in the same album folder, thereby realizing album classification of pictures of different users.

[0165] For example, when the image classification method of the present application is applied to album classification, the training data used to train the target neural network may be sample images of different users, identifications of different users, and identifications of cameras that acquired the sample images.

[0166] It should be understood that for the same camera, the images of the background area of ​​the captured picture can be regarded as approximately the same, that is, the images of different background areas can be distinguished by the camera ID.

[0167] It should be noted that the target neural network for application album classification provided in the embodiment of the present application is also applicable to the following Figures 5 to 12 The expansion, limitation, explanation and description of the target neural network related contents in the relevant embodiments will not be repeated here.

[0168] It should be understood that the above is an example of an application scenario and does not limit the application scenario of the present application.

[0169] 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 concepts of the neural networks that may be involved in the embodiments of the present application are first introduced below.

[0170] (1) Neural Network

[0171] A neural network can be composed of neural units. A neural unit can be a s The output of the operation unit with the intercept 1 as input can be:

[0172]

[0173] Where, s = 1, 2, ... n, n is a natural number greater than 1, W s For x s , 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 convolutional layer, and the activation function can be a sigmoid function. A neural network is a network formed by connecting multiple single neural units mentioned above, 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 features of the local receptive field. The local receptive field can be an area composed of several neural units.

[0174] (2) Deep Neural Networks

[0175] A deep neural network (DNN), also known as a multi-layer neural network, can be understood as a neural network with multiple hidden layers. According to the position of different layers, the neural network inside the DNN can be divided into three categories: input layer, hidden layer, and output layer. Generally speaking, the first layer is the input layer, the last layer is the output layer, and the layers in between are all hidden layers. The layers are fully connected, that is, any neuron in the i-th layer must be connected to any neuron in the i+1-th layer.

[0176] Although DNN looks complicated, the work of each layer is not complicated. In simple terms, it can be expressed as the following linear relationship: in, is the input vector, is the output vector, is the offset vector, W is the weight matrix (also called coefficient), and α() is the activation function. Each layer is just an input vector After such a simple operation, the output vector Since DNN has many layers, the coefficient W and the offset vector The number of these parameters is also relatively large. The definitions of these parameters in DNN are as follows: Take the coefficient W as an example: Assume that in a three-layer DNN, the linear coefficient from the 4th neuron in the second layer to the 2nd neuron in the third layer is defined as The superscript 3 represents the layer number of the coefficient W, while the subscripts correspond to the third layer index 2 of the output and the second layer index 4 of the input.

[0177] In summary, the coefficients from the kth neuron in the L-1th layer to the jth neuron in the Lth layer are defined as

[0178] It should be noted that the input layer does not have a W parameter. In a deep neural network, more hidden layers allow the network to better describe complex situations in the real world. Theoretically, the more parameters a model has, the higher its complexity and the greater its "capacity", which means it can complete more complex learning tasks. Training a deep neural network is the process of learning the weight matrix, and its ultimate goal is to obtain the weight matrix of all layers of the trained deep neural network (the weight matrix formed by many layers of vector W).

[0179] (3) Convolutional Neural Network

[0180] Convolutional neural network (CNN) is a deep neural network with a convolutional structure. Convolutional neural network contains a feature extractor consisting of a convolution layer and a subsampling layer, which can be regarded as a filter. Convolutional layer refers to the neuron layer in the convolutional neural network that performs convolution processing on the input signal. In the convolutional layer of the convolutional neural network, a neuron can only be connected to some neurons in the adjacent layers. A convolutional layer usually contains several feature planes, each of which can be composed of some rectangularly arranged neural units. The neural units in the same feature plane share weights, and the shared weights here are convolution kernels. Shared weights can be understood as the way to extract image information is independent of position. The convolution kernel can be initialized in the form of a matrix of random size, and the convolution kernel can obtain reasonable weights through learning during the training process of the convolutional neural network. In addition, the direct benefit of shared weights is to reduce the connection between the layers of the convolutional neural network, while reducing the risk of overfitting.

[0181] (4) Loss Function

[0182] In the process of training a deep neural network, because we hope that the output of the deep neural network is as close as possible to the value we really want to predict, we can compare the predicted value of the current network with the target value we really want, and then update the weight vector of each layer of the neural network according to 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 deep neural network). For example, if the predicted value of the network is high, adjust the weight vector to make it predict a lower value, and keep adjusting until the deep neural network can predict the target value we really want or a value very close to the target value we really want. Therefore, it is necessary to pre-define "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 deep neural network becomes a process of minimizing this loss as much as possible.

[0183] (5) Back propagation algorithm

[0184] 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.

[0185] Figure 5 A system architecture 200 provided by an embodiment of the present application is shown.

[0186] exist Figure 5 In the embodiment of the present application, the data acquisition device 260 is used to collect training data. For the image classification method of the present application, the neural network for image classification can be further trained by the training image, that is, the training data collected by the data acquisition device 260 can be the training image.

[0187] For example, in an embodiment of the present application, the training data for training the target neural network may include sample images, pedestrian identification included in the sample images, and background identification included in the sample images, wherein, for example, the pedestrian identification may be the pedestrian's ID, the pedestrian's identification card information, etc.; the background identification may be the identification information of the camera corresponding to the image to be processed, for example, it may be the ID information of the camera that obtains the image to be processed.

[0188] It should be understood that, for the same camera, the information of the background area of ​​the captured image may be unchanged, that is, the information of different background areas may be distinguished by the camera ID.

[0189] After collecting the training data, the data collection device 260 stores the training data in the database 230 , and the training device 220 obtains the target model / rule 201 through training based on the training data maintained in the database 230 .

[0190] The following describes how the training device 220 obtains the target model / rule 201 based on the training data. The training device 220 processes the input original image and compares the output image with the original image until the difference between the image output by the training device 220 and the original image is less than a certain threshold, thereby completing the training of the target model / rule 201.

[0191] For example, the target neural network for image classification provided in the present application can be trained by a classification loss function between the predicted classification result of a sample image and the sample classification result. The trained neural network makes the difference between the predicted classification result obtained by inputting the sample image into the target neural network and the sample classification result less than a certain threshold, thereby completing the training of the neural network and obtaining the parameters of the target neural network.

[0192] The above target model / rule 201 can be used to implement the image classification method of the embodiment of the present application. The target model / rule 201 in the embodiment of the present application can specifically be a neural network.

[0193] It should be noted that, in actual applications, the training data maintained in the database 230 may not all come from the data acquisition device 260, but may also be received from other devices. It should also be noted that the training device 220 may not train the target model / rule 201 entirely based on the training data maintained by the database 230, but may also obtain training data from the cloud or other places for model training. The above description should not be used as a limitation on the embodiments of the present application.

[0194] The target model / rule 201 trained by the training device 220 can be applied to different systems or devices, such as Figure 5 The execution device 210 shown in the figure may be a terminal, such as a mobile phone terminal, a tablet computer, a laptop computer, an augmented reality (AR) / virtual reality (VR), a vehicle terminal, etc., or a server, or a cloud, etc. Figure 5 In the embodiment, the execution device 210 is configured with an input / output (I / O) interface 212 for data interaction with an external device. A user may input data to the I / O interface 212 through a client device 240. The input data may include an image to be processed input by the client device in the embodiment of the present application.

[0195] Preprocessing module 213 and preprocessing module 214 are used to perform preprocessing according to the input data (such as the image to be processed) received by I / O interface 212. In the embodiment of the present application, preprocessing module 213 and preprocessing module 214 may be omitted (or only one of the preprocessing modules may be present), and the computing module 211 may be used directly to process the input data.

[0196] When the execution device 210 preprocesses the input data, or when the computing module 211 of the execution device 210 performs calculations and other related processing, the execution device 210 can call the data, code, etc. in the data storage system 250 for corresponding processing, and can also store the data, instructions, etc. obtained from the corresponding processing into the data storage system 250.

[0197] Finally, the I / O interface 212 returns the processing result, such as the classification result of the target area to be identified and the classification result of the background area in the image to be processed, to the client device 240 to provide it to the user.

[0198] It is worth noting that the training device 220 can generate corresponding target models / rules 201 based on different training data for different goals or different tasks. The corresponding target models / rules 201 can be used to achieve the above goals or complete the above tasks, thereby providing users with the desired results.

[0199] exist Figure 5 In the case shown in FIG. 2 , in one case, the user can manually provide input data, and the manual provision can be operated through the interface provided by the I / O interface 212 .

[0200] In another case, the client device 240 can automatically send input data to the I / O interface 212. If the client device 240 needs to obtain the user's authorization to automatically send the input data, the user can set the corresponding permissions in the client device 240. The user can view the results output by the execution device 210 in the client device 240, and the specific presentation form can be a specific method such as display, sound, action, etc. The client device 240 can also be used as a data acquisition terminal to collect the input data of the input I / O interface 212 and the output results of the output I / O interface 212 as shown in the figure as new sample data, and store them in the database 230. Of course, it is also possible not to collect through the client device 240, but the I / O interface 212 directly stores the input data of the input I / O interface 212 and the output results of the output I / O interface 212 as new sample data in the database 230.

[0201] It is worth noting that Figure 5 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 5 In the embodiment, the data storage system 250 is an external memory relative to the execution device 210. In other cases, the data storage system 250 can also be placed in the execution device 210.

[0202] like Figure 5As shown, the target model / rule 201 is obtained by training according to the training device 220. The target model / rule 201 in the embodiment of the present application may be the target neural network for image classification in the present application. Specifically, the target neural network provided in the embodiment of the present application may be a convolutional neural network (CNN), or a deep convolutional neural network (DCNN), etc.

[0203] Combine the following Figure 6 The focus is on a detailed introduction to the structure of the convolutional neural network. As mentioned in the basic concept introduction above, a convolutional neural network is a deep neural network with a convolutional structure and a deep learning architecture. A deep learning architecture refers to multiple levels of learning at different levels of abstraction through machine learning algorithms. As a deep learning architecture, a convolutional neural network is a feed-forward artificial neural network in which each neuron can respond to the image input into it.

[0204] The structure of the neural network used for image classification in the embodiment of the present application can be as follows: Figure 6 As shown. Figure 6 In the example, the convolutional neural network 300 may include an input layer 310, a convolutional layer / pooling layer 320 (wherein the pooling layer is optional), and a neural network layer 330. The input layer 310 may obtain an image to be processed, and the obtained image to be processed is passed to the convolutional layer / pooling layer 320 and the subsequent neural network layer 330 for processing, and the image processing result may be obtained. Figure 6 The internal layer structure of CNN 300 is introduced in detail.

[0205] Convolutional layer / pooling layer 320:

[0206] like Figure 6 The shown convolution layer / pooling layer 320 may include layers 321-326 as shown in Examples. For example: in one implementation, layer 321 is a convolution layer, layer 322 is a pooling layer, layer 323 is a convolution layer, layer 324 is a pooling layer, layer 325 is a convolution layer, and layer 326 is a pooling layer; in another implementation, layers 321 and 322 are convolution layers, layer 323 is a pooling layer, layers 324 and 325 are convolution layers, and layer 326 is a pooling layer, that is, the output of a convolution layer can be used as the input of a subsequent pooling layer, or as the input of another convolution layer to continue the convolution operation.

[0207] The following will take convolutional layer 321 as an example to introduce the internal working principle of a convolutional layer.

[0208] The convolution layer 321 may include a plurality of convolution operators, which are also called kernels. The convolution operator is equivalent to a filter that extracts specific information from the input image matrix in image processing. The convolution operator may be essentially a weight matrix, which is usually predefined. In the process of performing convolution operations on the image, the weight matrix is ​​usually processed one pixel after another (or two pixels after two pixels, etc., depending on the value of the stride) in the horizontal direction on the input image, thereby completing the work of extracting specific features from the image. The size of the weight matrix should be related to the size of the image. It should be noted that the depth dimension of the weight matrix is ​​the same as the depth dimension of the input image. In the process of performing convolution operations, the weight matrix will extend to the entire depth of the input image. Therefore, convolution with a single weight matrix will produce a convolution output with a single depth dimension, but in most cases, a single weight matrix is ​​not used, but multiple weight matrices of the same size (row × column), i.e., multiple isotype matrices, are applied. The output of each weight matrix is ​​stacked to form the depth dimension of the convolved image, and the dimension here can be understood as being determined by the "multiple" described above.

[0209] Different weight matrices can be used to extract different features in the image. For example, one weight matrix is ​​used to extract image edge information, another weight matrix is ​​used to extract specific colors of the image, and another weight matrix is ​​used to blur unnecessary noise points in the image. The multiple weight matrices have the same size (rows × columns), and the convolution feature maps extracted by the multiple weight matrices of the same size are also the same size. The extracted multiple convolution feature maps of the same size are then merged to form the output of the convolution operation.

[0210] The weight values ​​in these weight matrices need to be obtained through a lot of training in practical applications. The weight matrices formed by the weight values ​​obtained through training can be used to extract information from the input image, so that the convolutional neural network 300 can make correct predictions.

[0211] When the convolutional neural network 300 has multiple convolutional layers, the initial convolutional layer (for example, 321) often extracts more general features, which can also be called low-level features. As the depth of the convolutional neural network 300 increases, the features extracted by the later convolutional layers (for example, 326) become more and more complex, such as high-level semantic features. Features with higher semantics are more suitable for the problem to be solved.

[0212] Pooling layer:

[0213] Since it is often necessary to reduce the number of training parameters, it is often necessary to periodically introduce a pooling layer after the convolution layer. Figure 6The layers 321-326 illustrated in 320 may be a convolution layer followed by a pooling layer, or may be multiple convolution layers followed by one or more pooling layers. In the image processing process, the purpose of the pooling layer is to reduce the spatial size of the image. The pooling layer may include an average pooling operator and / or a maximum pooling operator for sampling the input image to obtain an image of smaller size. The average pooling operator may calculate the pixel values ​​in the image within a specific range to generate an average value as the result of average pooling. The maximum pooling operator may take the pixel with the largest value within a specific range as the result of maximum pooling. In addition, just as the size of the weight matrix used in the convolution layer should be related to the image size, the operator in the pooling layer should also be related to the image size. The size of the image output after processing by the pooling layer may be smaller than the size of the image input to the pooling layer, and each pixel in the image output by the pooling layer represents the average value or maximum value of the corresponding sub-region of the image input to the pooling layer.

[0214] Neural network layer 330:

[0215] After being processed by the convolution layer / pooling layer 320, the convolution neural network 300 is not sufficient to output the required output information. As mentioned above, the convolution layer / pooling layer 320 only extracts features and reduces the parameters brought by the input image. However, in order to generate the final output information (the required class information or other related information), the convolution neural network 300 needs to use the neural network layer 330 to generate one or a group of outputs of the required number of classes. Therefore, the neural network layer 330 may include multiple hidden layers (such as Figure 6 331, 332 to 33n) and the output layer 340 shown, the parameters contained in the multi-layer hidden layers can be pre-trained according to relevant training data of a specific task type. For example, the task type may include image recognition, image classification, image detection, and image super-resolution reconstruction, etc.

[0216] After the multiple hidden layers in the neural network layer 330, that is, the last layer of the entire convolutional neural network 300 is the output layer 340, which has a loss function similar to the classification cross entropy, specifically used to calculate the prediction error. Once the forward propagation of the entire convolutional neural network 300 (such as Figure 6 The propagation from 310 to 340 is forward propagation), and the reverse propagation (such as Figure 6 The propagation from 340 to 310 is called back propagation) and then starts to update the weight values ​​and biases of the aforementioned layers to reduce the loss of the convolutional neural network 300 and the error between the result output by the convolutional neural network 300 through the output layer and the ideal result.

[0217] It should be noted that Figure 6The convolutional neural network shown is only an example of the structure of the target neural network of an embodiment of the present application. In specific applications, the convolutional neural network adopted by the image classification method of the embodiment of the present application can also exist in the form of other network models.

[0218] Figure 7 The hardware structure of a chip provided in an embodiment of the present application includes a neural network processor 400 (neural-network processing unit, NPU). The chip can be set as follows Figure 4 The execution device 210 shown in FIG. 1 is used to complete the calculation work of the calculation module 211. The chip can also be set in Figure 4 The training device 220 shown in FIG. 2 is used to complete the training work of the training device 220 and output the target model / rule 201. Figure 6 The algorithms of each layer in the convolutional neural network shown in the figure can be used in Figure 7 is implemented in the chip shown.

[0219] The NPU 400 is mounted on the main central processing unit (CPU) as a coprocessor, and the main CPU assigns tasks. The core part of the NPU 400 is the operation circuit 403, and the controller 404 controls the operation circuit 403 to extract data from the memory (weight memory or input memory) and perform operations.

[0220] In some implementations, the operation circuit 403 includes multiple processing units (process engines, PEs) inside. In some implementations, the operation circuit 403 is a two-dimensional systolic array. The operation circuit 403 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 403 is a general-purpose matrix processor.

[0221] For example, assume there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit 403 takes the corresponding data of the matrix B from the weight memory 402 and caches it on each PE in the operation circuit 403. The operation circuit 403 takes the matrix A data from the input memory 401 and performs a matrix operation with the matrix B, and the partial result or the final result of the matrix is ​​stored in the accumulator 408 (accumulator).

[0222] The vector calculation unit 407 can further process the output of the operation circuit 403, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. For example, the vector calculation unit 407 can be used for network calculations of non-convolutional / non-FC layers in a neural network, such as pooling, batch normalization, local response normalization, etc.

[0223] In some implementations, the vector calculation unit 407 can store the processed output vector to the unified memory 406. For example, the vector calculation unit 407 can apply a nonlinear function to the output of the operation circuit 403, such as a vector of accumulated values, to generate an activation value. In some implementations, the vector calculation unit 407 generates a normalized value, a merged value, or both.

[0224] In some implementations, the vector of processed outputs can be used as activation input to the computational circuit 403, for example, for use in subsequent layers in a neural network.

[0225] The unified memory 406 is used to store input data and output data.

[0226] The weight data is directly stored in the input data in the external memory into the input memory 401 and / or the unified memory 406 through the direct memory access controller 405 (DMAC), the weight data in the external memory is stored in the weight memory 402, and the data in the unified memory 406 is stored in the external memory.

[0227] The bus interface unit 410 (BIU) is used to implement the interaction between the main CPU, DMAC and instruction fetch memory 409 through the bus.

[0228] An instruction fetch buffer 409 connected to the controller 404 is used to store instructions used by the controller 404 .

[0229] The controller 404 is used to call the instructions cached in the instruction fetch memory 409 to control the working process of the computing accelerator.

[0230] Generally, the unified memory 406, the input memory 401, the weight memory 402 and the instruction fetch memory 409 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 (DDR SDRAM), a high bandwidth memory (HBM) or other readable and writable memory.

[0231] in, Figure 6 The operations of each layer in the convolutional neural network shown can be performed by the operation circuit 403 or the vector calculation unit 407.

[0232] Introduced above Figure 4 The execution device 210 in the embodiment of the present application can execute each step of the image classification method. Figure 6 The CNN model shown and Figure 7 The chip shown can also be used to execute each step of the image classification method of the embodiment of the present application.

[0233] Figure 8 The embodiment of the present application provides a system architecture 500. The system architecture includes a local device 520, a local device 530, an execution device 510 and a data storage system 550, wherein the local device 520 and the local device 530 are connected to the execution device 510 via a communication network.

[0234] The execution device 510 can be implemented by one or more servers. Optionally, the execution device 510 can be used in conjunction with other computing devices, such as data storage devices, routers, load balancers, etc. The execution device 510 can be arranged at one physical site, or distributed at multiple physical sites. The execution device 510 can use the data in the data storage system 550, or call the program code in the data storage system 550 to implement the image classification method of the embodiment of the present application.

[0235] It should be noted that the above-mentioned execution device 510 can also be called a cloud device, and in this case the execution device 510 can be deployed in the cloud.

[0236] Users may operate respective user devices (e.g., local device 520 and local device 530) to interact with execution device 510. Each local device may represent any computing device, such as a personal computer, a computer workstation, a smart phone, a tablet computer, a smart camera, a smart car or other type of cellular phone, a media consumption device, a wearable device, a set-top box, a game console, etc.

[0237] The local device of each user can interact with the execution device 510 through a communication network of any communication mechanism / communication standard. The communication network can be a wide area network, a local area network, a point-to-point connection, etc., or any combination thereof.

[0238] In one implementation, the local device 520 and the local device 530 may obtain relevant parameters of the target neural network from the execution device 510, deploy the target neural network on the local device 520 and the local device 530, and use the target neural network to perform image classification processing, etc.

[0239] In another implementation, the target neural network can be directly deployed on the execution device 510, and the execution device 510 obtains the image to be processed from the local device 520 and the local device 530, and performs image classification processing on the image to be processed according to the target neural network.

[0240] For example, the above-mentioned target neural network can be the target neural network for image classification in the embodiments of the present application.

[0241] Image (or picture) classification is the basis of various image processing applications. Computer vision often involves the problem of how to classify the acquired images. However, the network model usually used for image classification is based on the global feature map of the image for classification. Since the target area to be identified may be part of the global feature map, the classification processing based on the global feature map will cause the feature map corresponding to the target area to be affected by the noise of the background area, thereby reducing the accuracy of the network model used for image classification.

[0242] An embodiment of the present application proposes an image classification method, which obtains a target neural network through training through a target area classification loss function, a background area classification loss function and a collaborative loss function, and can separate the feature map of the target area to be processed and the feature map of the background area in the image to be processed, and improve the accuracy of the classification result of the target area to be identified in the image to be processed by suppressing the influence of the noise of the background area on the feature map of the target area to be identified.

[0243] Fig. 9 A schematic flow chart of an image classification method 600 provided in an embodiment of the present application is shown. The method can be performed by a device capable of performing image classification. For example, the method can be performed by Figure 8 The execution device 510 in the embodiment may execute the method 600, or the local device 520 may execute the method 600. The method 600 includes steps 610 to 620, which are described in detail below.

[0244] S610: Acquire an image to be processed, where the image to be processed includes a target area to be identified and a background area.

[0245] For example, the image to be processed may refer to a foreground area and a background area containing a target object, and the target object may be any one of a pedestrian, an animal, and a vehicle.

[0246] It should be understood that the target area to be identified can be regarded as a foreground area containing a target object, and the target object can be an object with motion properties.

[0247] For example, the image to be processed may be an image captured by a camera of the electronic device, or the image to be processed may be an image obtained from the inside of the electronic device (for example, an image stored in an album of the electronic device, or a picture obtained by the electronic device from the cloud). Figure 8 Any of the local devices or execution devices shown.

[0248] S620. Classify the image to be processed according to the target neural network to obtain a classification result of the target area and a classification result of the background area; wherein the target area classification loss function is used to represent the loss value between the target area prediction classification result of the sample image and the target area annotation classification result, the background area classification loss function is used to represent the loss value between the background area prediction classification result of the sample image and the background area annotation classification result, and the collaborative loss function is used to separate the target area feature map of the sample image and the background area feature map of the sample image.

[0249] Specifically, the target area feature map (or background area feature map) of the sample image may be a feature map obtained after processing by other layers in the convolutional neural network. It should be understood that the other layers in the convolutional neural network mentioned here refer to a layer in the convolutional neural network, for example, the other layers may be one of the input layer, convolution layer, pooling layer or fully connected layer in the convolutional neural network.

[0250] Exemplarily, when the target area in the image to be processed is a portrait, the classification result of the target area may refer to the identification of the pedestrian, where the identification of the pedestrian may refer to the name of the pedestrian, the number of the pedestrian, or the ID number of the pedestrian; the classification result of the background area may refer to the identification of the camera that acquired the image to be processed, such as the number of the camera and the location information of the camera.

[0251] It should be noted that the above are examples of pedestrian identification and camera identification. The pedestrian identification is used to distinguish different behaviors. For the same camera, it can be approximately regarded as the background area image it obtains remains unchanged, that is, the classification result of the background area image can be determined by the camera identification. This application does not impose any limitation on the specific implementation form of the pedestrian identification and the camera identification.

[0252] For example, when the image to be processed input into the target neural network includes pedestrian A, the classification result of the output target area can be the identification information of pedestrian A, such as pedestrian A’s ID number or pedestrian A’s ID. The above identification information can be used to identify pedestrian A.

[0253] For example, when the image to be processed input to the target neural network includes a cat, the classification result of the output target area may be animal-cat.

[0254] For example, when the image to be processed input into the target neural network includes pedestrian A and street scene 1, the classification results of the target area and the classification results of the background area may refer to the identification information of pedestrian A and the identification information of camera A, wherein the identification information of pedestrian A is the ID number of pedestrian A or the ID of pedestrian A, and the above identification information can be used to identify pedestrian A; the identification information of camera A may be the ID of the camera corresponding to the street scene 1 area in the input image.

[0255] In a possible implementation, the target area mask and the background area mask of the sample image can be made complementary through the collaborative loss function.

[0256] For example, when the value range of the mask is [0,1], the sum of the target area mask and the background area mask is 1, that is, the background area mask = 1-target area mask. The target area mask is used to represent the probability value of each pixel point in the target area feature map belonging to the target area; the background area mask is used to represent the probability value of each pixel point in the background area feature map belonging to the background area.

[0257] For example, when the value range of the mask is [-1, 1], the sum of the target area mask and the background area mask is 0, that is, the background area mask = 0-target area mask.

[0258] It should be understood that the above examples are for illustrating that the target region mask and the background region mask are complementary, and do not impose any limitation on the value ranges of the target region mask and the background region mask.

[0259] In one possible implementation, the above-mentioned collaborative loss function can make the overlapping area of ​​the target area image corresponding to the target area feature map in the sample image and the background area image corresponding to the background area feature map in the sample image almost zero, that is, the collaborative loss function can make the boundary between the target area feature map and the background area feature map in the sample image extracted by the target neural network clear, thereby avoiding the influence of the background area noise on the target area feature map.

[0260] In an embodiment of the present application, the segmentation accuracy of the target area feature map extracted by the target neural network and the feature map of the background area can be improved through the collaborative loss function, that is, it is possible to avoid being affected by the background area when obtaining the feature map of the target area. In other words, the parameters of the network are continuously adjusted through the overall training of the target area classification loss function, the background area loss function and the collaborative loss function, so that when the target neural network classifies the image to be processed, the accuracy of the extracted target area feature map and the accuracy of the background area feature map can promote each other and improve synergistically.

[0261] Optionally, the collaborative loss function can be obtained by weighted processing of a first collaborative loss function and a second collaborative loss function, wherein the first collaborative loss function can be obtained by multiplying a target area feature map of the sample image by a background area mask of the sample image; the second collaborative loss function can be obtained by multiplying a background area feature map of the sample image by a target area mask of the sample image.

[0262] Among them, the background area mask of the sample image can represent the probability value of each pixel point in the background area feature map of the acquired sample image belonging to the background area of ​​the sample image; the target area mask of the sample image can represent the probability value of each pixel point in the target area feature map of the acquired sample image belonging to the target area of ​​the sample image.

[0263] For example, the value corresponding to each pixel in the target area mask represents the probability value that the position of the pixel belongs to the target area, and the probability value range may be [0,1]; 0 may represent that the probability that the position of the pixel belongs to the target area is 0; 1 may represent that the probability that the position of the pixel belongs to the target area is 1.

[0264] Similarly, the value corresponding to each pixel in the background area mask represents the probability value that the position of the pixel belongs to the background area, and the probability value range can be [0,1]; 0 can represent that the probability that the position of the pixel belongs to the background area is 0; 1 can represent that the probability that the position of the pixel belongs to the background area is 1.

[0265] The above target area mask is equivalent to the target area attention map; the above background area mask is equivalent to the background area attention map.

[0266] It should be noted that in the present application, the scales of any two of the target region feature map, the background region feature map, the target region mask and the background region mask of the image are the same.

[0267] For example, the synergy loss can be obtained by the following equation:

[0268]

[0269] Among them, L t represents the collaborative loss function, N represents the number of pixels in the sample image, and F i represents the i-th pixel in the target area of ​​the sample image, represents the probability value of the i-th pixel in the target area mask of the sample image, B i represents the i-th pixel in the background area of ​​the sample image, Represents the probability value of the i-th pixel in the background area mask of the sample image. ⊙ can be used to represent the multiplication of corresponding elements. N is an integer greater than 1, and i is an integer greater than or equal to 1 and less than or equal to N.

[0270] In an embodiment of the present application, in order to facilitate the training of a neural network through a foreground area classification loss function, a background area classification loss function, and a collaborative loss function to obtain a target neural network for image classification. When designing a neural network, two branches may be included, the first branch may be used to process the target area of ​​the sample image, and the second branch may be used to process the background area of ​​the sample image. The collaborative loss function may be used to coordinate the training of the first branch and the second branch, so that the accuracy of the extracted target area feature map and the accuracy of the background area feature map promote each other and improve synergistically.

[0271] Exemplarily, the target neural network may include a first branch and a second branch, wherein the first branch may be used to process a target area of ​​a sample image to obtain a target area feature map of the sample image and a target area mask of the sample image; and the second branch may be used to process a background area of ​​the sample image to obtain a background area feature map of the sample image and a background area mask of the sample image.

[0272] In a possible implementation, the target region mask is obtained by training through the extracted target region feature map; and the background region mask is obtained by training through the extracted background region feature map.

[0273] It should be noted that the above-mentioned target area classification loss function is used to represent the loss value between the predicted classification result corresponding to the target area feature map of the sample image and the target area annotation classification result, wherein the target area feature map of the sample image may also refer to the target area enhanced feature map of the sample image, such as the target area enhanced feature map is obtained by multiplying the extracted low-level feature map of the target area with the corresponding pixel points in the target area mask; similarly, the background area classification loss function is used to represent the loss value between the predicted classification result corresponding to the background area feature map of the sample image and the background area annotation classification result, wherein the background area feature map may also refer to the enhanced feature map of the background area, such as the background area enhanced feature map is obtained by multiplying the extracted low-level feature map of the background area with the corresponding pixel points in the background area mask.

[0274] In one possible implementation, in an embodiment of the present application, an image to be processed can be obtained, and the image to be processed includes a target area to be identified and a background area; feature extraction is performed on the image to be processed through a target neural network to obtain a feature map of the target area and a feature map of the background area; the target area feature map and the background area feature map are classified through the target neural network to obtain a classification result of the target area and a classification result of the background area.

[0275] Optionally, the target neural network may include a first branch and a second branch, the target area feature map may be a target area enhanced feature map, and the background area feature map may be a background area enhanced feature map; for example, the target area of ​​the image to be processed may be processed by the first branch of the target neural network to obtain a target area enhanced feature map of the image to be processed, wherein the target area enhanced feature map may be obtained by multiplying the extracted target area layer feature map with the corresponding pixel points in the target area mask; classification is performed based on the target area enhanced feature map to obtain a predicted classification result of the target area in the image to be processed.

[0276] Similarly, the background area of ​​the image to be processed can be processed by the second branch of the target neural network to obtain a background area enhanced feature map of the image to be processed, wherein the background area enhanced feature map can be obtained by multiplying the extracted background area feature map with the corresponding pixel points in the background area mask; classification is performed based on the background area enhanced feature map to obtain a predicted classification result of the background area in the image to be processed.

[0277] It should be noted that the first branch and the second branch in the target neural network can classify the image to be processed at the same time, or the target neural network can classify the image to be processed in the order of the first branch first and the second branch, or the target neural network can classify the image to be processed in the order of the second branch first and the first branch.

[0278] Furthermore, the target area classification loss function can be obtained by the deviation between the predicted classification result of the target area and the labeled classification result of the target area, and the background area classification loss function can be obtained by the deviation between the predicted classification result of the background area and the labeled classification result of the background area.

[0279] In the present application, the target neural network is trained by the target area classification loss function, the background area loss function and the collaborative loss function, so that the pre-trained target neural network can accurately separate the feature map of the target area and the feature map of the background area in the image to be processed. Therefore, when the target neural network classifies the image to be processed, by separating the feature map of the target area and the feature map of the background area in the image to be processed, it can not only obtain the classification result of the target area and the classification result of the background area, but also avoid the influence of the background area when obtaining the feature map of the target area, thereby improving the accuracy of the classification result of the target area in the image to be processed.

[0280] Fig.10 A schematic flow chart of a training method 700 for an image classification model provided in an embodiment of the present application is shown. The method can be performed by a device capable of performing image classification. For example, the method can be performed by Figure 8 The execution device 510 in the embodiment may execute the method 700, or the local device 520 may execute the method 700. The method 700 includes steps 710 to 740, which are described in detail below.

[0281] Step 710: Acquire training data, wherein the training data includes a sample image, a target region annotation classification result of the sample image, and a background region annotation classification result of the sample image.

[0282] For example, the target area is the area where the target object in the sample image is located, and the target object can be any one of pedestrians, animals, and vehicles.

[0283] Exemplarily, the training data may refer to a sample image containing pedestrian A, an identifier of pedestrian A, and an identifier of a background area image in the sample image, for example, the identifier of a camera that acquires the sample image.

[0284] It should be understood that the background area acquired by the same camera can be approximately regarded as unchanged, and the identification information corresponding to the background area image can be determined by the identification of the camera.

[0285] Step 720: Obtain a target region prediction classification result of the sample image based on the target region feature map of the sample image extracted by the neural network.

[0286] In a possible implementation, a convolution operation may be performed on the sample image to obtain low-level global features of the sample image; and a convolution operation may be performed on the low-level global features of the sample image to obtain a target area feature map of the sample image.

[0287] In another possible implementation, a convolution operation may be performed on the sample image to directly obtain a target region feature map of the sample image.

[0288] Furthermore, a target area mask may be obtained according to the extracted target area feature map.

[0289] For example, a fully convolutional network can be used to perform a convolution operation on the target area feature map to obtain a target area mask of the target area feature map, wherein the target area mask is used to represent the probability value of each pixel point in the target area feature map belonging to the target area. For example, the value range of the target area mask can be [0,1], where 0 can represent that the probability of the pixel point belonging to the target area is 0; and 1 can represent that the probability of the pixel point belonging to the target area is 1.

[0290] Optionally, obtaining a target region prediction classification result of the sample image according to the target region feature map of the sample image extracted by the neural network includes:

[0291] The target area of ​​the sample image can be processed by the target neural network to obtain an enhanced feature map of the target area of ​​the sample image, wherein the enhanced feature map of the target area can be obtained by multiplying the extracted low-level feature map of the target area with the corresponding pixel points in the target area mask; classification is performed based on the enhanced feature map of the target area to obtain a predicted classification result of the target area in the sample image.

[0292] For example, the above classification based on the enhanced feature map of the target area can be performed using the softmax algorithm in the prior art, which will not be described in detail here.

[0293] For example, for an input X, if we need to determine which category X belongs to among N categories, we assume that a model can output the scores of N categories for the input X. The higher the score, the greater the possibility that X belongs to this category, and the highest score is considered to be the correct category of X. However, such a score range is very wide, and the softmax algorithm can convert a set of scores (-∞, +∞) into a set of probabilities, and make the sum of these probabilities a normalized function of 1; in addition, this function is rank-preserving, that is, the original high score has a larger probability value after conversion, and the corresponding probability value of the small score is smaller.

[0294] Exemplarily, when the sample image includes pedestrian A, the classification result of the output target area may be identification information of pedestrian A, for example, the identification number of pedestrian A or the ID of pedestrian A. The above identification information may be used to identify pedestrian A.

[0295] For example, when the sample image includes a cat, the classification result of the output target area may be animal-cat.

[0296] Step 730: Obtain a background area prediction classification result of the sample image based on the background area feature map of the sample image extracted by the neural network.

[0297] In a possible implementation, a convolution operation may be performed on the sample image to obtain low-level global features of the sample image; and a convolution operation may be performed on the low-level global features of the sample image to obtain a background area feature map of the sample image.

[0298] In another possible implementation, a convolution operation may be performed on the sample image to directly obtain a background region feature map of the sample image.

[0299] Furthermore, a background area mask may be obtained according to the extracted target area feature map.

[0300] For example, a fully convolutional network can be used to perform a convolution operation on the background area feature map to obtain a background area mask corresponding to the background area, wherein the background area mask is used to represent the probability value of each pixel point in the background area feature map belonging to the background area. For example, the value range of the background area mask can be [0,1], where 0 can represent that the probability of the pixel point belonging to the background area is 0; and 1 can represent that the probability of the pixel point belonging to the background area is 1.

[0301] Optionally, obtaining a background area prediction classification result of the sample image according to the background area feature map of the sample image extracted by the neural network includes:

[0302] The background area of ​​the sample image can be processed by the target neural network to obtain a background area enhanced feature map of the sample image, wherein the background area enhanced feature map can be obtained by multiplying the extracted background area low-level feature map with the corresponding pixel points in the background area mask; classification is performed based on the background area enhanced feature map to obtain a predicted classification result of the background area in the sample image.

[0303] For example, the above classification based on the background area enhanced feature map can be performed using the softmax algorithm in the prior art, which will not be described in detail here.

[0304] For example, when the sample image includes pedestrian A and street scene 1, the classification result of the background area may refer to the identification information of camera A, and the identification information of camera A may be the ID of the camera corresponding to the street scene 1 area in the input image.

[0305] Optionally, the classification result of the background area of ​​the sample image refers to the identifier of a camera that acquires the sample image.

[0306] It should be understood that the background area acquired by the same camera can be approximately regarded as unchanged, and the identification information corresponding to the background area image can be determined by the identification of the camera.

[0307] Step 740: Determine the parameters of the neural network based on the target area classification loss function, the background area classification loss function and the collaborative loss function, wherein the target area classification loss function is used to represent the loss value between the target area prediction classification result and the target area annotation classification result of the sample image, the background area classification loss function is used to represent the loss value between the background area prediction classification result and the background area annotation classification result of the sample image, and the collaborative loss function is used to separate the target area feature map of the sample image and the background area feature map of the sample image.

[0308] In a possible implementation, the target area mask and the background area mask of the sample image can be made complementary through the collaborative loss function.

[0309] In one possible implementation, the above-mentioned collaborative loss function can make the overlapping area of ​​the target area image corresponding to the target area feature map in the sample image and the background area image corresponding to the background area feature map in the sample image almost zero, that is, the collaborative loss function can make the boundary between the target area feature map and the background area feature map in the sample image extracted by the target neural network clear, thereby avoiding the influence of the background area noise on the target area feature map.

[0310] Optionally, the collaborative loss function can be obtained by weighted processing of a first collaborative loss function and a second collaborative loss function, wherein the first collaborative loss function can be obtained by multiplying the target area feature map of the sample image with the corresponding pixel points in the background area mask of the sample image; the second collaborative loss function can be obtained by multiplying the background area feature map of the sample image with the corresponding pixel points in the target area mask of the sample image.

[0311] It should be noted that in the present application, the scales of any two of the target region feature map, the background region feature map, the target region mask and the background region mask of the image are the same.

[0312] For example, the collaborative loss function can be obtained by the following equation:

[0313]

[0314] Among them, L t represents the collaborative loss function, N represents the number of pixels in the sample image, and F i represents the i-th pixel in the target area of ​​the sample image, represents the probability value of the i-th pixel in the target area mask of the sample image, B i represents the i-th pixel in the background area of ​​the sample image, Represents the probability value of the i-th pixel in the background area mask of the sample image, ⊙ is used to represent the multiplication of corresponding elements, N is an integer greater than 1, and i is an integer greater than or equal to 1 and less than or equal to N.

[0315] For example, the final loss function obtained based on the target area classification loss function, the background area classification loss function and the collaborative loss function can be: Among them, L f It can represent the target area classification loss function, L b It can represent the background area classification loss function, L t It can represent the collaborative loss function.

[0316] In an embodiment of the present application, the segmentation accuracy of the target region feature map extracted by the target neural network and the feature map of the background region can be improved through the collaborative loss function, that is, the influence of the background region can be avoided when obtaining the feature map of the target region. In other words, the parameters of the network are continuously adjusted through the overall training of the target region classification loss, the background region loss and the collaborative loss, so that when the target neural network classifies the image to be processed, the accuracy of the extracted target region feature map and the accuracy of the background region feature map can promote each other and improve synergistically.

[0317] Optionally, the target neural network may include a first branch and a second branch, wherein the first branch can be used to process the target area of ​​the sample image to obtain a target area feature map of the sample image and a target area mask of the sample image; the second branch can be used to process the background area of ​​the sample image to obtain a background area feature map of the sample image and a background area mask of the sample image.

[0318] In an embodiment of the present application, in order to facilitate the training of a neural network through a foreground area classification loss function, a background area classification loss function, and a collaborative loss function to obtain a target neural network for image classification. When designing a neural network, two branches may be included, the first branch may be used to process the target area of ​​the sample image, and the second branch may be used to process the background area of ​​the sample image. The collaborative loss function may be used to coordinate the training of the first branch and the second branch, so that the accuracy of the extracted target area feature map and the accuracy of the background area feature map promote each other and improve synergistically.

[0319] For example, Fig.11 The figure is a schematic flow chart of a training method 800 for an image classification model provided in an embodiment of the present application. The method 800 includes steps 801 to 809, which are described in detail below.

[0320] Step 801: Input image.

[0321] The input image may be training data for training an image classification model, and the training data includes a sample image, a target area annotation classification result of the sample image, and a background area annotation classification result of the sample image.

[0322] For example, the target area is the area where the target object in the sample image is located, and the target object can be any one of pedestrians, animals, and vehicles.

[0323] Step 802: Extract low-level features.

[0324] For example, the low-level features of the input image can be extracted through a low-level feature extraction module, wherein the low-level feature extraction module can adopt a variety of architectures, such as VGG16, TSN network, etc.

[0325] Exemplarily, the low-level features of the input image mentioned above may refer to low-level texture features of the input image learned by the low-level feature extraction module.

[0326] Step 803: extract foreground area features.

[0327] For example, the foreground region features can be extracted by a foreground extraction module, and the foreground feature extraction module can be a multi-layer convolutional neural network. By inputting low-level features into the foreground feature extraction module, the output foreground region features can be obtained.

[0328] It should be noted that the foreground area feature mentioned above may refer to the area where the target object is located. For example, the target object may refer to pedestrians, animals, vehicles, etc.

[0329] Step 804: Generate a foreground attention mask.

[0330] For example, the foreground attention mask can be obtained by a foreground attention mask generation module, wherein the foreground attention mask generation module can be a fully convolutional neural network, which can include two convolution modules, and each convolution module can include three consecutive operations: a convolution layer, a batch normalization layer (bach normalization, BN), and a linear rectified unit (rectified linear unit, ReLU). The input of the foreground attention mask generation module is the foreground feature F, and the output is the foreground attention mask Z f .

[0331] It should be understood that the size of the foreground attention mask is consistent with the size of the foreground feature. The value corresponding to each position in the foreground attention mask represents the probability that the position belongs to the foreground area. The probability value can range from [0,1], where 0 represents that the probability that the position belongs to the foreground is 0, and 1 represents that the probability that the position belongs to the foreground is 1.

[0332] Step 805: Obtain foreground enhancement features

[0333] Among them, the foreground enhancement feature is obtained by the foreground attention mask Z f The foreground feature F is enhanced to suppress background noise.

[0334] For example, we can use the foreground attention mask Z f Multiply the foreground feature F pixel by pixel to obtain the enhanced foreground feature, where the foreground feature F and the foreground attention mask Z f The value of each position in the foreground attention mask represents the probability that it belongs to the foreground area.

[0335] Furthermore, the foreground enhancement features may be input into a foreground classifier for classification to obtain a predicted classification result of the foreground area.

[0336] For example, when the input image includes a pedestrian, the classification result is which pedestrian ID the input image belongs to.

[0337] Exemplarily, the pedestrian ID may refer to the pedestrian's name, the pedestrian's number, or the pedestrian's ID number, etc. The pedestrian ID may be used to distinguish different pedestrians.

[0338] Step 806: Extract background features.

[0339] For example, the background region features can be extracted by a background extraction module, and the background feature extraction module can be a multi-layer convolutional neural network. By inputting low-level features into the background feature extraction module, the output background region features can be obtained.

[0340] Step 807: Generate a background attention mask.

[0341] For example, the background attention mask can be obtained by a background attention mask generation module, wherein the background attention mask generation module can be a fully convolutional neural network, which can include two convolutional modules, each of which can include three consecutive operations: a convolutional layer, a batch normalization layer (bach normalization, BN), and a linear rectifier function (rectified linear unit, ReLU). The input of the background attention mask generation module is the background feature B, and the output is the background attention mask Z b .

[0342] It should be understood that the size of the background attention mask is consistent with the size of the background feature. The value corresponding to each position in the background attention mask represents the probability that the position belongs to the background area. The probability value can range from [0,1], where 0 represents the probability that the position belongs to the background is 0, and 1 represents the probability that the position belongs to the background is 1.

[0343] Step 808: Obtain background enhancement features

[0344] Among them, the foreground enhancement feature is obtained by the background attention mask Z b The background feature B is enhanced to suppress the foreground noise.

[0345] For example, we can use the background attention mask Z b Multiply the background feature B pixel by pixel to obtain the enhanced background feature, where the background feature B and the background attention mask Z b The value of each position in the background attention mask represents the probability that it belongs to the background area.

[0346] Furthermore, the background enhancement features may be input into a foreground classifier for classification to obtain a predicted classification result of the background area.

[0347] For example, the background area acquired by the same camera can be approximately regarded as unchanged, and the classification result corresponding to the background area image can be determined by the camera ID.

[0348] For example, the camera ID may refer to the camera number, the location information of the camera, etc.

[0349] Step 809: Collaborative training.

[0350] For example, the foreground feature map can be multiplied with the background attention mask correspondingly, and the background feature map can be multiplied with the foreground attention mask correspondingly to generate a co-training loss function.

[0351] In one embodiment, a training data may include an input image, a pedestrian ID corresponding to the input image, and a camera ID. The softmax loss function of the foreground branch can be obtained through the pedestrian ID, and the softmax loss function of the background branch can be obtained through the camera ID. The collaborative training loss function, the softmax loss function of the foreground branch, and the softmax loss function of the background branch are weighted to obtain the final loss function of the collaborative two-way network. The collaborative training loss function is minimized through the back-propagation algorithm to generate various parameter values ​​of the two-way network.

[0352] For example, the flowchart of the training method of the target neural network for image classification is as follows: Fig.12 As shown, in Fig.12 In the example, the input image is a pedestrian image. When the input image is a pedestrian image, the classification result of the foreground area outputted can be the ID of the pedestrian; the classification result of the background area can be the camera ID, that is, it can be the identification of the camera that obtains the input image.

[0353] like Fig.12 As shown, the process of the training method of the target neural network may include the following steps:

[0354] Step 1: input the training image into a feature extraction module (e.g., a low-level feature extraction module) to obtain a global feature map of the training image;

[0355] Step 2: Input the global feature map of the training image into the foreground feature extraction module and the background feature extraction module respectively to obtain the foreground feature map and the background feature map of the training image.

[0356] For example, the global feature map of the training image can be input into the foreground feature extraction module and the background feature extraction module respectively; or, the global feature map of the training image can be first input into the foreground feature extraction module, and then the global feature map of the training image can be input into the background feature extraction module.

[0357] It should be noted that the foreground feature extraction module and the background feature extraction module can process the feature map of the training image in parallel without limiting the order of input.

[0358] Step 3: Input the foreground feature map into the foreground attention mask generation module to generate the foreground attention mask;

[0359] Step 4: Input the background feature map into the background attention mask generation module to generate a background attention mask;

[0360] It should be noted that the above step 3 and step 4 may be executed simultaneously, or step 4 may be executed first and then step 3, and there is no limitation on the execution order of step 3 and step 4.

[0361] Step 5: Multiply the foreground feature map and the foreground attention mask pixel by pixel to generate an enhanced foreground feature map;

[0362] For example, the foreground region feature map is input into a target enhancement module (TEM) to obtain an enhanced foreground feature map.

[0363] Step 6: Multiply the background feature map and the background attention mask pixel by pixel to generate an enhanced background feature map;

[0364] For example, the background region feature map is input into a target enhancement module (TEM) to obtain an enhanced background feature map.

[0365] It should be understood that Fig.12 The TEM of the first branch and the TEM of the second branch can be two different modules. For example, the TEM of the first branch is used to enhance the feature map of the foreground area; and the TEM of the second branch is used to enhance the feature map of the background area.

[0366] It should be noted that the above step 5 and step 6 may be executed simultaneously, or step 5 may be executed first and then step 6, and there is no limitation on the execution order of step 5 and step 6.

[0367] Step 7: Downsample the enhanced foreground feature map and input it into the foreground classifier for classification, and the classified category is pedestrian ID;

[0368] Exemplarily, the pedestrian ID may refer to any one of the pedestrian's name, the pedestrian's serial number, or the pedestrian's ID number.

[0369] Step 8: Downsample the enhanced background feature map and input it into the background classifier for classification, and the classified category is the camera ID.

[0370] For example, the camera ID may refer to the camera number, or the location information of the camera.

[0371] It should be noted that the above is an example of pedestrian ID and camera ID. Pedestrian ID is used to distinguish different behaviors. For the same camera, it can be approximately regarded as the background area image it obtains remains unchanged, that is, the classification result of the background area image can be determined by the camera ID. This application does not impose any limitation on the specific implementation form of pedestrian ID and camera ID.

[0372] It should be understood that the above steps 7 and 8 may be performed simultaneously, or step 8 may be performed first and then step 7, and the execution order of step 7 and step 8 is not limited.

[0373] Step 9: Multiply the foreground feature map with the background attention mask correspondingly, and multiply the background feature map with the foreground attention mask correspondingly to generate the collaborative training Loss. Minimize the collaborative training Loss through the back propagation algorithm to generate the parameter values ​​of the dual-path network.

[0374] In the embodiments of the present application, Fig.12 The collaborative two-way network shown in the figure uses pedestrian ID and camera ID to supervise the collaborative two-way network training, so that the collaborative two-way network can extract pedestrian features and background features at the same time. By collaboratively training the two-way network, the accuracy of the foreground feature map, foreground attention mask, background feature map, and background attention mask can be collaboratively improved; at the same time, since the camera ID is used as supervision information, the network does not require additional labeled data sets when extracting attention masks.

[0375] It should be understood that the above examples are intended to help those skilled in the art understand the embodiments of the present application, rather than to limit the embodiments of the present application to the specific numerical values ​​or specific scenarios illustrated. Those skilled in the art can obviously make various equivalent modifications or changes based on the above examples, and such modifications or changes also fall within the scope of the embodiments of the present application.

[0376] Combination of the above Figures 1 to 12 , describes in detail the image classification method of the embodiment of the present application, and will now be combined with Fig.13 and Fig.16 , describes the device embodiment of the present application in detail. It should be understood that the image classification device in the embodiment of the present application can execute the various image classification methods in the aforementioned embodiment of the present application, that is, the specific working process of the following various products can refer to the corresponding process in the aforementioned method embodiment.

[0377] Fig.13 is a schematic block diagram of an image classification device provided in an embodiment of the present application. It should be understood that the image classification device 900 can execute Fig. 9 The image classification method shown in the figure. The image classification device 900 includes: an acquisition unit 910 and a processing unit 920.

[0378] The acquisition unit 910 is used to acquire an image to be processed, wherein the image to be processed includes a target area to be identified and a background area; the processing unit 920 is used to classify the image to be processed according to a target neural network to obtain a classification result of the target area and a classification result of the background area of ​​the image to be processed;

[0379] Among them, the target neural network is trained based on the target area classification loss function, the background area classification loss function and the collaborative loss function. The target area classification loss function is used to represent the loss value between the predicted classification result corresponding to the target area feature map of the sample image and the target area annotation classification result. The background area classification loss function is used to represent the loss value between the predicted classification result corresponding to the background area feature map of the sample image and the background area annotation classification result. The collaborative loss function is used to separate the target area feature map of the sample image from the background area feature map of the sample image.

[0380] Optionally, as an embodiment, the collaborative loss function is obtained by weighted processing of a first collaborative loss function and a second collaborative loss function, wherein the first collaborative loss function is obtained by multiplying a target area feature map of the sample image by corresponding pixel points in a background area mask of the sample image;

[0381] The second collaborative loss function is obtained by multiplying the background area feature map of the sample image by the corresponding pixel points in the target area mask of the sample image.

[0382] Optionally, as an embodiment, the target neural network includes a first branch and a second branch, wherein the first branch is used to process the target area of ​​the sample image to obtain a target area feature map of the sample image and a target area mask of the sample image;

[0383] The second branch is used to process the background area of ​​the sample image to obtain a background area feature map of the sample image and a background area mask of the sample image.

[0384] Optionally, as an embodiment, the collaborative loss function is obtained by the following equation:

[0385]

[0386] Among them, L t represents the collaborative loss function, N represents the number of pixels in the sample image, and F i represents the i-th pixel in the target area of ​​the sample image, represents the probability value of the i-th pixel in the target area mask of the sample image, B i represents the i-th pixel in the background area of ​​the sample image, represents the probability value of the i-th pixel in the background area mask of the sample image, ⊙ is used to represent the multiplication of corresponding elements, N is an integer greater than 1, and i is an integer greater than or equal to 1 and less than or equal to N.

[0387] Optionally, as an embodiment, the processing unit 920 is specifically configured to:

[0388] Processing the target area of ​​the image to be processed by the first branch of the target neural network to obtain an enhanced feature map of the target area of ​​the image to be processed, wherein the enhanced feature map of the target area is obtained by multiplying the target area feature map of the image to be processed and the target area mask of the image to be processed; Processing the background area of ​​the image to be processed by the second branch of the target neural network to obtain an enhanced feature map of the background area of ​​the image to be processed, wherein the enhanced feature map of the background area is obtained by multiplying the background area feature map of the image to be processed and the background area mask of the image to be processed;

[0389] Classification is performed based on the target region enhancement feature map and the background region enhancement feature map of the image to be processed to obtain a classification result of the target region and a classification result of the background region of the image to be processed.

[0390] Optionally, as an embodiment, the classification result of the background area of ​​the image to be processed refers to the identifier of a camera that acquires the image to be processed.

[0391] Fig.14 is a schematic block diagram of a training device for an image classification model provided in an embodiment of the present application. It should be understood that the training device 1000 can execute Fig.10 or Fig.11 The training method of the image classification model shown in FIG. 1 includes: an acquisition unit 1010 and a processing unit 1020 .

[0392] The acquisition unit 1010 is used to acquire training data, wherein the training data includes a sample image, a target area annotation classification result of the sample image, and a background area annotation classification result of the sample image; the processing unit 1020 is used to obtain a target area prediction classification result of the sample image according to a target area feature map of the sample image extracted by a neural network; obtain a background area prediction classification result of the sample image according to a background area feature map of the sample image extracted by the neural network; and determine the parameters of the neural network based on a target area classification loss function, a background area classification loss function, and a collaborative loss function of the sample image;

[0393] Among them, the target area classification loss function is used to represent the loss value between the target area prediction classification result and the target area annotation classification result of the sample image, the background area classification loss function is used to represent the loss value between the background area prediction classification result and the background area annotation classification result of the sample image, and the collaborative loss function is used to separate the target area feature map of the sample image and the background area feature map of the sample image.

[0394] Optionally, as an embodiment, the collaborative loss function is obtained by weighted processing of a first collaborative loss function and a second collaborative loss function, wherein the first collaborative loss function is obtained by multiplying a target area feature map of the sample image by corresponding pixel points in a background area mask of the sample image;

[0395] The second collaborative loss function is obtained by multiplying the background area feature map of the sample image by the corresponding pixel points in the target area mask of the sample image.

[0396] Optionally, as an embodiment, the neural network includes a first branch and a second branch, the first branch is used to process the target area of ​​the sample image to obtain a target area feature map of the sample image and a target area mask of the sample image;

[0397] The second branch is used to process the background area of ​​the sample image to obtain a background area feature map of the sample image and a background area mask of the sample image.

[0398] Optionally, as an embodiment, the collaborative loss function is obtained by the following equation:

[0399]

[0400] Among them, L t represents the collaborative loss function, N represents the number of pixels in the sample image, and F irepresents the i-th pixel in the target area of ​​the sample image, represents the probability value of the i-th pixel in the target area mask of the sample image, B i represents the i-th pixel in the background area of ​​the sample image, represents the probability value of the i-th pixel in the background area mask of the sample image, ⊙ is used to represent the multiplication of corresponding elements, N is an integer greater than 1, and i is an integer greater than or equal to 1 and less than or equal to N.

[0401] Optionally, as an embodiment, the target area prediction classification result of the sample image refers to an identifier of a camera that acquires the sample image.

[0402] It should be noted that the above-mentioned image classification device 900 and the image classification model training device 1000 are embodied in the form of functional units. The term "unit" here can be implemented in the form of software and / or hardware, and is not specifically limited to this.

[0403] For example, a "unit" may be a software program, a hardware circuit, or a combination of the two that implements the above functions. The hardware circuit may include an application specific integrated circuit (ASIC), an electronic circuit, a processor (e.g., a shared processor, a dedicated processor, or a group processor, etc.) and a memory for executing one or more software or firmware programs, a combined logic circuit, and / or other suitable components that support the described functions.

[0404] Therefore, the units of each example described in the embodiments of the present application can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.

[0405] Fig.15 It is a schematic diagram of the hardware structure of the image classification device provided in the embodiment of the present application. Fig.15 The image classification device 1100 shown (the device 1100 may be a computer device) includes a memory 1101, a processor 1102, a communication interface 1103 and a bus 1104. The memory 1101, the processor 1102 and the communication interface 1103 are connected to each other through the bus 1104.

[0406] The memory 1101 may be a read-only memory (ROM), a static storage device, a dynamic storage device or a random access memory (RAM). The memory 1101 may store a program. When the program stored in the memory 1101 is executed by the processor 1102, the processor 1102 is used to execute each step of the image classification method of the embodiment of the present application, for example, to execute Fig. 9 The steps shown.

[0407] It should be understood that the image classification device shown in the embodiment of the present application can be a server, for example, it can be a server in the cloud, or it can also be a chip configured in a server in the cloud.

[0408] Processor 1202 can adopt a general-purpose central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits to execute relevant programs to implement the image classification method of the method embodiment of the present application.

[0409] The processor 1102 may also be an integrated circuit chip with signal processing capability. In the implementation process, each step of the image classification method of the present application may be completed by an integrated logic circuit of hardware in the processor 1102 or by instructions in the form of software.

[0410] The above-mentioned processor 1202 can also be a general-purpose processor, a digital signal processor (digital signal processing, DSP), an 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 various methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field 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 1101, and the processor 1102 reads the information in the memory 1101, and completes the implementation of the present application in combination with its hardware. Fig.13 The functions required to be performed by the units included in the image classification device shown, or the functions required to perform the method embodiments of the present application Fig. 9 The image classification method shown.

[0411] The communication interface 1103 uses a transceiver device such as, but not limited to, a transceiver to implement communication between the apparatus 1100 and other devices or a communication network.

[0412] The bus 1104 may include a path for transmitting information between various components of the device 1100 (eg, the memory 1101 , the processor 1102 , and the communication interface 1103 ).

[0413] Fig.16 It is a schematic diagram of the hardware structure of the training device of the image classification model provided in the embodiment of the present application. Fig.16 The training device 1200 shown (the training device 1200 may be a computer device) includes a memory 1201, a processor 1202, a communication interface 1203 and a bus 1204. The memory 1201, the processor 1202 and the communication interface 1203 are connected to each other through the bus 1204.

[0414] The memory 1201 may be a read-only memory (ROM), a static storage device, a dynamic storage device or a random access memory (RAM). The memory 1201 may store a program. When the program stored in the memory 1201 is executed by the processor 1202, the processor 1202 is used to execute the various steps of the training method of the image classification model of the embodiment of the present application, for example, to execute Fig.10 or Fig.11 The steps shown.

[0415] It should be understood that the training device shown in the embodiment of the present application can be a server, for example, it can be a server in the cloud, or it can also be a chip configured in a server in the cloud.

[0416] Processor 1202 can adopt a general central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits to execute relevant programs to implement the training method of the image classification model of the method embodiment of the present application.

[0417] The processor 1202 may also be an integrated circuit chip with signal processing capability. In the implementation process, each step of the training method of the image classification model of the present application may be completed by an integrated logic circuit of hardware in the processor 1202 or by instructions in the form of software.

[0418] The processor 1202 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, or discrete hardware components. The methods, steps, and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware decoding processor, or may be executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a mature storage medium 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, or the like. The storage medium is located in the memory 1201, and the processor 1202 reads the information in the memory 1201 and completes the processing in combination with its hardware. Fig.14 The functions required to be performed by the units included in the training device of the image classification model shown, or the functions required to perform the method of the embodiment of the present application Fig.10 or Fig.11 The training method of the image classification model shown.

[0419] The communication interface 1203 uses a transceiver device such as but not limited to a transceiver to implement communication between the apparatus 1200 and other devices or a communication network.

[0420] The bus 1204 may include a path for transmitting information between various components of the device 1200 (eg, the memory 1201 , the processor 1202 , and the communication interface 1203 ).

[0421] It should be noted that although the above-mentioned device 1100 and training device 1200 only show a memory, a processor, and a communication interface, in the specific implementation process, those skilled in the art should understand that the device 1100 and the training device 1200 may also include other devices necessary for normal operation. At the same time, according to specific needs, those skilled in the art should understand that the above-mentioned device 1100 and the training device 1200 may also include hardware devices for implementing other additional functions. In addition, those skilled in the art should understand that the above-mentioned device 1100 and the training device 1200 may also only include the devices necessary to implement the embodiments of the present application, and do not necessarily include Fig.15 or Fig.16 All devices shown in .

[0422] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0423] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0424] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0425] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0426] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0427] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks or optical disks.

[0428] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. An image classification method, characterized in that: include: Acquire an image to be processed, wherein the image to be processed includes a target area to be identified and a background area; Classifying the image to be processed according to the target neural network to obtain a classification result of the target area and a classification result of the background area of ​​the image to be processed; Wherein, the target neural network is trained based on the target area classification loss function, the background area classification loss function and the collaborative loss function, the target area classification loss function is used to represent the loss value between the predicted classification result corresponding to the target area feature map of the sample image and the target area annotation classification result, the background area classification loss function is used to represent the loss value between the predicted classification result corresponding to the background area feature map of the sample image and the background area annotation classification result, and the collaborative loss function is used to separate the target area feature map of the sample image from the background area feature map of the sample image; The collaborative loss function is obtained by weighting a first collaborative loss function and a second collaborative loss function, wherein the first collaborative loss function is obtained by multiplying a target region feature map of the sample image by a background region mask of the sample image; The second collaborative loss function is obtained based on the multiplication of the background area feature map of the sample image and the target area mask of the sample image.

2. The image classification method according to claim 1, characterized in that: The target neural network includes a first branch and a second branch, wherein the first branch is used to process the target area of ​​the sample image to obtain a target area feature map of the sample image and a target area mask of the sample image; The second branch is used to process the background area of ​​the sample image to obtain a background area feature map of the sample image and a background area mask of the sample image.

3. The image classification method according to claim 1, characterized in that: The collaborative loss function is obtained by the following equation: Among them, L t represents the collaborative loss function, N represents the number of pixels in the sample image, and F i represents the i-th pixel in the target area of ​​the sample image, represents the probability value of the i-th pixel in the target area mask of the sample image, B i represents the i-th pixel in the background area of ​​the sample image, represents the probability value of the i-th pixel in the background area mask of the sample image, N is an integer greater than 1, and i is an integer greater than or equal to 1 and less than or equal to N.

4. The image classification method according to claim 2, characterized in that: The step of classifying the image to be processed according to the target neural network to obtain a classification result of the target area of ​​the image to be processed and a classification result of the background area includes: Processing the target region of the image to be processed by the first branch of the target neural network to obtain an enhanced feature map of the target region of the image to be processed, wherein the enhanced feature map of the target region is obtained by multiplying the target region feature map of the image to be processed and the target region mask of the image to be processed; Processing the background area of ​​the image to be processed by the second branch of the target neural network to obtain a background area enhanced feature map of the image to be processed, wherein the background area enhanced feature map is obtained by multiplying the background area feature map of the image to be processed and the background area mask of the image to be processed; Classification is performed based on the target region enhancement feature map and the background region enhancement feature map of the image to be processed to obtain a classification result of the target region and a classification result of the background region of the image to be processed.

5. The image classification method according to any one of claims 1 to 4, characterized in that: The classification result of the background area of ​​the image to be processed refers to the identifier of the camera that acquired the image to be processed.

6. A training method for an image classification model, characterized in that: include: Acquire training data, wherein the training data includes a sample image, a target area annotation classification result of the sample image, and a background area annotation classification result of the sample image; Obtaining a target region prediction classification result of the sample image according to a target region feature map of the sample image extracted by a neural network; Obtaining a background area prediction classification result of the sample image according to the background area feature map of the sample image extracted by the neural network; Determine the parameters of the neural network based on the target area classification loss function, the background area classification loss function and the collaborative loss function, The target area classification loss function is used to represent the loss value between the target area prediction classification result and the target area annotation classification result of the sample image, the background area classification loss function is used to represent the loss value between the background area prediction classification result and the background area annotation classification result of the sample image, and the collaborative loss function is used to separate the target area feature map of the sample image from the background area feature map of the sample image; The collaborative loss function is obtained by weighting a first collaborative loss function and a second collaborative loss function, wherein the first collaborative loss function is obtained by multiplying a target region feature map of the sample image by a background region mask of the sample image; The second collaborative loss function is obtained based on the multiplication of the background area feature map of the sample image and the target area mask of the sample image.

7. The training method according to claim 6, characterized in that: The neural network comprises a first branch and a second branch, wherein the first branch is used to process the target area of ​​the sample image to obtain a target area feature map of the sample image and a target area mask of the sample image; The second branch is used to process the background area of ​​the sample image to obtain a background area feature map of the sample image and a background area mask of the sample image.

8. The training method according to claim 6 or 7, characterized in that: The collaborative loss function is obtained by the following equation: Among them, L t represents the collaborative loss function, N represents the number of pixels in the sample image, and F i represents the i-th pixel in the target area of ​​the sample image, represents the probability value of the i-th pixel in the target area mask of the sample image, B i represents the i-th pixel in the background area of ​​the sample image, represents the probability value of the i-th pixel in the background area mask of the sample image, N is an integer greater than 1, and i is an integer greater than or equal to 1 and less than or equal to N.

9. The training method according to claim 6 or 7, characterized in that: The target area prediction classification result of the sample image refers to the identifier of the camera that acquired the sample image.

10. An image classification device, characterized in that: include: An acquisition unit, used for acquiring an image to be processed, wherein the image to be processed includes a target area to be identified and a background area; A processing unit, used for classifying the image to be processed according to a target neural network to obtain a classification result of the target area and a classification result of the background area of ​​the image to be processed; Wherein, the target neural network is trained based on the target area classification loss function, the background area classification loss function and the collaborative loss function, the target area classification loss function is used to represent the loss value between the predicted classification result corresponding to the target area feature map of the sample image and the target area annotation classification result, the background area classification loss function is used to represent the loss value between the predicted classification result corresponding to the background area feature map of the sample image and the background area annotation classification result, and the collaborative loss function is used to separate the target area feature map of the sample image from the background area feature map of the sample image; The collaborative loss function is obtained by weighting a first collaborative loss function and a second collaborative loss function, wherein the first collaborative loss function is obtained by multiplying a target region feature map of the sample image by a background region mask of the sample image; The second collaborative loss function is obtained based on the multiplication of the background area feature map of the sample image and the target area mask of the sample image.

11. The image classification device according to claim 10, characterized in that: The target neural network includes a first branch and a second branch, wherein the first branch is used to process the target area of ​​the sample image to obtain a target area feature map of the sample image and a target area mask of the sample image; The second branch is used to process the background area of ​​the sample image to obtain a background area feature map of the sample image and a background area mask of the sample image.

12. The image classification device according to claim 10, characterized in that: The collaborative loss function is obtained by the following equation: Among them, L t represents the collaborative loss function, N represents the number of pixels in the sample image, and F i represents the i-th pixel in the target area of ​​the sample image, represents the probability value of the i-th pixel in the target area mask of the sample image, B i represents the i-th pixel in the background area of ​​the sample image, represents the probability value of the i-th pixel in the background area mask of the sample image, N is an integer greater than 1, and i is an integer greater than or equal to 1 and less than or equal to N.

13. The image classification device according to claim 11, characterized in that: The processing unit is specifically used for: Processing the target region of the image to be processed by the first branch of the target neural network to obtain an enhanced feature map of the target region of the image to be processed, wherein the enhanced feature map of the target region is obtained by multiplying the target region feature map of the image to be processed and the target region mask of the image to be processed; Processing the background area of ​​the image to be processed by the second branch of the target neural network to obtain a background area enhanced feature map of the image to be processed, wherein the background area enhanced feature map is obtained by multiplying the background area feature map of the image to be processed and the background area mask of the image to be processed; Classification is performed based on the target region enhancement feature map and the background region enhancement feature map of the image to be processed to obtain a classification result of the target region and a classification result of the background region of the image to be processed.

14. The image classification device according to any one of claims 10 to 13, characterized in that: The classification result of the background area of ​​the image to be processed refers to the identifier of the camera that acquired the image to be processed.

15. A training device for an image classification model, characterized in that: include: An acquisition unit, configured to acquire training data, wherein the training data includes a sample image, a target region annotation classification result of the sample image, and a background region annotation classification result of the sample image; A processing unit is used to obtain a target area prediction classification result of the sample image according to a target area feature map of the sample image extracted by a neural network; obtain a background area prediction classification result of the sample image according to a background area feature map of the sample image extracted by the neural network; determine the parameters of the neural network based on a target area classification loss function, a background area classification loss function and a collaborative loss function of the sample image, The target area classification loss function is used to represent the loss value between the target area prediction classification result and the target area annotation classification result of the sample image, the background area classification loss function is used to represent the loss value between the background area prediction classification result and the background area annotation classification result of the sample image, and the collaborative loss function is used to separate the target area feature map of the sample image from the background area feature map of the sample image; The collaborative loss function is obtained by weighting a first collaborative loss function and a second collaborative loss function, wherein the first collaborative loss function is obtained by multiplying a target region feature map of the sample image by a background region mask of the sample image; The second collaborative loss function is obtained based on the multiplication of the background area feature map of the sample image and the target area mask of the sample image.

16. The training device according to claim 15, characterized in that The neural network comprises a first branch and a second branch, wherein the first branch is used to process the target area of ​​the sample image to obtain a target area feature map of the sample image and a target area mask of the sample image; The second branch is used to process the background area of ​​the sample image to obtain a background area feature map of the sample image and a background area mask of the sample image.

17. The training device according to claim 15 or 16, characterized in that The collaborative loss function is obtained by the following equation: Among them, L t represents the collaborative loss function, N represents the number of pixels in the sample image, and F i represents the i-th pixel in the target area of ​​the sample image, represents the probability value of the i-th pixel in the target area mask of the sample image, B i represents the i-th pixel in the background area of ​​the sample image, represents the probability value of the i-th pixel in the background area mask of the sample image, N is an integer greater than 1, and i is an integer greater than or equal to 1 and less than or equal to N.

18. The training device according to claim 15 or 16, characterized in that The target area prediction classification result of the sample image refers to the identifier of the camera that acquired the sample image.

19. An image classification device, characterized in that: The method comprises a processor and a memory, wherein the memory is used to store program instructions, and the processor is used to call the program instructions to execute the image classification method according to any one of claims 1 to 5.

20. A training device for an image classification model, characterized in that: It comprises a processor and a memory, wherein the memory is used to store program instructions, and the processor is used to call the program instructions to execute the training method according to any one of claims 6 to 9.

21. A computer-readable storage medium, characterized in that: The computer-readable medium stores a program code for execution by a device, wherein the program code includes a program for executing the image classification method according to any one of claims 1 to 5.

22. A computer-readable storage medium, characterized in that: The computer-readable medium stores a program code for execution by a device, wherein the program code includes a program for executing the training method according to any one of claims 6 to 9.

23. A chip, characterized in that: The chip includes a processor and a data interface, and the processor reads instructions stored in a memory through the data interface to execute the image classification method according to any one of claims 1 to 5.

24. A chip, characterized in that: The chip includes a processor and a data interface, and the processor reads instructions stored in a memory through the data interface to execute the training method as described in any one of claims 6 to 9.