Skip to content

SanKolisetty/AI-Image-Classifier

Repository files navigation

Banner

AI Image Classifier

AI Image Classifier is a machine learning model that can effectively classify Real and AI Generated Images.

Table of Contents

Brief Overview

(Back to top)

This project involved building a machine learning model that can classify real and AI generated images. The first step was to create a dataset comprising of AI-generated and real images. To accomplish this, pygoogle_image was used, with which images from Google were downloaded. Apart from Google Images, two more datasets were used.

  • CIFAKE: Real and AI-Generated Synthetic Images
  • Ai Generated Images | Images Created using Ai from Kaggle

These images were preprocessed and features were extracted. Then, a Convolutional Nueral Network based Classifier model was constructed and trained on the dataset containing around 1,00,000 images.

Demo

(Back to top)

Here is a short demo of the deployed web application.

demo.mp4

Installation

(Back to top)

Open Git Bash and change the directory to the location where the repository is to be cloned. Then, type the following commands.

  git init
  git clone https://github.com/SanKolisetty/AI-Image-Classifier.git

Now, install the requirements using the following command.

   pip install -r requirements.txt 

To access or use the application, open a terminal in the cloned repository folder and run the following command.

  streamlit run deploy.py

Finally, browse the link provided in your browser.

Data Sources

(Back to top)

The dataset comprised of Real and AI Generated Images. Images were collected from Google using the python library pygoogle_image. Every single image was verified to avoid issues such as incorrect and ambigous images. Two other datsets were also used.

  • CIFAKE: Real and AI-Generated Synthetic Images ( Link )
  • Ai Generated Images | Images Created using AI ( Link )

Combing the three datasets, we have:

  • Train Set: 101031
  • Test Set: 20000

Model

(Back to top)

The CNN model was built similar to VGG16 and was trained on the train dataset. The model has a Convolutional Layer, MaxPooling Layer and a Dropout Layer repeated four times with increasing sizes of filters of the Convolutional Layer i.e. 32, 64, 128, and 256. It has 3 dense layers. The activation for all the layers is relu except for the last layer, which has activation sigmoid.

The model architecture and model summary are uploaded.

Testing and Evaluation

(Back to top)

On evaluation, model achieved an accuracy of 93.90%

Classification Report:

image

Confusion Matrix:

image

0 is Real and 1 is AI Generated

Deployment

(Back to top)

The application has been deployed in the Streamlit Cloud.

You can access it here: https://ai-image-classifier-sk.streamlit.app/