🎭 NatyaNet: Indian Classical Dance Classifier

A deep learning project that classifies images of Indian classical dance forms using transfer learning with ResNet50.

Dataset: https://www.kaggle.com/datasets/somnath796/indian-dance-form-recognition Python PyTorch License

📋 Table of Contents

🎯 About

This project uses deep learning to automatically classify images of Indian classical dance forms. It employs transfer learning with a pre-trained ResNet50 model, fine-tuned on a dataset of dance images.

Key Features:

  • 🎨 Classifies 8 different Indian classical dance forms
  • 🚀 Uses transfer learning (ResNet50 pre-trained on ImageNet)
  • 📊 Includes data exploration and visualization tools
  • 🎓 Beginner-friendly with extensive documentation
  • 📈 Achieves ~85%+ accuracy on test set

💃 Dance Forms

The model can classify the following 8 Indian classical dance forms:

  1. Bharatanatyam - From Tamil Nadu
  2. Kathak - From Northern India
  3. Kathakali - From Kerala
  4. Kuchipudi - From Andhra Pradesh
  5. Manipuri - From Manipur
  6. Mohiniyattam - From Kerala
  7. Odissi - From Odisha
  8. Sattriya - From Assam

🔧 Installation

Prerequisites

  • Python 3.8 or higher
  • pip package manager
  • (Optional) CUDA-capable GPU for faster training

Step 1: Clone the Repository

git clone https://github.com/harshi-puli/Classical-indian-dance-classifier.git
cd Classical-indian-dance-classifier

Step 2: Create a Virtual Environment

# Create virtual environment
python -m venv natyam

# Activate it
source natyam/bin/activate  # On Mac/Linux
# OR
natyam\Scripts\activate  # On Windows

Step 3: Install Dependencies

pip install -r requirements.txt

Manual installation:

pip install torch torchvision tqdm pandas numpy matplotlib seaborn scikit-learn pillow

📁 Dataset Structure

Your project directory should look like this:

Classical-indian-dance-classifier/
├── dataset/
│   ├── train/              # Training images
│   │   ├── 1.jpg
│   │   ├── 2.jpg
│   │   └── ...
│   ├── test/               # Test images (optional)
│   │   ├── 501.jpg
│   │   └── ...
│   ├── train.csv           # Training labels
│   └── test.csv            # Test labels (optional)
├── dance_classifier.py     # Main training script
├── explore_data.py         # Data exploration
├── predict.py              # Prediction script
├── requirements.txt        # Python dependencies
└── README.md              # This file

CSV Format:

Image,target
1.jpg,kathak
2.jpg,bharatanatyam
3.jpg,odissi

🚀 Usage

1. Explore the Dataset

First, run the exploration script to understand your data:

python explore_data.py

This will:

  • ✅ Show class distribution
  • ✅ Check for missing images
  • ✅ Analyze image dimensions
  • ✅ Generate visualization plots
  • ✅ Create sample image grids

Output:

  • train_class_distribution.png
  • test_class_distribution.png
  • sample_images.png

2. Train the Model

Run the main training script:

python dance_classifier.py

Training Process:

  • Loads and preprocesses images
  • Splits data into train/validation sets (if needed)
  • Trains ResNet50 model for 25 epochs
  • Saves the best model automatically
  • Generates training history plots

Expected Training Time:

  • With GPU: ~15-30 minutes
  • With CPU: ~2-4 hours

Output:

  • best_dance_model.pth - Trained model weights
  • training_history.png - Loss and accuracy curves
  • confusion_matrix.png - Model performance breakdown

3. Make Predictions on New Images

Use the trained model to classify new dance images:

python predict.py --image path/to/your/image.jpg

Example:

python predict.py --image test/508.jpg

Output:

Prediction: Odissi
Confidence: 92.5%

Top 3 predictions:
1. Odissi      - 92.5%
2. Bharatanatyam - 4.2%
3. Kuchipudi   - 2.1%

Batch Prediction:

python predict.py --folder test/

This will classify all images in the folder and save results to predictions.csv.

📂 Project Structure

├── dance_classifier.py      # Main training script
├── explore_data.py          # Data exploration and visualization
├── predict.py               # Prediction script for new images
├── prepare_test_csv.py      # Helper to create proper train/test split
├── BEGINNERS_GUIDE.py       # Detailed explanations for beginners
├── VISUAL_GUIDE.py          # Visual diagrams and concepts
├── requirements.txt         # Python package dependencies
├── .gitignore              # Git ignore file
└── README.md               # This file

📊 Results

Model Performance

Metric Score
Training Accuracy ~95%
Validation Accuracy ~85%
Test Accuracy ~85%

Confusion Matrix

The model performs best on:

  • ✅ Kathak (90%+ accuracy)
  • ✅ Odissi (88%+ accuracy)
  • ✅ Bharatanatyam (87%+ accuracy)

Common confusions:

  • Kathakali ↔ Kuchipudi (similar costumes)
  • Mohiniyattam ↔ Bharatanatyam (similar poses)

🎓 Learning Resources

For Beginners

If you're new to deep learning, check out these guides:

  1. BEGINNERS_GUIDE.py - Detailed explanations of every concept
  2. VISUAL_GUIDE.py - Visual diagrams showing how everything works

Key Concepts Covered

  • What is image classification?
  • Neural networks and deep learning
  • Transfer learning with ResNet50
  • Data augmentation
  • Training vs validation vs test sets

🔧 Configuration

Customize training by editing dance_classifier.py:

# Training parameters
BATCH_SIZE = 32          # Reduce if out of memory
NUM_EPOCHS = 25          # Increase for better accuracy
LEARNING_RATE = 0.001    # Adjust learning rate

🐛 Troubleshooting

Common Issues

Out of Memory Error

# Reduce batch size in dance_classifier.py
BATCH_SIZE = 16  # or 8

Slow Training

# Use smaller model
model = models.resnet18(pretrained=True)

Low Accuracy

  • Train for more epochs (50-100)
  • Add more training data
  • Try different learning rates

Module Not Found

source natyam/bin/activate
pip install -r requirements.txt

🤝 Contributing

Contributions welcome! Areas for improvement:

  • Adding more dance forms
  • Improving model accuracy
  • Creating web interface
  • Better visualizations

📄 License

MIT License - see LICENSE file for details.

📧 Contact

Harshini Pulivarthi


Made with ❤️ for preserving Indian classical dance heritage through AI

Built With

Share this project:

Updates