# Optimized CNN-Based Recognition of District Names of Punjab State in Gurmukhi Script

Authors: Sandhya Sharma; Sheifali Gupta; Deepali Gupta; Sapna Juneja; Hamza Turabieh; Lokesh Sharma; Zelalem Kiros Bitsue
Journal: Journal of Mathematics
 (2022)

---

## Abstract

Automation of Postal systems has the major research scope in the field of automation. To create Postal Automation set-up for countries like India is a tedious task if compared with other countries because of India’s multiscript and multilingual behavior. This work will help in recognizing the “Gurmukhi” handwritten district names of the State Punjab. To recognize the district names, a CNN-based architecture is proposed by employing a Holistic approach. For this, an image database of 22000 samples is prepared having 1000 sample images for every district name which is collected from 500 different writers. Maximum accuracy on validation data achieved by the proposed Model is 99%.


---

## Body

## 1. Introduction

Artificial Intelligence (AI) is bridging the gap between the capabilities of humans and computers. One such area is Computer Vision [1]. The primary aim of this field is to make the computers behave as humans, perceive it in the same manner, and also use the knowledge for various tasks like for image recognition, image analysis, image classification, natural language processing (NLP), and so on. Similarly, Recognition of text can be done using Deep Learning which is the subset of AI. In this, automatic feature extraction and classification is done [1]. District names recognition helps in the automation of the postal system. To develop a postal automation system for the nation India is a tedious task as almost every state has its own script [2]. In this proposed work, Gurmukhi Script is considered as Government of Punjab has declared this as the official language. The address on all the official documents which are to be posted is usually written in the Gurmukhi Script only.For the recognition, a Holistic approach is used instead of Analytical approach [3]. In the Holistic approach, word for the recognition is not divided into individual characters instead a complete word is recognized whereas in Analytical approach, segmentation of word into characters is done [4]. As Gurmukhi being the cursive handwriting and characters in the word are usually written close to each other, recognition of such words using Analytical approach does not generate good recognition results.This work will help in automatically reading the district name of the State Punjab. This Script has 35 characters, 6 consonants, and 9 vowels. Its writing style is from left to right [3]. Aim of this work is to produce a system that can allow successful recognition of such handwritten words without their segmentation. In this article, the major contribution of the author is as follows:(a)
22000 images of handwritten dataset are created for the districts of the state Punjab in which 500 writers contributed(b)
Deep learning-based model is developed which can help to automate the postal system of the State Punjab(c)
Results which are obtained by the proposed model have been compared with those obtained by other state–of-the-art modelsPaper is structured as follows. In Section2, work related to the postal automation is given, in Section 3, research methodology of the work done is given. Results and Analysis are introduced in Section 4 of the manuscript, and Conclusion is given in Section 5.This manuscript has been presented as thesis in Shodhganga, a reservoir of Indian theses according to the link:https://shodhganga.inflibnet.ac.in/handle/10603/347820 which is the work of the author itself, and thesis is titled as “CNN-Based Recognition of District Names of Punjab State in Gurmukhi Script.”


## 2. Related Work

In this section, literature survey for the work done in the field of postal automation is presented. There are numerous fields which are present on the postal document like digits for address or pin code, city names, street names, and country names. Address or pin code may include numerals while word letters represent the city name, street name, or country name. Sharma et al. [5] have presented a work for the postal automation. The CNN model to recognize and detect the pin codes is introduced. Model has been implemented on 2300 handwritten English and Bangla written pin code digits. Different architectural networks are employed like Zeiler and Ferges, Visual geometry group (16), and VGG_M. Considerable results to recognize the pin codes are obtained by using VGG_M with the employment of the recurrent convolutional neural network model. Pincode box is also recognized using Zeiler and Ferges with an accuracy of 88%. 56% accuracy is obtained for the detection of pin code regions using VGG_M. 87% accuracy is obtained using VGG16 for the recognition of complete address region.To determine the 18000 handwritten city names which are written in Gurmukhi, Bansal et al. [6] have proposed a method. A dataset is collected from 60 different writers, and each writer has created 30 samples of each city name. From the total created dataset, 16200 are used to make the network model able to learn and rest to analyze the network model. Preprocessing on the collected dataset is also done like Binarization of the images, normalization, and also thinning operation. Diagonal tree extraction technique is employed on the preprocessed images so that various features can be extracted. Classifiers like K-nearest neighbor (KNN) and support vector machines (SVMs) are imposed. Highest recognition accuracy of 90.8% is obtained with the help of SVM classifier. Similarly, Thadchanamorthy et al. [7] have introduced a technique to recognize city names which are written in Tamil Script. Database having 265 Tamil handwritten city names is created first. Recognition is carried out on individual characters after the segmentation of words. Various features of the segmented characters are computed with the help of modified quadratic discriminant function (MQDF). Achieved accuracy is 96.89%. Pal et al. [8] have also developed a model to recognize the city names which are written in different scripts. To correct the slanted handwritten text, slant correction technique is employed. Next step is to segment them into characters. The model has been tested on 16132 l handwritten city names with the accuracy of 92.25%. Similarly, Pal et al. [9] have also developed a technique for the identification and classification of the handwritten city names, written in Bangla.Wen et al. [10] elaborated the method for the identification of handwritten numerals which are represented in Bangla Script. In the preprocessing step for the recognition of numerals, firstly the location of the numeral which is written on postcode is located so that it can be segmented. Features are extracted after the completion of the preprocessing step. Two different approaches are employed to recognize the Bangla numerals. In one approach, image reconstruction is carried out, and in the other approaches, feature extraction is carried out which is further combined with the principal component analysis (PCA) approach. Average accuracy obtained for the purpose of recognition is 95.6%. Nurseitov et al. [11] have also developed the two CNN model networks for identifying the handwritten names of the cities. The initial model works on CNN while the second one used the recurrent neural network (RNN). For the decoding, the connectionist temporal classification algorithm is implemented. Dataset used has 21000 images with 42 different categories of the city names which are written by 500 writers. Accuracy obtained the first model is 55.3%, and accuracy obtained by the other model is 75.1%. Sahoo et al. [12] have introduced a method to recognize the Bangla handwritten city names. A Holistic approach is used. Recognition is carried out on 50 popular city names of Bengal where each city has 150 samples. Once the features are extracted, then various classifiers like multilayer perceptron (MLP) and sequential minimal optimization (SMO) are used for the classification of images.So, in this section, an effort has been made to present the work that has been done in the field of postal automation.


## 3. Proposed Research Methodology

The methodology of the research work is presented in Figure1.Figure 1
Research methodology.Research methodology is developed to identify the district names of the Punjab State. Here, a Holistic approach is used for the purpose in which the segmentation of the words is not carried out. All the operations are employed on the whole word. The CNN model is trained and tested on Python platform using keras and Tensorflow libraries. To prepare the dataset, Adobe Photoshop is used.


### 3.1. Dataset

Firstly, the dataset is required to be collected on which the CNN model can be imposed for the purpose of recognition. As recognition is carried out on the 22 district names, 22000 Gurmukhi handwritten dataset images are created, whereas 1000 dataset image samples for every district name are created.For the creation of dataset of Gurmukhi handwritten words, the handwritten dataset samples are collected from 500 different writers which are selected on the basis of different age groups, different educational, and professional backgrounds. Sample sheets written by the writers are shown in Figure2.Figure 2
Handwritten sheets: (a) written by “Writer 1” and (b) written by“Writer 2.”
(a)(b)


### 3.2. Digitization and Preprocessing

After the collection of handwritten sheets, each sheet is digitized using the scanner which was set at the 300 dpi resolution. Scanned images obtained are shown in Figure3.Figure 3
Scanned handwritten sheets: (a) scanned image “Sample 1” and (b) scanned image “Sample 2.”
(a)(b)Next, to upgrade the quality of scanned sheets, some preprocessing techniques are employed. For the purpose of preprocessing, Adobe Photoshop has been used. For the preprocessing, Brightness, pixel intensity, and Contrast values are adjusted. Later, the words are cropped from the entire sheet. Table1 is showing a few images of the prepared dataset.Table 1
Districts names written with their corresponding prepared samples.
S. no.Districts namesSample 1Sample 2Sample 31Amritsar2Barnala3Bathinda4Faridkot5Fatehgarh6Firozpur7Fazilka8Gurdaspur9Hoshiarpur10Jalandhar11Kapurthala12Ludhiana13Mansa14Moga15Muktsar16Nawanshahr17Pathankot18Patiala19Ropar20Mohali21Sangrur22Taran taaran


### 3.3. Splitting the Dataset

Next step after the preparation of the dataset is to divide it into an 80 : 20 ratio. 200 images of each district name will be kept for the purpose of validation while some extra unseen images will be used to test the model.


### 3.4. Building the Proposed CNN Model

A CNN model is created to identify the district names. The model network will foretell the accuracy, loss, recall, and precision. The model consists of three layers: (a) “convolution,” “max-pooling,” and “flattening” layer.Layers, i.e., convolution and pooling help to preserve the important features of the given data images. The obtained features are converted into a column with the help of flattening layer so that they can be easily fed to the last layer of the model which helps to classify the output. The architecture network of the suggested CNN model is given in Figure4. This model has 12 layers, having 4 pairs of convolution and pooling layers, followed by 1 fattening layer, 2 dense layers, and 1 output layer. Filter size is 3 × 3 while the number of filters used in the different convolution layers is 32 filters in the first layer, 64 filters in the second, 128 filters in the third layer, and 256 filters are used in the last layer. All the max pooling layers have a size of 2 × 2.Figure 4
Architecture of the CNN model.


### 3.5. Training and Testing of the Network

The suggested CNN network model is now trained and tested on the developed dataset. The specifications like accuracy [13], recall, loss, and precision are calculated. Calculation is done using the discrete metrics of the confusion matrix (CM). Parameters used to simulate the model are shown in Table 2. The model performed at its best by employing the combinations of the values given in Table 2. On changing any of the values, the model’s performance either deteriorated or remained the same [14]. On further adding the number of layers in the model, the accuracy obtained remained the same but the time taken for the training of the model increased [15].Table 2
Simulation parameters.
S. no.ParameterValue1.Optimizer usedADAM2.Total layers in the model123.Number of training images176004.Number of validation images44005.Total layers of the model12.06.Batch size (BS) of the training images4.07.LR used0.0018.Steps/Epoch3000


## 3.1. Dataset

Firstly, the dataset is required to be collected on which the CNN model can be imposed for the purpose of recognition. As recognition is carried out on the 22 district names, 22000 Gurmukhi handwritten dataset images are created, whereas 1000 dataset image samples for every district name are created.For the creation of dataset of Gurmukhi handwritten words, the handwritten dataset samples are collected from 500 different writers which are selected on the basis of different age groups, different educational, and professional backgrounds. Sample sheets written by the writers are shown in Figure2.Figure 2
Handwritten sheets: (a) written by “Writer 1” and (b) written by“Writer 2.”
(a)(b)


## 3.2. Digitization and Preprocessing

After the collection of handwritten sheets, each sheet is digitized using the scanner which was set at the 300 dpi resolution. Scanned images obtained are shown in Figure3.Figure 3
Scanned handwritten sheets: (a) scanned image “Sample 1” and (b) scanned image “Sample 2.”
(a)(b)Next, to upgrade the quality of scanned sheets, some preprocessing techniques are employed. For the purpose of preprocessing, Adobe Photoshop has been used. For the preprocessing, Brightness, pixel intensity, and Contrast values are adjusted. Later, the words are cropped from the entire sheet. Table1 is showing a few images of the prepared dataset.Table 1
Districts names written with their corresponding prepared samples.
S. no.Districts namesSample 1Sample 2Sample 31Amritsar2Barnala3Bathinda4Faridkot5Fatehgarh6Firozpur7Fazilka8Gurdaspur9Hoshiarpur10Jalandhar11Kapurthala12Ludhiana13Mansa14Moga15Muktsar16Nawanshahr17Pathankot18Patiala19Ropar20Mohali21Sangrur22Taran taaran


## 3.3. Splitting the Dataset

Next step after the preparation of the dataset is to divide it into an 80 : 20 ratio. 200 images of each district name will be kept for the purpose of validation while some extra unseen images will be used to test the model.


## 3.4. Building the Proposed CNN Model

A CNN model is created to identify the district names. The model network will foretell the accuracy, loss, recall, and precision. The model consists of three layers: (a) “convolution,” “max-pooling,” and “flattening” layer.Layers, i.e., convolution and pooling help to preserve the important features of the given data images. The obtained features are converted into a column with the help of flattening layer so that they can be easily fed to the last layer of the model which helps to classify the output. The architecture network of the suggested CNN model is given in Figure4. This model has 12 layers, having 4 pairs of convolution and pooling layers, followed by 1 fattening layer, 2 dense layers, and 1 output layer. Filter size is 3 × 3 while the number of filters used in the different convolution layers is 32 filters in the first layer, 64 filters in the second, 128 filters in the third layer, and 256 filters are used in the last layer. All the max pooling layers have a size of 2 × 2.Figure 4
Architecture of the CNN model.


## 3.5. Training and Testing of the Network

The suggested CNN network model is now trained and tested on the developed dataset. The specifications like accuracy [13], recall, loss, and precision are calculated. Calculation is done using the discrete metrics of the confusion matrix (CM). Parameters used to simulate the model are shown in Table 2. The model performed at its best by employing the combinations of the values given in Table 2. On changing any of the values, the model’s performance either deteriorated or remained the same [14]. On further adding the number of layers in the model, the accuracy obtained remained the same but the time taken for the training of the model increased [15].Table 2
Simulation parameters.
S. no.ParameterValue1.Optimizer usedADAM2.Total layers in the model123.Number of training images176004.Number of validation images44005.Total layers of the model12.06.Batch size (BS) of the training images4.07.LR used0.0018.Steps/Epoch3000


## 4. Results and Analysis

In this part, various results are obtained on the training as well as the validation dataset. Results are seen in Table3. Value obtained for the minimum training loss is 0.05 which is obtained on the 45th Epoch. On the validation dataset, loss obtained is 0.08, accuracy is 99.0%, and recall and precision obtained are 0.99 on the last epoch. From the proposed model, the highest obtained validation accuracy is 99%.Table 3
Results obtained with the proposed CNN model.
EpochTraining lossValidation lossValidation accuracy (%)Validation recallValidation precision12.620.8777.00.650.8821.171.0474.00.680.8430.782.3460.00.560.6840.570.6889.00.800.8450.430.1895.00.950.96120.170.3797.00.970.97130.170.1497.00.980.98320.070.1998.00.980.98330.060.1098.00.980.98340.070.1098.00.980.98350.060.1498.00.980.98360.060.0898.00.980.98370.070.1598.00.980.98410.060.4097.00.970.97420.050.0898.00.980.98430.060.3598.00.980.98440.050.0898.00.980.99450.050.0899.00.990.99Average values0.200.2995.60.950.96Figure5 presents the plot curve of the values which are attained in Table 3. Figure 5(a) shows that the maximum validation loss of 2.3 is obtained on the 3rd epoch. From the 4th epoch onwards, the loss curve for the validation dataset is almost reducing with fluctuations while the curve of training loss is linearly reducing. In Figure 5(b), for validation accuracy, the accuracy is lowest on the 3rd epoch but from the 4th epoch onwards it is also increasing while the curve for the training loss is a linearly changing its value. Plots for the validation dataset using recall and precision parameters are shown in Figures 5(c) and 5(d). Curve for the training dataset is approximating close to 0.99.Figure 5
Plot curve obtained for the training and validation dataset using ADAM optimizer with a LR of 0.001 and 45 Epochs, (a) loss, (b) accuracy, (c) recall, and (d) precision.
(a)(b)(c)(d)Precision value, F1 score value, and recall value are also computed for each of the district name as shown in Figures6–8. Figure 6 shows that the implemented model is 100% précised for the recognition of the given districts. Bathinda, Amritsar, Fazilka, Jalandhar, Hoshiarpur, Gurdaspur, Mohali, Sangrur, Nawanshahr, and Ropar as the precision value have reached 1 while lowest value of 0.96 is achieved for the districts: “Fathegarh Sahib.” In Figure 7, value for recall is 1 or 100% for “Amritsar,” “Bathinda,” “Barnala,” “Fathegarh Sahib,” “Mansa,” and “Hoshiarpur” and the minimum value is obtained by the district “Kapurthala.” Figure 8 shows the F1-score; 100% value is obtained for the districts “Amritsar,” “Bathinda,” “Faridkot,” “Mohali,” and so on, and the lowest score is obtained for the district “Kapurthala.”Figure 6
Precision for each district.Figure 7
Recall for each district.Figure 8
F1-score for each district.CM for the proposed CNN model is given in Figure9. As it is already mentioned, 80% of the images from each of the district names are kept for the purpose of training and 20% are kept for the purpose of testing. It means 800 images of each district are used to train and the remaining 200 to test the model. Figure 9 shows that the model has correctly speculated all districts: “Amritsar,” “Faridkot,” “Bathinda,” and “Fazilka.”Figure 9
Confusion matrix.


### 4.1. Testing of Images

Here, testing the few images from the prepared dataset is done using the proposed model, and results are presented in Figure10. In Figure 10(a), district name “Sangrur” is 85% correctly tested.Figure 10
Testing of few dataset images: (a) Sangrur; (b) Amritsar; (c) Moga.
(a)(b)(c)Similarly, the district name “Amritsar” is 100% correctly predicted, and it is predicted 28% as “Muktsar” also in Figure10(b). So, it can be declared as district name “Amritsar.” Figure 10(c) shows that the district name “Moga” is 99.9% predicted correctly.


### 4.2. Comparative Analysis with Available Models

Table4 shows the comparison of the proposed work with the previous available approaches. Table 4 represents accuracy parameter results obtained using various scripts.Table 4
Comparison of the work with state-of-the-art techniques.
Ref no./yearWorked onScriptTechnique usedAccuracy obtained (%)Reference [16], 2021City namesBanglaCNN98.86Reference [11], 2019City and country namesRussian and KazzakCNN55.3Reference [17], 2017District namesMalayalamNNSVMRandom forest94.599787.83Reference [8], 2012City namesEnglish, Hindi, and BanglaManual feature extraction and dynamic programming92.5Reference [7], 2013City namesTamilManual feature extraction and modified quadratic discriminant function96.89Reference [18], 2009City namesBanglaManual feature extraction followed by hidden Markov model86.44Reference [19], 2021UNHD handwritten wordsUrduResnet1886Reference [20], 2021Handwritten wordsManipuriCNN98.70Reference [21], 2016Handwritten wordsBengaliCNN combined with a recurrent model86.96Reference [22], 2012UNIPEN handwritten databaseEnglishCNN92.20Reference [23], 2019Handwritten wordsBanglaFeature extraction: elliptical, vertical, and tetragonal pixel density histogramClassification: MLP and SVM83.64Proposed workDistrict namesGurmukhiCNN99


## 4.1. Testing of Images

Here, testing the few images from the prepared dataset is done using the proposed model, and results are presented in Figure10. In Figure 10(a), district name “Sangrur” is 85% correctly tested.Figure 10
Testing of few dataset images: (a) Sangrur; (b) Amritsar; (c) Moga.
(a)(b)(c)Similarly, the district name “Amritsar” is 100% correctly predicted, and it is predicted 28% as “Muktsar” also in Figure10(b). So, it can be declared as district name “Amritsar.” Figure 10(c) shows that the district name “Moga” is 99.9% predicted correctly.


## 4.2. Comparative Analysis with Available Models

Table4 shows the comparison of the proposed work with the previous available approaches. Table 4 represents accuracy parameter results obtained using various scripts.Table 4
Comparison of the work with state-of-the-art techniques.
Ref no./yearWorked onScriptTechnique usedAccuracy obtained (%)Reference [16], 2021City namesBanglaCNN98.86Reference [11], 2019City and country namesRussian and KazzakCNN55.3Reference [17], 2017District namesMalayalamNNSVMRandom forest94.599787.83Reference [8], 2012City namesEnglish, Hindi, and BanglaManual feature extraction and dynamic programming92.5Reference [7], 2013City namesTamilManual feature extraction and modified quadratic discriminant function96.89Reference [18], 2009City namesBanglaManual feature extraction followed by hidden Markov model86.44Reference [19], 2021UNHD handwritten wordsUrduResnet1886Reference [20], 2021Handwritten wordsManipuriCNN98.70Reference [21], 2016Handwritten wordsBengaliCNN combined with a recurrent model86.96Reference [22], 2012UNIPEN handwritten databaseEnglishCNN92.20Reference [23], 2019Handwritten wordsBanglaFeature extraction: elliptical, vertical, and tetragonal pixel density histogramClassification: MLP and SVM83.64Proposed workDistrict namesGurmukhiCNN99


## 5. Conclusion

In this paper, a CNN model is developed to recognize the 22 district names of Punjab. So, a dataset has been generated by different writers for the recognition which are handwritten in Gurmukhi Script. Recognition of Punjab’s district names is an application area of postal automation, which will help in the automatic sorting of mails at the post office. This work is also helpful to recognize the handwritten Gurmukhi words without dividing them into individual characters as well as this model has also eliminated the need of manual feature extraction which are required to train the model. The implemented CNN model has obtained a validation accuracy of 99.0% and the average validation accuracy of 95.6%. In this model, an “Adam” is used with a LR of “0.001.” The number of layers is 12 while the number of epochs used is 45. A thesis has previously been published for the proposed model (link for the same is already given). It has been observed that on further increasing the number of epochs and number of layers, accuracy remained the same. So, this model has provided the reasonably good accuracy for the recognition of Gurmukhi handwritten text.



---

*Source: 6580839-2022-05-28.xml*