Image recognition method, device, electronic device and storage medium
By extracting multi-scale features in the image recognition model and utilizing global and local recognition networks, automated image type recognition is achieved, solving the problem of low image recognition efficiency in the existing technology, and improving recognition efficiency and flexibility.
Patent Information
- Application Number
- CN202110605499.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-31
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2041-05-31
AI Technical Summary
The image recognition process in the existing technology is inefficient, mainly due to its reliance on manual annotation, which results in high work intensity and low efficiency.
An image recognition method is adopted, by obtaining the image to be recognized and inputting it into an image recognition model including a feature extraction network, a global recognition network and a local recognition network, extracting multi-scale features, and identifying the image in the global and local recognition networks Type information, determine whether the picture is an abnormal picture, and realize automatic picture type identification.
Without the need for manual annotation, the efficiency of image recognition is improved, the workload is reduced, and image recognition is made more flexible and convenient, and it can be recognized from the overall and local perspectives.
Smart Images

Figure CN113392887B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of image recognition, and in particular to an image recognition method, device, electronic device and storage medium. Background Art
[0002] With the rapid development of the Internet and wireless communication technologies, people have more and more ways to share information. As a new information sharing function, picture sharing allows users to show their daily lives to others through pictures (such as photos or frames in videos), which improves the convenience and fun of information sharing.
[0003] At present, with the rapid promotion of picture sharing, people are spreading more and more pictures. It is necessary to classify the picture type of each picture to facilitate the management of pictures. For example, pictures with illegal, unethical or vulgar content can be classified as vulgar pictures to prevent the spread of vulgar pictures. However, the identification of the picture type to which a picture belongs is usually done manually, which is labor-intensive and leads to low efficiency of picture recognition. It can be seen that the current picture recognition process has the problem of low efficiency. Summary of the invention
[0004] The purpose of the embodiments of the present disclosure is to provide a method, device, electronic device and storage medium for image recognition, so as to solve the problem of low efficiency in the current image recognition process.
[0005] The technical solution of the present disclosure is as follows:
[0006] According to a first aspect of an embodiment of the present disclosure, there is provided a method for image recognition, comprising:
[0007] Get the image to be identified;
[0008] Inputting the picture to be identified into a feature extraction network of a picture recognition model, and extracting multi-scale features through the feature extraction network, wherein the picture recognition model includes the feature extraction network and a global recognition network and a local recognition network connected to the feature extraction network, and the global recognition network is used to identify the picture type based on the global image features of the picture, and the local recognition network is used to identify the picture type based on the local image features of the picture, and the multi-scale features include the global image features and the local image features of the picture to be identified;
[0009] Input the multi-scale features into the global recognition network to identify the first type of information of the picture to be recognized, and / or input the multi-scale features into the local recognition network to identify the second type of information of the picture to be recognized, wherein the first type of information is used to indicate whether the global image of the picture to be recognized is abnormal, and the second type of information is used to indicate whether the local image of the picture to be recognized is abnormal;
[0010] When the first type information indicates an abnormality and / or the second type information indicates an abnormality, it is determined that the picture to be identified is an abnormal picture.
[0011] In one embodiment, before obtaining the image to be identified and inputting the image to be identified into the image recognition model, the method further includes:
[0012] Obtain a training sample set;
[0013] Inputting the picture samples of the training sample set into the recognition model to be trained including the feature extraction network, the global recognition network and the local recognition network, and calculating the first weighted loss of the global recognition network and the local recognition network;
[0014] When the first weighted loss does not meet the preset conditions, the parameters of each network in the recognition model to be trained are updated, and the model after the network parameters are updated is used as the recognition model to be trained, and the image samples of the training sample set are re-inputted into the recognition model to be trained until the first weighted loss meets the preset conditions to obtain the image recognition model.
[0015] In one embodiment, when the first weighted loss does not meet the preset condition, the parameters of each network in the recognition model to be trained are updated, and the model after the network parameters are updated is used as the recognition model to be trained, and the picture samples of the training sample set are input to the recognition model to be trained again until the first weighted loss meets the preset condition, so as to obtain the picture recognition model, including:
[0016] In the case where the parameters of the feature extraction network of the recognition model to be trained are in a fixed state, if the first weighted loss does not meet the preset conditions and the number of iterations does not reach the preset number, update the parameters of the global recognition network and the local recognition network in the recognition model to be trained, and use the model after the network parameters are updated as the recognition model to be trained, and re-execute the input of the picture samples of the training sample set into the recognition model to be trained, wherein the number of iterations is the number of times the parameters of the global recognition network and the local recognition network in the recognition model to be trained are updated;
[0017] When the first weighted loss does not meet the preset condition and the number of iterations reaches the preset number, the parameters of the feature extraction network are set to an updateable state, and the parameters of the feature extraction network, the global recognition network and the local recognition network in the recognition model to be trained are updated. The model after the network parameters are updated is used as the recognition model to be trained, and the image samples of the training sample set are input into the recognition model to be trained again until the first weighted loss meets the preset condition to obtain the image recognition model.
[0018] In one embodiment, the training sample set includes at least one first picture sample and at least one second picture sample, and the first picture sample corresponds to the global recognition network, and the second picture sample corresponds to the local recognition network;
[0019] Before obtaining the image to be identified and inputting the image to be identified into the image recognition model, the process further includes:
[0020] In the case where the parameters of the first recognition network in the recognition model to be trained are fixed, the picture samples corresponding to the second recognition network in the training sample set are input into the second recognition network, and the loss of the second recognition network is calculated, wherein the first recognition network is any one of the global recognition network and the local recognition network, and the second recognition network is a recognition network other than the first recognition network in the global recognition network and the local recognition network;
[0021] When the loss of the second recognition network does not reach a preset condition, updating the parameters of the feature extraction network and the second recognition network in the recognition model to be trained, and re-inputting the picture samples corresponding to the second recognition network in the training sample set into the second recognition network;
[0022] When the loss of the second recognition network reaches the preset condition, setting the parameters of the first recognition network to an update state and the parameters of the second recognition network to a fixed state, inputting the image samples corresponding to the first recognition network in the training sample set into the first recognition network, and calculating the loss of the first recognition network;
[0023] When the loss of the first recognition network does not reach the preset condition, the parameters of the feature extraction network and the first recognition network in the recognition model to be trained are updated, and the image samples corresponding to the first recognition network in the training sample set are input into the first recognition network again until the loss of the first recognition network reaches the preset condition, thereby obtaining the image recognition model.
[0024] In one embodiment, when the loss of the first recognition network does not reach the preset condition, the parameters of the feature extraction network and the first recognition network in the recognition model to be trained are updated, and the picture samples corresponding to the first recognition network in the training sample set are input into the first recognition network again until the loss of the first recognition network reaches the preset condition, thereby obtaining the picture recognition model, including:
[0025] When the loss of the first recognition network does not reach the preset condition, updating the parameters of the feature extraction network and the first recognition network in the recognition model to be trained, and re-inputting the picture samples in the training sample set corresponding to the first recognition network into the first recognition network;
[0026] When the loss of the first recognition network meets the preset condition, the parameters of the second recognition network are set to an update state, and the parameters of the feature extraction network, the first recognition network and the second recognition network in the recognition model to be trained are updated, and the model after the parameter update is used as the recognition model to be trained;
[0027] Inputting the picture samples corresponding to the first recognition network and the second recognition network in the training sample set into the recognition model to be trained, and calculating the second weighted losses of the first recognition network and the second recognition network;
[0028] When the second weighted loss fails to meet the preset condition, the parameters of the feature extraction network, the first recognition network and the second recognition network in the recognition model to be trained are updated, and the model with updated parameters is used as the recognition model to be trained, and the image samples corresponding to the first recognition network and the second recognition network in the training sample set are re-inputted into the recognition model to be trained until the second weighted loss meets the preset condition to obtain the image recognition model.
[0029] In one embodiment, obtaining a training sample set includes:
[0030] Acquire a first sample set and a second sample set, wherein the first sample set includes labeled picture samples, and the second sample set includes unlabeled picture samples;
[0031] Inputting the first sample set into the M-1th recognition model to obtain the Mth recognition model through training, wherein M is a positive integer;
[0032] Inputting the picture samples in the second sample set into the Mth recognition model to mark the input picture samples, and adding the marked picture samples to the first sample set;
[0033] In the case that the M recognition models do not meet the training stop condition, using the Mth recognition model as the M-1th recognition model, and re-implementing the first sample set into the M-1th recognition model;
[0034] When the M recognition models satisfy the training stop condition, the first sample set is used as the training sample set.
[0035] According to a second aspect of an embodiment of the present disclosure, there is provided a picture recognition device, including:
[0036] An image acquisition module is configured to acquire an image to be identified;
[0037] a multi-scale feature extraction module, configured to input the picture to be identified into a feature extraction network of a picture recognition model, and extract multi-scale features through the feature extraction network, wherein the picture recognition model includes the feature extraction network and a global recognition network and a local recognition network connected to the feature extraction network, and the global recognition network is used to identify the picture type based on the global image features of the picture, and the local recognition network is used to identify the picture type based on the local image features of the picture, and the multi-scale features include the global image features and the local image features of the picture to be identified;
[0038] The recognition module is configured to input the multi-scale features into the global recognition network to identify the first type of information of the picture to be recognized, and / or input the multi-scale features into the local recognition network to identify the second type of information of the picture to be recognized, wherein the first type of information is used to indicate whether the global image of the picture to be recognized is abnormal, and the second type of information is used to indicate whether the local image of the picture to be recognized is abnormal;
[0039] The abnormal picture determination module is configured to determine that the picture to be identified is an abnormal picture when the first type information indicates an abnormality and / or the second type information indicates an abnormality.
[0040] In one embodiment, the device further comprises:
[0041] A training set acquisition module is configured to acquire a training sample set;
[0042] A weighted loss calculation module is configured to input the image samples of the training sample set into the recognition model to be trained including the feature extraction network, the global recognition network and the local recognition network, and calculate the first weighted loss of the global recognition network and the local recognition network;
[0043] The first training module is configured to update the parameters of each network in the recognition model to be trained when the first weighted loss does not meet the preset conditions, and use the model after the network parameters are updated as the recognition model to be trained, and re-execute the input of the image samples of the training sample set into the recognition model to be trained until the first weighted loss meets the preset conditions to obtain the image recognition model.
[0044] In one embodiment, the first training module includes:
[0045] A first parameter updating unit is configured to update the parameters of the global recognition network and the local recognition network in the recognition model to be trained, and use the model after the network parameters are updated as the recognition model to be trained, and re-execute inputting the picture samples of the training sample set into the recognition model to be trained, when the parameters of the feature extraction network of the recognition model to be trained are in a fixed state and if the first weighted loss does not meet the preset conditions and the number of iterations does not reach the preset number, wherein the number of iterations is the number of times the parameters of the global recognition network and the local recognition network in the recognition model to be trained are updated;
[0046] The second parameter updating unit is configured to set the parameters of the feature extraction network to an updateable state and update the parameters of the feature extraction network, the global recognition network and the local recognition network in the recognition model to be trained when the first weighted loss does not meet the preset condition and the number of iterations reaches the preset number, and use the model after the network parameters are updated as the recognition model to be trained, and re-execute the input of the image samples of the training sample set into the recognition model to be trained until the first weighted loss meets the preset condition to obtain the image recognition model.
[0047] In one embodiment, the training sample set includes at least one first picture sample and at least one second picture sample, and the first picture sample corresponds to the global recognition network, and the second picture sample corresponds to the local recognition network;
[0048] The device further comprises:
[0049] A first loss calculation module is configured to input the picture samples corresponding to the second recognition network in the training sample set into the second recognition network when the parameters of the first recognition network in the recognition model to be trained are fixed, and calculate the loss of the second recognition network, wherein the first recognition network is any one of the global recognition network and the local recognition network, and the second recognition network is a recognition network other than the first recognition network in the global recognition network and the local recognition network;
[0050] A first parameter module is configured to update the parameters of the feature extraction network and the second recognition network in the recognition model to be trained, and re-enter the image samples corresponding to the second recognition network in the training sample set into the second recognition network when the loss of the second recognition network does not meet the preset condition;
[0051] A second loss calculation module is configured to set the parameters of the first recognition network to an updated state and the parameters of the second recognition network to a fixed state when the loss of the second recognition network reaches the preset condition, and input the image samples corresponding to the first recognition network in the training sample set into the first recognition network to calculate the loss of the first recognition network;
[0052] The second parameter updating module is configured to update the parameters of the feature extraction network and the first recognition network in the recognition model to be trained when the loss of the first recognition network does not reach the preset condition, and re-enter the image samples corresponding to the first recognition network in the training sample set into the first recognition network until the loss of the first recognition network reaches the preset condition, thereby obtaining the image recognition model.
[0053] In one embodiment, the second parameter updating module includes:
[0054] A third parameter updating unit is configured to update the parameters of the feature extraction network and the first recognition network in the recognition model to be trained, and re-enter the picture samples in the training sample set corresponding to the first recognition network into the first recognition network when the loss of the first recognition network does not reach the preset condition;
[0055] a fourth parameter updating unit, configured to set the parameters of the second recognition network to an updated state when the loss of the first recognition network meets the preset condition, and update the parameters of the feature extraction network, the first recognition network and the second recognition network in the recognition model to be trained, and use the model after the parameter update as the recognition model to be trained;
[0056] A weighted loss calculation unit, configured to input the picture samples corresponding to the first recognition network and the second recognition network in the training sample set into the recognition model to be trained, and calculate the second weighted loss of the first recognition network and the second recognition network;
[0057] The fifth parameter updating unit is configured to update the parameters of the feature extraction network, the first recognition network and the second recognition network in the recognition model to be trained when the second weighted loss does not meet the preset condition, and use the model after parameter update as the recognition model to be trained, and re-input the image samples corresponding to the first recognition network and the second recognition network in the training sample set into the recognition model to be trained until the second weighted loss meets the preset condition to obtain the image recognition model.
[0058] In one embodiment, the training set acquisition module includes:
[0059] A sample set acquisition unit, configured to acquire a first sample set and a second sample set, wherein the first sample set includes labeled picture samples, and the second sample set includes unlabeled picture samples;
[0060] A training unit is configured to input the first sample set into the M-1th recognition model to obtain the Mth recognition model through training, wherein M is a positive integer;
[0061] a labeling unit, configured to input the picture samples in the second sample set into the Mth recognition model to label the input picture samples, and add the labeled picture samples to the first sample set;
[0062] a training resetting unit, configured to, when the M recognition models do not satisfy the training stop condition, use the Mth recognition model as the M-1th recognition model, and re-execute inputting the first sample set into the M-1th recognition model;
[0063] The sample set output unit is configured to use the first sample set as the training sample set when the M recognition models meet the training stop condition.
[0064] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, which may include:
[0065] processor;
[0066] a memory for storing instructions executable by the processor;
[0067] The processor is configured to execute the instructions to implement the image recognition method as shown in any one of the embodiments of the first aspect.
[0068] According to the fourth aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided. When the instructions in the computer-readable storage medium are executed by a processor of an image recognition device or an electronic device, the image recognition device or the electronic device is enabled to implement the image recognition method as shown in any one of the embodiments of the first aspect.
[0069] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program or instructions, which, when executed by a processor, implements the image recognition method as shown in any one of the embodiments of the first aspect.
[0070] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0071] By inputting the image to be identified into the feature extraction network of the image recognition model to extract multi-scale features, and inputting the extracted multi-scale features into at least one recognition network of the local recognition network and the local recognition network of the image recognition model, the at least one recognition network is used to respectively determine whether the image to be identified is an abnormal image. In this way, through the image recognition method of the embodiment of the present application, in the process of image recognition, the image type of the image to be identified can be identified without manual labeling, reducing the workload of image recognition, thereby improving the efficiency of image recognition; in addition, it is also possible to recognize the image to be identified from the overall and local aspects, making image recognition more flexible and convenient.
[0072] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0074] Figure 1 is a flowchart of a method for image recognition according to an exemplary embodiment;
[0075] Figure 2 is a schematic diagram showing a picture recognition model identifying a picture type according to an exemplary embodiment;
[0076] Figure 3 is a schematic diagram of a training picture recognition model according to an exemplary embodiment;
[0077] Figure 4 is a structural block diagram of a picture recognition device according to an exemplary embodiment;
[0078] Figure 5It is a structural block diagram of a computing device according to an exemplary embodiment. DETAILED DESCRIPTION
[0079] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0080] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0081] See also Figure 1 , is a flow chart of a method for image recognition according to an exemplary embodiment. The method for image recognition is applied to electronic devices, such as computer terminals or electronic devices. For ease of understanding, this solution is described by taking electronic devices as an example. Figure 1 As shown, the above-mentioned image recognition method includes the following steps 101-104.
[0082] Step 101: Obtain a picture to be identified.
[0083] In one embodiment of the present application, the electronic device obtains the above-mentioned picture to be identified. The above-mentioned picture to be identified may be pre-stored in the electronic device, and the electronic device extracts the picture to be identified from a storage area; or, a user terminal (User Equipment, UE) may upload a picture to the electronic device, and the electronic device receives the uploaded picture and uses it as the above-mentioned picture to be identified.
[0084] It should be noted that the above-mentioned picture to be identified may be a photo taken by a user terminal, or may be a video frame in a captured video, which is not limited here.
[0085] Step 102: input the picture to be identified into the feature extraction network of the picture recognition model, and extract multi-scale features through the feature extraction network, wherein the picture recognition model includes a feature extraction network and a global recognition network and a local recognition network connected to the feature extraction network, and the global recognition network is used to identify the picture type based on the global image features of the picture, and the local recognition network is used to identify the picture type based on the local image features of the picture, and the multi-scale features include the global image features and local image features of the picture to be identified.
[0086] In one embodiment of the present application, the above-mentioned image recognition model is pre-set in the electronic device, and the image recognition model includes the above-mentioned feature extraction network, and the feature extraction network can be any model that can realize the extraction of multi-scale features of the image. Figure 2 As shown, the feature extraction network is a shared backbone network (Backbone), and the shared backbone network can adopt any one of the networks such as the big transfer network, the residual neural network (resNet) and the convolutional neural network GoogLeNet; or, the feature extraction network can also be the optimal (State Of The Art, SOTA) model, and so on.
[0087] Among them, the above-mentioned multi-scale features include global image features and local image features of the image. The global image features refer to image features extracted from the entire image area of the picture as a whole, while the local image features refer to image features extracted from a part of the image area of the picture as a whole.
[0088] For example, in a picture including a person image, the local image feature may be a feature extracted from the image area where the human body parts such as the chest, buttocks or triangle area in the person image are located; and the above-mentioned global image feature is a feature extracted from the entire image area of the above-mentioned person image.
[0089] In one embodiment of the present application, the above-mentioned image recognition model also includes a global recognition network and a local recognition network. The above-mentioned global recognition network is used to perform image type recognition based on the global image features in the multi-scale features extracted by the above-mentioned feature extraction network, and the above-mentioned local recognition network is used to perform image type recognition based on the local image features in the multi-scale features extracted by the above-mentioned feature extraction network.
[0090] The global recognition network may be any recognition network that can recognize the type of image (i.e., recognize whether the image is abnormal) based on the global image features of the image, where the image type includes whether the image is normal or abnormal. For example, the global recognition network may be Figure 2 The classification branch network shown may include a deep neural network (DNN) provided with an attention mechanism, and the classification branch network may identify a picture as a normal picture or a vulgar picture (i.e., an abnormal picture) based on the global image features of the picture.
[0091] In addition, the local recognition network can be any network that can recognize the type of an image (i.e., recognize whether the image is abnormal) based on the local image features of the image, where the image type includes whether the local image corresponding to the local image features is abnormal. For example, the local recognition network can be Figure 2 The target detection branch network shown may include an EfficientDet network and a single neural network-based target detection (You Only Look Once: Unified, Real-Time Object Detection, Yolo) series network, etc., and the target detection branch network may perform image type recognition from a local image of the image. Specifically, it may be based on an image of the image area of the buttocks in a person's image to recognize whether the image of the buttocks, chest or triangle area is exposed (i.e., it is abnormal when exposed and normal when not exposed).
[0092] In one embodiment of the present application, the above-mentioned image recognition model is a recognition model pre-set in the electronic device. Specifically, the above-mentioned image recognition model can be obtained by training the recognition model to be trained through a training sample set.
[0093] The process of training the recognition model to be trained by using the training sample set may be:
[0094] A global image recognition model for identifying whether the global image of an image is abnormal is obtained by training with a training sample set, that is, the image samples in the training sample set are input into the global image recognition model to be trained, and the loss between the output result of the global image recognition model to be trained and the labeling result of the image sample is calculated by a loss function, and when the loss does not reach a preset condition, the network parameters of the global image recognition model to be trained are updated, and the model with updated parameters is used as the global image recognition model to be trained, and the image samples in the training sample set are input into the global image recognition model to be trained again, and the training process is performed until the loss reaches a preset condition, and the preset condition may be less than or equal to a preset loss, etc.;
[0095] A local image recognition model for identifying whether a local image of an image is abnormal is obtained by training with a training sample set, that is, the image samples in the training sample set are input into the local image recognition model to be trained, and the loss between the output result of the local image recognition model to be trained and the labeling result of the image sample is calculated by a loss function, and when the loss does not reach a preset condition, the network parameters of the local image recognition model to be trained are updated, and the model with updated parameters is used as the local image recognition model to be trained, and the image samples in the training sample set are input into the local image recognition model to be trained again, and the training process is performed until the loss reaches the preset condition;
[0096] The first loss between the output result of the global image recognition model and the output result of the global recognition network is calculated by inputting the global image features of the image samples in the training sample set into the global image recognition model and the global recognition network in the recognition model to be trained; and the second loss between the output result of the local image recognition model and the output result of the local recognition network is calculated by inputting the local image features of the image samples into the local image recognition model and the local recognition network in the recognition model to be trained; when the weighted loss of the first loss and the second loss does not meet the preset conditions (such as the weighted loss is less than or equal to the preset loss, etc.), the parameters of the feature extraction network, the global recognition network and the local recognition network are updated until the weighted loss meets the preset conditions, and the parameter update is stopped to obtain the above-mentioned image recognition model.
[0097] Alternatively, before the above step 102, the following may also be included:
[0098] Obtain a training sample set;
[0099] Inputting the image samples of the training sample set into the recognition model to be trained including the feature extraction network, the global recognition network and the local recognition network, and calculating the first weighted loss of the global recognition network and the local recognition network;
[0100] When the first weighted loss does not meet the preset conditions, the parameters of each network in the recognition model to be trained are updated, and the model after the network parameters are updated is used as the recognition model to be trained. The image samples of the training sample set are input into the recognition model to be trained again until the first weighted loss meets the preset conditions to obtain the image recognition model.
[0101] Based on this, the recognition model to be trained, including the feature extraction network, the global recognition network and the local recognition network, is trained through the training sample set, and the parameters of each network in the model to be trained are updated through the weighted loss of the global recognition network and the local recognition network during the training process. This can not only improve the recognition accuracy of the image recognition model, but also reduce the complexity of model training, thereby accelerating the efficiency of model training.
[0102] In one embodiment of the present application, the above-mentioned training sample set may include at least one image sample labeled with the image type, and the at least one image sample includes both image samples labeled as to whether the global image is abnormal and image samples labeled as to whether the local image is abnormal.
[0103] Among them, the above-mentioned acquisition of the training sample set can be to obtain pictures with labels of picture types that have been annotated in the history as picture samples in the training sample set. At the same time, in order to ensure the comprehensiveness of sample coverage, the labels of picture types possessed by all pictures in the training sample set can include labels of whether the global image is abnormal and labels of whether the local image is abnormal.
[0104] For example, based on historical review records or records of user complaints and reports, a group of suspected vulgar pictures or video frames are extracted from video and picture resources, as well as a group of normal pictures or video frames are extracted from video and picture resources; and then each extracted picture and video frame is labeled by setting labeling standards, that is, a label of normal or abnormal is added to each picture and video frame, and abnormal areas of abnormal pictures and video frames (such as sensitive parts such as chest, buttocks, and triangle area) are framed, that is, the abnormal area is framed and labeled with an abnormal label of the abnormal area, such as exposed chest, exposed buttocks, or exposed triangle area.
[0105] Alternatively, the obtaining of the training sample set may include:
[0106] Acquire a first sample set and a second sample set, wherein the first sample set includes labeled picture samples, and the second sample set includes unlabeled picture samples;
[0107] Input the first sample set into the M-1th recognition model, and train to obtain the Mth recognition model, where M is a positive integer;
[0108] Input the picture samples in the second sample set into the Mth recognition model to mark the input picture samples, and add the marked picture samples to the first sample set;
[0109] When the M recognition models do not meet the training stop condition, the Mth recognition model is used as the M-1th recognition model, and the first sample set is input into the M-1th recognition model again;
[0110] When the M recognition models meet the training stop condition, the first sample set is used as the training sample set.
[0111] Based on this, in the process of training the recognition model, the recognition model to be trained is trained by a first sample set including labeled image samples, and the unlabeled image samples are labeled by the trained recognition model, and the labeled samples are added to the first sample set until the trained recognition model meets the training stop condition. The first sample set is used as the above-mentioned training sample set to obtain the training sample set in a semi-supervised manner, thereby reducing the workload of obtaining the training sample set and improving the efficiency of obtaining the training sample set.
[0112] The first sample set may include at least one image sample labeled with an image type (including whether a local image is abnormal and whether a global image is abnormal), and the second sample set may include at least one image sample not labeled with the above label.
[0113] In addition, the above-mentioned recognition model can be any model that can recognize the image type of the image, and the network structure of the recognition model can be different from the network structure of the above-mentioned image recognition model; or, the network structure of the recognition model can be the same as the network structure of the above-mentioned image recognition model, that is, the above-mentioned recognition model can be a model including a feature extraction network, a global recognition network and a local recognition network, so that the samples in the second sample set can be labeled with labels of whether the global image is abnormal and whether the local image is abnormal, so that the updated first sample set has more comprehensive coverage.
[0114] In an embodiment of the present application, the first sample set is input into the M-1th recognition model to train the Mth recognition model. The picture samples of the first sample set are input into the recognition model to be trained in the M-1th training (i.e., the M-1th recognition model), and the recognition model to be trained outputs a recognition result; the loss between the recognition result and the marking result of the label in the picture sample is calculated by a preset loss function; and it is determined whether the calculated loss meets the preset conditions. If the calculated loss does not meet the preset conditions, the network parameters in the recognition model are updated to obtain the Mth recognition model, and the Mth recognition model does not meet the training stop conditions.
[0115] Among them, the above-mentioned judgment of whether the calculated loss meets the preset condition can be to judge whether the difference between the calculated loss and the loss calculated in the previous training is less than or equal to the preset difference (such as tending to be unchanged), or, it can also be to judge whether the calculated loss is less than or equal to the preset loss, and so on.
[0116] In addition, the above-mentioned updating of the network parameters in the recognition model may be to adjust the network parameters of the recognition model according to a preset network parameter updating method, such as a gradient descent method.
[0117] It should be noted that after the Mth recognition model is obtained through training, the electronic device can input the unlabeled samples in the second sample set into the Mth recognition model to obtain image samples labeled by the machine, and add the labeled samples to the first sample set to increase the image samples in the first sample set. In this way, before the training stops, the unlabeled samples are continuously labeled and the first sample set is updated through the recognition model obtained through training until the above training meets the stopping condition, and the updated first sample set is used as the training sample set.
[0118] For example, Figure 3 As shown, the process of obtaining a training sample set in a semi-supervised manner may include:
[0119] The initial recognition model includes the target detection branch network and the classification branch network. The electronic device inputs the training sample set formed by the labeled abnormal pictures or video frames and the normal pictures or video frames into the initial recognition model, and trains the initial recognition model to obtain a teacher model.
[0120] The unlabeled data is labeled through the teacher model, that is, the classification branch network is used to label the categories and the target detection branch network is used to label the sensitive parts and frame them. The electronic device labeled data and a part of the noisy data are added to the training sample set, and the training sample set is updated.
[0121] Input the samples of the updated and expanded training sample set into the classification branch network and the target detection branch network of the teacher model, and determine whether the weighted loss of the classification branch network and the target detection branch network in the teacher model meets the preset conditions (such as whether the weighted loss is less than or equal to the preset loss, etc.). If the weighted loss of the teacher model does not meet the preset conditions, update the network parameters of the teacher model to obtain the student model, and use the student model as the teacher model. Return to execute the update step of labeling the unlabeled data through the teacher model until the weighted loss of the teacher model meets the preset conditions, stop training, and obtain the final training sample set.
[0122] In one embodiment of the present application, the process of calculating the first weighted loss of the global recognition network and the local recognition network is as follows: the weights of the global recognition network and the local recognition network are pre-configured in the image recognition model, respectively. During the training process, the global recognition network of the recognition model to be trained outputs a global recognition result and the local recognition network outputs a local recognition result. The global recognition network compares its global recognition result with the label of whether the global image is abnormal annotated by the image sample, and calculates the global loss of the global recognition network; the local recognition network compares its local recognition result with the label of whether the local image is abnormal annotated by the image sample, and calculates the local loss of the local recognition network. The product of the global loss and the corresponding weight and the sum of the product of the local loss and the corresponding weight are taken as the above-mentioned first weighted loss.
[0123] In an embodiment of the present application, after calculating the above-mentioned first weighted loss, the recognition model to be trained can iteratively update the parameters of each network in the model according to the first weighted loss, and train to obtain the above-mentioned image recognition model, that is, when the first weighted loss does not meet the preset conditions, the parameters of each network in the recognition model to be trained are updated, and the model after the network parameters are updated is used as the recognition model to be trained, and the image samples of the training sample set are re-input into the recognition model to be trained until the first weighted loss meets the preset conditions to obtain the image recognition model.
[0124] Among them, the above-mentioned iterative update of the parameters of each network in the model according to the first weighted loss can be that the parameters of the feature extraction network, the global recognition network and the local recognition network in the recognition model to be trained are all in an updateable state. In this way, when the first weighted loss does not meet the preset conditions, the parameters of the feature extraction network, the global recognition network and the local recognition network in the recognition model to be trained are all updated until the image recognition model is obtained when the first weighted loss meets the preset conditions.
[0125] Alternatively, when the first weighted loss does not meet the preset condition, the parameters of each network in the recognition model to be trained are updated, and the model after the network parameters are updated is used as the recognition model to be trained, and the picture samples of the training sample set are input into the recognition model to be trained again until the first weighted loss meets the preset condition, and the picture recognition model is obtained, which may include:
[0126] When the parameters of the feature extraction network of the recognition model to be trained are fixed, if the first weighted loss does not meet the preset conditions and the number of iterations does not reach the preset number, update the parameters of the global recognition network and the local recognition network in the recognition model to be trained, and use the model after the network parameters are updated as the recognition model to be trained, and re-execute the input of the picture samples of the training sample set into the recognition model to be trained, wherein the above-mentioned number of iterations is the number of times the parameters of the global recognition network and the local recognition network in the recognition model to be trained are updated;
[0127] When the first weighted loss does not meet the preset conditions and the number of iterations reaches the preset number, the parameters of the feature extraction network are set to an updateable state, and the parameters of the feature extraction network, the global recognition network and the local recognition network in the recognition model to be trained are updated. The model after the network parameters are updated is used as the recognition model to be trained, and the image samples of the training sample set are input into the recognition model to be trained again until the first weighted loss meets the preset conditions to obtain the image recognition model.
[0128] Based on this, by first fixing the parameters of the feature extraction network, the parameters of the global recognition network and the local recognition network are iteratively updated through the above-mentioned first weighted loss, and after a preset number of iterations, the parameters of the feature extraction network are released, so that when the first weighted loss does not meet the preset conditions, the parameters of the feature extraction network, the global recognition network and the local recognition network continue to be updated, and the recognition model to be trained is updated through multi-task weighted learning training, thereby reducing the complexity of the model training process and improving the efficiency of model training.
[0129] It should be noted that the above-mentioned judgment of whether the first weighted loss meets the preset conditions can also be a judgment in the electronic device whether the first weighted loss is less than or equal to the preset loss, or whether the difference between the above-mentioned first weighted loss and the weighted loss calculated in the previous iteration is less than or equal to the preset difference. If so, it is determined that the first weighted loss meets the preset conditions; otherwise, the first weighted loss does not meet the preset conditions.
[0130] For example, Figure 2 The following is an example of a recognition model to be trained including a shared backbone network (i.e., a feature extraction network), a target detection branch network, and a classification branch network. The training of the recognition network to be trained for the image may specifically include the following steps:
[0131] Step S11, set hyperparameters, initialize the loss weights of the classification branch network and the target detection branch network. Load the pre-trained shared backbone network weights (i.e., the parameters of the feature extraction network), and input the labeled data;
[0132] Step S12: setting the weight of the shared backbone network to a fixed state, calculating the weighted loss of the target detection branch network and the classification branch network (i.e., the first weighted loss), and using a preset optimization method (such as a gradient descent method, etc.) to update the parameters of the target detection branch network and the classification branch network according to the above loss;
[0133] Step S13, after iterating some rounds (i.e., the preset number of times), the weights of the shared backbone network are set to an updateable state, the labeled data continues to be input into the recognition model to be trained, the weighted losses of the classification branch network and the target detection branch network are calculated, and when the weighted loss does not meet the preset conditions (such as the weighted loss is less than or equal to the preset loss, etc.), the parameters of the backbone network, the target detection branch network, and the classification branch network are updated at the same time.
[0134] Step S14, after iterating several rounds of steps S12 and S13 respectively, until the calculated weighted loss reaches the preset condition, the optimal model (i.e., the trained image recognition model) is obtained.
[0135] Of course, the parameters of the feature extraction network, the global recognition network, and the local recognition network are continuously iterated and updated until the training stop condition is reached to obtain the above-mentioned image recognition model. Alternatively, the parameters of the image recognition model may be updated by alternating training. Specifically, the above-mentioned training sample set includes at least one first image sample and at least one second image sample, and the first image sample corresponds to the global recognition network, and the second image sample corresponds to the local recognition network;
[0136] Before obtaining the image to be identified and inputting the image to be identified into the image recognition model, the following steps may also be included:
[0137] When the parameters of the first recognition network in the recognition model to be trained are fixed, the picture samples corresponding to the second recognition network in the training sample set are input into the second recognition network, and the loss of the second recognition network is calculated, wherein the first recognition network is any one of the global recognition network and the local recognition network, and the second recognition network is a recognition network other than the first recognition network in the global recognition network and the local recognition network;
[0138] When the loss of the second recognition network does not reach the preset condition, update the parameters of the feature extraction network and the second recognition network in the recognition model to be trained, and re-enter the image samples corresponding to the second recognition network in the training sample set into the second recognition network;
[0139] When the loss of the second recognition network reaches a preset condition, the parameters of the first recognition network are set to an updated state and the parameters of the second recognition network are set to a fixed state, and the image samples corresponding to the first recognition network in the training sample set are input into the first recognition network to calculate the loss of the first recognition network;
[0140] When the loss of the first recognition network does not reach the preset condition, the parameters of the feature extraction network and the first recognition network in the recognition model to be trained are updated, and the image samples corresponding to the first recognition network in the training sample set are input into the first recognition network again until the loss of the first recognition network reaches the preset condition, thereby obtaining the image recognition model.
[0141] Based on this, the above-mentioned image recognition model can be trained by alternating training, so that the method of training the image recognition model is more flexible and diverse, and the accuracy of the trained image recognition model is improved.
[0142] Among them, the above-mentioned first image sample corresponds to the global recognition network, which can be understood as the first image sample being an image sample marked with whether the global image is abnormal; the above-mentioned second image sample corresponds to the local recognition network, which can be understood as the second image sample being an image sample marked with whether the local image is abnormal.
[0143] In addition, the image samples corresponding to the first recognition network and the picture samples corresponding to the second recognition network in the above-mentioned training sample set may include: when the first recognition network is a global recognition network and the second recognition network is a local recognition network, the image samples corresponding to the first recognition network are the above-mentioned first image samples, and the picture samples corresponding to the second recognition network are the above-mentioned second image samples; or, when the first recognition network is a local recognition network and the second recognition network is a global recognition network, the image samples corresponding to the first recognition network are the above-mentioned second image samples, and the picture samples corresponding to the second recognition network are the above-mentioned first image samples.
[0144] It should be noted that the image samples corresponding to the first recognition network and the second recognition network in the above-mentioned training sample set can be image samples in the training sample set in which the global image and the local image are annotated at the same time.
[0145] For example, Figure 2 The identification model to be trained including a shared backbone network (i.e., a feature extraction network), a classification branch network, and a target detection branch network is taken as an example for explanation, wherein the training of the identification network to be trained may specifically include the following steps:
[0146] Step S21, setting the parameters of the classification branch network (the first recognition network is the classification branch network at this time) to a fixed state, inputting the image samples of the first data set (i.e., the data set including the at least one second image sample) into the target detection network (the second recognition network is the target detection branch network at this time), and when the loss of the target detection network does not reach the preset condition (such as the loss of the target detection network is less than or equal to the preset loss or tends to be unchanged), updating the parameters of the shared backbone network and the parameters of the target detection branch network, and re-implementing the input of the image samples of the first data set into the target detection network until the loss of the target detection branch network reaches the preset condition, wherein the local image of the image sample of the first data set is labeled;
[0147] Step S22, setting the parameters of the target detection branch network (the first recognition network is the target detection branch network at this time) to a fixed state and the parameters of the classification branch network (the second recognition network is the classification branch network at this time) to an update state, inputting image samples of the second data set (i.e., a data set including at least one first image sample) into the classification branch network, and when the loss of the classification branch network does not reach a preset condition, updating the parameters of the shared backbone network and the parameters of the classification branch network, and re-inputting the image samples of the second data set into the classification branch network until the loss of the classification branch network reaches a preset condition and stops, wherein the global image of the image samples of the second data set is labeled;
[0148] Step S23: The model obtained when the loss of the classification branch network reaches the preset conditions is used as the above-mentioned image recognition model.
[0149] It should be noted that the above training iteration stopping condition can be that when the global recognition network and the local recognition network meet the preset conditions respectively, the parameter update of the network in the training recognition model is stopped to obtain the above image recognition model.
[0150] Furthermore, when the loss of the first recognition network does not reach the preset condition, updating the parameters of the feature extraction network and the first recognition network in the recognition model to be trained, and re-inputting the picture samples corresponding to the first recognition network in the training sample set into the first recognition network until the loss of the first recognition network reaches the preset condition, and obtaining the picture recognition model may include:
[0151] When the loss of the first recognition network does not reach the preset condition, update the parameters of the feature extraction network and the first recognition network in the recognition model to be trained, and re-enter the image samples corresponding to the first recognition network in the training sample set into the first recognition network;
[0152] When the loss of the first recognition network meets the preset conditions, the parameters of the second recognition network are set to an update state, and the parameters of the feature extraction network, the first recognition network and the second recognition network in the recognition model to be trained are updated, and the model after the parameter update is used as the recognition model to be trained;
[0153] Input any image sample in the training sample set into the recognition model to be trained, and calculate the second weighted loss of the first recognition network and the second recognition network;
[0154] When the second weighted loss does not meet the preset conditions, the parameters of the feature extraction network, the first recognition network and the second recognition network in the recognition model to be trained are updated, and the model with updated parameters is used as the recognition model to be trained. Any image sample in the training sample set is input into the recognition model to be trained again until the second weighted loss meets the preset conditions to obtain the image recognition model.
[0155] Based on this, after the global recognition network and the local recognition network meet the preset conditions respectively, it is further judged whether the weighted losses of the global recognition network and the local recognition network meet the preset conditions, and when the weighted loss meets the preset conditions, the final image recognition model is obtained to further improve the prediction accuracy of the image recognition model.
[0156] Exemplarily, after the loss of the classification branch network reaches a preset condition in the above step S22, S23 may be further performed:
[0157] Step S23, setting the parameters of the classification branch network and the target detection branch network to be in an update state, inputting the picture samples in the third data set into the classification branch network and the target detection branch network respectively, if the weighted loss of the classification branch network and the target detection branch network does not reach the preset condition, then updating the parameters of the shared backbone network, the parameters of the target detection branch network and the parameters of the classification branch network, and re-executing the picture samples in the third data set (i.e., the data set including the picture samples corresponding to the first recognition network and the second recognition network) into the classification branch network and the target detection branch network respectively, executing the training process until the weighted loss of the classification branch network and the target detection branch network reaches the preset condition, wherein the global image and the local image of the image samples of the third data set are both labeled;
[0158] At this time, the above step 23 may include: using a model obtained when the weighted loss of the classification branch network and the loss of the target detection branch network reaches a preset condition as the above image recognition model.
[0159] Step 103: input the multi-scale features into a global recognition network to identify first type information of the picture to be recognized, and / or input the multi-scale features into a local recognition network to identify second type information of the picture to be recognized, wherein the first type information is used to indicate whether the global image of the picture to be recognized is abnormal, and the second type information is used to indicate whether the local image of the picture to be recognized is abnormal.
[0160] The first type of information and the second type of information are information output by the global recognition network and the local recognition network, respectively, and the first type of information is used to indicate whether the global image of the picture to be recognized is abnormal, and the second type of information is used to indicate whether the local image of the picture to be recognized is abnormal. Specifically, the first type of information and the second type of information can be the output results of the output layer of the corresponding recognition network, such as confidence, etc.
[0161] In addition, at least one recognition network used in the above-mentioned image recognition model to identify the image to be recognized can be determined in the global recognition network and the local recognition network according to preset instructions. The preset instructions can be triggered by the user's operation, or can be automatically triggered by the electronic device, which is not limited here.
[0162] For example, when the electronic device displays a configuration interface of a picture recognition model, if the user inputs an operation to select the global recognition network control displayed in the configuration interface, then when the picture to be recognized is output to the picture recognition model, the picture to be recognized is recognized through the global recognition network of the picture recognition model; if the user inputs an operation to select the local recognition network control displayed in the configuration interface, then when the picture to be recognized is output to the picture recognition model, the picture to be recognized is recognized through the local recognition network of the picture recognition model. If the user inputs an operation to select the local recognition network control and the global recognition network control displayed in the configuration interface, then when the picture to be recognized is output to the picture recognition model, the picture to be recognized is recognized through the local recognition network and the global recognition network control of the picture recognition model.
[0163] Step 104: When the first type information indicates an abnormality and / or the second type information indicates an abnormality, determine that the image to be identified is an abnormal image.
[0164] Among them, after obtaining at least one type of information among the above-mentioned first type information and second type information, the image recognition model can compare each type of information with its corresponding preset type information, and determine whether the type information indicates normal or abnormal based on the comparison result.
[0165] For example, when the first type of information is the first confidence level, the first confidence level is compared with a preset confidence interval of the global image. If the first confidence level is within the preset confidence interval corresponding to the global recognition network, it is determined that the first type of information indicates an abnormality; otherwise, it is normal. When the second type of information is the second confidence level, the second confidence level is compared with at least one preset confidence interval corresponding to the local recognition network. In the at least one confidence interval, different confidence intervals may be confidence intervals corresponding to different types of local images, such as confidence intervals corresponding to the chest, buttocks, and triangular area, respectively. If the second confidence level is within the confidence interval corresponding to the chest, the second type of information indicates an abnormality caused by exposed chest, and so on.
[0166] In addition, when at least one of the first type information and the second type information indicates abnormality, the electronic device determines that the image to be identified is an abnormal image. Of course, when both the first type information and the second type information indicate normality, the electronic device can determine that the image to be identified is a normal image.
[0167] It should be noted that, when determining that the above-mentioned picture to be identified is an abnormal picture or a normal picture, the electronic device can also label the picture to be identified as an abnormal picture or a normal picture, and when there is a local image abnormality in the abnormal picture, the abnormal local image can also be labeled, such as by framing the abnormal image area. For example, when the above-mentioned target detection branch network detects that there is an image area with exposed breasts in the image of a person, the target detection network can frame the image area where the exposed breasts are located, and add a label of the framed image area as exposed breasts.
[0168] Based on this, the multi-scale features are extracted by inputting the image to be identified into the feature extraction network of the image recognition model, and the extracted multi-scale features are input into at least one of the local recognition network and the local recognition network of the image recognition model, and the at least one recognition network is used to respectively determine whether the image to be identified is an abnormal image. In this way, through the image recognition method of the embodiment of the present application, in the process of image recognition, the image type of the image to be identified can be identified without manual labeling, reducing the workload of image recognition, thereby improving the efficiency of image recognition; in addition, it is also possible to recognize the image to be identified from the overall and local aspects, making image recognition more flexible and convenient.
[0169] Figure 4 The figure is a schematic diagram showing the structure of a picture recognition device according to an exemplary embodiment.
[0170] like Figure 4 As shown, the image recognition device 400 may specifically include:
[0171] The picture acquisition module 401 is configured to acquire a picture to be identified;
[0172] The multi-scale feature extraction module 402 is configured to input the picture to be identified into a feature extraction network of a picture recognition model, and extract multi-scale features through the feature extraction network, wherein the picture recognition model includes the feature extraction network and a global recognition network and a local recognition network connected to the feature extraction network, and the global recognition network is used to identify the picture type based on the global image features of the picture, and the local recognition network is used to identify the picture type based on the local image features of the picture, and the multi-scale features include the global image features and the local image features of the picture to be identified;
[0173] The recognition module 403 is configured to input the multi-scale features into the global recognition network to identify the first type of information of the picture to be recognized, and / or input the multi-scale features into the local recognition network to identify the second type of information of the picture to be recognized, wherein the first type of information is used to indicate whether the global image of the picture to be recognized is abnormal, and the second type of information is used to indicate whether the local image of the picture to be recognized is abnormal;
[0174] The abnormal picture determination module 404 is configured to determine that the picture to be identified is an abnormal picture when the first type information indicates an abnormality and / or the second type information indicates an abnormality.
[0175] Based on this, the multi-scale features are extracted by inputting the image to be identified into the feature extraction network of the image recognition model, and the extracted multi-scale features are input into at least one of the local recognition network and the local recognition network of the image recognition model, and the at least one recognition network is used to respectively determine whether the image to be identified is an abnormal image. In this way, through the image recognition method of the embodiment of the present application, in the process of image recognition, the image type of the image to be identified can be identified without manual labeling, reducing the workload of image recognition, thereby improving the efficiency of image recognition; in addition, it is also possible to recognize the image to be identified from the overall and local aspects, making image recognition more flexible and convenient.
[0176] In one embodiment, the apparatus 400 further includes:
[0177] A training set acquisition module is configured to acquire a training sample set;
[0178] A weighted loss calculation module is configured to input the image samples of the training sample set into the recognition model to be trained including the feature extraction network, the global recognition network and the local recognition network, and calculate the first weighted loss of the global recognition network and the local recognition network;
[0179] The first training module is configured to update the parameters of each network in the recognition model to be trained when the first weighted loss does not meet the preset conditions, and use the model after the network parameters are updated as the recognition model to be trained, and re-execute the input of the image samples of the training sample set into the recognition model to be trained until the first weighted loss meets the preset conditions to obtain the image recognition model.
[0180] Based on this, the recognition model to be trained, including the feature extraction network, the global recognition network and the local recognition network, is trained through the training sample set, and during the training process, the parameters of each network in the model to be trained are updated through the weighted losses of the global recognition network and the local recognition network, which can not only improve the recognition accuracy of the image recognition model, but also reduce the complexity of model training, thereby accelerating the efficiency of model training.
[0181] In one embodiment, the first training module includes:
[0182] A first parameter updating unit is configured to update the parameters of the global recognition network and the local recognition network in the recognition model to be trained, and use the model after the network parameters are updated as the recognition model to be trained, and re-execute inputting the picture samples of the training sample set into the recognition model to be trained, when the parameters of the feature extraction network of the recognition model to be trained are in a fixed state and if the first weighted loss does not meet the preset conditions and the number of iterations does not reach the preset number, wherein the number of iterations is the number of times the parameters of the global recognition network and the local recognition network in the recognition model to be trained are updated;
[0183] The second parameter updating unit is configured to set the parameters of the feature extraction network to an updateable state and update the parameters of the feature extraction network, the global recognition network and the local recognition network in the recognition model to be trained when the first weighted loss does not meet the preset condition and the number of iterations reaches the preset number, and use the model after the network parameters are updated as the recognition model to be trained, and re-execute the input of the image samples of the training sample set into the recognition model to be trained until the first weighted loss meets the preset condition to obtain the image recognition model.
[0184] Based on this, by first fixing the parameters of the feature extraction network, the parameters of the global recognition network and the local recognition network are iteratively updated through the above-mentioned first weighted loss, and after a preset number of iterations, the parameters of the feature extraction network are released, so that when the first weighted loss does not meet the preset conditions, the parameters of the feature extraction network, the global recognition network and the local recognition network continue to be updated, and the recognition model to be trained is updated through multi-task weighted learning training, thereby reducing the complexity of the model training process and improving the efficiency of model training.
[0185] In one embodiment, the training sample set includes at least one first picture sample and at least one second picture sample, and the first picture sample corresponds to the global recognition network, and the second picture sample corresponds to the local recognition network;
[0186] The device 400 further includes:
[0187] A first loss calculation module is configured to input the picture samples corresponding to the second recognition network in the training sample set into the second recognition network when the parameters of the first recognition network in the recognition model to be trained are fixed, and calculate the loss of the second recognition network, wherein the first recognition network is any one of the global recognition network and the local recognition network, and the second recognition network is a recognition network other than the first recognition network in the global recognition network and the local recognition network;
[0188] A first parameter module is configured to update the parameters of the feature extraction network and the second recognition network in the recognition model to be trained, and re-enter the image samples corresponding to the second recognition network in the training sample set into the second recognition network when the loss of the second recognition network does not meet the preset condition;
[0189] A second loss calculation module is configured to set the parameters of the first recognition network to an updated state and the parameters of the second recognition network to a fixed state when the loss of the second recognition network reaches the preset condition, and input the image samples corresponding to the first recognition network in the training sample set into the first recognition network to calculate the loss of the first recognition network;
[0190] The second parameter updating module is configured to update the parameters of the feature extraction network and the first recognition network in the recognition model to be trained when the loss of the first recognition network does not reach the preset condition, and re-enter the image samples corresponding to the first recognition network in the training sample set into the first recognition network until the loss of the first recognition network reaches the preset condition, thereby obtaining the image recognition model.
[0191] Based on this, the above-mentioned image recognition model can be trained by alternating training, so that the method of training the image recognition model is more flexible and diverse, and the accuracy of the trained image recognition model is improved.
[0192] In one embodiment, the second parameter updating module includes:
[0193] A third parameter updating unit is configured to update the parameters of the feature extraction network and the first recognition network in the recognition model to be trained, and re-enter the picture samples in the training sample set corresponding to the first recognition network into the first recognition network when the loss of the first recognition network does not reach the preset condition;
[0194] a fourth parameter updating unit, configured to set the parameters of the second recognition network to an updated state when the loss of the first recognition network meets the preset condition, and update the parameters of the feature extraction network, the first recognition network and the second recognition network in the recognition model to be trained, and use the model after the parameter update as the recognition model to be trained;
[0195] A weighted loss calculation unit, configured to input the picture samples corresponding to the first recognition network and the second recognition network in the training sample set into the recognition model to be trained, and calculate the second weighted loss of the first recognition network and the second recognition network;
[0196] The fifth parameter updating unit is configured to update the parameters of the feature extraction network, the first recognition network and the second recognition network in the recognition model to be trained when the second weighted loss does not meet the preset condition, and use the model after parameter update as the recognition model to be trained, and re-input the image samples corresponding to the first recognition network and the second recognition network in the training sample set into the recognition model to be trained until the second weighted loss meets the preset condition to obtain the image recognition model.
[0197] Based on this, after the global recognition network and the local recognition network meet the preset conditions respectively, it is further judged whether the weighted losses of the global recognition network and the local recognition network meet the preset conditions, and when the weighted loss meets the preset conditions, the final image recognition model is obtained to further improve the prediction accuracy of the image recognition model.
[0198] In one embodiment, the training set acquisition module includes:
[0199] A sample set acquisition unit, configured to acquire a first sample set and a second sample set, wherein the first sample set includes labeled picture samples, and the second sample set includes unlabeled picture samples;
[0200] A training unit is configured to input the first sample set into the M-1th recognition model to obtain the Mth recognition model through training, wherein M is a positive integer;
[0201] a labeling unit, configured to input the picture samples in the second sample set into the Mth recognition model to label the input picture samples, and add the labeled picture samples to the first sample set;
[0202] a training resetting unit, configured to, when the M recognition models do not satisfy the training stop condition, use the Mth recognition model as the M-1th recognition model, and re-execute inputting the first sample set into the M-1th recognition model;
[0203] The sample set output unit is configured to use the first sample set as the training sample set when the M recognition models meet the training stop condition.
[0204] Based on this, in the process of training the recognition model, the recognition model to be trained is trained by a first sample set including labeled image samples, and the unlabeled image samples are labeled by the trained recognition model, and the labeled samples are added to the first sample set until the trained recognition model meets the training stop condition. The first sample set is used as the above-mentioned training sample set to obtain the training sample set in a semi-supervised manner, thereby reducing the workload of obtaining the training sample set and improving the efficiency of obtaining the training sample set.
[0205] Based on the same inventive concept, the present disclosure also provides a computing device, specifically in combination with Figure 5 Provide detailed explanation.
[0206] Figure 5 It is a structural block diagram of a computing device according to an exemplary embodiment.
[0207] like Figure 5 As shown, the computing device 500 is a structural diagram of an exemplary hardware architecture of a computing device that can implement the image recognition method and the image recognition apparatus in the embodiments of the present disclosure. The computing device may refer to the electronic device in the embodiments of the present disclosure.
[0208] The computing device 500 may include a processor 501 and a memory 602 storing computer program instructions.
[0209] Specifically, the processor 501 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0210] The memory 502 may include a large capacity memory for information or instructions. By way of example and not limitation, the memory 502 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 502 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 502 may be inside or outside the integrated gateway device. In a particular embodiment, the memory 502 is a non-volatile solid-state memory. In a particular embodiment, the memory 502 includes a read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM), or a flash memory, or a combination of two or more of these.
[0211] The processor 501 reads and executes the computer program instructions stored in the memory 502 to perform the following steps:
[0212] Processor 501 executes obtaining a picture to be identified;
[0213] Inputting the picture to be identified into a feature extraction network of a picture recognition model, and extracting multi-scale features through the feature extraction network, wherein the picture recognition model includes the feature extraction network and a global recognition network and a local recognition network connected to the feature extraction network, and the global recognition network is used to identify the picture type based on the global image features of the picture, and the local recognition network is used to identify the picture type based on the local image features of the picture, and the multi-scale features include the global image features and the local image features of the picture to be identified;
[0214] Input the multi-scale features into the global recognition network to identify the first type of information of the picture to be recognized, and / or input the multi-scale features into the local recognition network to identify the second type of information of the picture to be recognized, wherein the first type of information is used to indicate whether the global image of the picture to be recognized is abnormal, and the second type of information is used to indicate whether the local image of the picture to be recognized is abnormal;
[0215] When the first type information indicates an abnormality and / or the second type information indicates an abnormality, it is determined that the picture to be identified is an abnormal picture.
[0216] Based on this, the multi-scale features are extracted by inputting the image to be identified into the feature extraction network of the image recognition model, and the extracted multi-scale features are input into at least one of the local recognition network and the local recognition network of the image recognition model, and the at least one recognition network is used to respectively determine whether the image to be identified is an abnormal image. In this way, through the image recognition method of the embodiment of the present application, in the process of image recognition, the image type of the image to be identified can be identified without manual labeling, reducing the workload of image recognition, thereby improving the efficiency of image recognition; in addition, it is also possible to recognize the image to be identified from the overall and local aspects, making image recognition more flexible and convenient.
[0217] In one embodiment, the processor 501 executes obtaining a training sample set;
[0218] Inputting the picture samples of the training sample set into the recognition model to be trained including the feature extraction network, the global recognition network and the local recognition network, and calculating the first weighted loss of the global recognition network and the local recognition network;
[0219] When the first weighted loss does not meet the preset conditions, the parameters of each network in the recognition model to be trained are updated, and the model after the network parameters are updated is used as the recognition model to be trained, and the image samples of the training sample set are re-inputted into the recognition model to be trained until the first weighted loss meets the preset conditions to obtain the image recognition model.
[0220] Based on this, the recognition model to be trained, including the feature extraction network, the global recognition network and the local recognition network, is trained through the training sample set, and during the training process, the parameters of each network in the model to be trained are updated through the weighted losses of the global recognition network and the local recognition network, which can not only improve the recognition accuracy of the image recognition model, but also reduce the complexity of model training, thereby accelerating the efficiency of model training.
[0221] In one embodiment, the processor 501 executes, when the parameters of the feature extraction network of the recognition model to be trained are fixed, if the first weighted loss does not meet the preset conditions and the number of iterations does not reach the preset number, updating the parameters of the global recognition network and the local recognition network in the recognition model to be trained, and using the model after the network parameters are updated as the recognition model to be trained, and re-entering the image samples of the training sample set into the recognition model to be trained, wherein the number of iterations is the number of times the parameters of the global recognition network and the local recognition network in the recognition model to be trained are updated;
[0222] When the first weighted loss does not meet the preset condition and the number of iterations reaches the preset number, the parameters of the feature extraction network are set to an updateable state, and the parameters of the feature extraction network, the global recognition network and the local recognition network in the recognition model to be trained are updated. The model after the network parameters are updated is used as the recognition model to be trained, and the image samples of the training sample set are input into the recognition model to be trained again until the first weighted loss meets the preset condition to obtain the image recognition model.
[0223] Based on this, by first fixing the parameters of the feature extraction network, the parameters of the global recognition network and the local recognition network are iteratively updated through the above-mentioned first weighted loss, and after a preset number of iterations, the parameters of the feature extraction network are released, so that when the first weighted loss does not meet the preset conditions, the parameters of the feature extraction network, the global recognition network and the local recognition network continue to be updated, and the recognition model to be trained is updated through multi-task weighted learning training, thereby reducing the complexity of the model training process and improving the efficiency of model training.
[0224] In one embodiment, the training sample set includes at least one first picture sample and at least one second picture sample, and the first picture sample corresponds to the global recognition network, and the second picture sample corresponds to the local recognition network;
[0225] Processor 501, when the parameters of the first recognition network in the recognition model to be trained are fixed, inputs the picture sample corresponding to the second recognition network in the training sample set into the second recognition network, and calculates the loss of the second recognition network, wherein the first recognition network is any one of the global recognition network and the local recognition network, and the second recognition network is a recognition network other than the first recognition network in the global recognition network and the local recognition network;
[0226] When the loss of the second recognition network does not reach a preset condition, updating the parameters of the feature extraction network and the second recognition network in the recognition model to be trained, and re-inputting the picture samples corresponding to the second recognition network in the training sample set into the second recognition network;
[0227] When the loss of the second recognition network reaches the preset condition, setting the parameters of the first recognition network to an update state and the parameters of the second recognition network to a fixed state, inputting the image samples corresponding to the first recognition network in the training sample set into the first recognition network, and calculating the loss of the first recognition network;
[0228] When the loss of the first recognition network does not reach the preset condition, the parameters of the feature extraction network and the first recognition network in the recognition model to be trained are updated, and the image samples corresponding to the first recognition network in the training sample set are input into the first recognition network again until the loss of the first recognition network reaches the preset condition, thereby obtaining the image recognition model.
[0229] Based on this, the above-mentioned image recognition model can be trained by alternating training, so that the method of training the image recognition model is more flexible and diverse, and the accuracy of the trained image recognition model is improved.
[0230] In one embodiment, the processor 501 executes, when the loss of the first recognition network does not reach the preset condition, updating the parameters of the feature extraction network and the first recognition network in the recognition model to be trained, and re-inputting the picture samples corresponding to the first recognition network in the training sample set into the first recognition network;
[0231] When the loss of the first recognition network meets the preset condition, the parameters of the second recognition network are set to an update state, and the parameters of the feature extraction network, the first recognition network and the second recognition network in the recognition model to be trained are updated, and the model after the parameter update is used as the recognition model to be trained;
[0232] Inputting the picture samples corresponding to the first recognition network and the second recognition network in the training sample set into the recognition model to be trained, and calculating the second weighted losses of the first recognition network and the second recognition network;
[0233] When the second weighted loss fails to meet the preset condition, the parameters of the feature extraction network, the first recognition network and the second recognition network in the recognition model to be trained are updated, and the model with updated parameters is used as the recognition model to be trained, and the image samples corresponding to the first recognition network and the second recognition network in the training sample set are re-inputted into the recognition model to be trained until the second weighted loss meets the preset condition to obtain the image recognition model.
[0234] Based on this, after the global recognition network and the local recognition network meet the preset conditions respectively, it is further judged whether the weighted losses of the global recognition network and the local recognition network meet the preset conditions, and when the weighted loss meets the preset conditions, the final image recognition model is obtained to further improve the prediction accuracy of the image recognition model.
[0235] In one embodiment, the processor 501 executes obtaining a first sample set and a second sample set, wherein the first sample set includes labeled picture samples, and the second sample set includes unlabeled picture samples;
[0236] Inputting the first sample set into the M-1th recognition model to obtain the Mth recognition model through training, wherein M is a positive integer;
[0237] Inputting the picture samples in the second sample set into the Mth recognition model to mark the input picture samples, and adding the marked picture samples to the first sample set;
[0238] In the case that the M recognition models do not meet the training stop condition, using the Mth recognition model as the M-1th recognition model, and re-implementing the first sample set into the M-1th recognition model;
[0239] When the M recognition models satisfy the training stop condition, the first sample set is used as the training sample set.
[0240] Based on this, in the process of training the recognition model, the recognition model to be trained is trained by a first sample set including labeled image samples, and the unlabeled image samples are labeled by the trained recognition model, and the labeled samples are added to the first sample set until the trained recognition model meets the training stop condition. The first sample set is used as the above-mentioned training sample set to obtain the training sample set in a semi-supervised manner, thereby reducing the workload of obtaining the training sample set and improving the efficiency of obtaining the training sample set.
[0241] In one example, the computing device 500 may further include a transceiver 503 and a bus 504. Figure 5As shown, the processor 501, the memory 502 and the transceiver 503 are connected via a bus 504 and communicate with each other.
[0242] Bus 504 includes hardware, software or both.For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industry standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industry standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral control interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 504 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the present application considers any suitable bus or interconnection.
[0243] The embodiment of the present disclosure further provides a computer-readable storage medium, in which computer-executable instructions are stored. The computer-executable instructions are used to implement the image recognition method described in the embodiment of the present disclosure.
[0244] In some possible implementations, various aspects of the method provided by the present disclosure may also be implemented in the form of a program product, which includes a program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of the method according to various exemplary embodiments of the present disclosure described above in this specification. For example, the computer device may execute the image recognition method recorded in the embodiments of the present disclosure.
[0245] The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0246] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices, and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable image transmission device to produce a machine, so that the instructions executed by the processor of the computer or other programmable image transmission device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0247] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable image transmission device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0248] These computer program instructions may also be loaded onto a computer or other programmable image transmission device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0249] Obviously, those skilled in the art can make various changes and modifications to the present disclosure without departing from the spirit and scope of the present disclosure. Thus, if these modifications and variations of the present disclosure fall within the scope of the claims of the present disclosure and their equivalents, the present disclosure is also intended to include these modifications and variations.
Claims
1. A method for image recognition, characterized in that: include: Get the image to be identified; Inputting the picture to be identified into a feature extraction network of a picture recognition model, and extracting multi-scale features through the feature extraction network, wherein the picture recognition model includes the feature extraction network and a global recognition network and a local recognition network connected to the feature extraction network, and the global recognition network is used to identify the picture type based on the global image features of the picture, and the local recognition network is used to identify the picture type based on the local image features of the picture, and the multi-scale features include the global image features and the local image features of the picture to be identified; Input the multi-scale features into the global recognition network to identify the first type of information of the picture to be recognized, and / or input the multi-scale features into the local recognition network to identify the second type of information of the picture to be recognized, wherein the first type of information is used to indicate whether the global image of the picture to be recognized is abnormal, and the second type of information is used to indicate whether the local image of the picture to be recognized is abnormal; When the first type information indicates an abnormality and / or the second type information indicates an abnormality, determining that the picture to be identified is an abnormal picture; The picture recognition model is obtained by training the recognition model to be trained with the training sample set; the recognition model to be trained also includes a first recognition network and a second recognition network; wherein the first recognition network is any one of the global recognition network and the local recognition network, and the second recognition network is a recognition network other than the first recognition network in the global recognition network and the local recognition network; Determining the image recognition model based on the training sample set and the recognition model to be trained includes: When the loss of the first recognition network does not reach a preset condition, updating the parameters of the feature extraction network and the first recognition network in the recognition model to be trained, and re-inputting the picture samples in the training sample set corresponding to the first recognition network into the first recognition network; When the loss of the first recognition network meets the preset condition, the parameters of the second recognition network are set to an update state, and the parameters of the feature extraction network, the first recognition network and the second recognition network in the recognition model to be trained are updated, and the model after the parameter update is used as the recognition model to be trained; Inputting the picture samples corresponding to the first recognition network and the second recognition network in the training sample set into the recognition model to be trained, and calculating the second weighted losses of the first recognition network and the second recognition network; When the second weighted loss fails to meet the preset condition, the parameters of the feature extraction network, the first recognition network and the second recognition network in the recognition model to be trained are updated, and the model with updated parameters is used as the recognition model to be trained, and the image samples corresponding to the first recognition network and the second recognition network in the training sample set are re-inputted into the recognition model to be trained until the second weighted loss meets the preset condition to obtain the image recognition model.
2. The method according to claim 1, characterized in that Before obtaining the image to be identified and inputting the image to be identified into the image recognition model, the process further includes: Obtain a training sample set; Inputting the picture samples of the training sample set into the recognition model to be trained including the feature extraction network, the global recognition network and the local recognition network, and calculating the first weighted loss of the global recognition network and the local recognition network; When the first weighted loss does not meet the preset conditions, the parameters of each network in the recognition model to be trained are updated, and the model after the network parameters are updated is used as the recognition model to be trained, and the image samples of the training sample set are re-inputted into the recognition model to be trained until the first weighted loss meets the preset conditions to obtain the image recognition model.
3. The method according to claim 2, characterized in that When the first weighted loss does not meet the preset condition, the parameters of each network in the recognition model to be trained are updated, and the model after the network parameters are updated is used as the recognition model to be trained, and the picture samples of the training sample set are input to the recognition model to be trained again until the first weighted loss meets the preset condition, so as to obtain the picture recognition model, including: In the case where the parameters of the feature extraction network of the recognition model to be trained are in a fixed state, if the first weighted loss does not meet the preset conditions and the number of iterations does not reach the preset number, update the parameters of the global recognition network and the local recognition network in the recognition model to be trained, and use the model after the network parameters are updated as the recognition model to be trained, and re-execute the input of the picture samples of the training sample set into the recognition model to be trained, wherein the number of iterations is the number of times the parameters of the global recognition network and the local recognition network in the recognition model to be trained are updated; When the first weighted loss does not meet the preset condition and the number of iterations reaches the preset number, the parameters of the feature extraction network are set to an updateable state, and the parameters of the feature extraction network, the global recognition network and the local recognition network in the recognition model to be trained are updated. The model after the network parameters are updated is used as the recognition model to be trained, and the image samples of the training sample set are input into the recognition model to be trained again until the first weighted loss meets the preset condition to obtain the image recognition model.
4. The method according to claim 2, characterized in that: Before obtaining the image to be identified and inputting the image to be identified into the image recognition model, the process further includes: When the parameters of the first recognition network in the recognition model to be trained are fixed, inputting the picture samples corresponding to the second recognition network in the training sample set into the second recognition network, and calculating the loss of the second recognition network; When the loss of the second recognition network does not reach a preset condition, updating the parameters of the feature extraction network and the second recognition network in the recognition model to be trained, and re-inputting the picture samples corresponding to the second recognition network in the training sample set into the second recognition network; When the loss of the second recognition network reaches the preset condition, setting the parameters of the first recognition network to an update state and the parameters of the second recognition network to a fixed state, inputting the image samples corresponding to the first recognition network in the training sample set into the first recognition network, and calculating the loss of the first recognition network; When the loss of the first recognition network does not reach the preset condition, the parameters of the feature extraction network and the first recognition network in the recognition model to be trained are updated, and the image samples corresponding to the first recognition network in the training sample set are input into the first recognition network again until the loss of the first recognition network reaches the preset condition, thereby obtaining the image recognition model.
5. The method according to claim 2 or 4, characterized in that: The step of obtaining a training sample set includes: Acquire a first sample set and a second sample set, wherein the first sample set includes labeled picture samples, and the second sample set includes unlabeled picture samples; Inputting the first sample set into the M-1th recognition model to obtain the Mth recognition model through training, wherein M is a positive integer; Inputting the picture samples in the second sample set into the Mth recognition model to mark the input picture samples, and adding the marked picture samples to the first sample set; In the case that the M recognition models do not meet the training stop condition, using the Mth recognition model as the M-1th recognition model, and re-implementing the first sample set into the M-1th recognition model; When the M recognition models satisfy the training stop condition, the first sample set is used as the training sample set.
6. A picture recognition device, characterized in that: include: An image acquisition module is configured to acquire an image to be identified; a multi-scale feature extraction module, configured to input the picture to be identified into a feature extraction network of a picture recognition model, and extract multi-scale features through the feature extraction network, wherein the picture recognition model includes the feature extraction network and a global recognition network and a local recognition network connected to the feature extraction network, and the global recognition network is used to identify the picture type based on the global image features of the picture, and the local recognition network is used to identify the picture type based on the local image features of the picture, and the multi-scale features include the global image features and the local image features of the picture to be identified; The recognition module is configured to input the multi-scale features into the global recognition network to identify the first type of information of the picture to be recognized, and / or input the multi-scale features into the local recognition network to identify the second type of information of the picture to be recognized, wherein the first type of information is used to indicate whether the global image of the picture to be recognized is abnormal, and the second type of information is used to indicate whether the local image of the picture to be recognized is abnormal; an abnormal picture determination module, configured to determine that the picture to be identified is an abnormal picture when the first type information indicates an abnormality and / or the second type information indicates an abnormality; The picture recognition model is obtained by training the recognition model to be trained with the training sample set; the recognition model to be trained also includes a first recognition network and a second recognition network; wherein the first recognition network is any one of the global recognition network and the local recognition network, and the second recognition network is a recognition network other than the first recognition network in the global recognition network and the local recognition network; Determining the image recognition model based on the training sample set and the recognition model to be trained includes: When the loss of the first recognition network does not reach a preset condition, updating the parameters of the feature extraction network and the first recognition network in the recognition model to be trained, and re-inputting the picture samples in the training sample set corresponding to the first recognition network into the first recognition network; When the loss of the first recognition network meets the preset condition, the parameters of the second recognition network are set to an update state, and the parameters of the feature extraction network, the first recognition network and the second recognition network in the recognition model to be trained are updated, and the model after the parameter update is used as the recognition model to be trained; Inputting the picture samples corresponding to the first recognition network and the second recognition network in the training sample set into the recognition model to be trained, and calculating the second weighted losses of the first recognition network and the second recognition network; When the second weighted loss fails to meet the preset condition, the parameters of the feature extraction network, the first recognition network and the second recognition network in the recognition model to be trained are updated, and the model with updated parameters is used as the recognition model to be trained, and the image samples corresponding to the first recognition network and the second recognition network in the training sample set are re-inputted into the recognition model to be trained until the second weighted loss meets the preset condition to obtain the image recognition model.
7. The device according to claim 6, characterized in that The device further comprises: A training set acquisition module is configured to acquire a training sample set; A weighted loss calculation module is configured to input the image samples of the training sample set into the recognition model to be trained including the feature extraction network, the global recognition network and the local recognition network, and calculate the first weighted loss of the global recognition network and the local recognition network; The first training module is configured to update the parameters of each network in the recognition model to be trained when the first weighted loss does not meet the preset conditions, and use the model after the network parameters are updated as the recognition model to be trained, and re-execute the input of the image samples of the training sample set into the recognition model to be trained until the first weighted loss meets the preset conditions to obtain the image recognition model.
8. The device according to claim 7, characterized in that The first training module includes: A first parameter updating unit is configured to update the parameters of the global recognition network and the local recognition network in the recognition model to be trained, and use the model after the network parameters are updated as the recognition model to be trained, and re-execute inputting the picture samples of the training sample set into the recognition model to be trained, when the parameters of the feature extraction network of the recognition model to be trained are in a fixed state and if the first weighted loss does not meet the preset conditions and the number of iterations does not reach the preset number, wherein the number of iterations is the number of times the parameters of the global recognition network and the local recognition network in the recognition model to be trained are updated; The second parameter updating unit is configured to set the parameters of the feature extraction network to an updateable state and update the parameters of the feature extraction network, the global recognition network and the local recognition network in the recognition model to be trained when the first weighted loss does not meet the preset condition and the number of iterations reaches the preset number, and use the model after the network parameters are updated as the recognition model to be trained, and re-execute the input of the image samples of the training sample set into the recognition model to be trained until the first weighted loss meets the preset condition to obtain the image recognition model.
9. The device according to claim 7, characterized in that The device further comprises: A first loss calculation module is configured to input the picture samples corresponding to the second recognition network in the training sample set into the second recognition network when the parameters of the first recognition network in the recognition model to be trained are fixed, and calculate the loss of the second recognition network, wherein the first recognition network is any one of the global recognition network and the local recognition network, and the second recognition network is a recognition network other than the first recognition network in the global recognition network and the local recognition network; A first parameter module is configured to update the parameters of the feature extraction network and the second recognition network in the recognition model to be trained, and re-enter the image samples corresponding to the second recognition network in the training sample set into the second recognition network when the loss of the second recognition network does not meet the preset condition; A second loss calculation module is configured to set the parameters of the first recognition network to an updated state and the parameters of the second recognition network to a fixed state when the loss of the second recognition network reaches the preset condition, and input the image samples corresponding to the first recognition network in the training sample set into the first recognition network to calculate the loss of the first recognition network; The second parameter updating module is configured to update the parameters of the feature extraction network and the first recognition network in the recognition model to be trained when the loss of the first recognition network does not reach the preset condition, and re-enter the image samples corresponding to the first recognition network in the training sample set into the first recognition network until the loss of the first recognition network reaches the preset condition, thereby obtaining the image recognition model.
10. The device according to claim 7 or 9, characterized in that The training set acquisition module comprises: A sample set acquisition unit, configured to acquire a first sample set and a second sample set, wherein the first sample set includes labeled picture samples, and the second sample set includes unlabeled picture samples; A training unit is configured to input the first sample set into the M-1th recognition model to obtain the Mth recognition model through training, wherein M is a positive integer; a labeling unit, configured to input the picture samples in the second sample set into the Mth recognition model to label the input picture samples, and add the labeled picture samples to the first sample set; a training resetting unit, configured to, when the M recognition models do not satisfy the training stop condition, use the Mth recognition model as the M-1th recognition model, and re-execute inputting the first sample set into the M-1th recognition model; The sample set output unit is configured to use the first sample set as the training sample set when the M recognition models meet the training stop condition.
11. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the image recognition method as described in any one of claims 1 to 5.
12. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an image recognition device or an electronic device, the image recognition device or the electronic device implements the image recognition method as claimed in any one of claims 1 to 5.
13. A computer program product, comprising a computer program or instructions, characterized in that: When the computer program or instruction is executed by a processor, the image recognition method according to any one of claims 1 to 5 is implemented.
