1. Introduction
Eggs are a staple, high-quality source of protein, with varieties differing significantly in nutritional composition, flavor, and market value. However, their similar external appearance makes them vulnerable to fraudulent mislabeling (e.g., ordinary eggs misrepresented as premium varieties), posing risks to food safety and consumer trust [
1]. Moreover, eggs undergo continuous quality deterioration during storage and distribution, affecting both their edibility and economic value. Therefore, achieving reliable variety recognition across different storage periods and accurately classifying storage duration are crucial for effective food quality supervision and maintaining supply chain integrity.
Traditional methods for assessing egg quality include manual inspection, chromatography, polymerase chain reaction (PCR), and enzyme-linked immunosorbent assay (ELISA) [
2,
3,
4]. These methods, however, face several limitations, such as subjective bias, high cost, and the need for specialized equipment. Consequently, they are unsuitable for large-scale, rapid testing applications. In comparison, spectroscopic techniques—particularly those based on near-infrared (NIR, ~780–2500 nm) and short-wave infrared (SWIR, ~1000–2500 nm)—offer non-destructive, rapid, and cost-effective solutions for evaluating internal egg quality [
5]. The spectral bands used in hyperspectral imaging (HSI) are highly sensitive to key internal attributes, such as moisture content, protein structure, and microstructural changes. This sensitivity arises from the ability of NIR/SWIR light to partially penetrate the eggshell and interact with molecular bonds (e.g., C–H, O–H, and N–H). As a result, even subtle spectral changes caused by moisture loss, protein denaturation, or microbial activity during storage can be detected. This capability enables real-time monitoring of internal quality degradation [
6].
The efficacy of the NIR and SWIR spectral ranges in capturing both shell-surface and internal compositional information has been consistently demonstrated. Recent studies have leveraged these hyperspectral bands for non-destructive egg analysis. For instance, Brasil et al. [
7] used portable NIR with machine learning to predict quail egg freshness. Sahachairungrueng et al. [
8] distinguished organic from conventional eggs via NIR-HSI and PLS-DA. Coronel-Reyes et al. [
9] showed that NIR spectra can penetrate eggshells to reflect internal moisture and protein changes during room-temperature storage. Akowuah et al. [
10] reported strong correlations (r > 0.87) between portable NIR measurements and egg freshness or laying dates. Cozzolino et al. [
11] further validated the use of portable NIR for intact egg storage time prediction, demonstrating the robustness of this spectral range for freshness monitoring. Liu et al. [
12] classified egg origin and storage periods using SWIR features. Ahmed et al. [
13] predicted eggshell strength with SWIR features. Beyond single-modality spectroscopy, recent studies have explored integrating NIR with complementary imaging modalities to enhance detection performance. Examples include the fusion of visible and hyperspectral images for egg freshness and defect detection [
14], visible-NIR hyperspectral imaging for egg yolk quantification [
15], and deep learning-augmented HSI for real-time egg defect inspection [
16]. Collectively, these works demonstrate the value of combining NIR/SWIR spectral and imaging information for non-destructive internal egg quality assessment, providing a solid basis for addressing cross-temporal variety recognition and storage-period classification.
Despite notable progress in spectral modeling for egg variety and quality prediction, two core challenges remain. First, spectral characteristics drift over time as storage alters egg composition, causing feature inconsistency and reduced recognition accuracy across different storage periods. Second, most existing methods rely on single-task learning (STL), treating variety and storage period as independent tasks. This overlooks their intrinsic correlation and hinders the learning of shared spectral representations, limiting model robustness under temporal variation [
17]. Multi-task learning (MTL) is a machine learning paradigm that jointly trains a model on multiple related tasks by sharing representations, thereby improving generalization and efficiency across domains [
18].In recent years, MTL has demonstrated excellent performance in fields such as natural language processing [
19], face recognition [
20], speech recognition [
21], disease diagnosis [
22], and quality prediction [
23], and has gradually extended to spectral analysis research. For example, Shi et al. [
24] proposed a multi-task convolutional neural network (MCNN) based on the whale optimization algorithm, capable of jointly predicting multiple quality indices of pear fruits; He et al. [
25] applied HSI and a multi-task deep learning model to simultaneously predict pigment content in spinach leaves; Li et al. [
26] combined HSI, NIR, and CNN/MCNN to jointly predict soluble solids and pH values of citrus fruits, and validated its cross-device applicability. These studies indicate that MTL holds significant advantages in handling multidimensional spectral information and enhancing model stability, providing a strong methodological foundation for the cross-temporal egg variety classification and storage period classification in this study.
To address the aforementioned issues, we introduce multi-task learning (MTL) to jointly model cross-temporal variety classification and storage period classification, mitigating spectral drift while enhancing robustness. Specifically, this study proposes the Multi-Task Cross-Temporal Squeeze-and-Excitation Network (MT-CTSE-Net), a non-destructive egg detection framework using NIR (1000–2500 nm) spectroscopy to simultaneously classify egg variety and storage period across storage durations. By sharing features between tasks, the framework effectively mitigates the drift in spectral characteristics caused by storage time variation, enhancing the applicability of the model under real-world circulation conditions. Architecturally, by incorporating a network structure capable of modeling long-range dependencies, the proposed model captures global spectral trends across different storage periods, enhancing the representation of temporal dynamics. Meanwhile, a localized feature perception component improves sensitivity to subtle spectral variations, facilitating the discrimination of egg varieties and storage stages. A task-driven spectral selection strategy further emphasizes informative wavelengths while suppressing redundancy, thereby improving overall classification performance.
Therefore, this study aims to develop a cross-temporal, non-destructive egg detection framework based on multi-task learning that simultaneously classifies egg varieties and storage periods using NIR hyperspectral imaging (1000–2500 nm), thereby mitigating spectral drift and enabling robust quality monitoring in poultry supply chains. The main innovations of this study are as follows: (1) For the first time, multi-task learning is applied to cross-temporal non-destructive detection of eggs, simultaneously performing variety classification and storage period classification, effectively mitigating the impact of spectral drift caused by storage time on recognition accuracy; (2) Utilizing the Transformer module to capture global dependencies across spectral bands, thereby achieving robust feature extraction of temporally evolving spectra, and improving the accuracy and reliability of cross-temporal classification; (3) Combining the CNN module with the SE attention mechanism to refine local patterns and enhance the representation of key spectral bands, thereby improving the discriminability of task-related features and providing an efficient and reliable solution for non-destructive egg detection.
4. Discussion
The proposed MT-CTSE-Net demonstrated superior performance in cross-temporal egg variety classification and storage period classification, effectively addressing spectral drift induced by prolonged storage. The analysis identified notable temporal shifts in key absorption bands linked to moisture (1450 nm, 1950 nm) and lipids (1700-1800 nm). These spectral changes led to diminished inter-class separability—a finding attributable to the physicochemical alterations that occur during food storage, which is consistent with prior research on egg spoilage [
9,
10,
11]. However, traditional linear classifiers (e.g., SIMCA, LDA, and PCA-LDA) assume linear separability and stationary feature distributions, failing to accommodate the nonlinear spectral evolution caused by biochemical changes. Consequently, as shown in
Table S1, these linear models struggled to handle cross-temporal drift, with accuracies plummeting to between around 40.3% and 45.3% after 40 days of storage. Even nonlinear single-task baselines (e.g., ST-RF, ST-Transformer) exhibited substantial perfor mance degradation under extended storage, with accuracies falling to around 46.3% and 60.1% at 40 days. In contrast, MT-CTSE-Net maintained markedly higher accuracy (86%) and F1-score (86.1%), demonstrating strong resistance to temporal distribution drift. Unlike previous single-task spectroscopic approaches for egg analysis—such as NIR-HSI–based defect inspection [
16] or quail egg freshness prediction using portable NIR [
7]—which did not explicitly account for temporal spectral changes, the proposed multi-task framework enhances robustness by jointly modeling variety and storage-period information. The multi-task learning framework facilitated beneficial feature sharing between tasks, collectively enhancing model generalization beyond single-task approaches.
These integrations draw from and extend successful MTL applications in agricultural quality control [
24,
25,
26], particularly through Transformer-based handling of cross-temporal dependencies in hyperspectral data. Despite its strong performance, the MT-CTSE-Net framework presents opportunities for further optimization. While conventional industrial NIR/HSI systems prioritize high-throughput processing, the proposed MT-CTSE-Net achieves superior multi-task classification accuracy through enhanced spectral–temporal feature learning, albeit with higher computational demands. The integration of CNN, SE, and Transformer modules increases inference time compared to simpler industrial models—a trade-off also noted in related hyperspectral studies [
15,
16]. However, techniques like model compression and edge computing can mitigate this latency. Critically, MT-CTSE-Net utilizes existing spectrometers without major hardware changes, limiting extra costs largely to software training. Its deployment through modular software integration in sorting lines enables scalable adoption with minimal infrastructure impact.
Furthermore, this study focused on one-dimensional spectral data, without leveraging spatial features or multimodal inputs (e.g., visual, olfactory, weight). From an industrial implementation perspective, the MT-CTSE-Net framework demonstrates strong compatibility with existing NIR/HSI-based egg quality control workflows, such as automated grading and inline monitoring. It can be embedded as a software module into standard industrial spectrometers (e.g., SPECIM SWIR), requiring minimal additional hardware—primarily GPU support during the training phase. After deployment, inference can be efficiently executed on standard CPU-based systems, ensuring cost-effectiveness and seamless integration into production-scale environments. This practical scalability, combined with non-destructive testing compliance (e.g., GB 2749–2015), positions MT-CTSE-Net as a viable solution to enhance current quality control pipelines without requiring significant infrastructural changes.
Overall, MT-CTSE-Net provides an effective solution for cross-temporal egg variety authentication and storage period classification. It not only iterates on the spectroscopic egg quality studies [
7,
8,
9,
10,
11] and multi-task learning approaches in agricultural produce evaluation [
24,
25,
26] but also provides a transferable basis for other agri-food applications. Future efforts will focus on developing lightweight variants, applying knowledge distillation, and exploring multimodal data fusion to further improve operational efficiency and robustness in large-scale industrial settings.
5. Conclusions
This study tackles two key challenges in spectral analysis of stored eggs—temporal spectral drift and limited generalization of single-task models—via MT-CTSE-Net, a multi-task framework for joint egg variety and storage period classification. By integrating CNN, SE, and Transformer modules, it captures fine-grained local features and long-range temporal dependencies, fostering shared learning that mitigates drift-induced degradation.
Experiments demonstrate MT-CTSE-Net’s superiority over single-task baselines and traditional deep networks, with ablation studies validating each component’s complementary role and multi-task learning’s benefit in stabilizing predictions over time. Industrially, it aligns with portable NIR/hyperspectral systems for egg grading and warehouse inspections; lightweight compression enables edge deployment in real-time quality control without major hardware changes, ensuring practical viability.
The multi-task approach extends to other storage-sensitive agricultural products (e.g., fruits, grains, meat) exhibiting similar spectral evolution, via matrix-specific calibration and label redesign for robust temporal modeling in diverse food quality tasks. Overall, this work delivers a drift-resilient, multi-task spectral framework with proven performance and seamless paths to implementation.