Method for constructing a copy image recognition model and method for copy image recognition
By constructing a multi-level remake image recognition model and using initial and complex sample image data for training, the problem of low accuracy of traditional remake image recognition technology is solved, and a higher remake image recognition accuracy is achieved.
Patent Information
- Application Number
- CN202011214074.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-04
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2040-11-04
AI Technical Summary
Traditional remake image recognition technology has the problem of low judgment accuracy.
By constructing a remake image recognition model that includes a first classification model layer directed by classification speed and a second classification model layer directed by classification accuracy, model training is performed using initial sample image data and complex sample image data, comprehensive loss functions are generated and model parameters are updated to improve the accuracy of remake judgment.
It significantly improves the accuracy of remake image recognition, can more accurately identify remake images, reduce error information input, and improve picture normativeness.
Smart Images

Figure CN114529774B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method for constructing a reshot image recognition model and a reshot image recognition method. Background Art
[0002] With the development of computer technology, duplicate image recognition technology has emerged. Duplicate image recognition technology is mainly used to identify duplicate images taken with mobile phones from images to be processed, reduce the input of erroneous information caused by illegal shooting, and improve the standardization of images to be processed.
[0003] In traditional technology, traditional feature extraction algorithms are often used to identify copied images, or the original copied image needs to be provided to determine whether it is a copied image by comparing the image similarity.
[0004] However, traditional technologies all have the problem of low accuracy in judging remakes. Summary of the invention
[0005] Based on this, it is necessary to provide a method for constructing a duplicate image recognition model and a duplicate image recognition method that can improve the accuracy of duplicate judgment in order to address the above technical problems.
[0006] A method for constructing a re-shot image recognition model, the method comprising:
[0007] Acquire initial sample image data carrying category labels and an initial re-shot image recognition model, wherein the initial re-shot image recognition model includes a first classification model layer oriented toward classification speed and a second classification model layer oriented toward classification accuracy;
[0008] Inputting the initial sample image data into the first classification model layer to obtain a first loss function and complex sample image data with classification errors;
[0009] According to the complex sample image data and the initial sample image data, a second classification model layer is trained to obtain a second loss function;
[0010] According to the first loss function and the second loss function, a comprehensive loss function of the initial reshot image recognition model is obtained, and the model parameters of the initial reshot image recognition model are updated by back propagation according to the comprehensive loss function to obtain a trained reshot image recognition model.
[0011] In one embodiment, the initial sample image data is input into the first classification model layer, and the first loss function is obtained including:
[0012] Inputting the initial sample image data into the first classification model layer to obtain a first classification result corresponding to each initial sample image in the initial sample image data;
[0013] Determine a first loss value corresponding to each initial sample image according to the first classification result and the category label;
[0014] Determine, according to the category label, a first positive-negative sample ratio corresponding to the initial sample image data, and determine, according to the first positive-negative sample ratio, a first loss weight corresponding to each first loss value;
[0015] A first loss function is obtained according to the first loss value and the first loss weight.
[0016] In one embodiment, the second classification model layer is trained according to the complex sample image data and the initial sample image data to obtain the second loss function, which includes:
[0017] Adding the complex sample image data to the initial sample image data to obtain the target sample image data carrying the target category label;
[0018] According to the target sample image data, the second classification model layer is trained to obtain the second loss function.
[0019] In one embodiment, according to the target sample image data, training the second classification model layer to obtain the second loss function includes:
[0020] Input the target sample image data into the second classification model layer to obtain a second classification result corresponding to each target sample image data in the target sample image data;
[0021] Determine a second loss value corresponding to each target sample image according to the second classification result and the target category label;
[0022] Determine, according to the target category label, a second positive-negative sample ratio corresponding to the target sample image data, and determine, according to the second positive-negative sample ratio, a second loss weight corresponding to each second loss value;
[0023] A second loss function is obtained according to the second loss value and the second loss weight.
[0024] A method for identifying a re-shot image, the method comprising:
[0025] Get the image to be identified;
[0026] The image to be identified is input into a trained reproduced image recognition model to obtain a recognition result corresponding to the image to be identified. The trained reproduced image recognition model is constructed according to the reproduced image recognition model construction method described above.
[0027] In one embodiment, the image to be identified is input into a trained re-photographed image recognition model, and the recognition result corresponding to the image to be identified is obtained, including:
[0028] Inputting the image to be identified into the first classification model layer of the trained re-photographed image recognition model to obtain a first classification result;
[0029] When the first classification result is a remake, the image to be identified is input into the second classification model layer in the trained remake image recognition model to obtain a second classification result;
[0030] When the second classification result is a remake, the identification result is a remake.
[0031] In one embodiment, the method further includes: when the first classification result is non-copy or the second classification result is non-copy, obtaining a recognition result of non-copy.
[0032] A device for constructing a re-shot image recognition model, the device comprising:
[0033] A data acquisition module, used to acquire initial sample image data carrying category labels and an initial re-shot image recognition model, wherein the initial re-shot image recognition model includes a first classification model layer guided by classification speed and a second classification model layer guided by classification accuracy;
[0034] A first training module, used for inputting the initial sample image data into the first classification model layer to obtain a first loss function and complex sample image data with classification errors;
[0035] A second training module, used for training the second classification model layer according to the complex sample image data and the initial sample image data to obtain a second loss function;
[0036] A parameter updating module is used to obtain a comprehensive loss function of the initial reproduced image recognition model according to the first loss function and the second loss function, and to update the model parameters of the initial reproduced image recognition model by back propagation according to the comprehensive loss function to obtain a trained reproduced image recognition model.
[0037] A re-photographed image recognition device, the device comprising:
[0038] Image acquisition module, used to acquire the image to be identified;
[0039] The recognition module is used to input the image to be recognized into the trained reproduced image recognition model to obtain the recognition result corresponding to the image to be recognized. The trained reproduced image recognition model is constructed according to the above-mentioned reproduced image recognition model construction method.
[0040] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0041] Acquire initial sample image data carrying category labels and an initial re-shot image recognition model, wherein the initial re-shot image recognition model includes a first classification model layer oriented toward classification speed and a second classification model layer oriented toward classification accuracy;
[0042] Inputting the initial sample image data into the first classification model layer to obtain a first loss function and complex sample image data with classification errors;
[0043] According to the complex sample image data and the initial sample image data, a second classification model layer is trained to obtain a second loss function;
[0044] According to the first loss function and the second loss function, a comprehensive loss function of the initial reshot image recognition model is obtained, and the model parameters of the initial reshot image recognition model are updated by back propagation according to the comprehensive loss function to obtain a trained reshot image recognition model.
[0045] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0046] Get the image to be identified;
[0047] The image to be identified is input into a trained reproduced image recognition model to obtain a recognition result corresponding to the image to be identified. The trained reproduced image recognition model is constructed according to the reproduced image recognition model construction method described above.
[0048] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0049] Acquire initial sample image data carrying category labels and an initial re-shot image recognition model, wherein the initial re-shot image recognition model includes a first classification model layer oriented toward classification speed and a second classification model layer oriented toward classification accuracy;
[0050] Inputting the initial sample image data into the first classification model layer to obtain a first loss function and complex sample image data with classification errors;
[0051] According to the complex sample image data and the initial sample image data, a second classification model layer is trained to obtain a second loss function;
[0052] According to the first loss function and the second loss function, a comprehensive loss function of the initial reshot image recognition model is obtained, and the model parameters of the initial reshot image recognition model are updated by back propagation according to the comprehensive loss function to obtain a trained reshot image recognition model.
[0053] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0054] Get the image to be identified;
[0055] The image to be identified is input into a trained reproduced image recognition model to obtain a recognition result corresponding to the image to be identified. The trained reproduced image recognition model is constructed according to the reproduced image recognition model construction method described above.
[0056] The above-mentioned method for constructing a re-shot image recognition model can quickly obtain the first loss function and misclassified complex sample image data by inputting the initial sample image data into the first classification model layer oriented by classification speed, and then can train the second classification model layer oriented by classification accuracy based on the complex sample image data and the initial sample image data, so that the second classification model layer is more inclined to the complex sample image data during learning, and obtain the second loss function. According to the first loss function and the second loss function, a comprehensive loss function is determined, and the model parameters of the initial re-shot image recognition model are updated by back propagation according to the comprehensive loss function, so that a re-shot image recognition model that can accurately recognize re-shot images can be obtained, so that the re-shot image recognition model can be used to improve the accuracy of re-shot judgment. The above-mentioned method for re-shot image recognition can obtain a recognition result corresponding to the picture to be recognized by inputting the picture to be recognized into the re-shot image recognition model that can accurately recognize re-shot images, thereby improving the accuracy of re-shot judgment. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 A schematic diagram of a process of constructing a re-photographed image recognition model in one embodiment;
[0058] Figure 2 A schematic diagram of a process of a method for identifying a re-photographed image in one embodiment;
[0059] Figure 3 A schematic diagram of a method for constructing a reshot image recognition model in one embodiment;
[0060] Figure 4 A schematic diagram of a method for identifying a re-photographed image in one embodiment;
[0061] Figure 5 It is a structural block diagram of a device for building a re-photographed image recognition model in one embodiment;
[0062] Figure 6 is a structural block diagram of a re-photographed image recognition device in one embodiment;
[0063] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0064] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0065] In one embodiment, Figure 1 As shown, a method for constructing a re-shot image recognition model is provided. This embodiment uses the method applied to a server as an example for illustration. It can be understood that the method can also be applied to a terminal, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0066] Step 102, obtaining initial sample image data carrying category labels and an initial reproduced image recognition model, wherein the initial reproduced image recognition model includes a first classification model layer guided by classification speed and a second classification model layer guided by classification accuracy.
[0067] Among them, the category label refers to the label of each initial sample image in the initial sample image data, which is used to characterize the category of the initial sample image. For example, the category label can specifically be a copy. For another example, the category label can specifically be a non-copy. The initial copy image recognition model refers to a copy image recognition model whose parameters are not adjusted. The initial copy image recognition model includes a first classification model layer guided by classification speed and a second classification model layer guided by classification accuracy, wherein the first classification model layer guided by classification speed refers to a classification model layer with a fast classification speed, and the second classification model layer guided by classification accuracy refers to a classification model layer with a high classification accuracy. For example, the first classification model layer can specifically be an EfficientNet-B0 model layer, and the second classification model layer can specifically be an EfficientNet-B1 model layer.
[0068] Specifically, the server will directly obtain the initial sample image data carrying the category label and the initial reproduced image recognition model, wherein the initial sample image data carrying the category label may be data stored in a preset image database, and the server can directly obtain it from the preset image database.
[0069] Step 104: input the initial sample image data into the first classification model layer to obtain a first loss function and misclassified complex sample image data.
[0070] The first loss function refers to the loss function calculated by the first classification model layer after classification. The misclassified complex sample image data refers to the set of initial sample images misclassified by the first classification model layer, and the classification error here means that the first classification result is different from the category label. For example, when the first classification result is not a copy and the category label is a copy, it means that the corresponding initial sample image is misclassified and can be classified as a misclassified complex sample image.
[0071] Specifically, after the server inputs the initial sample image data into the first classification model layer, the first classification model layer will extract features from each initial sample image in the initial sample image data, obtain image features corresponding to each initial sample image, classify each initial sample image according to the image features, obtain a first classification result corresponding to each initial sample image, and obtain a first loss function and misclassified complex sample image data according to the first classification result and the category label. The first classification result can specifically be a remake or a non-remake.
[0072] Specifically, according to the first classification result and the category label, the first loss function and the misclassified complex sample image data can be obtained by comparing the first classification result and the category label, calculating the first loss function, and determining the misclassified initial sample image, dividing the misclassified initial sample image into misclassified complex sample images, and obtaining the complex sample image data according to the complex sample image. When calculating the first loss function, a weight parameter is set for the loss value corresponding to each initial sample image according to the positive and negative sample ratio in the initial sample image data, so that the influence of the positive and negative sample deviations in the training data on the model can be avoided.
[0073] Step 106: train a second classification model layer according to the complex sample image data and the initial sample image data to obtain a second loss function.
[0074] The second loss function refers to the loss function calculated by the second classification model layer after classification.
[0075] Specifically, the server inputs the target sample image data into the second classification model layer, and the second classification model layer extracts features of each target sample image in the target sample image data to obtain image features corresponding to each target sample image, and classifies each target sample image according to the image features to obtain a second classification result corresponding to each target sample image, and calculates the second loss function by comparing the second classification result with the target category label. When calculating the second loss function, a weight parameter is set for the loss value corresponding to each target sample image according to the ratio of positive and negative samples in the target sample image data, so that the influence of the positive and negative sample deviations in the training data on the model can be avoided.
[0076] Step 108, obtaining a comprehensive loss function of the initial re-shot image recognition model according to the first loss function and the second loss function, and updating the model parameters of the initial re-shot image recognition model by back-propagation according to the comprehensive loss function to obtain a trained re-shot image recognition model.
[0077] Specifically, the server can obtain the comprehensive loss function of the initial re-shot image recognition model according to the first loss function, the second loss function and the preset loss function weight, and then update the model parameters of the initial re-shot image recognition model according to the back propagation of the comprehensive loss function to obtain the trained re-shot image recognition model. Among them, the preset loss function weight can be set as needed. Specifically, the preset loss function weight can be set according to the importance of the first classification model layer and the second classification model layer to the initial re-shot image recognition model. For example, when the first classification model layer and the second classification model layer are equally important, the loss function weight can be set to 1:1.
[0078] Specifically, updating the model parameters of the initial re-shot image recognition model according to the back propagation of the comprehensive loss function to obtain the trained re-shot image recognition model means that after obtaining the comprehensive loss function, the model parameters of the new initial re-shot image recognition model are calculated using the comprehensive loss function, returning to the step of inputting the initial sample image data into the first classification model layer to obtain the first loss function and the misclassified complex sample image data, and recalculating the new comprehensive loss function until the comprehensive loss function meets the preset conditions to obtain the trained re-shot image recognition model. Here, meeting the preset conditions may specifically refer to the comprehensive loss function being less than the preset loss function threshold or the comprehensive loss function converging, etc., which is not limited in this embodiment.
[0079] The above-mentioned method for constructing a copied image recognition model can quickly obtain a first loss function and complex sample image data that are misclassified by inputting the initial sample image data into the first classification model layer oriented by classification speed, and then can train the second classification model layer oriented by classification accuracy based on the complex sample image data and the initial sample image data, so that the second classification model layer is more inclined to the complex sample image data during learning, and obtain a second loss function. According to the first loss function and the second loss function, a comprehensive loss function is determined, and the model parameters of the initial copied image recognition model are updated by back propagation according to the comprehensive loss function, so as to obtain a copied image recognition model that can accurately identify copied images, so that the copied image recognition model can be used to improve the accuracy of copy judgment.
[0080] In one embodiment, the initial sample image data is input into the first classification model layer, and the first loss function is obtained including:
[0081] Inputting the initial sample image data into the first classification model layer to obtain a first classification result corresponding to each initial sample image in the initial sample image data;
[0082] Determine a first loss value corresponding to each initial sample image according to the first classification result and the category label;
[0083] Determine, according to the category label, a first positive-negative sample ratio corresponding to the initial sample image data, and determine, according to the first positive-negative sample ratio, a first loss weight corresponding to each first loss value;
[0084] A first loss function is obtained according to the first loss value and the first loss weight.
[0085] Specifically, after the initial sample image data is input into the first classification model layer, a first classification result corresponding to each initial sample image in the initial sample image data will be obtained. The server will determine the loss value corresponding to each initial sample image by comparing the first classification result and the category label of each initial sample image, and determine the first positive and negative sample ratio corresponding to the initial sample image data according to the number of positive labels and the number of negative labels in the category label, and determine the first loss weight corresponding to each first loss value according to the first positive and negative sample ratio, the category label of each initial sample image data and the sample balance principle, and calculate the first loss function according to the first loss value and the first loss weight.
[0086] Among them, the sample balance principle means that the ratio of positive samples is roughly the same as the ratio of negative samples. When determining the first loss weight corresponding to each first loss value, the server first determines the positive sample weight and the negative sample weight according to the positive-negative sample ratio and the sample balance principle, and then determines whether each first loss value belongs to the positive sample loss or the negative sample loss according to the category label, sets the positive sample weight for the positive sample loss, and sets the negative sample weight for the negative sample loss. For example, when the positive-negative sample ratio is 1:4, in order to balance the samples, the positive sample weight can be determined to be 4 and the negative sample weight to be 1, then the corresponding weight 4 is set for the first loss value belonging to the positive sample loss, and the weight 1 is set for the first loss value belonging to the negative sample loss.
[0087] Furthermore, the method of comparing the first classification result and the category label of each initial sample image and determining the loss value corresponding to each initial sample image may specifically be to compare the first classification result and the category label of each initial sample image, determine the category probability in the first classification result that is the same as the analogy represented by the category label, and determine the loss value corresponding to each initial sample image according to the category probability. For example, the loss value may specifically be the absolute value of the category probability and 1 or the square of the absolute value, etc., which is not limited in this embodiment.
[0088] In this embodiment, by setting corresponding first loss weights for different first loss values according to the first positive-negative sample ratio, and obtaining the first loss function according to the first loss value and the first loss weight, the influence of the positive and negative sample deviations in the training data on the reproduced image recognition model can be avoided, thereby improving the accuracy of the reproduced image recognition model.
[0089] In one embodiment, the second classification model layer is trained according to the complex sample image data and the initial sample image data to obtain the second loss function, which includes:
[0090] Adding the complex sample image data to the initial sample image data to obtain the target sample image data carrying the target category label;
[0091] According to the target sample image data, the second classification model layer is trained to obtain the second loss function.
[0092] The target category label refers to the label of each target sample image in the target sample image data, which is used to characterize the category of the target sample image. For example, the target category label may be a copy. For another example, the target category label may be a non-copy. The target sample image data refers to the collection of complex sample image data and initial sample image data.
[0093] Specifically, the server can obtain target sample image data carrying target category labels by adding complex sample image data to the initial sample image data. Based on the target sample image data, the second classification model layer is trained to obtain a second classification result corresponding to the target sample image data. Based on the second classification result and the target category label, the second loss function can be obtained.
[0094] In this embodiment, by adding complex sample image data to the initial sample image data, target sample image data that is more inclined to be misclassified can be obtained, so that the target sample image data can be used to make the second classification model layer more inclined to the complex sample image data during learning, thereby obtaining a copied image recognition model that can accurately identify copied images.
[0095] In one embodiment, according to the target sample image data, training the second classification model layer to obtain the second loss function includes:
[0096] Input the target sample image data into the second classification model layer to obtain a second classification result corresponding to each target sample image data in the target sample image data;
[0097] Determine a second loss value corresponding to each target sample image according to the second classification result and the target category label;
[0098] Determine, according to the target category label, a second positive-negative sample ratio corresponding to the target sample image data, and determine, according to the second positive-negative sample ratio, a second loss weight corresponding to each second loss value;
[0099] A second loss function is obtained according to the second loss value and the second loss weight.
[0100] Specifically, after the target sample image data is input into the second classification model layer, the second classification result corresponding to each target sample image data in the target sample image data can be obtained. The server will determine the loss value corresponding to each target sample image by comparing the second classification result of each target sample image with the target category label, and determine the second positive and negative sample ratio corresponding to the target sample image data according to the number of positive labels and the number of negative labels in the target category label, determine the second loss weight corresponding to each second loss value according to the second positive and negative sample ratio, the target category label of each target sample image data and the sample balance principle, and calculate the second loss function according to the second loss value and the second loss weight.
[0101] Among them, the sample balance principle means that the ratio of positive samples is roughly the same as the ratio of negative samples. When determining the second loss weights corresponding to each second loss value, the server first determines the positive sample weight and the negative sample weight according to the positive-negative sample ratio and the sample balance principle, and then determines whether each second loss value belongs to the positive sample loss or the negative sample loss according to the target category label, sets the positive sample weight for the positive sample loss, and sets the negative sample weight for the negative sample loss. For example, when the positive-negative sample ratio is 1:4, in order to balance the samples, the positive sample weight can be determined to be 4 and the negative sample weight to be 1, then the corresponding second loss value belonging to the positive sample loss is set to a weight of 4, and the second loss value belonging to the negative sample loss is set to a weight of 1.
[0102] Furthermore, the method of comparing the second classification results of each target sample image with the target category label and determining the loss value corresponding to each target sample image may specifically be to compare the second classification results of each target sample image with the target category label, determine the category probability in the second classification result that is the same as the analogy represented by the target category label, and determine the loss value corresponding to each target sample image according to the category probability. For example, the loss value may specifically be the absolute value of the category probability and 1 or the square of the absolute value, etc., which is not limited in this embodiment.
[0103] In this embodiment, by setting corresponding second loss weights for different second loss values according to the second positive-negative sample ratio, and obtaining the second loss function according to the second loss value and the second loss weight, the influence of the positive and negative sample deviations in the training data on the reproduced image recognition model can be avoided, thereby improving the accuracy of the reproduced image recognition model.
[0104] In one embodiment, Figure 2 As shown, a method for re-photographed image recognition is provided. This embodiment takes the method applied to a server as an example for illustration. It is understandable that the method can also be applied to a terminal, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0105] Step 202: Obtain the image to be identified.
[0106] Step 204, input the image to be identified into the trained reproduced image recognition model to obtain a recognition result corresponding to the image to be identified. The trained reproduced image recognition model is constructed according to the reproduced image recognition model construction method described above.
[0107] The picture to be identified refers to a picture to be identified as a re-photographed image.
[0108] Specifically, after obtaining the picture to be identified, the server can obtain the recognition result corresponding to the picture to be identified by directly inputting the picture to be identified into the trained reproduced image recognition model.
[0109] The above-mentioned duplicate image recognition method can obtain a recognition result corresponding to the picture to be recognized by inputting the picture to be recognized into a duplicate image recognition model that can accurately recognize duplicate images, thereby improving the accuracy of duplicate judgment.
[0110] In one embodiment, the image to be identified is input into a trained re-photographed image recognition model, and the recognition result corresponding to the image to be identified is obtained, including:
[0111] Inputting the image to be identified into the first classification model layer of the trained re-photographed image recognition model to obtain a first classification result;
[0112] When the first classification result is a remake, the image to be identified is input into the second classification model layer in the trained remake image recognition model to obtain a second classification result;
[0113] When the second classification result is a remake, the identification result is a remake.
[0114] Specifically, after the server inputs the picture to be identified into the first classification model layer of the trained copied image recognition model, the classification speed-oriented first classification model layer will quickly predict the first classification result corresponding to the picture to be identified through operations such as feature extraction. When the first classification result is a copy, it is necessary to further use the second classification model layer in the trained copied image recognition model to determine whether the picture to be identified is a copy. The server will input the picture to be identified into the second classification model layer in the trained copied image recognition model, so that the classification accuracy-oriented second classification model layer will accurately predict the second classification result corresponding to the picture to be identified through operations such as feature extraction. When the second classification result is a copy, the recognition result is a copy.
[0115] In this embodiment, by inputting the picture to be identified into the first classification model layer to obtain a first classification result, when the first classification result is a copy, the picture to be identified is input into the second classification model layer to obtain a second classification result, when the second classification result is a copy, the identification result is a copy, and the first classification model layer and the second classification model layer can be used to realize accurate identification of whether the picture to be identified is a copy.
[0116] In one embodiment, the method further includes: when the first classification result is non-copy or the second classification result is non-copy, obtaining a recognition result of non-copy.
[0117] Specifically, when the first classification result is non-remake or the second classification result is non-remake, the server will conclude that the recognition result is non-remake, that is, only when the first classification result is remake and the second classification result is remake, can the server conclude that the recognition result is remake.
[0118] In this embodiment, when the first classification result is non-copy or the second classification result is non-copy, the recognition result is non-copy, and the first classification model layer and the second classification model layer can be used to accurately identify whether the picture to be recognized is a copy.
[0119] This application also provides an application scenario, such as Figure 3 As shown, the application scenario applies the above-mentioned method for building a re-shot image recognition model. Specifically, the application of the method for building a re-shot image recognition model in the application scenario is as follows:
[0120] The server obtains training data (i.e., initial sample image data carrying category labels) and an initial re-shot image recognition model, which includes model A (i.e., the first classification model layer oriented towards classification speed) and model B (i.e., the second classification model layer oriented towards classification accuracy). The training data is input into model A to obtain dynamic LossA (i.e., the first loss function) and complex sample image data with classification errors. The target sample image data carrying the target category label is obtained according to the complex sample image data and the training data through the data sampling module. Model B is trained according to the target sample image data to obtain dynamic LossB (i.e., the second loss function). According to dynamic LossA and dynamic LossB, the overall Loss (i.e., the comprehensive loss function) of the initial re-shot image recognition model is obtained. The model parameters of the initial re-shot image recognition model are updated according to the overall Loss back propagation to obtain the trained re-shot image recognition model.
[0121] This application also provides an application scenario, such as Figure 4 As shown, the application scenario applies the above-mentioned re-shot image recognition method. Specifically, the application of the re-shot image recognition method in the application scenario is as follows:
[0122] The server obtains the image to be identified, inputs the image to be identified into model A (i.e., the first classification model layer) in the trained remake image recognition model, and obtains the first classification result. When the first classification result is a remake, the image to be identified is input into model B (i.e., the second classification model layer) in the trained remake image recognition model, and obtains the second classification result. When the second classification result is a remake, the recognition result is a remake. When the first classification result is a non-remake or the second classification result is a non-remake, the recognition result is a normal image (i.e., a non-remake).
[0123] It should be understood that although Figure 1-4 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-4 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0124] In one embodiment, Figure 5As shown, a device for constructing a re-shot image recognition model is provided, comprising: a data acquisition module 502, a first training module 504, a second training module 506 and a parameter updating module 508, wherein:
[0125] A data acquisition module 502 is used to acquire initial sample image data carrying category labels and an initial re-shot image recognition model, wherein the initial re-shot image recognition model includes a first classification model layer oriented toward classification speed and a second classification model layer oriented toward classification accuracy;
[0126] A first training module 504, configured to input the initial sample image data into the first classification model layer to obtain a first loss function and misclassified complex sample image data;
[0127] A second training module 506, configured to train the second classification model layer according to the complex sample image data and the initial sample image data to obtain a second loss function;
[0128] The parameter updating module 508 is used to obtain a comprehensive loss function of the initial re-shot image recognition model according to the first loss function and the second loss function, and to update the model parameters of the initial re-shot image recognition model by back-propagation according to the comprehensive loss function to obtain a trained re-shot image recognition model.
[0129] The above-mentioned device for constructing a copied image recognition model can quickly obtain a first loss function and complex sample image data that are misclassified by inputting initial sample image data into a first classification model layer oriented toward classification speed, and then can train a second classification model layer oriented toward classification accuracy based on the complex sample image data and the initial sample image data, so that the second classification model layer is more inclined toward the complex sample image data during learning, and obtain a second loss function. Based on the first loss function and the second loss function, a comprehensive loss function is determined, and the model parameters of the initial copied image recognition model are updated by back propagation according to the comprehensive loss function, so as to obtain a copied image recognition model that can accurately identify copied images, thereby making it possible to use the copied image recognition model to improve the accuracy of copy judgment.
[0130] In one embodiment, the first training module is also used to input the initial sample image data into the first classification model layer to obtain a first classification result corresponding to each initial sample image in the initial sample image data, determine a first loss value corresponding to each initial sample image based on the first classification result and the category label, determine a first positive and negative sample ratio corresponding to the initial sample image data based on the category label, determine a first loss weight corresponding to each first loss value based on the first positive and negative sample ratio, and obtain a first loss function based on the first loss value and the first loss weight.
[0131] In one embodiment, the second training module is also used to add complex sample image data to initial sample image data to obtain target sample image data carrying target category labels, and train the second classification model layer based on the target sample image data to obtain a second loss function.
[0132] In one embodiment, the second training module is also used to input the target sample image data into the second classification model layer to obtain a second classification result corresponding to each target sample image data in the target sample image data, determine a second loss value corresponding to each target sample image according to the second classification result and the target category label, determine a second positive and negative sample ratio corresponding to the target sample image data according to the target category label, determine a second loss weight corresponding to each second loss value according to the second positive and negative sample ratio, and obtain a second loss function according to the second loss value and the second loss weight.
[0133] In one embodiment, Figure 6 As shown, a re-photographed image recognition device is provided, comprising: a picture acquisition module 602 and a recognition module 604, wherein:
[0134] The picture acquisition module 602 is used to acquire the picture to be identified;
[0135] The recognition module 604 is used to input the image to be recognized into the trained reproduced image recognition model to obtain a recognition result corresponding to the image to be recognized. The trained reproduced image recognition model is constructed according to the reproduced image recognition model construction method described above.
[0136] The above-mentioned copied image recognition device can obtain a recognition result corresponding to the picture to be recognized by inputting the picture to be recognized into a copied image recognition model that can accurately recognize the copied image, thereby improving the accuracy of copy judgment.
[0137] In one embodiment, the recognition module is also used to input the picture to be identified into the first classification model layer of the trained copied image recognition model to obtain a first classification result. When the first classification result is a copy, the picture to be identified is input into the second classification model layer of the trained copied image recognition model to obtain a second classification result. When the second classification result is a copy, the recognition result is a copy.
[0138] In one embodiment, the apparatus for identifying a copied image further comprises a processing module, and the processing module is configured to obtain a recognition result of non-copying when the first classification result is non-copying or the second classification result is non-copying.
[0139] The specific limitations of the re-shot image recognition model construction device and the re-shot image recognition device can be found in the above-mentioned limitations on the re-shot image recognition model construction method and the re-shot image recognition method, which will not be repeated here. The various modules in the above-mentioned re-shot image recognition model construction device and the re-shot image recognition device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0140] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store initial sample image data carrying category labels. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for constructing a reprinted image recognition model and a reprinted image recognition method are implemented.
[0141] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0142] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0143] Acquire initial sample image data carrying category labels and an initial re-shot image recognition model, wherein the initial re-shot image recognition model includes a first classification model layer oriented toward classification speed and a second classification model layer oriented toward classification accuracy;
[0144] Inputting the initial sample image data into the first classification model layer to obtain a first loss function and complex sample image data with classification errors;
[0145] According to the complex sample image data and the initial sample image data, a second classification model layer is trained to obtain a second loss function;
[0146] According to the first loss function and the second loss function, a comprehensive loss function of the initial reshot image recognition model is obtained, and the model parameters of the initial reshot image recognition model are updated by back propagation according to the comprehensive loss function to obtain a trained reshot image recognition model.
[0147] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0148] Inputting the initial sample image data into the first classification model layer to obtain a first classification result corresponding to each initial sample image in the initial sample image data;
[0149] Determine a first loss value corresponding to each initial sample image according to the first classification result and the category label;
[0150] Determine, according to the category label, a first positive-negative sample ratio corresponding to the initial sample image data, and determine, according to the first positive-negative sample ratio, a first loss weight corresponding to each first loss value;
[0151] A first loss function is obtained according to the first loss value and the first loss weight.
[0152] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0153] Adding the complex sample image data to the initial sample image data to obtain the target sample image data carrying the target category label;
[0154] According to the target sample image data, the second classification model layer is trained to obtain the second loss function.
[0155] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0156] Input the target sample image data into the second classification model layer to obtain a second classification result corresponding to each target sample image data in the target sample image data;
[0157] Determine a second loss value corresponding to each target sample image according to the second classification result and the target category label;
[0158] Determine, according to the target category label, a second positive-negative sample ratio corresponding to the target sample image data, and determine, according to the second positive-negative sample ratio, a second loss weight corresponding to each second loss value;
[0159] A second loss function is obtained according to the second loss value and the second loss weight.
[0160] In one embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory. When the processor executes the computer program, the following steps are implemented:
[0161] Obtain the picture to be recognized;
[0162] Input the picture to be recognized into the trained recognition model for retaken images to obtain a recognition result corresponding to the picture to be recognized. The trained recognition model for retaken images is constructed according to the above-mentioned construction method of the recognition model for retaken images.
[0163] In one embodiment, when the processor executes the computer program, the following steps are further implemented:
[0164] Input the picture to be recognized into the first classification model layer in the trained recognition model for retaken images to obtain a first classification result;
[0165] When the first classification result is retaken, input the picture to be recognized into the second classification model layer in the trained recognition model for retaken images to obtain a second classification result;
[0166] When the second classification result is retaken, obtain that the recognition result is retaken.
[0167] In one embodiment, when the processor executes the computer program, the following steps are further implemented:
[0168] When the first classification result is not retaken or the second classification result is not retaken, obtain that the recognition result is not retaken.
[0169] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0170] Obtain the initial sample image data carrying category labels and the initial recognition model for retaken images. The initial recognition model for retaken images includes a first classification model layer oriented to classification speed and a second classification model layer oriented to classification accuracy;
[0171] Input the initial sample image data into the first classification model layer to obtain a first loss function and the complex sample image data with classification errors;
[0172] Train the second classification model layer according to the complex sample image data and the initial sample image data to obtain a second loss function;
[0173] Obtain the comprehensive loss function of the initial recognition model for retaken images according to the first loss function and the second loss function. Update the model parameters of the initial recognition model for retaken images by backpropagation according to the comprehensive loss function to obtain the trained recognition model for retaken images.
[0174] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0175] Inputting the initial sample image data into the first classification model layer to obtain a first classification result corresponding to each initial sample image in the initial sample image data;
[0176] Determine a first loss value corresponding to each initial sample image according to the first classification result and the category label;
[0177] Determine, according to the category label, a first positive-negative sample ratio corresponding to the initial sample image data, and determine, according to the first positive-negative sample ratio, a first loss weight corresponding to each first loss value;
[0178] A first loss function is obtained according to the first loss value and the first loss weight.
[0179] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0180] Adding the complex sample image data to the initial sample image data to obtain the target sample image data carrying the target category label;
[0181] According to the target sample image data, the second classification model layer is trained to obtain the second loss function.
[0182] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0183] Input the target sample image data into the second classification model layer to obtain a second classification result corresponding to each target sample image data in the target sample image data;
[0184] Determine a second loss value corresponding to each target sample image according to the second classification result and the target category label;
[0185] Determine, according to the target category label, a second positive-negative sample ratio corresponding to the target sample image data, and determine, according to the second positive-negative sample ratio, a second loss weight corresponding to each second loss value;
[0186] A second loss function is obtained according to the second loss value and the second loss weight.
[0187] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0188] Get the image to be identified;
[0189] The image to be identified is input into a trained reproduced image recognition model to obtain a recognition result corresponding to the image to be identified. The trained reproduced image recognition model is constructed according to the reproduced image recognition model construction method described above.
[0190] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0191] Inputting the image to be identified into the first classification model layer in the trained re-photographed image recognition model to obtain a first classification result;
[0192] When the first classification result is a remake, the image to be identified is input into the second classification model layer in the trained remake image recognition model to obtain a second classification result;
[0193] When the second classification result is a remake, the identification result is a remake.
[0194] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0195] When the first classification result is non-copy or the second classification result is non-copy, the identification result is non-copy.
[0196] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0197] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0198] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for constructing a remake image recognition model, It is characterized in that The method comprises: Acquire initial sample image data carrying category labels and an initial re-shot image recognition model, wherein the initial re-shot image recognition model includes a first classification model layer oriented toward classification speed and a second classification model layer oriented toward classification accuracy; Inputting the initial sample image data into the first classification model layer to obtain a first loss function and misclassified complex sample image data; According to the complex sample image data and the initial sample image data, the second classification model layer is trained to obtain a second loss function; According to the first loss function and the second loss function, a comprehensive loss function of the initial re-shot image recognition model is obtained, and the model parameters of the initial re-shot image recognition model are updated by back propagation according to the comprehensive loss function to obtain a trained re-shot image recognition model.
2. The method according to claim 1, It is characterized in that Inputting the initial sample image data into the first classification model layer to obtain a first loss function comprises: Inputting the initial sample image data into the first classification model layer to obtain a first classification result corresponding to each initial sample image in the initial sample image data; Determining a first loss value corresponding to each initial sample image according to the first classification result and the category label; Determine, according to the category label, a first positive-negative sample ratio corresponding to the initial sample image data, and determine, according to the first positive-negative sample ratio, a first loss weight corresponding to each of the first loss values; A first loss function is obtained according to the first loss value and the first loss weight.
3. The method according to claim 1, It is characterized in that The training of the second classification model layer according to the complex sample image data and the initial sample image data to obtain a second loss function comprises: Adding the complex sample image data to the initial sample image data to obtain target sample image data carrying a target category label; The second classification model layer is trained according to the target sample image data to obtain a second loss function.
4. The method according to claim 3, It is characterized in that The training of the second classification model layer according to the target sample image data to obtain a second loss function comprises: Inputting the target sample image data into the second classification model layer to obtain a second classification result corresponding to each target sample image data in the target sample image data; Determining a second loss value corresponding to each target sample image according to the second classification result and the target category label; Determine, according to the target category label, a second positive-negative sample ratio corresponding to the target sample image data, and determine, according to the second positive-negative sample ratio, a second loss weight corresponding to each of the second loss values; A second loss function is obtained according to the second loss value and the second loss weight.
5. A method for identifying a re-photographed image, It is characterized in that The method comprises: Get the image to be identified; The image to be identified is input into a trained reproduced image recognition model to obtain a recognition result corresponding to the image to be identified, wherein the trained reproduced image recognition model is constructed according to the method described in any one of claims 1 to 4.
6. The method according to claim 5, It is characterized in that The step of inputting the image to be identified into a trained re-photographed image recognition model to obtain a recognition result corresponding to the image to be identified includes: Inputting the picture to be identified into a first classification model layer in a trained re-photographed image recognition model to obtain a first classification result; When the first classification result is a copy, inputting the picture to be identified into a second classification model layer in a trained copy image recognition model to obtain a second classification result; When the second classification result is a copy, the identification result is obtained as a copy.
7. The method according to claim 6, It is characterized in that Also includes: When the first classification result is non-copy or the second classification result is non-copy, the identification result is non-copy.
8. A device for constructing a re-photographed image recognition model, It is characterized in that The device comprises: A data acquisition module, used to acquire initial sample image data carrying category labels and an initial re-shot image recognition model, wherein the initial re-shot image recognition model includes a first classification model layer guided by classification speed and a second classification model layer guided by classification accuracy; A first training module, used for inputting the initial sample image data into the first classification model layer to obtain a first loss function and complex sample image data with classification errors; A second training module, used for training the second classification model layer according to the complex sample image data and the initial sample image data to obtain a second loss function; A parameter updating module is used to obtain a comprehensive loss function of the initial reproduced image recognition model according to the first loss function and the second loss function, and to update the model parameters of the initial reproduced image recognition model by back propagation according to the comprehensive loss function to obtain a trained reproduced image recognition model.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method and system for automatically detecting single neuron dendritic spine in fluorescence image
CN111091530A
Refinement of device classification and clustering based on policy coloring
US20200162329A1