Giter Site home page Giter Site logo

deruhat / nivscg-keras Goto Github PK

View Code? Open in Web Editor NEW
21.0 5.0 7.0 326 KB

Distinguishing Between Natural and Computer-Generated Images Using Convolutional Neural Networks in Keras.

Home Page: https://deruhat.github.io/portfolio/ni-vs-cg/

Python 68.30% MATLAB 31.70%
deep-learning convolutional-neural-networks computer-graphics image-forensics

nivscg-keras's Introduction

NIvsCG

Distinguishing Between Natural and Computer-Generated Images Using Convolutional Neural Networks



Preparing the Workspace

Make sure you have the project structured as follows:

├── checkpoints
├── logs
├── models
├── results
├── src
   ├── model.py
   ├── voting.py
   ├── patchesTestAcc.py
├── utils
   ├── mps
   ├── imageMpsCrop.m
   ├── makePatches.m
   └── imageNamesFileMaker.py
└── datasets
   ├── full
       ├── personal
           ├── 000001.jpg 
           └── ...
       └── prcg
           ├── 000001.jpg 
           └── ...
   └── patches
       ├── train
           ├── personal
              ├── patch-001.bmp 
              └── ...
           └── prcg
              ├── patch-001.bmp 
              └── ...
       ├── valid
           ├── personal
              ├── patch-001.bmp 
              └── ...
           └── prcg
              ├── patch-001.bmp 
              └── ...
       ├── test
           ├── personal
              ├── patch-001.bmp 
              └── ...
           └── prcg
              ├── patch-001.bmp 
              └── ...
       └── test-majority-voting
           ├── all
              ├── patch-001.bmp 
              └── ...
           └── filenames.txt

Dataset

We used the Personal and PRCG datasets for our two classes. Images of each class were split into 3:1:1 ratio (train:valid:test). And it was taken into account each image's category. For example, PRCG images fall into multiple categories (Archticture, nature, object, etc..) We split the images so each dataset (train, valid, test) has images from every category. Then made 200 crops of each image using the MPS algorithm to get the patches. All of this is done using the makePatches.m script.

  • Google and PRCG datasets can be downloaded here.
  • Personal dataset can be downloaded here.

Training the Model

The code for the CNN design described by the paper can be found in model.py. Image patches used as training and validation data have to be cropped using the MPS algorithm implemented here.

Majority Voting

The code for the majority voting algorithm is in voting.py. A trained .h5 model from model.py is needed in order to run the majority voting algorithm and get the test accuracy.

Results

So far we're able to achieve 95% 96.88% 97.18% accuracy on image classification. We take 200 patches that cover the whole image from each test sample using the MPS algorithm, and take the majority vote of these 200 patches to decide that test image's class.

You can download the trained model here.

Contributers

Abdulellah Abualshour

Abdulmajeed Aljaloud

References

nivscg-keras's People

Contributors

deruhat avatar rinzu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nivscg-keras's Issues

License

Hi, thank you for your great work! Could you please add a license file for this repo? Ideally MIT oder Apache, thank you! :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.