Image detection model training method, image detection method, device and equipment
By training the image detection model and using the image generation model for style transfer, the problem of image style transfer effect detection in the prior art is solved, more efficient image style detection and evaluation is achieved, and the quality of image processing is improved.
Patent Information
- Application Number
- CN202210426094.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-21
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2042-04-21
AI Technical Summary
The prior art is difficult to effectively detect and evaluate the effect of image style transfer, affecting the quality of image processing.
By training an image detection model, using the image generation model for style transfer, the generated target image is compared with the standard image, the sample label and detection label are determined, and the image detection model is trained to detect the similarity of image styles.
It improves the accuracy of the image detection model, can more effectively detect and evaluate the effect of image style transfer, and improves the quality of image processing.
Smart Images

Figure CN114998196B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a training method for an image detection model, an image detection method, a device and equipment. Background Art
[0002] With the development of computer technology, the ways of image processing are becoming more and more diverse. Image style transfer refers to converting the style of one image to another style while keeping the content of the image unchanged, such as artistic style transfer, gender style transfer, age style transfer, etc.
[0003] Generally, the effect of image style transfer is affected by many factors, such as the means used, the transferred style, or the content of the processed image, etc. Therefore, it is urgent to provide a method for detecting the effect of image style transfer. Summary of the invention
[0004] The present invention provides an image detection model training method, an image detection method, an apparatus and a device, which can improve the accuracy of image detection.
[0005] According to one aspect of an embodiment of the present disclosure, a method for training an image detection model is provided, the method comprising:
[0006] Acquire a standard image belonging to a target style, where the target style is any style;
[0007] Calling the image generation model being trained to perform style transfer on the original image to obtain a target image, wherein the image generation model is used to generate an image of the target style;
[0008] Based on the target image, determine a first sample image that matches the style of the target image, and based on the current number of training times of the image generation model, determine a sample label corresponding to the first sample image, wherein the sample label is used to indicate an actual similarity between the style of the first sample image and the target style, and the sample label is positively correlated with the number of training times of the image generation model;
[0009] Calling the image detection model to be trained, comparing the first sample image with the standard image, and obtaining a first detection label, where the first detection label is used to indicate the predicted similarity between the style of the first sample image and the target style;
[0010] Based on the sample label and the first detection label, the image detection model to be trained is trained to obtain a trained image detection model, and the trained image detection model is used to detect the similarity between the styles of any two images.
[0011] Optionally, determining, based on the target image, a first sample image that matches the style of the target image includes:
[0012] The target image is determined as the first sample image.
[0013] Optionally, the method further comprises:
[0014] Determine a plurality of candidate image generation models, each candidate image generation model having a respective number of training times and a respective accuracy, and different candidate image generation models have different current number of training times, and the accuracy represents the accuracy of the image generated by the candidate image generation model and belonging to the target style;
[0015] Among the multiple candidate image generation models, the image generation model whose accuracy is less than a target threshold is selected.
[0016] Optionally, calling the image generation model being trained to perform style transfer on the original image to obtain the target image includes:
[0017] Determine multiple image generation models, and different image generation models have different current training times;
[0018] Calling the multiple image generation models to perform style transfer on the original images respectively to obtain multiple target images;
[0019] The step of determining, based on the target image, a first sample image that matches the style of the target image comprises:
[0020] Determine an image obtained by fusing the multiple target images as the first sample image;
[0021] The determining, based on the current training times of the image generation model, a sample label corresponding to the first sample image includes:
[0022] Taking a weighted average of the training times of the multiple image generation models to obtain an average training time;
[0023] The average number of training times is normalized to obtain the sample label.
[0024] Optionally, the multiple image generation models include a first image generation model and a second image generation model; and determining the multiple image generation models includes:
[0025] Determine a plurality of candidate image generation models, each candidate image generation model having a respective number of training times and a respective accuracy, and different candidate image generation models have different current number of training times, and the accuracy represents the accuracy of the image generated by the candidate image generation model and belonging to the target style;
[0026] Among the multiple candidate image generation models, the first image generation model whose accuracy is equal to the target threshold is selected, and the second image generation model whose accuracy is the maximum value is selected.
[0027] Optionally, the method further comprises:
[0028] Performing multiple types of enhancement processing on the standard image to obtain multiple enhanced images;
[0029] Calling the image detection model to be trained, and comparing the first sample image with each of the enhanced images respectively to obtain a plurality of first enhanced labels, where the first enhanced labels are used to indicate the predicted similarity between the style of the first sample image and the style of the enhanced image;
[0030] The step of training the image detection model to be trained based on the sample label and the first detection label to obtain a trained image detection model includes:
[0031] Based on any one of the differences between any two of the first enhanced labels or the differences between the sample label and each of the first enhanced labels, and the difference between the sample label and the first detection label, the image detection model to be trained is trained to obtain the trained image detection model.
[0032] Optionally, the method further comprises:
[0033] Performing multiple types of enhancement processing on the standard image to obtain multiple enhanced images;
[0034] Calling the image detection model to be trained, comparing any two of the enhanced images, and obtaining a plurality of second enhanced labels, where the second enhanced labels are used to represent the predicted similarity between the styles of any two of the enhanced images;
[0035] The step of training the image detection model to be trained based on the sample label and the first detection label to obtain a trained image detection model includes:
[0036] Obtaining a target label, wherein the target label indicates that the styles of any two enhanced images are the same;
[0037] Based on the difference between the sample label and the first detection label, and the difference between each second enhanced label and the target label, the image detection model to be trained is trained to obtain the trained image detection model.
[0038] Optionally, the method further comprises:
[0039] Acquire a second sample image, where the second sample image is an image that does not belong to the target style;
[0040] calling the image detection model to be trained, comparing the first sample image with the second sample image, and obtaining a second detection label, where the second detection label is used to indicate a predicted similarity between a style of the first sample image and a style of the second sample image;
[0041] The step of training the image detection model to be trained based on the sample label and the first detection label to obtain a trained image detection model includes:
[0042] Based on the difference between the sample label and the first detection label, and the difference between the first detection label and the second detection label, the image detection model to be trained is trained to obtain the trained image detection model.
[0043] According to another aspect of the present disclosure, there is provided an image detection method, the method comprising:
[0044] Acquire a standard image belonging to a target style, where the target style is any style;
[0045] Migrating the style of the first image to the target style to obtain a second image of the target style;
[0046] Calling the trained image detection model, comparing the second image with the standard image, and obtaining an object detection label, where the object detection label is used to indicate the similarity between the style of the second image and the style of the standard image;
[0047] The trained image detection model is trained using the training method of the image detection model as described above.
[0048] According to another aspect of an embodiment of the present disclosure, a training device for an image detection model is provided, and the training device for an image detection model includes:
[0049] A first acquisition unit is configured to acquire a standard image belonging to a target style, where the target style is any style;
[0050] A second acquisition unit is configured to execute calling the image generation model being trained, perform style transfer on the original image, and obtain a target image, wherein the image generation model is used to generate an image belonging to the target style;
[0051] A first determining unit is configured to determine, based on the target image, a first sample image that matches the style of the target image, and determine, based on a current number of training times of the image generation model, a sample label corresponding to the first sample image, wherein the sample label is used to indicate an actual similarity between the style of the first sample image and the target style, and the sample label is positively correlated with the number of training times of the image generation model;
[0052] a model training unit configured to execute calling the image detection model to be trained, compare the first sample image with the standard image, and obtain a first detection label, wherein the first detection label is used to indicate a predicted similarity between a style of the first sample image and a target style;
[0053] The model training unit is further configured to train the image detection model to be trained based on the sample label and the first detection label to obtain a trained image detection model, wherein the trained image detection model is used to detect the similarity between the styles of any two images.
[0054] Optionally, the first determining unit is configured to determine the target image as the first sample image.
[0055] Optionally, the device further comprises:
[0056] A second determining unit is configured to determine a plurality of candidate image generation models, each of which has a respective number of training times and a respective accuracy, and different candidate image generation models have different current training times, and the accuracy represents the accuracy of the image generated by the candidate image generation model and belonging to the target style;
[0057] The model selection unit is configured to select the image generation model whose accuracy is less than a target threshold from among the multiple candidate image generation models.
[0058] Optionally, the second acquiring unit is configured to execute:
[0059] Determine multiple image generation models, and different image generation models have different current training times;
[0060] Calling the multiple image generation models to perform style transfer on the original images respectively to obtain multiple target images;
[0061] The first determining unit is configured to determine an image obtained by fusing the multiple target images as the first sample image;
[0062] The first determining unit is further configured to execute:
[0063] Taking a weighted average of the training times of the multiple image generation models to obtain an average training time;
[0064] The average number of training times is normalized to obtain the sample label.
[0065] Optionally, the multiple image generation models include a first image generation model and a second image generation model; and the second acquisition unit is configured to execute:
[0066] Determine a plurality of candidate image generation models, each candidate image generation model having a respective number of training times and a respective accuracy, and different candidate image generation models have different current number of training times, and the accuracy represents the accuracy of the image generated by the candidate image generation model and belonging to the target style;
[0067] Among the multiple candidate image generation models, the first image generation model whose accuracy is equal to the target threshold is selected, and the second image generation model whose accuracy is the maximum value is selected.
[0068] Optionally, the device further comprises:
[0069] An image enhancement unit, configured to perform various types of enhancement processing on the standard image to obtain a plurality of enhanced images;
[0070] The model training unit is further configured to execute calling the image detection model to be trained, respectively compare the first sample image with each of the enhanced images, and obtain a plurality of first enhanced labels, wherein the first enhanced labels are used to indicate the predicted similarity between the style of the first sample image and the style of the enhanced image;
[0071] The model training unit is further configured to execute training of the image detection model to be trained based on any one of the differences between any two of the first enhanced labels or the differences between the sample label and each of the first enhanced labels, and the difference between the sample label and the first detection label, to obtain the trained image detection model.
[0072] Optionally, the device further comprises:
[0073] An image enhancement unit, configured to perform various types of enhancement processing on the standard image to obtain a plurality of enhanced images;
[0074] The model training unit is further configured to execute calling the image detection model to be trained, compare any two of the enhanced images, and obtain a plurality of second enhanced labels, where the second enhanced labels are used to represent the predicted similarity between the styles of any two of the enhanced images;
[0075] The model training unit is further configured to execute:
[0076] Obtaining a target label, wherein the target label indicates that the styles of any two enhanced images are the same;
[0077] Based on the difference between the sample label and the first detection label, and the difference between each second enhanced label and the target label, the image detection model to be trained is trained to obtain the trained image detection model.
[0078] Optionally, the device further comprises:
[0079] A third acquisition unit is configured to acquire a second sample image, where the second sample image is an image that does not belong to the target style;
[0080] The model training unit is further configured to execute calling the image detection model to be trained, compare the first sample image with the second sample image, and obtain a second detection label, where the second detection label is used to indicate the predicted similarity between the style of the first sample image and the style of the second sample image;
[0081] The model training unit is further configured to train the image detection model to be trained based on the difference between the sample label and the first detection label, and the difference between the first detection label and the second detection label, to obtain the trained image detection model.
[0082] According to another aspect of the embodiments of the present disclosure, there is provided an image detection device, the image detection device comprising:
[0083] An acquisition unit is configured to acquire a standard image belonging to a target style, where the target style is any style;
[0084] A style transfer unit, configured to transfer the style of the first image to the target style to obtain a second image of the target style;
[0085] an image detection unit, configured to execute calling the trained image detection model, compare the second image with the standard image, and obtain an object detection label, wherein the object detection label is used to indicate the similarity between the style of the second image and the style of the standard image;
[0086] The trained image detection model is trained using the training method of the image detection model as described above.
[0087] According to another aspect of the embodiments of the present disclosure, an electronic device is provided, the electronic device comprising:
[0088] processor;
[0089] a memory for storing instructions executable by the processor;
[0090] Among them, the processor is configured to execute the instructions to implement the training method of the image detection model as described in the above aspects, or to implement the image detection method as described in the above aspects.
[0091] According to another aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the training method of the image detection model as described in the above aspects, or to execute the image detection method as described in the above aspects.
[0092] According to another aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program, which, when executed by a processor, implements the training method of the image detection model as described in the above aspects, or implements the image detection method as described in the above aspects.
[0093] The method provided by the embodiment of the present disclosure uses an image generation model to perform style transfer to obtain a target image and determine a sample image. Since the higher the number of training times of the image generation model, the better the style transfer effect of the target image obtained by the image generation model, that is, the more similar the style of the target image is to the target style, the sample label corresponding to the sample image is determined using the number of training times of the image generation model. Then, the image detection model can be trained using the sample image, the sample label, and a standard image of the target style, so that the image detection model automatically learns the deep features related to style detection in the image, so as to perform style detection based on the learned deep features, thereby improving the accuracy of the image detection model.
[0094] 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
[0095] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0096] Figure 1 It is a schematic diagram showing an implementation environment according to an exemplary embodiment.
[0097] Figure 2 The figure is a flowchart of a method for training an image detection model according to an exemplary embodiment.
[0098] Figure 3 The figure is a flowchart of another method for training an image detection model according to an exemplary embodiment.
[0099] Figure 4 The figure is a flowchart of another method for training an image detection model according to an exemplary embodiment.
[0100] Figure 5 The figure is a flow chart of an image detection method according to an exemplary embodiment.
[0101] Figure 6 is a flow chart of another image detection method according to an exemplary embodiment.
[0102] Figure 7 It is a block diagram of a training device for an image detection model according to an exemplary embodiment.
[0103] Figure 8 It is a block diagram of another image detection model training device according to an exemplary embodiment.
[0104] Fig. 9 is a block diagram of an image detection device according to an exemplary embodiment.
[0105] Fig.10 It is a block diagram of a terminal according to an exemplary embodiment.
[0106] Fig.11 It is a block diagram of a server according to an exemplary embodiment. DETAILED DESCRIPTION
[0107] 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.
[0108] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned figure descriptions 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 interchangeable 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.
[0109] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0110] The execution subject of the embodiment of the present disclosure is an electronic device. Exemplarily, the electronic device is a terminal, which is a computer, a mobile phone, a tablet computer or other terminals. Exemplarily, the electronic device is a server, which is a background server or a cloud server that provides cloud computing and cloud storage services. Among them, the electronic device uses an image generation model to obtain sample images and corresponding sample labels, and then uses the sample images, sample labels and standard images to train an image detection model, and then uses the image detection model to detect the similarity between the styles of any two images.
[0111] Figure 1 is a schematic diagram of an implementation environment provided by an embodiment of the present disclosure. Figure 1 , the implementation environment includes a terminal 101 and a server 102. The terminal 101 and the server 102 are connected via a wireless or wired network.
[0112] Exemplarily, the terminal 101 is installed with a target application provided by the server 102, and the terminal 101 can realize functions such as image style migration and style detection through the target application. Of course, the target application can also have other functions, such as network social functions, video sharing functions, or chat functions. Exemplarily, the target application is a target application in the operating system of the terminal 101, or a target application provided by a third party. Exemplarily, the target application is a short video application, a game application, a social application, or other application, which is not limited in the embodiments of the present disclosure.
[0113] In the disclosed embodiment, the server 102 trains an image detection model and provides the trained image detection model and a standard image of a target style to the terminal 101. After the terminal 101 performs style transfer on the original image, a target image is obtained, and the style of the target image is detected by using the trained image detection model and the standard image to determine whether the style of the target image has been successfully transferred to the target style.
[0114] The image detection method provided by the embodiments of the present disclosure can be applied to any scenario where style detection is required.
[0115] For example, it is applied to the scenario of making hand-drawn style images. The terminal stores an image detection model trained by the method provided by the embodiment of the present disclosure. After the user takes a photo at the terminal, he wants to transfer the style of the photo to the hand-drawn style to increase the interest of the photo. The terminal then transfers the style of the photo to the hand-drawn style multiple times to obtain multiple images after style transfer. Then, the image detection model is called to compare the multiple images with the standard images belonging to the hand-drawn style respectively to obtain the similarity between the styles of the multiple images and the style of the standard image. The image with the greatest similarity is the image closest to the hand-drawn style, that is, the image with the best effect of image style transfer, so the terminal displays the image to the user.
[0116] Figure 2 is a flowchart of a method for training an image detection model according to an exemplary embodiment, the method being executed by an electronic device, see Figure 2 , the method comprises the following steps:
[0117] 201. The electronic device obtains a standard image belonging to a target style, where the target style is any style.
[0118] The standard image refers to a real image of the target style, rather than an image obtained through style transfer. In the embodiment of the present disclosure, the standard image is a reference standard for style detection. The content of the standard image can be any type of content, and the embodiment of the present disclosure does not limit the content of the standard image.
[0119] 202. The electronic device calls the image generation model being trained to perform style transfer on the original image to obtain a target image. The image generation model is used to generate an image of the target style.
[0120] Since the disclosed embodiment does not limit whether the style of the target image is the true target style, the image generation model can be a model with higher accuracy or a model with lower accuracy. If the accuracy of the image generation model is lower, the style of the generated target image is far from the target style, and if the accuracy of the image generation model is higher, the style of the generated target image is closer to the target style.
[0121] 203. The electronic device determines, based on the target image, a first sample image that matches the style of the target image, and determines, based on the current number of training times of the image generation model, a sample label corresponding to the first sample image.
[0122] After the electronic device acquires the target image, it determines a first sample image for training the image detection model based on the target image, and the style of the first sample image is determined by the style of the target image.
[0123] The sample label is used to represent the actual similarity between the style of the first sample image and the target style, and the sample label is positively correlated with the number of times the image generation model is trained. The more times the image generation model is trained, the higher the actual similarity represented by the sample label, and the fewer times the image generation model is trained, the lower the actual similarity represented by the sample label.
[0124] The higher the number of training iterations of the image generation model, the better the style transfer effect of the target image obtained by the image generation model, that is, the more similar the style of the target image is to the target style. The higher the number of training iterations of the image generation model, the worse the style transfer effect of the target image obtained by the image generation model, that is, the less similar the style of the target image is to the target style. Therefore, using the number of training iterations of the image generation model to determine the sample label corresponding to the sample image is equivalent to using an unsupervised method to generate a "pseudo label" for the first sample image, thereby constructing the sample data required for the training image detection model.
[0125] 204. The electronic device calls the image detection model to be trained, compares the first sample image with the standard image, and obtains a first detection label.
[0126] After the electronic device obtains the first sample image and the standard image, it calls the image detection model to be trained, compares the first sample image with the standard image, and obtains a first detection label. The first detection label is used to represent the predicted similarity between the style of the first sample image and the target style. The predicted similarity refers to the similarity predicted by the image detection model, not the actual similarity.
[0127] 205. The electronic device trains the image detection model to be trained based on the sample label and the first detection label to obtain a trained image detection model, and the trained image detection model is used to detect the similarity between the styles of any two images.
[0128] Since the sample label represents the actual similarity, and the first detection label is the predicted similarity obtained by calling the image detection model, the electronic device can determine whether the first detection label obtained by the image detection model is accurate based on the sample label. The electronic device trains the image detection model to be trained based on the sample label and the first detection label to obtain a trained image detection model. The similarity predicted by the trained image detection model is more accurate, thereby improving the accuracy of the image detection model.
[0129] It should be noted that the above steps 204-205 are only described by taking one training process as an example. In another embodiment, the electronic device obtains multiple first sample images and corresponding sample labels, and repeatedly executes the above steps 204-205 to iteratively train the image detection model to be trained, thereby obtaining a more accurate image detection model.
[0130] The method provided by the embodiment of the present disclosure uses an image generation model to perform style transfer to obtain a target image and determine a sample image. Since the higher the number of training times of the image generation model, the better the style transfer effect of the target image obtained by the image generation model, that is, the more similar the style of the target image is to the target style, the sample label corresponding to the sample image is determined using the number of training times of the image generation model. Then, the image detection model can be trained using the sample image, the sample label, and a standard image of the target style, so that the image detection model automatically learns the deep features related to style detection in the image, so as to perform style detection based on the learned deep features, thereby improving the accuracy of the image detection model.
[0131] Furthermore, the disclosed embodiment provides a method for training an image detection model, which facilitates the subsequent direct use of the trained image detection model to detect the similarity between the styles of any two images, thereby facilitating the automation of style detection and improving the efficiency of style detection.
[0132] Figure 3 is a flowchart of another method for training an image detection model according to an exemplary embodiment. The method is executed by an electronic device. In the embodiment of the present disclosure, a process of obtaining a first sample image and a sample label corresponding to the first sample image is specifically described. Figure 3 , the method comprises the following steps:
[0133] 301. The electronic device obtains a standard image belonging to a target style, where the target style is any style.
[0134] The step 301 is the same as the above step 201 and will not be described in detail here.
[0135] 302. The electronic device determines a plurality of candidate image generation models being trained, and selects, from the plurality of candidate image generation models, the image generation model whose accuracy is less than a target threshold.
[0136] Among them, each candidate image generation model has its own training times and its own accuracy, and different candidate image generation models have different current training times. The accuracy indicates the accuracy of the image generated by the candidate image generation model belonging to the target style. The training times of the multiple candidate image generation models are different. The more training times a candidate image generation model has, the higher the accuracy of the candidate image generation model, and the fewer training times a candidate image generation model has, the lower the accuracy of the candidate image generation model. Therefore, in the initial stage of training, the accuracy of the candidate image generation model is low, and in the stable stage of training, the accuracy of the candidate image generation model is high.
[0137] In the disclosed embodiment, the number of training times of the image generation model will be used to determine the sample labels subsequently, that is, the number of training times is used to determine the similarity between the style of the sample image obtained based on the target image and the style of the standard image. Considering that the image generation model converges faster in the initial stage of training, the similarity between the style of the sample image and the style of the standard image is more obviously affected by the number of training times of the image generation model. Therefore, selecting an image generation model with an accuracy less than the target threshold to generate the target image can ensure the accuracy of the sample labels determined based on the number of training times.
[0138] Optionally, the electronic device determines the FID (Fréchet Inception Distance, an evaluation index for the model) of the candidate image generation model as the accuracy of the candidate image generation model.
[0139] Optionally, the electronic device determines the change amplitudes corresponding to the multiple candidate image generation models in order of the number of training times from small to large, and the change amplitude corresponding to the candidate image generation model refers to the difference between the accuracy of the candidate image generation model and the accuracy of the previous candidate image generation model. The electronic device determines the candidate image generation model corresponding to the first change amplitude that is less than a preset value, and determines the accuracy of the candidate image generation model as the target threshold.
[0140] 303. The electronic device calls the selected image generation model to perform style transfer on the original image to obtain a target image. The image generation model is used to generate an image of the target style.
[0141] The step 303 is the same as the above step 202 and will not be described in detail here.
[0142] 304. The electronic device determines the target image as a first sample image.
[0143] In the disclosed embodiment, after acquiring the target image generated by the image generation model, the electronic device directly determines the target image as a sample image for training the image detection model, thereby providing a method for automatically generating sample images without the need for manual selection of sample images, thereby improving efficiency.
[0144] 305. The electronic device determines a sample label corresponding to the first sample image based on the number of training times of the image generation model, where the sample label is positively correlated with the number of training times of the image generation model.
[0145] The sample label is used to represent the actual similarity between the style of the first sample image and the target style. The more times the image generation model is trained, the higher the actual similarity represented by the sample label, and the fewer times the image generation model is trained, the lower the actual similarity represented by the sample label.
[0146] The higher the number of training iterations of the image generation model, the better the style transfer effect of the target image obtained by the image generation model, that is, the more similar the style of the target image is to the target style. The higher the number of training iterations of the image generation model, the worse the style transfer effect of the target image obtained by the image generation model, that is, the less similar the style of the target image is to the target style. Therefore, using the number of training iterations of the image generation model to determine the sample label corresponding to the sample image is equivalent to using an unsupervised method to generate a "pseudo label" for the first sample image, thereby constructing the sample data required for the training image detection model.
[0147] 306. The electronic device calls the image detection model to be trained, compares the first sample image with the standard image, and obtains a first detection label, where the first detection label is used to indicate the predicted similarity between the style of the first sample image and the target style.
[0148] In a possible implementation, the image detection model to be trained includes a feature extraction network and a classification network. The electronic device calls the feature extraction network to extract features from the first sample image and the standard image, respectively, to obtain a sample style feature of the first sample image and a standard style feature of the standard image. The classification network is called to classify the difference features between the sample style feature and the standard style feature, to obtain a first detection label.
[0149] Optionally, the classification network includes N classification layers, where N is an integer greater than 1. The electronic device determines the difference features between the sample style features and the standard style features; calls the N classification layers respectively to classify the difference features to obtain N classification labels, wherein the i-th classification label is used to indicate whether the probability that the style represented by the sample style features belongs to the style represented by the standard style features is greater than the ratio of i-1 to N, where i is a positive integer not greater than N; and fuses the N classification labels to obtain a first detection label.
[0150] 307. The electronic device trains the image detection model to be trained based on the sample label and the first detection label to obtain a trained image detection model, where the trained image detection model is used to detect the similarity between the styles of any two images.
[0151] Since the sample label represents the actual similarity, and the first detection label is the predicted similarity obtained by calling the image detection model to be trained, the electronic device can determine whether the first detection label obtained by the image detection model to be trained is accurate based on the sample label. The electronic device trains the image detection model to be trained based on the sample label and the first detection label to obtain a trained image detection model, so that the similarity predicted by the trained image detection model is more accurate, thereby improving the accuracy of the image detection model.
[0152] In one possible implementation, the electronic device determines a first loss value based on a difference between a sample label and a first detection label, and trains the image detection model to be trained based on the first loss value.
[0153] Considering that the closer the first detection label is to the sample label, the more accurate the first detection label is, and the more accurate the image detection model to be trained is, therefore, the electronic device determines a first loss value based on the difference between the sample label and the first detection label, and trains the image detection model to be trained based on the first loss value, so that the difference between the first detection label predicted by the trained image detection model and the sample label becomes smaller, that is, the first loss value becomes smaller, thereby obtaining a more accurate image detection model.
[0154] In one possible implementation, the image detection model to be trained corresponds to a loss function, and the loss function is used to determine the first loss value based on the sample label and the first detection label. The electronic device initializes the model parameters and the target training times in the image detection model, reversely derives the loss function of the image detection model, and updates the model parameters based on the gradient corresponding to the loss function after reverse derivation. When the number of updates reaches the target training times, the training is stopped and the current image detection model is saved to obtain a trained image detection model.
[0155] Optionally, the electronic device uses a uniform initialization method to initialize the model parameters in the image detection model to be trained, and initializes the number of training times t=0, and sets the target number of training times to E. Further, the loss function L is reversely derived to obtain the partial derivatives of L with respect to the model parameters, and the model parameters are updated by gradient back propagation. Each time the model parameters are updated, the number of training times t is increased by 1, and it is determined whether t meets the training termination condition: if t≤E, the above steps of updating the model parameters are repeated; if t>E, the training is stopped to obtain a trained image detection model.
[0156] The method provided by the embodiment of the present disclosure uses an image generation model to perform style transfer to obtain a target image and determine a sample image. Since the higher the number of training times of the image generation model, the better the style transfer effect of the target image obtained by the image generation model, that is, the more similar the style of the target image is to the target style, the sample label corresponding to the sample image is determined using the number of training times of the image generation model. Then, the image detection model can be trained using the sample image, the sample label, and a standard image of the target style, so that the image detection model automatically learns the deep features related to style detection in the image, so as to perform style detection based on the learned deep features, thereby improving the accuracy of the image detection model.
[0157] Figure 4 is a flowchart of another method for training an image detection model according to an exemplary embodiment. The method is executed by an electronic device. In the embodiment of the present disclosure, a process of obtaining a first sample image and a sample label corresponding to the first sample image is specifically described. Figure 4 , the method comprises the following steps:
[0158] 401. The electronic device obtains a standard image belonging to a target style, where the target style is any style.
[0159] The step 401 is the same as the above step 201 and will not be described in detail here.
[0160] 402. The electronic device determines a plurality of image generation models, and different image generation models are currently trained at different times. The electronic device calls the plurality of image generation models to perform style transfer on the original images respectively, and obtains a plurality of target images.
[0161] Since the multiple image generation models are trained at different times, the accuracies of the multiple image generation models are also different, and the styles of the target images generated by the multiple image generation models are also different.
[0162] Optionally, the multiple image generation models include a first image generation model and a second image generation model. The process of the electronic device determining the first image generation model and the second image generation model includes: determining multiple candidate image generation models, each candidate image generation model has its own training times and its own accuracy, and different candidate image generation models have different current training times, and the accuracy represents the accuracy of the image generated by the candidate image generation model belonging to the target style. Among the multiple candidate image generation models, select the first image generation model with an accuracy equal to the target threshold, and select the second image generation model with the maximum accuracy.
[0163] Among them, the multiple candidate image generation models are the same as the multiple candidate image generation models mentioned in step 302. Since the accuracy is positively correlated with the number of training times, the accuracy of the candidate image generation model is low in the initial stage of training, and the accuracy of the candidate image generation model is high in the stable stage of training. In the embodiment of the present disclosure, the number of training times of the image generation model will be used to determine the sample label later, that is, the number of training times is used to determine the similarity between the style of the sample image obtained based on the target image and the style of the standard image. Considering that the image generation model converges slowly in the stable stage of training, and the quality of the generated target image fluctuates, the similarity between the style of the sample image and the style of the standard image is less affected by the number of training times of the image generation model. Therefore, only the first image generation model with an accuracy equal to the target threshold and the second image generation model with the maximum accuracy are selected to generate the target image, thereby avoiding large errors in the obtained sample labels and ensuring the accuracy of the sample labels determined based on the number of training times.
[0164] 403. The electronic device determines an image obtained by fusing the multiple target images as a first sample image.
[0165] The electronic device fuses the multiple target images to obtain a fused image, and determines the fused image as a first sample image.
[0166] Optionally, the electronic device performs weighted fusion of the multiple target images based on the weights of the multiple image generation models, and determines the fused image as the first sample image. In the disclosed embodiment, when fusing the multiple target images, the weights of the image generation models are taken into consideration. Since different image generation models have different training times, that is, different accuracies, fusing according to the weights of the image generation models is conducive to grasping the accuracy of the first sample image.
[0167] For example, the multiple image generation models include a first image generation model and a second image generation model, the weight of the first image generation model is a, the weight of the second image generation model is b, the target image generated by the first image generation model is X, and the image generated by the second image generation model is Y, then the electronic device determines the image Z obtained by a*X+b*Y as the first sample image.
[0168] Optionally, the electronic device performs pixel-domain interpolation processing on the multiple target images based on the weights of the multiple image generation models, and determines the image obtained after the interpolation processing as the first sample image.
[0169] 404. The electronic device performs weighted average of the training times of the multiple image generation models to obtain an average training time, and performs normalization processing on the average training time to obtain the sample label.
[0170] Optionally, the electronic device performs weighted average of the training times of the multiple image generation models based on the weights of the multiple image generation models to obtain an average training time, and performs normalization processing on the average training time to obtain the sample label. In the disclosed embodiment, when the training times of the multiple image generation models are fused, the weights of the image generation models are taken into account, which can improve the accuracy of the determined sample labels.
[0171] For example, the multiple image generation models include a first image generation model and a second image generation model, the weight of the first image generation model is a, the weight of the second image generation model is b, the number of training times of the first image generation model is m, and the number of training times of the second image generation model is n, then the electronic device determines the number of training times obtained by a*m+b*n as the sample label.
[0172] Since the accuracy of the target image generated by the image generation model has a certain degree of randomness, in order to ensure that the error between the first sample image and the corresponding sample label is not too large, the electronic device fuses the multiple target images to obtain a fused image, determines the fused image as the first sample image, and determines the number of training times obtained by fusing the training times of the multiple image generation models as the sample label, thereby reducing the error between the first sample image and the corresponding sample label and ensuring the accuracy of the first sample image and the corresponding sample label.
[0173] 405. The electronic device calls the image detection model to be trained, compares the first sample image with the standard image, and obtains a first detection label, where the first detection label is used to indicate the predicted similarity between the style of the first sample image and the target style.
[0174] 406. The electronic device trains the image detection model to be trained based on the sample label and the first detection label to obtain a trained image detection model, where the trained image detection model is used to detect the similarity between the styles of any two images.
[0175] Step 405-step 406 are similar to the above-mentioned step 306-step 307, and will not be described in detail here.
[0176] The method provided by the embodiment of the present disclosure uses an image generation model to perform style transfer to obtain a target image and determine a sample image. Since the higher the number of training times of the image generation model, the better the style transfer effect of the target image obtained by the image generation model, that is, the more similar the style of the target image is to the target style, the sample label corresponding to the sample image is determined using the number of training times of the image generation model. Then, the image detection model can be trained using the sample image, the sample label, and a standard image of the target style, so that the image detection model automatically learns the deep features related to style detection in the image, so as to perform style detection based on the learned deep features, thereby improving the accuracy of the image detection model.
[0177] It should be noted that the above Figure 3 The embodiments shown and Figure 4 The embodiment shown is only described by taking the acquisition of a first sample image and a corresponding sample label as an example. In another embodiment, the electronic device acquires multiple first sample images and corresponding sample labels, and uses the acquired multiple first sample images and corresponding sample labels to train the image detection model. The specific process of acquiring multiple first sample images is as follows.
[0178] The electronic device obtains multiple candidate image generation models, each of which has its own number of training times and its own accuracy. The electronic device divides the multiple candidate image generation models into models for the initial training stage and models for the stable training stage according to the target threshold. Among them, the candidate image generation model with an accuracy less than the target threshold belongs to the model for the initial training stage, the candidate image generation model with an accuracy greater than or equal to the target threshold belongs to the model for the stable training stage, the candidate image generation model with an accuracy equal to the target threshold belongs to the starting point model for the stable training stage, that is, the first image generation model, and the candidate image generation model with the maximum accuracy belongs to the end point model for the stable training stage, that is, the second image generation model.
[0179] For each candidate image generation model in the initial stage of training, since the convergence speed in the initial stage of training is significantly faster and can capture low-frequency and simple features, the accuracy of the image generation model is more obviously affected by the number of training times. Therefore, the error of the sample labels determined according to the number of training times of these candidate image generation models is small. Therefore, the electronic device can determine the multiple candidate image generation models in the initial stage of training as the image generation model for generating the target image. In addition, for each image generation model, the electronic device calls the image generation model, performs style transfer on the original image, obtains a target image, determines the target image as the first sample image, and determines the sample label corresponding to the first sample image based on the number of training times of the image generation model.
[0180] For each candidate image generation model in the stable training stage, since the convergence speed in the stable training stage is slow and the accuracy of the generated image fluctuates, the error of the sample label determined according to the number of training times of these candidate image generation models is large. Therefore, the electronic device only determines the starting model and the end point model in the stable training stage as the image generation model for generating the target image. Optionally, the electronic device calls the starting model to perform style transfer on the original image to obtain a first target image, and calls the end point model to perform style transfer on the original image to obtain a second target image. The electronic device performs weighted fusion on the first target image and the second target image based on the weight of the starting model and the weight of the end point model to obtain a first sample image, and performs weighted fusion on the number of training times of the starting model and the number of training times of the end point model based on the weight of the starting model and the weight of the end point model to obtain the sample label corresponding to the first sample image. By setting different weights for the starting model and the end point model, different first sample images and corresponding sample labels can be obtained.
[0181] The above embodiment only takes the training of the image detection model to be trained based on the sample label and the first detection label as an example. In addition, the electronic device can also use other methods to obtain other types of labels and train the image detection model to be trained in combination with other types of labels. Therefore, the embodiment of the present disclosure also provides the following three methods for training the image detection model.
[0182] The first training method: the electronic device performs various types of enhancement processing on the standard image to obtain multiple enhanced images; the image detection model to be trained is called to compare the first sample image with each enhanced image respectively to obtain multiple first enhancement labels, where the first enhancement label is used to represent the predicted similarity between the style of the first sample image and the style of the enhanced image; based on any difference between any two of the first enhancement labels or any difference between the sample label and each of the first enhancement labels, as well as the difference between the sample label and the first detection label, the image detection model to be trained is trained to obtain the trained image detection model.
[0183] Among them, the various types of enhancement processing are all processing methods that do not destroy the image style, such as rotation processing, cropping processing, reduction processing or enlargement processing, so the style of the multiple enhanced images is the same as the style of the standard image, that is, they all belong to the target style. Since the style of each enhanced image belongs to the same style, the closer the predicted similarity between the style of the first sample image and the style of each enhanced image, that is, the closer any two first enhancement labels are, the more accurate the image detection model is. Therefore, the image detection model to be trained can also be combined with the difference between any two first enhancement labels or the difference between the sample label and each of the first enhancement labels to obtain the trained image detection model, which is conducive to improving the robustness of the image detection model.
[0184] Optionally, the electronic device determines a first loss parameter based on the difference between the sample label and the first detection label, determines a second loss parameter based on the difference between any two first enhanced labels, trains the image detection model to be trained based on the first loss parameter and the second loss parameter, and obtains the trained image detection model. Alternatively, the electronic device determines a first loss parameter based on the difference between the sample label and the first detection label, determines a fifth loss parameter based on the difference between the sample label and each of the first enhanced labels, trains the image detection model to be trained based on the first loss parameter and the fifth loss parameter, and obtains the trained image detection model.
[0185] Among them, the first loss parameter can represent the difference between the sample label and the first detection label, and the first loss parameter is positively correlated with the difference, the second loss parameter can represent the difference between the two first enhanced labels, and the second loss parameter is positively correlated with the difference, and the fifth loss parameter can represent the difference between the sample label and each first enhanced label, and the fifth loss parameter is positively correlated with the difference. The electronic device trains the image detection model to be trained based on the first loss parameter and the second loss parameter to obtain the trained image detection model, so that the first loss parameter and the second loss parameter obtained based on the trained image detection model become smaller, thereby obtaining a more accurate image detection model. Alternatively, the electronic device trains the image detection model to be trained based on the first loss parameter and the fifth loss parameter to obtain the trained image detection model, so that the first loss parameter and the fifth loss parameter obtained based on the trained image detection model become smaller, thereby obtaining a more accurate image detection model.
[0186] The second training method: the electronic device performs various types of enhancement processing on the standard image to obtain multiple enhanced images; calls the image detection model to be trained, compares any two enhanced images, and obtains multiple second enhancement labels, where the second enhancement labels are used to indicate the predicted similarity between the styles of any two enhanced images. The electronic device obtains a target label, where the target label indicates that the styles of any two enhanced images are the same; based on the difference between the sample label and the first detection label, and the difference between each second enhancement label and the target label, the image detection model to be trained is trained to obtain the trained image detection model.
[0187] Among them, the various types of enhancement processing are all processing methods that do not destroy the image style, so the style of the multiple enhanced images is the same as the style of the standard image, that is, they all belong to the target style. Since the style of each enhanced image belongs to the same style, the closer the second enhancement label between any two enhanced images should be to the target label, the more accurate the image detection model is. Therefore, the image detection model can also be trained in combination with the difference between each second enhancement label and the target label, which is conducive to improving the robustness of the image detection model.
[0188] Optionally, the electronic device determines a first loss parameter based on the difference between the sample label and the first detection label; determines a third loss parameter based on the difference between each second enhanced label and the target label; and trains the image detection model to be trained based on the first loss parameter and the third loss parameter to obtain the trained image detection model.
[0189] The first loss parameter can represent the difference between the sample label and the first detection label, and the first loss parameter is positively correlated with the difference. The third loss parameter can represent the difference between the second enhanced label and the target label, and the third loss parameter is positively correlated with the difference. The electronic device trains the image detection model to be trained based on the first loss parameter and the third loss parameter to obtain the trained image detection model, so that the first loss parameter and the third loss parameter obtained based on the trained image detection model become smaller, thereby obtaining a more accurate image detection model.
[0190] The third training method: the electronic device obtains a second sample image, which is an image that does not belong to the target style; calls the image detection model to be trained, compares the first sample image with the second sample image, and obtains a second detection label, and the second detection label is used to indicate the predicted similarity between the style of the first sample image and the style of the second sample image; based on the difference between the sample label and the first detection label, and the difference between the first detection label and the second detection label, trains the image detection model to be trained to obtain the trained image detection model.
[0191] Among them, since the second sample image is an image that does not belong to the target style, and the first sample image is an image generated by the image generation model, and the image generation model is used to generate an image of the target style, the smaller the predicted similarity between the style of the first sample image and the style of the second sample image, the more accurate the image detection model is. Therefore, the image detection model can also be trained in combination with the second detection label, which is conducive to improving the robustness of the image detection model.
[0192] Optionally, the electronic device determines a first loss parameter based on a difference between the sample label and the first detection label, and determines a fourth loss parameter based on a difference between the first detection label and the second detection label. The electronic device trains the image detection model to be trained based on the first loss parameter and the fourth loss parameter to obtain the trained image detection model.
[0193] Among them, the first loss parameter can represent the difference between the sample label and the first detection label, and the first loss parameter is positively correlated with the difference, and the fourth loss parameter can represent the difference between the first detection label and the second detection label, and the fourth loss parameter is negatively correlated with the difference. The electronic device trains the image detection model to be trained based on the first loss parameter and the fourth loss parameter to obtain the trained image detection model, so that the first loss parameter and the fourth loss parameter obtained based on the trained image detection model become smaller, thereby obtaining a more accurate image detection model.
[0194] It should be noted that the above three training methods can be combined arbitrarily, that is, the electronic device can train the image detection model based on the first loss parameter and at least one of the second loss parameter, the third loss parameter, the fourth loss parameter or the fifth loss parameter.
[0195] In one possible implementation, the electronic device determines a target loss parameter based on the first loss parameter, the second loss parameter, the third loss parameter, and the fourth loss parameter, and trains an image detection model based on the target loss parameter.
[0196] For example, the electronic device uses the following formula to determine the target loss parameter.
[0197]
[0198] Among them, L represents the target loss parameter, L 1 [p(I r ,I g ),t(I r ,I g )] represents the first loss parameter, p(I r ,I g ) represents the first detection tag, t(I r ,I g ) represents the sample label, I r represents the enhanced image, I g Represents the first sample image. represents the second loss parameter, and They respectively represent the first enhanced labels corresponding to different enhanced images, and They represent different enhanced images respectively. represents the third loss parameter, represents the second enhanced label, and 1 represents the target label. represents the fourth loss parameter, represents the average value of each value in the second detection label, s(I r ,I g ) represents the average value of each value in the first detection label, Represents the second sample image. 1 , 2 and λ 3 are all weighting coefficients.
[0199] Among them, L 1 [·] and L 3 [·] represents the cross entropy loss function.
[0200] in, represents the square of the 2-norm.
[0201] in, max[·] means taking the maximum value, and γ is the coefficient.
[0202] In the embodiments of the present disclosure, a variety of loss parameters determined in different ways are provided to train the image detection model from different angles, so that the image detection model can learn deep features for style detection in a variety of images, which is beneficial to improving the robustness and accuracy of the image detection model.
[0203] Figure 5 is a flowchart of an image detection method according to an exemplary embodiment. Figure 5 The method is performed by an electronic device and comprises the following steps:
[0204] 501. The electronic device obtains a standard image belonging to a target style, where the target style is any style.
[0205] The standard image refers to a real image of the target style, rather than an image obtained through style transfer. In the embodiment of the present disclosure, the standard image is a reference standard for style detection. The content of the standard image can be any type of content, and the embodiment of the present disclosure does not limit the content of the standard image.
[0206] 502. The electronic device transfers the style of the first image to a target style to obtain a second image of the target style.
[0207] In the disclosed embodiments, style transfer refers to converting the style of one image to another style while keeping the content of the image unchanged, such as artistic style transfer, gender style transfer, age style transfer, etc.
[0208] The first image is an image that needs to be transferred to a target style, and the style of the first image is different from the target style. Since the effect of style transfer on the first image is affected by many factors, such as the means used, the target style to be transferred, the content in the first image, and the style of the first image, after obtaining the second image, the embodiment of the present disclosure will perform the following step 503 to detect the effect of the style transfer to determine whether the style of the first image has been successfully transferred to the target style.
[0209] The style of the first image is any style except the target style. For example, the style of the first image is a realistic style, and the target style is a hand-painted style or a comic style.
[0210] 503. The electronic device calls the trained image detection model, compares the second image with the standard image, and obtains a target detection label.
[0211] The trained image detection model is used to detect the similarity between the styles of any two images. The training process of the image detection model is detailed in the above Figures 2 to 4 The embodiment shown will not be described here for the time being.
[0212] After the electronic device acquires the second image and the standard image, in order to detect the style transfer effect of the second image, the trained image detection model is called to compare the second image with the standard image to obtain a target detection label, which is used to indicate the similarity between the style of the second image and the style of the standard image.
[0213] Among them, since the expected style of the second image is the target style and the standard image belongs to the target style, the higher the similarity between the style of the second image and the style of the standard image, the closer the second image is to the target style, that is, the better the effect of image style transfer.
[0214] The method provided by the embodiment of the present disclosure introduces a standard image of the target style in order to detect the effect of image style transfer. The second image obtained after style transfer is compared with the standard image using a trained image detection model to obtain the similarity between the style of the second image and the style of the standard image, that is, to determine the degree of proximity between the style of the second image and the expected target style, thereby providing an image detection method using the standard image as a reference, which can improve the accuracy of style detection.
[0215] In the disclosed embodiment, the trained image detection model includes a feature extraction network and a classification network, the feature extraction network is connected to the classification network, the feature extraction network is used to extract the style features of the image, and the classification network is used to classify the difference features between two style features to obtain the similarity between the two style features. The specific process of calling the trained image detection model for image detection is as follows.
[0216] Figure 6 is a flowchart of another image detection method according to an exemplary embodiment, the method is executed by an electronic device, see Figure 6 , the method comprises the following steps:
[0217] 601. The electronic device obtains a standard image belonging to a target style, where the target style is any style.
[0218] In a possible implementation, the electronic device can transfer multiple styles, and the electronic device stores a standard image corresponding to each style. Therefore, when detecting whether the style of the second image belongs to the target style, it is sufficient to obtain a standard image belonging to the target style from the stored multiple standard images.
[0219] 602. The electronic device transfers the style of the first image to a target style to obtain a second image of the target style.
[0220] In a possible implementation, the electronic device determines a trained image generation model, which is used to generate an image of a target style. The electronic device calls the trained image generation model to perform style transfer on the first image to obtain the second image.
[0221] The image generation model can transfer the source domain image to the target domain image. The source domain image refers to the image to be transferred, and the target domain image refers to the image of the target style. The image style transfer task implemented by the image generation model is also called the image translation task, which is to "translate" the image from the source domain to the target domain. The image generation model can be any type of model, which is not limited in the embodiments of the present disclosure.
[0222] 603. The electronic device calls a feature extraction network to perform feature extraction on the second image and the standard image respectively to obtain target style features of the second image and standard style features of the standard image.
[0223] After the electronic device obtains the second image and the standard image, it inputs the second image and the standard image into a feature extraction network, which performs feature extraction on the second image and outputs target style features of the second image, and performs feature extraction on the standard image and outputs standard style features of the standard image.
[0224] The standard style feature is used to represent the style of the standard image. The target style feature of the second image is used to represent the style of the second image. Optionally, the target style feature and the standard style feature may be in the form of a feature vector or a feature matrix, etc., which is not limited in the embodiments of the present disclosure.
[0225] 604. The electronic device calls a classification network to classify the difference features between the target style features and the standard style features to obtain a target detection label.
[0226] After the electronic device obtains the target style features and the standard style features, it inputs the difference features between the target style features and the standard style features into the classification network. The classification network classifies the difference features and outputs a target detection label, which is used to indicate the similarity between the style of the second image and the style of the standard image.
[0227] In the disclosed embodiment, a feature extraction network is called to automatically extract style-related deep features from the second image and the standard image, and then classification is performed based on the difference features between the extracted deep features to obtain the similarity between the style of the second image and the style of the standard image. Therefore, the style-related deep features are utilized in the image detection process, which can ensure the accuracy of image detection.
[0228] In a possible implementation, the classification network includes N classification layers, where N is an integer greater than 1. The electronic device determines the difference features between the target style features and the standard style features, calls the N classification layers respectively, classifies the difference features, obtains N classification labels, and fuses the N classification labels to obtain the target detection label.
[0229] Among them, the i-th classification label is used to indicate whether the probability that the style represented by the target style feature belongs to the style represented by the standard style feature is greater than the ratio of i-1 to N, and i is a positive integer not greater than N. In the disclosed embodiment, the maximum probability that the style represented by the target style feature belongs to the style represented by the standard style feature is 1. In order to predict the probability that the style represented by the target style feature belongs to the style represented by the standard style feature, the possible probabilities are divided into N cases, namely 0, 1 / N, 2 / N, 3 / N...N-1 / N. The i-th classification layer among the N classification layers is used to predict whether the probability that the style represented by the target style feature belongs to the style represented by the standard style feature is greater than i-1 / N.
[0230] Optionally, the i-th classification layer among the N classification layers is used to predict the probability that the style represented by the target style feature belongs to the style represented by the standard style feature is greater than i-1 / N. For example, the classification label is a value between 0 and 1. When the classification label output by the i-th classification layer is 0.8, it means that the probability that the style represented by the target style feature belongs to the style represented by the standard style feature is greater than i-1 / N is 0.8.
[0231] Optionally, the electronic device determines a difference between the target style feature and the standard style feature, and determines an absolute value of the difference as a difference feature between the target style feature and the standard style feature.
[0232] Optionally, the classification label is a numerical value, and N classification labels are N numerical values, then the electronic device splices the N numerical values into a vector, and determines the spliced vector as the detection label. Alternatively, the electronic device averages the N numerical values, and determines the average value as the detection label.
[0233] In the disclosed embodiment, multiple classification layers are introduced to respectively predict the various probabilities that the style represented by the target style feature belongs to the style represented by the standard style feature, and the classification labels output by the multiple classification layers are fused to obtain the detection labels, thereby providing a fine-grained classification method that is beneficial to improving the accuracy of the detection labels.
[0234] The method provided by the embodiment of the present disclosure introduces a standard image of the target style in order to detect the effect of image style transfer. By comparing the second image obtained after style transfer with the standard image, the similarity between the style of the second image and the style of the standard image is obtained, that is, the degree of proximity between the style of the second image and the expected target style is determined, thereby providing an image detection method with a standard image as a reference, which can improve the accuracy of style detection.
[0235] Figure 7 is a block diagram of a training device for an image detection model according to an exemplary embodiment. Figure 7 The device includes a first acquisition unit 701, a second acquisition unit 702, a first determination unit 703 and a model training unit 704.
[0236] A first acquisition unit 701 is configured to acquire a standard image belonging to a target style, where the target style is any style;
[0237] The second acquisition unit 702 is configured to execute calling the image generation model being trained, perform style transfer on the original image, and obtain a target image, wherein the image generation model is used to generate an image belonging to the target style;
[0238] The first determining unit 703 is configured to determine, based on the target image, a first sample image that matches the style of the target image, and determine, based on the current number of training times of the image generation model, a sample label corresponding to the first sample image, the sample label being used to indicate an actual similarity between the style of the first sample image and the target style, and the sample label being positively correlated with the number of training times of the image generation model;
[0239] The model training unit 704 is configured to execute calling the image detection model to be trained, compare the first sample image with the standard image, and obtain a first detection label, where the first detection label is used to indicate the predicted similarity between the style of the first sample image and the target style;
[0240] The model training unit 704 is further configured to train the image detection model to be trained based on the sample label and the first detection label to obtain a trained image detection model, and the trained image detection model is used to detect the similarity between the styles of any two images.
[0241] The device provided by the embodiment of the present disclosure determines a sample image by using an image generation model to obtain a target image through style transfer. Since the higher the number of training times of the image generation model, the better the style transfer effect of the target image obtained by the image generation model, that is, the more similar the style of the target image is to the target style, the sample label corresponding to the sample image is determined by using the number of training times of the image generation model. Then, the image detection model can be trained using the sample image, the sample label, and a standard image of the target style, so that the image detection model automatically learns the deep features related to style detection in the image, so as to perform style detection based on the learned deep features, thereby improving the accuracy of the image detection model.
[0242] In one possible implementation, see Figure 8 The first determination unit 703 is configured to determine the target image as the first sample image.
[0243] In one possible implementation, see Figure 8 , the device further comprises:
[0244] The second determining unit 705 is configured to determine a plurality of candidate image generation models, each of which has a respective number of training times and a respective accuracy, and different candidate image generation models have different current training times, and the accuracy indicates the accuracy of the image generated by the candidate image generation model and belonging to the target style;
[0245] The model selection unit 706 is configured to select the image generation model whose accuracy is less than a target threshold from among the multiple candidate image generation models.
[0246] In one possible implementation, see Figure 8 , the second acquisition unit 702 is configured to execute:
[0247] Determine multiple image generation models, and different image generation models have different current training times;
[0248] Calling the multiple image generation models to perform style transfer on the original images respectively to obtain multiple target images;
[0249] The first determining unit 703 is configured to determine an image obtained by fusing the multiple target images as the first sample image;
[0250] The first determining unit 703 is further configured to execute:
[0251] Performing a weighted average of the training times of the multiple image generation models to obtain an average training time;
[0252] The average number of training times is normalized to obtain the sample label.
[0253] In one possible implementation, see Figure 8 , the multiple image generation models include a first image generation model and a second image generation model; the second acquisition unit 702 is configured to execute:
[0254] Determine a plurality of candidate image generation models, each candidate image generation model having its own number of training times and its own accuracy, and different candidate image generation models have different current number of training times, and the accuracy represents the accuracy of the image generated by the candidate image generation model and belonging to the target style;
[0255] Among the multiple candidate image generation models, the first image generation model whose accuracy is equal to the target threshold is selected, and the second image generation model whose accuracy is the maximum value is selected.
[0256] In one possible implementation, see Figure 8 , the device further comprises:
[0257] An image enhancement unit 707 is configured to perform various types of enhancement processing on the standard image to obtain multiple enhanced images;
[0258] The model training unit 704 is further configured to execute calling the image detection model to be trained, respectively compare the first sample image with each of the enhanced images, and obtain a plurality of first enhanced labels, wherein the first enhanced labels are used to indicate the predicted similarity between the style of the first sample image and the style of the enhanced image;
[0259] The model training unit 704 is also configured to execute training of the image detection model to be trained based on any one of the differences between any two of the first enhanced labels or the differences between the sample label and each of the first enhanced labels, and the difference between the sample label and the first detection label, to obtain the trained image detection model.
[0260] In one possible implementation, see Figure 8 , the device further comprises:
[0261] An image enhancement unit 707 is configured to perform various types of enhancement processing on the standard image to obtain multiple enhanced images;
[0262] The model training unit 704 is further configured to execute calling the image detection model to be trained, compare any two of the enhanced images, and obtain a plurality of second enhanced labels, where the second enhanced labels are used to represent the predicted similarity between the styles of any two of the enhanced images;
[0263] The model training unit 704 is further configured to execute:
[0264] Obtain a target label, which indicates that any two enhanced images have the same style;
[0265] Based on the difference between the sample label and the first detection label, and the difference between each second enhanced label and the target label, the image detection model to be trained is trained to obtain the trained image detection model.
[0266] In one possible implementation, see Figure 8 , the device further comprises:
[0267] A third acquisition unit 708 is configured to acquire a second sample image, where the second sample image is an image that does not belong to the target style;
[0268] The model training unit 704 is further configured to execute calling the image detection model to be trained, compare the first sample image with the second sample image, and obtain a second detection label, where the second detection label is used to indicate the predicted similarity between the style of the first sample image and the style of the second sample image;
[0269] The model training unit 704 is also configured to train the image detection model to be trained based on the difference between the sample label and the first detection label, and the difference between the first detection label and the second detection label, to obtain the trained image detection model.
[0270] Regarding the device in the above embodiment, the specific manner in which each unit performs the operation has been described in detail in the embodiment of the method, and will not be elaborated here.
[0271] Fig. 9 is a block diagram of an image detection device according to an exemplary embodiment. Fig. 9 The device includes an acquisition unit 901, a style transfer unit 902 and an image detection unit 903.
[0272] An acquisition unit 901 is configured to acquire a standard image belonging to a target style, where the target style is any style;
[0273] A style transfer unit 902 is configured to transfer the style of the first image to the target style to obtain a second image of the target style;
[0274] The image detection unit 903 is configured to execute calling the trained image detection model, compare the second image with the standard image, and obtain an object detection label, where the object detection label is used to indicate the similarity between the style of the second image and the style of the standard image;
[0275] Among them, the trained image detection model is based on Figure 7 or Figure 8 The image detection model shown is trained by the training device.
[0276] The device provided by the embodiment of the present disclosure introduces a standard image of the target style in order to detect the effect of image style transfer. The second image obtained after style transfer is compared with the standard image using a trained image detection model to obtain the similarity between the style of the second image and the style of the standard image, that is, to determine the degree of proximity between the style of the second image and the expected target style, thereby providing an image detection method using the standard image as a reference, which can improve the accuracy of style detection.
[0277] Regarding the device in the above embodiment, the specific manner in which each unit performs the operation has been described in detail in the embodiment of the method, and will not be elaborated here.
[0278] An embodiment of the present disclosure provides an electronic device, which includes: a processor, and a memory for storing instructions executable by the processor, wherein the processor is configured to execute the instructions to implement the above-mentioned image detection method.
[0279] In some embodiments, the electronic device includes a terminal. Fig.10 1 is a block diagram of a terminal 1000 according to an exemplary embodiment. The terminal 1000 may be a portable mobile terminal, such as a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 player (Moving Picture Experts Group Audio Layer IV), a laptop computer or a desktop computer. The terminal 1000 may also be referred to as a user device, a portable terminal, a laptop terminal, a desktop terminal or other names.
[0280] The terminal 1000 includes: a processor 1001 and a memory 1002 .
[0281] The processor 1001 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1001 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1001 may also include a main processor and a coprocessor, the main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. The memory 1002 may include one or more computer-readable storage media, which may be non-transitory. The memory 1002 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1002 is used to store at least one program code, which is used to be executed by the processor 1001 to implement the image detection method provided by the method embodiment of the present disclosure.
[0282] In some embodiments, the terminal 1000 may also optionally include: a peripheral device interface 1003 and at least one peripheral device. The processor 1001, the memory 1002 and the peripheral device interface 1003 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 1003 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: a radio frequency circuit 1004, a display screen 1005, a camera assembly 1006 and a power supply 1007.
[0283] The peripheral device interface 1003 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 1001 and the memory 1002. In some embodiments, the processor 1001, the memory 1002, and the peripheral device interface 1003 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1001, the memory 1002, and the peripheral device interface 1003 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.
[0284] The radio frequency circuit 1004 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1004 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency circuit 1004 converts the electrical signal into an electromagnetic signal for transmission, or converts the received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 1004 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The radio frequency circuit 1004 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 1004 may also include circuits related to NFC (Near Field Communication), which is not limited in the present disclosure.
[0285] The display screen 1005 is used to display a UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 1005 is a touch display screen, the display screen 1005 also has the ability to collect touch signals on the surface or above the surface of the display screen 1005. The touch signal can be input to the processor 1001 as a control signal for processing. At this time, the display screen 1005 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 1005 can be one, arranged on the front panel of the electronic device 1000; in other embodiments, the display screen 1005 can be at least two, respectively arranged on different surfaces of the electronic device 1000 or in a folding design; in other embodiments, the display screen 1005 can be a flexible display screen, arranged on a curved surface or a folding surface of the electronic device 1000. Even, the display screen 1005 can also be arranged as a non-rectangular irregular figure, that is, a special-shaped screen. The display screen 1005 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0286] The camera assembly 1006 is used to capture images or videos. Optionally, the camera assembly 1006 includes a front camera and a rear camera. The front camera is arranged on the front panel of the electronic device, and the rear camera is arranged on the back of the electronic device. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 1006 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.
[0287] The power supply 1007 is used to power various components in the electronic device 1000. The power supply 1007 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 1007 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery charged through a wired line, and a wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0288] Those skilled in the art will understand that Fig.10 The structure shown in the figure does not constitute a limitation on the terminal 1000, and the terminal 1000 may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.
[0289] In some embodiments, the electronic device includes a server. Fig.11 This is a schematic diagram of the structure of a server according to an exemplary embodiment. The server 1100 may have relatively large differences due to different configurations or performances, and may include one or more processors (Central Processing Units, CPU) 1101 and one or more memories 1102, wherein the memory 1102 stores at least one computer program, and the at least one computer program is loaded and executed by the processor 1101 to implement the methods provided by the above-mentioned various method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output. The server may also include other components for implementing device functions, which will not be described in detail here.
[0290] In an exemplary embodiment, a computer-readable storage medium is also provided, and when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can perform the steps in the above-mentioned image detection method. For example, the computer-readable storage medium can be a ROM (Read Only Memory), a RAM (Random Access Memory), a CD-ROM (Compact Disc Read-Only Memory), a magnetic tape, a floppy disk, an optical data storage device, etc.
[0291] In an exemplary embodiment, a computer program product is also provided, including a computer program, and when the computer program is executed by a processor of an electronic device, the steps in the above-mentioned image detection method are implemented.
[0292] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the disclosure herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0293] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A training method for an image detection model, characterized in that: The method comprises: Acquire a standard image belonging to a target style, where the target style is any style; Calling an image generation model being trained to perform style transfer on an original image to obtain a target image, wherein the image generation model is used to generate an image of the target style; the image generation model includes a model whose accuracy is less than a target threshold among a plurality of candidate image generation models, each candidate image generation model has its own training times and its own accuracy, and different candidate image generation models have different current training times, and the accuracy represents the accuracy of the image of the target style generated by the candidate image generation model; Based on the target image, determine a first sample image that matches the style of the target image, and based on the current number of training times of the image generation model, determine a sample label corresponding to the first sample image, the sample label is used to indicate the actual similarity between the style of the first sample image and the target style, and the sample label is positively correlated with the number of training times of the image generation model; Calling the image detection model to be trained, comparing the first sample image with the standard image, and obtaining a first detection label, where the first detection label is used to indicate the predicted similarity between the style of the first sample image and the target style; Based on the sample label and the first detection label, the image detection model to be trained is trained to obtain a trained image detection model, wherein the trained image detection model is used to detect the similarity between the styles of any two images; The method further comprises: Determine the change ranges corresponding to the multiple candidate image generation models in order of the number of training times from small to large; the change range corresponding to the candidate image generation model refers to the difference between the accuracy of the candidate image generation model and the accuracy of the previous candidate image generation model; A candidate image generation model corresponding to a first variation amplitude smaller than a preset value is determined, and the accuracy of the candidate image generation model is determined as the target threshold.
2. The training method of the image detection model according to claim 1, characterized in that: The step of determining, based on the target image, a first sample image that matches the style of the target image comprises: The target image is determined as the first sample image.
3. The training method of the image detection model according to claim 2, characterized in that: The method further comprises: Determining the plurality of candidate image generation models; Among the multiple candidate image generation models, the image generation model whose accuracy is less than the target threshold is selected.
4. The training method of the image detection model according to claim 1, characterized in that: The calling of the image generation model being trained to perform style transfer on the original image to obtain the target image includes: Determine multiple image generation models, and different image generation models have different current training times; Calling the multiple image generation models to perform style transfer on the original images respectively to obtain multiple target images; The step of determining, based on the target image, a first sample image that matches the style of the target image comprises: Determine an image obtained by fusing the multiple target images as the first sample image; The determining, based on the current training times of the image generation model, a sample label corresponding to the first sample image includes: Taking a weighted average of the training times of the multiple image generation models to obtain an average training time; The average number of training times is normalized to obtain the sample label.
5. The method for training an image detection model according to claim 4, characterized in that: The multiple image generation models include a first image generation model and a second image generation model; and determining the multiple image generation models includes: Determining the plurality of candidate image generation models; Among the multiple candidate image generation models, the first image generation model whose accuracy is equal to the target threshold is selected, and the second image generation model whose accuracy is the maximum value is selected.
6. The method for training an image detection model according to any one of claims 1 to 5, characterized in that: The method further comprises: Performing multiple types of enhancement processing on the standard image to obtain multiple enhanced images; Calling the image detection model to be trained, and comparing the first sample image with each of the enhanced images respectively to obtain a plurality of first enhanced labels, where the first enhanced labels are used to indicate the predicted similarity between the style of the first sample image and the style of the enhanced image; The step of training the image detection model to be trained based on the sample label and the first detection label to obtain a trained image detection model includes: Based on any one of the differences between any two of the first enhanced labels or the differences between the sample label and each of the first enhanced labels, and the difference between the sample label and the first detection label, the image detection model to be trained is trained to obtain the trained image detection model.
7. The method for training an image detection model according to any one of claims 1 to 5, characterized in that: The method further comprises: Performing multiple types of enhancement processing on the standard image to obtain multiple enhanced images; Calling the image detection model to be trained, comparing any two of the enhanced images, and obtaining a plurality of second enhanced labels, where the second enhanced labels are used to represent the predicted similarity between the styles of any two of the enhanced images; The step of training the image detection model to be trained based on the sample label and the first detection label to obtain a trained image detection model includes: Obtaining a target tag, wherein the target tag indicates that any two enhanced images have the same style; Based on the difference between the sample label and the first detection label, and the difference between each second enhanced label and the target label, the image detection model to be trained is trained to obtain the trained image detection model.
8. The method for training an image detection model according to any one of claims 1 to 5, characterized in that: The method further comprises: Acquire a second sample image, where the second sample image is an image that does not belong to the target style; calling the image detection model to be trained, comparing the first sample image with the second sample image, and obtaining a second detection label, where the second detection label is used to indicate a predicted similarity between a style of the first sample image and a style of the second sample image; The step of training the image detection model to be trained based on the sample label and the first detection label to obtain a trained image detection model includes: Based on the difference between the sample label and the first detection label, and the difference between the first detection label and the second detection label, the image detection model to be trained is trained to obtain the trained image detection model.
9. An image detection method, characterized in that: The method comprises: Acquire a standard image belonging to a target style, where the target style is any style; Migrating the style of the first image to the target style to obtain a second image of the target style; Calling the trained image detection model, comparing the second image with the standard image, and obtaining an object detection label, where the object detection label is used to indicate the similarity between the style of the second image and the style of the standard image; Wherein, the trained image detection model is trained using the image detection model training method as described in any one of claims 1 to 8.
10. A training device for an image detection model, characterized in that: The device comprises: A first acquisition unit is configured to acquire a standard image belonging to a target style, where the target style is any style; A second acquisition unit is configured to execute calling the image generation model being trained, perform style transfer on the original image, and obtain a target image, wherein the image generation model is used to generate an image belonging to the target style; the image generation model includes a model whose accuracy is less than a target threshold among a plurality of candidate image generation models, each candidate image generation model has its own training times and its own accuracy, and different candidate image generation models have different current training times, and the accuracy represents the accuracy of the image belonging to the target style generated by the candidate image generation model; A first determining unit is configured to determine, based on the target image, a first sample image that matches the style of the target image, and determine, based on a current number of training times of the image generation model, a sample label corresponding to the first sample image, wherein the sample label is used to indicate an actual similarity between the style of the first sample image and the target style, and the sample label is positively correlated with the number of training times of the image generation model; a model training unit configured to execute calling the image detection model to be trained, compare the first sample image with the standard image, and obtain a first detection label, wherein the first detection label is used to indicate a predicted similarity between a style of the first sample image and a target style; The model training unit is further configured to train the image detection model to be trained based on the sample label and the first detection label to obtain a trained image detection model, wherein the trained image detection model is used to detect the similarity between the styles of any two images; Modules for performing the following steps: Determine the change ranges corresponding to the multiple candidate image generation models in order of the number of training times from small to large; the change range corresponding to the candidate image generation model refers to the difference between the accuracy of the candidate image generation model and the accuracy of the previous candidate image generation model; A candidate image generation model corresponding to a first variation amplitude smaller than a preset value is determined, and the accuracy of the candidate image generation model is determined as the target threshold.
11. The training device for an image detection model according to claim 10, characterized in that: The first determining unit is configured to determine the target image as the first sample image.
12. The training device for an image detection model according to claim 11, characterized in that: The device also includes: A second determining unit is configured to determine the plurality of candidate image generation models; The model selection unit is configured to select the image generation model whose accuracy is less than the target threshold from among the multiple candidate image generation models.
13. The training device for an image detection model according to claim 10, characterized in that: The second acquisition unit is configured to execute: Determine multiple image generation models, and different image generation models have different current training times; Calling the multiple image generation models to perform style transfer on the original images respectively to obtain multiple target images; The first determining unit is configured to determine an image obtained by fusing the multiple target images as the first sample image; The first determining unit is further configured to execute: Taking a weighted average of the training times of the multiple image generation models to obtain an average training time; The average number of training times is normalized to obtain the sample label.
14. The training device for an image detection model according to claim 13, characterized in that: The multiple image generation models include a first image generation model and a second image generation model; the second acquisition unit is configured to execute: Determining the plurality of candidate image generation models; Among the multiple candidate image generation models, the first image generation model whose accuracy is equal to the target threshold is selected, and the second image generation model whose accuracy is the maximum value is selected.
15. The training device for an image detection model according to any one of claims 10 to 14, characterized in that: The device also includes: An image enhancement unit, configured to perform various types of enhancement processing on the standard image to obtain a plurality of enhanced images; The model training unit is further configured to execute calling the image detection model to be trained, respectively compare the first sample image with each of the enhanced images, and obtain a plurality of first enhanced labels, wherein the first enhanced labels are used to indicate the predicted similarity between the style of the first sample image and the style of the enhanced image; The model training unit is further configured to execute training of the image detection model to be trained based on any one of the differences between any two of the first enhanced labels or the differences between the sample label and each of the first enhanced labels, and the difference between the sample label and the first detection label, to obtain the trained image detection model.
16. The training device for an image detection model according to any one of claims 10 to 14, characterized in that: The device also includes: An image enhancement unit, configured to perform various types of enhancement processing on the standard image to obtain a plurality of enhanced images; The model training unit is further configured to execute calling the image detection model to be trained, compare any two of the enhanced images, and obtain a plurality of second enhanced labels, where the second enhanced labels are used to represent the predicted similarity between the styles of any two of the enhanced images; The model training unit is further configured to execute: Obtaining a target tag, wherein the target tag indicates that any two enhanced images have the same style; Based on the difference between the sample label and the first detection label, and the difference between each second enhanced label and the target label, the image detection model to be trained is trained to obtain the trained image detection model.
17. The image detection model training device according to any one of claims 10 to 14, characterized in that: The device also includes: A third acquisition unit is configured to acquire a second sample image, where the second sample image is an image that does not belong to the target style; The model training unit is further configured to execute calling the image detection model to be trained, compare the first sample image with the second sample image, and obtain a second detection label, where the second detection label is used to indicate the predicted similarity between the style of the first sample image and the style of the second sample image; The model training unit is further configured to train the image detection model to be trained based on the difference between the sample label and the first detection label, and the difference between the first detection label and the second detection label, to obtain the trained image detection model.
18. An image detection device, characterized in that: The device comprises: An acquisition unit is configured to acquire a standard image belonging to a target style, where the target style is any style; A style transfer unit, configured to transfer the style of the first image to the target style to obtain a second image of the target style; an image detection unit, configured to execute calling the trained image detection model, compare the second image with the standard image, and obtain an object detection label, wherein the object detection label is used to indicate the similarity between the style of the second image and the style of the standard image; Wherein, the trained image detection model is trained using the image detection model training method as described in any one of claims 1 to 8.
19. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the training method of the image detection model as described in any one of claims 1 to 8, or to implement the image detection method as described in claim 9.
20. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the training method of the image detection model as described in any one of claims 1 to 8, or implement the image detection method as described in claim 9.
21. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, it implements the training method of the image detection model described in any one of claims 1 to 8, or implements the image detection method described in claim 9.
Citation Information
Patent Citations
Training method of image recognition model, and image recognition method and device
CN112990390A
Model training method and image processing method
CN113869429A