Skip to Content
Applied SciencesApplied Sciences
  • Article
  • Open Access

2 May 2026

15 Pages

Small-Sample Ctenopharyngodon idella Disease Recognition via Dual-Stream Data Augmentation and Supervised Contrastive Learning

and
School of Information, Shanghai Ocean University, Shanghai 201306, China
*
Author to whom correspondence should be addressed.

Abstract

Addressing the challenges of extreme sample scarcity, complex underwater optical environments, and significant variations in lesion scales in real-world aquaculture, this paper proposes a small-sample grass carp disease recognition method, namely Swin Transformer with Supervised Contrastive Learning (ST-SCL), integrating dual-stream data augmentation and supervised contrastive learning. First, a frequency-spatial dual-stream augmentation strategy is constructed. In the frequency domain, the Amplitude-Mix technique is introduced to simulate diverse lighting and turbidity styles by mixing background amplitude spectra, thereby enhancing environmental generalization. In the spatial domain, a pathology-mask-guided instance-level Copy-Paste strategy is employed to directionally expand scarce lesion samples and address data imbalance. Second, the Swin Transformer is adopted as the backbone network, leveraging its hierarchical shifted window attention mechanism to effectively capture multi-scale features, balancing the detection of tiny parasites and extensive superficial ulcerations. Finally, supervised contrastive learning is incorporated to maximize intra-class compactness and minimize inter-class separability within the feature space, effectively reducing overfitting inherent to small-sample learning. Experimental results demonstrate that the proposed method achieves a macro-average F1-score of 95.86% across six disease categories. Compared with mainstream models such as ResNet and ConvNeXt, the ST-SCL exhibits notable performance improvements and enhanced robustness in small-sample scenarios, offering a promising technical path for precise fish disease diagnosis in complex aquatic environments.

1. Introduction

Grass carp (Ctenopharyngodon idella) is one of the major freshwater aquaculture species in China [1]. However, with the widespread adoption of high-density intensive farming, water eutrophication has become increasingly severe, leading to frequent outbreaks of bacterial and parasitic diseases such as erythrodermatitis, gill rot, and anchor worm infestation [2,3]. Conventional approaches to fish disease diagnosis include clinical observation of external symptoms, microscopic pathological examination, bacterial culture, and molecular techniques such as PCR [4]. While these methods can provide definitive pathogen identification, they present significant practical limitations in intensive aquaculture settings: clinical observation requires experienced professionals and is prone to subjective error, particularly for early-stage or visually subtle diseases; laboratory-based methods demand specialized equipment and involve lengthy processing times, making them unsuitable for rapid field screening; and critically, all conventional approaches necessitate manual capture and handling of fish, which induces physiological stress responses that can exacerbate disease progression. With the growing demand for intelligent and precision aquaculture management [5,6,7], there is an urgent need for non-contact, automated, and scalable diagnostic tools applicable to real-world aquaculture environments.
In recent years, breakthroughs in computer vision have opened new possibilities for non-contact fish disease diagnosis. Early studies were predominantly based on convolutional neural networks (CNNs) such as VGG and ResNet, achieving notable results on specific datasets [8,9]. Deep learning has also been applied to fish detection and species classification in underwater environments [10]. However, applying general-purpose models to grass carp disease recognition in practical aquaculture environments remains constrained by several factors:
Sample scarcity and environmental noise-induced overfitting: Acquiring disease images in real underwater environments is extremely costly, and disease outbreaks are sporadic, making it difficult to construct large-scale standardized datasets comparable to ImageNet. Existing augmentation methods primarily employ geometric transformations or automated strategies such as AutoAugment [11], which fail to realistically simulate the optical noise unique to underwater imaging (e.g., turbidity, scattering) and dynamic occlusion. Under small-sample conditions, models readily learn non-robust features such as background textures, resulting in limited generalization capability. Similar challenges have been observed in other agricultural domains, where small-sample learning approaches have shown promising results for plant disease recognition under data-scarce conditions [12].
Multi-scale variability of lesions: Fish disease features exhibit significant scale differences [13,14,15]. For instance, erythrodermatitis manifests as large-area body surface reddening and scale loss, representing macroscopic features [16,17]; whereas parasitic diseases such as anchor worm present as extremely small punctate protrusions, constituting microscopic fine-grained features [18]. Because traditional CNN convolution kernels have fixed receptive fields, it is difficult for a single network to simultaneously capture both global semantics and local microscopic details, leading to missed detection of small lesions.
Interference from complex underwater environments: Actual aquaculture ponds are often characterized by high turbidity and high-density fish occlusion. Existing models trained on ideal images typically exhibit significant performance degradation when confronted with water quality variations and partial occlusion scenarios [19].
To address these challenges, this paper proposes a grass carp disease recognition method (ST-SCL) integrating dual-stream data augmentation, multi-scale Swin Transformer, and supervised contrastive learning.

2. Materials and Methods

2.1. Overall Framework

To address the dual challenges of extreme sample scarcity (small-sample) and complex underwater imaging environments in grass carp disease recognition, this study constructs a recognition framework integrating dual-stream data augmentation and supervised contrastive learning. Let the original small-sample dataset be 𝒟 = {(xi,yi)}i=1N, where xi ∈ R H × W × C is the input image and yi is the disease label. The framework aims to train a feature extractor fθ(·) and classifier gφ(·) with strong generalization capability through physical augmentation in the data space and manifold optimization in the feature space. The framework comprises three core modules:
Frequency spectrum-based cross-domain environment simulation: Traditional geometric transformations fail to simulate the optical scattering and turbidity effects unique to underwater imaging. Based on digital image processing theory, the amplitude spectrum 𝒜(u,v) mainly characterizes low-level statistical styles such as brightness and contrast, while the phase spectrum 𝒫(u,v) encodes high-level semantic structures such as edges and textures. This module introduces an amplitude spectrum mixing strategy in the frequency domain. While preserving the source phase spectrum 𝒫src, the source amplitude spectrum 𝒜src is linearly interpolated with randomly sampled water body background amplitude spectra 𝒜trg, generating virtual samples with diverse turbidity and illumination distributions without destroying fish body structural information.
Pathology-guided instance-level augmentation: To address the issue that microscopic lesions (e.g., parasitic punctate protrusions) occupy an extremely small proportion of the entire image and are easily overwhelmed by background noise, this module proposes a mask-based instance-level Copy-Paste strategy. Using expert-annotated lesion masks Mlesion to extract key texture regions, applying random rotation, scaling, and other affine transformations 𝒯(·), and seamlessly fusing them into healthy fish bodies or different background regions. This method forces the attention mechanism to focus on discriminative pathological textures rather than spurious correlations in the background.
Supervised contrastive learning and classification module: To resolve the issues of ambiguous classification boundaries and overfitting under small-sample conditions, this method replaces the single cross-entropy loss training paradigm. After extracting feature vectors hi using the Swin Transformer backbone, a projection head maps features onto a low-dimensional unit hypersphere to obtain zi. Supervised contrastive loss (SupCon Loss) is then applied to explicitly pull together same-class samples (Positive Pairs) and push apart different-class samples (Negative Pairs) in the feature space. This joint optimization with linear classification constructs a robust feature manifold with intra-class compactness and inter-class separation, significantly improving generalization on unseen test sets.

2.2. Dual-Stream Environment and Pathology Data Augmentation Strategy

2.2.1. Frequency Domain Environment Simulation Based on Amplitude Spectrum Mixing

Traditional data augmentation methods (e.g., brightness adjustment, histogram equalization) fail to realistically simulate the light scattering and absorption effects unique to underwater imaging [20], despite being widely adopted in general computer vision tasks [21]. Based on digital image processing theory, the phase spectrum mainly contains high-level semantic content (e.g., fish body contours, spatial structures), while the amplitude spectrum primarily reflects low-level statistical features (e.g., illumination distribution, turbidity, water color style) [22].
To enhance model generalization across different water quality environments, this paper introduces an amplitude spectrum mixing strategy based on the Fast Fourier Transform (FFT). The specific implementation process is shown in Figure 1. Given an input source image x ∈ R H × W × C , it is first transformed from the spatial domain to the frequency domain:
F x u , v = A u , v ⋅ e j ⋅ P ( u , v )
where F(·) denotes the Fourier transform, and A(u,v) and P(u,v) represent the amplitude spectrum and phase spectrum, respectively.
Figure 1. Schematic diagram of frequency domain augmentation based on amplitude spectrum mixing strategy.
To generate virtual samples with new environmental styles, a target background image (e.g., one with high turbidity or different lighting conditions) is randomly selected, and its amplitude spectrum A_trg is extracted. Through linear interpolation, the source amplitude spectrum A_src is replaced with a mixed amplitude spectrum while strictly preserving the source phase spectrum P_src:
A ^ = 1 − λ A s r c + λ A t r g
x a u g = F − 1 A ^ , P s r c
where λ~U(0,1) is a random factor controlling style transfer intensity, and F−1 denotes the inverse Fourier transform. Through this process, the model can simulate continuously varying complex water environments during training, effectively overcoming overfitting caused by a single background.

2.2.2. Pathology-Guided Instance-Level Copy-Paste

For diseases such as erythrodermatitis and anchor worm that are underrepresented in the dataset and whose lesion regions occupy an extremely small pixel proportion of the entire image, conventional image-level augmentation has limited effectiveness in expanding lesion features. Therefore, this paper implements instance-level Copy-Paste augmentation using pathological annotation masks [23], as shown in Figure 2. The core steps are as follows:
Figure 2. Pipeline of pathology-guided instance-level Copy-Paste augmentation.
Lesion extraction: Based on expert-annotated JSON mask files, a set of image patches containing complete pathological textures is extracted from diseased fish images, forming a lesion patch set 𝒮lesion = {p1, p2, …, pn}.
Random perturbation: To prevent the model from memorizing specific lesion shapes, random geometric transformations are applied to extracted lesion patches pi, including rotation θ ∈ [−180°, 180°], scaling s∈ [0.5, 1.5], and minor color jittering.
Seamless fusion: Perturbed lesion patches are randomly fused into non-edge regions of healthy grass carp images or background images xbg. To avoid unrealistic composites, several safeguards are applied: (1) lesion patches are only pasted onto anatomically plausible regions (e.g., body surface) by constraining placement coordinates within the fish body contour; (2) Gaussian smoothing filters are applied to patch boundaries to eliminate visible pasting artifacts and ensure seamless blending with surrounding textures; (3) color histogram matching is performed between the lesion patch and the target region to maintain color consistency under varying lighting conditions. Gaussian smoothing filters are applied to edges to eliminate pasting boundary artifacts.
Through this strategy, multiple lesions of different morphologies can be synthesized on a single healthy fish image, artificially constructing hard examples of severe infection. This not only substantially increases the quantity of disease features but also effectively balances class distribution, forcing the attention mechanism to focus on lesion textures themselves rather than fish body positions. To ensure the integrity of augmented samples, each synthesized image was generated using a unique combination of randomly perturbed lesion patches and background images so that no two augmented samples share identical lesion placement, scale, or orientation. After augmentation, the expanded dataset was partitioned into training, validation, and test splits, and perceptual hash-based deduplication was applied to the test set to ensure that no near-duplicate images exist between splits. Furthermore, even when a lesion patch originates from the same source image, the substantial random perturbations applied during augmentation (rotation within [−180°, 180°], scaling within [0.5, 1.5], and color jittering) ensure that the synthesized samples are visually distinct from the original, preventing the model from memorizing specific lesion morphologies and effectively mitigating source-level information leakage.

2.3. Multi-Scale Feature Extraction Based on Swin Transformer

Grass carp disease visual representations exhibit significant multi-scale characteristics. For instance, parasitic diseases such as anchor worm present as tiny punctate protrusions occupying a minimal pixel proportion, whereas bacterial diseases such as erythrodermatitis manifest as large-area body surface reddening and necrosis. Traditional CNNs typically use fixed convolution kernel receptive fields, making it difficult to simultaneously capture fine textures and model macroscopic lesions in a single forward pass. Therefore, this paper adopts the Swin Transformer [24], which introduces a CNN-like hierarchical design with progressive downsampling to construct a feature pyramid adapted to multi-scale lesion detection.
The core components of the Swin Transformer include Window-based Multi-head Self-Attention (W-MSA) and Shifted Window Multi-head Self-Attention (SW-MSA). To reduce the computational complexity of global self-attention, the input feature map is partitioned into non-overlapping local windows, each containing M × M patches. Self-attention computation is confined within each window. For features within a window X ∈ R M 2 × C , Query (Q), Key (K), and Value (V) are computed as:
A t t e n t i o n Q , K , V = S o f t M a x Q K T d + B V
where d is the scaling factor and B ∈ R M 2 × M 2 is the relative position bias. In fish disease recognition, introducing B is crucial as it explicitly encodes relative spatial geometric relationships between pixels, enabling the model to capture regular scale arrangement textures and relative positional information between parasites and fish bodies. Furthermore, to address the lack of inter-window information exchange in W-MSA, the SW-MSA module shifts window partitions through cyclic shift operations, moving the window partition positions toward the lower-right by (⌊M/2⌋, ⌊M/2⌋) pixels. This mechanism establishes cross-window connections between consecutive Transformer blocks and extends the effective receptive field to cover the entire image, thereby linking local lesion features with global fish body structures.
To fully leverage multi-scale inductive biases, this paper extracts output feature maps from Stage 2, Stage 3, and Stage 4 of the network. Stage 2 outputs capture high-resolution shallow features responsible for high-frequency texture details (e.g., anchor worm body contours, water mold hyphae edges), while Stage 4 outputs capture low-resolution deep features encoding macroscopic semantic patterns (e.g., erythrodermatitis reddened distribution range, gill rot organ damage). Finally, global average pooling maps deep features into one-dimensional vectors as input for the subsequent supervised contrastive learning module. The overall architecture is shown in Figure 3.
Figure 3. Architecture of the Swin Transformer backbone and the schematic of the Shifted Window Attention Mechanism (SW-MSA).

2.4. Supervised Contrastive Learning Strategy

In small-sample classification tasks, traditional cross-entropy loss often fails to construct robust decision boundaries due to training data scarcity, causing models to overfit to background noise (e.g., water body color). Therefore, this paper introduces supervised contrastive learning to explicitly optimize the data manifold structure during feature extraction. Unlike unsupervised contrastive learning, SupCon utilizes label information to treat all same-class samples within a batch as positive pairs, thereby maximizing intra-class compactness and inter-class separability in the feature space. This approach builds upon the self-supervised contrastive learning framework SimCLR [25], extending it to the supervised setting by leveraging label information.
Specifically, the global feature vector hi ∈ R D e extracted by Swin Transformer is first mapped to a low-dimensional embedding space through a projection head and l2-normalized to obtain zi ∈ R D p . For a training batch containing N samples, let I ≡ {1…N} be the sample index set. For any anchor sample i ∈ I, let P(i) = {p ∈ I∖{i}|yp = yi} be the index set of all same-class positive samples, and A(i) = I∖{i} be the index set of all samples except itself. The supervised contrastive loss function is defined as:
L s u p = ∑ i ∈ I − 1 P i ∑ p ∈ P ( i ) l o g e x p z i ⋅ z p / τ ∑ a ∈ A ( i ) e x p z i ⋅ z a / τ
where z_i and z_p are the normalized feature vectors of the anchor and positive samples, respectively; P(i) is the index set of all same-class samples excluding i; A(i) is the index set of all samples excluding i; and τ is the temperature coefficient controlling the model’s focus on hard samples.
To balance feature representation generalization with classification accuracy, this paper adopts a multi-task joint optimization strategy:
L t o t a l = λ ⋅ L s u p + 1 − λ ⋅ L c e
where λ is the balancing coefficient. Under this framework, L_sup optimizes feature distribution at the encoder level, ensuring features possess environmental invariance, while L_ce finds the optimal linear decision plane at the classifier level. This synergistic optimization of feature shaping and classification decision effectively alleviates the problem of single cross-entropy loss falling into local optima under small-sample conditions. The overall mechanism is illustrated in Figure 4.
Figure 4. Schematic diagram of supervised contrastive learning mechanism in feature space.

2.5. Dataset and Experimental Setup

The experimental data were collected from two primary sources: field sampling at aquaculture bases and public internet databases. To realistically simulate the complex and variable underwater environments in practical production, the dataset encompasses grass carp images captured under different lighting conditions (sunny direct light, overcast diffuse light) and various water quality backgrounds (clear water, eutrophic green algae water, and highly turbid muddy water). After screening and expert curation, a dataset comprising six typical physiological categories was constructed: erythrodermatitis, gill rot, anchor worm, scale protrusion disease, water mold, and healthy grass carp, as shown in Figure 5. These five diseases were selected because they are the most common visually distinguishable conditions in grass carp aquaculture, readily identifiable through external morphological symptoms without requiring laboratory testing, spanning three distinct etiological categories: bacterial (erythrodermatitis, gill rot), parasitic (anch3000 total) was partitioned into 300 per class for training, 100 for validation, and 100 for testing. To ensure evaluation integrity, the test set was subjected to perceptual hash-based deduplication to eliminate near-duplicate samples. Images from both field and internet sources were distributed across all data splits to prevent source-specific data leakage. Additionally, pixel-level fine-grained annotations of key lesion regions were performed using LabelMe (v6.1.1) [26], generating corresponding JSON mask files.
Figure 5. Representative images of the six grass carp categories.
All experimental models were built on the PyTorch 1.13 deep learning framework [27], with hardware configured asAll experimental models were built using PyTorch (v1.13) [27], with hardware configured as Intel Core i9-13900K CPU (Intel Corporation, Santa Clara, CA, USA) and NVIDIA GeForce RTX 4090 GPU (NVIDIA Corporation, Santa Clara, CA, USA) with CUDA (v11.7, NVIDIA Corporation, Santa Clara, CA, USA) for parallel computation acceleration. Input image resolution was uniformly resized to 224 × 224 pixels, with ImageNet pre-trained weights for parameter initialization [28]. The AdamW optimizer [29] was selected with an initial learning rate of 5 × 10−4, weight decay of 0.05, batch size of 32, and 200 training epochs. The temperature coefficient τ in supervised contrastive loss was set to 0.07, and the balancing weight λ was set to 0.6. Macro-Precision, Macro-Recall, and Macro-F1 were selected as core evaluation metrics.

3. Results

3.1. Performance Comparison of Models on the Test Set

To validate the effectiveness of the ST-SCL framework, four representative deep learning models were selected as baselines: classic CNN architecture ResNet50 [30], lightweight model MobileNetV3 [31], modern CNN benchmark ConvNeXt [32], and early Vision Transformer variant ViT-Tiny. All baseline models used standard ImageNet pre-trained weights with full fine-tuning on the same small-sample training set. Results are presented in Table 1. These four models were deliberately chosen to span the major architectural paradigms in modern visual recognition: ResNet50 represents the classic deep CNN with residual connections; MobileNetV3 represents lightweight architectures designed for resource-constrained deployment; ConvNeXt represents the latest modernized CNN design that incorporates Transformer-inspired components; and ViT-Tiny represents the early Vision Transformer family, providing a direct architectural comparison with the Swin Transformer backbone used in ST-SCL.
Table 1. Performance comparison of different models on the small-sample test set.
As shown in Table 1, the ST-SCL method outperforms all baseline models across all metrics. The macro-average F1-score reaches 95.86%, representing a 9.90% improvement over the best-performing baseline ConvNeXt and a 32.53% improvement over the classic ResNet50. This indicates that introducing targeted augmentation strategies and contrastive learning significantly improves classification performance under data-limited conditions.
To further investigate the recognition performance across individual disease categories, Figure 6 presents the confusion matrix of the ST-SCL model on the test set. The results reveal that the model achieves consistently high recognition accuracy across all six categories. As expected, the healthy class achieves the highest recognition rate due to its distinct visual features. Among disease classes, erythrodermatitis benefits from its large-area macroscopic lesion patterns that are relatively easier to capture. In contrast, anchor worm exhibits the most confusion with other categories, consistent with its nature as a fine-grained, small-lesion disease where punctate protrusions occupy minimal pixel area and are easily overwhelmed by background noise. Nevertheless, the proposed dual-stream augmentation and supervised contrastive learning still achieve competitive performance for this challenging category, demonstrating the effectiveness of the pathology-guided Copy-Paste strategy in enhancing small-lesion recognition.
Figure 6. Confusion matrix of the ST-SCL model on the test set.

3.2. Model Generalization and Overfitting Analysis

To quantitatively assess the overfitting degree of each model, Table 2 reports the F1-score differences between training and validation sets:
Table 2. Performance comparison of models on training and validation sets.
ResNet50, MobileNetV3, and ViT-Tiny all achieved over 95% on the training set but experienced significant validation performance drops, with generalization gaps exceeding 30%. In contrast, ST-SCL maintained high training accuracy while showing only a 2.56% validation F1 decline, demonstrating optimal generalization stability.

3.3. Ablation Study

To systematically evaluate the contribution of each innovative module in the ST-SCL framework and to isolate the source of performance gains, a strict component-wise ablation study was conducted using Swin Transformer as the fixed backbone. Four configurations were compared: (1) Swin + Basic Aug. + CE (baseline), (2) Swin + Dual-Stream Aug. + CE, (3) Swin + Basic Aug. + SupCon, and (4) Swin + Dual-Stream Aug. + SupCon (full ST-SCL). This design ensures that the backbone remains constant across all experiments, enabling a fair and isolated assessment of the dual-stream augmentation strategy and the supervised contrastive learning component, as well as their interaction. Results are presented in Table 3. Here, “Basic Aug.” refers to traditional geometric transformations, “Dual-Stream Aug.” includes the proposed frequency-domain amplitude mixing and pathology-guided Copy-Paste, and “SupCon” refers to the supervised contrastive loss.
Table 3. Ablation study on different model components.
Based on the data in Table 3, the contribution mechanisms of each component can be analyzed in depth. First, introducing the proposed frequency-spatial dual-stream augmentation strategy while maintaining cross-entropy loss improved F1 from 83.15% to 91.21%, a gain of 8.07%. This improvement highlights the importance of targeted data augmentation in small-sample aquatic disease recognition. Traditional geometric transformations fail to simulate the complex optical environment underwater, whereas the frequency-domain amplitude mixing strategy effectively suppresses model overfitting to specific environmental noise by introducing diverse water body background styles. Meanwhile, the pathology-guided Copy-Paste strategy directionally expands scarce lesion samples, forcing the model to attend to disease texture features rather than background, thereby significantly enhancing the robustness of feature extraction.
Second, replacing cross-entropy with supervised contrastive loss while maintaining basic augmentation yielded a 4.56% F1 improvement to 87.71%. This result indicates that traditional cross-entropy loss under sample scarcity can only learn relatively ambiguous classification boundaries, whereas SupCon Loss leverages label information to explicitly pull together same-class samples and push apart different-class samples in the feature space, constructing a more compact intra-class distribution. Experiments demonstrate that even without additional augmented data, an improved feature space structure can notably enhance the model’s discriminative ability for confusable diseases.
Finally, when both dual-stream augmentation and supervised contrastive learning were applied simultaneously, the model achieved an optimal performance of 95.86%, with a total improvement of 12.71%. Notably, this total improvement slightly exceeds the sum of individual contributions (8.07% + 4.56% = 12.63%), indicating a synergistic complementary relationship between the two modules. The rich and challenging samples generated by dual-stream augmentation provide higher-quality training material for supervised contrastive learning, enabling SupCon Loss to mine deeper semantic invariance features; conversely, the optimized feature manifold enhances the classifier’s adaptability to complex, transformed data. Together, they effectively resolve the poor generalization problem under small-sample conditions.

4. Discussion

Based on the experimental data presented above, this section conducts an in-depth analysis from two perspectives: model architectural characteristics and method effectiveness. An in-depth analysis reveals that ResNet50, MobileNetV3, and ViT-Tiny all exhibit significant overfitting tendencies. Despite achieving over 95% training F1-scores, their validation performance drops dramatically with generalization gaps exceeding 30%. This scissors effect indicates that under insufficient data diversity, traditional models tend to mechanically memorize background noise in training samples (e.g., specific water body colors or aquatic plant textures) rather than learning essential disease features. In particular, ViT-Tiny, lacking the inductive biases inherent to CNNs, struggles to converge effectively under the 50-shot constraint, while ResNet50, despite its residual structure, is limited by local receptive fields and cannot simultaneously handle multi-scale feature extraction.
In contrast, the proposed ST-SCL model demonstrates improved generalization stability, with only a 2.56% F1 difference between training and validation sets. This improvement is primarily attributed to the synergistic effect of dual-stream augmentation and supervised contrastive learning. First, the dual-stream data augmentation strategy constructs a high-fidelity virtual sample space: frequency-domain amplitude mixing forces the model to remain insensitive to water environment variations, while pathology-guided instance augmentation breaks the model’s dependence on specific backgrounds. Second, supervised contrastive learning explicitly optimizes the data manifold structure in feature space. Unlike cross-entropy loss, which only focuses on linear decision boundaries, SupCon forces same-class samples to cluster tightly on the projection hypersphere, providing greater safety margins for classification decisions and ensuring robust discriminative ability when facing unseen complex underwater images. Furthermore, the confusion matrix (Figure 6) provides additional evidence of robustness: ST-SCL achieves high per-class recognition rates across all six categories, with the most challenging class (anchor worm) still reaching 92% accuracy. The error patterns reveal that misclassifications are predominantly between visually similar disease categories rather than systematic confusion with the healthy class, indicating that the model has learned meaningful pathological features rather than overfitting to superficial shortcuts.
The architectural choices in ST-SCL are grounded in both theoretical motivation and empirical evidence. Vision Transformer has demonstrated advantages in fishery image analysis owing to its global modeling capability [33], as also shown in agricultural disease detection tasks [34]. Its hierarchical shifted window mechanism in Swin Transformer further enables efficient multi-scale feature extraction, which is critical for capturing disease features ranging from large-area reddening to tiny punctate protrusions. Meanwhile, supervised contrastive learning has been shown to possess stronger feature representation ability than traditional cross-entropy loss in small-sample scenarios [35], providing a principled approach to constructing robust classification boundaries under data scarcity.

5. Conclusions

This paper proposes a small-sample grass carp (Ctenopharyngodon idella) disease recognition method, ST-SCL, to address the challenges of extreme sample scarcity, complex underwater optical environments, and multi-scale lesion variability in practical aquaculture. The framework integrates three core innovations: (1) A frequency-spatial dual-stream data augmentation strategy, where amplitude spectrum mixing in the frequency domain simulates diverse underwater lighting and turbidity conditions to enhance environmental generalization and pathology-guided instance-level Copy-Paste in the spatial domain directionally expands scarce fine-grained lesion samples using expert-annotated masks, effectively addressing class imbalance. (2) Multi-scale feature extraction based on Swin Transformer, whose hierarchical shifted window attention mechanism enables effective capture of both large-area body surface lesions and tiny punctate protrusions, overcoming the limitations of fixed-receptive-field CNNs. (3) Supervised contrastive learning for feature space optimization, which maximizes intra-class compactness and inter-class separability to construct more robust classification boundaries than traditional cross-entropy loss, effectively reducing overfitting under small-sample conditions.
Comprehensive experiments on a dataset comprising six grass carp disease categories validate the effectiveness of the proposed framework. The main findings are as follows: (1) ST-SCL achieves a macro-average F1-score of 95.86%, outperforming the best baseline model (ConvNeXt) by 9.90 percentage points, with the lowest standard deviation (±0.12%) across five repeated runs, demonstrating both high accuracy and stability. (2) The model maintains the lowest generalization gap (2.56%) among all compared methods, indicating strong resistance to overfitting. (3) Confusion matrix analysis confirms robust per-class recognition across all categories, with even the most challenging fine-grained disease (anchor worm) achieving 92% accuracy; misclassification patterns are predominantly between visually similar disease categories rather than systematic confusion with the healthy class, indicating that the model has learned meaningful pathological features. (4) The ablation study reveals a synergistic complementary effect between the two core modules: dual-stream augmentation and supervised contrastive learning contribute 8.07% and 4.56% F1 improvements individually, while their combination yields 12.71%, slightly exceeding the sum of individual contributions.
Despite these promising results, this study has certain limitations. The current dataset split was performed randomly without source-aware or environment-wise stratification, and fine-grained metadata such as specific farm identity and water quality parameters were not systematically recorded during data collection. Although the frequency-domain augmentation strategy and the low generalization gap provide indirect evidence of cross-environment robustness, more rigorous evaluation protocols would further strengthen the generalization claims. Future work will focus on the following directions: (1) collecting richer metadata to enable pond-wise or environment-wise cross-validation for a more stringent assessment of model robustness across diverse real-world aquaculture scenarios; (2) model lightweighting and knowledge distillation to facilitate real-time deployment on underwater robots and mobile terminals; and (3) expanding the framework to cover additional fish species and disease types to enhance the practical applicability of intelligent aquaculture disease diagnosis systems.

Author Contributions

Conceptualization, Y.W. and D.W.; methodology, Y.W.; software, Y.W.; validation, Y.W. and D.W.; formal analysis, Y.W.; investigation, Y.W.; resources, D.W.; data curation, Y.W.; writing—original draft preparation, Y.W.; writing—review and editing, D.W.; visualization, Y.W.; supervision, D.W.; project administration, D.W.; funding acquisition, D.W. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the National Natural Science Foundation of China Youth Science Fund Project (32403031).

Institutional Review Board Statement

Not applicable.

Data Availability Statement

The data presented in this study are available on request from the corresponding author.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Li, X.; Li, J.; Wang, Y.; Fu, L.; Fu, Y.; Li, B.; Jiao, B. Aquaculture Industry in China: Current State, Challenges, and Outlook. Rev. Fish. Sci. 2011, 19, 187–200. [Google Scholar] [CrossRef] [Scilit]
  2. Wenning, R. The state of world fisheries and aquaculture (SOFIA) 2020 report. Integr. Environ. Assess. Manag. 2020, 16, 800–801. [Google Scholar]
  3. Wang, Y.; Liu, W.; Li, Z.; Qiu, B.; Li, J.; Geng, G.; Hu, B.; Liao, A.; Cai, Y.; Wen, M.; et al. Improvement and Application of Genetic Resources of Grass Carp (Ctenopharyngodon idella). Reprod. Breed. 2024, 4, 126–133. [Google Scholar] [CrossRef] [Scilit]
  4. Ina-Salwany, M.Y.; Al-saari, N.; Mohamad, A.; Mursidi, F.A.; Mohd-Aris, A.; Amal, M.N.A.; Kasai, H.; Mino, S.; Sawabe, T.; Zamri-Saad, M. Vibriosis in fish: A review on disease development and prevention. J. Aquat. Anim. Health 2019, 31, 3–22. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  5. Wang, C.; Li, Z.; Wang, T.; Xu, X.; Zhang, X.; Li, D. Intelligent Fish Farm—The Future of Aquaculture. Aquac. Int. 2021, 29, 2681–2711. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  6. Morro, B.; Riera-Batle, I.; Mira, A.; Mecinas, C.; Grau, A.M.; Alós, J. Reliability of self-reported catch and effort data via a smartphone application in a multi-species recreational fishery. Fish. Res. 2025, 289, 107502. [Google Scholar] [CrossRef] [Scilit]
  7. Honarmand Ebrahimi, S.; Ossewaarde, M.; Need, A. Smart fishery: A systematic review and research agenda for sustainable fisheries in the age of AI. Sustainability 2021, 13, 6037. [Google Scholar] [CrossRef] [Scilit]
  8. Hasan, M.M.; Islam, M.S.; Shin, J. YOLO-Fish: A robust fish detection model to detect fish in realistic underwater environment. Ecol. Inform. 2022, 72, 101847. [Google Scholar]
  9. Ahmed, M.S.; Aurpa, T.T.; Azad, M.A.K. Fish Disease Detection Using Image Based Machine Learning Technique in Aquaculture. J. King Saud Univ. Comput. Inf. Sci. 2022, 34, 5170–5182. [Google Scholar] [CrossRef] [Scilit]
  10. Jalal, A.; Salman, A.; Mian, A.; Shortis, M.; Shafait, F. Fish detection and species classification in underwater environments using deep learning with temporal information. Ecol. Inform. 2020, 57, 101088. [Google Scholar] [CrossRef] [Scilit]
  11. Cubuk, E.D.; Zoph, B.; Mane, D.; Vasudevan, V.; Le, Q.V. AutoAugment: Learning augmentation policies from data. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Long Beach, CA, USA, 15–20 June 2019; pp. 113–123. [Google Scholar]
  12. Rezaei, M.; Diepeveen, D.; Laga, H.; Jones, M.G.K.; Sohel, F. Plant disease recognition in a low data scenario using few-shot learning. Comput. Electron. Agric. 2024, 219, 108812. [Google Scholar] [CrossRef] [Scilit]
  13. Rao, Y.; Su, J. Insights into the antiviral immunity against grass carp (Ctenopharyngodon idella) reovirus (GCRV) in grass carp. J. Immunol. Res. 2015, 2015, 670437. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  14. Mishra, S.S.; Rakesh, D.; Dhiman, M.; Choudhary, P.; Debbarma, J.; Sahoo, S.N.; Mishra, C.K. Present status of fish disease management in aquaculture. In Proceedings of the National Seminar on Emerging Diseases in Freshwater Aquaculture, Bhubaneswar, India, 18 January 2017; pp. 167–176. [Google Scholar]
  15. Saleh, A.; Abdel-Salam, E.M.; Amer, A.A. Artificial intelligence for fish disease diagnosis and management: Innovations, challenges, and One Health implications. Aquac. Int. 2025, 33, 352. [Google Scholar] [CrossRef] [Scilit]
  16. Sioutas, S.; Hoffmann, R.W.; Pfeil-Putzien, C.; Fischer-Scherl, T. Carp erythrodermatitis (CE) due to an Aeromonas hydrophila infection. Casuistic and experimental results. J. Vet. Med. Ser. B 1991, 38, 186–194. [Google Scholar]
  17. Semwal, A.; Kumar, A.; Kumar, N. A review on pathogenicity of Aeromonas hydrophila and their mitigation through medicinal herbs in aquaculture. Heliyon 2023, 9, e14088. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  18. Lin, T.Y.; Dollár, P.; Girshick, R.; He, K.; Hariharan, B.; Belongie, S. Feature pyramid networks for object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Honolulu, HI, USA, 21–26 July 2017; pp. 2117–2125. [Google Scholar]
  19. Cherian, A.K.; Venugopal, J.; Abishek, R.; Jabbar, F. Survey on underwater image enhancement using deep learning. In Proceedings of the 2022 International Conference on Computing, Communication, Security and Intelligent Systems (IC3SIS), Kochi, India, 23–25 June 2022; pp. 1–5. [Google Scholar]
  20. Yang, Y.; Soatto, S. FDA: Fourier domain adaptation for semantic segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Seattle, WA, USA, 13–19 June 2020; pp. 4085–4095. [Google Scholar]
  21. Shorten, C.; Khoshgoftaar, T.M. A survey on image data augmentation for deep learning. J. Big Data 2019, 6, 60. [Google Scholar] [CrossRef] [Scilit]
  22. Oppenheim, A.V.; Lim, J.S. The importance of phase in signals. Proc. IEEE 1981, 69, 529–541. [Google Scholar] [CrossRef] [Scilit]
  23. Ghiasi, G.; Cui, Y.; Srinivas, A.; Qian, R.; Lin, T.Y.; Cubuk, E.D.; Le, Q.V.; Zoph, B. Simple Copy-Paste is a strong data augmentation method for instance segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Nashville, TN, USA, 20–25 June 2021; pp. 2918–2928. [Google Scholar]
  24. Liu, Z.; Lin, Y.; Cao, Y.; Hu, H.; Wei, Y.; Zhang, Z.; Lin, S.; Guo, B. Swin Transformer: Hierarchical vision transformer using shifted windows. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), Montreal, QC, Canada, 10–17 October 2021; pp. 10012–10022. [Google Scholar]
  25. Chen, T.; Kornblith, S.; Norouzi, M.; Hinton, G.E. A simple framework for contrastive learning of visual representations. In Proceedings of the 37th International Conference on Machine Learning (ICML), Virtual, 13–18 July 2020; pp. 1597–1607. [Google Scholar]
  26. Russell, B.C.; Torralba, A.; Murphy, K.P.; Freeman, W.T. LabelMe: A database and web-based tool for image annotation. Int. J. Comput. Vis. 2008, 77, 157–173. [Google Scholar] [CrossRef] [Scilit]
  27. Paszke, A.; Gross, S.; Massa, F.; Lerer, A.; Bradbury, J.; Chanan, G.; Killeen, T.; Lin, Z.; Gimelshein, N.; Antiga, L.; et al. PyTorch: An imperative style, high-performance deep learning library. In Proceedings of the Advances in Neural Information Processing Systems 32 (NeurIPS), Vancouver, BC, Canada, 8–14 December 2019; pp. 8026–8037. [Google Scholar]
  28. Deng, J.; Dong, W.; Socher, R.; Li, L.J.; Li, K.; Fei-Fei, L. ImageNet: A large-scale hierarchical image database. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Miami, FL, USA, 20–25 June 2009; pp. 248–255. [Google Scholar]
  29. Loshchilov, I.; Hutter, F. Decoupled weight decay regularization. In Proceedings of the International Conference on Learning Representations (ICLR), New Orleans, LA, USA, 6–9 May 2019. [Google Scholar]
  30. He, K.; Zhang, X.; Ren, S.; Sun, J. Deep residual learning for image recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Las Vegas, NV, USA, 27–30 June 2016; pp. 770–778. [Google Scholar]
  31. Howard, A.; Sandler, M.; Chu, G.; Chen, L.C.; Chen, B.; Tan, M.; Wang, W.; Zhu, Y.; Pang, R.; Vasudevan, V.; et al. Searching for MobileNetV3. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), Seoul, Republic of Korea, 27 October–2 November 2019; pp. 1314–1324. [Google Scholar]
  32. Liu, Z.; Mao, H.; Wu, C.Y.; Feichtenhofer, C.; Darrell, T.; Xie, S. A ConvNet for the 2020s. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), New Orleans, LA, USA, 18–24 June 2022; pp. 11976–11986. [Google Scholar]
  33. Dosovitskiy, A.; Beyer, L.; Kolesnikov, A.; Weissenborn, D.; Zhai, X.; Unterthiner, T.; Dehghani, M.; Minderer, M.; Heigold, G.; Gelly, S.; et al. An image is worth 16 × 16 words: Transformers for image recognition at scale. In Proceedings of the International Conference on Learning Representations (ICLR), Virtual, 3–7 May 2021. [Google Scholar]
  34. Barman, U.; Sarma, P.; Rahman, M.; Deka, V.; Lahkar, S.; Sharma, V.; Saikia, M.J. ViT-SmartAgri: Vision Transformer and smartphone-based plant disease detection for smart agriculture. Agronomy 2024, 14, 327. [Google Scholar] [CrossRef] [Scilit]
  35. Khosla, P.; Teterwak, P.; Wang, C.; Sarna, A.; Tian, Y.; Isola, P.; Maschinot, A.; Liu, C.; Krishnan, D. Supervised contrastive learning. In Proceedings of the Advances in Neural Information Processing Systems (NeurIPS), Online, 6–12 December 2020; pp. 18661–18673. [Google Scholar]
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.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.