Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 69

Fraudulent Image Detection

7. INTRODUCTION

The objective of this project is to identify fake images(Fake images are the images that are
digitally altered images). The problem with existing fake image detection system is that
they can be used detect only specific tampering methods like splicing, coloring etc. We
approached the problem using machine learning and neural network to detect almost all
kinds of tampering on images.

Using latest image editing software’s, it is possible to make alterations on image which are
too difficult for human eye to detect. Even with a complex neural network, it is not
possible to determine whether an image is fake or not without identifying a common factor
across almost all fake images. So, instead of giving direct raw pixels to the neural network,
we gave error level analysed image.

This project provides two level analysis for the image. At first level, it checks the image
metadata. Image metadata is not that much reliable since it can be altered using simple
programs. But most of the images we come across will have non-altered metadata which
helps to identify the alterations. For example, if an image is edited with Adobe Photoshop,
the metadata will contain even the version of the Adobe Photoshop used.

In the second level, the image is converted into error level analysed format and will be
resized to 100px x 100px image. Then these 10,000 pixels with RGB values (30,000
inputs) is given in to the input layer of Multilayer perceptron network. Output layer contain
two neurons. One for fake image and one for real image. Depending upon the value of
these neuron outputs along with metadata analyser output, we determine whether the image
is fake or not and how much chance is there for the given image to be tampered.

Page | 1
Fraudulent Image Detection

8. Literature Review

FaceForensics++: Learning to Detect Manipulated Facial Images (25 Jan


2019  ·  Andreas Rössler, Davide Cozzolino, Luisa Verdoliva, Christian Riess, Justus
Thies, Matthias Nießner).
The rapid progress in synthetic image generation and manipulation has now
come to a point where it raises significant concerns for the implications towards society. At
best, this leads to a loss of trust in digital content, but could potentially cause further harm
by spreading false information or fake news. This paper examines the realism of state-of-
the-art image manipulations, and how difficult it is to detect them, either automatically or
by humans. To standardize the evaluation of detection methods, we propose an automated
benchmark for facial manipulation detection. In particular, the benchmark is based on
DeepFakes, Face2Face, FaceSwap and NeuralTextures as prominent representatives for
facial manipulations at random compression level and size. The benchmark is publicly
available and contains a hidden test set as well as a database of over 1.8 million
manipulated images. This dataset is over an order of magnitude larger than comparable,
publicly available, forgery datasets. Based on this data, we performed a thorough analysis
of data-driven forgery detectors. We show that the use of additional domainspecific
knowledge improves forgery detection to unprecedented accuracy, even in the presence of
strong compression, and clearly outperforms human observers.

MesoNet: a Compact Facial Video Forgery Detection Network 4 Sep 2018  ( Darius


Afchar, Vincent Nozick, Junichi Yamagishi, Isao Echizen ).

This paper presents a method to automatically and efficiently detect face tampering
in videos, and particularly focuses on two recent techniques used to generate hyper-
realistic forged videos: Deepfake and Face2Face. Traditional image forensics techniques
are usually not well suited to videos due to the compression that strongly degrades the data.

Page | 2
Fraudulent Image Detection

Thus, this paper follows a deep learning approach and presents two networks, both with a
low number of layers to focus on the mesoscopic properties of images. We evaluate those
fast networks on both an existing dataset and a dataset we have constituted from online
videos. The tests demonstrate a very successful detection rate with more than 98% for
Deepfake and 95% for Face2Face.
Blind Fake Image detection (Nidhal El Abbadi1 , Adil Mohamad Hassan2 , Mudher
Mohammed AL-Nwany3 1Computer Science Dep., University of Kufa Najaf, Iraq).
Cameras are regarded as trustworthy devices and photos traditionally imply truth.
Nowadays, digital photos have been widely used as historical records and as evidences of
real happenings in applications from journalist reporting, police investigation, law
enforcement, insurance, medical and dental examination, military, and museum to
consumer photography. While digital photos are conveniently used, their credibility has
been severely challenged due to numerous fraudulent cases involving image forgeries, e.g.
the fake results on human stem-cell research

Page | 3
Fraudulent Image Detection

9. Materials and Methods

9.1 WORKING ENVIRONMENT

The system requirement is a main part in the analyzing space of the project.
The analyzer of the project has to properly analyze the hardware and software requirement
otherwise in future designer will face more trouble with hardware and software required.
They should specify the correct hardware and software to suit the particular project.

9.1.1 Hardware Specification


Processor : Core i7
Ram : 8GB
Hard Disk : 1TGB
Monitor : 15” color monitor
Keyboard : Multimedia
Mouse : Optical
9.1.2 Software Specification
Framework : Java

9.2. SOFTWARE DESCRIPTION

9.2.1 History
The Java platform and language began as an internal project at Sun Microsystems
inDecember 1990, providing an alternative to the C++/C programming languages.
Engineer Patrick Naughton had become increasingly frustrated with the state of Sun's C++
and C application programming interfaces (APIs) and tools. While considering moving to
NeXT, Naughton was offered a chance to work on new technology and thus the Stealth

Page | 4
Fraudulent Image Detection

Project was started.


The Stealth Project was soon renamed to the Green Project with James Gosling and
Mike Sheridan joining Naughton. Together with other engineers, they began work in a
small office on Sand Hill Road in Menlo Park, California. They were attempting to develop
a new technology for programming next generation smart appliances, which Sun expected
to be a major new opportunity.
The team originally considered using C++, but it was rejected for several reasons.
Because they were developing an embedded system with limited resources, they decided
that C++ needed too much memory and that its complexity led to developer errors. The
language's lack of garbage collection meant that programmers had to manually manage
system memory, a challenging and error-prone task. The team was also troubled by the
language's lack of portable facilities for security, distributed programming, and threading.
Finally, they wanted a platform that could be easily ported to all types of devices.
Bill Joy had envisioned a new language combining Mesa and C. In a paper
called Further, he proposed to Sun that its engineers should produce an object-oriented
environment based on C++. Initially, Gosling attempted to modify and extend C++ (that he
referred to as "C++ ++ --") but soon abandoned that in favor of creating a new language,
which he called Oak, after the tree that stood just outside his office.
By the summer of 1992, they were able to demonstrate portions of the new platform
including the Green OS, the Oak language, the libraries, and the hardware. Their first
attempt, demonstrated on September 3, 1992, focused on building a personal digital
assistant (PDA) device named Star7 that had a graphical interface and a smart agent called
"Duke‖to assist the user. In November of that year, the Green Project was spun off to
become first person, a wholly owned subsidiary of Sun Microsystems, and the team
relocated to Palo Alto, California.
The first person team was interested in building highly interactive devices, and
when Time Warner issued a request for proposal (RFP) for a set-top box, firstperson
changed their target and responded with a proposal for a set-top box platform. However,

Page | 5
Fraudulent Image Detection

the cable industry felt that their platform gave too much control to the user and firstperson
lost their bid to SGI. An additional deal with The 3DO Company for a set-top box also
failed to materialize. Unable to generate interest within the TV industry, the company was
rolled back into S

9.2.2 INTRODUCTION TO JAVA:


Java is an object-oriented programming language with a built -in
application programming interface (API) that can handle graphics and u ser
interfaces and that can be used to create applications or applets. Because of its rich
set of API's, similar to Macintosh and Windows, and its platform independence,
Java can also be thought of as a platform in itself. Java also has standard libraries
for doing mathematics. Much of the syntax of Java is the same as C and C++. One
major difference is that Java does not have pointers. However, the biggest
difference is that you must write object oriented code in Java. Procedural pieces of
code can only be embedded in objects. In the following we assume that the reader
has some familiarity with a programming language. In particular, some familiarity
with the syntax of C/C++ is useful. In Java we distinguish between applications,
which are programs that perform the same functions as those written in other
programming languages, and applets, which are programs that can be embedded in
a web page and accessed over the Internet. Our initial focus will be on writing
applications. When a program is compiled, a byte code is produced that can be read
and executed by any platform that can run Java.
9.2..3 Java Install
Some PCs might have Java already installed.
To check if you have Java installed on a Windows PC, search in the start bar for
Java or type the following in Command Prompt (cmd.exe):
C:\Users\Your Name>java -version
If Java is installed, you will see something like this (depending on version):

Page | 6
Fraudulent Image Detection

javaversion"11.0.1"2018-10-16LTSJava(TM) SE Runtime Environment 18.9 (build


11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)
If you do not have Java installed on your computer, you can download it for free
at oracle.com.

9.2.4 Setup for Windows


To install Java on Windows:
1. Go to "System Properties" (Can be found on Control Panel > System and Security >
System > Advanced System Settings)
2. Click on the "Environment variables" button under the "Advanced" tab
3. Then, select the "Path" variable in System variables and click on the "Edit" button
4. Click on the "New" button and add the path where Java is installed, followed by \
bin. By default, Java is installed in C:\Program Files\Java\jdk-11.0.1 (If nothing
else was specified when you installed it). In that case, You will have to add a new
path with: C:\ProgramFiles\Java\jdk-11.0.1\binThen, click "OK", and save the
settings
5. At last, open Command Prompt (cmd.exe) and type java -version to see if Java is
running on your machine
Show how to install Java step-by-step with images »
Step 1

Page | 7
Fraudulent Image Detection

Step 2

Step 3

Page | 8
Fraudulent Image Detection

Step 4

Step 5
Write the following in the command line (cmd.exe):
C:\Users\Your Name>java -version

Page | 9
Fraudulent Image Detection

9.3.MODULE DESCRIPTION

INTRODUCTION
A module is a separate unit of software or hardware. Software is
composed of separate, interchangeable components called modules.

9.3.1 Metadata Analysis :

Most image files do not just contain a picture. They also contain information
(metadata) about the picture. Metadata provides information about a picture's pedigree,
including the type of camera used, color space information, and application notes.
Different picture formats include different types of metadata. Some formats, like BMP,
PPM, and PBM contain very little information beyond the image dimensions and color
space. In contrast, a JPEG from a camera usually contains a wide variety of information,
including the camera's make and model, focal and aperture information, and timestamps.
PNG files typically contain very little information, unless the image was converted from a
JPEG or edited with Photoshop. Converted PNG files may include metadata from the
source file format. Metadata provides information related to how the file was generated and
handled. This information can be used to identify if the metadata appears to be from a
digital camera, processed by a graphical program, or altered to convey misleading
information. Common things to look for include:

1) Make, Model, and Software These identify the device or application that
created the picture. Most digital cameras include a Make and Model in the
EXIF metadata block. (However, the original iPhone does not!) The Software
may describe the camera's firmware version or application information.

2) Image size The metadata often records the picture's dimensions. Does the
rendered image size (listed at the bottom of the metadata) match the other sizes
in the metadata? Many applications resize or crop pictures without updating
other metadata fields.
Page | 10
Fraudulent Image Detection

3) Timestamps Look for fields that detail timestamps. These typically identify
when a picture was taken or altered. Do the timestamps match the expected
timeframe?

9.3.2 Error Level Analysis :

JPEG is a lossy format, but the amount of error introduced by each resave is not
line. Any modification to the picture will alter the image such that stable areas (no
additional error) become unstable. Fig.1 shows a modified image using Photoshop. The
modified picture was based on the first 75% resave. Books on the shelf were duplicated
and a toy dinosaur was added to the shelf. The 95% ELA identifies the changes since they
are areas that are no longer at their minimal error level. Additional areas of the picture
show slightly more volatility because Photoshop merged information from multiple layers,
effectively modifying many of the pixels.

9.3.3 Machine Learning :

The process of machine learning is similar to that of data mining. Both systems
search through data to look for patterns. However, instead of extracting data for human
comprehension as is the case in data mining applications machine learning uses that data to
detect patterns in data and adjust program actions accordingly. Machine learning
algorithms are often categorized as being supervised or unsupervised. Supervised
algorithms can apply what has been learned in the past to new data. Unsupervised
algorithms can draw inferences from datasets. Facebook's News Feed uses machine
learning to personalize each member's feed. If a member frequently stops scrolling in order
to read or "like" a particular friend's posts, the News Feed will start to show more of that
friend's activity earlier in the feed. Behind the scenes, the software is using statistical
analysis and predictive analytics to identify patterns in the user's data and use to patterns to
populate the News Feed. They observe the activities of the user like, comment, share etc on

Page | 11
Fraudulent Image Detection

various posts and based on these activities the contents on the news feed will be adjusted
continuously.

9.4 SYSTEM DESIGN


Design is the first step in the development phase for every product. System
design is a solution to the creation of new system. The design phase focuses on the detailed
implementation of the system. Design is concerned with identifying software structure
maintaining a record of designing definition and providing the implementation phases.

9.4.1 Tools Used

Neuroph Studio

Neuroph studio is an open source Java neural network framework that helps to
easily build and use neural networks. It also provides a direct interface for loading images

Metadata-extractor

Metadata-extractor is an open source java library used to extract metadata


from images.

JavaFX

JavaFX is used to implement modern user interface for the application.

9.4.2 Table Design

Page | 12
Fraudulent Image Detection

Flow Chart : Detection

Flow Chart : Training

Metadata Analysis
Most image files do not just contain a picture. They also contain information (metadata) about the
picture. Metadata provides information about a picture's pedigree, including the type of camera
used, color space information, and applicationnotes. Different picture formats include different types
ofmetadata. Some formats, like BMP, PPM, and PBM containvery little information beyond the image
dimensions and colorspace. In contrast, a JPEG from a camera usually contains awide variety of
information, including the camera's make andmodel, focal and aperture information, and timestamps.PNG
files typically contain very little information, unlessthe image was converted from a JPEG

Page | 13
Fraudulent Image Detection

or edited withPhotoshop. Converted PNG files may include metadata fromthe source file
format. Metadata provides information related to how the file was generated and handled.
This information can be used
1) Make, Model, and Software
These identify the device or application that created the picture. Most digital cameras
include a Make and Model in the EXIF metadata block. (However, the original iPhone does not!) The
Software may describe the camera's firmw areversion or application information.
2) Image size
The metadata often records the picture's dimensions. Doesthe rendered image size (listed at the bottom of
the metadata)match the other sizes in the metadata? Many applications resizeor crop pictures without
updating other metadata fields.

3) Timestamps
Look for fields that detail timestamps. These typically identifyy when a picture was taken or altered. Do
thtimestamps matchch the expected timeframe?
4)Types of metadata
There are many different metadata types. Some aonly generatedted by cameras, while others are only
generated by applications.
5) Descriptions
Many pictures include embedded annotations that describe the photo, identify the photographer, or itemize
alteration steps.
6) Missing metadata
Are any metadata fields missing? If the picture came from adigital camera, then it should have camera-
specificinformation. Some applications and online services strip outmetadata. A lack of specific metadata
usually indicates aresaved picture and not an original photo.
7) Altered Metadata
Metadata is analogous to the chain of custody for evidencehanding. It can identify how a picture was
generated, processed, and last saved. However, some people intentionallyalter metadata. They
may edit timestamps or photo informationin an attempt to deceive
Page | 14
Fraudulent Image Detection

 B. Error Level Analysis


JPEG is a lossy format, but the amount of error introduced by each resave is not line. Any
modification to the picture willalter the image such that stable areas (no additional
error) become unstable. Fig.1 shows a modified image usingPhotoshop. The modified picture
was based on the first 75%resave. Books on the shelf were duplicated and a toy dinosaurwas added to the
shelf. The 95% ELA identifies the changessince they are areas that are no longer at their minimal errorlevel.
Additional areas of the picture show slightly morevolatility because Photoshop merged information from
multiplelayers, effectively modifying many of the pixels.A 90% image resaved at 90% is equivalent to a
one-timesave of 81%. Similarly, saving an image at 75% and thenresaving it at 90% (75% 90%) will
generate virtually the sameimage as 90% 75%, or saved once at 67.5%. 19 The amount oferror is limited to
the 8x8 cells used by the JPEG algorithm;after roughly 64 resaves, there is virtually no change.
However,when an image is modified, the 8x8 cells containing themodifications are no longer at the same
error level as the rest ofthe unmodified image. Error level analysis (ELA) works byintentionally resaving
the image at a known error rate, such as95%, and then computing the difference between the images.
Ifthere is virtually no change, then the cell has reached its localminima for error at that quality level.
However, if there is alarge amount of change, then the pixels are not at their localminima and are effectively
“original”. JPEG is a lossy format, but the amount of error introduced by each resave is not
linearmodification to the picture will alter the image such that stableareas (no additional error) become
unstable .
 
Books on the shelf were duplicated and a toy dinosaur wasadded to the shelf. The 95% ELA identifies the
changes sincethey are areas that are no longer at their minimal error level.Additional areas of the picture
show slightly more
volatility because Photoshop merged information from multiple layers,effectively modifying
many of the pixels. Nearly all pixels inthe original image are not at their local minima. The first
resave(75%) shows large areas where the pixels have reached theirlocal minima. The second resave
introduces more areas thathave reached their local minima for error.By analyzing the pattern in the ELA
applied image (Fig 1left part), we can determine which part of the image is possiblyfaked. It is hard for the

Page | 15
Fraudulent Image Detection

human eye to detect small scalechanges to image so that we have decided to use machinelearning to detect
the anomalies in the error level analyzedimages.
C. Machine Learning
The process of machine learning is similar to that of datamining. Both systems search through data to look
for patterns.However, instead of extracting data for human comprehensionas is the case in data mining
applications machine learning usesthat data to detect patterns in data and adjust program
actionsaccordingly. Machine learning algorithms are oftencategorized as being supervised or
unsupervised. Supervisedalgorithms can apply what has been learned in the past to newdata. Unsupervised
algorithms can draw inferences fromdatasets.Facebook's News Feed uses machine learning
to personalize each member's feed. If a member frequently stopsscrolling in order to read or
"like" a particular friend's posts,
the News Feed will start to show more of that friend's activityearlier in the feed. Behind the
scenes, the software is usingstatistical analysis and predictive analytics to identify patternsin the user's data
and use to patterns to populate the News Feed.They observe the activities of the user like, comment, share
etcon various posts and based on these activities the contents onthe news feed will be adjusted continuously.

9.5. SYSTEM TESTING

System testing is actually as series different test whose primary purpose is to full exercise
the computer base system. Where the software and other system elements are tested as
whole. To test computer software, we spiral out along streamlines the broader the scope of
testing with each turn. The last higher-order testing step falls outside the boundary of
software Engineering and in to the broader context of computer system engineering.
Software, once validated, must be combining with order system Elements (e.g. hardware,
people, and databases). System testing verifies that all the elements Mesh properly and that
overall system function/performance is achieved.

Page | 16
Fraudulent Image Detection

Software testing is a critical element of software quality assurance and represents the
ultimate review of specification, design and coding. In fact, testing is the one step in the
software engineering process that could be viewed as destructive rather than constructive.

A strategy for software testing integrates software test case design methods into a well-
planned series of steps that result in the successful construction of software. Testing is
the set of activities that can be planned in advance and conducted systematically. The
underlying motivation of program testing is to affirm software quality with methods that
can economically and effectively apply to both strategic to both large and small-scale
systems.

Data Collection
The dataset used in the experiments was extracted from CelebA [24]. The images
from the CelebA covered large pose variations and background clutter, including 10,177 of
identities and 202,599 aligned face images. In the experiment, five state-of-the-art GANs
were used to produce the training set of fake images based on the CelebA dataset, and they
were as follows:
 DCGAN (Deep convolutional GAN) [15]
 WGAP (Wasserstein GAN) [16]
 WGAN-GP (WGAN with Gradient Penalty) [17]
 LSGAN (Least Squares GAN) [18]
 PGGAN [1]
By using the selected GANs, it was hard to synthesize realistic images with high-
resolution, except for the PGGAN. In [15,16,17,18], the default size of the generated face
images in the released source code was only 64×64 pixels. Specifically, if the size of the
fake image was set to 128×128 pixels, many artifacts would be significant in the generated
images, so the artifacts to recognize the fake image would be easily observed. In such a
case, the fake image detector would not be needed. The most GANs could generate
realistic fake images only of the smaller resolution, such as 64×64 pixels. To achieve a fair

Page | 17
Fraudulent Image Detection

comparison of the performance of different image detectors in recognizing fake images


generated by different GANs, the size of the input image was consistent, and it was set
to 64×64 pixel. In the PGGAN, the best model released by the authors of the corresponding
GAN was used. However, the PGGAN [1] can be used to generate the high-resolution fake
face images, in which the size of the generated face image is different from the one used in
our experiments. Therefore, in the experiments, we downsampled the fake face image
generated by the PGGAN to 64×64. Note, the generated images are downloaded from the
official website provided by the authors in PGGAN [1].
Each GAN randomly generated 40,000 fake images with the size of 64×64, which
were recorded into the fake image pool. Since the fake image is generated by giving a
random vector to GANs, the generated content will vary each time unless we set the
random vector as a constant vector. To have a fair experiment result, we save the generated
face images to a fake image pool to ensure the fake contents of the generated face images
are consistent in each experiment. There were 200,000 fake images in total in the pool. We
also randomly selected 200,000 real images from CelebA. Therefore, the total number of
images, including real and fake images, was 400,000. To evaluate the performance of the
proposed method, we split the image dataset into the training, validation, and test sets
consisting of 380,000, 10,000, and 10,000 images, respectively. In each set, the number of
fake images was equal to the number of real images.
Experimental Settings
In the training of the proposed CFFN and fake face detector, we set the learning rate
to = 1e−3, and the total number of epochs to 15. The threshold value m of the contrastive
loss was set to 0.5. Adam optimizer [25] was used for both the first- and second-step
learning. The number of epochs of the first-step learning of the CFFN was set to 2, and the
number of epochs of the classification learning of the classification sub-network was set to
13. The batch size was 88 for all the learning tasks. The parameters settings were as in
[5,9,11].
In the experiments, we used the conventional image forgery method based on the

Page | 18
Fraudulent Image Detection

sensor pattern noise [8] for performance comparison. The Baseline-I method was the
jointly learning method based on the contrastive loss and binary cross-entropy loss without
two-step learning. In the Baseline-II method, instead of the CFFN structure, the DenseNet
[19] with two-step learning of the contrastive and binary cross-entropy loss functions was
adopted.
We compared the performance regarding the precision P and recall R, which were
defined as:
P=TPTP+FP
(4)
R=TPTP+FN,
(5)
where TP denoted the number of true positives, indicating that a real image was
recognized as a real, FP denoted the number of false positives, denoting that a fake image
was detected as a real image, and FN denoted the number of false negatives, showing that a
real image was recognized as a fake one.
Objective Performance Comparison
To verify the effectiveness of the proposed method, we excluded one of the selected
GANs from the training process and used it in the testing process instead to make the
training and test sets be different. For instance, when the PGGAN was excluded from the
training phase of the proposed DeepFD, the fake images generated by the PGGAN and the
corresponding real images were used to evaluate the performance of the trained fake face
detector. The objective performance comparison of the proposed fake face detector, two
baseline methods, and methods proposed in [9,10,11] in terms of precision and recall, is
presented in Table 3. As presented in Table 3, the proposed method significantly
outperformed other state-of-the-art methods; thus, the CFFN can be used to capture the
discriminative features of the fake images. The curves of the validation accuracy during the
training phase are depicted in Figure 4. It demonstrated that the effectiveness of the
proposed DeepFD. The proposed pairwise learning successfully captured the CFFs from

Page | 19
Fraudulent Image Detection

the training images generated by different GANs. Thus, it was verified that the proposed
method had higher generalization ability and effectiveness than the other methods.

The curves of the validation accuracy during the training phase for the proposed DeepFD.
The objective performance comparison of the proposed and other fake face detectors.

Visualized Result
As presented in [26], the object can be localized by designing the number of channels
in the last convolution layers to be the same as the number of classes. Also, as suggested in
[26], the channels of the last convolutional layer of the proposed CDNN enable the
visualization ability. Therefore, the proposed model was used to visualize fake regions in
the generated images by extracting the last convolution layer and mapping the responses to
the image domain. Since the last convolution layer was designed to have two channels, the
first channel was regarded as a feature response of the first class (i.e., real image), and the

Page | 20
Fraudulent Image Detection

second channel corresponded to the second class (i.e., fake image). As a result, the
proposed method could be used to visualize the fake regions, making a more intuitive
interpretation of typical fake features generated by the GANs. Moreover, the heat map of
the last convolutional layer is produced by the normalized response values in the feature
map with the second channel (i.e., the feature map for fake feature). As a result in Figure
5, the higher feature response values can be observed in the corresponding regions with
artifacts in the fake face images, while the real images have relatively lower feature
response values. We map the response value to the original image to draw the artifact
regions in red color.

The visualized fake feature map for localization of fake regions in face images generated
by the (a–e) WGAN [16] and (f–j) PGGAN [1]. (k–t) are the real images and the
corresponding feature responses.
Training Convergence
In the proposed method, it is necessary to guarantee the convergence of network
training. Therefore, the convergence of the contrastive loss and CFFN training accuracy
was analyzed, and the results are presented in Figure 6. In Figure 6a, the orange line
depicts the accuracy curve during the training with supervised learning without contrastive
loss, and the blue line indicates the validation accuracy curve of the training process with
the proposed pairwise learning in two-step learning policy. It is clear that the proposed

Page | 21
Fraudulent Image Detection

pairwise learning enhanced the method convergence significantly compared to the


supervised learning strategy. On the other hand, it was necessary to ensure the contrastive
loss converged as well. Figure 6b depicts the convergence of the proposed contrastive loss
during the CFFN training. As the results show, the proposed contrastive loss was
successfully decreased after only several iterations.

Figure 6. (a) The curves of the validation accuracy evaluated on the fake face images
generated by PGGAN during the training phase for the proposed DeepFD, Baseline-I, and
Baseline-II. (b) The curves of the contrastive loss values of the proposed DeepFD (in Log-
view).
In general, over-fitting can be observed when the validation accuracy is dropping
down as well as the training accuracy is still improving. In our experiments, the validation
accuracy only slightly improves after 21,000 iterations. It is clear that the validation
accuracy in Figure 6a does not drop down after 21,000 iterations. Therefore, the total
number of the training iterations can be higher than 21,000.
Fake General Image Detection
In the task of fake general image detection, we used three state-of-the-art GANs to
generate high-quality fake images:
 BigGAN (Large Scale GAN Training for High Fidelity Natural Image Synthesis)
[2]
 SA-GAN (Self-Attention GAN) [27]
 SN-GAN (Spectral Normalization GAN) [28]
Page | 22
Fraudulent Image Detection

The dataset was extracted from the ILSVRC12 [29]. We adopted the source code
provided in [2,27,28] and its released model that was trained on the ILSVRC12 to generate
the fake general images. Each GAN generated 100,000 fake images with a size
of 128×128, which were recorded into the fake general image pool. Then, we randomly
selected 300,000 real images from the ILSVRC12. Therefore, the total number of images
was 600,000. To evaluate the performance of the proposed method, we split the image
dataset into the training, validation, and test sets that consisted of 580,000, 10,000,
and 10,000 images, respectively.
The objective performance comparison of the proposed method and other state-of-the-
art image forgery detection methods is presented in Table 4. The results given in Table
4 show that the proposed CFFN with the pairwise learning strategy was significantly better
than other state-of-the-art image forgery detectors. Compared to the supervised learning-
based methods [9,11], the performance of the proposed method was significantly better.
Accordingly, it was proven that the proposed method could learn the CFF of a fake general
image.The subjective performance comparison of the proposed and other fake general
image detectors.

 Discussions and Limitations
In the proposed CFFN and DeepFD, the fake face and general image detection ability
is provided using deep neural networks. Since the main contribution of this work is that the
CFFs are learned from the pairwise training samples, the proposed CFFs may fail when the
fake features of the results of a new generator are significantly different from most of those
used in the training phase. In such a situation, the fake face and general image detector
should be retrained. Another limitation of the proposed method is related to the collection
of training samples. The technical details of some fake image generators maybe have not
been revealed, so the training samples might be hard to collect in practice. In order to
overcome this limitation, a few-shot learning policy should be employed in the learning of
the CFF from a small-scale training set.

Page | 23
Fraudulent Image Detection

TYPES OF TESTING

There are different types of testing used in the project. They are following

• Unit Testing

• Black box Testing

• White box Testing

• Integration Testing

A strategy for software testing may also be viewed in the context of the spiral. Unit testing
begins at the vertex of the spiral and concentrates on each unit of the software as
implemented in source code. Testing progress by moving outward along the spiral to
integration testing, where the focus is on the design and the construction of the software
architecture.

Talking another t urn on outward on the spiral we encounter validation testing where
requirements established as part of software requirements analysis are validated against the
software that has been constructed. Finally we arrive at system testing, where the software
and other system elements are tested as a whole.

9.5.1 Unit Testing

Unit testing is the testing of an individual unit or group of related units. If falls under the
class of white box testing. It is often done by the programmer to test that the unit he/she
has implemented is producing expected output against given input. Unit testing is a
software development process that involves synchronized application of a broad spectrum

Page | 24
Fraudulent Image Detection

of defect prevention and detection strategies in order to reduce software development risks,
time, and costs.

It is performed by the software developer or engineer during the construction phase of the
software development lifecycle. Rather than replace traditional QA focuses, it augments it.
Unit testing aims to eliminate construction errors before code is promoted to QA.

9.5.2 White Box Testing

White box testing is a testing technique that takes into account the internal mechanism of a
system. It is also called structural testing and glass box testing. White-box testing can be
applied at the unit, integration and system levels of the software testing process, it is
usually done at the unit level.

It can test paths within a unit, paths between units during integration, and between
subsystems during a system-level test. Though this method of test design can uncover
many errors or problems, it might not detect unimplemented parts of the specification or
missing requirements. Techniques used in white-box testing include:

9.5.3 Black Box Testing

• API testing

• Code coverage

• Fault injection

• Mutation testing methods

• Static testing methods

Page | 25
Fraudulent Image Detection

Black –box testing treats the software as a “black box”, examining functionality without
any knowledge of internal implementation. Black-box testing methods include:
equivalence partitioning, boundary value analysis, all-pairs testing, state transition tables,
decision table testing, fuzz testing, model-based testing, use case testing, exploratory
testing and specification based testing.

One advantages of the black box technique is that no programming knowledge is required.
On the other hand, black –box testing has been said to be “like a walk in a dark labyrinth
without a flashlight. This method of test can be applied to all levels of software testing:
unit, integration, system and acceptance.

9.6.CONCLUTION AND FUTURE ENHANCEMENT

9.6.1 Conclusion
Neural network has been successfully trained using the error level analysis
with 4000 fake and 4000 real images. The trained neural network was able to recognize the
image as fake or real at a maximum success rate of 83%. The use of this application in
mobile platforms will greatly reduce the spreading of fake images through social media.
This project can also be used as a false proof technique in digital authentication, court
evidence evaluation etc. By combining the results of metadata analysis (40%) and neural
network output (60%) a reliable fake image detection program is developed and tested.

9.6.2 Future Enhancement


Here are a few more approaches we are trying to get more accuracy:
1. more aggressive data augmentation
2. more aggressive dropout
3. use of L1 and L2 regularization (also known as "weight decay")

Page | 26
Fraudulent Image Detection

4. Fine-tuning one more convolutional block (alongside greater


regularization)

10. Results

10.1 Coding:

ConstantObjects.class:
package com.gc.fakeimagedetection.core;

import com.gc.fakeimagedetection.core.errorlevelanalysis.FIDErrorLevelAnalysis;
import com.gc.fakeimagedetection.core.listener.ErrorLevelAnalysisListener;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.HashMap;
import org.neuroph.core.NeuralNetwork;
import org.neuroph.imgrec.ImageRecognitionPlugin;

public class FIDNetworkAnalyser implements ErrorLevelAnalysisListener {

private NeuralNetwork nnet;

public FIDNetworkAnalyser(String nSourceFile) throws FileNotFoundException


{
nnet = NeuralNetwork.load(new FileInputStream(nSourceFile)); // load trained
neural network saved with Neuroph Studio

Page | 27
Fraudulent Image Detection

public static void main(String[] args) throws FileNotFoundException {


if (args == null || args.length < 5) {
System.err.println("Usage : <neural net file> <image file> <quality>
<width> <height>");
}
String neuralSource = args[0];
String imageLoc = args[1];
String quality = args[2];
String sWidth = args[3];
String sHeight = args[4];

new FIDNetworkAnalyser(neuralSource)
.run(imageLoc, Integer.parseInt(quality),
new Dimension(Integer.parseInt(sWidth),
Integer.parseInt(sHeight)));

private void run(String imageLocation, int quality, Dimension dim) {


FIDErrorLevelAnalysis elaAnalyzer = new
FIDErrorLevelAnalysis(imageLocation, quality, dim, this);
elaAnalyzer.start();
}

public void processOnNeuralNetwork(BufferedImage elaImage) {


ImageRecognitionPlugin imageRecognition = (ImageRecognitionPlugin)

Page | 28
Fraudulent Image Detection

nnet.getPlugin(ImageRecognitionPlugin.class); // get the image recognition plugin


from neural network
HashMap<String, Double> output =
imageRecognition.recognizeImage(elaImage);
if (output == null) {
System.err.println("Image Recognition Failed");
}
System.out.println(output.toString());
}

@Override
public void elaCompleted(BufferedImage image) {
if(image==null)
return;
processOnNeuralNetwork(image);
}
}
FIDNetworkTrainer.java
package com.gc.fakeimagedetection.core;

import com.gc.fakeimagedetection.core.listener.BatchImageTrainingListener;
import com.gc.fakeimagedetection.core.trainer.BatchImageTrainer;
import java.awt.Dimension;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;

public class FIDNetworkTrainer implements BatchImageTrainingListener {

Page | 29
Fraudulent Image Detection

private final float MERROR = 0.01f;


private final float LEARNING_RATE = 0.1f;
private final float MOMENTUM = 0.7f;

public static void main(String[] args) {


if (args == null || args.length < 5) {
System.err.println("usage : <source> <neural path> <width> <height>
<labels(comma seperated)>");
return;
}

String sourceDir = args[0];


String neuralDir = args[1];
String sWidth = args[2];
String sHeight = args[3];
String imageLabelString = args[4];

new FIDNetworkTrainer().run(sourceDir, neuralDir, sWidth, sHeight,


imageLabelString);
}

@Override
public void batchImageTrainingCompleted() {
System.out.println("Training Completed");
}

@Override

Page | 30
Fraudulent Image Detection

public void batchImageTrainingUpdate(int iteration, Double error) {


System.out.println("Iteration " + iteration + "\t Error = " + error);
}

private void run(String sourceDir, String neuralDir, String sWidth, String


sHeight, String imageLabelString) {
ArrayList<String> labels = new ArrayList<>();
labels.addAll(Arrays.asList(imageLabelString.split(",")));
BatchImageTrainer neuralTrainer
= new BatchImageTrainer(new File(sourceDir), new File(neuralDir),
new Dimension(Integer.parseInt(sWidth), Integer.parseInt(sHeight)),
labels, this);
neuralTrainer.setMaxError(MERROR);
neuralTrainer.setMomentum(MOMENTUM);
neuralTrainer.setLearningRate(LEARNING_RATE);
neuralTrainer.start();
}

}
FIDPreprocessor.java
package com.gc.fakeimagedetection.core;

import com.gc.fakeimagedetection.core.errorlevelanalysis.ImageStandardizer;
import java.awt.Dimension;
import java.io.File;

public class FIDPreprocessor {

Page | 31
Fraudulent Image Detection

public static void main(String[] args) {


if (args == null || args.length < 5) {
System.err.println("Usage : <sourceDir> <destDir> <sWidth> <sHeight>
<output label>");
return;
}
String srcDir = args[0];
String destDir = args[1];
String sWidth = args[2];
String sHeight = args[3];
String outLabel = args[4];

ImageStandardizer preprocessor
= new ImageStandardizer(new File(srcDir), new File(destDir),
new Dimension(Integer.parseInt(sWidth), Integer.parseInt(sHeight)),
outLabel);
}
}

ConstantObjects.java:

package com.gc.fakeimagedetection.core.constants;

public class ConstantObjects {

public static String[] supportedExtensions


= {"JPG", "jpg", "JPEG", "PNG", "png", "TIFF", "TIF", "tif"};

Page | 32
Fraudulent Image Detection

public static String neuralNetworkPath = "nnet/MLPV2.0.nnet";


public static Boolean shouldPropogateResult = true;
public static float fakeness = -1;
public static float realness = -1;
}
ErrorLevelAnalyzer.java
package com.gc.fakeimagedetection.core.errorlevelanalysis;

import com.gc.fakeimagedetection.core.listener.ErrorLevelAnalysisUpdateListener;
import com.gc.fakeimagedetection.ui.alert.Calert;
import com.gc.fakeimagedetection.core.multithread.NotifyingThread;
import ij.ImagePlus;
import ij.io.FileSaver;
import static ij.io.FileSaver.setJpegQuality;
import ij.plugin.ContrastEnhancer;
import ij.plugin.ImageCalculator;
import ij.process.ImageProcessor;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Rectangle;
import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import javafx.scene.control.Alert;
import javax.imageio.ImageIO;

public class ErrorLevelAnalyzer extends NotifyingThread {

Page | 33
Fraudulent Image Detection

String fileLocation;
String destination = "output/processed";
int quality = 95;
Boolean runningStatus = false;
Dimension sampledDimension;
String outLabel;
ArrayList<String> supportedExtensions;
ErrorLevelAnalysisUpdateListener listener;
int baseCount = 1;

public ErrorLevelAnalyzer(String fileLocation, String destination, int quality) {


this.fileLocation = fileLocation;
this.destination = destination + "/";
this.quality = quality;
}

public void setListener(ErrorLevelAnalysisUpdateListener listener) {


this.listener = listener;
}

public ErrorLevelAnalyzer(String dirLoc, String destination, int quality,


ArrayList<String> supportedExtensions, Dimension, String outLabel) {
this.fileLocation = dirLoc;
this.quality = quality;
this.sampledDimension = dimension;
this.supportedExtensions = supportedExtensions;
this.destination = destination + "/";

Page | 34
Fraudulent Image Detection

this.outLabel = outLabel;
}

public void setSampledDimension(Dimension sampledDimension) {


this.sampledDimension = sampledDimension;
}

public Dimension getSampledDimension() {


return sampledDimension;
}

@Override
public void doRun() {
try {
System.out.println("Changing Images to size " + sampledDimension);

File[] availableFiles = new File(fileLocation).listFiles();


float totalSize = availableFiles.length;
float processedSize = 0;
checkForImageConflict();

for (File : availableFiles) {


String ext = file.getName().split("[.]")[1];
if (!supportedExtensions.contains(ext)) {
System.out.println("Dropping " + file.getName() + " due to
unsupported extension --" + file.getName().split("[.]")[1]);
continue;
}

Page | 35
Fraudulent Image Detection

runningStatus = true;
Image img;
try {
img = ImageIO.read(file);
} catch (IOException ex) {
System.err.println("Null Image");
return;
}
ImagePlus orig = new ImagePlus("Source Image", img);
if (orig.getWidth() < sampledDimension.getWidth() || orig.getHeight() <
sampledDimension.getHeight()) {
System.err.println("Too Small to process");
continue;
}

String basePath = "output/";


String origPath = basePath + "original.jpg";
String resavedPath = basePath + "resaved.jpg";
String elaPath = basePath + "ELA.png";

FileSaver fs = new FileSaver(orig);


setJpegQuality(100);
fs.saveAsJpeg(origPath);

setJpegQuality(quality);
fs.saveAsJpeg(resavedPath);
ImagePlus resaved = new ImagePlus(resavedPath);

Page | 36
Fraudulent Image Detection

ImageCalculator calc = new ImageCalculator();


ImagePlus diff;
try {
diff = calc.run("create difference", orig, resaved);
} catch (Exception e) {
Calert.showAlert("Error Occured", e.getMessage(),
Alert.AlertType.ERROR);
continue;
}
diff.setTitle("ELA @ " + quality + "%");

ContrastEnhancer c = new ContrastEnhancer();


c.stretchHistogram(diff, 0.05);

ImageProcessor ip = diff.getProcessor();
ImageProcessor imp;
if (ip.getWidth() > ip.getHeight()) {
Rectangle rec = new Rectangle(0, 0, ip.getHeight(), ip.getHeight());
ip.setRoi(rec);
imp = ip.crop();
} else {
Rectangle rec = new Rectangle(0, 0, ip.getWidth(), ip.getWidth());
ip.setRoi(rec);
imp = ip.crop();
}
imp = imp.resize((int) sampledDimension.getWidth(), (int)
sampledDimension.getHeight());
FileSaver resultSaver = new FileSaver(new ImagePlus("Result",

Page | 37
Fraudulent Image Detection

imp.getBufferedImage()));

DecimalFormat format = new DecimalFormat("#");


String savePath = destination + outLabel + format.format(baseCount +
processedSize) + ".png";
resultSaver.saveAsPng(savePath);

runningStatus = false;

float percentage = processedSize / totalSize;

String status = "Processing " + file.getName() + " " +


format.format(processedSize) + " / " + format.format(totalSize);
listener.iterationCompleted(status, percentage);
processedSize++;

}
} catch (Exception e) {
System.err.println("Error Occured at Ela_processor :" + e.getMessage());
}
}

private void checkForImageConflict() {


baseCount = 1;
while (true) {
String savePath = destination + outLabel + (baseCount + 1) + ".png";
if (new File(savePath).exists()) {
baseCount++;

Page | 38
Fraudulent Image Detection

} else {
break;
}
}
System.out.println("There are " + (baseCount - 1) + " images already. Starting
from " + baseCount);
}

}
FIDErrorLevelAnalysis.java
package com.gc.fakeimagedetection.core.errorlevelanalysis;

import com.gc.fakeimagedetection.core.listener.ErrorLevelAnalysisListener;
import com.gc.fakeimagedetection.core.multithread.NotifyingThread;
import com.gc.fakeimagedetection.ui.alert.Calert;
import ij.ImagePlus;
import ij.io.FileSaver;
import static ij.io.FileSaver.setJpegQuality;
import ij.plugin.ContrastEnhancer;
import ij.plugin.ImageCalculator;
import ij.process.ImageProcessor;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Rectangle;
import java.io.File;
import java.io.IOException;
import javafx.application.Platform;
import javafx.scene.control.Alert;

Page | 39
Fraudulent Image Detection

import javax.imageio.ImageIO;

public class FIDErrorLevelAnalysis extends NotifyingThread {

String fileLocation;
int quality = 95;
Boolean runningStatus = false;
Dimension sampledDimension;
ErrorLevelAnalysisListener listener;

public FIDErrorLevelAnalysis(String fileLocation,


int quality, Dimension sampledDimension, ErrorLevelAnalysisListener
listener) {
this.fileLocation = fileLocation;
this.quality = quality;
this.sampledDimension = sampledDimension;
this.listener = listener;
}

@Override
public void doRun() {
try {
Image img;
try {
System.out.println("Loading Image :" + fileLocation);
img = ImageIO.read(new File(fileLocation));
} catch (IOException ex) {
System.err.println("Null Image");

Page | 40
Fraudulent Image Detection

return;
}
System.out.println("Dimension is set to " + sampledDimension);
ImagePlus orig = new ImagePlus("Source Image", img);

String basePath = "tmp/";


File = new File(basePath);
if (!file.exists()) {
file.mkdir();
}
String origPath = basePath + "-original.jpg";
String resavedPath = basePath + "-resaved.jpg";
String elaPath = basePath + "-ELA.png";

FileSaver fs = new FileSaver(orig);


setJpegQuality(100);
fs.saveAsJpeg(origPath);

setJpegQuality(quality);
fs.saveAsJpeg(resavedPath);
ImagePlus resaved = new ImagePlus(resavedPath);

ImageCalculator calc = new ImageCalculator();


ImagePlus diff = calc.run("create difference", orig, resaved);
diff.setTitle("ELA @ " + quality + "%");

ContrastEnhancer c = new ContrastEnhancer();


c.stretchHistogram(diff, 0.05);

Page | 41
Fraudulent Image Detection

ImageProcessor ip = diff.getProcessor();

ImageProcessor imp;
if (ip.getWidth() > ip.getHeight()) {
Rectangle rec = new Rectangle(0, 0, ip.getHeight(), ip.getHeight());
ip.setRoi(rec);
imp = ip.crop();
} else {
Rectangle rec = new Rectangle(0, 0, ip.getWidth(), ip.getWidth());
ip.setRoi(rec);
imp = ip.crop();
}

imp = imp.resize((int) sampledDimension.getWidth(), (int)


sampledDimension.getHeight());
listener.elaCompleted(imp.getBufferedImage());
} catch (Exception e) {
//JavaFX UI thread is different from current Thread
System.err.println(e.toString());
Platform.runLater(new Runnable() {
@Override
public void run() {
Calert.showAlert("Fatal Error Occured", "Neural Network Error",
Alert.AlertType.ERROR);
}
});
listener.elaCompleted(null);
}

Page | 42
Fraudulent Image Detection

}
ImageStandardizer.java:
package com.gc.fakeimagedetection.core.errorlevelanalysis;

import com.gc.fakeimagedetection.core.listener.ErrorLevelAnalysisUpdateListener;
import com.gc.fakeimagedetection.core.constants.ConstantObjects;
import com.gc.fakeimagedetection.core.listener.ThreadCompleteListener;
import java.awt.Dimension;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;

public final class ImageStandardizer implements ThreadCompleteListener {

File sourceDir = null;


File destDir = null;
Dimension resolution = null;
File[] availableFiles = null;
ArrayList<String> supportedExtensions;
ErrorLevelAnalysisUpdateListener listener;
String outputLabel;

public ImageStandardizer(File sourceDirectory, File destinationDirectory,


Dimension finalResolution, String outLabel) {
System.out.println("Starting new Image Standardizer");
sourceDir = sourceDirectory;

Page | 43
Fraudulent Image Detection

resolution = finalResolution;
destDir = destinationDirectory;
outputLabel = outLabel;
}

public void run() {


init();
loadDirectory(sourceDir.getAbsolutePath());
processImages(outputLabel);

public void setListener(ErrorLevelAnalysisUpdateListener listener) {


this.listener = listener;
}

void init() {
supportedExtensions = new
ArrayList<>(Arrays.asList(ConstantObjects.supportedExtensions));
}

void processImages(String outLabel) {


System.out.println("Calling Processor with dimension " + resolution);
ErrorLevelAnalyzer imageProcessor
= new ErrorLevelAnalyzer(sourceDir.getAbsolutePath(),
destDir.getAbsolutePath(), 95, supportedExtensions, resolution, outLabel);
imageProcessor.setListener(listener);
imageProcessor.addListener(this);

Page | 44
Fraudulent Image Detection

imageProcessor.start();
}

public void loadDirectory(String path) {


System.out.println("Loading directory....");
sourceDir = new File(path);
if (!sourceDir.exists() || sourceDir.isFile()) {
System.out.println("Not a valid directory");
return;
}
availableFiles = sourceDir.listFiles();
if (availableFiles == null) {
return;
}
System.out.println("Total " + availableFiles.length + " files are available");
}

@Override
public void notifyOfThreadComplete(Thread thread) {
System.out.println("Image Processing Completed");
System.exit(0);
}
}

Batchimageprocessor.fxml:
<?xml version="1.0" encoding="UTF-8"?>

<?import com.jfoenix.controls.JFXButton?>

Page | 45
Fraudulent Image Detection

<?import com.jfoenix.controls.JFXCheckBox?>
<?import com.jfoenix.controls.JFXTextField?>
<?import javafx.scene.control.ProgressBar?>
<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Text?>

<AnchorPane id="AnchorPane" fx:id="rootPane" prefHeight="400.0"


prefWidth="514.0" style="-fx-background-color: #e1e1e1;"
xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="com.gc.fakeimagedetection.ui.controllers.BatchImageProcessorCont
roller">
<children>
<AnchorPane layoutX="50.0" layoutY="36.0" prefHeight="317.0"
prefWidth="426.0" style="-fx-background-color: #FFFFFF;">
<children>
<JFXButton buttonType="RAISED" layoutX="77.0" layoutY="12.0"
onAction="#loadSourceFolder" prefHeight="50.0" prefWidth="181.0" style="-fx-
background-color: #1976D2; -fx-text-fill: #ffffff;" text="Load Source Foder" />
<JFXCheckBox fx:id="srcIndicator" layoutX="294.0" layoutY="29.0"
text=" " />
<JFXTextField fx:id="sWidth" labelFloat="true" layoutX="14.0"
layoutY="169.0" maxWidth="181.0" minWidth="170.0" prefHeight="35.0"
prefWidth="170.0" promptText="Sampling Width" />
<JFXTextField fx:id="sHeight" labelFloat="true" layoutX="226.0"
layoutY="168.0" maxWidth="181.0" minWidth="181.0" prefHeight="35.0"
prefWidth="181.0" promptText="Sampling Height" />
<JFXTextField fx:id="outputBatchName" labelFloat="true"

Page | 46
Fraudulent Image Detection

layoutX="13.0" layoutY="215.0" maxWidth="403.0" minWidth="390.0"


prefHeight="32.0" prefWidth="393.0" promptText="Output Batch Name" />
<JFXButton buttonType="RAISED" layoutX="78.0" layoutY="73.0"
onAction="#loadDestinationFolder" prefHeight="50.0" prefWidth="181.0"
style="-fx-background-color: #1976D2; -fx-text-fill: #ffffff;" text="Load
Destination Foder" />
<JFXCheckBox fx:id="destIndicator" layoutX="295.0" layoutY="90.0"
text=" " />
<JFXButton buttonType="RAISED" layoutX="165.0" layoutY="262.0"
onAction="#startProcessing" prefHeight="35.0" prefWidth="80.0" style="-fx-
background-color: #1976D2; -fx-text-fill: #ffffff;" text="Start" />
</children>
<effect>
<DropShadow height="10.0" radius="4.5" width="10.0" />
</effect>
</AnchorPane>
<ProgressBar fx:id="progressBar" layoutY="382.0" prefHeight="20.0"
prefWidth="514.0" progress="0.0" />
<Text fx:id="status" layoutX="-1.0" layoutY="370.0"
strokeType="OUTSIDE" strokeWidth="0.0" textAlignment="CENTER"
wrappingWidth="513.9999953272927" />
</children>
</AnchorPane>

.gitignore.gf

__pycache__/

.vscode/*

Page | 47
Fraudulent Image Detection

static/uploaded_videos/*.mp4

static/cartoonized_images/*.jpg

config.yaml

run_local: true #Set this to true if you are running locally, false if you have configured the
Google buckets and algorithmia code.

gpu: true #Set this to true if you want to use the GPU

trim-video: true #Set this to false if you want to process full video

trim-video-length: 15 #Max number of seconds you want to trim the video from start

original_frame_rate: false #If False output_frame_rate will be used else original video
detected frame rate will be used, if no metadata found will use output_frame_rate

output_frame_rate: '24/1' #Set the output frame rate, if original resolution

colab-mode: false #Set true if you are executing in colab mode

original_resolution: false # Set to true if you don't want to resize the original video

resize-dim: 720 #The width of the video will be resized to specified number maintaining
aspect ratio

FIDNetworkTrainer.java

package com.gc.fakeimagedetection.core;

import com.gc.fakeimagedetection.core.listener.BatchImageTrainingListener;

Page | 48
Fraudulent Image Detection

import com.gc.fakeimagedetection.core.trainer.BatchImageTrainer;

import java.awt.Dimension;

import java.io.File;

import java.util.ArrayList;

import java.util.Arrays;

public class FIDNetworkTrainer implements BatchImageTrainingListener {

private final float MERROR = 0.01f;

private final float LEARNING_RATE = 0.1f;

private final float MOMENTUM = 0.7f;

public static void main(String[] args) {

if (args == null || args.length < 5) {

System.err.println("usage : <source> <neural path> <width> <height>


<labels(comma seperated)>");

return;

Page | 49
Fraudulent Image Detection

String sourceDir = args[0];

String neuralDir = args[1];

String sWidth = args[2];

String sHeight = args[3];

String imageLabelString = args[4];

new FIDNetworkTrainer().run(sourceDir, neuralDir, sWidth, sHeight,


imageLabelString);

@Override

public void batchImageTrainingCompleted() {

System.out.println("Training Completed");

@Override

public void batchImageTrainingUpdate(int iteration, Double error) {

Page | 50
Fraudulent Image Detection

System.out.println("Iteration " + iteration + "\t Error = " + error);

private void run(String sourceDir, String neuralDir, String sWidth, String sHeight,
String imageLabelString) {

ArrayList<String> labels = new ArrayList<>();

labels.addAll(Arrays.asList(imageLabelString.split(",")));

BatchImageTrainer neuralTrainer

= new BatchImageTrainer(new File(sourceDir), new File(neuralDir),

new Dimension(Integer.parseInt(sWidth), Integer.parseInt(sHeight)), labels,


this);

neuralTrainer.setMaxError(MERROR);

neuralTrainer.setMomentum(MOMENTUM);

neuralTrainer.setLearningRate(LEARNING_RATE);

neuralTrainer.start();

MLPNetworkMaker.java

package com.gc.fakeimagedetection.core.neuralnet;

Page | 51
Fraudulent Image Detection

import com.gc.fakeimagedetection.core.listener.NeuralNetworkCreationCompleteListener;

import java.util.List;

import org.neuroph.core.NeuralNetwork;

import org.neuroph.imgrec.ColorMode;

import org.neuroph.imgrec.ImageRecognitionHelper;

import org.neuroph.imgrec.image.Dimension;

import org.neuroph.util.TransferFunctionType;

public class MLPNetworkMaker implements Runnable {

String networkLabel;

Dimension samplingDimension;

ColorMode mode;

List<String> outputNeuronLabels;

List<Integer> neuronCounts;

TransferFunctionType type;

NeuralNetwork nnet;

Page | 52
Fraudulent Image Detection

String saveLocation;

NeuralNetworkCreationCompleteListener listener;

public void setListener(NeuralNetworkCreationCompleteListener listener) {

this.listener = listener;

public MLPNetworkMaker(String networkLabel, Dimension samplingDimension,


ColorMode mode, List<String> outputNeuronLabels, List<Integer> neuronCounts,
TransferFunctionType type, String saveLocation) {

this.networkLabel = networkLabel;

this.samplingDimension = samplingDimension;

this.mode = mode;

this.outputNeuronLabels = outputNeuronLabels;

this.neuronCounts = neuronCounts;

this.type = type;

this.saveLocation = saveLocation;

Page | 53
Fraudulent Image Detection

@Override

public void run() {

Boolean flag = true;

try {

nnet = ImageRecognitionHelper.createNewNeuralNetwork(networkLabel,
samplingDimension, mode, outputNeuronLabels, neuronCounts, type);

if (nnet == null) {

throw new Exception("Network Creation Failed");

nnet.save(saveLocation);

} catch (Exception e) {

flag = false;

listener.networkCreationComplete(flag);

NeuralNetProcessor.java

package com.gc.fakeimagedetection.core.processor;

Page | 54
Fraudulent Image Detection

import com.gc.fakeimagedetection.core.constants.ConstantObjects;

import com.gc.fakeimagedetection.core.listener.NeuralnetProcessorListener;

import com.gc.fakeimagedetection.core.multithread.NotifyingThread;

import java.awt.image.BufferedImage;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.IOException;

import java.util.HashMap;

import java.util.logging.Level;

import java.util.logging.Logger;

import javafx.application.Platform;

import javafx.scene.control.Alert;

import javafx.scene.control.Alert.AlertType;

import javax.imageio.ImageIO;

import org.neuroph.core.NeuralNetwork;

import org.neuroph.imgrec.ImageRecognitionPlugin;

Page | 55
Fraudulent Image Detection

public class NeuralNetProcessor extends NotifyingThread {

static BufferedImage image;

public static NeuralNetwork nnet;

static ImageRecognitionPlugin imageRecognition;

NeuralnetProcessorListener listener;

public void setListener(NeuralnetProcessorListener listener) {

this.listener = listener;

public static void main(String[] args) {

try {

System.out.println("usage java -jar nn.jar image_to_be_processed


file_of_neural_network");

System.out.println("Loading Image....");

image = ImageIO.read(new File(args[0]));

Page | 56
Fraudulent Image Detection

System.out.println("Loading NN....");

File NNetwork = new File(args[1]);

if (!NNetwork.exists()) {

System.err.println("Cant Find NN");

return;

nnet = NeuralNetwork.load(new FileInputStream(NNetwork)); // load trained


neural network saved with Neuroph Studio

System.out.println("Load Image Recog Plugin....");

imageRecognition = (ImageRecognitionPlugin)
nnet.getPlugin(ImageRecognitionPlugin.class); // get the image recognition plugin from
neural network

System.out.println("Recognize Image....");

HashMap<String, Double> output = imageRecognition.recognizeImage(image);

System.out.println("Output is....");

System.out.println(output.toString());

} catch (IOException ex) {

Logger.getLogger(NeuralNetProcessor.class.getName()).log(Level.SEVERE, null,
ex);

}
Page | 57
Fraudulent Image Detection

public NeuralNetProcessor(BufferedImage image) {

this.image = image;

void notifyUser() {

Platform.runLater(new Runnable() {

@Override

public void run() {

Alert alert = new Alert(AlertType.ERROR);

alert.setTitle("Neural Network Missing");

alert.setHeaderText("Cant find network file");

alert.setContentText("Please make sure that the file " +


ConstantObjects.neuralNetworkPath + " exists");

alert.showAndWait();

});

Page | 58
Fraudulent Image Detection

@Override

public void doRun() {

try {

//Bypass network reload during comeback through home button

if (nnet == null) {

File NNetwork = new File(ConstantObjects.neuralNetworkPath);

System.out.println("Nueral network loaded = " + NNetwork.getAbsolutePath());

if (!NNetwork.exists()) {

notifyUser();

return;

nnet = NeuralNetwork.load(new FileInputStream(NNetwork)); // load trained


neural network saved with Neuroph Studio

System.out.println("Learning Rule = " + nnet.getLearningRule());

imageRecognition = (ImageRecognitionPlugin)
nnet.getPlugin(ImageRecognitionPlugin.class); // get the image recognition plugin from
neural network

Page | 59
Fraudulent Image Detection

HashMap<String, Double> output = imageRecognition.recognizeImage(image);

if (output == null) {

System.err.println("Image Recognition Failed");

System.out.println(output.toString());

listener.neuralnetProcessCompleted(output);

} catch (Exception ex) {

Logger.getLogger(NeuralNetProcessor.class.getName()).log(Level.SEVERE, null,
ex);

listener.neuralnetProcessCompleted(null);

requirements.txt

Flask==1.0.2

gunicorn==20.0.4

Pillow==6.2.0

Page | 60
Fraudulent Image Detection

opencv_python==4.2.0.34

tensorflow==2.1.0

google-cloud-storage==1.29.0

algorithmia==1.3.0

scikit-video==1.1.11

tf_slim==1.1.0

PyYaml==5.3.1

flask-ngrok

Page | 61
Fraudulent Image Detection

10.2 Screen Shot

10.2.1 Home Page:

Page | 62
Fraudulent Image Detection

10.2.2 Image Select :

Page | 63
Fraudulent Image Detection

10.2.3 Checking Data

Page | 64
Fraudulent Image Detection

10.2.4 Result:

Page | 65
Fraudulent Image Detection

10.2.5 apply ELA on Image:

Page | 66
Fraudulent Image Detection

10.2.61 Result:

Page | 67
Fraudulent Image Detection

11. References

Book Reference

1. Head First Java. Authors: Kathy Sierra & Bert Bates.

2. Effective Java. Author: Joshua Bloch.

3. Hands-on ML with Scikit-Learn, Keras &


TensorFlow. author Aurélien Géron ,edition – second
edition publisher – O’Reilly Media, Inc.

Web Reference
[1] A picture‟s worth, Digital Image Analysis and Forensics, N Krawetz - 2007 Ph
D, Hacker Factor Solutions
[2] http://imagej.net/Welcome ImageJ is an open source image processing program
designed for scientific multidimensional images.J. Clerk Maxwell, A Treatise on
Electricity and Magnetism, 3rd ed., vol. 2. Oxford: Clarendon, 1892, pp.68–73.
[3] http://forensics.idealtest.org/ CASIA v2.0 CASIA V2.0 is with larger size and
with more realistic and challenged fake images by using post-processing of tampered
regions. It contains 7491 authentic and 5123 tampered color images.
[4] http://neuroph.sourceforge.net/ Neuroph Framework Neuroph is lightweight
Java neural network framework to develop common neural network architectures. It
contains well designed, open source Java library with small number of basic classes which
correspond to basic NN concepts.

Page | 68
Fraudulent Image Detection

12. List of Publications


S.No Title of Article International Month& year ISBN/ISSN
/National Journal of Publications Number
Name with details
1 Fraudulent Detection International 24th and 25th 9789391553401
Conference on March 2022
Advances in Science
and Engineering
(ICASE - 2022)

Page | 69

You might also like