Computer Science
Computer Science-2021.gz:143383
Computer Science Environmental Science
524f3058179b8d43d9cceb13b0642ffb13882ae1
Tackling Inter-Class Similarity and Intra-Class Variance for Microscopic Image-based Classification

Automatic classification of aquatic microorganisms is based on the morphological features extracted from individual images. The current works on their classification do not consider the inter-class similarity and intra-class variance that causes misclassification. We are particularly interested in the case where variance within a class occurs due to discrete visual changes in microscopic images. In this paper, we propose to account for it by partitioning the classes with high variance based on the visual features. Our algorithm automatically decides the optimal number of sub-classes to be created and consider each of them as a separate class for training. This way, the network learns finer-grained visual features. Our experiments on two databases of freshwater benthic diatoms and marine plankton show that our method can outperform the state-of-the-art approaches for classification of these aquatic microorganisms.


Introduction
Micro-organisms are key components of aquatic ecosystems and analysing their distribution is a central question in aquatic ecology. This often requires manual identification of organisms by a human expert using a microscope. Organisms are grouped into taxa based on morphological features which can present a huge diversity. The classification task often turns out to be time-consuming, tedious and sometimes requires a high-level of expertise. Thus, methods are being developed to automate the process [5,17]. Over the years, the automatic classification has evolved from traditional hand-crafted methods [2,16] to deep-learning-based ones [8,10]. While the methods using deep learning have shown improved performance, we show that they are not sufficient to learn fine-grained visual features for reliable classification [11]. For this study, we consider the classification task of two typical aquatic microorganisms: freshwater benthic diatoms and marine plankton. Diatoms are unicellular micro-algae characterized by a highly ornamented silicified exoskeleton. Plankton includes a group of organisms drifting or floating in the water column, encompassing a large range of microbes, algae and larvae. Automated classification of these microscopic images is challenging notably due to two aspects: inter-class similarity and intra-class variance. Inter-class similarity occurs when objects belonging to different classes have visually similar appearance due to minute variations in the morphological features. Intra-class variance is when some objects belonging to the same class have drastically different appearances. This is prevalent in microscopic images due to the restrictions in view-points from which the images are acquired. Diatoms are typically imaged on permanent microscope slides: samples are treated chemically in order to remove organic materials and the diatom suspension is allowed to settle out, which restricts each organism to lie either on its side or top. While in planktons, after appropriate sub-sampling by size-selective filtration, images of live samples are acquired using a submersible imaging flow-cytometer, which ensures that every processed organisms are analysed individually. Indeed due to imaging constraints, the images acquired using these microscopy methods result in discrete view-points. Examples of diatoms with inter-class similarity and intra-class variance are shown in Fig. 1. Fig. 1(a) shows the images of diatoms from three different classes that have similar appearance and are often confused by the classification network. Fig. 1(b) shows the images from a single class, but taken from the side and top view. Here, the network fails to identify all of them as belonging to the same class.
An intuitive approach to tackle this problem would be to separate the feature embeddings of different classes by a distance so that the network can better differentiate them. This is known as metric-learning [4,15] and the principle behind it is to bring closer the feature embeddings of the objects belonging to the same class while pushing apart the embeddings of the objects belonging to different classes. This is effective for inter-class similarity, but does not impose any constraints on the intra-class variance. Hence, in this paper, we propose an algorithm that automatically clusters the instances within the high variance classes. Then the generated clusters are considered as independent classes while training. The clustering is based on the learned visual features and so, each cluster contains similar feature embeddings. In this way, the variance within each class is reduced, and the network can learn fine-grained features specific to them. Our technical contribution is that our algorithm automatically chooses the classes to be clustered and the optimal number of clusters to be generated. Finally, to handle the problem of inter-class similarity, we use triplet loss to increase the distance between the inter-class features. Experimental results on a diatom and plankton dataset show that by reducing the impact of intra-class variance and inter-class similarity, the network learns finer-grained features that improves the classification performance.
Our contributions in this paper can be summarised as follows: (1) We propose a method to address the problem of inter-class similarity and intra-class variance in fine-grained visual classification, particularly in the setting where the images within a class have contrasting appearance changes. (2)We apply our method to a real-world problem of diatom and plankton classification and show that our method has improved performance over the existing state-of-the-art approaches.

Related Work
Early methods of plankton and diatom classification relied on hand-crafted methods to extract features for classification. [17] uses multiple kernel learning to perform plankton classification. [5] is a pilot study on using image processing techniques to perform automatic detection of diatoms. [2] analyses different morphological and statistical descriptors to classify the diatoms. Although the handcrafted based methods have been proven to be successful in identification, it is time-consuming to choose the appropriate features. Thus, the recent focus is on using deep learning to extract features automatically. [14] develops a deep network model to exploit the translational and rotational symmetry in plankton images. [8] compares the performance of various deep neural networks for plankton and coral classification. [10] develops a combination of unsupervised and supervised learning to classify plankton images. However, none of these works consider the influence of intra-class variance and inter-class similarity on the classification performance.
Few methods have been proposed in the computer vision literature to handle intra-class variance and inter-class similarity for visual recognition. [7] uses splitand-merge to handle high intra-image and intra-class variations for celiac disease diagnosis. [3] considers the instances contributing to high intra-class variance as outliers. They use triplet loss with a weighting scheme where each instance is given a weight based on how representative they are of their class. [13] uses a Hadamard layer to minimise the intra-class variance. The one closely related to ours is [6], where they cluster the instances within each class into a set of pre-defined sub-classes (K classes) using K-Means clustering. They calculate two sets of triplet losses: one for the broader class instances and the other for the sub-class instances. The drawback with this approach for our application is that since K-Means is applied to all the classes and K is pre-defined, it could result in over or under-clustering. Contrary to their approach, our algorithm uses X-Means [12] and decides the classes to be clustered and the optimal number of clusters during training. X-Means is a variant of K-Means that can automatically decide the number of clusters to be created based on certain conditions such as Akaike information criterion (AIC) or Bayesian information criterion (BIC) scores.

Method
The proposed method considers the two challenges of aquatic microorganism classification: (1) inter-class similarity and (2) intra-class variance.

Inter-class Similarity
Inter-class similarity results in the network learning similar feature embeddings for the classes with similar-looking images. During inference, this causes confusion in differentiating between them. Along with the cross-entropy loss commonly used for classification networks, we use triplet loss to separate the feature embeddings between each class. The triplet loss tries to minimise the distance between the objects belonging to the same class while maximising the distance between the objects belonging to different classes in the feature space. This can be formulated as follows: Let x a , x p and x n be the anchor, positive and negative image. Here x a and x p belong to the same class while x n is from a different class. Let f be the function to obtain the feature embeddings of the images. The triplet loss is given by where α is the margin to separate the positive and negative images in the feature space. Our final loss is the sum of the cross-entropy loss and the triplet loss.

Intra-class variance
The classification network fails to identify all the images as belonging to the same class when there is a high variance of data within the class. Our proposed method clusters the classes with high variance into sub-groups and consider these sub-groups as independent classes for classification. We use X-Means since it automatically decides the clusters to be generated. However, it can sometimes generate non-optimal number of clusters. When there is over-clustering, there will be overlap of visual features between two or more clusters. Considering these clusters as independent classes further aggravates the problem of inter-class similarity. Having a smaller number of clusters still doesn't solve the intra-class variance problem. Thus, the goal of our method is to find the optimal number of clusters to minimize both the inter-class similarity and intra-class variance. X-Means uses a parameter for the upper limit to the number of allowed clusters, and always generates clusters that are less than or equal to this value. Our algorithm decides this parameter for each class so that the optimal number of clusters is generated.

Training algorithm
For every class in the data, we define a parameter num-allowed-clusters, which is the upper limit to the number of clusters that can be generated for that class.
As the training progresses, num-allowed-clusters is adapted until it reaches the optimal value. There is a threshold to the maximum value that can be attained by num-allowed-clusters which is max-clusters. The overall training can be divided into the following steps and the process is repeated until the training converges: 1) Extract feature embeddings for the training images; 2) Cluster using X-Means; 3) Train the classification encoder network; 4) Perform validation and obtain the normalised confusion matrix; 5) Adjust num-allowed-clusters based on the confusion matrix. In order to generate the clusters, we extract the feature embeddings of the images from the last fully-connected layer of a classification network pre-trained on the ImageNet dataset. X-Means uses these feature embeddings to cluster the images. At the beginning of training, we initialise num-allowed-clusters to 1 for all the classes, which is the same as training a standard classifier. However as the training progresses, we adapt num-allowed-clusters and X-Means generates clusters based on this value. These clusters are then considered as independent classes while training the network. Fig. 2 shows an example of clusters generated for the diatom class Aulacoseira pusilla. The diatoms have been clustered based on the difference in view-point and the porosity. Since they are considered as independent classes, the network learns these intricate details which helps in fine-grained classification. After every epoch of training, we obtain the normalised confusion matrix. When the false-negative for a particular class is above confusion-threshold, we increment num-allowed-clusters for that class. For our application, the classification certainty of each class is important and so we use false-negatives to optimize num-allowed-clusters. As the training progresses and when the falsenegatives is greater than the confusion-threshold, we increment num-allowed -clusters until it reaches max-clusters. During the initial stages of the training, when the feature embeddings learned by the network are not fully refined, the false negatives are relatively high for many of the classes. Thus the false negatives of these classes will be above the confusion-threshold and the number of clusters may overshoot the optimal value. Thus we start decrementing num-allowed-clusters until it reaches 1. This adaptation continues until the optimal value is reached. The above process is repeated for every epoch until the training converges. The summary of our algorithm is given in Algorithm 1.

Datasets
We apply our method on two datasets: Diatom Dataset The diatom dataset consists of individual images of diatom from three different public taxonomic atlases [1]. The dataset contains a total of 166 classes with a total of 9895 images.
WHOI-Plankton Dataset [9] The WHOI plankton dataset consists of 3.4 million images spread across 70 classes. We considered only those classes that have at least 50 images. Finally we obtained 38 classes and a total of 26612 images.
All the images were padded and resized to size 256 × 256. We used K-Fold cross-validation with K=5.

Baselines
To evaluate our method we perform experiments on the following baselines: 1. Standard Classification -We use a state-of-the-art classification network pre-trained on ImageNet dataset and fine-tune to our dataset. 2. Classification with triplet loss -Along with the cross-entropy loss, we use the triplet loss. This method is done to study the impact of inter-class similarity on the classification performance. 3. Classification with clustering -This is our proposed clustering method, but using only the cross-entropy loss for classification. This is used to study the impact of intra-class variance on the classification performance. 4. Classification with clustering and triplet loss -This is our proposed method to minimise the impact of both the inter-class similarity and the intra-class variance.

GS-TRS [6] -This method uses K-Means to divide each class into K clusters and uses triplet loss for inter-cluster and inter-class objects.
We perform our experiments on two classification model architectures: ResNet50 and EfficientNet.

Evaluation metrics
We evaluate the different approaches using the standard metrics used in classification, namely the classification accuracy, precision, recall, F-Score. A higher value of these metrics indicates a better performance. Additionally, we also calculate the variance of the per-class false-negatives and false-positives. The variance gives us a measure of how consistent the classification is and so a lower value is preferred.

Implementation Details
We use Adam optimizer and the learning rate is 0.0002 and we use a batch size of 128. The output feature embedding dimension from the network is 256. We trained our networks on GeForce GTX 1080 with 12 GB RAM. The value of max-allowed-clusters is set to 5. Our confusion-threshold is set to 0.3 based on hyper-parameter search. Table 1 shows the quantitative metrics for the diatom classification. Our results show that using both clustering and triplet loss consistently outperforms the other methods. One interesting conclusion from the results is that classification with clustering performs better than classification with triplet loss. This means that intra-class variance has a higher impact on the classification performance than the inter-class similarity. Finally, optimizing both the inter-class similarity and intra-class variance further improves the performance of the network. GS-TRS [6] is not well-suited for this application because the number of clusters generated are not optimal and over or under-clustering deteriorates the performance. For automatic classification of aquatic microorganisms, the certainty of prediction of a class is important which means that the false negatives should be minimal. Fig. 3(a) shows a zoomed version of the false negatives with 3 methods: standard classification, classification with clustering, and classification with clustering and triplet loss overlaid onto a single graph. From the plots, 120 classes are perfectly classified when using a state-of-the-art classifier whereas 140 classes are perfectly classified when using clustering with triplet loss. Also, the overall magnitude of the false negatives is reduced when using clustering and triplet loss than when compared to the other methods. This is a significant improvement since the network can reliably be used to identify a larger number of classes than before. Table 2 shows the quantitative metrics for classification on the WHOI-Plankton dataset. Similar to the diatoms, the clustering along with triplet loss outperforms the other methods. Fig. 3(b) shows the overlay plot of the false negatives.

WHOI-Plankton Dataset
In contrast to three classes that were perfectly identified by the state-of-theart classifier, clustering and triplet loss improves it to seven perfectly identified classes. One could observe from Fig. 3(b) that when using only clustering and when using clustering along with triplet loss, the false negative magnitude does not change much. This is due to the relatively lower number of classes in the WHOI-plankton dataset, which reduces the impact of the inter-class similarity.

Conclusion
In this paper, we proposed a method to tackle the inter-class similarity and intra-class variance due to discrete image subsets, which is commonly found in microscopic images. Our method automatically identifies the classes to be clustered and the optimal number of clusters to be generated. Then these clusters are considered as independent classes while training a classification network. Finally, to deal with the inter-class similarity, we use triplet loss to separate out the features between each class. Using this approach, the network was able to learn finer-grained features that improved the classification performance. This was validated using quantitative metrics on a diatom and a plankton dataset.