This project trains a deep neural network using Keras/TensorFlow to classify artistic styles or recognize artists from images, leveraging transfer learning from pre-trained models (e.g., VGG16 or ResNet) and data augmentation to handle limited datasets. The goal is to achieve high accuracy on image classification tasks related to art, with techniques to mitigate overfitting through augmentation (rotation, flipping, zooming) and fine-tuning.
Implemented in a Jupyter Notebook (artist.ipynb
), the project includes data loading, augmentation, model building, training, evaluation, and submission generation for predictions on a test set.
- Classify Artistic Styles: Predict artist or style from input images.
- Apply Transfer Learning: Use pre-trained CNNs as base models for feature extraction.
- Augment Data: Increase dataset size and diversity with ImageDataGenerator.
- Generate Submission: Output predictions in CSV format for evaluation.
- Data Handling:
- Loads images from directories using
ImageDataGenerator
. - Applies real-time augmentation (rotation, width/height shift, shear, zoom, horizontal flip).
- Loads images from directories using
- Transfer Learning:
- Base model: VGG16 or similar, frozen initial layers, fine-tune top layers.
- Custom classifier head with Dense layers and softmax output.
- Training:
- Adam optimizer, categorical cross-entropy loss.
- Early stopping and model checkpointing.
- Evaluation:
- Accuracy and loss plots.
- Confusion matrix and classification report.
- Submission:
- Predicts on test images, saves labels to
submission.csv
.
- Predicts on test images, saves labels to
- Open
artist.ipynb
in Jupyter/Colab. - Run cells:
- Load and augment data.
- Build transfer learning model.
- Train and evaluate.
- Generate predictions.
- Output:
submission.csv
with predicted classes.
-
Data Augmentation:
from tensorflow.keras.preprocessing.image import ImageDataGenerator train_datagen = ImageDataGenerator(rotation_range=20, width_shift_range=0.2, ...) train_generator = train_datagen.flow_from_directory('data/train', target_size=(224, 224), batch_size=32)
-
Transfer Learning Model:
from tensorflow.keras.applications import VGG16 base_model = VGG16(weights='imagenet', include_top=False, input_shape=(224, 224, 3)) model = Sequential([base_model, GlobalAveragePooling2D(), Dense(1024, activation='relu'), Dense(num_classes, activation='softmax')])
-
Training & Submission:
model.fit(train_generator, epochs=20, validation_data=val_generator) preds = model.predict(test_generator) submission = pd.DataFrame({'id': test_ids, 'class': np.argmax(preds, axis=1)}) submission.to_csv('submission.csv', index=False)
- Cells 1-3: Imports, data loading/augmentation.
- Cells 4-6: Model building (transfer learning), compilation.
- Cells 7-9: Training, evaluation (plots, metrics).
- Cell 10: Test predictions, submission.
- Metrics: Top-1/Top-5 accuracy, loss curves.
- Validation: Separate val set from train data.
- Augmentation Impact: Reduces overfitting, improves generalization.
- Transfer Learning: Freezes base layers, trains top for domain adaptation.
- Augmentation: Essential for small art datasets to simulate variations.
- GPU: Use for faster training; Colab T4 sufficient.
- Improvements: Focal loss for imbalance, ensemble models.