SHERLOOK is an advanced Deep Learning model that provides users with a powerful tool to detect fake news by identifying images as either original or modified, while also indicating potential areas of alteration.
- What is this?
- Demo
- Dataset
- Results
- Project Structure
- Requirements
- How to use
- Built With
- License
- How to contribute
- Citing
- Support
- Authors
- Bibliography
This repository showcases the work and results of implementing a deep learning model using TensorFlow. The primary objective of this project is to detect whether an image has been modified, either by software or by an AI, with the aim of combating the spread of fake news. By leveraging advanced techniques in deep learning, the model is trained to analyze image features and accurately classify images as either authentic or modified. The repository provides a comprehensive overview of the model architecture, training process, evaluation metrics, and the implementation code. The ultimate goal is to contribute to the development of tools that can aid in verifying the authenticity of images, thereby helping to mitigate the impact of fake news in various domains.
If you would like to delve deeper into the details of this project, you can refer to the accompanying paper, which can be accessed at the following link: Paper. The paper provides comprehensive information about the methodology, experimental setup, results, and analysis, offering a more in-depth understanding of the project's contributions and findings.
The dataset used in this project is the Casia dataset, which contains 12,614 images. The images are divided into two folders: Au (original images) and Tp (modified images).
Alternatively, you can download it from here where you will have the exact same dataset as the one used in this project, with some minor modifications.
The dataset includes different categories of images, such as:
- ani: (animal)
- arc: (architecture),
- art: (art),
- cha: (characters),
- nat: (nature),
- pla: (plants),
- sec: (sections),
- txt: (texture)
βββ dataset
β βββ Au
β | βββ Au_ani_00001.jpg
β | βββ Au_ani_00002.jpg
β | βββ ...
β βββ Tp
β | βββ Tp_D_CND_M_N_ani00018_sec00096_00138.jpg
β | βββ Tp_D_CND_M_N_art00076_art00077_10289.jpg
β | βββ ...
To create the dataset with tampered images, it is important to note that we have two subcategories within the main categories:
- D: Different
- S: Same
This is because images can be modified in two ways:
- Different: The image is modified using another image.
- Same: The image is modified using the same image.
Various experiments have been conducted with different architectures and image preprocessing techniques. The first part of the text represents the architecture used, while the last part represents the image preprocessing technique. E stands for Error Level Analysis, W stands for Wavelet, and YUV stands for utilizing the YUV color space.
Modelo | Γpocas | Tiempo por Γpoca | Accuracy | Loss | PrecisiΓ³n | Recall | AUC | PRC | F1-Score |
---|---|---|---|---|---|---|---|---|---|
ENB1_v2_E | 13 | 99s | 0.93 | 0.21 | 0.95 | 0.94 | 0.98 | 0.98 | 0.93 |
ENB3_E | 14 | 126s | 0.92 | 0.20 | 0.95 | 0.90 | 0.98 | 0.98 | 0.92 |
XC_E | 12 | 147s | 0.90 | 0.55 | 0.90 | 0.93 | 0.93 | 0.94 | 0.92 |
MN_E | 12 | 64s | 0.91 | 0.22 | 0.99 | 0.84 | 0.98 | 0.99 | 0.91 |
MN_YUV | 33 | 45s | 0.92 | 0.23 | 0.90 | 0.92 | 0.97 | 0.97 | 0.91 |
ENVB2_E | 31 | 104s | 0.89 | 0.30 | 0.84 | 0.98 | 0.97 | 0.97 | 0.91 |
ENB1_E | 31 | 100s | 0.89 | 0.31 | 0.85 | 0.84 | 0.97 | 0.97 | 0.90 |
XC_YUV | 20 | 130s | 0.82 | 0.83 | 0.78 | 0.98 | 0.91 | 0.90 | 0.87 |
V16_E | 15 | 25s | 0.87 | 0.38 | 0.80 | 0.86 | 0.93 | 0.87 | 0.83 |
ENV2B1_E | 29 | 60s | 0.78 | 0.68 | 0.71 | 1 | 0.95 | 0.94 | 0.83 |
ENB1_YUV | 18 | 104s | 0.63 | 0.69 | 0.62 | 1 | 0.49 | 0.58 | 0.77 |
R50_E | 7 | 32s | 0.83 | 0.46 | 0.81 | 0.72 | 0.93 | 0.88 | 0.76 |
XC_W | 11 | 158s | 0.62 | 0.61 | 0.62 | 1 | 0.50 | 0.62 | 0.76 |
V16_W | 20 | 108s | 0.62 | 0.67 | 0.62 | 1 | 0.50 | 0.62 | 0.76 |
ENB1_W | 16 | 125s | 0.61 | 0.67 | 0.91 | 1 | 0.49 | 0.60 | 0.76 |
V16_YUV | 14 | 89s | 0.63 | 0.65 | 0.65 | 0.90 | 0.61 | 0.70 | 0.75 |
Scrath_W | 15 | 42s | 0.60 | 0.68 | 0.56 | 1 | 0.50 | 0.60 | 0.75 |
MN_W | 20 | 67s | 0.60 | 0.68 | 0.60 | 1 | 0.50 | 0.60 | 0.75 |
R50_W | 14 | 90s | 0.60 | 0.68 | 0.60 | 1 | 0.50 | 0.60 | 0.75 |
Scrath_E | 12 | 43s | 0.74 | 1.64 | 0.94 | 0.32 | 0.85 | 0.82 | 0.48 |
If you want test the others models you can download the models here
Visual results have been obtained to provide a visual representation of the potential modifications made. The best result is showcased, highlighting the specific modification that has been implemented. These visual results serve as a demonstration of how the modifications impact the overall output.
The confusion matrix will be presented to further analyze and understand the test results. The confusion matrix provides a detailed breakdown of the model's predictions, showing the number of true positive, true negative, false positive, and false negative instances. It offers valuable information on the model's performance, allowing for a deeper understanding of its accuracy and potential areas of improvement.
The model training process was completed in approximately 25 minutes. The training and validation metrics are provided to evaluate the performance of the model. These metrics offer insights into how well the model was trained and how it performed on both the training and validation datasets.
All the code is located in the src folder. The dataset is located in the dataset folder. The doc folder contains the final report of the project. The requirements.txt file contains all the required libraries to run the code. The gitignore file contains the files that are not uploaded to the repository. The README.md file is the file you are currently reading.
βββ dataset
β βββ Au
β | βββ Au_ani_00001.jpg
β | βββ Au_ani_00002.jpg
β | βββ ...
β βββ Tp
β | βββ Tp_D_CND_M_N_ani00018_sec00096_00138.jpg
β | βββ Tp_D_CND_M_N_art00076_art00077_10289.jpg
β | βββ ...
β βββ test
β | βββ cat.jpg
β | βββ me_x_3.jpg
β | βββ edited_by_ia.jpg
β βββ gitignore
βββ model
β | βββ custom_models
β | | βββ efficientnetB3
β | | | βββ model_arquitecture.json
β | | | βββ model_weights.h5
β | | βββ mobilenet
β | | | βββ model_arquitecture.json
β | | | βββ model_weights.h5
β | βββ ela_models
β | | βββ detect_manipulated_images_model_scratch.h5
β | | βββ ...
β | βββ wavelet_models
β | | βββ detect_manipulated_images_model_scratch.h5
β | | βββ ...
β | βββ yuv_models
β | | βββ detect_manipulated_images_model_efficientNetB1.h5
β | | βββ ...
β | βββ gitignore
βββ doc
β βββ Final_Report_of_Bachelor_Thesis.pdf
β βββ Gantt_diagram.xlsx
β βββ poster.png
βββ src
β βββ analisys.ipynb
β βββ model_custom.ipynb
β βββ models_ela_custom.ipynb
β βββ models_ela.ipynb
β βββ models_wavelet.ipynb
β βββ models_yuv_custom.ipynb
βββ result
β βββ confusion_matrix.png
β βββ grad-cam.png
β βββ metrics.png
βββ gitignore
βββ LICENSE
βββ README.md
βββ requirements.txt
- Python 3.9
- All the required libraries are in the requirements.txt file
- opencv-python
- numpy
- matplotlib
- Pillow
- Pandas
- kaggle
- tensorflow
- scikit-learn
- PyWavelets
- keras-tuner
If you don't have some of these libraries, you can install them manually or by running the following command:
pip install -r requirements.txt
- Clone this repo.
git clone https://github.com/migueldemollet/real-or-fake-image-machine-learning.git
- Go to the directory.
cd real-or-fake-image-machine-learning
- Install the required libraries.
using pip :
pip install -r requirements.txt
using conda :
conda install --file requirements.txt
- Run the code.
python3 src/main.py
vscode - The code editor used
This project is under the MIT License - see the LICENSE file for details
If you want to contribute to this project, you create a pull request. All contributions are welcome.
- Jordi Serra Raiz - Tutor of the project - Jordi Serra Raiz
- Laia Guerreo Candela - Provider of AI-generated modified images and logo design.- Laia Guerreo Candela
- Miguel del Arco - migueldemollet
-
Adoble. Adoble Analytics, Link, 2012.
-
RaΓΊl Γlvarez. Adobe, el creador de Photoshop, estΓ‘ desarrollando software para detectar imΓ‘genes manipuladas... con Photoshop, Link, 2018.
-
Sheng-Yu Wang, Oliver Wang, Andrew Owens, Richard Zhang, Alexei A. Efros. Detecting Photoshopped Faces by Scripting Photoshop. ICCV, 2019.
-
Thanh Thi Nguyen, Quoc Viet Hung Nguyen, Dung Tien Nguyen, Duc Thanh Nguyen, Thien Huynh-The, Saeid Nahavandi, Thanh Tam Nguyen, Quoc-Viet Pham, Cuong M. Nguyen. Deep Learning for Deepfakes Creation and Detection: A Surveyl, arXiv:1909.11573, 2022.
-
Andreas RΓΆssler, Davide Cozzolino, Luisa Verdoliva, Christian Riess, Justus Thies, Matthias NieΓner. FaceForensics++: Learning to Detect Manipulated Facial Images, arXiv:1901.08971, 2019.
-
NPHAT SOVATHANA. casia dataset v2, Link, 2018.
-
NPHAT SOVATHANA. casia dataset v1, Link, 2018.
-
MarsAnalysisProject. Image Forensics, Link, 2016.
-
Koushik Chandrasekaran. 2D-Discrete Wavelet Transformation and its applications in Digital Image Processing using MATLAB, Link, 2021.
-
Wikipedia. YUV, Link, 2004.
-
Jason Brownlee. Use Early Stopping to Halt the Training of Neural Networks At the Right Time, Link, 2020.
-
Xue Ying. An Overview of Overfitting and its Solutions, 10.1088/1742-6596/1168/2/022022, 2019.
-
B. Chen. Early Stopping in Practice: an example with Keras and TensorFlow 2.0, Link, 2020.
-
Tokio School. Analizamos quΓ© es y para quΓ© se usa el Transfer Learning en el Deep Learning, Link, 2022.
-
DataScientest. ΒΏQuΓ© es el mΓ©todo Grad-CAM?, Link, 2022.
-
fchollet. Grad-CAM class activation visualization, Link, 2020.
-
Mingxing Tan, Quoc V. Le. EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks, arXiv:1905.11946, 2019.
-
Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, Mark Chen. Hierarchical Text-Conditional Image Generation with CLIP Latents, arXiv:2204.06125, 2022.
-
Jonas Oppenlaender. The Creativity of Text-to-Image Generation, arXiv:2206.02904, 2022.