An image authenticity detection device, comprising a memory and one or more processors, the memory storing computer-readable instructions, and the computer-readable instructions, when executed by the one or more processors, causing the one or more processors to:
- obtain a target image;
- input the target image into a generator of a generative adversarial network, and outputting an artifact image corresponding to the target image through the generator, wherein the artifact image represents a difference between the target image and a real image;
- the generator is configured to output a prediction artifact image corresponding to a sample image and generate a fitting image based on the prediction artifact image;
- and the generative adversarial network further comprises a discriminator in a training stage, and the discriminator is configured to discriminate the authenticity of the fitting image, to assist the generator to learn a difference feature between a false sample image and a real sample image;
- and
- determine an authenticity detection result of the target image based on the artifact image, wherein the generative adversarial network is obtained by:
- obtaining sample images and image labels corresponding to the sample images;
- inputting each sample image into a to-be-trained generator of the generative adversarial network, and outputting a prediction artifact image respectively corresponding to each sample image through the to-be-trained generator;
- generating the fitting image corresponding to each sample image according to the prediction artifact image, comprising:
- performing pixel matching on the sample image and the corresponding prediction artifact image, and determining a first pixel and a second pixel corresponding to a same pixel position in the sample image and the prediction artifact image;
- subtracting a pixel value of the second pixel at the same pixel position from a pixel value of the first pixel, to obtain a fitting pixel value corresponding to the corresponding pixel position;
- and
- determining the fitting image of the sample image based on fitting pixel values corresponding to respective pixel positions;
- and
- performing iterative adversarial training on the generator and the discriminator in the generative adversarial network based on each sample image, the image label, and the fitting image, and stopping training when an iteration stop condition is reached.