Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the devices, modules or units to be determined as different devices, modules or units, and are not used for limiting the sequence or interdependence relationship of the functions executed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
An embodiment of the present disclosure provides an image processing method, as shown in fig. 1, which may include:
step S110, an image to be processed is acquired.
The image to be processed refers to an image needing to be improved in definition, namely an image needing to be deblurred. In the embodiment of the present disclosure, the image to be processed may include a certain object, such as a human face, a human body, a building, a vehicle, a landscape, and the like, which is not limited by the embodiment of the present disclosure. In addition, the image to be processed may be an image of any style, such as a color photo style image, a black and white photo style image, a color oil painting style image, and the like, which is not limited in this disclosure.
Step S120, carrying out at least one image processing on the image to be processed through the image generation network to obtain a processed image, wherein the definition of the processed image is higher than that of the image to be processed; the image generation network is a generation network in the trained generation type countermeasure network.
In practical application, when the image with the image definition being improved is needed, the image to be processed can be correspondingly processed based on the image generation network, and then the image with the image definition being improved can be obtained. For example, after an image to be processed (see fig. 2A) with H × W (i.e., H pixels × W pixels) is processed by the image generation network, an image with HxW and higher definition than the image to be processed (see fig. 2B) can be obtained.
Further, if a higher-definition image is desired, multiple (including two) image processes may be performed through the image generation network to obtain the higher-definition image, where, when multiple image processes are performed, an input image of the image generation network at a next image process is an output image of a previous image process. The image generation network is a generator g (generator) in a trained Generative Adaptive Network (GAN).
In the embodiment of the disclosure, when the sharpness of the image to be processed is improved, the image to be processed may be processed at least once based on the image generation network, and because the image generation network is a generation network in a trained generation countermeasure network, when the sharpness of various images to be processed is improved (i.e., deblurring processing), a better deblurring effect may be achieved, and some singular points may not be generated in the deblurring process, thereby improving user experience.
In an optional embodiment of the present disclosure, the generative confrontation network comprises a generative network and a discriminative network;
as shown in fig. 3, the generative confrontation network is trained by the following ways:
step S301, a training sample set is obtained, wherein the training sample set comprises sample image pairs, each sample image pair comprises a first image and a second image, the original image contents of the first image and the second image are the same, and the definition of the first image is smaller than that of the second image;
step S302, training the initial generative confrontation network based on the training sample set until the corresponding loss function meets the set condition.
In practical applications, the main structure of the generative countermeasure network GAN includes a generator g (generator) and a discriminator d (discriminator).
The training sample set refers to sample data for training the generative confrontation network, and each sample image pair comprises a first image and a second image with the same original image content. Wherein the sharpness of the first image in each sample image pair is less than the sharpness of the second image. That is, for the second image in each sample image pair, there may be sharpness changes from the first image in that sample image pair.
Further, the initial generative countermeasure network may be trained based on the training sample set until the corresponding loss function satisfies the set condition. When the corresponding loss function meets the set condition, the generated countermeasure network obtained at the moment has a good effect of improving the image definition. For convenience of description, the first image will be referred to as a blurred image, and the second image will be referred to as a sharp image corresponding to the blurred image.
In alternative embodiments of the present disclosure, the first image may be obtained by:
acquiring a second image;
and carrying out blurring processing on the second image based on a preset image blurring processing method to obtain a first image.
The specific type of the second image is not limited in the embodiments of the present disclosure, and may be a single image captured by an image capturing device, a video frame image in a video, or the like.
In practical application, when images in each sample image pair are obtained, only each sharp image may be obtained, and then each sharp image is blurred based on a preset image blurring method, so that a blurred image (i.e., a first image) corresponding to each sharp image and having a sharpness smaller than that of the sharp image is obtained. The image blurring processing method may be configured in advance, and the embodiment of the present disclosure is not limited. For example, a sharp image may be blurred by adding a mosaic.
In the embodiment of the disclosure, when the image in the sample image pair is obtained, the corresponding blurred image can be directly obtained based on the clear image, and the corresponding blurred image does not need to be separately obtained, so that resources can be effectively saved, and the processing efficiency is improved.
As shown in fig. 4, in an alternative embodiment of the present disclosure, training the initial generative confrontation network based on the training sample set may include:
step S401, inputting a first image in each sample image pair into a generation network to obtain a generation image corresponding to the first image;
step S402, inputting the second image and the corresponding generated image into a discrimination network to obtain a first discrimination result corresponding to the generated image and a second discrimination result corresponding to the second image;
step S403 is to calculate a value of the loss function based on the generated image, the second image, the first determination result, and the second determination result, and train the generative countermeasure network based on the value of the loss function.
In practical applications, as shown in fig. 5, the initial generative confrontation network may include a generation network and a discrimination network, and the generation network included therein is used as a generator G for performing sharpness enhancement processing on the first image (i.e., blurred image) in each sample image pair and outputting a generated image; the discrimination network in the initial generative confrontation network serves as a discriminator D for discriminating the second image (i.e., sharp image) in the training sample set and the authenticity of the generated image (i.e., discrimination result in fig. 5), i.e., whether the second image is sharp (Real) or blurred (Fake) (i.e., second discrimination result in fig. 5), and whether the generated image is sharp or blurred (i.e., first discrimination result in fig. 5), further, calculating the value of the loss function based on the generated image, the second image, the first discrimination result, and the second discrimination result, and then training the generative confrontation network based on the value of the loss function.
After the first image is input to the generation network, the generation network may extract features of the first image and generate a generated image corresponding to the first image based on the extracted features. For example, the generation network may perform the up-sampling process for a set number of times and the down-sampling process for a set number of times on the first image to obtain a generated image corresponding to the first image.
Further, a second discrimination result for characterizing the authenticity (i.e., clear or blurred) of the second image and a first discrimination result for characterizing the authenticity (i.e., clear or blurred) of the generated image may be determined based on the discrimination network.
In an example, training the initial generative confrontation network based on the training sample set may specifically include:
initializing the generation network parameters of the initial generation type countermeasure network and the network parameters of a judgment network;
training an initializing initial generative confrontation network based on m sample image pairs, wherein the m sample image pairs may comprise a first set of images { a }
1,a
2,…,a
mAnd a second set of images b
1,b
2,…,b
mIn which a
iAnd b
iFor a sample image pair, e.g. a
1And b
1Namely a sample image pair; further, the generated images may be generated based on m generated images obtained from the generation network
Further, training a discrimination network to distinguish a real sample (clear image) and a generated sample (generated image) as accurately as possible; training the generation network to reduce the difference between the generated sample (generated image) and the real sample (sharp image) as much as possible also means that the discrimination network cannot discriminate whether the image is the sharp image in the sample image or the image generated by the generation network as much as possible. That is, the two networks respectively improve the generation capability and the discrimination capability in the process of the countermeasure training. After multiple update iterations, the final ideal case is to discriminate whether the network cannot discriminate whether the sample is a generated sample or a real sample.
In the embodiment of the disclosure, because the generation capability of the generation network reaches an ideal state through the countermeasure training, the trained generation network is determined as the image generation network, and a good effect of improving the image definition can be achieved.
In an alternative embodiment of the present disclosure, as shown in fig. 6, the loss function may include a pixel loss function, a first discrimination result loss function, a second discrimination result loss function, and an image generation loss function, wherein,
the value of the pixel loss function is determined based on corresponding pixels in the second image and the corresponding generated image in each sample image pair; the value of the first discrimination loss function is determined based on the first discrimination corresponding to the generated image in each sample image pair; the value of the second discrimination loss function is determined based on a second discrimination result corresponding to the second image in each sample image pair; the value of the image generation loss function is determined based on the second image and the corresponding generated image in each sample image pair.
In the embodiment of the present disclosure, since the decision network needs to determine all m second images as true samples (that is, true samples, where the true probability is 1), but in the actual training process, the probability that each second image is determined as true by the decision network may not be 1, at this time, a countermeasure loss function may be determined based on the determination of the true and false probabilities of the second images, which is defined as a second decision result loss function corresponding to the second image in the embodiment of the present disclosure, and for convenience of description, the second decision result loss function corresponding to the second image is hereinafter referred to as "loss 1" for short.
Further, since the discrimination network needs to discriminate all m generated images as false samples (i.e. the generated samples have a true probability of 0), in the actual training process, the probability that each generated image is discriminated as true by the discrimination network may not be 0. Another countermeasure loss function, which is defined as a first discrimination result loss function corresponding to the generated image in the embodiment of the present disclosure, may be determined at this time based on a determination of a true or false probability of the generated image, and for convenience of description, the first discrimination result loss function corresponding to the generated image will be simply referred to as loss2 hereinafter.
Accordingly, the difference between the generated sample (generated image) and the real sample (clear image) needs to be reduced as much as possible, that is, the generated network determines that the judgment of the network is wrong as much as possible, and all the m generated images are judged as the real sample. The pixel loss function loss3 and the image generation loss function loss4 may be determined at this time based on the generated image and the second image (sharp image) that are generated.
The pixel loss function and the generation loss characterization function are image difference degrees between the generated image and the clear image, the pixel loss function loss3 is characterized by the difference degree at the pixel level, and the image generation loss function loss4 is characterized by the difference degree at the image level. In practical applications, the specific functional form of each loss function is not limited in the present disclosure.
It will be clear to a person skilled in the art that the image sizes of the first image, the second image and the corresponding generated image in each set of training samples are the same, e.g. b
1A1 and
are the same. But there may be a difference between the second image (sharp image) in each sample image pair and the corresponding generated imageThe corresponding second and generated images may be aimed at, e.g. for b
1And
comparing the same pixels one by one, determining the difference value of each pixel, and determining the value of the pixel loss function between the second image and the generated image according to the difference value of each pixel. In one possible implementation, the difference values of each pixel are summed to obtain a value of a pixel loss function between the second image and the generated image.
In the embodiment of the present disclosure, calculating a value of a loss function based on the generated image, the second image, the first determination result, and the second determination result includes:
determining the weight of each function;
and performing weighted fusion on the values of the functions based on the weight of the functions to obtain the value of the loss function.
In practical application, considering that the degree of contribution of each sample image to the corresponding pixel loss, first discrimination result loss, second discrimination result loss and image generation loss to network optimization is different, in the embodiment of the present disclosure, a weight corresponding to each loss may be set to represent the importance degree of each loss.
In practical applications, different image sample pairs may use the same weight for the pixel loss function, the value of the first discrimination result loss function, the value of the second discrimination result loss function, and the value of the image generation loss function.
A person skilled in the art may adjust weights respectively corresponding to the pixel loss function, the first discrimination result loss function, the second discrimination result loss function, and the image generation loss function corresponding to the sample image according to an actual situation, which is not limited herein in the embodiment of the present disclosure.
Hereinafter, for convenience of description, the weights corresponding to the pixel loss function, the first discrimination result loss function, the second discrimination result loss function, and the image generation loss function corresponding to each sample image pair are abbreviated as w1, w2, w3, and w4, respectively.
Then for the disclosed embodiments, for each sample image pair, the total Loss is:
Loss=w1×loss3+w2×loss2+w3×loss1+w4×L2_loss4
and then in the training process, adjusting network parameters of the generation network and the judgment network according to the Loss function Loss corresponding to each sample image pair, optimizing the generation type confrontation network, and after adjustment aiming at a plurality of groups of training samples, converging the Loss so as to finish the training of the generation type confrontation network.
In the embodiment of the present disclosure, the generative confrontation network may be optimized according to the total loss function corresponding to each sample image to obtain an optimal training effect, and at this time, when the sharpness of the image is processed by using the generative network in the trained generative confrontation network, a processing effect with the clearest degree and the highest sharpening degree may be obtained.
Based on the same principle as the method shown in fig. 1, an embodiment of the present disclosure also provides an image processing apparatus 30, as shown in fig. 7, the image processing apparatus 30 may include an image acquisition module 310 and an image processing module 320, where:
an image obtaining module 310, configured to obtain an image to be processed;
the image processing module 320 is configured to perform at least one image processing on an image to be processed through an image generation network to obtain a processed image, where a definition of the processed image is higher than that of the image to be processed;
the image generation network is a generation network in the trained generation type countermeasure network.
In the embodiment of the disclosure, the generative confrontation network comprises a generative network and a discriminant network; the device comprises a training module, a generation type confrontation network and a generation type confrontation network, wherein the training module is used for training in the following way:
acquiring a training sample set, wherein the training sample set comprises sample image pairs, each sample image pair comprises a first image and a second image, the original image contents of the first image and the second image are the same, and the definition of the first image is smaller than that of the second image;
and training the initial generative confrontation network based on the training sample set until the corresponding loss function meets the set condition.
In the embodiment of the present disclosure, the first image is obtained by:
acquiring a second image;
and carrying out blurring processing on the second image based on a preset image blurring processing method to obtain a first image.
In the embodiment of the present disclosure, when the training module trains the initial generative confrontation network based on the training sample set, the training module is specifically configured to:
inputting a first image in each sample image pair into a generation network to obtain a generation image corresponding to the first image;
inputting the second image and the corresponding generated image into a discrimination network to obtain a first discrimination result corresponding to the generated image and a second discrimination result corresponding to the second image;
and calculating the value of the loss function based on the generated image, the second image, the first judgment result and the second judgment result, and training the generative countermeasure network based on the value of the loss function.
In the disclosed embodiment, the loss function includes a pixel loss function, a first discrimination loss function, a second discrimination loss function, and an image generation loss function, wherein,
the value of the pixel loss function is determined based on corresponding pixels in the second image and the corresponding generated image in each sample image pair; the value of the first discrimination loss function is determined based on the first discrimination corresponding to the generated image in each sample image pair; the value of the second discrimination loss function is determined based on a second discrimination result corresponding to the second image in each sample image pair; the value of the image generation loss function is determined based on the second image and the corresponding generated image in each sample image pair.
In an embodiment of the present disclosure, when the training module calculates the value of the loss function based on the generated image, the second image, the first determination result, and the second determination result, the training module is specifically configured to:
determining the weight of each function;
and performing weighted fusion on the values of the functions based on the weight of the functions to obtain the value of the loss function.
The image processing apparatus of the embodiment of the present disclosure can execute an image processing method provided by the embodiment of the present disclosure, and the implementation principles thereof are similar, the actions executed by the modules in the image processing apparatus in the embodiments of the present disclosure correspond to the steps in the image processing method in the embodiments of the present disclosure, and for the detailed functional description of the modules in the image processing apparatus, reference may be specifically made to the description in the corresponding image processing method shown in the foregoing, and details are not repeated here.
Based on the same principle as the method shown in the embodiments of the present disclosure, embodiments of the present disclosure also provide an electronic device, which may include but is not limited to: a processor and a memory; a memory for storing computer operating instructions; and the processor is used for executing the method shown in the embodiment by calling the computer operation instruction.
Based on the same principle as the method shown in the embodiment of the present disclosure, an embodiment of the present disclosure further provides a computer-readable storage medium, where at least one instruction, at least one program, a code set, or an instruction set is stored in the computer-readable storage medium, and the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the method shown in the embodiment, which is not described herein again.
Referring now to FIG. 8, shown is a schematic diagram of an electronic device 600 suitable for use in implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 8 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
The electronic device includes: a memory and a processor, wherein the processor may be referred to as the processing device 601 hereinafter, and the memory may include at least one of a Read Only Memory (ROM)602, a Random Access Memory (RAM)603 and a storage device 608 hereinafter, which are specifically shown as follows:
as shown in fig. 8, electronic device 600 may include a processing means (e.g., central processing unit, graphics processor, etc.) 601 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 8 illustrates an electronic device 600 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules or units described in the embodiments of the present disclosure may be implemented by software or hardware. Wherein the designation of a module or unit does not in some cases constitute a limitation of the unit itself.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, [ example a1 ] there is provided an image processing method comprising:
acquiring an image to be processed;
performing at least one image processing on an image to be processed through an image generation network to obtain a processed image, wherein the definition of the processed image is higher than that of the image to be processed;
the image generation network is a generation network in the trained generation type countermeasure network.
A2, according to the method A1, the generation type confrontation network comprises a generation network and a judgment network;
the generative confrontation network is trained by the following modes:
acquiring a training sample set, wherein the training sample set comprises sample image pairs, each sample image pair comprises a first image and a second image, the original image contents of the first image and the second image are the same, and the definition of the first image is smaller than that of the second image;
and training the initial generative confrontation network based on the training sample set until the corresponding loss function meets the set condition.
A3, according to the method of a2, the first image is obtained by:
acquiring a second image;
and carrying out blurring processing on the second image based on a preset image blurring processing method to obtain a first image.
A4, training an initial generative confrontation network based on a training sample set according to the method of A2, comprising:
inputting a first image in each sample image pair into a generation network to obtain a generation image corresponding to the first image;
inputting the second image and the corresponding generated image into a discrimination network to obtain a first discrimination result corresponding to the generated image and a second discrimination result corresponding to the second image;
and calculating the value of the loss function based on the generated image, the second image, the first judgment result and the second judgment result, and training the generative countermeasure network based on the value of the loss function.
A5, according to the method of A4, the loss function includes a pixel loss, a first discrimination loss, a second discrimination loss, and an image generation loss, wherein,
pixel loss is determined based on corresponding pixels in the second image and the corresponding generated image in each sample image pair; the first discrimination loss is determined based on a first discrimination corresponding to the generated image in each sample image pair; the second judgment result loss is determined based on a second judgment result corresponding to the second image in each sample image pair; the image generation loss is determined based on the second image in each sample image pair and the corresponding generated image.
A6, calculating a value of a loss function based on the generated image, the second image, the first discrimination result, and the second discrimination result according to the method of a4, including:
determining the weight of each function;
and performing weighted fusion on the values of the functions based on the weight of the functions to obtain the value of the loss function.
According to one or more embodiments of the present disclosure, [ example B1 ] there is provided an image processing apparatus comprising:
the image acquisition module is used for acquiring an image to be processed;
the image processing module is used for carrying out at least one image processing on the image to be processed through the image generation network to obtain a processed image, and the definition of the processed image is higher than that of the image to be processed;
the image generation network is a generation network in the trained generation type countermeasure network.
B2, the apparatus according to B1, the generative confrontation network comprising a generative network and a discriminative network; the device comprises a training module, a generation type confrontation network and a generation type confrontation network, wherein the training module is used for training in the following way:
acquiring a training sample set, wherein the training sample set comprises sample image pairs, each sample image pair comprises a first image and a second image, the original image contents of the first image and the second image are the same, and the definition of the first image is smaller than that of the second image;
and training the initial generative confrontation network based on the training sample set until the corresponding loss function meets the set condition.
B3, apparatus according to B2, the first image being obtained by:
acquiring a second image;
and carrying out blurring processing on the second image based on a preset image blurring processing method to obtain a first image.
B4, the apparatus of B2, wherein the training module, when training the initial generative confrontation network based on the training sample set, is specifically configured to:
inputting a first image in each sample image pair into a generation network to obtain a generation image corresponding to the first image;
inputting the second image and the corresponding generated image into a discrimination network to obtain a first discrimination result corresponding to the generated image and a second discrimination result corresponding to the second image;
and calculating the value of the loss function based on the generated image, the second image, the first judgment result and the second judgment result, and training the generative countermeasure network based on the value of the loss function.
B5, according to the method of B4, the loss function includes a pixel loss, a first discrimination loss, a second discrimination loss, and an image generation loss, wherein,
pixel loss is determined based on corresponding pixels in the second image and the corresponding generated image in each sample image pair; the first discrimination loss is determined based on a first discrimination corresponding to the generated image in each sample image pair; the second judgment result loss is determined based on a second judgment result corresponding to the second image in each sample image pair; the image generation loss is determined based on the second image in each sample image pair and the corresponding generated image.
B6, according to the method of B4, the training module, when calculating the value of the loss function based on the generated image, the second image, the first discrimination result, and the second discrimination result, is specifically configured to:
determining the weight of each function;
and performing weighted fusion on the values of the functions based on the weight of the functions to obtain the value of the loss function.
According to one or more embodiments of the present disclosure, [ example C1 ] there is provided an electronic device comprising:
a processor and a memory;
a memory for storing computer operating instructions;
a processor for executing the method of any one of A1-A6 by calling computer operation instructions.
According to one or more embodiments of the present disclosure, [ example D1 ] there is provided a computer readable medium having stored thereon at least one instruction, at least one program, set of codes, or set of instructions, which is loaded and executed by a processor to implement the method of any one of a1 to a 6.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.