Image processing method and device based on artificial intelligence, terminal equipment and medium
By modifying the normalized exponential function and adjusting parameters of the text image generation model, the problem in the existing technology that two models are required for watermark addition and real umbrella detection respectively is solved, and an image processing method that completes these two tasks simultaneously is realized. , reducing costs.
Patent Information
- Application Number
- CN202411507306.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-01-21
AI Technical Summary
In the prior art, image watermark addition and authenticity detection require the use of two different models to perform image processing separately, resulting in higher costs.
Bymented by the ingredients generated by the text image generated by the preference settings are modified, and the model is adjusted through the parameter loss, so that the model can simultaneously add watermarking and real umbrella detection.
The use of a text image generation model to complete the watermark addition and real umbrella detection tasks at the same time, reducing the cost of image processing.
Smart Images

Figure CN119338661A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to an image processing method, apparatus, terminal device and medium based on artificial intelligence. Background Art
[0002] With the rapid development and widespread application of multimedia technology and network technology, people use a lot of image information in daily life and production activities. Therefore, the problem of image processing has attracted more and more attention. Image processing refers to the technology of analyzing and processing images to achieve the desired results. Image processing mainly focuses on improving image quality, reducing storage space or achieving specific application requirements.
[0003] In the existing image processing process, watermarking and authenticity detection of the image to be processed require the use of two different models for image processing respectively, which leads to high image processing costs. Summary of the invention
[0004] In view of this, the embodiments of the present application provide an artificial intelligence-based image processing method, apparatus, terminal device and medium to solve the problem in the prior art that image watermarking and authenticity detection require the use of two different models to perform image processing separately.
[0005] A first aspect of an embodiment of the present application provides an image processing method based on artificial intelligence, comprising:
[0006] Performing preference setting on the text image generation model according to the preferred color set, and performing normalized exponential function modification on the text image generation model after the preference setting;
[0007] Inputting the sample image into the text image generation model modified by the normalized exponential function to perform watermarking processing to obtain a predicted watermark image;
[0008] Determining parameter loss according to the predicted watermark image and the sample image, and adjusting parameters of the text image generation model according to the parameter loss until the text image generation model converges;
[0009] Input the image to be processed into the converged text image generation model to perform watermarking to obtain a target watermark image, and perform texture recognition on the target watermark image to obtain a texture image;
[0010] The authenticity of the image to be processed is detected according to the pixel information of the texture image to obtain an authenticity detection result.
[0011] Further, determining parameter loss according to the predicted watermark image and the sample image includes:
[0012] Performing feature extraction on the predicted watermark image and the sample image to obtain predicted image features and sample image features, and performing vector conversion on the predicted image features and the sample image features to obtain predicted feature vectors and sample feature vectors;
[0013] The mean and covariance matrix of the predicted feature vector and the sample feature vector are calculated, and the mean and the covariance matrix are operated according to the Fréchet perceptual distance formula to obtain the parameter loss.
[0014] Further, feature extraction is performed on the predicted watermark image and the sample image to obtain predicted image features and sample image features, including:
[0015] Binarizing the predicted watermark image and the sample image to obtain a watermark binary image and a sample binary image, and performing image closing operation on the watermark binary image and the sample binary image to obtain a watermark closed operation image and a sample closed operation image;
[0016] Performing image opening operation on the watermark closed operation image and the sample closed operation image to obtain a watermark open operation image and a sample open operation image, and obtaining connected domains in the watermark open operation image and the sample open operation image to obtain a watermark connected domain and a sample connected domain;
[0017] Features are generated according to the central coordinates of the watermark connected domain and the central coordinates of the sample connected domain to obtain the predicted image features and the sample image features.
[0018] Further, adjusting parameters of the text image generation model according to the parameter loss until the text image generation model converges includes:
[0019] comparing the parameter loss to a loss threshold;
[0020] When the parameter loss is greater than or equal to the loss threshold, adjusting the parameter variables in the text image generation model;
[0021] Return to the step of inputting the sample image into the text image generation model modified by the normalized exponential function for watermarking and recalculating the parameter loss until the parameter loss is less than the loss threshold, then it is determined that the text image generation model has converged.
[0022] Further, texture recognition is performed on the target watermark image to obtain a texture image, including:
[0023] Setting a cluster center for the image to be processed according to the converged text image generation model, and determining a search neighborhood according to the cluster center;
[0024] Perform pixel allocation on the cluster center according to the image pixels in the search neighborhood to obtain candidate superpixels, and calculate the pixel average and position average of the candidate superpixels;
[0025] The cluster center is updated according to the pixel average value and the position average value, and according to the updated cluster center, the step of determining the search neighborhood according to the cluster center is returned and the cluster center is updated again, until the update change between the updated cluster center and the cluster center before the update is less than the change threshold, and the updated cluster center is determined as the target superpixel;
[0026] A complex area is determined according to the position of the target superpixel, and an image corresponding to the complex area is determined as a texture image.
[0027] Furthermore, authenticity detection is performed on the image to be processed according to the pixel information of the texture image to obtain an authenticity detection result, including:
[0028] Determine the image to be compared in the image to be processed according to the image position of the texture image, and respectively obtain image pixel points of the texture image and the image to be compared to obtain complex pixel points and pixel points to be compared;
[0029] Calculating a pixel difference between the complex pixel and the corresponding pixel to be compared, and determining a color deviation pixel among the pixel to be compared according to the pixel difference;
[0030] If the number of the color-deviant pixels is greater than the number threshold, the image to be processed is determined to be a forged image;
[0031] If the number of the color deviation pixels is less than or equal to the number threshold, the image to be processed is determined to be a real image.
[0032] Furthermore, the formula used to modify the normalized exponential function of the text image generation model after the preference setting includes:
[0033]
[0034] Among them, P(i) is the normalized probability that the label of the sample image l belongs to the i-th category, C is the color set output by the text image generation model, P is the preferred color set, and δ is a parameter variable.
[0035] A second aspect of an embodiment of the present application provides an image processing device, including:
[0036] A preference setting unit, used to perform preference setting on the text image generation model according to the preference color set, and perform normalized exponential function modification on the text image generation model after the preference setting;
[0037] A watermark processing unit, used for inputting a sample image into the text image generation model modified by a normalized exponential function to perform watermarking processing to obtain a predicted watermark image;
[0038] A parameter adjustment unit, used to determine a parameter loss according to the predicted watermark image and the sample image, and to adjust parameters of the text image generation model according to the parameter loss until the text image generation model converges;
[0039] A texture recognition unit, used for inputting the image to be processed into the converged text image generation model to perform watermarking processing to obtain a target watermark image, and performing texture recognition on the target watermark image to obtain a texture image;
[0040] The authenticity detection unit is used to perform authenticity detection on the image to be processed according to the pixel information of the texture image to obtain an authenticity detection result.
[0041] A third aspect of an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements each step of the artificial intelligence-based image processing method provided by the first solution when executing the computer program.
[0042] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, each step of the artificial intelligence-based image processing method provided by the first solution is implemented.
[0043] The embodiments of the present application provide an artificial intelligence-based image processing method, apparatus, terminal device and medium. By modifying the text image generation model after preference setting with a normalized exponential function, parameter variables can be effectively added to the text image generation model. The parameters of the text image generation model are adjusted through parameter loss, so that the converged text image generation model can effectively add watermarks to the processed image. By performing texture recognition on the target watermark image, the texture image in the target watermark image can be effectively extracted. Through the pixel information of the texture image, the authenticity of the processed image can be automatically detected. Therefore, by applying one text image generation model, the watermark addition and authenticity detection tasks of the processed image can be completed simultaneously, thereby reducing the image processing cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0045] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0046] Figure 2 is a flow chart of an embodiment of an artificial intelligence-based image processing method according to the present application;
[0047] Figure 3 is a schematic structural diagram of an embodiment of an image processing device according to the present application;
[0048] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION
[0049] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0050] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0051] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0052] like Figure 1As shown, the system architecture 100 may include a terminal device 101, a network 102 and a server 103. The terminal device 101 may be a laptop 1011, a tablet computer 1012 or a mobile phone 1013. The network 102 is used to provide a medium for a communication link between the terminal device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links or optical fiber cables.
[0053] The user can use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0054] The terminal device 101 can be any electronic device with a display screen and supporting web browsing. In addition to a laptop computer 1011, a tablet computer 1012 or a mobile phone 1013, the terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV), a laptop computer, a desktop computer, etc.
[0055] The server 103 may be a server that provides various services, such as a background server that provides support for a web page displayed on the terminal device 101 .
[0056] It should be noted that the artificial intelligence-based image processing method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the image processing device is generally arranged in the server / terminal device.
[0057] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0058] Continue to refer Figure 2, showing a flow chart of an embodiment of an image processing method based on artificial intelligence according to the present application. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted. The image processing method based on artificial intelligence provided by the embodiment of the present application can be applied to any scenario based on the need for image processing, for example, in a financial scenario, watermarking or authenticity identification of user information. The image processing method based on artificial intelligence includes the following steps:
[0059] Step S201, performing preference setting on a text image generation model according to a preferred color set, and performing normalized exponential function modification on the text image generation model after the preference setting;
[0060] In this embodiment, the electronic device (eg, Figure 1 The server / terminal device shown in the figure can receive the image to be processed through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.
[0061] The text image generation model can be any generative model, the preferred color set P can be set according to the requirements, and the color set output by the text image generation model is C. That is, the number of categories in the softmax layer classifier in the text image generation model is |P|=|C| / 2. In this step, by modifying the text image generation model after the preference setting with a normalized exponential function, parameter variables can be effectively added to the text image generation model. By adding parameter variables, the watermark adding performance of the text image generation model can be effectively adjusted.
[0062] Optionally, the formula used to modify the normalized exponential function of the text image generation model after the preference setting includes:
[0063]
[0064] Among them, P(i) is the normalized probability that the label of the sample image l belongs to the i-th category, C is the color set output by the text image generation model, P is the preferred color set, and δ is a parameter variable.
[0065] Step S202, inputting the sample image into the text image generation model modified by the normalized exponential function to perform watermarking processing to obtain a predicted watermark image;
[0066] Among them, a generation network is set in the text image generation model, and the generation network is used to sample noise, generate an image based on the sampled noise and the sample image, and obtain a predicted watermark image.
[0067] Step S203, determining a parameter loss according to the predicted watermark image and the sample image, and adjusting parameters of the text image generation model according to the parameter loss until the text image generation model converges;
[0068] Among them, the parameter loss is obtained by calculating the feature difference between the predicted watermark image and the sample image, and the parameters of the text image generation model are adjusted through the parameter loss to improve the watermark adding effect of the text image generation model.
[0069] Optionally, determining parameter loss according to the predicted watermark image and the sample image includes:
[0070] Performing feature extraction on the predicted watermark image and the sample image to obtain predicted image features and sample image features, and performing vector conversion on the predicted image features and the sample image features to obtain predicted feature vectors and sample feature vectors; wherein the features extracted from the predicted watermark image and the sample image can be set according to requirements, for example, the extracted features include color features, texture features, shape features or spatial relationship features, etc. In this step, by performing vector conversion on the predicted image features and the sample image features, the calculation of feature differences between the predicted image features and the sample image features is effectively facilitated;
[0071] The mean and covariance matrix of the predicted feature vector and the sample feature vector are calculated, and the mean and the covariance matrix are operated according to the Fleche perceptual distance formula to obtain the parameter loss; wherein, the quality of the text image generation model is quantified by calculating the distribution difference between the predicted watermark image and the sample image in the embedding space through the Fleche perceptual distance formula, and the smaller the parameter loss is, the closer the distribution of the image after the watermark is added to the text image generation model is to the real image, and the higher the quality of the text image generation model is.
[0072] Further, feature extraction is performed on the predicted watermark image and the sample image to obtain predicted image features and sample image features, including:
[0073] Binarization is performed on the predicted watermark image and the sample image to obtain a watermark binary image and a sample binary image, and image closing operation is performed on the watermark binary image and the sample binary image to obtain a watermark closed operation image and a sample closed operation image; wherein, by binarization of the predicted watermark image and the sample image, the predicted watermark image and the sample image can be effectively converted from RGB images to binary images, and by image closing operation of the watermark binary image and the sample binary image, noise points caused by reflection in the image can be effectively removed, thereby improving the image quality;
[0074] Performing image opening operation on the watermark closed operation image and the sample closed operation image to obtain a watermark open operation image and a sample open operation image, and obtaining connected domains in the watermark open operation image and the sample open operation image to obtain a watermark connected domain and a sample connected domain; wherein, by performing image opening operation on the watermark closed operation image and the sample closed operation image, the regions far apart in the image can be effectively separated, which facilitates the division of connected domains in the watermark open operation image and the sample open operation image;
[0075] Feature generation is performed according to the central coordinates of the watermark connected domain and the central coordinates of the sample connected domain to obtain the predicted image feature and the sample image feature; wherein the central coordinates of the watermark connected domain in the watermark open operation image are connected in sequence to obtain the predicted image feature, and the central coordinates of the sample connected domain in the sample open operation image are connected in sequence to obtain the sample image feature.
[0076] Furthermore, adjusting parameters of the text image generation model according to the parameter loss until the text image generation model converges includes:
[0077] comparing the parameter loss to a loss threshold;
[0078] When the parameter loss is greater than or equal to the loss threshold, adjusting the parameter variables in the text image generation model;
[0079] Return to the step of inputting the sample image into the text image generation model modified by the normalized exponential function for watermarking and recalculating the parameter loss until the parameter loss is less than the loss threshold, then the text image generation model is determined to have converged; wherein, parameter variables in the text image generation model are adjusted until the parameter loss is less than the loss threshold, then the watermarking function of the text image generation model is determined to meet the preset expectations.
[0080] Step S204, inputting the image to be processed into the converged text image generation model to perform watermarking processing to obtain a target watermark image, and performing texture recognition on the target watermark image to obtain a texture image;
[0081] Among them, the converged text image generation model can effectively add watermarks to the processed image to obtain the target watermark image. By performing texture recognition on the target watermark image, the texture image in the target watermark image can be effectively extracted.
[0082] Optionally, performing texture recognition on the target watermark image to obtain a texture image includes:
[0083] According to the converged text image generation model, cluster centers are set for the image to be processed, and a search neighborhood is determined according to the cluster centers; wherein, according to the converged text image generation model, the image to be processed is converted from an RGB color space to a Lab color space, and in the Lab space, cluster centers are evenly placed according to a preset number of superpixels and an image size of the image to be processed, the number of cluster centers can be set according to requirements, and the size and shape of the search neighborhood can be set according to requirements;
[0084] According to the image pixels in the search neighborhood, the cluster center is assigned pixels to obtain candidate superpixels, and the pixel average value and position average value of the candidate superpixels are calculated; wherein the image pixels in the search neighborhood are assigned to the corresponding cluster center to form candidate superpixels, and the pixel average value and position average value of the candidate superpixels are calculated, which facilitates the subsequent updating of the cluster center;
[0085] The cluster center is updated according to the pixel average and the position average, and according to the updated cluster center, the step of determining the search neighborhood according to the cluster center is returned and the cluster center is updated again until the update change between the updated cluster center and the cluster center before the update is less than the change threshold, the updated cluster center is determined as the target superpixel, the complex area is determined according to the position of the target superpixel, and the image corresponding to the complex area is determined as the texture image; wherein the pixel average and position average of the superpixel are set to the pixel value and position value of the corresponding cluster center to achieve the update effect of the cluster center, when the update change between the updated cluster center and the cluster center before the update is less than the change threshold, it is determined to be converged, the updated cluster center is output, and the target superpixel is obtained, and the change threshold can be set according to needs.
[0086] Step S205, performing authenticity detection on the image to be processed according to the pixel information of the texture image to obtain an authenticity detection result;
[0087] Among them, the pixel information of the texture image can be effectively used to automatically detect the authenticity of the processed image, so that the application of a text image generation model can simultaneously complete the watermark addition and authenticity detection tasks of the processed image, without the need to use two different models to perform the watermark addition and authenticity detection tasks respectively.
[0088] Optionally, performing authenticity detection on the image to be processed according to pixel information of the texture image to obtain an authenticity detection result includes:
[0089] Determine the image to be compared in the image to be processed according to the image position of the texture image, and respectively obtain image pixel points of the texture image and the image to be compared to obtain complex pixel points and pixel points to be compared; wherein the image corresponding to the image position of the texture image in the image to be processed is determined as the image to be compared;
[0090] Calculate the pixel difference between the complex pixel and the corresponding pixel to be compared, and determine the color deviation pixel among the pixel to be compared according to the pixel difference; wherein, calculate the pixel difference between the complex pixel and the pixel to be compared between the same image positions, if the pixel difference is greater than the difference threshold, determine the pixel to be compared as a color deviation pixel, and the difference threshold can be set according to the demand;
[0091] If the number of the color-deviant pixels is greater than the number threshold, the image to be processed is determined to be a forged image; if the number of the color-deviant pixels is less than or equal to the number threshold, the image to be processed is determined to be a real image; wherein the number threshold can be set according to demand, and if the number of the color-deviant pixels is greater than the number threshold, it is determined that the image to be processed has a large color deviation after the watermark is added, and therefore, the image to be processed is a forged image.
[0092] In this embodiment, the concept of "model preference color" is proposed, that is, 50% of the color types are randomly selected and defined as "model preference color". In the text image generation reasoning process, the probability of selecting the color of each pixel of the image as the "model preference color" is increased (for example, 10%-30%). For real images, the probability of the "model preference color" of the pixels of the texture image is about 50%. However, for the forged image generated by the text image generation model, the color pixels of the "texture image" will obviously deviate from 50% because it obeys statistical laws. The authenticity of the image can be judged by detecting whether the color pixels of the "texture image" conform to the statistical laws of the "model preference color".
[0093] In this embodiment, by modifying the text image generation model after the preference setting with a normalized exponential function, parameter variables can be effectively added to the text image generation model, and the parameters of the text image generation model are adjusted through parameter loss, so that the converged text image generation model can effectively add watermarks to the processed image, and by performing texture recognition on the target watermark image, the texture image in the target watermark image can be effectively extracted, and the authenticity of the processed image can be automatically detected through the pixel information of the texture image, so that the application of one text image generation model can simultaneously complete the watermark addition and authenticity detection tasks of the processed image, thereby reducing the image processing cost.
[0094] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0095] It should be emphasized that in order to further ensure the privacy and security of the above-mentioned target watermark image and authenticity detection results, the above-mentioned target watermark image and authenticity detection results can also be stored in a blockchain node.
[0096] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0097] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0098] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0099] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0100] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0101] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of an image processing device, and the device embodiment is Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices. Figure 3 As shown, the image processing device 300 described in this embodiment includes: a preference setting unit 301, a watermark processing unit 302, a parameter adjustment unit 303, a texture recognition unit 304 and an authenticity detection unit 305, wherein:
[0102] The preference setting unit 301 is used to perform preference setting on the text image generation model according to the preference color set, and perform normalized exponential function modification on the text image generation model after the preference setting.
[0103] Optionally, the formula used to modify the normalized exponential function of the text image generation model after the preference setting includes:
[0104]
[0105] Among them, P(i) is the normalized probability that the label of the sample image l belongs to the i-th category, C is the color set output by the text image generation model, P is the preferred color set, and δ is a parameter variable.
[0106] The watermark processing unit 302 is used to input the sample image into the text image generation model modified by the normalized exponential function to perform watermarking processing to obtain a predicted watermark image.
[0107] The parameter adjustment unit 303 is used to determine the parameter loss according to the predicted watermark image and the sample image, and adjust the parameters of the text image generation model according to the parameter loss until the text image generation model converges.
[0108] Optionally, the parameter adjustment unit 303 is further used to: perform feature extraction on the predicted watermark image and the sample image to obtain predicted image features and sample image features, and perform vector conversion on the predicted image features and the sample image features to obtain predicted feature vectors and sample feature vectors;
[0109] The mean and covariance matrix of the predicted feature vector and the sample feature vector are calculated, and the mean and the covariance matrix are operated according to the Fréchet perceptual distance formula to obtain the parameter loss.
[0110] Further, the parameter adjustment unit 303 is further used to: perform binarization processing on the predicted watermark image and the sample image to obtain a watermark binary image and a sample binary image, and perform image closing operation processing on the watermark binary image and the sample binary image to obtain a watermark closed operation image and a sample closed operation image;
[0111] Performing image opening operation on the watermark closed operation image and the sample closed operation image to obtain a watermark open operation image and a sample open operation image, and obtaining connected domains in the watermark open operation image and the sample open operation image to obtain a watermark connected domain and a sample connected domain;
[0112] Features are generated according to the central coordinates of the watermark connected domain and the central coordinates of the sample connected domain to obtain the predicted image features and the sample image features.
[0113] Furthermore, the parameter adjustment unit 303 is further configured to: compare the parameter loss with a loss threshold;
[0114] When the parameter loss is greater than or equal to the loss threshold, adjusting the parameter variables in the text image generation model;
[0115] Return to the step of inputting the sample image into the text image generation model modified by the normalized exponential function for watermarking and recalculating the parameter loss until the parameter loss is less than the loss threshold, then it is determined that the text image generation model has converged.
[0116] The texture recognition unit 304 is used to input the image to be processed into the converged text image generation model for watermarking to obtain a target watermark image, and perform texture recognition on the target watermark image to obtain a texture image.
[0117] Optionally, the texture recognition unit 304 is further used to: set a cluster center for the image to be processed according to the converged text image generation model, and determine a search neighborhood according to the cluster center;
[0118] Perform pixel allocation on the cluster center according to the image pixels in the search neighborhood to obtain candidate superpixels, and calculate the pixel average and position average of the candidate superpixels;
[0119] The cluster center is updated according to the pixel average value and the position average value, and according to the updated cluster center, the step of determining the search neighborhood according to the cluster center is returned and the cluster center is updated again, until the update change between the updated cluster center and the cluster center before the update is less than the change threshold, and the updated cluster center is determined as the target superpixel;
[0120] A complex area is determined according to the position of the target superpixel, and an image corresponding to the complex area is determined as a texture image.
[0121] The authenticity detection unit 305 is used to perform authenticity detection on the image to be processed according to the pixel information of the texture image to obtain an authenticity detection result.
[0122] Optionally, the authenticity detection unit 305 is further used to: determine the image to be compared in the image to be processed according to the image position of the texture image, and respectively obtain image pixel points of the texture image and the image to be compared to obtain complex pixel points and pixel points to be compared;
[0123] Calculating a pixel difference between the complex pixel and the corresponding pixel to be compared, and determining a color deviation pixel among the pixel to be compared according to the pixel difference;
[0124] If the number of the color-deviant pixels is greater than the number threshold, the image to be processed is determined to be a forged image;
[0125] If the number of the color deviation pixels is less than or equal to the number threshold, the image to be processed is determined to be a real image.
[0126] In this embodiment, by modifying the text image generation model after the preference setting with a normalized exponential function, parameter variables can be effectively added to the text image generation model, and the parameters of the text image generation model are adjusted through parameter loss, so that the converged text image generation model can effectively add watermarks to the processed image, and by performing texture recognition on the target watermark image, the texture image in the target watermark image can be effectively extracted, and the authenticity of the processed image can be automatically detected through the pixel information of the texture image, so that the application of one text image generation model can simultaneously complete the watermark addition and authenticity detection tasks of the processed image, thereby reducing the image processing cost.
[0127] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0128] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 4 with a memory 41, a processor 42, and a network interface 43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0129] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0130] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk equipped on the computer device 4, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions of an image processing method based on artificial intelligence, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.
[0131] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run computer-readable instructions stored in the memory 41 or process data, such as computer-readable instructions for running the artificial intelligence-based image processing method.
[0132] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.
[0133] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0134] In the embodiment of the present application, by modifying the text image generation model after the preference setting by a normalized exponential function, parameter variables can be effectively added to the text image generation model, and the parameters of the text image generation model can be adjusted through parameter loss, so that the converged text image generation model can effectively add watermarks to the processed image, and by performing texture recognition on the target watermark image, the texture image in the target watermark image can be effectively extracted, and the authenticity of the processed image can be automatically detected through the pixel information of the texture image, so that the application of one text image generation model can simultaneously complete the watermark addition and authenticity detection tasks of the processed image, thereby reducing the image processing cost.
[0135] The present application also provides another embodiment, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the above-mentioned artificial intelligence-based image processing method.
[0136] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0137] In the embodiment of the present application, by modifying the text image generation model after the preference setting by a normalized exponential function, parameter variables can be effectively added to the text image generation model, and the parameters of the text image generation model can be adjusted through parameter loss, so that the converged text image generation model can effectively add watermarks to the processed image, and by performing texture recognition on the target watermark image, the texture image in the target watermark image can be effectively extracted, and the authenticity of the processed image can be automatically detected through the pixel information of the texture image, so that the application of one text image generation model can simultaneously complete the watermark addition and authenticity detection tasks of the processed image, thereby reducing the image processing cost.
[0138] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0139] The non-Company software tools or components appearing in the embodiments of this application are merely examples and do not represent actual use.
[0140] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. An image processing method based on artificial intelligence, characterized in that: include: Performing preference setting on the text image generation model according to the preferred color set, and performing normalized exponential function modification on the text image generation model after the preference setting; Inputting the sample image into the text image generation model modified by the normalized exponential function to perform watermarking processing to obtain a predicted watermark image; Determining parameter loss according to the predicted watermark image and the sample image, and adjusting parameters of the text image generation model according to the parameter loss until the text image generation model converges; Input the image to be processed into the converged text image generation model to perform watermarking to obtain a target watermark image, and perform texture recognition on the target watermark image to obtain a texture image; The authenticity of the image to be processed is detected according to the pixel information of the texture image to obtain an authenticity detection result.
2. The image processing method based on artificial intelligence according to claim 1, characterized in that: Determining parameter loss according to the predicted watermark image and the sample image includes: Performing feature extraction on the predicted watermark image and the sample image to obtain predicted image features and sample image features, and performing vector conversion on the predicted image features and the sample image features to obtain predicted feature vectors and sample feature vectors; The mean and covariance matrix of the predicted feature vector and the sample feature vector are calculated, and the mean and the covariance matrix are operated according to the Fréchet perceptual distance formula to obtain the parameter loss.
3. The image processing method based on artificial intelligence according to claim 2, characterized in that: Extracting features from the predicted watermark image and the sample image to obtain predicted image features and sample image features includes: Binarizing the predicted watermark image and the sample image to obtain a watermark binary image and a sample binary image, and performing image closing operation on the watermark binary image and the sample binary image to obtain a watermark closed operation image and a sample closed operation image; Performing image opening operation on the watermark closed operation image and the sample closed operation image to obtain a watermark open operation image and a sample open operation image, and obtaining connected domains in the watermark open operation image and the sample open operation image to obtain a watermark connected domain and a sample connected domain; Features are generated according to the central coordinates of the watermark connected domain and the central coordinates of the sample connected domain to obtain the predicted image features and the sample image features.
4. The image processing method based on artificial intelligence according to claim 1, characterized in that: Adjusting parameters of the text image generation model according to the parameter loss until the text image generation model converges, including: comparing the parameter loss to a loss threshold; When the parameter loss is greater than or equal to the loss threshold, adjusting the parameter variables in the text image generation model; Return to the step of inputting the sample image into the text image generation model modified by the normalized exponential function for watermarking and recalculating the parameter loss until the parameter loss is less than the loss threshold, and then determine that the text image generation model converges.
5. The image processing method based on artificial intelligence according to claim 1, characterized in that: Performing texture recognition on the target watermark image to obtain a texture image includes: Setting a cluster center for the image to be processed according to the converged text image generation model, and determining a search neighborhood according to the cluster center; Perform pixel allocation on the cluster center according to the image pixels in the search neighborhood to obtain candidate superpixels, and calculate the pixel average and position average of the candidate superpixels; The cluster center is updated according to the pixel average value and the position average value, and according to the updated cluster center, the step of determining the search neighborhood according to the cluster center is returned and the cluster center is updated again, until the update change between the updated cluster center and the cluster center before the update is less than the change threshold, and the updated cluster center is determined as the target superpixel; A complex area is determined according to the position of the target superpixel, and an image corresponding to the complex area is determined as a texture image.
6. The image processing method based on artificial intelligence according to claim 1, characterized in that: Performing authenticity detection on the image to be processed according to the pixel information of the texture image to obtain an authenticity detection result includes: Determine the image to be compared in the image to be processed according to the image position of the texture image, and respectively obtain image pixel points of the texture image and the image to be compared to obtain complex pixel points and pixel points to be compared; Calculating a pixel difference between the complex pixel and the corresponding pixel to be compared, and determining a color deviation pixel among the pixel to be compared according to the pixel difference; If the number of the color-deviant pixels is greater than the number threshold, the image to be processed is determined to be a forged image; If the number of the color deviation pixels is less than or equal to the number threshold, the image to be processed is determined to be a real image.
7. The image processing method based on artificial intelligence according to claim 1, characterized in that: The formula used to modify the normalized exponential function of the text image generation model after the preference setting includes: Among them, P(i) is the normalized probability that the label of the sample image l belongs to the i-th category, C is the color set output by the text image generation model, P is the preferred color set, and δ is a parameter variable.
8. An image processing device, characterized in that: include: A preference setting unit, used to perform preference setting on the text image generation model according to the preference color set, and to perform normalized exponential function modification on the text image generation model after the preference setting; A watermark processing unit, used for inputting a sample image into the text image generation model modified by a normalized exponential function to perform watermarking processing to obtain a predicted watermark image; A parameter adjustment unit, used to determine a parameter loss according to the predicted watermark image and the sample image, and to adjust parameters of the text image generation model according to the parameter loss until the text image generation model converges; A texture recognition unit, used for inputting the image to be processed into the converged text image generation model to perform watermarking processing to obtain a target watermark image, and performing texture recognition on the target watermark image to obtain a texture image; The authenticity detection unit is used to perform authenticity detection on the image to be processed according to the pixel information of the texture image to obtain an authenticity detection result.
9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.