1. Introduction
Climate change and rising world population increase pressure on agricultural production, which subsequently reduces arable lands, water sources, and biodiversity. Therefore, alternative crop production methods are gaining more and more interest and popularity [
1]. In recent years, soilless growing techniques such as hydroponics and aeroponics have gained popularity in many countries [
2]. This makes hydroponics particularly valuable for vertical agriculture and regions where there is poor soil quality or a water shortage [
3]. Moreover, it is important to provide plants with essential nutrients and growing conditions (pH, temperature, and humidity). Although plants obtain ions at low concentration when continuously supplied, a change in equilibrium can cause plant toxicity [
4,
5].
Lettuce (
Lactuca sativa L.) is a major leafy vegetable and contains many nutritional compounds (e.g., vitamins, minerals, phenolic compounds) that are part of a healthy diet, with a production of 27.5 Mt and a cultivation area of 1 Mha [
6,
7]. It is a widely produced and consumed leafy vegetable all over the world, China being the largest producer, followed by the US and Western Europe [
8,
9]. The nitrogen content in lettuce is an important reference indicator and plays a crucial role in development, significantly influencing the synthesis of amino acids, proteins, and chlorophyll contents in lettuce throughout its growth [
10]. The application of nitrogen fertilizers significantly enhances crop yields. However, the current approach to nitrogen fertilizer application primarily relies on human judgment. Farmers frequently overapply nitrogen fertilizers in an attempt to increase yields, which can have unforeseen repercussions like reduced crop yields, environmental degradation, and a waste of resources. Therefore, it is crucial to accurately determine unique nitrogen conditions. This precision not only makes it possible to apply the right amount of nitrogen fertilizer, but it also helps to boost yields and cost savings [
11]. Accurate nitrogen content estimation in lettuce enables optimized fertilization and improved crop quality and yield, supporting resource-efficient production and enhancing food security [
3,
12]. Traditional nitrogen detection techniques are mostly destructive biochemical detection methods. However, these methods require destructive sampling, which is expensive and time-consuming. As a result, there is a dire need for intelligent diagnostic tools that allow farmers to rapidly determine the nitrogen levels in lettuce plants without using destructive techniques [
13,
14].
As science and technology have advanced, optical imaging equipment has become widely available in daily life, providing a quick and easy way to take optical images. Plant nutrient levels can be quickly acquired by utilizing spectral imaging in conjunction with computer vision technologies. This method has the advantages of being quick, highly automated, and non-destructive [
15]. In addition, machine learning techniques have been widely used in agriculture. For instance, Buxbaum [
16] et al. verified the feasibility of using deep learning and RGB images to monitor the growth dynamics at the scale of individual plants under non-idealized planting conditions. Nowadays, non-destructive testing of crop characterization information extraction has been widely applied in predicting the composition of agricultural products and it has great potential in measuring the N content of lettuce [
17,
18].
Convolutional Neural Networks (CNNs) have become a fundamental tool in agricultural applications. Researchers have notably applied CNNs for diagnosing nutrient transportation and predicting yields in various agricultural products, including fruits and vegetables [
19,
20]. CNNs have opened up new possibilities for recognising nutrient deficiencies in crop nutritional status. For instance, Yu H et al. [
21] utilized deep learning technology to extract features from lettuce phenotypes, achieving precise segmentation of the lettuce canopy in black screens. This achievement indicates that neural networks have a strong ability to extract features from RGB images of potted lettuce canopies. Moreover, OJOMO et al. [
22] employed the bileNetv2 integrated into the DeepLabv3+ network and successfully achieved semantic segmentation of RGB visible-light images from the top-down perspective of the lettuce canopy with an accuracy of up to 0.9985. In addition, RGB images have a strong correlation with plant nutrition and are highly stable against environmental changes. Similarly, Yu et al. [
23] developed two end-to-end deep learning models based on a two-dimensional convolutional neural network and a fully connected neural network for hyperspectral images of lettuce canopies, which directly predicted two tissue quality traits of lettuce—soluble solids content and tissue pH (both measured from lettuce juice as biochemical indicators of taste and harvest timing)—with prediction R
2 values of 0.9030 and 0.8490, respectively.
The main way deep learning technology is applied in agriculture is by using deep convolutional neural networks to extract feature information, mainly for regression and classification [
24]. This study mainly utilizes the regression application of deep learning, involving the neighborhood related to crop yield prediction. The common approach has shifted from directly using classical convolutional neural networks to adaptively modifying and reengineering their network structures to improve model accuracy [
25]. For instance, Thaknetr et al. [
26] built an improved lightweight VGG model—VGG-ICNN—which performed well on the public dataset of crop diseases. A stacking integrated convolutional neural network model was developed to determine the nitrogen nutrient levels in rice [
26]. The authors obtained an ideal diagnostic accuracy of 96.41% using DenseNet121, ResNet50, and Inception ResNet V2 as base learners. With DenseNet121, the accuracy rose to 98.10% following the stacking algorithm’s integration of various models [
27]. These integrative approaches demonstrate how well different models may be combined to improve crop nutritional status diagnosis accuracy while negotiating the difficulties of different nutrient levels and deficiency kinds in agricultural settings.
Prior work has introduced attention mechanisms into residual CNNs [
28,
29] and attention-gated or attention-enhanced encoder–decoder designs [
30,
31] In lettuce nutrient estimation, Cohen et al. compared ResNet- and Vision Transformer-based models using hyperspectral imagery [
32]. Ensemble-learning approaches have also been used for crop nutrient monitoring [
33], while residual networks incorporating multi-head attention have been reported in general image-classification research [
34]. Agricultural Vision Transformer studies have employed image-based or spatial–temporal transformer pipelines for crop-yield prediction [
35,
36]. Recent lettuce research has evaluated EfficientNetV2-S for RGB-based nitrogen regression [
37]. More general computer-vision studies include attention-augmented convolution [
38], Bottleneck Transformer architectures that replace selected ResNet convolutions with self-attention [
39], and the standard Vision Transformer, which processes projected image patches and uses a learnable classification token [
40]. Accordingly, this study does not claim to be the first to combine MSA and ResNet, nor does it claim novelty for self-attention itself. The specific architectural question examined here is whether the integration mode and insertion depth of an MSA block affect tray-level multi-output nutrient regression when all models are evaluated under the same controlled image-acquisition setting. The proposed comparison considers two integration modes. The R-series retains the corresponding ResNet stage and laterally fuses an attention-enhanced representation, whereas the E-series replaces a selected ResNet stage with the SA block. Each strategy is evaluated at three depths. Unlike the standard ViT architecture [
40], the attention input in the present framework is derived from an intermediate CNN feature map rather than directly from projected image patches, and no image-level classification token is used.
The objective was therefore to evaluate a controlled-condition proof-of-concept framework for mapping one standardized tray-level RGB image to a jointly predicted N–P–K nutrient-status vector. The controlled setting reduces variation unrelated to the architectural comparison, but it does not establish external validity.
The contributions of this study can be summarized as follows:
A systematic evaluation of two strategies for integrating multi-head self-attention into a ResNet50 backbone—lateral fusion (R-series) and stage replacement (E-series)—for non-destructive lettuce nutrient diagnosis from canopy RGB imagery.
A comparison of three attention insertion depths per strategy, yielding six ResNet50-SA variants for tray-level, multi-output estimation of lettuce N, P, and K status, matching the management unit of greenhouse fertigation.
A batch-grouped five-fold cross-validation against five baseline CNN architectures, reflecting batch-to-batch variation under production conditions, together with explicit boundaries on statistical inference, nutrient-specific interpretation, and external agricultural application.
4. Experimental Results
4.1. Feature Information Propagation
When delving into the differences between the ResNet50 and ResNet50_SA_RV1 models in terms of lettuce feature extraction and propagation, we analyzed the feature-map outputs of each model during image processing, which were reconstructed from the original image in
Figure 2B using the trained test model. As can be seen from the comparison of feature maps in
Figure 6, (H) shows more high-lighted regions and attention points compared with (D) for the same lettuce image, where RV1 exhibits higher sensitivity for capturing lettuce canopies. The feature maps (
Figure 7) represent intermediate activations generated during hierarchical feature extraction. They were visualized to qualitatively compare how different MSA insertion strategies affected spatial feature representation, activation distribution, and information propagation within the ResNet hierarchy.
ResNet50, as a classic CNN architecture, effectively mitigated the potential performance degradation of deep networks during training by introducing residual connections. As the depth of the network increases, from the basic layer to higher levels (layer1 to layer4), the degree of abstraction of the feature map gradually increases, from capturing the bottom edge and texture information of the image to extracting more advanced semantic features.
In contrast, the core improvement of ResNet50_SA_RV1, as a variant of ResNet50, lies in the introduction of MSA mechanisms. The MSA mechanism gives the model greater flexibility and targeting in feature extraction, enabling it to focus more effectively on key areas in the image, thereby enhancing the model’s representational and generalization capabilities. By comparing the feature map outputs of the two models at the same level (
Figure 7), we find the following:
4.1.1. Semantic Information Extraction
At the lower levels of the network, such as layer1, the feature map of ResNet50_SA_RV1 retains more detailed information about the lettuce canopy compared to ResNet50, and performs significantly better than ResNet50 in distinguishing the texture of the lettuce leaf edge from the background. This is mainly due to the MSA mechanism’s precise localization and emphasis on key areas of the image. The feature map of ResNet50 is likely to be relatively blurry. As the network hierarchy deepened, both models gradually demonstrated the ability to capture advanced semantic information about the texture and color of individual leaves of lettuce. However, ResNet50_SA_RV1 performed more precisely and comprehensively in extracting semantic information through the self-MSA mechanism, which helped the model better understand the context in the image.
4.1.2. Robustness
In terms of robustness, because the dataset is single, the dataset images are set in terms of light intensity, color saturation, shooting angle, and lettuce variety in accordance with the principle of fit for the lettuce production scenario application, which means that the feature extraction effect is highly specific and not robust. In summary, ResNet50_SA_RV1 shows significant advantages in feature extraction and propagation by integrating the MSA mechanism on top of ResNet50. However, further experimental verification is needed to verify the actual performance of these advantages in specific tasks. The performance evaluation of a model often relies on its performance on both the training set and the validation set. By analyzing the downtrend of train loss and validation loss, we can gain a deeper understanding of the differences in feature learning and generalization ability among different models. In this study, we compared the characteristics of ResNet50 and its variants with different self-attention (SA) modules, such as EV1, EV2, RV1, etc., during the loss degradation process, aiming to reveal the superiority or inferiority of these models in terms of performance.
First, from the perspective of training loss, all models show a rapid drop in loss in the early stages of training, which is a natural phenomenon for models in learning the underlying features of the data. Notably, ResNet50_SA and its variants with SA blocks showed similar loss reduction trends during training, but in the later stages of training, the models with SA blocks (such as EV1, EV2, RV1, etc.) showed more stable loss values. This trend suggests that these models may have captured the complex features of the data better and have moderate robustness against overfitting. However, ResNet50_SA_RV3 saw an increase in loss values in the later stages of training, possibly due to the model’s excessive complexity leading to overfitting on the training set.
Secondly, the change in validation loss provides us with clues about the generalization ability of the model on unseen data. Compared with the training loss, the decline rate of the validation loss may be slower and may be accompanied by fluctuations, which reflects the challenges the model faces when adapting to new data. On the validation set, ResNet50_SA and its variants with SA blocks also show a similar trend, but models with SA blocks typically have lower validation loss values. This finding further confirms the effectiveness of the MSA mechanism in improving model performance.
Overall, variants of ResNet50 with SA blocks showed more stable and lower loss values during the loss reduction process, suggesting an advantage in feature learning and generalization ability. However, excessive model complexity can lead to overfitting problems, so it is necessary to weigh the complexity and performance of the model when choosing a model to achieve the best results in practical applications.
4.2. Model Performance
As can be seen from the model test results (
Table 1), we compared the performance of different models on the validation set and the test set, with the main metrics being R2, RMSE, and MAE. First, we can note that on the validation set, the R2 of the ResNet50_SA_RV1 model reached 0.89, which is much higher than that of other models, while the RMSE and MAE were relatively low. This indicates that the model has a stronger predictive ability on the validation set and is more accurate than other models. On the test set, the ResNet50_SA_RV1 model also performed well, with R2 reaching 0.92 and RMSE and MAE showing more stable loss values than EV1, EV2, RV1, etc. This trend suggests that these models may have captured the complex features of the data better and have moderate robustness against overfitting.
Secondly, the variation in validation loss provides us with clues about the model’s ability to generalize on unseen data. Compared with the training loss, the decline rate of the validation loss may be slower and may be accompanied by fluctuations, which reflects the challenges the model faces when adapting to new data. On the validation set, ResNet50_SA and its variants with SA blocks also show a similar trend, but models with SA blocks typically have lower validation loss values. This finding further confirms the effectiveness of the MSA mechanism in improving model performance.
Overall, variants of ResNet50 with SA blocks showed greater stability and lower loss reduction, further verifying the robustness of the model.
The ResNet50_SA_RV1 model, which has a relatively small number of parameters, 62.8 M, but performs relatively well on both the validation set and the test set, possibly because it uses the MSA mechanism to improve ResNet50 and enhance the model’s feature extraction ability. In contrast, the ResNet50_SA_EV3 model performed relatively poorly on the validation set and test set, despite having a large number of parameters, reaching 623.4 M, but with a lower R2 and higher RMSE and MAE. This may be because in this model, the application of the MSA mechanism did not effectively improve the model’s performance; instead, it may have increased the model’s complexity, resulting in a decline in performance.
In addition, we can also observe that the computational cost (GFLOPS) of the ResNet50_SA_RV1 model is relatively low, at 17.065, while that of the ResNet50_SA_RV3 model is the highest, at 17.645. Although the ResNet50_SA_RV3 model has a higher R2 on the validation set, its large computational load may increase the training and inference time cost of the model. Therefore, in practical applications, both model performance and computational cost need to be taken into account (
Figure 8).
In summary, the ResNet50_SA_RV1 model performs better than other models on validation sets and test sets, possibly due to its relatively simple structure and effective feature extraction capabilities. Other models may have performed poorly due to higher model complexity or improper application of the MSA mechanism. When choosing a model, one needs to take into account the model’s performance, computational cost, and application scenarios in light of the actual situation. These results, however, were obtained on a single fixed partition; their robustness is further examined through grouped cross-validation in
Section 4.3.
As illustrated in
Figure 7, the SA-enhanced ResNet50 model we proposed demonstrates exceptional prediction consistency across the three random validation sets (RV1–RV3). The blue scatter points are tightly aligned with the 1:1 baseline, and the red fitted line nearly overlaps with the ideal line, indicating that the enhancement module effectively mitigates prediction bias. For the external validation sets (EV1–EV3), despite slight scattering of the points, a strong positive correlation is still maintained overall, which confirms the model’s reliable cross-distribution generalization capability. In comparison with the performance of the vanilla ResNet50, the SA-enhanced variant exhibits a denser distribution of scatter points and a fitted line that is more closely aligned with the baseline—findings that further validate the efficacy of the proposed enhancement strategy in improving the stability and accuracy of model predictions.
The purpose of this study was to evaluate an architectural hypothesis under controlled acquisition conditions: whether applying multi-head self-attention to intermediate ResNet50 feature representations could improve joint tray-level N–P–K regression. The controlled environment reduced variation unrelated to the architectural comparison and allowed the effects of alternative feature-extraction strategies to be examined under a common image-acquisition setting. Comparisons with ResNet18, SqueezeNet1.1, ShuffleNetV2, and RegNet were added to assess whether the observed performance extended beyond comparisons among ResNet50 variants. These experiments provide preliminary evidence of algorithmic feasibility for controlled-condition biological image regression but do not establish sensitivity to all subtle nutrient variations or robustness across seasons, cultivars, locations, or field environments.
4.3. Grouped Five-Fold Cross-Validation and Benchmark Comparison
To verify that the superiority of ResNet50_SA_RV1 is not an artifact of a particular data split, grouped five-fold cross-validation was conducted for ResNet50_SA_RV1, the ResNet50 baseline, and four conventional CNN architectures of different scales (ResNet18, SqueezeNet1_1, ShuffleNetV2, and RegNet), as summarized in
Table 2. Notably, the five-fold mean R
2 values of ResNet50_SA_RV1 and ResNet50 (0.92 and 0.81, respectively) coincide with the fixed-split test results in
Table 1, indicating that the original partition did not overstate model performance.
The proposed ResNet50_SA_RV1 achieved the highest accuracy (R2 = 0.92 ± 0.03; RMSE = 7.16 ± 1.77 mg/g; MAE = 4.06 ± 1.58 mg/g), clearly outperforming the ResNet50 baseline (R2 = 0.81 ± 0.06; RMSE = 9.91 ± 1.96 mg/g; MAE = 6.31 ± 1.54 mg/g). Paired bootstrap analysis tentatively verified that the stability of this improvement was statistically significant, with a ΔMAE of −2.25 mg/g (95% CI: −2.88 to −1.62) and a Holm-adjusted p-value < 0.001. Among the conventional baselines, ResNet18 achieved the closest performance to ResNet50 (R2 = 0.80 ± 0.06) despite its substantially smaller parameter count, while SqueezeNet1_1, ShuffleNetV2, and RegNet yielded progressively lower accuracy (R2 range: 0.49–0.75), confirming that the performance gain of ResNet50_SA_RV1 stems from the attention mechanism rather than increased model capacity alone.
5. Discussion
This work integrates the multi-head self-attention (MSA) mechanism into the residual neural convolutional network (ResNet-SA), which was designed by collecting environmental data through high-definition RGB images, aiming for high-precision diagnosis of lettuce nitrogen levels.
5.1. Model Architecture Comparison and Innovation
Wang et al. proposed a network with residual connections between soft attention modules, which performed well on the CIFAR10 dataset [
33]. Previous studies have improved the attention mechanism of ResNet, such as using the soft attention mechanism to implement the segmentation task on private datasets using a compressed attention encoder and a multi-head attention decoder [
29,
30]. As these studies show, attention-enhanced CNNs and CNN–Transformer hybrids have been reported previously [
31]. The contribution of this study is therefore not a first combination of MSA and ResNet, but a systematic comparison of two integration modes—lateral fusion and stage replacement—at three insertion depths for tray-level multi-output nutrient regression. A recent paper proposed embedding a multi-head attention mechanism encoder (Trans SE-ResNet) at the end of the ResNet structure for pneumonia diagnosis in chest CT images, achieving extremely high accuracy in pathological classification tasks [
31]. Compared with these studies on natural-image benchmarks and medical diagnosis, the present method targets high-precision estimation of crop nitrogen, phosphorus, and potassium levels [
34]. Li et al. [
39] reported a test-set R
2 of 0.9859 for lettuce nitrogen estimation from RGB images using EfficientNetV2-S; it should be emphasized, however, that their prediction was performed at the single-plant scale—each image contained one lettuce plant, and the model was developed on 4620 such single-plant images expanded by data augmentation, Meanwhile, Cohen et al. [
32] reported a test R
2 of 0.65 for nitrogen using raw hyperspectral imagery. These results cannot be treated as a leaderboard because the experimental units, nutrient ranges, modalities, and validation protocols differ. The distinct objective here is joint tray-level estimation of N, P, and K from a single low-cost RGB view. We created three improved models of SA blocks for ResNet50 and optimal position for attention embedding, and identified the best-performing of six model variants -ResNet50_SA_RV1. RV1 produced the highest test-set R
2 point estimate among the ResNet50-based variants; however, a single split cannot establish a stable architectural ranking, so this result is interpreted as preliminary evidence that integration mode and insertion depth matter. Compared to feature maps being used for feature extraction and propagation in ResNet50 and ResNet50_SA_RV1, we found that the introduction of the MSA mechanism significantly enhanced the model’s ability in feature extraction and propagation. ResNet50_SA_RV1 not only retains more detailed information at a lower network level but also extracts advanced semantic information more precisely at a higher level, which helps the model better understand the context in the image [
35].
Further, by analyzing the downtrend of training loss and validation loss, we found that the ResNet50 variant with SA block had a more stable loss during training and a lower validation loss, demonstrating the effectiveness of the MSA mechanism in improving the generalization ability of the model.
5.2. Model Performance Analysis
In order to verify the reliability and stability of our model, we compared the performance of different models on validation sets and test sets, mainly based on evaluation metrics including R
2 (coefficient of determination), RMSE (root mean square error), and MAE (mean absolute error). These metrics provided us with an intuitive measure of the accuracy and robustness of the model’s predictions. The ResNet50_SA_RV1 model stands out particularly from the results of the validation set (
Table 1). Its R
2 value was as high as 0.89, significantly better than other models, while the values of RMSE and MAE were relatively low. This result indicates that the ResNet50_SA_RV1 model not only has a stronger predictive ability but also provides more accurate predictions.
The regression R2 of the multimodal ViT model incorporating the time dimension constructed by Lin et al. in a county-level yield prediction task for four crops, namely corn, cotton, soybean, and winter wheat, was at the levels of 0.7 and 0.8 [
36]. Furthermore, an earlier study by Bi et al. [
37] used the VIT model to predict soybean yields, with a regression prediction R
2 of 0.664. On the test set, the ResNet50_SA_RV1 model demonstrated superior performance. Its R
2 value rose further to 0.92, while RMSE and MAE values remained low. This performance further validates that the ResNet50_SA_RV1 model can achieve high prediction accuracy on small datasets after introducing an attention mechanism with a relatively large number of parameters.
Analyzing the characteristics of the ResNet50_SA_RV1 model in terms of model size, it has a relatively small number of parameters, only 62.8 M. In contrast, the ResNet50_SA_EV3 model performed relatively poorly on both the validation set and the test set. Despite having a large number of parameters, reaching 623.4 M, it performed poorly on three metrics: R2, RMSE, and MAE. This may be because, in the model, the MSA mechanism completely replaced the main structure of ResNet in Stage 3, which, on the one hand, caused the information propagation chain of ResNet itself to break, and on the other hand, the application of the MSA mechanism did not effectively improve the performance of the model. Instead, it may be due to the excessive complexity of the model, which led to performance degradation and overfitting. In addition, we also note that the ResNet50_SA_RV1 model has a lower computational effort (GFLOPS) of 17.065, which gives the model a lower time cost during training and inference. The ResNet50_SA_RV3 model had the highest computational cost at 17.645. Overall, the ResNet50_SA_RV1 model demonstrated excellent performance on both the validation set and the test set, mainly due to its relatively simple structure and effective feature extraction capabilities. In practical applications, we need to select the most suitable model based on specific scenarios and requirements, taking into account factors such as model performance, computational cost, and application scenarios.
The grouped cross-validation results (
Section 4.3) provide important context for interpreting model performance. The five-fold mean R
2 of 0.92 ± 0.03 for ResNet50_SA_RV1 demonstrates that the attention-based improvement is stable across independent batch groupings rather than an artifact of a favorable data split, which is further supported by the significant paired ΔMAE (95% CI: −2.88 to −1.62; Holm-adjusted
p < 0.001). Notably, ResNet18 achieved an accuracy comparable to the deeper ResNet50 baseline (R
2 = 0.80 vs. 0.81), suggesting that at this dataset scale (96 tray images), model depth alone does not guarantee performance gains—the attention mechanism, rather than capacity scaling, is the primary driver of improvement. Nevertheless, these estimates remain bounded by the single-season, single-cultivar experimental design; external validation across multiple growing seasons and commercial greenhouse conditions is required to establish generalizability. In addition, nitrogen, phosphorus, and potassium were represented as a unified three-dimensional target vector and learned simultaneously using a shared feature-extraction network. This multi-output design was intended to capture visual representations shared among nutrient-related canopy responses and to exploit potential relationships among the three nutrient targets. The reported MSE and R
2 are aggregate multi-output metrics calculated for the complete N–P–K prediction vector and therefore represent the model’s overall nutrient-prediction performance.
5.3. Main Limitations of the Study and Corresponding Strategies
A dataset consisting of 96 RGB images of lettuce canopies was utilized in this study. Due to the limited sample size, the model struggles to generalize to rare nutrient conditions—such as severe potassium deficiency—that account for a small proportion of the dataset. Specifically developed for Italian premium loose-leaf lettuce, the model depends entirely on RGB images, which only capture visible light spectra. As a result, it faces inherent difficulties in identifying subtle nutrient variations that do not present obvious changes in color or texture. All images were acquired under controlled conditions of greenhouse floating-plate soilless cultivation, where lighting, shooting angles, lettuce varieties, and nutrient solution formulas remained constant. The high homogeneity of the dataset ultimately leads to insufficient environmental robustness of the model. Previous agricultural imaging studies have evaluated multi-target regression from standardized top-view lettuce images and proof-of-concept nutrient estimation from lettuce imagery using relatively limited datasets under controlled or semi-controlled acquisition conditions [
38,
39]. These studies provide methodological precedent for exploratory image-based regression but do not, by themselves, establish external generalizability. Because all candidate architectures in the present study were evaluated using the same observations, target definitions, and evaluation protocol, the results provide a preliminary internal comparison of model configurations. Nevertheless, limited sample sizes can produce substantial uncertainty in performance estimates and increase sensitivity to data partitioning [
38] while insufficient dataset size and diversity may restrict model transfer across biological materials and imaging conditions [
40]. Therefore, the reported performance should be interpreted as preliminary evidence under the acquisition conditions represented in this experiment, rather than as evidence of generalization across fields, cultivars, seasons, geographic regions, or imaging systems.
To address these limitations, future research will expand the dataset by incorporating images of open-field lettuce grown in different geographical regions, across various growing seasons, and of diverse varieties. Synthetic data augmentation techniques—including lighting adjustments, image rotation, and blurring—will be employed to simulate environmental noise encountered in actual agricultural production. A transfer learning approach will be adopted: ResNet50_SA_RV1 will first be pre-trained on large public agricultural image datasets like PlantVillage, followed by fine-tuning using lettuce nutrient data to enhance its ability to generalize features. Additionally, a lightweight crop-specific feature adaptation layer will be integrated into ResNet50_SA_RV1 to establish a cross-species adaptive framework. For other crops such as spinach and cabbage, only this adaptation layer needs to be fine-tuned, eliminating the need to retrain the entire network. Finally, the performance of the quantized model and its compatibility with the computing capabilities of edge hardware will be validated on mainstream agricultural edge devices.
5.4. Future Research Directions
Beyond the specific models compared here, this study provides three reusable inputs for subsequent agricultural model development: architectural evidence that shallow lateral fusion of MSA outperforms deeper stage replacement for tray-level nutrient regression; a batch-grouped cross-validation protocol suited to small, batch-structured agricultural datasets; and a low-cost tray-level RGB acquisition design aligned with fertigation management units. This study validates the effectiveness of combining lateral connection MSA with ResNet50, but in light of the characteristics of agricultural images, the MSA-CNN hybrid architecture still has considerable room for optimization. Future explorations can be carried out as follows:
- (1)
Apply the spatiotemporal MSA mechanism to time-series images of lettuce canopies to model the dynamic changes of nutrients during the growth period, replacing the current single-time-point diagnosis;
- (2)
Explore lightweight MSA variants, such as spatial MSA and depthwise separable MSA, to further reduce model complexity while retaining the ability to model global features. We will continue to explore the balance between performance, biological interpretability, computational efficiency, and environmental robustness of deep learning models in agriculture.
The current experiment does not establish performance under open-field illumination, complex soil/background conditions, occlusion, different cameras, other lettuce cultivars, or different seasons. Nutrient-related RGB cues may also be confounded by water stress, temperature, disease, senescence, or cultivar pigmentation. External multi-site and multi-season validation is therefore required before agronomic deployment.
6. Conclusions
This study explores the performance differences between the classic ResNet50 model and its improved version ResNet50_SA_RV1 in extracting and propagating lettuce canopy features. The multi-scale attention mechanism (MSA) introduced by ResNet50_SA_RV1 significantly enhances feature extraction capabilities, particularly in preserving the detailed information of the lettuce canopy and accurately capturing advanced semantic features across different network layers. Through experiments, we observed that ResNet50_SA_RV1 outperformed other models on both the validation set and the test set. The model showed higher accuracy in terms of R2 values, RMSE, and MAE. Notably, ResNet50_SA_RV1 achieved these results with a relatively low number of parameters (62.8 M) and computational cost (17.065 GFLOPS), demonstrating its superiority in performance and computational efficiency, suitable for scenarios with high requirements for performance and computational efficiency in practical applications. However, we also notice that models with higher complexity (such as ResNet50_SA_RV3) do not necessarily lead to better performance. Instead, these models are more prone to overfitting, resulting in poor performance on unseen data. This suggests that balancing model complexity with an effective feature extraction mechanism is key to optimizing performance in deep learning tasks. This conclusion is further supported by the grouped five-fold cross-validation by sampling batch, in which ResNet50_SA_RV1 maintained stable and significantly superior performance (R2 = 0.92 ± 0.03; Holm-adjusted p < 0.001 versus the ResNet50 baseline), demonstrating that the MSA-based improvement is robust to data partitioning.
Overall, the findings of this study emphasize the importance of integrating attention mechanisms, such as MSA, into traditional CNN architectures like ResNet50 for enhanced feature extraction and improved model performance. Future work could further optimize the attention module and explore its applications in areas beyond lettuce canopy analysis.