{'fraction_non_alphanumeric': 0.0257295051760528, 'fraction_numerical': 0.007939964487922543, 'mean_word_length': 5.0, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Semantics Preserving Hierarchy based Retrieval of Indian heritage monuments

Monument classification can be performed on the basis of their appearance and shape from coarse to fine categories. Although there is much semantic information present in the monuments which is reflected in the eras they were built, its type or purpose, the dynasty which established it, etc. Particularly, Indian subcontinent exhibits a huge deal of variation in terms of architectural styles owing to its rich cultural heritage. In this paper, we propose a framework that utilizes hierarchy to preserve semantic information while performing image classification or image retrieval. We encode the learnt deep embeddings to construct a dictionary of images and then utilize a re-ranking framework on the the retrieved results using DeLF features. The semantic information preserved in these embeddings helps to classify unknown monuments at higher level of granularity in hierarchy. We have curated a large, novel Indian heritage monuments dataset comprising of images of historical, cultural and religious importance with subtypes of eras, dynasties and architectural styles. We demonstrate the performance of the proposed framework in image classification and retrieval tasks and compare it with other competing methods on this dataset.


I. INTRODUCTION
Monuments are highly complex three dimensional structures which are constructed to commemorate a person or an event and become an integral part of the cultural heritage due to the historical, political, artistic or architectural significance [1]. In [1], authors suggested that the buildings and monuments cannot be classified at instance level alone as they have more fine-grained information that can be categorized based on their architectural styles. Architectural styles may not only vary over time but also over geographical regions. In order to discover the characteristic feature across the architectural styles there are several challenges to address the variations in: i) scale, ii) appearance and iii) viewpoint and occlusion. Thus, the discriminative patches to be mined across multiple scales need to be semantically meaningful as well. In [2], different applications on multimedia ontology and semantic representations have been elucidated which includes instance retrieval, content based recommendation engines, and information integration. It presents the usage of Multimedia Web Ontology Language (MOWL) to preserve tangible and intangible heritage aspects by leveraging digital heritage. Another seminal work in monuments classification is done by [3]. The authors investigated the geographically relevant features in the visual context such as windows with railings, balcony styles, doorway styles, blue/green/white street signs to classify the Paris buildings. An amalgamation of visual and semantic information can aid in the monument classification and retrieval tasks. This further may guide the application area of interactive virtual tour of heritage sites [4].
In this work, we explore the finer nuances in the Indian heritage monument types. India attributes its rich cultural heritage to the reigns of different dynasties belonging to different eras [5]. Even the architectural style across the country is quite varied. Further, due to the variations in the architectural types they can be classified into temples, mosques, gurudwaras, church, fort, tomb, caves, monastry, cemetry, baoli, stupas, landscape and palaces. Fig. 1 demonstrates the categorical examples of these architectural type classes. These monuments of such varied architectural types were constructed across various eras which can be further subdivided into various dynasty reigns. In order to incorporate such huge diversity in any retrieval methods in computer vision, it requires a lot of semantic knowledge embedded in the learning paradigm. Most of the retrieval methods [6]- [10] rely upon the instance level search based on the semantic similarity however such architectures do not allow category level drill-down at the same time.
Recently, a considerable amount of research has been focused towards solving instance based retrieval in multimedia and computer vision. The problem of finding and retrieving similar or exact instances of the query image from a large pool of images refers to content based image retrieval. The focus has been now shifted towards semantic retrieval rather than just restricting it to the domain of instance based retrieval. Vector encoding strategies such as bag of visual words [11], fisher vector [12] etc. has remained the de-facto standard for retrieval pipelines using local features. Once the descriptors are extracted from images, similar images can be then retrieved using inverted file index organisation or hashing based methods. In order to incorporate geometric verification in bag of visual words, [13] introduced a variant of bag of visual words. It enables to retrieve multiple view variations of the query image. Due to the representational ability of deep convolutional neural networks (CNNs) [14] as they learn rich mid-level image descriptors, feature vectors from last layers have shown exemplary performance in image retrieval as well. To reduce the feature dimensionality for matching purposes, PCA based techniques are further augmented. In [15], authors utilize deep CNNs to construct hash codes to speed up retrieval. Archaeological experts with the domain knowledge can easily categorize monuments based on the given characteristics. Automating the task of identifying the fine-grained classes in case of monuments and infusing semantic information of the hierarchy in the feature embedding given no a-priori knowledge is quite daunting task. In this paper, we construct a hierarchy tree of various eras subdivided into different architectural styles further classified into dynasties as the leaf node. We explore the structural nuances in such architectural styles so that features which are representative of the particular era can be clustered together. Finally, a dictionary is constructed based on the deep semantic embeddings obtained and re-ranking framework is imposed on top of it utilizing DeLF features [16]. A query image can belong to classes (monuments) already seen in the training phase or can be an unseen/unknown monument (novel classes) in the retrieval phase.
Thus, owing to the complexity of variations present in Indian monuments due to its rich cultural influence, we primarily focus to propose a framework that is capable of describing holistic attributes in the retrieval mechanism particularly in context of Indian heritage monuments. In this paper, we have tried to address the following questions: • What type of fine-grained information can we infer from images of Indian monuments-particularly eras, dynasty reign and architectural styles? • Can semantically learnt deep representations be utilized for constructing a unified framework capable of predicting multiple attributes for a given image of an Indian monument and consequently strengthen the retrieval pipeline? In view of above discussions, the key contributions can be summarized as 1) To the best of our knowledge, this is the first work to holistically infuse semantic hierarchy preserving embeddings to learn deep representations for retrieval in the domain of Indian heritage monuments. 2) We encode the learnt embeddings to construct a dictionary of images and then utilize a re-ranking framework on the retrieval results using DeLF features. 3) We show the applicability of proposed framework for fine-grained classification and semantics preserving retrieval. 4) We have curated a novel data-set comprising of monument images of historical, cultural and religious importance from all over India namely Indian heritage monuments dataset (IHMD). These monuments are further subdivided into different eras, dynasties and architectural styles. Overall architecture of the paper is as follows. Related works is given in Section II. The proposed methodology is explained in Section III. Experimental results and discussion are given in Section IV followed by conclusion in Section V.

A. Handcrafted features based retrieval
In [17], authors developed a framework for image retrieval using scene graphs. Conditional Random Fields (CRFs) are utilized to map the objects, attributes and relationships between them into the scene graph. Likelihood scores based on CRF graphs are taken into account for retrieval. In [13], authors performed retrieval on large scale dataset utilizing spatial verification in the ranking process and introduced a novel quantization technique using randomized trees. In [18], authors pioneered the bag of keypoint concept where vector quantization methods were utilized to encode the affine invariant descriptors on image patches. The de-facto standard for feature detectors Scale Invariant Feature Transform (SIFT) and Speeded Up Robust Features (SURF) was championed by ORB [19] which utilized binary descriptor named BRIEF and was invariant to rotation and noise variations. ORB has been predominantly utilized in feature matching applications thereafter. In [20], authors introduced a new robust descriptor RootSIFT and novel method for query expansion to discriminatively learn the query features with efficient use of inverted file index structures. Various feature quantization methods like Fisher Vector [12], VLAD [21] also gained popularity for image retrieval tasks.
Another set of works are in the domain of content based image retrieval (CBIR). In [22], CBIR based techniques are used to store and retrieve images over cloud server. First, feature vectors are extracted and then locality sensitive hashing is used to construct pre filter table. Finally, using secure Knearest neighbor pixels are encrypted with secure cipher. In [23], the rich semantic information embedded in the text helps in boosting the performance of unsupervised visual hashing of images. In [24], a detailed review of the CBIR techniques has been elucidated. In [25], author presented an ensemble network of deep CNN based and low level features like color or texture constructed by vector quantization techniques to perform the task of content based image retrieval.

B. Deep features based retrieval
In [26], authors investigated aggregation of local deep descriptors to produce a global descriptor for efficient image retrieval. In [27], authors generated region wise descriptors and aggregated to form a global descriptor for instance based search. Thus, region proposal network is incorporated to select the regions which should be the constituent of the global descriptor followed by learning a triplet loss to segregate the dissimilar pairs from similar pairs. In [28], authors created a large scale noisy Landmarks dataset for image retrieval tasks and also show improvements on the global deep descriptor based on Siamese architecture. In [29], authors proposed an instance search pipeline based on object proposal networks such as Faster-RCNN and leverage the deep features followed by a spatial re-ranking framework. In [30], authors utilized integral images to handle max pooling in the convolutional layer activations. In [31], authors utilized deep correspondence matching based on image patches in aerial images for retrieval task. In [32], authors utilized a novel regional aggregated selective match kernel to combine the information from the regions detected into a holistic description. In [33], authors augmented regional-attention network with Regional-Maximum Activation of Convolutions (R-MAC) to improve the retrieval performance. In [15], authors utilized deep supervised hashing to learn compact similarity preserving binary codes for fast and efficient retrieval. They discriminatively learn the similarity between the pair of images and produce binary hash codes in a manner that similar images are mapped closer and viceversa for the dissimilar images. In [9], authors extended the binary hash code to multilabel semantic image retrieval. In this work, the authors construct hash codes based on deep CNNs which jointly learns the feature encoding and mappings based on multilevel semantic ranking.

III. PROPOSED METHODOLOGY
In this section, we give a detailed overview of the proposed semantic hierarchy preserving retrieval scheme. The end-toend pipeline of the proposed method is shown in Fig. 2.

A. Semantic Feature Embedding
Most of the existing work in context of retrieval has been done in content based image retrieval (CBIR). Recently, incorporating semantics into retrieval is gaining attention. However, infusing this information only at the class-level may not rigorously embed the parent-child relationships. Learning this embedding at cross-class level is even difficult. Therefore, in order to deal with this we capture domain knowledge in the form of a hierarchy tree to aid the retrieval pipeline. In [34], authors introduced hierarchy tree concept for generic object dataset CIFAR-100 where the class-level intricacies are less. We get inspired from [34], and take it a level-forward in case of monuments and construct a hierarchy tree with careful selection of nodes. However, in contrast to [34] which utilizes prior knowledge only for semantic image retrieval in generic object datasets, in our proposed framework, we jointly learn semantic embeddings such that all the class embeddings lie on a unit hypersphere and visual feature embeddings such that the attention function when applied to the last fully convolutional layer of CNN (DeLF features, as described in Sec. III-C) gives us a global descriptor for each image. For e.g., the semantic embeddings for two different tombs will lie close on the hypersphere. The objective of semantics preserving image retrieval for our Indian heritage dataset with the given semantic relations has not been presented earlier in this domain.
The reason why Indian monuments are challenging are as follows: • Indian monuments show huge variations across eras, dynasties, architectural styles. However, different architectural styles within same dynasties may have similarities. Similarly, within same eras, different architectural styles may be built in same fashion. This requires not only similarity by part but also a global descriptor which inherently infuses such distribution of semantic embedding space. • Cross-cultural architectural monuments may also exhibit strong data association. • In CBIR based techniques, the data which is visually similar in terms of cues such as color, texture, structure may get clustered together even though they are not Masjid is for religious prayers while Taj Mahal which is rather more close to Humayun's Tomb as they both fall in the broad category of tombs. Thus, visual as well as semantic similarity both play a strong cue in retrieval. Most of the traditional semantic learning approaches ( [35], [36]) utilize class level knowledge in classification or retrieval pipeline at the classifier level or utilize taxonomy embeddings however they do not semantically learn the feature embedding space as done in [34]. It helps in integrating relevance feedback in the sequence. Only visual embeddings are not enough to map this taxonomic relevance to the retrieval engine rather word embeddings need to be incorporated as well. Instead of training on huge corpus of text, rather utilizing class embeddings based on prior knowledge derived from hierarchy tree of classes is more reliable and less complex.
For a directed acyclic graph G(V, E), where V denotes the nodes and E, denotes the edges specifying the hyponymy relation between semantic concepts. For Indian heritage monuments dataset, we construct extensive hyponym and hypernym creation along with 4-level tree for better domain representation. We maintain a trade-off between region level annotation and ontology infusion. Edge (u, v) would mean that u is a superclass of v. Classes of interest are denoted by C = {c 1 , ..., c n } ⊆ V are a subset of semantic concepts. The dissimilarity between two classes is given as the height of the hierarchy tree which is further calculated using the lowest common subsumer (LCS) of two classes as, where the height of a node is the depth of the tree from that node to leaf. The LCS of two nodes is the ancestor of both nodes that does not have any child being an ancestor of both nodes as well. Thus, the semantic similarity [0-1] between two classes is given as, The next step is to compute the class embedding φ(C i ) R n , ∀c i C such that, where all the classes lie on a unit hypersphere, if a new embedding is present the dot product with the already embedded class will give the semantic similarity of the two classes. After the target embeddings for all classes is precomputed, we need a transformation ψ : X → R n from the image space into hierarchy-based semantic embedding space, so that image features are close to the centroid of their class. This transformation or feature representation is learned as presented in next section III-B.

B. Learning Semantic Embeddings using CNNs
We employ CNNs to learn the feature representation that correlates to semantic embedding of the class. The correlation loss as defined in [34] enforces similarity between the learned image representations and the semantic embedding of the class. Usually, the features extracted from the last layer of the same CNN network architecture, trained with crossentropy loss gives a good feature embedding. Hence when adding a fully-connected layer with softmax function on top of the embedding layer, the network can learn simultaneously semantic image embeddings and classify images based on combined loss.

C. DeLF Feature based Reranking
Next, in order to embed visual similarity further to the semantic similarity in the retrieval pipeline we further rerank the retrieved images with DeLF based features [16]. For a given image, dense features are extracted using a fully convolutional network (FCN) by training with a classification loss. We utilized pretrained ResNet50 architecture [37] on ImageNet [38] for obtaining the FCN features. The weights are finetuned on Google Landmarks dataset [16]. In order to handle the scale variations, pyramidal network is employed. Following that, an attention layer is incorporated to select the subset of features. The attention score function α(.) is designed with a 2-layer CNN followed by softplus activation function. Let f n R n , n = 1, ..., N denote the d-dimentional features to be jointly learnt with attention model. An attention score function α(f n ; θ) is learnt for each feature, where θ denotes the parameters of function α(.). The output logit y is obtained as, where W R M xd denotes the weights of the final FC layer of the CNN trained to predict M classes. For training, cross entropy loss is utilized as in [16]. Thus, we do not need to describe the feature points as we get a global descriptor of dimensionality 1×40 for each image. This enables to incorporate visual similarity for retrieval of images.

D. Retrieval
Since, the CBIR based techniques just take into account visual similarity thus, mean average precision (mAP) and precision @ top-K results are evaluated. In order to incorporate the semantic similarity in the retrieval, we require a heirarchical precision metric (HP @k, 1 K m) as adopted from [39]. It is defined as, HP @k(R) = i = 1 k s G (y q , y i ) max π i = 1 k s G (y q , y πi ) where π denotes the permutation of indices from 1 to m. Denominator helps in normalizing the sum of precisions. Here, x q X denotes the query image with class label y q Y = 1, ..., n and retrieved images are denoted by R = (x 1 , y 1 ), ..., (x m , y m ), where each retrieved image is an ordered pair of image x i and its associated label y i . The area under the curve for k ranging from 1 to K denotes the average hierarchical precision @K. Thus, the semantic similarity can be measured for the retrieved set of images.

A. Experimental Setup and Parameter Settings
We perform the experiments in similar lines to [34] on the curated Indian Heritage Monuments dataset. The efficacy of the semantic embeddings on generic object dataset such as CIFAR-100 has been validated in [34]. In order to make our framework applicable to Indian heritage monuments dataset, we created a taxonomy for the set of classes present in this dataset. A toy hierarchy tree which is subset of the full taxonomy is shown in Fig. 4. There is a strict process of branching out at different levels of the taxonomy as shown in Fig. 3. Different semantic relations are captured at different levels of the taxonomy. First level is the era in which the monument is established, the second level is the monument type which represents the purpose of the establishment, the third level is the dynasty under which the monument is established which captures the architecture styles and finally the fourth level is the name of the monument itself. We perform training from scratch for learning semantic embeddings with different convolutional neural network architectures and compare its performance with pre-trained CNN architecture on ImageNet after doing transfer learning. We do not rely upon off-the-shelf pre-trained semantic embedding models trained over other datasets. The Indian heritage dataset is very distinct from other generic object datasets like CIFAR-100/ImageNet categories as it contains much finer nuances in terms of architectural styles, therefore utilizing pretrained networks without the prior knowledge of semantic relationships doesnt improve the mean Average Hierarchical Precision (mAHP). One of the architecture is Plain-11, which is a VGG style network with 11 trainable layers. Other two are vanilla ResNet-34 and ResNet-50, which are regular deep residual networks with 34 and 50 trainable layers. For ResNet-50 network, we also compare results of model with and without pre-training on ImageNet dataset. (*) denotes the network with pre-training. For the training process of all the networks, we use a cyclical learning rate with Stochastic Gradient Descent with Warm Restarts (SGDR) [40]. This refreshes the model learning by setting the learning rate as near as zero for every 12, 36 and 84 and 180 epochs. This is primarily used so that the network doesnt get stuck in a local minima and the model learning is more generalised over the entire dataset. All the networks were trained for 180 epochs with a batch size of 8. In case of pre-trained ResNet-50 model, the fine-tuning over monument dataset is performed for 8 epochs only. In the curated Indian heritage monuments dataset, each class consists of 50 images over 143 monument classes. The train to test ratio split is 8:2.

B. Indian Heritage Monuments dataset details
We collected the data from Google images, Wikimedia and Flickr using webscraping by web APIs 1 . The initial list of monuments were obtained from Archaeological Survey of India (ASI) website 2 along with Wikipedia. After extracting images for 200 monuments, we applied DeLF based features to cluster images as a preprocessing step to filter irrelevant and redundant images. Since this is a retrieval problem, we ensured that they have enough intra-class and inter-class variance so that the proposed method addresses issues related to scale, occlussion, low illumination/night condition imagery etc. Several monuments from 200 classes had very few relevant samples (less than 10) and consisted of clutter in terms of people standing in front of the monument, occlusion of the facade due to the view, watermark, etc. Thus, after initial filtering the dataset consists of 143 classes where we have a balanced number of samples with mean sample per class as 50. Once we prepared the Indian Heritage monuments dataset (IHMD) 3  There are few other works which have addressed Indian architectural styles. The dataset used by [41] is limited to four architectural styles namely, Buddhist (8 classes), Kalinga (7 classes), Dravidian (8 classes) and Mughal (4 classes) with a total of 3514 images in 27 classes. While our dataset has high semantic information where we cover the type of the monument (architectural style) (11 classes), ruling dynasty when it was built (37 classes) and the monument classes(143 classes) with a total of 7150 images. In IHIRD dataset [42], authors capture several individual structures (or sculptures) found in the monument instead of the facade of the monument as done in our dataset. For e.g. there are images of Nandi bull (sculpture) present in front of Lord Shiva temple.

C. Quantitative Evaluation
Image retrieval when evaluated using the precision of top K results (P@k) or mean average precision (mAP), the results does not take into account similarities among classes and varying misclassification costs. Hence, we choose the metric proposed in [39], average hierarchical precision @K (AHP@K) which is aware of the semantic relationships of the classes. In our experiments, we present results as AHP@40, because it indicates the average number of images per class in Indian heritage monument dataset. The training set and validation set is roughly divided in 40 images and 10 images respectively from each class. We use each of the test image as individual query, to retrieve semantically similar images from the remaining ones. Retrieval is performed by ranking the images in dataset in decreasing order of the dot product with the query image in the feature space. We evaluate semantic embeddings, learnt with combined cost function of correlation loss and cross-entropy loss, in addition with DeLF based reranking. As a baseline, the comparison is done with features extracted from the last layer of the same network architecture, trained with cross-entropy loss namely classification-based in Table I. Further comparison is done with label embeddings networks [43] as shown in table I. All methods have been experimented with identical network architectures and trained with same conditions. We also plot a graph of hierarchical precision against the top K correctly retrieved results with different CNN architectures as shown in Fig. 9. Similarly for image classification, we evaluate the semantic embeddings on basis of accuracy obtained with softmax function applied to fully-connected layer on top of the embedding layer. Further classification accuracy is compared with label embedding network model [43] after applying softmax function and the baseline classification model without any embedding layer as shown in table II. As shown in table II pretrained ResNet-50 model(*) performs best in monument image classification on given dataset. The performance of semantic embeddings is lower because we consider Top-1 accuracy for classification.
We further perform experiments to improve the performance of pre-trained ResNet-50 model with different input image sizes and evaluate the corresponding inference speed as shown in table III. We also construct confusion matrix for the best performing ResNet-50 model at different levels of image classification as shown in Fig. 5 and in Fig.6. In Fig. 5 the confusion matrix for monument type level image classification is shown and Fig. 6 shows the confusion matrix for dynasty level image classification. From these confusion matrices,  we observe that proposed framework is not only able to categorize images in classes at higher level of hierarchy such as monument type level with considerable high accuracy but also categorize them in classes at lower level of hierarchy such as dynasty level with good accuracy. Usually the classification performance goes down when we descend from higher level to lower level of hierarchy due to high visual similarity between the categories at lower levels. TableIV shows the confusion matrix at leaf node level between 2 visually similar monument classes. Figure 7 shows the qualitative image retrieval results for known and unknown monument class, while training. The left side of the figure 7 shows the retrieved images for test query 'Humayun's Tomb' where 'Humayun's Tomb' class is present during the training. On the right side of the figure 7 shows the retrieved images for test query 'Gurudwara Sri Guru Singh Sabha Sikh Temple' from Southall England where the concerned monument class is not present in during the training. Hence the qualitative results shows that globally, semantic information is well captured in the semantic embeddings and re-ranking of retrieved images with DeLF features improved the results locally. It confirms that even though the trained model for given monument classes does not encompass all the monuments that exist, we can still retrieve similar looking monuments from the hierarchy at the level of architectural styles. Figure 8 shows the visual examples for the confusion matrix shown in table IV. It captures the misclassification at leaf node level in visually similar sub-classes, where 'Lodi Tomb' is classified as 'Sayyid Tomb' and vice versa. Here, we observe that in case of visually similar sub-classes there are very few local structures or subtle differences which distinguishes them from one another, thus leading to more confusion.

V. CONCLUSION
In this paper, the proposed framework for semantic feature embeddings integrates the prior knowledge about the semantics between the classes with deep learning with the help of an Indian heritage monuments taxonomy based on era, dynasty and architecture styles. Thus retrieved images from the database using this semantic feature embeddings are not only visually similar but also semantically similar to the test query image. The exhaustive set of results confirms that global and local representation of monument images is very well captured by the semantic feature embeddings and the DeLF signatures.