Identifying the Dance Form, Image Classification With Convolutional Neural Network

Identifying the dance form with cnn

Today we are going to learn something crazy, by using deep learning techniques. We are going to build an Image classification model with a convolutional neural network or CNN.

Which can classify the given dance form image to the specific dance category.

The popularity of deep learning techniques usage increased predominantly over the years due to the significant cost reduction in storing and computing resources.

We can solve major chunks of problems, where machine learning models are not giving promising performance results. 

The other reasons for deep learning usage is due to its flexibility and robustness in learning patterns in the data, which is hard for humans to learn or identify. 

With growing training data, deep learning models learn more patterns, similarly like how the human brain learns with the amount of examples seen over the time. 

Today let’s see one such example of how the deep learning models learn the dance form patterns to identify the dance form given the input image.

In a more technical term of saying Image classification with convolutional neural network

Are you excited ?
We are too 🙂

Before jumping straight into the use case , let’s have an eagle view on the table of contents.

Identifying the Dance Form, Image Classification With Convolutional Neural Network #cnn #deeplearning #imageclassification

Click to Tweet

What is Image Classification

Image classification

Today's crazy use case will fall under the image classification category. If you are not sure about classification don’t worry we all were there at the beginning. So we would suggest you look at the below articles. 

Which helps you in solid foundation for understanding the classification concepts. 

For now let’s understand what we mean by Image classification. 

Image Classification is most prominently used under Computer Vision techniques. It is a supervised learning algorithm which is able to classify the images into its respective classes or categories. 

To train the Image classification model we need an image dataset and its target labels. This is known as the training dataset most important or critical part in image classification model building. 

We can solve various real world problems using Image classification techniques. It is involved in various applications, which includes Face Recognition , Gender Classification etc.

Just to understand the depth of image classification technique, let’s see a few more real world examples.

Image Classification Applications

As mentioned before the Image classification has various use cases  which are widely used in various domains.

Applications of Image classification

Just to give you the idea, We are presenting you the domains where the image classification is heavily used.  

Here you can see some of the sectors which are highly using Image Classification.


Health Care is one of the finest domains we need to consider. It has different types of applications which can be solved using the image classification models. It includes

  • Lungs Cancer Detection.
  • Brain tumor Detection, 
  • Covid19 detection from x-ray scan images

With these kinds of use cases using image classification applications is growing exponentially in the healthcare sector. 

It is giving promenade results with different evaluation metrics and providing efficient solutions for various kinds of complex medical problems.


Image classification or recognition is playing a very crucial role in the education sector too. Such as  face detection.  

Face recognition applications help to take attendance at one glance with no human effort.

Driver less cars

Image classification is one of the key components fueling self-driving technology, including the enhancement of safety features. 

It is implemented to identify objects on the roads, which includes

  • Other vehicles, 
  • Sharp turns, 
  • People, 
  • Pathways, 
  • Moving objects etc. 

Self-Driving cars facilitate traveling with more safety features.

Now let’s deep dive to use of image classification technique in identifying the dance form, given the image of dance.  

Image Classification Problem Statement

Classifying Dance Form

You can see the different images above representing various dance forms. Anyone without dancing knowledge can’t tell the difference between these dance forms.

Tobe frank, even we can’t say.

Probably most of the people will fail to define the actual dance form names or images from the shown images. This is  a nutshell explanation for the image classification problem statement .

We have different dance forms available in the world. 

Our main task is to Identify the dance form for the given image.

Let’s understand a bit about the dataset we are using to build the image classification model.

Image Classification Model Dataset

The dataset consists of 364 training images belonging to 8 categories, namely 

  • Manipuri, 
  • Bharatanatyam, 
  • Odissi, 
  • Kathakali, 
  • Kathak, 
  • Sattriya, 
  • Kuchipudi, 
  • Mohiniyattam

Directory Structure

  • train folder - consists 364 training images
  • test folder - consists 154 testing images
  • train.csv
  • test.csv

You can download the data by using this link, Copy past the below link

Image Classification Model Building

To build the image classification model with deep learning involves different stages.

  • Data Preprocessing
  • Analysis of the data
  • Data augmentation
  • Data Split
  • Image classification model building
  • Model specific graphs
  • Image classification model evaluation

Data Preprocessing

Here, we are importing the necessary libraries to implement the model.

Here, we are reading the image files , converting it into an array ,and normalizing it.

Here, We are converting the image to numerical, the same way we used to convert the text to numerical values while solving the natural language processing problems.

The above code is simply converting the target label into one hot encoding.

Analysis of the data

Image Classification Data Distribution

Here, we can see the target distribution of the Training data set. Seems like more over all targets having a similar kind of distribution. 

To increase the dataset, let’s create multiple copies of the data with meaningful changes. Which is called data augmentation in deep learning.

Data Augmentation

Data augmentation is a method that is used to increase the amount of data by applying various operations to the available image dataset. 

It can be performed by adding newly created synthetic data or images from existing data or slightly modified copies of already existing data or images. It helps to avoid overfitting when training a model.

Below is the code snippet to get this done.

Here , we are augmenting the data using various techniques in order to increase the data samples.

Data Spliting 

Here ,we are splitting the data into training and validation data with the ratio of 80% and 20%.

Image Classification Model Building

Now let’s build the image classification model.


  • First we are creating a Sequential model with an input layer having input_shape (224,224) 
  • It is followed by three hidden conv2D layers with the sequence of 128,64 and 128 hidden neurons, respectively.
  • Along with relu activation function, 2*2 kernel size maxpooling2D, and Dropout ratio.
  • Flattening the data- (Flattening is converting the data into a 1-dimensional array for inputting it to the next layer).
  • Dense layer with 64 neurons and relu activation function
  • Last dense output layer with 8 neurons and softmax activation function.
  • Now, we are compiling the defined model having Adam optimizer with categorical_crossentropy loss and accuracy metric.

Above all the key terms (Conv2D,MaxPooling2D and Dropout) are related to Convolutional Neural Network. 

We used different activation functions. You can refer to activation functions for more learning.

Here, we are creating both train and test data Generators to load data while training the model with having batch_size=32.

Here, we fit the model based on given arguments

  • generator: a generator whose outcome must be a list of the form:- (inputs, targets)  
  • steps_per_epoch: it defines the complete number of steps taken from the generator as soon as one epoch is finished and the next epoch has started. It can be calculated as the total number of samples in your dataset divided by the batch size.
  • epochs:  epoch refers to one iteration throughout a full training dataset. 
  • validation_data:  it can be either- an inputs and targets list, a generator
  • validation_steps: It can be used only if the validation_data is a generator. It defines the complete number of steps taken from the generator previously interrupted at every iteration, and it is calculated as the total number of validation data points in your dataset divided by the validation batch size.

Model Specific Graphs

To visualize epoch wise how the loss is changing, we are going to use the below code snippet.

Train and validation Loss Graph

Here we are plotting the train loss vs validation loss with respect to Epochs during training of the model.

Train and validation Accuracy

Here, we are plotting the train accuracy vs validation accuracy with respect to Epochs during training of the model.

Image Classification Model Evaluation

Here , we are loading the test images ,converting it into array data.  

Here , we are making predictions on the test data using a trained CNN model, inverse transforming the results into its original names and finally saving it into pandas DataFrame.

Next we are concatenating the predictions into a test file and saving it into a csv file for submission.


We move to the end of this article. We learned how to build an image classification model which is able to classify the different dance forms using Convolutional Neural Networks in python.

Don't limit yourself; use this methodology, and do some slight modifications to build models to  solve different image classification applications.

I believe you learned something new from this article, Happy Learning!

Frequently Asked Questions (FAQs) On Convolution Neural Network

1. What is a Convolutional Neural Network (CNN)?

 A Convolutional Neural Network is a deep learning algorithm that can take in an input image, assign importance (learnable weights and biases) to various aspects/objects in the image, and differentiate one from the other.

2. How Can CNNs Be Used to Identify Dance Forms?

 CNNs can be trained on images of different dance forms. Through training, the network learns to recognize patterns and features specific to each dance form and uses this knowledge to identify the dance form in new images.

3. What Are the Key Components of a CNN for Image Classification?

 Key components include convolutional layers (for feature extraction), pooling layers (for dimensionality reduction), and fully connected layers (for classification).

4. Why are CNNs Preferred for Image Recognition Tasks?

 CNNs are preferred due to their ability to automatically and adaptively learn spatial hierarchies of features from input images, making them highly effective for image recognition.

5. How is a CNN Trained to Recognize Different Dance Forms?

 The network is trained using a large dataset of labeled images, where each image is tagged with the corresponding dance form. The CNN learns to associate specific visual patterns with each dance form.

6. What is the Role of Convolutional Layers in CNNs?

 Convolutional layers apply a convolution operation to the input, passing the result to the next layer. This helps the network in feature detection and extraction.

7. How Important is the Dataset's Size and Quality for Training a CNN?

 The size and quality of the dataset are crucial. A large, diverse, and high-quality dataset ensures the CNN learns a wide variety of features and reduces the chances of overfitting.

8. Can CNNs Handle Videos for Dance Form Identification?

 Yes, CNNs can be extended to handle video input through techniques like using 3D convolutions or combining CNNs with Recurrent Neural Networks (RNNs) to capture temporal dynamics.

9. What are the Challenges in Using CNNs for Dance Form Identification?

 Challenges include ensuring a large and diverse dataset, handling variations in lighting and background, and differentiating between similar dance forms.

10. How Does Transfer Learning Help in Training CNNs for Specific Tasks Like Dance Identification?

  Transfer learning involves using a pre-trained CNN (trained on a large dataset like ImageNet) and fine-tuning it for the specific task. This can lead to better performance, especially when the available dataset for the new task is small.

11. What Preprocessing Steps are Needed Before Training a CNN?

  Preprocessing steps might include resizing images to a uniform size, normalizing pixel values, and augmenting the dataset through techniques like rotation and flipping to increase variability.

12. How Do You Evaluate the Performance of a CNN in Dance Form Classification?

  Performance can be evaluated using metrics like accuracy, precision, recall, and the confusion matrix, which provide insights into how well the CNN is classifying each dance form.

Recommended Courses

Deep Learning Courses

Deep Learning Course

Rating: 4.5/5

Machine Learning Courses

Machine Learning

Rating: 4/5

Natural Language Processing Course

NLP Course

Rating: 5/5

Follow us:


I hope you like this post. If you have any questions ? or want me to write an article on a specific topic? then feel free to comment below.


Leave a Reply

Your email address will not be published. Required fields are marked *