In this project we attempt to explore the application of deep learning techniques for image classification by making an image classifier that recognizes if a given Art Image is generated by an AI or not.
All models have been trained with Art Images provided by the following dataset from Kaggle:
- Dataset: AI-ArtBench
The project is organized by following the next approach:
- Apply CNNs to each Art Style - Classify if image of given Art Style is AI Generated or not.
- Apply CNNs to all Art Styles - Classify if image from any Art Style is AI Generated or not.
Results obtained by running all the models are in the following report:
- AI-Generated Art Detection Project - PDF Report
- Course: Context Aware Security Analytics In Computer Vision 2023/2024 - UNISA
Authors: Katia Melanie Perchet, Franco Nicolas Merenda.
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:
- Folders Organization:
AI_<source_model>_<art_style>
source_model
: Latent Diffusion (LD
), Standard Diffusion (SD
)art_style
:Art Nouveau
,Baroque
,Expressionism
,Impressionism
,Post impressionism
,Realism
,Renaissance
,Romanticism
,Surrealism
,Ukiyo-e
- Total Images Count from All Art Styles:
Train
Split : 155,015Test
Split : 30,000
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:
CNN
- Defined by authors
VGG16
(Transfer Learning) + Flatten() + Dense(256, "relu") + Dropout(0.5) + Dense(1, "sigmoid")VGG19
(Transfer Learning) + Flatten() + Dense(256, "relu") + Dropout(0.5) + Dense(1, "sigmoid")
For All Art Styles, we tested the following CNNs:
ResNet50
(Transfer Learning) + Flatten() + Dense(256, "relu") + Dropout(0.5) + Dense(1, "sigmoid")InceptionV3
(Transfer Learning) + Flatten() + Dense(256, "relu") + Dropout(0.5) + Dense(1, "sigmoid")
2.1 Using poetry
- Install Python
- Clone Project
git clone https://github.com/katiaperchet/ai-art-casa
- Install Poetry - Follow instructions.
- Go to the project directory
- Install dependencies
poetry install
- Run jupyter-notebook to access notebooks and run examples/tests!
poetry run jupyter notebook
- Install Python
- Clone Project
git clone https://github.com/katiaperchet/ai-art-casa
- Go to the project directory
- Install dependencies
pip install -r requirements.txt
- Run jupyter-notebook to access notebooks and run examples/tests!
poetry run jupyter notebook
2.3 Using miniforge
- conda -- MacOS M1/M2 🍎 GPU Support!
Useful Links:
- TensorFlow Installation on Mac M1/M2(Apple Silicon) Chip | Quick Setup Guide
- 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"
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
-
(Option 1) - Create conda environment with
python=3.11
withtensorflow=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
-
(Option 2) - Create conda environment from file
conda env create -f conda_macm1_environment.yaml
- Run
jupyter notebook
with GPU support!
- If issues with
TensorFlow importing
:- Solution:
pip install tensorflow==2.16.1 --force-reinstall
- Solution: