On Detecting GANs and Retouching based Synthetic Alterations
Anubhav Jain, Richa Singh, Mayank Vatsa
Introduction
Digital images have become an essential part of our daily lives. With the availability of sophisticated image processing tools and techniques, the Internet is filled with fake images. While some of these images are harmless, others have been used for creating forged legal documents, presenting doctored evidence in court, and manipulating historic incidences. Today, social media is also flooded with re-touched images which makes someone’s skin look flawless. Social media websites have also started promoting retouching, by introducing image filters to enhance your appearance. These filters let the user remove wrinkles, pimples, change basic facial structures, and add texture, along with altering facial color i.e. forging skin tones to have fairer skin or adding unnatural tanning effect. Similarly, as shown in Figure 1, beauty or celebrity magazines which are giving people unrealistic expectations with altered appearances.
One of the most challenging aspects of image forgery is that, when done carefully, it can be visually imperceptible. Russello showed that such altered appearances lowers self-esteem of people trying to adhere to the societal norms on attractiveness. It also leads to body dissatisfaction due to unrealistic body images being portrayed. In 2013, Israel announced its plans to enact the “Photoshop Law”. This law makes it mandatory for advertisers and magazines to label photo-shopped images . It shows the necessity of algorithms to detect tampering and also the extent to which this issue is prevalent.
Apart from the health and moral effects of image retouching, synthetic alterations also affect biometric system used for identification of individuals. There is a plausibility that the doctored image might be unrecognizable or incomparable with its original version. This could hinder the identification process or automatic matching with original faces. Recent studies have shown that face recognition models suffer in the presence of retouching or make-up . While facial images are being used in identification cards, there is a need for an automatic system which can detect retouched images.
More recently, with the emergence of Generative Adversarial Networks , researchers have been exploring image generation as well. With these algorithms becoming more sophisticated, generated images are now looking exceptionally realistic. Various GANs such as CycleGANs are used for learning image to image translations. Pix2pix GANs network is able to generate images using label maps. It also uses an image to image translation approach and is able to color images and even generate images from edge maps. While the use of generated images has not been reported for manipulation, it possesses similar powers as tampered images, if not more. This makes it important to also have a mechanism to detect such “fake” images.
Retouching, makeup detection, face spoofing and morphing are widely studied areas, that can be considered similar to retouching detection. Recent work by Bharati et al. makes use of supervised deep Boltzmann machine algorithm for detecting retouching on the ND-IIITD database. It also introduces the ND-IIITD dataset which consists of 2600 original and 2275 retouched images. It uses different facial parts to learn features for classification. In 2017, Bharati et al. proposed an algorithm which uses semi-supervised autoencoders. The paper has reported results on the Multi-Demographic Retouched Faces (MDRF) dataset. Earlier research by Kee and Farid learned a support vector regression (SVR) between the retouched and original images. They used both geometric and photometric features for training the SVR on various celebrity images.
Research in the broad area of facial image forensics, include the paper by Kose et al. which uses SVM and alligator classifier on a feature vector consisting of shape and texture characteristics. The have reported accuracies for makeup detection on the YMC and VMU datasets. Singh et al. presents an algorithm which detects tampered face images. The algorithm makes use of a gradient based approach for classification.
2 Contributions
While existing research has primarily focuses on one of the challenges, this paper proposes a convolutional neural network based algorithm to detect retouching and image generation using GANs. The results are demonstrated using images generated from StarGAN and facial retouching on the ND-IIITD dataset .
Proposed Detection Algorithm
Different kinds of tampering/retouching algorithms introduce different kinds of irregularities in the face image. As the alterations visually blend inside the image there is a need to focus on local regions, boundary regions and texture. Convolutional neural networks such as ResNet have demonstrated effective results for different image classification challenges by encoding local and global features. Therefore, we have proposed CNN based architecture for detecting alterations.
As shown in Figure 3, the proposed approach is built on the CNN architecture, where the first step consists of extracting non-overlapping patches of size (64,64,3) or (128,128,3) (only in the case of detecting retouching) from the image. The extracted patches are used as an input for the convolutional neural network which detects various features such as edges, texture and objects. The architecture consists of 6 hidden convolutional layers and 2 fully connected layers. The convolutional layers use kernel size of (3,3,D) where D is the depth of the filter.
Inspired from the wider architecture of ResNet and the residual connections, the proposed algorithm uses a residual connection. Mathematically, the residual connection for wider networks can be summarized as:
The functions in equation (1) represent the mapping to be learned. The “addition” operation refers to an element wise addition with the shortcut connection. The algorithm uses a similar residual connection to connect the second and the fifth layers with the help of a pooling layer i.e., the output of the second layer is added to the output of the 5th layer. The algorithm takes inspiration from the idea in and it introduces a 15 layered convolutional block on the residual connection. With this, the output getting added is the output/feature map of this convolutional block.
To localize retouching in patches, the model is trained using focal loss, which is mathematically represented in Equation (2).
This is derived by modifying the expression for the conventional cross entropy loss. It introduces an additional term of which contains the tunable parameter . The algorithm sets the value of the trainable parameter to be equal to 5. The benefit of using focal loss is two fold, it helps in localizing objects or regions and addresses large class imbalance. The latter is quite relevant for this application, as retouching or tampering is only present in specific regions. This can lead to large class imbalances in tampered and authentic patches. One of the major advantages of focal loss over cross entropy loss is that focal loss helps in localizing retouched or distinguishing objects/ textures in the patches.
2 Image Classification
The classification results on patches are combined to classify the images. The proposed algorithm looks at two methods of classification, namely thresholding and support vector machine (SVM). The predictions are preprocessed to take into account the differences in the number of patches predicted as fake. This is primarily because if retouching is only introduced in specific regions, the difference in the number of authentic patches would not be large. This is even more prevalent in image tampering techniques such as splicing and cloning where only specific regions are tampered. As the CNN network performs better at classifying original patches, we focus on detecting differences in tampered patches. The prediction of the CNN pipeline is therefore post-processed using:
The ratio in the equation ensures that for images of different size, a common threshold can be obtained. For large differences in image size, a common threshold of tampered patches would not be able to distinguish whether the difference is due to alterations or size difference. This is the motivation behind using the above mentioned method which normalizes all values for efficient classification.
For thresholding based classification, the best threshold is searched in the range of 1 to 10 using grid search, and the most optimal threshold is observed to be 4. For decision making, if an image contains more number of tampered patches than the threshold, the image is classified as retouched or fake. Otherwise, it is classified as authentic.
For SVM based classification, radial basis function kernel is used for training the SVM. The input to the SVM is the output obtained from equation (4). As retouching has been introduced in non-facial regions of the image in the ND-IIITD database , all the patches of the retouched images are considered as tampered. For GANs based evaluation, specific regions that are classified using GANs are labeled as tampered. SVM based classification learns the decision boundary based on the training samples and has shown superior results compared to thresholding based approach.
3 Implementation Details
The model weights are initialized using Xavier’s method as shown by Glorot and Bengio . L1 regularization is used because of its robustness and its ability to select features. Normalization is performed as a preprocessing step to make the data comparable across all the features. To prevent the issue of internal covariate shift while training deep neural networks we normalize the data in each mini-batch. ReLU activation function is used due to its ability to accelerate the convergence of stochastic gradient descent. The CNN network is pre-trained with training data, while testing the test patches are passed through the pre-trained network to get the predictions of the patches. A portion of the training data is used to train the support vector machine and to grid search the threshold value.
Dataset
The paper presents results on two sets of fake images: retouched images and generated images using StarGAN . For the former, the algorithm is trained on the ND-IIITD dataset.
The dataset consists of total 4875 face images, out of which 2600 are original collected from the Notre Dame database, Collection B and 2275 are retouched. The alterations have been introduced using a sophisticated software, PortraitPro Studio Max. There are seven sets of probe images each varying in terms of the characteristics and extent of retouching. In the first two probe sets the level of alterations are lesser compared to other probes and they are only present in local regions. This increases with different probes, with the 7th probe having maximum deviation from the original images. Each probe set contains 325 facial images out of which 211 are males and 114 are females. The following protocols are used for classification:
To be consistent with the protocols followed in literature, 50% train-test split protocol is followed. The model is tested on 106 males and 57 females from each retouched and original probe.
To learn intra-probe (preset) variations the algorithm is trained on 50% of the images within a probe (preset) consisting of about 185,000 blocks of size (64,64,3). This is tested on the remaining 163 images of the same preset.
To determine whether the trained models are generalizable across different kinds of probe, the model is learned on the 7th probe and tested on the rest. In other words, 325 retouched and 325 original images from probe 7 are used for training, and the remaining dataset is used for testing.
2 Generated Images
StarGANs was trained using the CelebA dataset to learn attribute transfer, such as black hair; blond hair; brown hair; gender; aging; hair and gender together; hair and age together; age and gender together; hair, age and gender together. Using StarGANs, 18,000 images are created corresponding to a set of 2000 face images and 9 attributes. Additionally, 15500 original non-overlapping images from the CelebA dataset are used. All the images are of size (128,128,3) and are cropped from the center of the original CelebA dataset images. The GANs model is trained for 20 epochs. Barring some generated images, the rest can deceive the human eye in terms of whether they are generated or original. They are exceedingly similar to original images in terms of facial features, textures and colors. The total database thus comprises 35,500 images. For automated classification of generated images, 2500 images are used for testing, in which 1500 images are from the authentic class and 1000 are from the generated class. Further, 500 images from each class are used for validation. The model is trained on the remaining 32000 images.
Results
The result section is divided into three parts according to the experiments. The first subsection discusses the results of detecting facial retouching on the ND-IIITD database and comparison to state-of-the-art reported in literature. The second subsection reports the results of the proposed algorithm in detecting synthetic alterations made using GANs. The third and last subsection examines the impact of image compression on the performance of the proposed algorithm.
The proposed architecture with SVM classification yields an overall accuracy of 99.65% for protocol 1. The class-based accuracies range from 99.38% to 100% for probe 1 to 7, respectively. Setting a threshold manually gives slightly lower classification result of 99.48%. On the same database, Bharati et al. achieved 87.1% and Kee and Farid achieved 48.8% accuracy. The same experiment is also performed using image patches of size (64,64,3). It yields an accuracy of 99.42% with SVM and 99.70% while using thresholding. These results are summarized in Table 3. In this experiment, all the authentic patches are correctly classified by the CNN architecture. Some of the misclassified patches of size (128,128,3) are shown in Figure 6. For retouched images, the architecture does not perform well on patches which contained either clothing articles or hair. This is because the retouching texture differences gets hidden in clothing or hair texture.
The network is tested for its performance in detecting inter-probe and intra-probe variations. For intra-probe variations, protocol 2 is followed and it achieved an accuracy of around 98% for probes 1,2 and 3; 96% for probes 4 and 5; and slightly higher accuracy for the probe 6, i.e., 99%. However, the predicted accuracy for probe 7 is slightly lower than others. It yields an accuracy of about 96.89% using thresholding and 93.88% using SVM for image classification from patches. This shows that the data required to train the model is not very high because of the patch based approach and moreover this performs well with individual probes. The results are summarized in Table 1. The accuracies are lesser as compared to the overall accuracy on the dataset, due to scarcity of data for training for individual probes.
To test the network for inter-probe variations, one probe set is used for training and the others are used for testing. As probe 7 contains maximum retouching, it is used for training. The overall testing accuracy on probe 1-6 is 99.73% using thresholding and 99.91% using SVM.
To assert the importance of the residual connection, it is ablated (i.e. removed). A significant dip in the performance of the model is observed. The patch based accuracy is only 97.83% and the classification accuracy of the image using thresholding is 96.80% and 99% using SVM. The SVM model is finding a high threshold value for distinguishing the two classes as the number of misclassified patches increases. Thus, to ensure a lower false positive rate (FPR), the residual connection is required in the model.
2 Detecting Generated Images
The overall accuracy of the proposed algorithm on generated images from STARGAN is 99.83% using thresholding and 99.73% using support vector machine for image classification from patches. The images are converted to JPG format to test the models performance in presence of lossy compression. The images are compressed using a quality factor of 50. The patch classification accuracy on compressed images is 95.6% and image classification using SVM yields an accuracy of 96.33%. The accuracy for JPG compressed images using thresholding is significantly lesser, 88.89%. One of the major reason is the higher false positive rate. This also shows the added advantage of using support vector machines for predicting the labels of images as generated or real. These results are summarized in Table 4 below. Figure 7 shows some examples for patches which are correctly and falsely classified. Table 5 compares the performance of proposed algorithm for detecting synthetic alterations with Bharati et al. which yields an accuracy of 91.83%.
3 Compression Analysis for Retouching
Deep learning models perform well in detecting double compressed JPG images . Introducing tampering/retouching in an already compressed JPG image followed by re-compression afterwards leads to double compression. To ensure that the model is not learning such variations, JPG format images present in the retouching dataset are converted to PNG format and the model is fine tuned for PNG format images. Similar results confirmed that the network is not learning the properties of image compression.
Conclusion and Future Work
The paper presents a convolutional neural network architecture for detecting digital manipulations in terms of retouching and GANs based alterations. The results are demonstrated on two databases: ND-IIITD database and images generated using StarGANs. The proposed algorithm shows significant improvements compared to the results reported in the literature. This paper also opens another possible avenue for research in classification of generated images and testing photorealism as well. While this paper analyzes the images generated using StarGANs, the idea of unified automatic detection could be an interesting extension.
Acknowledgement
Vatsa and Singh are partly supported through Infosys Center for Artificial Intelligence at IIIT-Delhi. The research is also partly supported through a grant from MEITY, Government of India.