|
--- |
|
license: apache-2.0 |
|
datasets: |
|
- DataScienceProject/Art_Images_Ai_And_Real_ |
|
pipeline_tag: image-classification |
|
library_name: keras |
|
--- |
|
**Real art vs AI-Generated art image classification** |
|
|
|
This project provides a ResNet50 pre-trained model for classifying images as either 'real art' or 'fake art'. |
|
ResNet50 is a deep convolutional neural network with 50 layers, known for its "residual connections" that help mitigate the vanishing gradient problem. |
|
It allows training of very deep networks by adding shortcut connections that skip one or more layers, making it highly effective for image classification tasks. |
|
Our goal is to accurately classify the source of the image with at least 85% accuracy and achieve at least 80% in the recall test. |
|
|
|
***Installation instructions*** |
|
|
|
The following libraries or packages are required: numpy, pandas, tensorflow, keras, matplotlib, sklearn, cv2. |
|
We prepare the data for the model by sorted the images into 2 types of folders which are divided equally(real art- labeled as 0, fake art- labeled as 1). |
|
Our ResNet50 model is based on 2,800 images that have been resized and normalized, the files formats is PNG, JPG. |
|
The images are divided into a training set that contains 90% from data and a testing set that contains the remaining 10%. |
|
|
|
***ResNet50 model architecture*** |
|
|
|
The model is pre-trained on 'ImageNet' that contains a large dataset of more than millions images. |
|
It applies transfer learning, freezing initial layers of ResNet50, and training only the final layers. |
|
The final layer, which makes the predictions, is a binary classification layer that uses a sigmoid activation function. |
|
|
|
***Training Details*** |
|
|
|
The model is trained using binary cross-entropy loss and the Adam optimizer. |
|
The model validates itself during training using 20% of the training data as validation, independent of the test data, to monitor performance and avoid overfitting. |
|
The model is trained for 5 epochs with a batch size of 32 and employs 4-fold cross-validation to ensure robust performance. |
|
During each fold, the model's weights are saved after training, allowing for the reuse of the best-performing weights. |
|
|
|
***Performance Evaluation*** |
|
|
|
After training, the model is evaluated on the test set. |
|
The following metrics are used to measure performance: |
|
Accuracy: The percentage of correct classifications. |
|
Precision, Recall, F1-Score: For evaluating the model’s classification ability on both real art and AI-generated art images. |
|
Confusion Matrix: Provides insights into classification performance. Displays true positives, false positives, true negatives, and false negatives. |
|
|
|
***To run the project*** |
|
|
|
Place the images in the respective training and testing folders. |
|
Preprocess the images by resizing and normalizing them. |
|
Train the model using the provided code. |
|
Evaluate the model on the test set. |
|
|
|
***Visualization results*** |
|
|
|
Confusion Matrix: To visualize the classification performance. |
|
Training and Validation Metrics: Plots for accuracy and loss over the epochs. |
|
|
|
***Results*** |
|
|
|
Test accuracy = 0.784 |
|
|
|
Test loss = 0.48 |
|
|
|
Precision = 0.76 |
|
|
|
Recall = 0.83 |
|
|
|
F1 = 0.79 |
|
|
|
*Confusion Matrix:* |
|
|
|
![image/png](https://cdn-uploads.huggingface.co/production/uploads/66d6f28a19214d743ca1eb43/lhs-dzknQWXddWxhdov1t.png) |
|
|
|
|
|
|