AI_Human

AI-Generated Art Detection Project - In this project we learned to explore the application of deep learning techniques for image classification by making an image classifier that recognizes if a given Art Image was generated by an AI or not.

This was done in the context of the course Context Aware Security Analytics In Computer Vision 2023/2024 - UNISA, during my master Degree.

Authors: Katia Melanie Perchet, Franco Nicolas Merenda.

The project is organized by following the next approach:

  1. Apply CNNs to each Art Style - Classify if image of given Art Style is AI Generated or not.
  2. Apply CNNs to all Art Styles - Classify if image from any Art Style is AI Generated or not.

During this project, special thanks to Katia ๐Ÿ˜, since she was the main lead on this project, where she was in charge of the majority of the project, fine-tuning the models and define the custom model described below. I learned a ton from her during this, about deep learning models, customizations and how to customize parameters. Thank you so much Katita ๐Ÿ’•๐Ÿ’•.

1.1. Dataset: AI-ArtBench

AI-ArtBench is a dataset that contains 180,000+ art images. 60,000 of them are human-drawn art that was directly taken from ArtBench-10 dataset and the rest is generated equally using Latent Diffusion and Standard Diffusion models. The human-drawn art is in 256x256 resolution and images generated using Latent Diffusion and Standard Diffusion has 256x256 and 768x768 resolutions respectively.

Dataset Information:

  1. Folders Organization: AI_<source_model>_<art_style>
    1. source_model: Latent Diffusion (LD), Standard Diffusion (SD)
    2. art_style: Art Nouveau, Baroque, Expressionism, Impressionism, Post impressionism, Realism, Renaissance, Romanticism, Surrealism, Ukiyo-e
  2. Total Images Count from All Art Styles:
    • Train Split : 155,015
    • Test Split : 30,000

1.2. CNN - Models

In this project we have tested different types of CNNs architectures in order to perform good accuracy.

For each Art Style, we tested the following CNNs:

  1. CNN - Defined by Katia
AI_Human
  1. VGG16 - (Transfer Learning) + Flatten() + Dense(256, "relu") + Dropout(0.5) + Dense(1, "sigmoid")
  2. VGG19 - (Transfer Learning) + Flatten() + Dense(256, "relu") + Dropout(0.5) + Dense(1, "sigmoid")

For All Art Styles, we tested the following CNNs:

  1. ResNet50 - (Transfer Learning) + Flatten() + Dense(256, "relu") + Dropout(0.5) + Dense(1, "sigmoid")
  2. InceptionV3 - (Transfer Learning) + Flatten() + Dense(256, "relu") + Dropout(0.5) + Dense(1, "sigmoid")

2. Lessons Learned

While doing this project, we made use of different libraries to build the models, train them and get

The full source code and documentation are available on:

2. Extras

While setting up the environment to train the models on my local machine, I had some issues to take advantage of the Mac M1 GPU. After doing some research, I reached to this point where you can make use of it.

2.1 Using miniforge - conda – MacOS M1/M2 ๐ŸŽ GPU Support!

Useful Links:

  1. TensorFlow Installation on Mac M1/M2(Apple Silicon) Chip | Quick Setup Guide
  2. TensorFlow Setup on Apple Silicon Mac (M1, M1 Pro, M1 Max)

NOTE: Run your terminal in ARM64 Mode. You can use the following aliases to run as ARM or X86.

alias arm="env /usr/bin/arch -arm64 /bin/zsh --login"
alias intel="env /usr/bin/arch -x86_64 /bin/zsh --login"
  1. Download Miniforge3
git clone https://github.com/katiaperchet/ai-art-casa
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh
sh ~/Downloads/Miniforge3-MacOSX-arm64.sh
source ~/miniforge3/bin/activate
  1. (Option 1) - Create conda environment with python=3.11 with tensorflow=2.16.2 dependencies:

    i. Create it Step by step

    conda install -c apple tensorflow-deps
    conda create -n tensorflow python=3.11
    # Activate created virtual environment
    conda activate tensorflow
    

    ii. Install necessary dependencies (Two options):

    pip install tensorflow-macos
    pip install tensorflow-metal
    conda install numpy=1.26.4 pandas matplotlib scikit-learn scipy plotly jupyter seaborn
    
  2. (Option 2) - Create conda environment from file

conda env create -f conda_macm1_environment.yaml
  1. Run jupyter notebook with GPU support!