Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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.

Notifications You must be signed in to change notification settings

Mmonire/Artist-Style-Recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

🎨 Artist Style Recognition with Transfer Learning

📖 Overview

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.

🎯 Objectives

  • 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.

✨ Features

  • Data Handling:
    • Loads images from directories using ImageDataGenerator.
    • Applies real-time augmentation (rotation, width/height shift, shear, zoom, horizontal flip).
  • 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.

🚀 Usage

  1. Open artist.ipynb in Jupyter/Colab.
  2. Run cells:
    • Load and augment data.
    • Build transfer learning model.
    • Train and evaluate.
    • Generate predictions.
  3. Output: submission.csv with predicted classes.

Key Code

  • 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)

📊 Code Structure

  • 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.

🔍 Evaluation

  • Metrics: Top-1/Top-5 accuracy, loss curves.
  • Validation: Separate val set from train data.
  • Augmentation Impact: Reduces overfitting, improves generalization.

📝 Notes

  • 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.

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published