[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Next Article in Journal
Contact Parameter Calibration for Discrete Element Potato Minituber Seed Simulation
Previous Article in Journal
Increase or Reduce: How Does Rural Infrastructure Investment Affect Villagers’ Income?
You seem to have javascript disabled. Please note that many of the page functionalities won't work as expected without javascript enabled.
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Field Grading of Longan SSC via Vis-NIR and Improved BP Neural Network

1
College of Engineering, South China Agricultural University, Guangzhou 510642, China
2
Guangdong Laboratory for Lingnan Modern Agriculture, Guangzhou 510642, China
3
State Key Laboratory of Agricultural Equipment Technology, Beijing 100083, China
*
Author to whom correspondence should be addressed.
Agriculture 2024, 14(12), 2297; https://doi.org/10.3390/agriculture14122297
Submission received: 16 November 2024 / Revised: 5 December 2024 / Accepted: 12 December 2024 / Published: 14 December 2024
(This article belongs to the Section Digital Agriculture)
Figure 1
<p>Block diagram of the hardware system structure.</p> ">
Figure 2
<p>Perspective view of the device.</p> ">
Figure 3
<p>Physical drawing of the device: (<b>a</b>) internal structure of the device; (<b>b</b>) overall view of the device.</p> ">
Figure 4
<p>Spectral collection points.</p> ">
Figure 5
<p>Overall structures of the BPNN and Brix-BPNN.</p> ">
Figure 6
<p>Structural diagram of the ECA-Brix attention mechanism.</p> ">
Figure 7
<p>H-swish and ReLU activation functions.</p> ">
Figure 8
<p>Max pooling process for longan spectral data.</p> ">
Figure 9
<p>Original spectral curves.</p> ">
Figure 10
<p>Average spectral curves of the three SSC grades.</p> ">
Figure 11
<p>Feature wavelength selection of longan SSC based on the SPA algorithm: (<b>a</b>) RMSE variation of the model; (<b>b</b>) optimal feature wavelength selected by SPA.</p> ">
Figure 11 Cont.
<p>Feature wavelength selection of longan SSC based on the SPA algorithm: (<b>a</b>) RMSE variation of the model; (<b>b</b>) optimal feature wavelength selected by SPA.</p> ">
Figure 12
<p>Feature wavelength selection of longan SSC based on the CARS algorithm: (<b>a</b>) number of sample variables; (<b>b</b>) RMSECV.</p> ">
Figure 12 Cont.
<p>Feature wavelength selection of longan SSC based on the CARS algorithm: (<b>a</b>) number of sample variables; (<b>b</b>) RMSECV.</p> ">
Figure 13
<p>Statistical chart of the true and predicted labels for the SSC grade of the test samples.</p> ">
Versions Notes

Abstract

:
Soluble solids content (SSC) measurements are crucial for managing longan production and post-harvest handling. However, most traditional SSC detection methods are destructive, cumbersome, and unsuitable for field applications. This study proposes a novel field detection model (Brix-back propagation neural network, Brix-BPNN), designed for longan SSC grading based on an improved BP neural network. Initially, nine preprocessing methods were combined with six classification algorithms to develop the longan SSC grading prediction model. Among these, the model preprocessed with Savitzky–Golay smoothing and the first derivative (SG-D1) demonstrated a 7.02% improvement in accuracy compared to the original spectral model. Subsequently, the BP network structure was refined, and the competitive adaptive reweighted sampling (CARS) algorithm was employed for feature wavelength extraction. The results show that the improved Brix-BPNN model, integrated with the CARS, achieves the highest prediction performance, with a 2.84% increase in classification accuracy relative to the original BPNN model. Additionally, the number of wavelengths is reduced by 92% compared to the full spectrum, making this model both lightweight and efficient for rapid field detection. Furthermore, a portable detection device based on visible-near-infrared (Vis-NIR) spectroscopy was developed for longan SSC grading, achieving a prediction accuracy of 83.33% and enabling fast, nondestructive testing in field conditions.

1. Introduction

Longan, a specialty fruit native to tropical and subtropical regions, is rich in nutrients and valued for its nourishing and tonic properties [1]. Its fresh fruit, dry fruit, and canned sugar water are globally traded, contributing significantly to economic value [2]. Measuring the soluble solids content (SSC) is essential for evaluating fruit maturity, guiding postharvest treatments, and determining the optimal harvest time [3]. Conventional SSC detection relies primarily on digital refractometers, which suffer from drawbacks such as destructive sampling, tedious operation, and low efficiency [4]. Consequently, there is an urgent need for innovative methods that enable rapid, accurate, and nondestructive SSC evaluation. With the development of spectral detection technology, nondestructive methods based on spectroscopy have been extensively applied to assess the quality of fruits such as pears, apples, and others [5,6,7,8]. However, the bulky design and high costs of most spectral detection equipment hinder their practical application in the fields. Therefore, there is an urgent need to develop efficient nondestructive testing methods and portable equipment for fruit quality. In recent years, researchers have designed and utilized portable spectral detection devices to measure the SSC in fruits such as apples and balsam pears [9,10,11]. However, studies on field detection algorithms and portable detection devices specifically for longan fruits are still scarce.
Meanwhile, deep learning technology is advancing rapidly and shows significant potential in the field of spectral detection [12,13]. With their superior feature extraction and pattern recognition capabilities, deep learning algorithms have achieved remarkable success in predicting the SSC of various fruits. For example, Qiao et al. [14] effectively predicted the SSC and firmness index (FI) of blueberries using hyperspectral imaging combined with the MS-SPA-BPNN model. Zheng et al. [15] developed an apple SSC prediction model using 1D-CNN and PLSR models, demonstrating that the 1D-CNN model can simplify the Vis-NIR spectral modeling process. Qi et al. [8] utilized Vis-NIR and MLP-CNN-TCN deep learning models to achieve fast and nondestructive SSC prediction for crown pear. However, the unique characteristics of longan fruits (such as their hard shell, large seed, and low flesh content) pose significant challenges. These factors impair spectral signal transmittance, increasing the complexity of spectral detection and introducing substantial interference. Consequently, the accuracy and stability of traditional deep learning algorithms for SSC prediction in longan are considerably reduced. Moreover, no specifically SSC prediction model for longan has been developed so far. Therefore, developing an SSC prediction model for longan has become imperative to fulfill the need for the rapid, nondestructive testing of longan fruit ripeness in the field. Such a model would also offer a scientific foundation and decision-making support for mid-production management and postharvest handling.
This study aims to tackle the challenges associated with SSC detection in longan fruits by proposing a qualitative analytical model, the Brix-back propagation neural network (Brix-BPNN), based on an improved BP neural network for rapid and nondestructive SSC detection. The effectiveness and applicability of Brix-BPNN in longan SSC detection were validated through experimental comparisons. Additionally, a portable detection device suitable for field environments was designed and tested. This research offers an effective solution for the quality assessment of longan fruits.

2. Materials and Methods

2.1. Test Samples

The experimental samples were “Chuliang” longans collected from the Longan Garden of the Fruit Tree Research Institute of Guangdong Academy of Agricultural Sciences, Guangzhou, China. A total of 350 Chuliang longans of similar shape and size were selected by a random sampling method. The samples were returned to the laboratory within 1 h after picking, and spectral data collection and soluble solids content determination experiments were carried out at room temperature. Before collecting the spectra, impurities on the sample surface were removed, and samples with damage or defects were excluded, resulting in 325 test samples.
In this study, the SSC (denoted as S) of 325 longan fruits was graded according to the quality grading standard for fresh longan [16]. According to the standard, S ≥ 21.0% is classified as a super-grade, first-grade, or second-grade fruit; 21.0% > S ≥ 19.0% is classified as a third-grade fruit; and S < 19.0% is classified as an equal external fruit. The specific grade classification is shown in Table 1. These three levels are denoted as 0, 1, and 2 in the classification model.

2.2. Portable Detection Device

To achieve rapid field detection of longan SSC and meet the need for real-time fruit quality assessment during the harvest season, ensuring optimal harvesting timing, optimizing management, and increasing value, this study designed a portable detection device based on a fiber optic spectrometer. By collecting spectral information from the longan and utilizing a classification prediction model embedded in the instrument, the device enables nondestructive, on-site detection of longan SSC grades.
Figure 1 shows a block diagram of the hardware system structure of the portable detection device. The spectrometer used in this paper is a SPEC-CMS960 fiber optic spectrometer (Pynect, Shenzhen, China) with a wavelength range of 190.357–1100.1 nm and an optical resolution of approximately 2.6 nm. The Youyeetoo X1 SBC x86 control board (SmartFLY Tech. Corp., Shenzhen, China) was selected. The light source used was an LS-H100-type adjustable halogen tungsten light (Pynect, Shenzhen, China) source with a power of 100 W and an effective wavelength range of 380–2500 nm. An RP-N600-7D-1M-ST reflective Y-type fiber probe (Pynect, Shenzhen, China) was used, and the wavelength range was 300–2600 nm.
The portable detection device is shown in Figure 2 and Figure 3. The overall size is 320 mm × 220 mm × 240 mm. A black rubber material hood was designed at the probe to avoid interference from natural light when collecting spectra. When the portable detection device works, Longan’s spectral reflectance information is obtained through the acquisition module, and the spectral signal is converted into a digital signal and transmitted to the control module for data processing and calculation. The detection results are displayed through the display module, and finally, the spectral data and detection results are saved.

2.3. Modeling Method

2.3.1. Spectral Data Acquisition

The spectral equipment was preheated and whiteboard corrected before spectrum acquisition. The experimental parameters were set to an integration time of 10 ms, averaging number of 10, and smoothing number of 5. The spectrum acquisition range was 190.357–1100.1 nm, and there were 1365 bands in the spectral range. The spectral collection point (Figure 4) is the equatorial part of each sample, collected every 90°, and four spectra are collected for each sample. When the spectrum is collected, the reflection probe is closely attached to the surface of the longan sample to be measured, and the light source is transmitted to the probe through the optical fiber to illuminate the sample. The probe receives the diffuse light signal from the sample, transmits it through the optical fiber to the spectrometer, and then saves the data.

2.3.2. Determination of Longan SSC Values

The SSC of longan varies with storage time and environment. Therefore, SSC measurements should be performed immediately after spectral acquisition to obtain more accurate data. The SSC was determined using an ATAGO PAL-BX/ACID3 sugar acidity meter (ATAGO Tech. Corp., Tokyo, Japan); the measurement range was 0–60%, and the measurement accuracy was 0.2%. The longan was peeled and squeezed, and the juice was dropped into the measurement area of the sugar acidity meter for reading. The measurements were repeated three times for each longan sample, and the average value was taken as the real measurement value of the SSC.
In this study, the longan dataset was divided into a training set and a test set without a separate validation set. This approach was adopted to ensure that the training set contained sufficient data to support effective neural network training. Given the relatively small size of the longan dataset, further splitting it to create a validation set could result in an excessively small training set, potentially compromising the model’s learning capacity and overall performance [17]. Table 2 shows the statistical results for the SSC of longan. In this experiment, the SSC range of the training set samples is 14.67% to 24.00%, and the SSC range of the test set samples is 15.95% to 23.65%. The SSC range of the training set samples encompasses the range of the test set samples, so the SSC prediction model established by the training set can be applied to the test set samples.

2.3.3. Spectral Data Preprocessing Method

The original spectral data includes both the sample’s characteristic information and extraneous information like instrument noise, baseline drift, and stray light [18]. Therefore, preprocessing is a crucial step to ensure the accuracy and reliability of the model. This study considers that different spectral preprocessing techniques address various issues in spectral data (such as denoising, smoothing, baseline correction, etc.), which, ultimately, have different impacts on model performance. In this study, several common and effective preprocessing methods are used, including multiplicative scatter correction (MSC), standard normal variate (SNV), first derivative (D1), mean centering (CT), Savitzky–Golay smoothing (SG), and their combinations, to preprocess the spectral data. By comparing multiple methods, we aim to gain a more comprehensive understanding of the data characteristics and optimize model performance.

2.3.4. Feature Wavelength Selection Method

The original spectral data have a large amount of data and contain considerable redundancy, noise, and other invalid information. By effectively extracting the characteristic wavelengths associated with SSC, the dimensionality of the data can be significantly reduced and the invalid information can be reduced, thus reducing the computational complexity and improving the efficiency of SSC detection in longan in the field. The successive projection algorithm (SPA) [19] confers the advantages of strong robustness, fast convergence speed, and parallelization in feature wavelength extraction. The competitive adaptive reweighted sampling algorithm (CARS) [20] is outstanding for mining the relationships between features and adaptive weight adjustment. Therefore, the SPA and CARS algorithms were utilized for feature wavelength selection, and a small number of selected feature wavelengths with low collinearity and reduced redundancy, and that contain the most effective information, are used as the input variables of the prediction model to improve the prediction ability and stability.

2.3.5. Classification Models

Due to the high-dimensional, complex, and nonlinear nature of spectral data, selecting the appropriate classification algorithm is crucial. To establish the optimal model for longan SSC classification, this study fully considers the data characteristics and task requirements of longan SSC grading, as well as the advantages of various common traditional machine learning methods and deep learning techniques. Six classification algorithms were selected, including support vector machine (SVM), K-nearest neighbors (KNN), logistic regression (LR), random forest (RF), backs propagation neural network (BPNN), and convolutional neural network (CNN). Through a comprehensive comparison of these methods, the goal was to determine the most effective classification model for achieving more accurate and efficient longan SSC classification. The results indicate that the BPNN model achieved the best classification performance. Therefore, in order to further improve the accuracy and efficiency of longan SSC detection, this study innovatively proposes an improved Brix-BPNN model based on the BP neural network, specifically designed for the precise prediction of longan SSC grades.

2.3.6. Proposed Brix-BPNN Model

The Brix-BPNN model is mainly composed of a Brix module, an activation function module, and a pooling module. The Brix module includes a normalization module, an attention mechanism module, and a convolution module, etc. The overall network structures of the BPNN model and the improved Brix-BPNN model are shown in Figure 5.
Typically, the spectral data of longan exhibit two-dimensional characteristic wavelengths, with overall spectral features that are irregular, inconspicuous, and widely distributed. This situation easily leads to multiple sets of spectra with similar feature wavelengths, relatively flat feature wavelengths, and overlapping phenomena. Therefore, in this paper, 78 two-dimensional feature wavelength tensors X are selected by the CARS algorithm, and a dimension is added as the number of channels, C, so that the data can be better input into the Brix-BPNN convolutional neural network for feature processing. Second, the feature mapping characteristics of the fully connected layer-A module were used to linearly extract and convert the 3D feature wavelength to map the subsequent module for spectral feature extraction. The extracted 3D spectral feature wavelengths were input into the batch normalization module in the Brix module. The batch normalization module standardizing and regularizing each mini batch during the training process helps to reduce the risk of model overfitting and improve the generalization ability of the model. At the same time, reducing the internal covariate shift helps to reduce the problems of gradient disappearance or gradient explosion, thus accelerating the convergence of the Brix-BPNN model.
To improve the correlation and expression ability between the longan SSC and spectral features, and to reduce the negative impact of redundant information and noise on the BP neural network to help the model focus on the most distinctive and important features in the input, the ECA-Brix Attention mechanism module was introduced within the Brix module. The ECA-Brix attention mechanism incorporates a φ module that spreads the spectral features into a single vector, and an ω module that changes the height and width of the spectral features to one. Specifically, the φ module spreads the features in each sample to generate a spectral tensor φ of shape (batch_size,1, height × width × channels), making subsequent processing (e.g., passing into the fully connected layer) easier. The ω module keeps the channels of each sample unchanged while changing them to 1 in height and width, thus generating a spectral tensor ω of shape (batch_size,channels,1), making it easy to compute with tensors of other shapes. The specific structure of the ECA-Brix attention mechanism is shown in Figure 6. By introducing the improved ECA-Brix attention mechanism, the input spectral value tensors can be rearranged and combined. It adaptively learns the importance and weight of each channel and better captures the dependencies between different feature channels, making the model devote more attention to the feature channels related to the longan SSC prediction task. Thus, the correlation and expression ability between the longan SSC and spectral features are improved, and the accuracy and robustness of the model in the prediction of SSC grade are improved. At the same time, compared with a conventional attention mechanism (such as the squeeze-and-excitation module used in SENet), the ECA-Brix attention mechanism adopts a one-dimensional convolution operation, which can calculate channel attention without introducing excessive additional parameters, reducing the computational complexity and storage requirements of the model. This approach is conducive to the development and application of portable devices.
At the same time, to improve the ability of the Brix-BPNN neural network model to learn the complex nonlinear mapping relationship between the longan SSC and spectral values, the H-swish activation function A is connected after the ECA-Brix attention mechanism module. This activation function only requires simple addition, subtraction, and multiplication operations, and has low computational cost. It is more suitable for processing high-dimensional spectral data and has a non-zero gradient in the negative region, which can effectively alleviate the problem of gradient disappearance and improve the training stability of the model in the deep network. At the same time, the H-swish activation function introduces nonlinear transformation, so that the model can better adapt to the data distribution of various complex spectra when activating the output and improve the accuracy and robustness of the model prediction.
The principal formula of the H-swish activation function is shown in Equation (1). Compared with the ReLU activation function in the BPNN model, H-swish not only has the advantages of relatively simple calculations and high computational efficiency but also has a smoother curve (Figure 7), which can help the model better handle spectral data in the spectral data list. In addition, the performance of the model is improved.
H a r d S w i s h x = x × H a r d S i g m i o d x = x × R e L u 6 x + 3 6 = x × 1 , x 3 x 6 + 1 2 , 3 < x < 3 0 , x 3
Moreover, to fully utilize the limited resources and arithmetic power of the portable detection device, as well as to help the model extract the most significant features in the region of the spectral feature list, the max-pooling module and the convolutional layer module are introduced in the second half of the Brix module. The max-pooling module effectively extracts key features from spectral data by selecting the maximum values within local regions while reducing the computational burden (as shown in Figure 8), and ensures that the slight translation of the input features within a certain range does not change the position of the maximum value, helping to improve the robustness and generalization ability of the Brix-BPNN model. The role of the convolution module is to perform sliding window calculations on the input spectral data through the convolution kernel to extract local features in the input data. At the same time, by exploiting the “sparse interaction” property of the convolution module, only the local region of the input spectral data is focused, without the full connection with all the input spectral data. This interaction reduces the amount of calculation, improves the computational efficiency, and helps to capture the spatial structure information in the spectral data list.
Finally, the H-swish activation function B and the fully connected layer B module were connected after the Brix module. The secondary activation through the H-swish activation function can further enhance the nonlinear characteristics so that the Brix-BPNN model can better fit the complex data distribution output from the Brix module and improve the expression ability and generalization ability of the model. The fully connected layer B module performs further linear transformation of the features, uses the squeeze () function to remove the channel number dimension C of the output tensor X, and restores the spectral data after feature extraction into a two-dimensional tensor.
The improvement of the BP network structure aims to enhance the model’s performance in longan SSC classification, with these optimizations primarily focused on more effectively capturing and processing spectral data. Specifically, by introducing the channel dimension and one-dimensional convolution, the model is better able to capture local features of SSC. The ECA module further optimizes channel weights, focusing on key features to reduce noise interference. Additionally, normalization accelerates convergence to ensure stability in the learning process. The H-swish activation function enhances the model’s adaptability to diverse data. Finally, pooling layers effectively reduce dimensionality, preserving key features and improving robustness. These optimizations have improved the accuracy, stability, and generalization ability of the Brix-BPNN model.

2.3.7. Model Parameter Setting and Evaluation

To determine the performance of the established model, four main evaluation metrics, namely, accuracy, precision, recall, and harmonic mean F1 score, are used to evaluate the classification model. The traditional machine learning model parameters and deep learning model parameters are summarized in Table 3 and Table 4, respectively.

2.4. Field Experiment Method

The designed portable detection device was used to verify the field experiment of longan SSC grade prediction, which was carried out in the Longan Garden of the Fruit Tree Research Institute of Guangdong Academy of Agricultural Sciences, China. The longan garden was divided into 10 regions, and three fruits from one longan tree were randomly selected in each region for detection so that 30 Chuliang longans were detected. The test was repeated three times for each fruit, and the results were recorded to ensure the reliability of the results. After the field test, the fruits were picked and numbered. Within 1 h, the SSC values were measured by a sugar acidity meter, and the grades were recorded to verify the accuracy of the prediction results.

3. Results

The dataset used in this study was sourced from the longan orchard of the Fruit Tree Research Institute, Guangdong Academy of Agricultural Sciences, China, with the “Chuliang” variety of longan selected as the experimental sample. A random sampling method was applied to randomly select 350 longan samples with similar shapes and sizes. After manual screening to remove surface impurities and exclude damaged or defective samples, a final dataset of 325 “Chuliang” longan samples was obtained for model training and evaluation. To ensure fairness, the training and test datasets were kept consistent across all models, with 244 samples designated for training and 81 samples for testing.
All experiments were conducted under the same experimental environment. The experimental setup included a Windows 10 operating system, with Python 3.9, CUDA 11.7, and PyTorch 2.0, and hardware configuration comprising an Intel(R) Core(TM) i5-9300H CPU @ 2.40 GHz and an NVIDIA GeForce GTX 1650 GPU. During model training, the initial learning rate was set to 0.001, and the training period (epochs) was 300.
To validate the effectiveness and fairness of the Brix-BPNN model, we designed a series of horizontal comparative experiments and performed ablation analyses focusing on the model’s improvements. Training and validation were conducted under identical hyperparameter conditions, and these experiments demonstrated the performance advantages of the Brix-BPNN model under the same conditions.

3.1. Sample Spectral Analysis

Due to the significant spectral noise at the beginning (190.357–300.475 nm) and termination (950.248–1100.100 nm) of the spectrum, to maintain the spectral curve with a high signal-to-noise ratio, only the 300.475–950.248 nm band, which included 975 wavelengths, was selected for subsequent analysis. The original spectral curves are shown in Figure 9. It can be seen from the figure that longan spectral curves of different SSC grades have similar trends, and their absorption peak positions are roughly similar. The average spectral curves of longan with three SSC grades are shown in Figure 10. It can be seen from the curves that the differences between different SSC grades are obvious in the ranges of 500–680 nm and 700–880 nm, and the spectral reflectance of longan increases with increasing soluble solid content. Therefore, it is feasible to classify the SSC of longan using spectral data.

3.2. Results of Spectral Data Preprocessing

The original spectral data and the full-band spectral data after different preprocessing were substituted into different models to analyze the effects of the different preprocessing methods on the performances of the different models. The experimental results are shown in Table 5.
The modeling results show that different preprocessing methods have different modeling effects on different models, and most of them improve the prediction performance of the model. Among the nine preprocessing methods, Savitzky–Golay smoothing combined with the first derivative preprocessing method (SG-D1) has the best effect, and the accuracy of the six classification models established by SG-D1 is higher than that of the other preprocessing methods. Comparing the modeling effects of the six classification models revealed that the accuracies of the BPNN models established by different preprocessing methods are mostly greater than those of the other classification models. Among them, the BPNN model preprocessed by SG-D1 has the best modeling result, and the model classification accuracy reaches 69.10%, which is 7.02% higher than that of the original spectral model. Therefore, in this paper, the SG-D1 preprocessing method was used to preprocess the original spectral data, and the BP neural network was used to establish a longan SSC grading prediction model.

3.3. Characteristic Wavelength Selection

To eliminate a significant amount of redundant, noisy, and invalid information from the original spectral data, reduce model complexity, and enhance detection efficiency to meet the rapid real-time detection needs for longan fruits in the field, SPA and CARS feature extraction algorithms were employed for dimensionality reduction. This is of great value to orchard staff in assessing the maturity of longan in a timely manner and optimizing the timing of picking.

3.3.1. Results of SPA Feature Wavelength Selection

The process of applying the SPA algorithm to the longan spectral data preprocessed by SG-D1 for feature wavelength selection is shown in Figure 11a. The SPA determines the number of feature wavelengths according to the root mean square error (RMSE). Figure 11a shows that with an increase in the number of wavelengths, the RMSE quickly decreases to the lowest point and then tends to flatten after a small fluctuation. When the RMSE reaches the minimum value, the 20 optimal feature wavelengths are identified as [327.584, 341.479, 362.667, 364.654, 367.967, 448.903, 464.85, 479.475, 558.029, 600.706, 674.164, 682.185, 719.636, 728.334, 873.734, 887.152, 898.559, 905.27, 911.31, and 916.68], and the specific distributions are shown in Figure 11b.

3.3.2. Results of CARS Feature Wavelength Selection

The process of applying the CARS algorithm to longan spectral data preprocessed by SG-D1 for feature wavelength selection is shown in Figure 12. The number of Monte Carlo samples is set to 50. Figure 12a shows that the number of selected wavelengths gradually decreases with increasing sampling time. Figure 12b shows that the RMSECV first decreases and then increases with increasing sampling time, and when the number of iterations reaches 20, the RMSECV reaches the minimum value, at which point 78 feature wavelengths are selected.

3.4. Results of BP Neural Network Modeling

The BPNN classification prediction model for the longan SSC grade is established based on full-band spectral data and the feature wavelengths selected by the SPA and CARS algorithms, and the influence of the number of wavelength variables on the performance of the model is compared and analyzed.
Table 6 shows that the BPNN model established based on the full band has the best prediction effect, with an accuracy of 69.10%. Compared with those of the full band, the numbers of feature wavelengths selected by the SPA and CARS algorithms are reduced by 98% and 92%, respectively, and the model training efficiency is significantly improved, while the modeling accuracy is reduced by only 1.69% and 0.84%, respectively, compared with that of the full band. There is also only a small decrease in the precision, recall, and harmonic mean F1 score. The results show that a large amount of invalid spectral information is eliminated, which significantly improves the operating efficiency and stability of the BPNN model and makes the model more suitable for practical portable detection device applications in the field. Therefore, the BPNN model established based on the feature wavelength has good predictive ability for the nondestructive testing of longan SSC grading.
The modeling accuracy of the 78 feature wavelengths selected by the CARS algorithm combined with the BP neural network is 68.26%, which is higher than the 67.41% achieved by the 20 feature wavelengths selected by the SPA algorithm, which indicates that some important features may be lost during SPA feature wavelength selection, thus reducing the prediction performance of the model.

3.5. Results of Brix-BPNN Modeling

The improved Brix-BPNN model was used to establish a qualitative analysis model of longan SSC grade based on the full band and feature wavelengths, and the classification results are shown in Table 5. According to Table 4 and Table 5, compared with the BPNN model, the Brix-BPNN model achieves better modeling effects for different wavelength variables, with improved values of the four evaluation indicators and model performance. The modeling accuracies of the full-band, 20-feature-wavelength, and 78-feature-wavelength models are 69.66%, 68.25%, and 71.10%, respectively, which are 0.56%, 0.85%, and 2.84% higher than those of the BPNN model. This indicates that the Brix-BPNN model achieves better predictive performance than the BPNN model in the qualitative analysis of longan SSC grades.
Table 7 shows that the longan SSC classification model established by 78 feature wavelengths selected by the CARS algorithm has the best prediction effect, and the accuracy of the model is 1.44% higher than that of the full-band model and 2.85% higher than that of the 20-feature-wavelength model; the precision, recall rate and harmonic mean F1 score of the proposed model are also greater than those of the full-band model and the 20-feature-wavelength model. This further indicates that feature wavelength selection helps improve the overall prediction performance and stability of the model, while too few feature wavelength variables may eliminate some important features, thereby reducing the prediction performance of the model.
Therefore, combining the feature wavelengths selected by the CARS algorithm with the improved Brix-BPNN neural network model resulted in a classification accuracy of 71.10%, achieving the best prediction performance. The CARS algorithm performed excellently in selecting feature wavelengths from the longan SSC spectral data. Compared to using the full spectrum, it effectively reduced the number of wavelengths by 92% while retaining key information, thereby alleviating the computational burden on the model and shortening the training duration. This improvement enhances the model’s training efficiency and prediction speed, which is particularly crucial for deploying the model in field environments and enabling real-time detection.

3.6. Results of Model Ablation and Comparison Experiments

To further validate the superiority of the proposed CARS+Brix-BPNN model, ablation experiments were conducted, and the results are presented in Table 8. Model 1 represents the original structure of the BPNN model based on the full spectrum, while Model 2 represents the original structure of the BPNN model constructed using 78 feature wavelengths extracted by CARS. Model 3 incorporates a Batch Normalization module into the front-end of the CARS+BPNN model, and Model 4 integrates the improved ECA-Brix attention mechanism into the front-end of the CARS+BPNN model. Model 5 replaces the ReLU activation function with the H-Swish activation function in the CARS+BPNN model. Model 6 integrates a Max-Pooling module into the backend of the CARS+BPNN model, and Model 7 incorporates a convolution module into its backend. Model 8 integrates both the Batch Normalization module and the improved ECA-Brix attention mechanism into the front-end of the CARS+BPNN model, while Model 9 builds on Model 8 by replacing the ReLU activation function with the H-Swish activation function. Model 10 extends Model 9 by incorporating a Max-Pooling module. Model 11 integrates the Brix-Module into the middle section of the CARS+BPNN model, and Model 12 represents the proposed CARS+Brix-BPNN model structure in this study.
As shown in Table 8, incorporating the Batch Normalization module, the improved ECA-Brix attention mechanism, the Max-Pooling module, and the convolution module into the CARS+BPNN model, as well as replacing the ReLU activation function with the H-Swish activation function, all contributed to improvements in the model’s accuracy, with the highest improvement reaching 0.84%. Furthermore, progressively combining and applying individual modules to the CARS+BPNN model demonstrated that each combination algorithm improved the model’s accuracy, precision, recall, and F1 score, exhibiting a cumulative performance effect. Among these, the combination of the CARS+BPNN model with the Brix-Module further enhanced the model’s overall performance. Ultimately, compared to the full-spectrum BPNN model, the CARS+Brix-BPNN model reduced the number of wavelengths by 92%, while improving accuracy and precision by 2% and 1.61%, respectively. These findings indicate that the proposed Brix-BPNN model not only achieved improved detection accuracy but also successfully realized model lightweighting, meeting the requirements for both accuracy and efficiency in predictive modeling.
To further validate the efficiency and adaptability of the proposed Brix-BPNN model in classifying and recognizing SSC within complex longan spectral data, comparative experiments were conducted with various machine learning models. The Brix-BPNN model was compared with several BPNN variants, including MLP, Dropout-BPNN, Residual-BPNN, and ResNet-BPNN. Four performance metrics—accuracy, precision, recall, and F1 score—were selected to comprehensively evaluate and analyze the performance of each model. The experimental results are presented in Table 9.
Based on the results in Table 9, the proposed Brix-BPNN model outperforms other classical models in both detection accuracy and precision. Compared to other models, the Brix-BPNN model achieved an average improvement of 2.53% in accuracy and 4.29% in precision. Considering all performance metrics comprehensively, the Brix-BPNN model demonstrates the best overall performance, showcasing exceptional capabilities in analyzing longan spectral features as well as identifying and classifying SSC. It effectively meets the dual requirements of real-time performance and high accuracy.

3.7. Field Experiment Verification

Embedding the improved optimal Brix-BPNN model into the developed portable detection device, the stability and accuracy of the model were verified according to the field experiment method mentioned in Section 2.4. The SSC grade of 30 Chuliang longan fruits was predicted, and the SSC values were measured with a sugar acidity meter. The true and predicted labels of the longan samples are shown in Figure 13, and a summary of the test results is provided in Table 10.
Among the 30 test samples, 25 were correctly predicted, resulting in an overall classification accuracy of 83.33%, which is generally sufficient for the rapid, nondestructive field detection of longan SSC classification. Among the five misclassified samples (numbers 8, 11, 17, 21, 26), three samples had SSC values of 21.20% (sample 11), 20.75% (sample 17), and 18.80% (sample 26), which are very close to the classification thresholds of 21% and 19%, respectively. This proximity to the critical thresholds may have been the primary cause of misclassification. Furthermore, the misclassification of samples 8 and 21 might have been influenced by field environmental factors such as lighting and humidity, as well as noise or feature interference in the spectral data, which led to the model incorrectly identifying the true classification of these samples. The test results show that this classification model performs well in predicting longan samples. Future research plans include further improving the model algorithm and enhancing data preprocessing, particularly by controlling the surface conditions of the samples and environmental factors, to improve the classification accuracy of longan fruit.

4. Discussion

Based on the results of the study, the proposed nondestructive detection method based on Vis-NIR spectroscopy, along with the portable device, has shown remarkable performance in the classification of longan SSC. Compared to traditional SSC detection methods such as refractometry and chemical titration, the spectral method offers higher sensitivity and accuracy, and it allows for rapid measurement without the need for sample pretreatment. This greatly improves detection efficiency and convenience. Furthermore, the developed portable device has the advantages of compact structure and ease of operation, enabling real-time field detection and overcoming the limitations of traditional methods that require specialized laboratory settings and complex operating procedures.
The spectral analysis results show that there are distinct differences in the spectral data of longan at different SSC levels within the wavelength ranges of 500–680 nm and 700–880 nm. As the SSC content increases, the reflectance gradually increases, indicating that it is feasible to use spectral data for the classification and detection of longan SSC.
Preprocessing is crucial for enhancing the robustness and reliability of the model, especially in real-time on-site prediction scenarios, as it removes noise and improves the quality of the spectral data [21]. The results of spectral data preprocessing indicate that using the Savitzky–Golay smoothing method combined with the first derivative (SG-D1) effectively reduces noise in the raw spectral data caused by environmental and equipment factors, while enhancing the spectral features related to the longan SSC. Compared to other preprocessing methods, SG-D1 shows significant effectiveness in noise reduction and the enhancement of subtle features, making the final spectral data more stable and of higher quality, which, in turn, improves the predictive performance of the model. Furthermore, the study results suggest that combining different preprocessing methods is more effective than using a single preprocessing method in improving both spectral data quality and model performance, as also demonstrated in other studies [22].
This study employed two feature extraction algorithms, SPA (Successive Projections Algorithm) and CARS (Competitive Adaptive Reweighted Sampling), to select wavelengths most relevant to longan SSC from the spectral data. This process retained key information while effectively reducing the number of spectral variables, thus improving training efficiency, reducing computational load, and speeding up prediction, which is crucial for real-time field detection. The results showed that SPA performed well in dimensionality reduction efficiency, whereas CARS exhibited superior classification accuracy, consistent with the findings of Cheng et al. [23], who also found that CARS retained more classification-relevant information, thereby enhancing the model’s predictive capability. However, despite CARS outperforming SPA with smaller datasets in this study, a balance between efficiency and accuracy in real-time applications with larger datasets still requires further investigation.
The Brix-BPNN model proposed in this study significantly improved the accuracy and stability of longan SSC classification compared to the original BPNN model. By incorporating a Brix module, which includes normalization, attention mechanisms, and convolutional modules, the model more effectively captures and enhances key information, significantly improving classification accuracy and stability. However, compared to studies on SSC detection in other fruits, the prediction accuracy in this study was slightly lower. Liu et al. [24] used visible-near-infrared spectroscopy combined with the BPNN model to achieve 90% accuracy in the measurement of navel orange fruit SSC. Chen et al. [25] utilized the BP-PLS method in combination with NIR to achieve the rapid and accurate detection of SSC in PE-packed blueberries (Rp2 = 0.947). Several factors contribute to the accuracy of the model. First, the physical characteristics of different fruits may be a major reason for accuracy differences. Longan fruits have a hard shell and low edible portion, making spectral signal acquisition more challenging. The separation of the peel from the pulp may cause spectral interference, affecting data quality and model accuracy. In contrast, fruits such as navel oranges, which have thin and transparent skins, allow for clearer spectral signals and, therefore, higher SSC prediction accuracy. Second, different detection devices can significantly impact model accuracy. Given the goal of enhancing the portability of the device and reducing costs, the spectral detection equipment chosen for this study may have a lower resolution and signal-to-noise ratio compared to other devices used in previous studies, leading to suboptimal spectral data quality and, in turn, affecting model training and prediction performance.
Therefore, in future research, we will consider optimizing the network structure from several aspects to further improve the model performance. For example, we could try to design a more lightweight network structure to reduce the computational complexity, introducing dynamic weight allocation or a dynamic layer selection mechanism, so that the network can adapt to adjust the structure according to the input data, improving the computational efficiency and performance. Or, we could introduce a residual structure to alleviate the gradient disappearance problem of the deep network, and a design multi-branch structure to process different feature or scale information, and carry out feature fusion in the final stage to improve the adaptability to complex tasks.
Moreover, by combining the developed portable device with an efficient classification model, this study has achieved the rapid, nondestructive field detection of longan SSC. The system design of this study places a greater emphasis on the practical needs of field applications, making the detection system suitable for agricultural production environments. Unlike many studies that require laboratory-based testing [14,26], this research provides a new technological solution for the rapid field detection of fruit quality, with promising potential for practical applications in agricultural settings.

5. Conclusions

To achieve the rapid field detection of longan SSC and address the need for real-time fruit quality assessment during the harvest period, ensuring optimal harvest timing, this study proposes a detection method based on an improved BP neural network and develops a portable detection device. Spectral data of Chuliang longan within the 190.357–1100.1 nm wavelength range were collected, pretreated, and analyzed to select characteristic wavelengths. A qualitative analysis model for longan SSC was established and improved subsequently. Finally, the accuracy and stability of the model were validated through experimental testing. The following were the main conclusions:
  • The original spectral data collected were preprocessed by nine preprocessing methods (SG, D1, SNV, MSC, CT, SG-D1, SG-SNV, SG-MSC, and SG-CT) and combined with six classification algorithms (SVM, KNN, LR, RF, BPNN, and CNN) to develop an SSC qualitative analysis model for longan. Among these methods, the SG-D1 preprocessing method paired with the BP neural network demonstrated the best prediction performance. The classification accuracy of the full-band model reached 69.10%, which is 7.02% higher than the accuracy of the original spectral model.
  • The SPA and CARS algorithms were applied to extract feature wavelength spectra following data pretreatment. These were then combined with the BPNN model and the improved Brix-BPNN model to establish a qualitative analysis model for longan SSC, utilizing both the full band and the feature wavelength. The experimental results showed that the Brix-BPNN model, based on 78 feature wavelengths extracted via CARS, achieved the best performance, with a classification accuracy of 71.10%, which is 2.84% higher than that of the original BPNN model. The number of wavelengths was reduced by 92% compared to the full band, making this model lightweight and efficient for rapid field detection.
  • The improved optimal Brix-BPNN model was implanted into the developed portable detection device and validated through field experiments. The SSC grade of 30 Chuliang longan samples was predicted, with 25 accurate predictions, resulting in a total classification accuracy of 83.33%. The results demonstrate that the portable detection system can effectively facilitate the rapid, nondestructive detection of longan SSC grading in the field. The portable detection can serve as a decision-making tool for longan production management and postharvest treatment, offering promising application prospects.

Author Contributions

Conceptualization, G.H. and H.C.; methodology, J.L. and M.Z.; software, M.Z. and K.W.; validation, Z.M. and J.X.; formal analysis, H.C.; investigation, Z.M. and J.X.; data curation, M.Z. and K.W.; writing—original draft preparation, J.L. and M.Z.; writing—review and editing, G.H.; supervision, J.L.; project administration, J.L.; funding acquisition, J.L. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the Guangdong Laboratory for Lingnan Modern Agriculture (NZ2021040 and NT2021009), the Special Project of Rural Vitalization Strategy of Guangdong Academy of Agricultural Sciences (TS-1-4), the China Agriculture Research System (CARS-32), the Guangdong Provincial Agricultural Science and Technology Demonstration (2023-440000-60010000-9818), and the Discipline Construction Project of South China Agricultural University in 2023 (2023B10564002).

Institutional Review Board Statement

Not applicable.

Data Availability Statement

Data available on request due to privacy. The data presented in this study are available on request from the corresponding author. The data are not publicly available due to undisclosed intellectual property content and privacy concerns.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Huang, S.; Lv, X.; Han, Y.; Han, D.; Wei, J.; Li, J.; Guo, D. Disrupted sugar transport and continued sugar consumption lead to sugar decline in ripe ‘Shixia’longan fruit. LWT 2024, 191, 115620. [Google Scholar] [CrossRef]
  2. Zeng, S.; Wang, K.; Liu, X.; Hu, Z.; Zhao, L. Potential of longan (Dimocarpus longan Lour.) in functional food: A review of molecular mechanism-directing health benefit properties. Food Chem. 2023, 437, 137812. [Google Scholar] [CrossRef] [PubMed]
  3. Shao, Y.; Ji, S.; Xuan, G.; Wang, K.; Xu, L.; Shao, J. Soluble solids content monitoring and shelf life analysis of winter jujube at different maturity stages by Vis-NIR hyperspectral imaging. Postharvest Biol. Technol. 2024, 210, 112773. [Google Scholar] [CrossRef]
  4. Guo, W.; Li, W.; Yang, B.; Zhu, Z.; Liu, D.; Zhu, X. A novel noninvasive and cost-effective handheld detector on soluble solids content of fruits. J. Food Eng. 2019, 257, 1–9. [Google Scholar] [CrossRef]
  5. Tian, X.; Fan, S.; Li, J.; Huang, W.; Chen, L. An optimal zone combination model for on-line nondestructive prediction of soluble solids content of apple based on full-transmittance spectroscopy. Biosyst. Eng. 2020, 197, 64–75. [Google Scholar] [CrossRef]
  6. Sirisomboon, P.; Tanaka, M.; Kojima, T.; Williams, P. Nondestructive estimation of maturity and textural properties on tomato ‘Momotaro’by near infrared spectroscopy. J. Food Eng. 2012, 112, 218–226. [Google Scholar] [CrossRef]
  7. Yang, X.; Zhu, L.; Huang, X.; Zhang, Q.; Li, S.; Chen, Q.; Wang, Z.; Li, J. Determination of the soluble solids content in korla fragrant pears based on visible and near-infrared spectroscopy combined with model analysis and variable selection. Front. Plant Sci. 2022, 13, 938162. [Google Scholar] [CrossRef]
  8. Qi, H.; Shen, C.; Chen, G.; Zhang, J.; Chen, F.; Li, H.; Zhang, C. Rapid and nondestructive determination of soluble solid content of crown pear by visible/near-infrared spectroscopy with deep learning regression. J. Food Compos. Anal. 2023, 123, 105585. [Google Scholar] [CrossRef]
  9. Yuan, W.; Zhou, H.; Zhou, Y.; Zhang, C.; Jiang, X.; Jiang, H. In-field and nondestructive determination of comprehensive maturity index and maturity stages of Camellia oleifera fruits using a portable hyperspectral imager. Spectrochim. Acta Part A 2024, 315, 124266. [Google Scholar] [CrossRef] [PubMed]
  10. Yu, Y.; Zhang, Q.; Huang, J.; Zhu, J.; Liu, J. Nondestructive determination of SSC in Korla fragrant pear using a portable near-infrared spectroscopy system. Infrared Phys. Technol. 2021, 116, 103785. [Google Scholar] [CrossRef]
  11. Yao, Y.N.; Ma, K.; Zhu, J.; Huang, F.; Kuang, L.; Wang, X.; Li, S. Nondestructive determination of soluble solids content in intact apples using a self-made portable NIR diffuse reflectance instrument. Infrared Phys. Technol. 2023, 132, 104714. [Google Scholar] [CrossRef]
  12. Mansuri, S.M.; Chakraborty, S.K.; Mahanti, N.K.; Pandiselvam, R. Effect of germ orientation during Vis-NIR hyperspectral imaging for the detection of fungal contamination in maize kernel using PLS-DA, ANN and 1D-CNN modeling. Food Control 2022, 139, 109077. [Google Scholar] [CrossRef]
  13. Shih, M.S.; Chang, K.C.; Chou, S.A.; Liu, T.S.; Ouyang, Y.C. The Automated Detection of Fusarium Wilt on Phalaenopsis Using VIS-NIR and SWIR Hyperspectral Imaging. Remote Sens. 2023, 15, 4174. [Google Scholar] [CrossRef]
  14. Qiao, S.; Tian, Y.; Gu, W.; He, K.; Yao, P.; Song, S.; Wang, J.; Wang, H.; Zhang, F. Research on simultaneous detection of SSC and FI of blueberry based on hyperspectral imaging combined MS-SPA. Eng. Agric. Environ. Food 2019, 12, 540–547. [Google Scholar] [CrossRef]
  15. Zheng, Y.; Cao, Y.; Yang, J.; Xie, L. Enhancing model robustness through different optimization methods and 1-D CNN to eliminate the variations in size and detection position for apple SSC determination. Postharvest Biol. Technol. 2023, 205, 112513. [Google Scholar] [CrossRef]
  16. Q/YNKG 12; 2020 Quality Grading Standard for Fresh Fruit of Chuliang Longan. Fruit Tree Research Institute of Guangdong Academy of Agricultural Sciences: Guangzhou, China, 2020.
  17. Ashtiani, S.H.M.; Javanmardi, S.; Jahanbanifard, M.; Martynenko, A.; Verbeek, F.J. Detection of mulberry ripeness stages using deep learning models. IEEE Access 2021, 9, 100380–100394. [Google Scholar] [CrossRef]
  18. Guo, P.; Li, T.; Gao, H.; Chen, X.; Cui, Y.; Huang, Y. Evaluating calibration and spectral variable selection methods for predicting three soil nutrients using Vis-NIR spectroscopy. Remote Sens. 2021, 13, 4000. [Google Scholar] [CrossRef]
  19. Ye, S.; Wang, D.; Min, S. Successive projections algorithm combined with uninformative variable elimination for spectral variable selection. Chemom. Intell. Lab. Syst. 2008, 91, 194–199. [Google Scholar] [CrossRef]
  20. Zhan, B.; Li, P.; Li, M.; Luo, W.; Zhang, H. Detection of Soluble Solids Content (SSC) in Pears Using Near-Infrared Spectroscopy Combined with LASSO–GWF–PLS Model. Agriculture 2023, 13, 1491. [Google Scholar] [CrossRef]
  21. Sohn, S.I.; Oh, Y.J.; Pandian, S.; Lee, Y.H.; Zaukuu, J.L.Z.; Kang, H.J.; Ryu, T.H.; Cho, W.S.; Cho, Y.S.; Shin, E.K. Identification of Amaranthus species using visible-near-infrared (vis-NIR) spectroscopy and machine learning methods. Remote Sens. 2021, 13, 4149. [Google Scholar] [CrossRef]
  22. Ryu, D.S.; Noh, S.H.; Hwang, I.G. Preprocessing effects on on-line SSC measurement of Fuji apple by NIR spectroscopy. Korean Soc. Agric. Mach. 2000, 11, 560–568. [Google Scholar]
  23. Cheng, T.; Guo, S.; Pan, Z.; Fan, S.; Ju, S.; Xin, Z.; Zhou, X.; Jiang, F.; Zhang, D. Near-infrared model and its robustness as affected by fruit origin for ‘dangshan’ pear soluble solids content and pH measurement. Agriculture 2022, 12, 1618. [Google Scholar] [CrossRef]
  24. Liu, Y.; Sun, X.; Ouyang, A. Nondestructive measurement of soluble solid content of navel orange fruit by visible–NIR spectrometric technique with PLSR and PCA-BPNN. LWT 2010, 43, 602–607. [Google Scholar] [CrossRef]
  25. Chen, Y.; Li, Y.; Williams, R.A.; Zhang, Z.; Peng, R.; Liu, X.; Xing, T. Modeling of soluble solid content of PE-packaged blueberries based on near-infrared spectroscopy with back propagation neural network and partial least squares (BP–PLS) algorithm. J. Food Sci. 2023, 88, 4602–4619. [Google Scholar] [CrossRef]
  26. Tian, S.; Liu, W.; Xu, H. Improving the prediction performance of soluble solids content (SSC) in kiwifruit by means of near-infrared spectroscopy using slope/bias correction and calibration updating. Food Res. Int. 2023, 170, 112988. [Google Scholar] [PubMed]
Figure 1. Block diagram of the hardware system structure.
Figure 1. Block diagram of the hardware system structure.
Agriculture 14 02297 g001
Figure 2. Perspective view of the device.
Figure 2. Perspective view of the device.
Agriculture 14 02297 g002
Figure 3. Physical drawing of the device: (a) internal structure of the device; (b) overall view of the device.
Figure 3. Physical drawing of the device: (a) internal structure of the device; (b) overall view of the device.
Agriculture 14 02297 g003
Figure 4. Spectral collection points.
Figure 4. Spectral collection points.
Agriculture 14 02297 g004
Figure 5. Overall structures of the BPNN and Brix-BPNN.
Figure 5. Overall structures of the BPNN and Brix-BPNN.
Agriculture 14 02297 g005
Figure 6. Structural diagram of the ECA-Brix attention mechanism.
Figure 6. Structural diagram of the ECA-Brix attention mechanism.
Agriculture 14 02297 g006
Figure 7. H-swish and ReLU activation functions.
Figure 7. H-swish and ReLU activation functions.
Agriculture 14 02297 g007
Figure 8. Max pooling process for longan spectral data.
Figure 8. Max pooling process for longan spectral data.
Agriculture 14 02297 g008
Figure 9. Original spectral curves.
Figure 9. Original spectral curves.
Agriculture 14 02297 g009
Figure 10. Average spectral curves of the three SSC grades.
Figure 10. Average spectral curves of the three SSC grades.
Agriculture 14 02297 g010
Figure 11. Feature wavelength selection of longan SSC based on the SPA algorithm: (a) RMSE variation of the model; (b) optimal feature wavelength selected by SPA.
Figure 11. Feature wavelength selection of longan SSC based on the SPA algorithm: (a) RMSE variation of the model; (b) optimal feature wavelength selected by SPA.
Agriculture 14 02297 g011aAgriculture 14 02297 g011b
Figure 12. Feature wavelength selection of longan SSC based on the CARS algorithm: (a) number of sample variables; (b) RMSECV.
Figure 12. Feature wavelength selection of longan SSC based on the CARS algorithm: (a) number of sample variables; (b) RMSECV.
Agriculture 14 02297 g012aAgriculture 14 02297 g012b
Figure 13. Statistical chart of the true and predicted labels for the SSC grade of the test samples.
Figure 13. Statistical chart of the true and predicted labels for the SSC grade of the test samples.
Agriculture 14 02297 g013
Table 1. Classification of Chuliang longan.
Table 1. Classification of Chuliang longan.
SSC %≥21.021.0~19.0<19.0
GradeSuper-grade, first-grade, second-grade fruitThird-grade fruitEqual external fruit
Grade labels01 2
Table 2. Statistical results of soluble solids content in longan.
Table 2. Statistical results of soluble solids content in longan.
Sample SetNumber of SamplesSSC %
RangeAverage ValueStandard Deviation
Training set24414.67~24.0020.711.68
Test set8116.15~23.6020.721.61
Table 3. Traditional machine learning model parameters.
Table 3. Traditional machine learning model parameters.
SVMKNN
ParametersParameter ValueParametersParameter Value
C1.0n_neighbors5
kernel‘rbf’weights‘uniform’
gammascalealgorithm‘auto’
shrinkingTruep2
decision_function
_shape
‘ovr’metric‘minkowski’
LRRF
ParametersParameter valueParametersParameter value
C1.0n_estimators100
penalty‘l2’max_depth10
solver‘lbfgs’max_features‘auto’
max_iter100min_samples_split2
tol1 × 10−4min_samples_leaf1
Table 4. Deep learning model parameters.
Table 4. Deep learning model parameters.
Parameters Model
CNNBPNNBrix-BPNN
batch_size222
epochs300300300
optimizer SGD SGD SGD
learning_rate0.0010.0010.001
loss functionCross-EntropyCross-EntropyCross-Entropy
Table 5. Modeling results of different spectral preprocessing methods.
Table 5. Modeling results of different spectral preprocessing methods.
PreprocessingAccuracy%
SVMKNNLRRFBPNNCNN
Original spectral54.2155.9059.8360.9662.0864.32
SG54.2155.9060.3961.5262.3662.36
SNV53.0957.3064.3360.3963.2060.39
MSC53.0957.0262.3660.1260.3961.24
CT54.2159.2763.4861.2463.7663.76
D161.2456.4663.7663.7667.1367.13
SG-D161.2460.9666.2965.1769.1067.41
SG-SNV53.0957.5863.7660.3963.4862.36
SG-MSC53.0957.3063.7660.9661.5262.08
SG-CT54.2159.5563.2062.9263.2065.17
Table 6. BPNN modeling results for longan SSC grading based on full-band and feature wavelengths.
Table 6. BPNN modeling results for longan SSC grading based on full-band and feature wavelengths.
Variable Selection MethodWavelength NumberAccuracy%Precision%Recall%F1%
Full band97469.1068.4367.8267.20
SPA2067.4163.0964.4163.42
CARS7868.2667.0767.4266.71
Table 7. Brix-BPNN modeling results for longan SSC grading based on full-band and feature wavelengths.
Table 7. Brix-BPNN modeling results for longan SSC grading based on full-band and feature wavelengths.
Variable Selection MethodWavelength NumberAccuracy%Precision%Recall%F1%
Full band97469.6669.5068.4267.40
SPA2068.2566.0266.8565.12
CARS7871.1070.0469.1068.44
Table 8. CARS+Brix-BPNN model ablation experiment results.
Table 8. CARS+Brix-BPNN model ablation experiment results.
NumberModelAccuracy%Precision%Recall%F1%
1BPNN69.1068.4367.8267.20
2CARS+BPNN68.2667.0767.4266.71
3CARS+BPNN+BN69.1064.4765.7364.84
4CARS+BPNN+ECA-Brix68.8268.2068.8265.87
5CARS+BPNN+H-Swish68.5465.1566.0162.13
6CARS+BPNN+Max-Pool68.5367.1367.5266.48
7CARS+BPNN+CONV68.8263.9265.7362.72
8CARS+BPNN
+BN+ECA-Brix
69.3865.9567.4265.58
9CARS+BPNN+BN
+ECA-Brix+H-Swish
69.6668.8767.8566.11
10CARS+BPNN+BN
+ECA-Brix+H-Swish+Max-Pool
70.5068.6668.8267.83
11CARS+BPNN+Brix-Module70.8669.4768.5667.93
12CARS+Brix-BPNN71.1070.0469.1068.44
Table 9. Brix-BPNN model comparison experiment results.
Table 9. Brix-BPNN model comparison experiment results.
Model (CARS+)Accuracy%Precision%Recall%F1%
BPNN68.2667.0767.4266.71
MLP69.3865.9866.8563.67
Dropout-BPNN68.2666.7666.8564.23
Residual-BPNN68.8262.8463.2061.96
ResNet-BPNN68.1566.1266.0161.90
Brix-BPNN71.1070.0469.1068.44
Table 10. Results of field experiments.
Table 10. Results of field experiments.
SSC GradeGrade LabelsNumber of True DetectionsNumber of True PredictionsNumber of False PredictionsAccuracy%
Super-grade, first-grade, second-grade fruit01513286.67%
Third-grade fruit186275%
Equal external fruit276185.71%
TotalTotal3025583.33%
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.

Share and Cite

MDPI and ACS Style

Li, J.; Zhang, M.; Wu, K.; Chen, H.; Ma, Z.; Xia, J.; Huang, G. Field Grading of Longan SSC via Vis-NIR and Improved BP Neural Network. Agriculture 2024, 14, 2297. https://doi.org/10.3390/agriculture14122297

AMA Style

Li J, Zhang M, Wu K, Chen H, Ma Z, Xia J, Huang G. Field Grading of Longan SSC via Vis-NIR and Improved BP Neural Network. Agriculture. 2024; 14(12):2297. https://doi.org/10.3390/agriculture14122297

Chicago/Turabian Style

Li, Jun, Meiqi Zhang, Kaixuan Wu, Hengxu Chen, Zhe Ma, Juan Xia, and Guangwen Huang. 2024. "Field Grading of Longan SSC via Vis-NIR and Improved BP Neural Network" Agriculture 14, no. 12: 2297. https://doi.org/10.3390/agriculture14122297

APA Style

Li, J., Zhang, M., Wu, K., Chen, H., Ma, Z., Xia, J., & Huang, G. (2024). Field Grading of Longan SSC via Vis-NIR and Improved BP Neural Network. Agriculture, 14(12), 2297. https://doi.org/10.3390/agriculture14122297

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop