Instructions to use DataScienceProject/CNN with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use DataScienceProject/CNN with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://DataScienceProject/CNN") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from DataScienceProject/CNN: direct link, hf CLI and curl.
- Browser
- Download file 3.02 kB
-
https://huggingface.co/DataScienceProject/CNN/resolve/8ef7576f7b38c7ee8ec813db2fcbb881680e158d/README.md
- Command line
-
hf download hf://DataScienceProject/CNN@8ef7576f7b38c7ee8ec813db2fcbb881680e158d/README.md
-
curl -L -o README.md https://huggingface.co/DataScienceProject/CNN/resolve/8ef7576f7b38c7ee8ec813db2fcbb881680e158d/README.md
3.02 kB
| license: apache-2.0 | |
| Real art vs AI-Generated art image classification | |
| This project provides a Convolutional Neural Network (CNN) model for classifying images as either 'real art' or 'fake art'. | |
| CNN is a type of deep learning model specifically designed to process and analyze visual data by applying convolutional layers that automatically detect patterns and features in images. | |
| 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 CNN 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%. | |
| CNN model architecture | |
| Convolutional Layers: for feature extraction from images, applying 32 or 64 filters with a size of 3x3, the activation function used id ReLU . | |
| MaxPooling Layers: for reducing the spatial dimensions to a size of 2x2. | |
| Flatten: converts the multi-dimensional output of previous layers into a one-dimensional vector for input into fully connected layers. | |
| Dropout Layer: to prevent overfitting with a thinning rate of 0.5 after the first Dense layer. | |
| Dense Layer: last layer of dense for classification with a sigmoid activation function. | |
| Training Details | |
| The model is trained using binary cross-entropy loss and the Adam optimizer. It is validated with 20% of the training data reserved for validation. | |
| The model employs 4-fold cross-validation to ensure robust performance. | |
| The following callbacks are used during training: | |
| EarlyStopping: Stops training if the validation accuracy ceases to improve for a specified patience period. | |
| ModelCheckpoint: Saves the best weights during training based on validation accuracy. | |
| The best-performing model from each fold is saved, and the model with the best weights overall is selected for final testing. | |
| 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 and AI-generated images. | |
| Confusion Matrix: Displays true positives, false positives, true negatives, and false negatives. | |
| Instructions | |
| 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. | |