Rajat Sahay

Mickaël Coustaty
email: mickael.coustaty@univ-lr.fr

An Enhanced Prototypical Network Architecture for Few-Shot Handwritten Urdu Character Recognition

Few shot models have started to gain a lot of popularity in the past few years. This is mostly because these models grant the ability to structure the representation space (classes) using a very less amount of examples for each class. Such models are usually trained on a wide range of different classes and their examples, which allows them to form and learn a decision-based metric in the process. Non-Latin languages, especially languages such as Urdu, have a bi-linear direction of writing and are context-sensitive in nature, and are hard to recognize. Also, unlike traditional English, there is a very small amount of clean, collated, and usable data that is available for the Urdu language. In this paper, we explore a prototypical network for k-shot classification on handwritten Urdu characters. The prototypical network learns the Euclidean embeddings of the provided images and uses clusters to classify newer examples. Our improved method is able to outperform other methods of few-shot learning and is able to accurately classify both Urdu characters as well as numerals using a minimal number of examples. After comprehensive qualitative and quantitative evaluation and comparison of our proposed approach with other methods to classify handwritten text in fewshot settings, we found out that our proposed approach was typically able to beat other methods by a margin of 1% -2% while relying on a small training set.

I. INTRODUCTION

Urdu is the national language of Pakistan. It is widely spoken and understood as a second language by a majority of people of Pakistan [START_REF] Rahman | Language and Politics in Pakistan by Tariq Rahman[END_REF], and Urdu handwriting is used for official assignments and communications in all the organizations. Urdu has also been observed to be spoken in other regions of South-East Asia, including India, Bangladesh, Afghanistan etc. Previous works [START_REF] Jan | Online Urdu handwriting recognition system using geometric invariant features[END_REF], [START_REF] Khan | An analysis of off-line and online approaches in Urdu character recognition[END_REF], [START_REF] Sagheer | Holistic Urdu handwritten word recognition using support vector machine[END_REF] have shown that there is a sizeable gap in the amount of data that has been accumulated for Urdu when compared to the data that has been accumulated for the recognition of Latin-based languages (English, German etc).

Although fields like OCR have witnessed a significant improvement with advancements in vision technology, due

The associate editor coordinating the review of this manuscript and approving it for publication was Donato Impedovo . to reasons mentioned above combined with the complexity of typesetting non-Latin languages, the OCR for Urdu is still in its initial stages of infancy [START_REF] Akram | Ligature-based font size independent OCR for Noori Nastalique writing style[END_REF], [START_REF] Wali | Context sensitive shape-substitution in Nastaliq writing system: Analysis and formulation[END_REF]. The problems affecting OCR are compounded often due to incorrect acquisition and segmentation processes during the annotation and recognition processes. The main motivation of this work is to imitate human reading ability, with human accuracy and a higher speed, even for data-sparse languages like Urdu.

Deep Learning has been gaining popularity in the past decade, and the continuous research conducted has only advanced the speed of progress. However, most of the deep learning methods that are developed are usually observed to perform better in settings with abundance of data. The field of computer vision and pattern recognition are no different and suffer from the same problem. Most methods proposed in this field usually rely on being iteratively trained with lots of data in a supervised manner. The problem of handwritten text recognition has been one of the oldest and most widely explored problems in this field [START_REF] Beigi | An overview of handwriting recognition[END_REF]. However, in some cases, like the one this paper explores, the previously proposed solutions to these problems are somewhat ineffective because they are unable to adapt to new or unseen data quickly.

Since there is a shortage of the amount of handwritten data accumulated for the recognition of Urdu characters, this paper proposes a few-shot learning based system that is able to recognize individual Urdu characters and digits from an extremely limited amount of given examples. We test our improved prototypical network based approach against other methods and are able to achieve better accuracy and outperform other methods. We note an average accuracy of 92% on characters in a 5-way-5-shot setting over multiple datasets, while showing an average classification accuracy of 90% for classifying numerals in a 5-way-5-shot settings. To assess relevance and generalization capabilities of our proposed approach, we tested our solution on two different datasets. These datasets are the one created by Husnain et al. [START_REF] Husnain | Urdu handwritten text recognition: A survey[END_REF], and the UHaT dataset [START_REF] Ali | Pioneer dataset and automatic recognition of Urdu handwritten characters using a deep autoencoder and convolutional neural network[END_REF]. We show in Table 1 and Table 2 that our proposed method was able to consistently outperform previous few-shot solutions for recognition tasks. The next section presents the related works (section II), our proposed approach (section III) and its evaluation (section IV).

II. RELATED WORKS A. URDU HANDWRITTEN CHARACTER RECOGNITION

Recognizing handwritten text at the character level has been one of the first and foremost tasks that researchers have hoped to tackle using computer vision methods [START_REF] Beigi | An overview of handwriting recognition[END_REF]. Recognition of handwritten characters was first put to use to recognize handwritten, and machine-printed text for the interpretation of postal addresses [START_REF] Srihari | Recognition of handwritten and machine-printed text for postal address interpretation[END_REF]. This is extraordinarily challenging since handwritten characters present large amounts of variations, even when written by the same person. Postal addresses, on the other hand, were written by many different people, each presenting a different style of writing. Previous studies and research [START_REF] Singh | Handwriting change as a psychiatric symptom[END_REF] show that the handwriting of an individual is a direct consequence of various different factors, which include but are not limited to age, current mood, and immediate surroundings.

In the past few years, there have been sizeable developments in the field of handwritten character recognition [START_REF] Liu | Handwritten character recognition using gradient feature and quadratic classifier with multiple discrimination schemes[END_REF], [START_REF] Pal | Handwritten English character recognition using neural network[END_REF]. However, most of the research in this field deals with the recognition of the 26 alphabets and 10 digits of the Latin languages. Urdu is one of the most commonly used languages in countries from South Asia (like Pakistan and Afghanistan). Urdu is written right-to left in an extension of the Persian alphabet, which is itself an extension of the Arabic alphabet. Urdu is associated with the Nasta īq style of Persian calligraphy, which is notoriously difficult to typeset (and then commonly handwritten). This difficulty leads to the non-availability of properly collated and annotated data, which is the primary reason for such less research in handwritten Urdu character recognition. Similar challenges also exist for typesetting Persian and Arabic characters, which has prompted an increase in similar research in innovative ways for character recognition for these languages as well [START_REF] Hamdi | ASAR 2021 competition on online Arabic character recognition: ACRC[END_REF], [START_REF] Shabir | Real-time Pashto handwritten character recognition using salient geometric and spectral features[END_REF], [START_REF] Uddin | Benchmark Pashto handwritten character dataset and Pashto object character recognition (OCR) using deep neural network with rule activation function[END_REF]. This paper specifically focuses on the recognition of handwritten characters in the Urdu language. While the literature on generic handwritten text recognition is available, non-Latin languages like Urdu have inhibited research due to the lack of availability of data. Moreover, issues like context-sensitivity and non-standard shapes of characters make it a harder task compared to simple handwritten text recognition.

Many previous research works in the handwritten recognition field show the use of Artificial Neural Networks (ANNs) [START_REF] Van Gerven | Artificial neural networks as models of neural information processing[END_REF]. The problem with the development of a generic character recognition system is that it cannot be generalized to support all types of languages due to many variations between Latin and Asian languages. The first distinguishing feature of the Urdu script is that it is written and read from right-to-left, unlike traditional Latin languages. To overcome the problem of non-generalization of different languages, a novel approach was proposed [4] which mapped the character set of any language to a feature space representing them by using geometrical strokes that formed the characters. This allowed the ANN to be trained only once. It was able to achieve a success rate of approximately 75%-80%.

One other way in which Urdu differs from English and other traditional Latin languages is its intrinsic variability. Urdu script is written from right-to-left, while the numerals are written from left-to-right. This is why Urdu is considered as a bidirectional language. It consists of 38 alphabets and 10 numerals as displayed in Figure 1. Due to a large character set, and considering the fact that the Urdu script is context-sensitive, which means that the characters have different shapes and sizes based on their position in the word, the recognition of Urdu characters becomes increasingly difficult in contrast to English. Also, there are a lot of characters in Urdu that, in visual terms, look quite similar to each other. Keeping this in mind, authors of [START_REF] Haider | Online recognition of single stroke handwritten Urdu characters[END_REF] grouped the Urdu characters on the basis of the number of strokes it took to construct the character. The novel features from each group were extracted and given as input to classifiers with different neural architectures. These included a Probabilistic Neural Network (PNN) and a Backpropogation-based Neural Network (BNN). The result showed that the PNN was able to outperform other classifiers. Based on experiments done in the paper, the PNN was able to outperform other classifier architectures by a margin of 6%. Previous studies done for lone character recognition [START_REF] Shahzad | Urdu Qaeda: Recognition system for isolated Urdu characters[END_REF] were able to sufficiently recognize handwritten Urdu characters using a feature vector that it built by the analysis of the strokes that were used to construct the character. There have been more recent works that tackle the problem of Urdu Character Recognition. For instance, Ahmed et al. [START_REF] Ahmed | Handwritten Urdu character recognition using one-dimensional BLSTM classifier[END_REF] presented the offline-UNHD dataset for Urdu characters. Experiments were performed using a 1-dimensional Bi-Directional LSTM to classify individual character labels. Other works such as [START_REF] Riaz | Conv-transformer architecture for unconstrained off-line Urdu handwriting recognition[END_REF] VOLUME 11, 2023 FIGURE 1. Urdu character set with phonemes and Urdu numerals with their corresponding Roman equivalences (from [START_REF] Husnain | Urdu handwritten text recognition: A survey[END_REF]).

use Transformer architectures with a CNN backbone for unconstrained character classification.

The large variability of Urdu characters and numerals representation is a challenge for deep-learning models as they need a large set of annotated data to learn their representation. To the best of our knowledge, only two public properly collated datasets could be used to train a model with a limited number of samples per class. The dataset used by Husnain et al. [START_REF] Husnain | Urdu handwritten text recognition: A survey[END_REF] proposed around 500 samples per class, while the Urdu Handwritten Text (UHaT) [START_REF] Ali | Pioneer dataset and automatic recognition of Urdu handwritten characters using a deep autoencoder and convolutional neural network[END_REF] dataset proposes around 700 samples per class. The lack of properly structured and annotated data has always been a major hindrance for these types of tasks. Most recent methods [START_REF] Ahmed | Handwritten Urdu character recognition using one-dimensional BLSTM classifier[END_REF], [START_REF] Naseer | Meta-feature based few-shot Siamese learning for Urdu optical character recognition[END_REF], [START_REF] Riaz | Conv-transformer architecture for unconstrained off-line Urdu handwriting recognition[END_REF] that involve the use of data-intensive and hungry architectures like LSTMs and Transformers usually are unable to perform when provided with sparse datasets. With continually changing styles and patterns, the Urdu language provides just that in the real world. In order to tackle the large variability of Urdu language and to learn from a limited number of examples with supervised information, some new machine learning paradigm, called Few-Shot Learning, have been proposed in the middle on 2000's and widely studied since that time [START_REF] Wang | Generalizing from a few examples: A survey on few-shot learning[END_REF]. We propose to study them in our context.

B. FEW SHOT LEARNING

Deep learning methods have been observed to perform extremely well in settings and environments where there is an abundance of data available. Most conventional neural network architectures are designed in such a way that the influence of a particular example within the training set would be extremely small in terms of bringing about a change in the final results. These networks are designed to capture and learn the general features that are displayed throughout the dataset [START_REF] Santoro | One-shot learning with memory-augmented neural networks[END_REF], which usually has a varied amount of examples.

There are however some areas that require fast adaption to new kinds of data, with a minimal number of given examples. The concept of one-shot, few-shot or k-shot learning is motivated by the general idea of how humans are able to learn a new class of objects with just a few given examples. These types of learning methods require the network to classify unseen classes of data using single, a few and k examples respectively.

The first working example of a model using a few-shot learning based approach was given by Vinyals et al. [START_REF] Vinyals | Matching networks for one shot learning[END_REF] in the form of Matching Networks. The training for this type of network was performed on sets of support examples for a subset of possible classes, and a query example belonging to one of the classes. Each training step was the combination of training the network on support classes and query classes and was referred to as an episode. These episodes were generated for a wide range of classes. The number of support examples would be varied based on the type of learning that the network was used to achieve. Each episode was used to essentially mimic the task of classifying data into classes with a minimal amount of examples by subsampling the number of classes as well as the data points in each of them. It has been demonstrated that this approach helped improve the overall performance and made the entire training problem more faithful to the testing environment. It also enabled the network to better generalize results to unseen examples. It would be given k examples for k-shot learning and a single example for one-shot learning. Reference [START_REF] Ravi | Optimization as a model for few-shot learning[END_REF] was able to take the idea of training a network with episodes a step ahead and combined it with an LSTM [START_REF] Hochreiter | Long short-term memory[END_REF]. The authors proposed an approach that could be considered as a meta-learning approach to few-shot learning.

Non-parametric models, like k-nearest neighbours (kNN) can also be considered as an ideal candidate for few-shot classification. This is because they allow inclusion of previously unseen classes. They use distance in the space of inputs as a metric to define class boundaries, which prevents a high accuracy during classification. However, it has been seen that combinations of parametric and non-parametric methods have yielded the best results [START_REF] Koch | Siamese neural networks for one-shot image recognition[END_REF], [START_REF] Snell | Prototypical networks for few-shot learning[END_REF].

In this paper, we explore Prototypical Networks, which do not suffer from severe overfitting and according to our knowledge are able to achieve state of the art performance on the Omnilogot dataset [START_REF] Snell | Prototypical networks for few-shot learning[END_REF]. Furthermore, with the scarcity of annotated data for Urdu characters, we found that these networks consistently outperformed other few-shot learning approaches.

We were also able to improve the performance of a vanilla Prototypical Network on both the datasets of Urdu characters and numerals by adding modules for regularizing individual weights given to initial prototypes and balancing the distances between the clusters that are formed in the embedding vector space.

C. PROTOTYPICAL NETWORKS

Prototypical Networks were introduced by Snell et al. [START_REF] Snell | Prototypical networks for few-shot learning[END_REF] for both few-shot as well as zero-shot settings. The authors of the paper drew connections to Matching Networks [START_REF] Vinyals | Matching networks for one shot learning[END_REF], which were used in one-shot learning problems, and built upon the underlying distance function. They related Prototypical Networks to clustering in order to justify the use of class means as prototypes when the distances are computed with a Bregman divergence, such as Squared Euclidian Distance.

The objective of a Prototypical Network is to learn the metric on the embedding space which is a representation of the similarity in the form of a distance metric (which, previous research [START_REF] Koch | Siamese neural networks for one-shot image recognition[END_REF], [START_REF] Vinyals | Matching networks for one shot learning[END_REF] has shown can be L2 distance or cosine distance). This method is easily able to adapt to general k-shot by using the mean of the k samples as the center of the cluster. They do not classify the image directly, but learn the mapping of an image in metric space. The encoder of the network maps the images belonging to the same class close to each other, while images that belong to entirely different classes are placed apart from each other by a considerable distance. Whenever a new example is given, the network confirms the nearest cluster to the encoding of the image in the metric space, and classifies the image accordingly.

They differ from Matching Networks as the latter produces a weighted nearest neighbour given the support set while the former uses squared Euclidian Distance to give a linear classifier as the output. In the case of a one-shot setting, where there is only one data-point available per class, both networks become equivalent. Vinyals et al. [START_REF] Vinyals | Matching networks for one shot learning[END_REF] and Ravi and Larochelle [START_REF] Ravi | Optimization as a model for few-shot learning[END_REF] both used the cosine distance as a metric to compute distance. However, the authors of [START_REF] Snell | Prototypical networks for few-shot learning[END_REF] found that the squared Euclidian distance was better and improved results for both Prototypical as well as Matching Networks. Based on this study, we propose in the next of this paper, to develop our proposed approach using a prototypical network for Urdu handwritten recognition.

III. PROPOSED APPROACH

The approach that we followed was majorly derived from classical recognition problems in pattern recognition. We first preprocessed the images in the dataset to remove any unnecessary noise, resize them to a standard size, keeping the aspect ratio fixed. We also rotated them in multiples of 90 degrees to generate more classes. These images were then passed through a self-supervised encoder to obtain a generic representation of the features of the images. Finally, we use an improved Prototypical Network model (described in Sections 3.3, 3.4 and 3.5) to structure the representation space which we used to classify unseen data with a minimal number of examples.

Figure 3 gives a allegorical overview on the step-by-step process taken by our approach to classify handwritten Urdu text.

A. PREPROCESSING

As in all pattern recognition processes, data need to be cleaned to remove noises and irrelevant features. To this end, the images of the dataset are sent through basic preprocessing steps to prepare the individual images to be encoded. First, the images are processed to remove noise using methods that were used in noteworthy work conducted by Bieniecki et al. [START_REF] Bieniecki | Image preprocessing for improving OCR accuracy[END_REF]. All the images are grayscaled and resized to 28 × 28 pixels (if there were any images that were not of this size) while keeping the aspect ratio fixed at all times. We also (similar to the authors of [START_REF] Snell | Prototypical networks for few-shot learning[END_REF]) rotated the images by angles of 90 • , 180 • and 270 • in order to augment the variability of images and gain in genericity. This last step was also done keeping in mind real-world uses of Urdu OCR applications. By using data augmentation, our model would be able to make more robust predictions when given 'dirty' examples, which are usually Urdu characters captured in different orientations. For our model to be deployed in practical scenarios, we deem it equally necessary that the confidence of our predictions our not altered by simply a change of the orientation of a provided character.

B. ENCODER

Once data are cleaned, we propose to encode the given input images so that they can be mapped across a metric space for later classification. For this second step, we use a multilayer convolutional neural network as an encoder network to convert the given image into a 64 dimensional point in the metric space. For practical purposes, we used 5 convolutional blocks. Each block consists of a two-dimensional, 3 × 3 convolutional layer, followed by batch normalization and a ReLU activation function [START_REF] Agarap | Deep learning using rectified linear units (ReLU)[END_REF]. This is followed by a 2 × 2 Max-Pooling layer. After the 5 blocks, the final result is returned as the flattened form of the output. When applied to the 28 × 28 sized images, it leads to a 64-dimensional output embedding. A schematic overview of this encoder is proposed in figure 4.

For a vanilla prototypical network, the encoder can be defined as a function

encoder(W ) : I ∈ R H * W * C → -→ x ∈ R V (1)
where, I is the input image provided to the encoder, -→ x is the embedded vector, H is the height of the image, W is the width of the image and C is the number of channels. V is the embedding dimension of the vector space.

The encoder network that we proposed was taken from the original paper which explored Prototypical Networks [START_REF] Snell | Prototypical networks for few-shot learning[END_REF]. We explored other architectures for an encoder network by changing the architecture of the CNN, but we found that the original network outperformed the others. We used the same encoding network for embedding both the support as well as the query points.

For the loss function of the encoder, we decided to use the Negative Log Likelihood [START_REF] Zhu | Negative log likelihood ratio loss for deep neural network classification[END_REF] loss function, because it is robust enough for the encoder to learn representations efficiently.

C. k-SHOT LEARNING USING PROTOTYPICAL NETWORK

The last step or our architecture is related to the representation space structuring. Few-shot learning environment are usually provided with a set of labelled examples, known as the support set (S). Let K be the set of classes (in our case, the set of all possible Urdu characters), the support set would have N image-label pairs in it, as S = {x i , y j }|(1 <= i <= N , 1 <= j <= K ), where each x corresponds to the vector obtained in the encoding step and each y belongs to the target space (ranging in 1, . . . K ). The x belongs to the V -dimensional vector space (R V ) and S k denotes the set of examples labelled with k th class.

We used the original implementation of a Prototypical Network (pictorially denoted in Figure 2) with some added modules to obtain an M -dimensional vector space R M allowing to represent each class(denoted (c k )).Since the encoder reduces the original images into an R V space, we map these encodings to an R M space to reduce linearity and avoid sparsity in the embeddings that are going to be passed into the prototypical architecture. This is achieved through a function f τ with learnable parameters τ . The function f τ maps from the feature vector space R V to the M -dimensional vector space, R M . Each representation (c k ) is the value of the mean of all vectors of the embedded points in class k. It can be defined as:

c k = 1 | S k | x i ,y i f τ (x i ) (2)
The aim of our prototypical network is to train a classifier, i.e. set the centroids of classes. This classifier is then able to generalize to new and previously unseen classes (query set) that were previously unavailable during the training. It also required an extremely small number of examples of each of the new classes (the support set). We randomly selected C classes from the input data. From each class, we chose a support set and a query set. We passed all the images from the class through the encoder model, and computed, which gave us their features in the R V feature vector space. We then mapped these features to the M -dimensional vector space (R M ) to obtain the centroid for each class' embeddings. For each class C, its centroid was defined as C n , where n ranged from 1 to k and would be further used to classify test queries.

To classify test queries, we needed to determine their geometric position in the embedding vector space. We accomplished this by passing the query images through an encoding model, which mapped them to their position in an M -dimensional space. For each image in the query set (Q), its position in the embedding space was represented as Q λ , where λ varied from 1 to j. To classify the image, we calculated the distance between each point of the query image in the M -dimensional space and the centroids of each class, (C 1 , C 2 , . . . , C k ). This resulted in a matrix in which the distance of the point corresponding to the j th query image from the center of the k th class was represented by the index jk.

We used a simple argmin [START_REF] Gould | On differentiating parameterized argmin and argmax problems with application to bi-level optimization[END_REF] function to calculate the distance between a query image and the centroid point of a class to predict which class would the image be classified into. We then compared the predicted class (predicted value) and the actual class (ground truth) to calculate loss and backpropogate the difference in error. To further improve the performance of the prototypical networks on the character and numeral dataset, we proposed two additional modules to be added to the original network. These were the Weight Distribution module, which gave weights to the initial class prototypes based on their amount of representativeness of the class; and the Distance Scaling module, which was able to regulate inter-and intra-class distances between the prototypes in the embedding space. While concepts similar to the Weight Distribution module have been studied in the context of Prototypical Networks before [START_REF] Snell | Prototypical networks for few-shot learning[END_REF], we increment this approach by using an attention-based order to get representative prototypes of different classes. We describe our proposed approach in more detail in Section III-D.

D. WEIGHT DISTRIBUTION IN PROTOTYPICAL NETWORKS

One of the modules that was incorporated in the original implementation of the Prototypical Networks was the Weight Distribution module. In the original implementation of Prototypical Networks, all samples from the same class were treated equally, and were given the same weightage during the classification process. However, different characters may carry a different amount of the representativeness of the particular class that they belong to.

Taking this into consideration, we put forward an attentionbased strategy to get weighted prototypes of different classes. This weighted prototype is obtained based on the image features of a provided sample set of images. The module consists mainly of a 3-layered network which projects the input vector to the weight space.

The following equation gives a succinct mathematical representation of the formation of the weighted instance prototypes

W n = E(κ(X 1 (J n1 , . . . , J nk )) (3)
Here, W n is the weight vector for the n th class in the sample set. This input provided to this module is the collective visual feature that groups instances of the same class one after the other. The module outputs a single weight instance vector that is perceptive of the representativeness to the class.

X n = x x=1 W nx * encoder(J nx ) (4)
X in the above equation is the operator responsible for connecting the instance features from the same class. ξ represents the encoder that was defined previously.

E. DISTANCE SCALING

The second contribution is one that appears as another module, and aims at improving the performance of the existing vanilla Prototypical Network along with the Distance VOLUME 11, 2023 Scaling module. To complement the self-supervised encoder and the Weight Distribution module, we propose a strategy to create a further disparity between clustered classes in the embedding space. This is achieved by maximizing the difference between classes while minimizing the distance between instances of the same class. We scale the distances with different coefficients, which are a direct product of the class-wise cross-entropy. The objective function chosen to define the distance between two instances within the same class can be written as

L υ = n i=1 log   c j=1 exp(-F θ (J (x i ), c j ))   (5)
Here, L υ is the overall loss that is achieved after training the enhanced prototypical network pipeline after one episode, and x i is an instance belonging to the i th class. F is the Euclidean function that is measured as a standard metric to compute the distance in the objective function. In a similar way, the objective function that defines the inter-class distance can be formulated as

L ψ = -F θ (J (x i ), c (i+1) ) (6)
We scale both L υ and L ψ with different coefficients to respectively maximize and minimize them. We can hypothesize the coefficients α and β and the final equation can be formulated as

L = α(L υ ) + β(L ψ ) (7)
While the above is the theoretical hypothesis of distance scaling, we consider a three-layer network to integrate this module with the larger pipeline. The feature maps generated from the instances of the query set are appended with the instances from the support set, which are finally provided to the network as the input vector. The scaling coefficient for the i th class can be calculated as

ε = K k=1 p κ (A x 1 ,x 2 (F θ (x nk ), F θ (x i )) ( 8
)
where p is the input vector and A x 1 ,x 2 (•, •) defines the append operation.

F. POST-PROCESSING

Complementing the distance scaling module, in order to achieve better accuracy on all characters of the dataset, we also had to post-process our results. This was necessary in order to account for the diacritics that the characters in the Urdu language contain. We explain this problem and our process in more detail in this section. Each character in the Urdu language is comprised of two ligatures: the primary and secondary ligatures. In some cases, the secondary ligature may not exist. Different Urdu characters join with each other and form different ligatures based on joiner rules [START_REF] Osman | An efficient languageindependent multi-font OCR for Arabic script[END_REF]. These ligatures often take the form of diacritics like dots or dashes that are appended somewhere with the character. We use a connected component labelling process similar to [START_REF] Vishwanath | Connected component analysis for Indian license plate infra-red and color image character segmentation[END_REF] in order to separate secondary ligatures from primary. To further segment the actual images, we use a simple thresholding segmentation process to look at each ligature's contour boundary. We calculate the height of each ligature and store it in an independently accessible list. Based on experiments, we classify any ligature with a height less than 30% of the largest height of all ligatures to be a secondary ligature.

These secondary ligatures are stored separately in a list and are marked during the entire training process. When the training procedure invokes the distance scaling module, we allot specific weights to different ligatures based on the joiner rules [START_REF] Osman | An efficient languageindependent multi-font OCR for Arabic script[END_REF]. These weights allow the model to separate similar characters with only a discriminating diacritic, which helps in improving the per-class classification accuracy and the subsequent overall accuracy.

IV. EVALUATION PROTOCOL AND RESULTS

To assess the accuracy and validate that our method is correctly classifying the characters and numerals and giving a high accuracy at the same time, we applied a number of qualitative and quantitative methods to give a comprehensive overview of how our network is performing. As described above, we used two different datasets to test out our proposed approach.

A. EVALUATION PROTOCOL

This subsection deals with the method we used to estimate the accuracy of our proposed model and other models used for the comparison. A support set and query set are selected from each class. The feature vector of the images in the support set and the query set in the embedding space can be defined as the support points and query points. We classify the whole query set of every class (query points named N Q ) for all support points N S=k in the range k ∈ [1, . . . 5]. The number of query points for every instance of k could be determined as N Q = 20 -N S , as we randomly sample 20 images from each class. The accuracies for all of these are aggregated, and the k-shot classification accuracy for the model can be determined as a function of k. We evaluate our models for 5-shot and 1-shot test classification.

B. DATASETS

In order to assess the relevance of our proposed approach, we tested our results on two comprehensive datasets with individually separated Urdu characters. These two datasets are the Urdu Handwritten Text Dataset (UHaT) [START_REF] Ali | Pioneer dataset and automatic recognition of Urdu handwritten characters using a deep autoencoder and convolutional neural network[END_REF], and the one used by Husnain et al. in [START_REF] Husnain | Urdu handwritten text recognition: A survey[END_REF] (where they used a CNN to classify individual Urdu characters). They were chosen as they correspond to the most relevant and the most recent datasets related to our task. Some recent works [START_REF] Ahmed | Handwritten Urdu character recognition using one-dimensional BLSTM classifier[END_REF], [START_REF] Naseer | Meta-feature based few-shot Siamese learning for Urdu optical character recognition[END_REF] have been proposed in the literature and allow us to propose a fair comparison of our results.

The UHaT dataset [START_REF] Ali | Pioneer dataset and automatic recognition of Urdu handwritten characters using a deep autoencoder and convolutional neural network[END_REF] contains samples from more than 900 individuals who wrote characters and digits of the Urdu language. The training set for each character contains 700 images on average. The number of images in each of the set of characters is uneven. For example: the class alif contains 697 images and ayn contains 811 images. Similarly, the training set for digits has 140 images on average. Since we are conducting the research in a few-shot environment, we randomly sampled 40 images from each class and used it as a training set; and 10 images as testing. Each of the testing images are 28 × 28 in size.

The other dataset we used for the experiment was collated by Husnain et al. [START_REF] Husnain | Urdu handwritten text recognition: A survey[END_REF]. In their paper, the authors classified Urdu characters and digits using convolutional neural networks. The dataset was built by collecting images from 500 different Urdu speakers belonging to a variety of social groups. Each of the authors was directed to write the character and the numeral in their own writing. The dataset also recorded the age, gender, hand preference while writing, physical impairments (if any) and the profession of each of the writers, but that data was not used in this experiment. As with the UHaT dataset, we randomly sampled 40 images from each class for training and 10 images from the query set each class for testing.

For both datasets, we have intentionally limited the number of samples in the training phase as this paper intends to demonstrate that it is possible to make a Urdu Handwritten Recognition system using few samples. This is done with the idea to mimic the human behavior, which is able to generalize knowledge based on few learning samples. Some examples of those datasets are provided in figure 5.

C. IMPLEMENTATION DETAILS

We conducted a large number of few-shot learning experiments on both the datasets using many random sets in order to assess the generality of the proposed approach. We used the Adam optimizer with an initial learning rate of 1×10 -3 . All of our models were implemented in Tensorflow and were trained on Google Collaboratory, on a single NVIDIA K80 GPU. The training time for the Prototypical Network on each of the datasets was around a day. We trained our models for both datasets in the same way to avoid the possibility of ambiguity in the final results.

We trained our model separately on all 40 classes of Urdu characters and the 10 numeric classes and tested each trained model with 5 classes at a time (5-way classification). The reason for this was that most pre-existing literature [START_REF] Snell | Prototypical networks for few-shot learning[END_REF], [START_REF] Vinyals | Matching networks for one shot learning[END_REF] demonstrated their results on the Omnilogot dataset on the basis of a 5-way classification.

D. RESULTS

This section provides a comprehensive overview on the results that we obtained from our experiments. It is divided into two major subsections, the Qualitative Results and the Quantitative Results. The Qualitative results deal with the functioning of our method and aim at illustrating the way classes are organized. This qualitative evaluation is also compared to other existing approaches, and it shows how well it is able to cluster different segments of handwritten Urdu characters with varying amounts of similarity, across common prototypes in the embedding space. In a complementary way, the Quantitative results give us an empirical overview into the accuracy of our method over the two datasets that we tested it on.

As this study tends to prove that a few-shot learning approach is able to learn the Urdu handwritten features, we trained the Prototypical Network in 1-shot and 5-shot scenarios, taking the nearest and the 5 nearest points in the embedding space. We also found that it was sufficiently advantageous to pair the training-shot with the test-shot, as well as use a higher number of classes (a higher 'way') per training episode.

1) QUALITATIVE RESULTS

As a first part of our analysis, we propose a qualitative evaluation of our proposed model. The idea behind this evaluation is to firstly illustrate that the proposed results appear relevant, and to have a visual comparison of our proposed method towards existing ones.

a: PCA GRAPH REPRESENTATION

To qualitatively analyze the results obtained from our proposed approach, we first developed a Principal Component Analysis (PCA) visualization of the embeddings that were learned by the prototypical networks based on the work developed in [START_REF] Mishra | Principal component analysis[END_REF]. We applied PCA to reduce the embedding space to a two-dimensional slice while the network was being trained on characters. We visualized samples of characters in order to gain a better and more comprehensive insight into the learning process of the prototypical networks. Figure 6 is presenting this process on two different dataset. The left part (Figure 6a) is displaying this result on the Omnilogot dataset ( [START_REF] Fort | Gaussian prototypical networks for few-shot learning on Omniglot[END_REF]) while the right part (Fig. 6b) corresponds to the visualization of the embedding space obtained on the Urdu characters. Even though the visualized characters are minor variations of each other, the PCA diagram shows that the network is able to cluster hand-drawn characters closely around the prototypes, while separating the different classes.

b: t-SNE COMPARISON

In order to go deeper in the visualization of our proposed approach, we propose a fair comparison with the results proposed in [START_REF] Husnain | Visualization of high-dimensional data by pairwise fusion matrices using t-SNE[END_REF]. To do so, we used a t-distributed stochastic neighbor embedding (t-SNE) [START_REF] Van Der Maaten | Visualizing data using t-SNE[END_REF] to visualize our embedding space. t-SNE is a widely used non-linear dimensionality reduction technique for visualizing high-dimensional data with clear and perfect separation. Figure 7 proposed to illustrate this comparison between the results obtained in [START_REF] Husnain | Visualization of high-dimensional data by pairwise fusion matrices using t-SNE[END_REF] and our embedding space created using only 5 samples per class.

In the previous work, the authors applied the t-SNE to visualize Urdu handwritten characters (see figure 7a). One can observe that even with a very low number of elements per class (5 in this work), our proposed approach of few short learning technique (see figure 7b) is able to propose a well separated representation space. We can however see that some mistakes remains (highlighted in red circles). However, as the classification process is based on a k-nearest neighbor, those mistakes should not have a great impact on the final results.

2) QUANTITATIVE RESULTS

Following this qualitative analysis, we propose formally assessing the relevance of our proposed approach in this section. To this end, we tested it on two major datasets (Urdu Handwritten Text (UHaT) dataset [START_REF] Ali | Pioneer dataset and automatic recognition of Urdu handwritten characters using a deep autoencoder and convolutional neural network[END_REF] and the one from [START_REF] Husnain | Urdu handwritten text recognition: A survey[END_REF]) and we propose hereafter a comparative study against other baselines. This comparison was firstly conducted on other few-shot learning techniques, including Matching Networks [START_REF] Vinyals | Matching networks for one shot learning[END_REF], Neural Statistician [START_REF] Edwards | Towards a neural statistician[END_REF] and Model Agnostic Meta-Learning (MAML) [START_REF] Finn | Model-agnostic meta-learning for fast adaptation of deep networks[END_REF]. We also propose to study the genericity of the embedding models by training on one dataset and testing on the other one. Finally, we also propose a comparison with classical (i.e. non-few-shot learning) techniques which were published recently.

a: COMPARISON WITH FEW-SHOT LEARNING APPROACHES

The classification accuracy of our models was computed by averaging the results obtained over 200 randomly generated episodes from the testing set for both test cases (5-way-5shot and 5-way-one-shot). We used the traditional measure of computing classification accuracy by comparing the values of the predicted class given by the network to the actual class in the dataset. We can mathematically depict the classification accuracy as:

(y, ŷ) = n i=1 argmax( ŷi , 1) ∼ y i n ( 9
)
where (y, ŷ) is the classification score for the true value y and its predicted output ŷ. n is the total number of datapoints in a randomly generated episode. We compute for 200 episodes and average the overall score to get the final accuracy for the model. Table 1 shows a summarized view of the results on training our network on Urdu characters, while table 2 deals with Urdu Numerals. In a global overview, we can observe that our proposed method is competitive and outperforms stateof-the-art on the two datasets. In addition to computing the classwise accuracy for characters and numerals, we also compared our model against other techniques in terms of another quantifiable measure, inference time. We found that our fewshot learning approach can operate at a competitive inference time compared to other similar techniques.

Table 2 shows the classification accuracy for our method in comparison with other few-shot learning based methods, when trained on Urdu numerals separately. The classification accuracy, as with the characters, was generated by aggregating the results obtained by 200 randomly generated episodes for both the test cases, 5-way-5-shot and 5-way-1-shot. One can observe that our method is able to outperform all the existing approaches in both 1 and 5-sot learning, ensuring that the proposed approach is relevant.

We also propose a deep analysis of our performances on how our proposed network can accurately predict a given individual character or numeral. Table 3 andTable 4 contain the classification accuracy for individual characters and numerals. This gives us a better insight into how well our method performs on an individual test case, rather than collectively classifying characters. An important feature of the proposed system is that in all classes, results are improved when using a 5-shot classification compared to the 1-shot classification process. This is an important feature of our model because, as displayed in figure 7b, one can see that the proposed model miss-classify some character (highlighted in red circles). Even if in a 1-shot classification process the nearest neighbor used to associate a class to a query can lead to errors and reduce the total accuracy, the 5-shot classification always proposes better results. This highlights the ability of our system to generate a well-designed representation space (i.e. group together similar character in the embedding space) even with very few information. While it is implicitly understood that the model would obviously perform better when given more data for a single class, looking at the performance of our model in multiple settings allows us to get a better understanding of its overall performance. The mean improvement when using the 5 nearest neighbor instead of the nearest neighbor is of 6,77% which clearly assess the relevance of this process.

Taking a step further, to even better understand the specific boundaries that our network forms when classifying characters, we decided that a Confusion Matrix would be the best way to observe the amount of similarity our network observes when comparing different characters and numerals. Thus, we created a confusion matrix from the numerals in Table 4. Figure 8 shows the confusion matrix, from which we observe that the boundaries between the correctly predicted number and a randomly selected number are quite distinct. While we did create a similar confusion matrix for all of the associated per-class accuracy of characters as depicted in Table 3, we are not including it in the current text in the interest of space. Please refer to our supplementary material to have a look at the character confusion matrix.

b: ABALATION STUDY

In order to highlight and compare the performance of our two strategies, we decided to conduct experiments and perform abalation studies, the results of which can be found in Table 5. We also conducted experiments without adding data augmentation in order to test the robustness of our approaches. We notice that our accuracy drops in both cases, signalling that data augmentation is key to our network, especially since it makes the input in a few-shot setting less sparse.

c: GENERICITY EVALUATION OF OUR APPROACH

The next part of our evaluation tends to highlight that our approach can embed some generic knowledge from one

TABLE 6.

Genericity evalution of our few-shot learning methods on individual handwritten Numeral Urdu. The values corresponds to the classification accuracy when learning on one dataset and testing on a second one. The ''Delta'' values correspond to the difference with the results presented in Table 4.

dataset to propagate it to a second one. To do so, we decided to put our model to the test by training it on a dataset and providing the query set from a completely unrelated set of images. By doing so, we were able to observe whether our model was robust to changes in the structure of the images, and was not learning shortcuts such as visual artifacts unique to a particular dataset, in order to optimize performance.

With that in mind, we trained our model on the numerals from the UHaT dataset, and we used the query set of the numerals from the dataset used in [START_REF] Husnain | Visualization of high-dimensional data by pairwise fusion matrices using t-SNE[END_REF]. Our system reached a global accuracy of 90.81% which is approximately 1.9 points lower than the accuracy obtained on our previous result, for 5-way-5-shot learning. However, we can observe that a large part of the results remain relevant, in both 5-way-5-shot as well as 5-way-1-shot, and unchanged even with varied datasets. Moreover, in order to propose a fully comparable evaluation, table 6 presents a comparative study of results obtained on each number. We can observe that the changes in the accuracy have a degree of variance (denoted by Delta). Delta ranges from 1.1 to 2.9 for 5-way-5-shot learning, and from 0.7 to 2.0 for 5-way-1-shot. We can then conclude that the proposed embedding space is generic enough to be learned on one dataset and tested on another one, even with a very limiter number of samples in the training set.

d: COMPARISON WITH LARGE TRAINING MODELS

Finally, in order to determine how our method performs against existing solutions like [51], we compared our proposed approach with non-few-shot learning based approaches. This gave us an idea on how close we are to replicating the results obtained with large set of training data used in conventional approaches [START_REF] Borse | Offline Handwritten and Printed Urdu Digits Recognition Using Daubechies Wavelet[END_REF], [START_REF] Chhajro | Handwritten Urdu character recognition via images using different machine learning and deep learning techniques[END_REF], [START_REF] Husnain | Visualization of high-dimensional data by pairwise fusion matrices using t-SNE[END_REF], [START_REF] Razzak | Numeral recognition for Urdu script in unconstrained environment[END_REF]. Table 7 shows the comparison between our method and other conventional handwritten character recognition methods for the Urdu language (from the second dataset [START_REF] Husnain | Visualization of high-dimensional data by pairwise fusion matrices using t-SNE[END_REF]). While our network is not able to outperform these, it comes fairly close to emulating the results with a comparable accuracy for characters. For numerals, classical deep learning approaches using large training sets remains the best.

V. CONCLUSION AND FUTURE WORKS A. DISCUSSIONS

Handwritten character recognition has been an age-old problem in the field of computer vision. However, most systems for this were tuned to languages like English, and French; or the languages that made use of the English alphabet. Other languages with non-English characters did not share the same limelight, which made it harder for progress to be observed. Recent developments have been made [START_REF] Purkaystha | Bengali handwritten character recognition using deep convolutional neural network[END_REF], [START_REF] Wang | Radical aggregation network for few-shot offline handwritten Chinese character recognition[END_REF], but the amount of structured and annotated data is usually a barrier in most cases. Rather than collating more data, we decided to use a method which was previously proven to accurately classify images with a minimal amount of examples. It is based on the idea that we can represent each character or digit as a class by the mean of its examples in the embedding space learned by a neural network. We found that our proposed approach is more efficient as well as more simpler than other meta-learning approaches, such as Matching Networks and Model Agnostic Meta-Learning (MAML), and is able to produce state-of-the art results on two independently collated datasets consisting of individual examples of Urdu characters and numerals.

In our experiment, we trained a Prototypical Network pipeline to classify handwritten Urdu characters and numerals with a minimal number of examples. We also employed an episodic training process, which was proved to be more effective for training [START_REF] Snell | Prototypical networks for few-shot learning[END_REF], and proposed a pipeline for its training, consisting of a preprocessing step, an encoding network, the Prototypical Network acting as the classifier, and a post-processing step to account for diacritics.

Our method was able to give a good enough accuracy compared to OCR solutions for other languages [START_REF] Memon | Handwritten optical character recognition (OCR): A comprehensive systematic literature review (SLR)[END_REF] and was able to manage it with a minimal amount of examples. The qualitative and empirical results show that it can perform quite accurately on the basis of an OCR. However, Prototypical Networks are also prone to false positives and false negatives in some cases. This is mainly due to the fact that the embedding space relies on a small amount of data and the k-nearest neighbor procedure. While this could be a bad point for the end-user, we assume this could be an opportunity for reducing the black-box effect of such a system for non-expert users. We could then propose more than one answer to the user and illustrate those choices by displaying the embedding space, which could help in understanding the proposed answer.

B. FUTURE WORKS

In the field of handwritten text recognition, there is an abundance of data for commonly used languages like English and French. This makes character-level prediction relatively easy when compared to languages like Urdu, which, apart from having a scarcity in the amount of proper, usable data, also is bidirectional and context-sensitive in nature.

There have been a lot of developments in the field of few-shot learning in recent times. Wang et al. [START_REF] Wang | Radical aggregation network for few-shot offline handwritten Chinese character recognition[END_REF] put forward a Radical Aggregation Network for few-shot classification of handwritten Chinese characters, and we feel that the same concept would be able to give a comparable or better result than our proposed method. Other newly proposed methods like few-shot learning with geometric constraints [START_REF] Jung | Few-shot learning with geometric constraints[END_REF], or using instance credibility inference to improve the accuracy further [START_REF] Wang | Instance credibility inference for few-shot learning[END_REF] could also serve as viable improvements to our proposed solution. With unprecedented advancements in attention mechanisms for few-shot object detection and recognition, we believe some of the recent works by authors [START_REF] Bhunia | Handwriting transformers[END_REF], [START_REF] Yang | A transformerbased radical analysis network for Chinese character recognition[END_REF] can also be adapted for the purposes of our problems. We welcome comparisons of our results with future works and it would be interesting to see new and innovative ways to tackle character recognition for non-Latin languages presented in a few-shot setting.

RAJAT SAHAY is currently pursuing the bachelor's degree with the School of Computer Science and Engineering, Vellore Institute of Technology, Vellore, India. He was involved in computer vision techniques to solve problems in disparate fields. His research interests include applied machine learning, vision, and statistical techniques. 33696 VOLUME 11, 2023

FIGURE 2 .

 2 FIGURE 2. State of Prototypical Networks in Few Shot and Zero Shot Scenarios. Embedded query points are classified using the mean over distances to individual class prototypes (from [41]).

FIGURE 3 .

 3 FIGURE 3. An overview of our proposed approach. The encoder (the CNN) converts an image to a vector ( -→ x ∈ R V ). Then, the prototypical network maps each image -→ x into the embedding space R M (dark circles in the figure) while the support images are used to define the prototypes c k (stars in the figure). The distance between prototypes and encoded query images are used to classify the images.

FIGURE 4 .

 4 FIGURE 4. Structure of the multi-layered convolutional neural network that is used to encode the features of Urdu characters and numerals into a 64-dimensional vector space: R V .

FIGURE 5 .

 5 FIGURE 5. Samples from the same set of character written by different people. The variance in each individual character is evident from the figure.

FIGURE 6 .

 6 FIGURE 6. A two-dimensional projection of the embedding space during training, as obtained by Principle Component Analysis. The clustering of similar characters, used for classification of unknown query images, is apparent in the plot.

FIGURE 7 .TABLE 1 .

 71 FIGURE 7.A two-dimensional projection comparison of the embedding space unsing t-SNE during training. We can observe that few mistakes were made by our system while only using 5 samples per class for setting up the embedding space.

FIGURE 8 .TABLE 5 .

 85 FIGURE 8. A Confusion Matrix on the 10 Urdu numerals showing the per-class accuracy and error for each of the sampled characters.

  MICKAËL COUSTATY (Member, IEEE) is currently an Associate Professor with the Laboratoire Informatique, Image et Interaction, La Rochelle Université, France. His research interests include document analysis based on computer vision and natural language processing, digital trust in information exchange with the development of fraud detection techniques and document securing systems, segmentation and classification of large document flow, and pattern recognition.

TABLE 2 .

 2 Classification accuracy of few-shot learning methods on handwritten Urdu numerals.

TABLE 3 .

 3 Classification accuracy of few-shot learning methods on individual handwritten Urdu characters.

TABLE 4 .

 4 Classification accuracy of few-shot learning methods on individual handwritten Urdu numerals.

TABLE 7 .

 7 Classification accuracy of few-shot learning methods on individual handwritten Urdu numerals and characters compared with non-few shot learning methods.

 VOLUME 11, 2023

 VOLUME 11, 2023

 VOLUME 11, 2023

 VOLUME 11, 2023

 VOLUME 11, 2023

 VOLUME 11, 2023