Abstract
Background: White blood cells (WBCs), also known as leukocytes, play a central role in immune defense, and accurate WBC classification is essential for a hematological assessment and computer-assisted diagnosis. However, a severe class imbalance remains a major challenge in deep-learning-based WBC classification, particularly when minority classes contain substantially fewer training samples. Although data augmentation is commonly used to address this issue, synthetic transformations may fail to capture the complex morphological and appearance variations of WBCs and may introduce redundant patterns and additional computational costs. Methods: This study proposes a hybrid ViT-ECA-CF framework with adaptive loss reweighting (ALR) for minority-class WBC classification without data augmentation. The framework integrates efficient channel attention (ECA) to enhance discriminative feature representations and color-feature fusion (CF) to jointly capture morphological and staining-related color information from WBC components, including the nucleus, cytoplasm, and granules. An adaptive loss-reweighting strategy dynamically adjusts class contributions according to class distribution, prediction loss, and prediction confidence, thereby directing model optimization toward challenging minority WBC classes. Results: On the evaluated WBC classification dataset, the proposed framework achieved a 90.00% accuracy, 94.49% macro-F1, and 93.98% balanced accuracy, with an F1-score of 96.43% for minority classes. The framework substantially reduced the majority-to-minority performance gap, achieving a minority-to-majority F1 balance ratio of 1.053, indicating a comparable recognition performance across classes despite the severe imbalance. The proposed approach was also evaluated on independent datasets and compared with a CNN baseline in terms of training time. Conclusions: The findings provide an effective strategy by combining transformer-based feature representation, ECA, color-feature fusion, and adaptive loss reweighting to improve minority-class WBC recognition without relying on synthetic data augmentation. The proposed approach offers a potential strategy for handling a severe class imbalance. Further validation on larger and multicenter datasets is required to establish the robustness and clinical applicability of the proposed framework.
1. Introduction
White blood cell (WBC) classification is essential for the accurate and early diagnosis of immune and blood-related disorders. Despite significant improvements in deep learning models, the classification of white blood cells remains a challenging task [1]. The availability of balanced datasets for WBC classification is a major concern, as WBC datasets contain fewer images of basophils as compared to neutrophils. Class imbalance occurs when some classes contain substantially fewer samples than others. In the Raabin–WBC training set, basophils are the least represented class and are therefore treated as a minority class [2,3]. Similarly, lymphocytes and neutrophils contain more images as compared to eosinophils and monocytes [4,5]. This class imbalance can lead to lower classification performance with minority classes while achieving higher performance for majority classes, which can affect medical diagnosis. Missing minority-class cells in several conditions, such as chronic myeloid leukemia [6] and diseases related to eosinophils [7], can lead to delayed or incorrect diagnoses. Some traditional approaches such as data augmentation and resampling can address this class imbalance [8,9]. Data augmentation generates additional images by applying different transformation techniques to images, such as flipping, rotation, or adjusting the color. Recent studies have also shown that domain-specific augmentation can improve WBC classification performance. However, the effectiveness of these methods can vary depending on the characteristics of the WBC dataset and the applied transformations [10]. In WBC classification, conventional transformations such as scaling or rotating may not always provide substantial additional morphological information because these transformations generally preserve the underlying cellular morphology. Moreover, these methods increase training time and storage requirements, which often results in overfitting, specifically on noisy or small datasets. These limitations highlight the need for alternative methods that avoid data augmentation and provide solutions to improve model efficiency in recognizing the WBCs’ minority class. The multi-pipeline strategy allows the models to focus on the morphological features that are critical for the accurate classification of minority-class cells. The vision transformer with efficient channel attention and color-feature fusion model is proposed, and it achieves a 96.43% F1-score on minority classes without data augmentation, unlike traditional methods that apply robust augmentation [11] techniques on data. In cross-data validation, it also performed better compared with augmentation-based models, which exhibit a notable reduction in overall results. These findings indicate that the ViT-ECA-CF model with adaptive loss reweighting improves generalization across varying conditions of clinical images. The dataset used in this study includes five WBC classes with an imbalanced sample distribution, with basophils being the least represented class compared with neutrophils [5], which highlights the importance of class-balanced training. The proposed model captures fine-grained features such as granular texture, nuclear shape, and chromatin density factors, which are often ignored by standard augmentation methods. The integration of the attention mechanism with an adaptive loss reweighting strategy improves the model’s interpretability and robustness for white blood cell classification. Future work may include explainability modules to visualize attention maps and reinforcement gradients to strengthen clinicians’ confidence in decision-making. Overall, ViT-ECA-CF with adaptive loss reweighting provides a reliable, augmentation-free approach that improves the recognition of minority classes and enhances generalization in real-world hematology applications.
2. Literature Review
White blood cell (WBC) image classification is still hampered by the issue of class imbalance, which increases the risk of biased learning and decreases generalization. In medical image analysis, many datasets are imbalanced [12]. Some cell types are low-abundance classes, including basophils and eosinophils. This disparity results in a model that favors the majority classes, which increases the need for diagnostic tools. Existing deep network techniques and data augmentation techniques exhibit less effectiveness and fail to capture a specific morphology in medical datasets [13]. Recent research has shown a shift toward adjusting training weights to deal with class imbalance, rather than relying completely on data augmentation [14]. In recent studies, adaptive loss functions have been introduced [15], which help rebalance learning for minority classes and reduce the dominance of majority classes during model training [16].
Cost-sensitive learning is another method used for balancing [17]. It assigns a higher cost to misclassified samples of the minority class than to misclassifying samples from the majority class. This leads to more directed, focused learning for the minority class [18]. Transfer learning has also driven developments in imbalanced medical imaging [19], as models pre-trained on rich and diverse datasets can be fine-tuned on smaller, class imbalanced datasets while retaining essential visual features and adapting to domain specific requirements. Chen et al. [20] used transfer learning plus focal loss to increase the classification accuracy on minority classes without the addition of any data augmentation techniques. Models learn details using these strategies while addressing imbalance-training data. Although GAN-based augmentation can improve the representation of minority classes [12], precautionary measures are required when using synthetic data in sensitive medical applications. Recent studies have highlighted that synthetic data may introduce artifacts or affect the fidelity required for clinical decision-making and emphasize the importance of improving core model learning alongside the use of synthetic images [21]. In addition, attention guided convolutional networks [22] and reinforcement-aware learning strategies have been examined in the last couple of years to improve class detection. These models claim to learn to attend to the most informative regions in an image, while also adapting based on class-specific feedback as they are trained on the respective training dataset [23]. Their approach incorporated reinforcement-aware learning and encouraged the exploration of minority-class features, which was promising, especially when the visual patterns for the minority class were subtle in the dataset. This is especially relevant in WBC image classification, where there is little variability between classes. However, even slight variations can be clinically significant. Another promising development is the use of meta-learning strategies [24]. These strategies enable models to learn class-aware decision boundaries across various tasks. An author introduced a meta-learning approach that was able to quickly adapt to few shot scenarios and improve the accuracy of the minority class in highly imbalanced medical datasets [25]. These meta models reduce dependence on large, balanced datasets while optimizing learning based on the problem’s structure, even when limited labeled data is available, as often observed in the cases of clinical contexts. Cross-dataset validation has become a recent research focus to evaluate the generalization performance of imbalance-aware models.
Two models for WBC classification avoided augmentation and performed better on independent datasets, e.g., LISC, BCCD, and Raabin–WBC [26]. These models ensure a better accuracy with strong robustness and transferability, which are important requirements for a reliable diagnostic system. Furthermore, high accuracy alone is misleading if the classes are imbalanced, as it is often dominated by majority classes, making them less sensitive to minority classes. Researchers now use metrics such as the precision, recall, AUC, and F1-score to evaluate the performance more effectively on minority classes, rather than relying solely on accuracy [27]. A model that achieves a high accuracy may still fail to recognize rare disease conditions if minority classes are poorly represented. There has been a new emphasis on balancing the performance across all classes, not just the majority classes, especially in life-critical areas such as the detection of hematological diseases.
Kasprowicz and Silva [28] showed that vision transformer (ViT) models were compared with YOLOv11 variants for the classification of leukocyte classes using a private 14-class dataset, and the effect of HistAuGAN-based color augmentation was also evaluated. Similarly, Uddin et al. developed a lightweight model using Efficient Channel Attention (ECA) for five-class WBC classification, demonstrating that channel attention enhances the discriminatory power of features and the model was evaluated for robustness across different datasets with a lower computational cost [29]. Moreover, Ayesha and Khalidi proposed a self-attention-based Vision Transformer which was able to capture the long range dependencies in the blood cell images, producing a high classification accuracy [30]. Although these developments have taken place, current works are based on different strategies, including classical loss functions, fixed sampling approaches, data augmentation, attention mechanisms, and feature-based methods, to address class imbalance. However, the combined use of channel attention, handcrafted color features, and adaptive loss reweighting to tackle the class imbalance remains less explored. This constraint inspires the proposed ViT-ECA-CF with an Adaptive Loss Reweighting (ALR) framework to enhance the minority-class recognition ability while preserving a high overall classification accuracy. The literature shows that different strategies, including data augmentation, model benchmarking, and cross-dataset evaluation, have been explored for blood cell classification [31]. These studies do not establish a general superiority of augmentation-free methods over GAN- or SMOTE-based approaches. Rather, they indicate that different strategies may be suitable depending on the dataset and classification setting. Therefore, instead of assuming that augmentation is unnecessary, this study investigates an augmentation-free strategy that focuses on improving the model to learn distinguishing features from the original images. In summary, the literature reflects the use of both augmentation-based and augmentation-free approaches in handling a class imbalance in WBC image classification. This includes methods such as cost-sensitive loss, attention-guided learning, meta-learning, ensemble fusion, data augmentation, and cross-dataset validation. The overall results set the basis for reliable and clinically applicable models, motivating the current research to build an augmentation-free architecture that integrates channel attention, color feature fusion, and adaptive loss reweighting. The literature review is summarized in Table 1, which includes augmentation-based, transfer-learning, cost-sensitive, meta-learning, and attention-based methods.
Table 1.
Comparative summary of the literature review.
This research addresses critical gaps in the existing research on performance transparency in imbalanced datasets. Previous studies have reported class-wise performance metrics, including F1 scores, for WBC classification. However, comparatively limited attention has been given to explicitly analyzing the balance of the F1 performance between majority and minority classes. This study is a clear example of displaying class-wise F1 score matrices, which provide detailed information about performance that may not be apparent from the overall accuracy. Rather than claiming that class-wise F1 reporting is absent from the literature, we introduce and report the F1 Balance Ratio to measure the evenness of the spread of performance across the majority and minority classes. One notable finding is that significantly improved performance was achieved by the proposed vision transformer variants. The F1 score obtained by these ViT variants for the minority class ranges from 56.52% to 96.43, showing that these variants can address a class imbalance more efficiently while improving the minority-class performance compared with existing CNN methods. Existing techniques may present a high overall accuracy without sufficiently emphasizing the balance of performance across individual classes. In contrast, this transformer architecture demonstrates the class-wise performance and balance between majority and minority classes. The majority–minority F1 balance ratio presents an additional quantitative measure of the balance between class-wise performance, providing complementary information to the class-wise F1 scores.
The proposed work addresses critical gaps in the existing methods. The literature shows the overall accuracy while the proposed work reports the class-level performance analysis. This study explicitly shows minority-class F1 scores and the balance ratio to analyze the performance equity across imbalanced classes. This study shows a substantial improvement in minority classes.
3. Research Gaps and Contributions
The main research gaps identified from the literature and the corresponding contributions of the proposed framework are summarized in Table 2. This comparison demonstrates how the proposed approach addresses the key limitations of existing methods.
Table 2.
Summary of research gaps addressed and proposed contributions.
The main contributions of this research are as follows:
- A novel strategy is proposed that replaces traditional augmentation to reduce feature redundancy and avoid training overload in the WBC dataset. The hybrid learning pipeline combines patch-level-feature fusion with adaptive loss reweighting to enhance model training efficiency, reduce redundancy, and provide focused learning from authentic image of white blood cells.
- An attention mechanism is used, which helps the network to focus on particular visual patterns of each class. A hybrid feature extraction method is used to extract the various morphological features according to the different types of WBCs, and optimization focuses on color features that are important for distinguishing overlapping or similar-looking cells.
- An Efficient Channel Attention (ECA) block is integrated to enhance feature robustness by emphasizing important channel-wise information. This reinforcement helps the model to learn discriminative patterns and increase its generalization capability and boost its accuracy, particularly for the complex and minority WBC classes.
- This paper proposed an Adaptive Confidence-Aware Loss Reweighting strategy, which dynamically adjusts class weights during training based on the class imbalance, difficulty of classification, and prediction confidence. The adaptive weights are integrated into the cross-entropy loss, enabling the model to emphasize underrepresented and difficult samples while preserving balanced learning across all classes.
4. Materials and Methods
This research proposed a model to classify white blood cells while handling class imbalance by enhancing the model’s performance to accurately classify minority cell types without compromising its classification performance on majority cell types. First, each input image is processed and divided into appropriate patches that are then processed further by a dual-branch extractor. One branch extracts structural feature of the images using ResNet-18, which are further refined by Efficient Channel Attention (ECA) block to highlight important morphological patterns in the image. The second branch extracts color features from the image. The extracted features from both branches are combined to form a 515-dimensional token. This fusion ensures that both the low-level color variations and the high-level structural changes are properly utilized during training. The resulting fused patches are passed to a Vision Transformer (ViT) encoder, where a self-attention mechanism extracts further relationships between the patches. Furthermore, focal loss and weighted random sampling are used during training to handle the class imbalance problem, which prioritizes minority class samples without affecting the majority class. Overall, the step-by-step workflow is illustrated in Figure 1.
Figure 1.
Proposed efficient channel attention and color feature fusion.
All input images are first resized to a uniform dimension of 224 by 224 pixels. This resolution maintains compatibility across models while also keeping the subcellular details intact. This standard sizing for images enables the model to train efficiently using batching and avoid scale-induced bias during patch tokenization or convolution. Various normalization techniques are applied to ensure consistency across the images. Moreover, each pixel in the image is rescaled to have a mean and standard deviation σ for the entire image as follows:
The changes ensure a consistent and similar distribution across the input channels (R, G, and B), improving the model convergence during training of the model. The resulting images are subsequently fed into the modified Vision Transformer [35] with feature extraction modules such as morphology, color, chromatics, and contextual reasoning, which are called Efficient Channel Attention and Color Fusion (ViT-ECA-CF). In the first step, model divides an input RGB image into non-overlapping patches of size . Each image results in patches. Each patch retains local spatial and color information essential for WBC classification. Each patch is passed through a dual-branch feature extractor to extract features from five distinct classes of WBC. ResNet-18 is used due to its capacity to learn hierarchical spatial patterns in image data. Let the input image be represented by , where and represent the height, width, and number of channels, respectively. The convolutional operation applied at layer is mathematically defined as follows:
where is the input feature map from the previous layer, represents the learnable convolutional kernel of size , is the bias term, ∗ denotes the convolution operator, and is a non-linear activation function (typically ReLU). Each feature map captures spatially localized patterns that help distinguish between the morphological attributes of different WBC classes (e.g., nucleus shape, granularity, and texture). To reduce spatial dimensions and retain dominant features, a pooling operation—typically max pooling—is applied after selected convolutional layers, as shown below:
Here, represents the window size.
The efficient channel attention (ECA) block is integrated into the proposed architecture without introducing more complexity in convolutional neural networks to enhance the capabilities of CNNs. Unlike existing methods that enhance attention using fully connected layers equipped with large number of parameters, the ECA block uses a local cross-channel interaction strategy to capture channel-wise dependencies. Let be the output feature map from a convolutional layer, where C is the number of channels, and H, W represent the spatial dimensions. The ECA block operates on global average pooling, Local Cross-Channel Interaction via 1D Convolution, and Channel-Wise Recalibration. Global average pooling is applied across the spatial dimensions to compress the feature map into a channel-wise descriptor, which can be represented as follows:
This results in a vector representing the global statistics of each channel. Instead of using a fully connected layer, ECA introduces a 1D convolution with a kernel size k (an odd number, e.g., 3 or 5) to learn the attention weights across local channel neighborhoods, which is mathematical represented as follows:
where Conv1Dk is a 1D convolution of kernel size k, σ(·) denotes the sigmoid activation function, and a ∈ ℝC is the learned attention weight vector. The kernel size k is adaptively defined as follows:
where γ and b are hyper-parameters (commonly γ = 2, b = 1), and the operation returns the nearest odd integer. The original feature map is reweighed by the attention vector through channel-wise multiplication: , resulting in , the refined feature map with enhanced informative channels and suppressed less-relevant ones. The final convolutional layer output is flattened into a feature vector , where denotes the total number of extracted features.
A dedicated branch for the color feature extraction process analyzes the input image in various color spaces to capture difference in the cytoplasm and nucleus of different types of white blood cells. This process helps to capture the morphological features of the image, which are difficult to capture using convolutional filters. Given an input RGB image , it is first converted into alternative color spaces such as HSV and Lab to extract perceptually relevant color components: LAB is a perceptually uniform color space that separates luminance (L*) from color information (a*: green–red, b*: blue–yellow), mimicking human color perception. LAB gives Vision Transformers superior color discriminability and invariance to lighting variations by separating brightness from chrominance and using the attention mechanism to capture perceptually meaningful color differences rather than device-dependent RGB difference.
For each channel , we compute first-order statistical descriptors to quantify the global color distribution: mean , standard deviation , skewness , and kurtosis . Mean is defined as the mean intensity value for a specific color channel c (e.g., R, G, or B) in an image, which is calculated using as follows:
whereas standard deviation is computed by averaging all pixel values across the spatial dimensions as shown below:
where H and W represent the image height and width for a given color channel c. Skewness measures the spread or dispersion of pixel values around the mean calculated across all spatial positions in an image of size H × W, defined as follows:
where skewness represents the pixel intensity distribution for a color channel c, quantifying the asymmetry of the distribution. Kurtosis is calculated by averaging the fourth power of the normalized deviation of each pixel value from the mean , scaled by the standard deviation , over the entire image of size H × W as shown below:
where defines the kurtosis of pixel intensities for a specific color channel c, which measures the tailedness or peakedness of the distribution; the histogram is computed by taking the average of the fourth power of the standardized pixel intensity deviations from the mean normalized by the standard deviation across the entire image of size H × W. Histograms with fixed bin size b (e.g., ) are constructed for each color channel, defined as follows:
where δk (·) is an indicator function that returns 1 if the pixel intensity falls within the kth bin range, and 0 otherwise. The extracted features from all color channels are concatenated to form a comprehensive high-dimensional color feature vector . Given nine channels across RGB, HSV, and Lab, with four statistical descriptors and histogram bins per channel, the resulting feature dimension is . This high-dimensional color feature vector is passed through a fully connected layer to obtain a compact 3-dimensional color representation Fcolor ∈ . The resulting 3-dimensional color representation is then concatenated in parallel with the 512-dimensional CNN feature representation to produce a 515-dimensional patch token, which represents both structural and color features.
A learnable [CLS] token is inserted at the beginning of this resulting sequence of patch tokens, where This token serves as the global representation for classification. Additionally, a learnable positional encoding is added to the token sequence to preserve spatial relationship as follows:
This enriched sequence is passed into the Vision Transformer (ViT) Encoder, which contains a multi-head self-attention layer and a feedforward layer to capture long-range dependencies across patches and global information in [CLS] tokens. Each patch token has a dimension of 515, obtained by concatenating the 512-dimensional CNN feature vector with the 3-dimensional color feature vector. The final [CLS] token output (a vector of dimension d = 515) is passed into a fully connected (linear) layer to produce predicted logits for each class, where is the final [CLS] representation from the encoder, is the weight matrix of the classifier, is the classifier bias, and are the raw logits for classes.
A confidence-aware adaptive loss reweighting strategy is introduced to dynamically adjust the contribution of each class during model optimization. Unlike conventional weighted Cross-Entropy loss, where class weights are computed once based on the training distribution and remain fixed throughout the learning process, the proposed approach continuously updates class weights according to the learning behavior of the network. The adaptive mechanism considers three factors: (1) class distribution, (2) class-wise learning difficulty, and (3) prediction confidence. This enables the model to automatically allocate greater importance to underrepresented and difficult-to-classify WBC categories.
Initially, class weights are calculated based on the number of samples available in each class. For a dataset containing classes, the initial weight for class is defined as follows:
where represents the number of training samples in class , denotes the sample count of the majority class, and is a scaling parameter controlling the impact of class imbalance.
During training, the ViT-ECA model generates predictions for each input image, and class-wise loss and prediction confidence are recorded. The average loss of each class represents the learning difficulty, while the average confidence indicates how reliably the model recognizes that class. Based on these parameters, the class weights are dynamically updated after each epoch as follows:
where is the updated weight for class at epoch , represents the average classification loss of class during epoch , and denotes the average prediction confidence for correctly classified samples of class . The parameters and control the contribution of classification difficulty and prediction uncertainty, respectively. The values of and are set to 0.5, weight minimum is 0.2, and weight maximum is 5.
The dynamically updated weights are incorporated into the Cross-Entropy objective function:
where represents the ground-truth label and denotes the predicted probability for class .
During each training epoch, the model first learns discriminative features through the ViT-ECA architecture. The obtained predictions are then used to compute class-wise loss and confidence statistics. At the end of every epoch, the proposed adaptive module recalibrates the class weights, which are subsequently used in the next optimization cycle. Therefore, the proposed strategy allows the model to progressively focus on challenging minority classes while reducing unnecessary emphasis on already well-learned majority classes. The complete optimization procedure is summarized in Algorithm 1.
| Algorithm 1: Adaptive Loss Reweighting for ViT-ECA Optimization |
| Input: Training dataset , Number of classes , ViT-ECA model parameters , Number of training epochs , Hyperparameters Output: Optimized ViT-ECA model parameters Step 1: Initial Class Weight Computation
a. Mini-batch Processing
|
5. Results and Discussion
A comparative analysis of the proposed ViT-ECA-CF model and seven existing CNN models using imbalanced dataset is presented in this section. The results are obtained in terms of Precision, Recall, Accuracy, and F1 score. Additionally, the performance of each class separately, ablation studies, and Grad Cam visualizations are also presented to show the model’s effectiveness and interpretability. The experimental setup used in this research includes the workstation having an NVIDIA GeForce RTX 3060 GPU, 12 GB VRAM, 32 GB DDR4 RAM, and Intel Core i5-12400F processor, transformer architectures, scikit-learn used for performance evaluation, and PIL for image handling. In addition, a modified Vision Transformer was employed that used ResNet-18 as the patch feature extractor, followed by ECA and Transformer-based feature processing. Input WBC images were resized to 224 × 224 pixels and partitioned into 16 × 16 non-overlapping patches, resulting in 196 patch tokens. The learnable class (CLS) token along with the learnable positional embeddings was appended before Transformer encoding. The Transformer encoder consisted of 12 encoder layers, each comprising 12 multi-head self-attention heads with a head dimension of 64, followed by a feed-forward network with a hidden dimension of 3072 and GELU activation. Pre-Layer Normalization and residual skip connections were employed throughout the encoder blocks. To enhance discriminative channel-wise feature representation, an Efficient Channel Attention (ECA) module was incorporated to enhance the discriminative channel-wise feature representation with its adaptive kernel selection parameters γ = 2 and b = 1, resulting in a 1D convolution kernel size of 5, followed by sigmoid activation to generate channel attention weights.
The model was initialized with ImageNet pretrained weights and optimized using the Adam optimizer with a learning rate of 1 × 10−4. Training was performed for 20 epochs using a batch size of 32. To compare the impact of different loss functions on class imbalance learning, the proposed architecture was trained using cross-entropy, weighted cross-entropy, and focal loss (γ = 2.0). The proposed adaptive loss reweighting function initializes class weights based on the inverse class frequency computed from the training set. These weights are subsequently updated after each training epoch using class-wise learning difficulty and prediction confidence, allowing the weighted Cross-Entropy loss to dynamically adjust the contribution of each class during optimization. The proposed ViT-ECA framework was primarily trained and evaluated using the Raabin-WBC dataset [5] which has high-resolution microscopic images. The peripheral blood smears shown in the dataset are classified into five main categories of leukocytes presented in Table 3.
Table 3.
Data description and description of minority and majority classes.
As the Raabin–WBC dataset provides predefined training and testing partitions, k-fold cross-validation was performed on the predefined training set. The model was trained using the predefined training set within the cross-validation procedure, while Test-A and Test-B were kept separate and used only for evaluation, ensuring consistency with the original dataset protocol. To assess the generalization capability of the proposed framework, an independent evaluation was conducted using the predefined Test-B subset of the Raabin–WBC dataset. Test-B contains double-labeled neutrophil and lymphocyte images acquired under different imaging conditions from the training data, making it suitable for assessing robustness under an unseen acquisition setting. The Test-B images were not used during cross-validation, model training, or model selection, and served solely as an independent evaluation set. To further validate the proposed framework, experiments were also performed on the LISC dataset. Since LISC is primarily designed for leukocyte segmentation and classification, the white blood cells were first cropped from the original images using the available annotations before being provided as input to the trained ViT-ECA model. The LISC dataset was used exclusively for external validation, and no images from this dataset were included during cross-validation, training, or model selection.
To assess the robustness and reproducibility of the proposed framework, the comparative experiments between the strongest baseline (ResNet50) and the proposed ViT-ECA-CF model were repeated five times using different random initialization seeds while maintaining identical data splits and hyperparameter settings. The results are reported as mean ± standard deviation (SD). Statistical significance was evaluated using the Wilcoxon signed-rank test, with p < 0.05 considered statistically significant. Table 4 provides a summary of the class-wise performance of the tested baseline CNN architectures on the imbalanced WBC dataset, without any data augmentation, offering a summarized comparison of overall performance, F1-scores, and the majority–minority class behavior. Furthermore, this table provides a quantitative standardization of the trends in comparison above, offering insight into the performance differences among architectures and cell types under the same training conditions. Additionally, Figure 2 shows the comprehensive model performance comparison using metric heatmaps and F1-score rankings.
Table 4.
Class-wise performance comparison of baseline CNN architectures on the imbalanced WBC dataset without data augmentation.
Figure 2.
Comprehensive performance comparison: annotated metric heatmap and F1-score ranking.
Table 5 presents the results of the ablation study on the proposed ViT-ECA-CF model, which isolates the impact of each architectural and training mechanism on performance by class and overall. The table serves as a quantitative reference in a structured format, outlining successive design decisions regarding the model’s behavior under the same experimental conditions.
Table 5.
Ablation study of proposed ViT-ECA-CF architecture showing the impact of each component (ECA, CF, Focal Loss, Adaptive Loss reweighting, and Weighted Sampling) on class-wise and overall performance.
In addition, Figure 3 shows the proposed variant demonstrates a balanced overall classification performance.
Figure 3.
Overall performance comparison of the evaluated ViT model variants.
Table 6 and Table 7 provide a consolidated comparison between CNN baselines and proposed ViT-based architectures. Among CNN models, ResNet50 achieves the highest performance with 87.58% accuracy and 89.58% F1-score but maintains a 10.89% majority-minority gap. The proposed ViT-ECA-CF achieves the highest accuracy (96.50%) with a minimal gap of 1.51%.
Table 6.
Performance comparison of proposed ViT-ECA-CF variants with state-of-the-art CNN methods on WBC classification. WCE = Weighted Cross Entropy, WS = Weighted Sampling, FL = Focal Loss, ALR = Adaptive Loss Reweighting. A negative gap indicates that the minority F1 score exceeds the majority F1 score. In addition, plus (+) represent the word “with”.
Table 7.
Class-wise F1-score comparison between the best CNN baseline (ResNet50) and the proposed models.
The gap for ViT-ECA-CF with adaptive loss reweighting is inverted to −4.83%, with an F1-score of 96.43% for minority classes, which is the best among all considered models. The results show that architectural innovation (ECA and CF) is an effective solution for the class imbalance problem in WBC classification. Incorporating ECA maintains competitive accuracy while providing a better handling of class attention, although minority classes remain slightly weaker. Further, adding color features significantly improves basophil recognition and enhances class-specific representation, even though the overall accuracy decreases. The use of focal loss further balances class weights, resulting in a better recall for minority classes and fair performance across classes. The complete ViT-ECA-CF model not only provides stability for majority classes but also enhances the recognition performance of minority classes and obtains a well-balanced trade-off. Finally, the use of weighted sampling and Adaptive Loss Reweighting gives a significantly large improvement in the F1 score of the minority class, along with a high performance for the majority class, thus contributing to strong generalization and proving the effectiveness of the proposed approach for solving the class imbalance. Table 8 presents a comprehensive performance comparison of existing CNN architectures and the proposed ViT-based variants, evaluated across accuracy, precision, recall, and F1-score metrics, with a specific emphasis on the performance disparities between majority and minority classes. The proposed ViT-based framework substantially enhances minority-class detection on severely imbalanced datasets. By incorporating ECA attention, color features, focal loss, weighted sampling, and adaptive loss, model variants achieve significant improvements across all metrics. Compared to the best-performing CNN baseline (ResNet50, 80.37% minority F1-score), ViT-ECA-CF with weighted sampling and Adaptive Loss Reweighting achieves a 96.43% minority F1-score, representing a 16.06 absolute improvement. Concurrently, the framework achieves an overall F1-score of 94.49%, an accuracy of 90.00%, a precision of 98.39%, and a recall of 86.72%, demonstrating a well-balanced classification performance. These results confirm that the proposed approach effectively addresses extreme class imbalance while maintaining strong performance across both minority and majority classes. The F1 balance ratio in Table 8 is calculated using the formula given in Equation (16).
Table 8.
Comparison with existing base models and proposed model variants.
To further investigate the feature learning capability of the proposed framework, Table 9 compares the Grad-CAM activation maps of ResNet-50 and the proposed ViT-ECA model.
Table 9.
Grad-CAM visualization on white blood cell images.
Table 10 provides a comparative analysis of the proposed model with the best existing model, using both augmented (random rotation, vertical/horizontal flip, random cropping and resizing, contrast adjustment, and color jitter) and non-augmented data. The proposed model achieves a very high precision, recall, and F1-scores, and its classification performance is strong and reliable. The results demonstrate that the proposed method improves predictive performance while reducing computational cost, especially in the non-augmented setting. In addition, the proposed ViT-ECA-CF model consistently outperformed the strongest CNN baseline (ResNet50) under both augmented and non-augmented settings. The low standard deviations across fifteen independent runs indicate stable and reproducible performance, while the Wilcoxon signed-rank test confirmed that the observed improvements were statistically significant (p < 0.05). Figure 4 shows the graphical representation of the augmented and non-augmented dataset settings.
Table 10.
Comparison of the under augmented and non-augmented dataset settings.
Figure 4.
Comparative evaluation model under augmented and non-augmented dataset settings.
Table 11 shows the proposed model performance on LISC dataset. The reduction in performance on LISC is primarily attributable to a cross-dataset distribution shift, including differences in imaging conditions, staining characteristics, and cellular morphology. Despite these variations, the model maintained relatively strong recall and Macro-F1, indicating that the learned discriminative representations retain a substantial generalization capability on an independent dataset.
Table 11.
Cross-dataset validation performance of ViT-ECA-CF with Adaptive Loss Reweighting on the LISC dataset.
The proposed framework is compared with recent state-of-the-art methods in terms of computational complexity and robustness in Table 12. With 85.8 M parameters and 33.6 G FLOPs, the proposed model gives competitive computational efficiency among the compared approaches and achieves the lowest inference time (8.8 ms), making it suitable for real-time clinical applications. Moreover, the proposed framework demonstrates good generalization ability when tested on the Raabin–WBC, Test-B, and LISC datasets, demonstrating its robustness in various imaging conditions.
Table 12.
Comparison of the proposed method with recent state-of-the-art WBC classification methods in terms of computational requirements, efficiency, and robustness.
6. Conclusions and Future Directions
A Vision-Transformer-based Efficient Channel Attention with Adaptive Loss Reweighting framework is proposed in this research for the classification of minority white blood cell classes under severe class imbalance. The proposed technique enhances minority class learning by combining the global representation capability of ViT with Efficient Channel Attention and adaptive loss reweighting, thereby preserving the original data distribution while avoiding data augmentation. Experimental results show that the proposed technique achieved a 96.43% F1 score of the minority class, significantly improved minority-class recognition, reduced the performance gap between majority and minority classes, and showed an improved minority-class performance compared with the selected CNN baselines. A cross-dataset evaluation further demonstrated the robustness and generalization capability of the proposed framework across different imaging conditions. Additionally, the evaluation on Test-B and LISC provided additional evidence of the model performance under different imaging conditions. Although these results are promising, prospective clinical validation on diverse patient populations is still required before routine real-world clinical deployment. Grad-CAM visualizations provided qualitative insight into the regions contributing to the model predictions. Despite the promising performance of the proposed framework, several limitations remain. The model may experience reduced performance on low-quality images, staining variations, imaging artifacts, overlapping cells, or rare white blood cell morphologies that are underrepresented in the training data. In addition, visually similar leukocyte subtypes with subtle morphological differences may still be challenging to distinguish, potentially leading to misclassification. Further validation on larger multicenter clinical datasets, including prospective evaluation and patient-level analysis, is required before assessing clinical applicability. Future work will investigate more advanced adaptive loss optimization and hybrid data-balancing strategies to further enhance the complementary strengths of adaptive loss reweighting and sampling under extreme class imbalance. The framework will also be extended to classify additional white blood cell subtypes using larger multicenter datasets. Furthermore, lightweight transformer architectures, multimodal clinical information, enhanced explainability techniques, and prospective multicenter clinical validation will be explored to improve the real-world reliability and clinical applicability of the proposed framework.
Author Contributions
Conceptualization, F.J. and J.H.S.; methodology, F.J., J.H.S. and M.A. (Muhammad Awais); software, J.H.S. and M.A. (Maira Afzal); validation, F.J., M.A. (Maira Afzal) and M.A. (Muhammad Awais); formal analysis, F.J. and J.H.S.; investigation, F.J., J.H.S. and M.A. (Maira Afzal); data curation, J.H.S. and M.A. (Maira Afzal); writing—original draft preparation, F.J., J.H.S. and M.A. (Muhammad Awais); writing—review and editing, M.A. (Maira Afzal) and M.A. (Muhammad Awais); visualization, M.A. (Maira Afzal) and J.H.S.; supervision, M.A. (Muhammad Awais); project administration, M.A. (Muhammad Awais). All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
The datasets used in this study are publicly available. The code in the repository at https://github.com/jhshah101/Blood-Cell-Disorder-Detection (accessed on 1 May 2026).
Acknowledgments
The researchers would like to thank the Deanship of Graduate Studies and Scientific Research at Qassim University (https://www.qu.edu.sa) for financial support (QU-APC-2026).
Conflicts of Interest
The authors declare no conflicts of interest.
Abbreviations
The following abbreviations are used in this manuscript
| Symbol | Stands for |
| WBC | White Blood Cell |
| ViT | Vision Transformer |
| ECA | Efficient Channel Attention |
| CF | Color Features |
| ALR | Adaptive Loss Reweighting |
| WS | Weighted Sampling |
| WCE | Weighted Cross-Entropy |
| FL | Focal Loss |
| Baseline ViT | Vision Transformer without additional enhancements |
| ViT + ECA + WS | Vision Transformer with Efficient Channel Attention and Weighted Sampling |
| ViT + ECA + CF | Vision Transformer with Efficient Channel Attention and Color Features |
| ViT-ECA-CF + ALR | Proposed Hybrid ViT-ECA framework with Adaptive Loss Reweighting |
References
- Asghar, R.; Kumar, S.; Shaukat, A.; Hynds, P. Classification of white blood cells (leucocytes) from blood smear imagery using machine and deep learning models: A global scoping review. PLoS ONE 2024, 19, e0292026. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Asghar, R.; Shaukat, A.; Akram, U.; Tariq, R. Automatic Classification of White Blood Cell Images Using Convolutional Neural Network. arXiv 2024, arXiv:2409.13442. [Google Scholar]
- Oybek Kizi, R.F.; Armand, T.P.T.; Kim, H.-C. A review of deep learning techniques for leukemia cancer classification based on blood smear images. Appl. Biosci. 2025, 4, 9. [Google Scholar] [CrossRef] [Scilit]
- Ashour, A.S.; Wahba, M.A.; Ghannam, R. A cascaded classification-segmentation reversible system for computer-aided detection and cells counting in microscopic peripheral blood smear basophils and eosinophils images. IEEE Access 2021, 9, 78883–78901. [Google Scholar] [CrossRef] [Scilit]
- Kouzehkanan, Z.M.; Saghari, S.; Tavakoli, E.; Rostami, P.; Abaszadeh, M.; Mirzadeh, F.; Shahabi Satlsar, E.; Gheidishahran, M.; Gorgi, F.; Mohammadi, S.; et al. Raabin-WBC: A large free access dataset of white blood cells from normal peripheral blood. bioRxiv 2021. [Google Scholar] [CrossRef] [Scilit]
- Jabbour, E.; Kantarjian, H. Chronic myeloid leukemia: A review. JAMA 2025, 333, 1618–1629. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Sutabri, T.; Putra, C.A. White Blood Cell Classification Using SMOTE-SVM Method with Hybrid Feature Extraction and Image Segmentation Using Gaussian Mixture Model. ECTI Trans. Comput. Inf. Technol. 2025, 19, 75–87. [Google Scholar] [CrossRef] [Scilit]
- Gao, W.; Lan, L.; Fan, X. DaNet: Domain-adaptive white blood cell classification through synthetic augmentation and cross-domain feature alignment. Array 2025, 26, 100416. [Google Scholar] [CrossRef] [Scilit]
- Abidoye, I.; Ikeji, F.; Coupland, C.A.; Calaminus, S.D.; Sander, N.; Sousa, E. Platelets Image Classification Through Data Augmentation: A Comparative Study of Traditional Imaging Augmentation and GAN-Based Synthetic Data Generation Techniques Using CNNs. J. Imaging 2025, 11, 183. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Pandey, M.; Shrivastava, A. White Blood Cell Classification Using Vision Transformer Model. In Proceedings of the 2024 First International Conference on Data, Computation and Communication (ICDCC); IEEE: Piscataway, NJ, USA, 2024; pp. 367–373. [Google Scholar]
- Ferreira, F.R.T.; do Couto, L.M. Using deep learning on microscopic images for white blood cell detection and segmentation to assist in leukemia diagnosis. J. Supercomput. 2025, 81, 410. [Google Scholar] [CrossRef] [Scilit]
- Ding, H.; Huang, N.; Wu, Y.; Cui, X. Improving imbalanced medical image classification through GAN-based data augmentation methods. Pattern Recognit. 2025, 166, 111680. [Google Scholar] [CrossRef] [Scilit]
- Hays, P. Artificial intelligence in cytopathological applications for cancer: A review of accuracy and analytic validity. Eur. J. Med. Res. 2024, 29, 553. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Xu, F.; Yang, F.; Li, X.; Zhang, X. A Unified Loss for Handling Inter-Class and Intra-Class Imbalance in Medical Image Segmentation. Proc. AAAI Conf. Artif. Intell. 2025, 39, 8842–8850. [Google Scholar] [CrossRef] [Scilit]
- Dzikunu, O.K.; Ahamed, S.; Toosi, A.; Li, X.; Rahmim, A. Adaptive voxel-weighted loss using L1 norms in deep neural networks for detection and segmentation of prostate cancer lesions in PET/CT images. arXiv 2025, arXiv:2502.02756. [Google Scholar]
- Chen, Y.; Huang, Q.; Wang, Z.; Geng, M. ACANet: Adaptive Contour Aware Nucleus Segmentation Network. Biomed. Signal Process. Control 2025, 104, 107575. [Google Scholar] [CrossRef] [Scilit]
- Shawon, M.T.R.; Shibli, G.S.; Ahmed, F.; Joy, S.K.S. Explainable cost-sensitive deep neural networks for brain tumor detection from brain MRI images considering data imbalance. Multimed. Tools Appl. 2025, 84, 43615–43642. [Google Scholar] [CrossRef] [Scilit]
- Araf, I.; Idri, A.; Chairi, I. Cost-sensitive learning for imbalanced medical data: A review. Artif. Intell. Rev. 2024, 57, 80. [Google Scholar] [CrossRef] [Scilit]
- Kumar, A.; Nelson, L. Deep Learning-based Blood Cell Classification Using EfficientNetB3 Architecture. In Proceedings of the 2025 6th International Conference on Mobile Computing and Sustainable Informatics (ICMCSI); IEEE: Piscataway, NJ, USA, 2025; pp. 954–960. [Google Scholar]
- Chen, B.; Qin, F.; Shao, Y.; Cao, J.; Peng, Y.; Ge, R. Fine-grained imbalanced leukocyte classification with global-local attention transformer. J. King Saud Univ. Comput. Inf. Sci. 2023, 35, 101661. [Google Scholar] [CrossRef] [Scilit]
- van Breugel, B.; Liu, T.; Oglic, D.; van der Schaar, M. Synthetic data in biomedicine via generative artificial intelligence. Nat. Rev. Bioeng. 2024, 2, 991–1004. [Google Scholar] [CrossRef] [Scilit]
- Hasen, A.E.; Shangming, Y.; Ukwuoma, C.C.; Gashaw, B.; Yutra, A.Z. ABCD: Automatic Blood Cell Detection via Attention-Guided Improved YOLOX. arXiv 2025, arXiv:2507.19296. [Google Scholar]
- Khan, S.U.R.; Asim, M.N.; Vollmer, S.; Dengel, A. Robust & Precise Knowledge Distillation-Based Novel Context-Aware Predictor for Disease Detection in Brain and Gastrointestinal. arXiv 2025, arXiv:2505.06381. [Google Scholar]
- Margret, I.N.; Rajakumar, K. Deep learning techniques for analyzing peripheral blood smears: A meta-analysis. Neural Comput. Appl. 2025, 37, 18039–18065. [Google Scholar] [CrossRef] [Scilit]
- Pratellesi, C. Meta Learning for Blast Cell Classification in Flow Cytometry Data Using MAML and Transformer Models; Technische Universität Wien: Vienna, Austria, 2024. [Google Scholar]
- Balasubramanian, K.; Gayathri Devi, K.; Ramya, K. Classification of white blood cells based on modified U-Net and SVM. Concurr. Comput. Pract. Exp. 2023, 35, e7862. [Google Scholar] [CrossRef] [Scilit]
- Choudhary, S.; Kumar, S.; Siddhaarth, P.S.; Charitasri, G.; Gulhane, M.; Rakesh, N.; Mon, F.A.; Al-Rasheed, A.; Getahun, M.; Soufiene, B.O. Advancing blood cell detection and classification: Performance evaluation of modern deep learning models. BMC Med. Inform. Decis. Mak. 2025, 25, 207. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Kasprowicz, J.; Silva, A.G. Comparative analysis of convolutional and vision transformer models for automated leukocyte classification enhanced by generative color augmentation. Signal Image Video Process. 2026, 20, 286. [Google Scholar] [CrossRef] [Scilit]
- Uddin, R.; Melon, M.M.H.; Kazi, S.R.; Nobel, M.N.A.; Rahman, M.M.; Biswas, D.; Keneni, R. Lightweight efficient channel attention network for cross dataset white blood cell classification. Discov. Artif. Intell. 2026, 6, 790. [Google Scholar] [CrossRef] [Scilit]
- Ayesha, N.; Khalidi, H. A Vision Transformer with a Self-Attention Mechanism for High-Accuracy Blood Cell Classification. Eng. Technol. Appl. Sci. Res. 2026, 16, 32557–32563. [Google Scholar] [CrossRef] [Scilit]
- Chen, Y.; Chen, Z.; An, Y.; Lu, C.; Qiao, X. DAFFNet: A dual attention feature fusion network for classification of white blood cells. Biomed. Signal Process. Control 2025, 106, 107699. [Google Scholar] [CrossRef] [Scilit]
- Davamani, K.A.; Jawahar, M.; Anbarasi, L.J.; Ravi, V.; Al Mazroa, A.; Robin, C.R. Deep transfer learning technique to detect white blood cell classification in regular clinical practice using histopathological images. Multimed. Tools Appl. 2025, 84, 5699–5723. [Google Scholar] [CrossRef] [Scilit]
- Gan, L.; Li, X.; Wang, X. A curated and re-annotated peripheral blood cell dataset integrating four public resources. Sci. Data 2025, 12, 1694. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Dipto, S.M.; Reza, M.T.; Rahman, M.N.J.; Parvez, M.Z.; Barua, P.D.; Chakraborty, S. An XAI integrated identification system of white blood cell type using variants of vision transformer. In Proceedings of the Second International Conference on Innovations in Computing Research (ICR’23); Springer: Berlin/Heidelberg, Germany, 2023; pp. 303–315. [Google Scholar]
- Elghandour, M. PCA-NCA based VIT features for classification of white blood cell images. J. Supercomput. 2025, 81, 1278. [Google Scholar] [CrossRef] [Scilit]
- Ullah, T.; Ullah, K.; Khan, P.; Brikova, O.; Voznesensky, A.; Eroshkin, A.; Hussain, I. Fuzzy logic and deep learning approach for automated white blood cell detection and classification via multi-CNN feature fusion. Sci. Rep. 2025, 15, 44546. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Gao, R.; Ke, Q.; Li, A.; Qin, X.; Zhao, S. Edge-prior and reliability-guided collaborative learning for white blood cell classification. Sci. Rep. 2026, 16, 60469. [Google Scholar] [CrossRef] [Scilit] [PubMed]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.


















