Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

LWT - Food Science and Technology 168 (2022) 113902

Contents lists available at ScienceDirect

LWT
journal homepage: www.elsevier.com/locate/lwt

Deep learning based research on quality classification of


shiitake mushrooms
Qiang Liu , Ming Fang *, Yusheng Li , Mingwang Gao
School of Mechanical Engineering, Shandong University of Technology, Zibo, 255000, China

A R T I C L E I N F O A B S T R A C T

Keywords: The classification and processing of shiitake mushrooms is inclined to a labor-intensive task, which needs to pick
Shiitake mushrooms shiitake mushrooms of high quality by labor force for a long time. In this paper, a high-efficiency channel
Channel pruning pruning mechanism is proposed to improve the YOLOX deep learning method that is the latest version of YOLO
YOLOX
serials algorithm for identification and grading of mushroom quality. Firstly, the YOLOX model is built by
Deep learning
Quality classification
transfer learning after the image data set was expanded. Secondly, the built model was optimized by channel
pruning algorithm. Finally, the pruned model is further fine-tuned by knowledge distillation, and the image data
set was used to train the YOLOX network model optimized by channel pruning. The experimental results indicate
that the improved YOLOX method proposed in this paper can inspect the surface texture of shiitake mushrooms
effectively that mAP and FSP are respectively 99.96% and 57.3856, and the model size was reduced by more
than half. Compared with Faster R–CNN, YOLOv3, YOLOv4, SSD 300 and the original YOLOX, the improved
method proposed in this paper owns better comprehensive performance that it can be effectively applied to the
rapid quality classification for shiitake mushrooms in production process.

1. Introduction and white, chrysanthemum-like patterns, the mushrooms with these


features are called flower shiitake mushrooms (Cao, 2000, pp. 6–40). As
Shiitake mushroom is a genus of Basidaomycetes, Agaricales, Tri­ the treasures of shiitake mushrooms, flower shiitake mushrooms, fav­
cholomatacete and Lentinus, of which scientific name is Lentinus edo­ oured by consumers in domestic and foreign markets, boast thick pilei,
des. As the second largest mushroom in the world, it is originated in tender meat, beautiful appearance and the highest economic value.
China and has long since acquired a reputation as a precious edible fungi Ordinary shiitake mushrooms have no cracks in their pilei, which are
(Yang et al., 2006). Shiitake mushrooms boast thick and tender meat, also called smooth cap shiitake mushrooms (Jiang & Li, 2005).
delicious taste, unique aroma and rich nutrition. It is medicinal and Compared with smooth cap shiitake mushrooms, flower shiitake
edible, which has high nutritional, medicinal and health-care values (Li mushrooms enjoy the higher value that higher 5–8 times in price. In
et al., 2005). Because of the above features, the demand for shiitake order to ensure the quality and price by grade, it is necessary to sort the
mushrooms at home and abroad has shown an obvious upward trend in shiitake mushrooms with mixed patterns, thus pursuing economic
the past 20 years. The market prospects for shiitake mushrooms and efficiency.
their products in developed regions and countries such as Europe, the Making use of traditional computer vision technology, although
United States and Southeast Asia are promising. China’s domestic shii­ certain research results have been achieved in the non-destructive in­
take mushroom market has huge potential, thus making shiitake spection and quality grading of mushrooms, there are still several
mushrooms one of the fastest growing mushrooms in the world (Xu & shortcomings: (1) The image processing of shiitake mushrooms, such as
Zhang, 2021). The external quality inspection and grading of shiitake feature extraction and defect detection, is still based on artificial expe­
mushrooms are the key factors that affect the development of shiitake rience, including geometry, color and surface texture defect of shiitake
mushroom industry. During the growth of mushrooms, because the di­ mushrooms. In addition, these feature extraction methods requires
vision of epidermal cells and fleshy cells is not synchronized, the manual experience to participate in the design, which is a great degree of
fast-growing fleshy cells rupture the epidermal cells that forming brown limitations. The quality grading even needs to be further judged by

* Corresponding author.
E-mail address: fm15256860798@163.com (M. Fang).

https://doi.org/10.1016/j.lwt.2022.113902
Received 15 March 2022; Received in revised form 16 June 2022; Accepted 22 August 2022
Available online 26 August 2022
0023-6438/© 2022 The Authors. Published by Elsevier Ltd. This is an open access article under the CC BY license (http://creativecommons.org/licenses/by/4.0/).
Q. Liu et al. LWT 168 (2022) 113902

labor, so that the degree of automation is reduced. (2) Traditional image of mushroom defect detection (Xie, 2020). Liu et al. introduced residual
processing technology for feature extraction requires high image quality network to YOLOv2 algorithm, which is one of the classical deep
of shiitake mushrooms, but it is inevitable that the images will be learning algorithms, of which feature extraction network is Residual
affected by noise or light changes during image collection, resulting in Network (ResNet) 50, to make the detection accuracy better, with a
low accuracy of feature extraction models, weak robustness and other confidence value of 90% and a detection accuracy of 94% (Liu, 2020, pp.
issues. 10–43). However, there are still some disadvantages that the sorting
With the continuous and in-depth research in the field of artificial accuracy is not high or the sorting detection speed is low, which cannot
intelligence in recent years, deep learning that is a complex machine meet the needs in actual applications, so the automatic quality classifi­
learning algorithm, has also developed rapidly. Deep learning focuses on cation and recognition on the basis of ensuring the sorting accuracy and
inherent laws and representation levels of sample data. The information high sorting efficiency need in-depth study.
obtained in the deep learning is of great help to the data such as text, Generally, target detection algorithms based on deep learning are
images and sounds. In terms of voice and image recognition, deep currently divided into two categories: two-stage and one-stage algo­
learning far exceeds the previous related technologies (Chen, 2014, pp. rithms. The former algorithm extracts candidate regions that may
9–35). The model of deep learning network adopts an end-to-end, contain the detected object from the input image, and gets the volume of
multi-hidden layers and layer-by-layer learning method, of which the image through a convolutional neural network, then products fea­
working principle is to imitate the thinking characteristics of human tures, finally classifies and regresses the detected objects in the candi­
brain, deeply learn data features from the shallower to the deeper, and is date area. While one-stage algorithm uses an end-to-end neural network
more suitable for big data and abstract and complex data feature (Duan to pre-generate the candidate area, and directly classifies and locates the
et al., 2020). Compared with traditional machine learning, deep target, resulting in an absolute advantage in detection speed, but the
learning can achieve deeper feature extraction, and obtain autonomous detection accuracy is not as high as two-stage algorithm (Liu et al.,
learning ability (Hinton & Salakhutdinov, 2006). Since the target 2021). You Only Look Once (YOLO) series algorithms, as representative
detection technology based on deep learning has shown its superiority in algorithms of one-stage algorithms, have been widely used in real-time
many fields, it is also popular in the classification and detection of target detection. YOLO network unifies target classification and posi­
agricultural products. Zhang et al. combined the deep learning methods tioning as a regression problem, and outputs the position and category of
and spectral analysis to propose an end-to-end spectral qualitative the detected target (Redmon et al., 2016; Redmon & Farhadi, 2017,
analysis model based on convolutional neural network, which can Redmon & Farhadi, 2018, pp. 6517–6525). With the development and
effectively identify 20 grape varieties. Compared with the traditional continuous optimization of YOLO, YOLO series of algorithms have been
partial least squares regression-linear discriminant analysis and prin­ developed to the latest YOLOX (Ge et al., 2021).
cipal component analysis-logistic regression model, there is a significant This paper proposed a novel deep learning method that channel
improvement in accuracy, and the average classification accuracy of the pruning algorithm is combined with YOLOX, which improved the ac­
proposed method has reached 87.81% (Zhang, 2021, pp. 10–50). Wang curacy and efficiency of the quality classification of shiitake mushrooms,
et al. used channel pruning algorithm to optimize and improve the You and verified that the improved algorithm proposed in this paper can
Only Look Once (YOLO) v4 algorithm in deep learning, which proposed meet the actual production needs, which can be used for the processing
an improved method based on YOLOv4 for the detection of soil and of shiitake mushrooms. The high-efficiency and automatic sorting of
stone in potatoes, and realized the rapid detection and effective removal shiitake mushrooms urgently needed by the export industry provides a
of soil and stone in the potato containing miscellaneous after harvest. In feasible method.
addition, Mean Average Precision (mAP) also reached 96.42% (Wang
et al., 2021). Andre Dantas de Medeiros et al. respectively achieved 2. Materials and methods
91%, 95% and 82% recognition accuracy in the integrity, germination
rate and vigor of internal tissues of seeds by combining X-ray images and 2.1. Image data set
deep learning network model (Medeiros et al., 2021).
The model is also gradually developing towards the direction of 2.1.1. Data set acquisition
lightweight. Zhang et al. developed a stud pose detection system, which To identify the quality of shiitake mushrooms based on deep
combined photometric stereo with YOLOv4 neural network that is learning, it is necessary to obtain a sufficient number of samples for
applied to achieve the detection of stud position. Experimental results appearance inspection of shiitake mushrooms.
show that the proposed method can achieve fast detection and high The experimental materials used in this paper are from the 10th
precision positioning of the stud (Zhang & Wang, 2022). Zou et al. Invitational Contest of University Student Modeling in Central China.
presented a deep imitation reinforcement learning (DIRL) framework, The dataset consists of 55 images of white flower shiitake mushroom, 25
which is based on a deep deterministic policy gradient algorithm images of tea flower shiitake mushroom, 55 images of smooth cap
(DDPG) by vision for the inefficiency of deep reinforcement learning in shiitake mushroom and 15 images of shiitake mushroom with foreign
exploring large continuous motion spaces in the field of automatic matter on its surface. Due to insufficient data provided by the data set,
driving. Simulation results show that the proposed method can obtain and considering that the pictures taken under actual conditions will be
the correct control strategy and has less training time (Zou et al., 2021). affected by a series of external factors such as shooting angle, lighting
Domestic and foreign scholars have achieved good results in many conditions and physical vibrations, etc., a large amount of noise appears
applications of deep learning in agricultural products, but the applica­ in the captured mushroom images, and the spectral characteristics are
tion of deep learning in the quality inspection of shiitake mushrooms are impaired, etc, in order to improve the generalization ability of the
rarely studied. Chen et al. intercepted the appropriate texture area from network model, prevent the model from overfitting, and enable the
the mushroom cap, from which gray-level histogram statistics, gray- trained model to meet the detection requirements of multiple scenes in
level co-occurrence matrix, Gauss Markov random field model and actual situations, in this paper, some data enhancement methods are
fractal dimension model are used to extract features, finally constructed used to expand the data samples for image data set. The brightness,
K the nearest neighbor classifier for classifying the features of images, chroma, contrast and sharpness of the image data are processed, after
and the correct rate of sorting can reach 93.57%. Experimental results which they were respectively increased by 1.1 times and reduced by
show that it is feasible to use the texture of the mushroom cap to classify 10% under two different scenes. In addition, in order to simulate the
the types of mushrooms (Chen et al., 2014). Xie et al. used computer noise that may be generated by the device during the image acquisition
vision and image processing technology to realize the defect detection of process, the samples of data set are enhanced that gaussian noise with a
a variety of mushrooms, and improved the speed and grading accuracy variance of 0.05 and salt and pepper noise are added into the original

2
Q. Liu et al. LWT 168 (2022) 113902

images, and the number of samples of data set are expanded to 1606. Table 1
Detailed information of dataset.
2.1.2. Data set division Shiitake Mushrooms data Flower shiitake Smooth cap shiitake
Flower shiitake mushroom is a variety of shiitake mushroom, of set (1606) mushroom set (935) mushroom set (671)
which top surface is light black and cracks to form a white flower-like Number of training 1152
pattern or net-like pattern. Therefore, flower shiitake mushroom is samples
named because of the pattern on top surface. The surface of ordinary Number of samples of 129
shiitake mushrooms have no cracks and are classified as smooth cap validation set
Number of samples of 162 141
shiitake mushrooms according to the texture of the surface feature. test set
Based on the above characteristics, the mushroom data set is divided
into two categories as shown in Fig. 1. In this experiment, the data is
marked by the data marking tool that Labelimg, after which the marked
data is saved as a text file in YOLO data format, including 935 flower
shiitake mushrooms and 671 smooth cap shiitake mushroom images that
are used for network training and parameter optimization. And
randomly 129 from the 1606 image data set are selected as the verifi­
cation set, and the other images as the training and test set. The specific
information of training set is shown in Table 1.
The computer hardware configuration used for image processing and
model training in this experiment is as follows: CPU: Inter-Xeon W-2245,
3.90GHZ; GPU: NVLDLA Quadro P4000 (8 GB memory); RAM: 64 GB;
SSD: 512G. The network model is trained under Windows 10 Profes­
sional 64-bit operating system. All program codes are written in Python
3.7, and OpenCV is used for image processing and dispaly.

2.2. Quality classification model for shiitake mushrooms based on


YOLOX

The main purpose of this research is to construct a novel quality


classification model for shiitake mushrooms that can ensure good ac­
curacy and high efficiency for sorting at the same time. The basic
framework of this research is shown in Fig. 2 below. Firstly, the tagging Fig. 2. The framework of quality classification of shiitake mushroom based on
tool that LabelImg for labelimg data is used to label the original images modified YOLOX.
of data set; secondly, OpenCV is adopted to enhance the labeled images
of data set; thirdly, the mushroom data set is used to train the YOLOX The backbone network that CSPDarknet adopted by YOLOX can
network through migration learning, after which the YOLOX model is obtain the corrsponding pix value every other pix, and all information
fine-tuned; fourthly, channel pruning algorithm is used to optimize the were stacked and integrated in channel information after four inde­
previous YOLOX model; Finally the model is further fine-tuned to pendent feature layers were obtained. Meanwhile, SPP was adopted as
restore the detection accuracy of the model, and the final network model enhancing extraction network to extract features using max pooling for
is obtained. different pooling kernels, by which the receptive field was expanded.
The feature layer that Lay3 outputted by feature extracting network of
2.2.1. Fast and accurate detection based on YOLOX backbone used one P1 convolution and downsampling, and one P2
With the continuous development of deep learning, in the field of convolution and downsampling, of which results were respectively in­
target detection, YOLO series has always pursued excellent trade-off tegrated with Lay1 and Lay2 outputted by feature extracting network to
between speed and precision for real-time applications. As the latest obtain Out1. Out1 used two downsamplings, and then were respectively
version of YOLO series algorithms, YOLOX has optimized and summa­ stacked with P1 and P2, finally adopted feature extraction to get Out2
rized the characteristics of YOLOv3, YOLOv4 and YOLOv5, of which and Out3. The three enhancing feature layers were inputted into Yolo
target detection performance has been greatly improved. Therefore, Head to obtain the predicting outcomes, and the classification and
YOLOX is chosen in this research. The construction process of model and regression of YOLOX were respectively carried out, which were inte­
the results of the YOLOX-based mushroom quality classification network grated together at the stage of prediction.
model are shown in Fig. 3 below. YOLOX network mainly uses two data enhancement methods:
Mosaic and MixUp. Mosaic draws on the data enhancement method of
the previous YOLO series, which is a very effective enhancement strat­
egy, and splices the input image data through random scaling, cropping
and arrangement, and then detects small targets. MixUp randomly picks
multiple images and extract the features of the detected targets, after
which they are merged and superimposed. YOLOX adopts Cross-Stage-
Partial-connections (CSP) Darknet as the backbone feature extraction
network. Considering that the backbone network in YOLOv4 and
YOLOv5 is over-optimized for the anchor frame, YOLOX borrows from
the backbone network of YOLOv3, after which Spatial Pyramid Pooling
(SPP) components are added. YOLOX network adopts Feature Pyramid
Networks (FPN) as the enhanced feature extraction network. The
effective feature layer obtaining from the backbone is used to further
Fig. 1. The image examples of different kinds of shiitake mushrooms: (a) extract features, and the extracted feature information is transferred and
Flower shiitake mushroom; (b) Smooth cap shiitake mushroom.

3
Q. Liu et al. LWT 168 (2022) 113902

Fig. 3. The framework of YOLOX network model.

fused. In YOLOX, the Path Aggregation Network (PANet)structure of part continues the original stack; the other part is like a residual
YOLOv4 is also adopted for reference. Up-sampling and down-sampling edge, which is directly connected to the end after a small amount
are both applied to achieve feature fusion. The final prediction part of of processing, and used for feature extraction to enhance the
YOLOX adds three decoupling heads and divides decoupling head of learning ability of network model.
Yolo Head into two parts to realize classification and regression (4) SPP. module. This module realizes the fusion of local features and
respectively, and then integrate them together in the final prediction, global features through the maximum pooling of sizes of different
which not only greatly improves the accuracy, but also greatly improved pooling core, and improves the receptive field of the network and
the convergence speed of the network. Then, the anchor free method is the detection accuracy of the entire network model.
used to extract the target frame and the labeled ground truth for com­ (5) Cls-output, Reg-output and Obj-output modules. These three
parison, between which the gap is judged. Finally, the number of posi­ modules are used to determine the type of object contained in
tive samples is dynamically allocated by SimOTA method. each feature point and predict the category of the target frame; to
The components of quality classification network model for shiitake determine the regression parameters of each feature point, and
mushrooms based on YOLOX are as follows: the prediction frame can be obtained after the regression pa­
rameters are adjusted; to determine whether each feature point
(1) The focus module. In this module, the input image is sliced, and contains object and predict the coordinate information of the
then the horizontal and vertical slices continued to be spliced to target frame.
expand the input channel, which not only greatly improves the
output depth but also retains relatively complete image infor­ The YOLOX model used in this paper was pre-trained by using the
mation, enabling subsequent feature extraction more fully. VOC data set, and these parameters that batch size, network input size,
(2) Convolution, Batch Normalization and Sigmoid Weighted Liner learning rate, number of classification categories and number of itera­
Unit activation function (Conv2D_BN_SiLU) module. The module tions were fine-tuned.
is composed of residual convolution layer, batch normalization
layer and SiLu activation function. The main part of residual 2.2.2. The training part of model
convolution is a 1 × 1 convolution and a 3 × 3 convolution, The following Fig. 4 shows the loss curve during training. The
which is easy to be optimized. The accuracy is improved by calculation of loss is actually a comparison between the predicted result
increasing the depth, which can effectively alleviate the problem of network and the real result of network. The loss of YOLOX network is
of gradient disappearance caused by increasing the depth in the composed of three parts, including Cls-output, Reg-output and Obj-
deep neural network. The SiLU activation function is an improved output. The Cls-output part is the type of object contained in the
version of the Sigmoid and Rectified Linear Unit activation feature point; The Reg-output part is the judgment of regression
functions (ReLU), which has the characteristics of no upper parameter for the feature point; The Obj-output part is the judgment
bound and lower bound, smoothness and non-monotonicity, and whether the feature point contains an object.
the effect on learning model is better than the counterpart of the In YOLOX, firstly, the degree of overlap between each real frame and
ReLU activation function. the prediction frame of current feature point is calculated. Secondly, ten
(3) Centre and Scale Prediction Layer (CspLayer) module. Split the prediction frames with the highest degree of overlap are added the real
stack of the original Conv2D_BN_SiLU module into two parts, one Intersection over Union (IoU) to obtain the number of positive samples

4
Q. Liu et al. LWT 168 (2022) 113902

Table 2
Parameters setting for channel pruning.
Method steps Parameters value

Sparse training Batch-size 8


Learning rate 0.001
Epochs 300
Sparsity ratio 0.001
Channel pruning Pruning rate 0.8
Fine-tuning the pruned model Epochs 200
Batch-size 8

The basic flow of channel pruning algorithm adopted in this paper is


as follows:

(1) Sparse training. L1 regularization constrain was applied to BN


layer coefficient of YOLOX shiitake mushroom quality classifi­
cation model, which adjusts the channels of the model towards
sparsity.
(2) Channel pruning. After sparse training, a pruning rate of 0.8 was
Fig. 4. Training loss curve of model. used to trim the fine-tuned YOLOX model to obtain a more
simplified model. The channel changes before and after channel
pruning are shown in Fig. 5.. After pruning, the number of
for each real frame, which means that each real frame has the same
channels in the network model has been effectively reduced from
number of feature points that is corresponding to the number of positive
10376 to 2676, resulting in the required simplified model.
samples. Finally the feature points are used to predict which feature
(3) Fine-tuning the pruned model. Detection accuracy of model is
points the real frame of the object falls within.
generally reduced after channel pruning, so a distillation method
After the feature point corresponding to each box is obtained, the
(Lai et al., 2020) is used to fine-tune the model to restore the lost
prediction box of feature point is taken out, then the real box and pre­
accuracy of the pruned model.
diction box are used to calculate the IoU loss, finally the loss of the Reg
part is also obtained. The formula for calculating IoU (Equation (1)) is as
The main function of distillation method (Equation (2)) is that big
follows:
model makes knowledge transferring for small model. In this paper,
DR ∩ GT normal training YOLOX and the pruned model were respectively spec­
IOU = (1)
DR ∪ GT ified as teacher model and student model. Training samples were
inputted into teacher network and student network, meanwhile, student
where DR represents the prediction frame, GT represents the actual
network was trained using sample lables that probability distribution
frame, and IOU is an important indicator to measure the accuracy of the
outputted by teacher network, which made the output distribution of
prediction frame.
student network approach the counterpart of teacher network. Based on
The feature points corresponding to the real frame are positive
the above process, the loss functions of teacher network and student
samples, and the rest of feature points are negative samples. After the
network can be obtained. Soft target set is obtained by increasing value
feature points corresponding to the real frame are obtained, the cross
of temperature parameter of teacher network model.
entropy loss is calculated, which is based on the prediction results that
whether the positive, negative samples and the feature points contain exp(zi /T)
qi = ∑ (2)
objects, to get the loss of the Obj part. j exp(zi/T)
The prediction result of the feature point type is taken out according
to the obtained feature point corresponding to each frame, then the cross where T represents temperature, zi represents probability of classifica­
entropy loss is calculated according to the type of the real frame and the tions, exp represents exponent arithmetic and qi is the output of soft
prediction result of the feature point type, finally the loss of the Cls part target. Besides, student network still has another loss function derived
is obtained. from true label values. Therefore, the objective function of student
network consists of loss function based on soft-target and loss function
2.2.3. Pruning of YOLOX quality classification model for shiitake based on ordinary training.
mushrooms based on channel pruning algorithm
The original YOLOX model trained through experimental data set
can accurately detect the quality of shiitake mushrooms, but still has the
disadvantage of occupying a large amount of resources. Channel prun­
ing algorithm can further simplify the structure of YOLOX model, reduce
the number of parameters and improve the detection efficiency. In this
paper, channel pruning is used to remove unimportant channels and
related input and output relationships, and reduce the complexity of the
network model (Kong et al., 2018). The various parameter settings in the
process of channel pruning are shown (Table 2).
When the model is trained, the scaling factor is introduced into the
Batch Normalization (BN) layer in the network, and then the contribu­
tion rate of each channel is evaluated. Channels with high and low
contribution rate are both retained, which enhanced the sparsity of
channels, and finally the accuracy loss that is caused by pruning is offset
by fine-tuning the model (Sergey & Christian, 2015).
Fig. 5. Changes of channels before and after channel pruning.

5
Q. Liu et al. LWT 168 (2022) 113902

2.3. Evaluation criteria where TP is True Positives, TN is True Negatives, FP is False Positives,
and FN is False Negatives.
In this study, performance indexs such as precision (Equation (3)),
recall rate (Equation (4)), F1 score (Equation (5)), and mAP were used to F1 = 2 ×
precision⋅recall
(5)
verify the improved model proposed in this paper and evaluate the in­ (precision + recall)
spection results. Recall and precision are respectively taken as the horizontal axis and
TP vertical axis to obtain the P-R curve, under which the area is AP value.
precision = (3)
(TP + FP) The average AP value is calculated to obtain the mAP value, which is an
important parameter that shows the effect of the constructed neural
TP network model.
recall = (4)
(TP + FN)

Fig. 6. Test results of quality classification for


shiitake mushrooms in different environments:
(a) Test result of quality classification for shii­
take mushrooms under dark light conditions; (b)
Test result of quality classification for shiitake
mushrooms under strong light conditions; (c)
Test result of quality classification for foreign
matter on the surface of shiitake mushrooms; (d)
Test result of quality classification for shiitake
mushrooms at a distance; (e) The detection result
of quality classification for shiitake mushrooms
under the condition of blurry pictures; (f) The
detection result of quality classification for shii­
take mushrooms under noise conditions.

6
Q. Liu et al. LWT 168 (2022) 113902

3. Results and SSD 300 models, namely that the improved YOLOX algorithm
proposed in this paper owns the best mAP value among the five models.
3.1. Performance test of the built model For making the comparison more intuitive, the comparison results are
shown in Fig. 8. Although the recall rate and accuracy of our model are
In order to test the performance of the YOLOX-based shiitake slightly lower than the counterparts of Faster R–CNN and YOLOv4, the
mushroom quality classification model proposed in this paper, it was storage space and detection speed of our model have significant ad­
tested with 303 mushroom images, of which there were 162 flower vantages over the other four algorithms.
shiitake mushrooms and 141 smooth cap shiitake mushrooms. For the Chen et al. used Faster-RCNN to identify oil tea fruits in the wild,
sake of simplicity, flower shiitake mushroom and smooth cap shiitake achieved 92% average recognition rate, 98.92% accuracy rate and
mushroom is respectively abbreviated as hua shiitake and smooth cap 93.32% recall rate, comprehensive evaluation index is 96.04%, and the
shiitake during the process of experiment. detection time consuming for one image was 0.21s(Chen et al., 2021). Su
The accuracy, recall and mAP of the improved model proposed in et al. built a lightweight model to locate the position of tomatoes in
this paper are respectively 99.30%, 98.10% and 99.96%, and the green ripe stage under the complex background based on YOLOv3
average detected Frames Pro Second (FPS) is 57.3856. The detection convolutional network, and the detection accuracy, detection speed and
results are shown in Fig. 6., and the detection model proposed in this memory usage were respectively 98.28%, 47.09FPS and 92.79 MB after
article is not only suitable for strong light conditions, but also has good the proposed model was trained. The function that accurate detection
detection results under weak light and backlight conditions, as shown in was achieved, but there are some disadvantages that lager model size
Fig. 6 A and Fig. 6 B that respectively indicates that the improved model and low recognition rate (Su et al., 2022). Compared with Faster-RCNN
proposed in this paper can be applied to the inspection requirements of a and YOLOv3, YOLOX adopted anchor-free detector, so the number of
variety of scenes under real conditions. Fig. 6 C and Fig. 6 D are the parameters and Giga Floating-point Operations (GFLOPs)Per Second
collected images, which are shot at a long distance and some foreign were reduced, which showed good performance that faster detection
objects is added. Fig. 6 E and Fig. 6 F show that even though the speed and higher accuracy rate for target detection.
mushroom images are blurred and have noise, they are still detected
well with high accuracy. 4. Discussion
The above experimental results show that the improved model pro­
posed in this paper can achieve high detection accuracy and detection 4.1. The analysis of detection results for shiitake mushrooms
speed, meet the requirements of real-time, and is a feasible method to
solve the efficient and automatic sorting of mushrooms. Shiitake mushrooms are one of the most important horticulture in­
dustrial corps, and the accurate and efficient classification for shiitake
3.2. Comparison of model performance before and after pruning mushrooms quality plays an important role in shiitake mushrooms in­
dustry (Shan, 2017). Because of the environmental factor and charac­
In order to verify the influence of the model for the quality classifi­ teristics of shiitake mushrooms, the detection for shiitake mushrooms
cation of shiitake mushrooms before and after pruning, the number of quality faces the uncertain light condition, the cover and aggregation of
parameters and detection performance of the YOLOX model before and shiitake mushroom entity and the similarity between shiitake mushroom
after pruning were compared. As shown (Table 3.), the number of pa­ surface and the background, etc. The traditional image processing and
rameters were reduced by 84% and the memory footprint was reduced target detection has low feature extraction efficiency for shiitake
by 18.97 MB. The above data shows that channel pruning algorithm can mushroom, detection model needs a lot of complex artificial designs, the
effectively reduce the amount of parameters and size of memory space. detection effect for features are also not ideal, and the simplicity and
After fine-tuning, the model size becomes 15.31 MB and mAP is real-time are generally not good (Li et al., 2010). As the rapid devel­
improved to 99.96%. The comparison results indicate that the applica­ opment of deep learning technology, detection model based on neural
tion of channel pruning algorithm reduces the size and number of pa­ network has been widely applied in many industries.
rameters of the model while ensuring the detection accuracy, and Deep convolutional neural networks (DCNN) have significant ad­
obtains a simplified model for the quality classification of shiitake vantages that automatic detection, extracting appropriate features based
mushrooms. For making the comparison more intuitive, the comparison on the input images and independent learning capability and so on,
results are shown in Fig. 7. which are very suitable for quality classification for shiitake mushrooms
(Alex et al., 2017; Huang et al., 2016; Szegedy et al., 2014, pp. 1–9). For
3.3. Comparison of different target detection algorithms the requirement of real-time and accuracy of detection model, the latest
YOLOX algorithm is adopted in this paper, the detection accuracy for
In order to validate the performance effect of model in a deeper step, shiitake mushroom quality reached to 99.3%, which can meet the ac­
the improved model proposed in this paper is compared with Faster curacy needs of quality classification for shiitake mushrooms in indus­
R–CNN (Ren et al., 2017), YOLOv3, YOLOv4 and SSD 300 (Liu et al., trial production. On this basis, the model was further optimized by
2016, pp. 21–37). The backbone networks of the above four target pruning channels to reduce the model size, but the detection accuracy
detection algorithms is respectively ResNet50, Darknet53, CSPDar­ kept unchanged, which is suitable of applying in small computing de­
knet53 and VGG16. These network models are processed by using the vices. The method proposed in this paper provides thinking of study and
same data set for training, verification and evaluating the performance consult for the application of artificial intelligence technology in food
of the model. The test results of each model are shown in Table 4, which detection field.
show that mAP of our target detection algorithm is respectively 0.04%,
1.21%, 2.17% and 0.90% higher than Faster R–CNN, YOLOv3, YOLOv4 4.2. The application analysis of detection model for shiitake mushrooms

The main difficulties of quality classification for shiitake mushrooms


Table 3
are that shiitake mushrooms surface is very similar with the background,
Comparison of performance indexs before and after channel pruning.
and the crack features of some shiitake mushrooms surface are hard to
Performance indexs YOLOX Pruned YOLOX Fine-turned YOLOX
be extracted, etc. In order to validate whether the built model in this
Number of parameters 6152912 198182 967777 paper can adapt various complicated environments, 436 frame images
Model size/MB 34.28 7.6 15.31 were captured from mushroom planting program of China CCTV7 mil­
mAP/% 99.98 94.06 99.96
itary and agricultural channel by Adobe Premiere Pro CC 2019 to

7
Q. Liu et al. LWT 168 (2022) 113902

Fig. 7. Line chart of performance change before and after pruning: (a) Line chart of number of model parameters; (b) Line chart of model size (MB); (c) Line chart of
model mAP(%).

generate dataset, and was further expanded to 4467 images by data


Table 4
enhancement method. The YOLOX model network was trained using the
Comparison of performance indexs among different methods.
above dataset processed by data enhancement method, and Table 5
Methods Precision Recall mAP Detection Model Size shows the performance indexs. Compared with detection results under
(%) (%) (%) speed (FPS) (MB)
single background, mAP and detection accuracy respectively decreased
Faster 97.32 100 99.92 7.4642 108.16 1.3% and 0.135%, which showed that the detection performance
R–CNN
dropped a little. Fig. 9 shows the test results of quality classification for
YOLOv3 98.59 95.68 98.75 33.1463 235
YOLOv4 100 97.80 97.79 23.9132 224.32 shiitake mushrooms in complex background. So the model proposed in
SSD300 98.59 96.61 99.06 51.5779 91.11 this paper can classify the quality of shiitake mushrooms in various
Ours 99.30 99.96 99.96 57.3856 15.31 complicated environments, namely that the excellent detection perfor­
mance is still maintained. After analysis, it is found that the decreasing
of performance of shiitake mushrooms detection model resulted from
significant similarities between the background and shiitake mushrooms
surface of some shiitake mushroom images, so the feature extraction
capability of model declined.
In order to verify the further subdivision capability of model pro­
posed in this paper for flower shiitake mushrooms, flower shiitake
mushroom dataset were lablled. 436 captured frame images, 150 shii­
take mushroom images from the 10th Invitational Contest of University
Student Modeling in Central China in 2017 and 28 shiitake mushroom
images by capturing for other shiitake mushroom videos are processed

Table 5
Comparison of performance indexs between using single and complex back­
ground datasets.
Performance indexs Precision Recall mAP Detection speed
(%) (%) (%) (FPS)

Fig. 8. Test results of five methods in the histogram. Single background 99.30 99.96 99.96 57.3856
dataset
Complex back-ground 99.17 99.08 98.68 45.4024
dataset

8
Q. Liu et al. LWT 168 (2022) 113902

Fig. 9. Test results of quality classification for shiitake mushrooms in complex background: (a), (c) Test results of quality classification for flower shiitake mush­
rooms; (b), (d) Test results of quality classification for smooth cap shiitake mushrooms.

by data enhancement to generate new dataset that 1213 images, which Validation, Supervision.
consists of white flower shiitake mushroom, tea flower shiitake mush­
room, flower shiitake mushroom. The experimental results after training
that mAP, average detection accuracy and detection speed were Declaration of competing interest
respectively 97.24%, 95.17% and 45.4223 FPS, which shows that the
proposed model in this paper can extract the crack features of shiitake We wish to draw the attention of the editor to the following facts
mushrooms surface effectively, and further subdivide the shiitake which may be considered as potential conflicts of interest and to sig­
mushrooms quality, but mAP, detection accuracy and detection speed nificant financial contributions to this work.
only decreased a little. In follow-up study, for the model proposed in this We confirm that the manuscript has been read and approved by all
paper, the image processing and feature extraction efficiency of target named authors and that there are no other persons who satisfied the
detection for shiitake mushrooms will be further optimized. criteria for authorship but are not listed. We further confirm that the
order of authors listed in the manuscript has been approved by all of us.
We confirm that we have given due consideration to the protection of
5. Conclusions
intellectual property associated with this work and that there are no
impediments to publication, including the timing of publication, with
In this study, an improved quality classification method for shiitake
respect to intellectual property. In so doing we confirm that we have
mushrooms based on YOLOX algorithm is proposed to quickly detect
followed the regulations of our institutions concerning intellectual
and classify the quality of shiitake mushrooms. Compared with the
property.
original YOLOX algorithm, the improved YOLOX proposed in this paper
We understand that the Corresponding Author is the sole contact for
greatly reduced the number of model parameters by 5185135, but kept
the Editorial process (including Editorial Manager and direct commu­
the detection accuracy almost unchanged. The experimental results
nications with the office). He is responsible for communicating with the
show that the recall rate, accuracy rate and mAP value of the improved
other authors about progress, submissions of revisions and final
YOLOX algorithm is respectively 99.30%, 98.10% and 99.96%, and the
approval of proofs. We confirm that we have provided a current, correct
FPS of the detected image and model size is respectively 57.3856 and
email address which is accessible by the Corresponding Author and
only 15.31 MB. Therefore, the model proposed in this paper can accu­
which has been configured to accept email from LWT-Food Science and
rately classify the quality of shiitake mushrooms in real time. In the
Technology.
future, we will further explore this research, and strive to make the
model not only can efficiently detect and classify the quality of shiitake
mushrooms in more complex scenarios, but also can efficiently detect References
and classify other agricultural products.
Alex, K., Ilya, S., & Geoffrey E, H. (2017). ImageNet classification with deep
convolutional neural networks. Communications of the ACM, 60, 84–90.
Data availability statement Cao, Z. M. (2000). Study on the principle of variegated mushroom’s formation in Lentinus.
Dissertation. Nanjing Agricultural University.
Chen, X. C. (2014). Research on algorithm and application of deep learning based on
The dataset can be obtained from https://www.saikr.com/vse/hua convolutional neural network. Dissertation. Zhejiang Gongshang University.
zhongliansaigr/2017 (accessed on 6 August 2021). Chen, B., Rao, H. H., Wang, Y. L., Li, Q. S., Wang, B. Y., & Liu, M. H. (2021). Study on
detection of camellia fruit in natural environment based on faster-RCNN. Acta
Agriculturae Jiangxi, 67–70.
CRediT authorship contribution statement Chen, H., Xia, Q., Zuo, T., Tan, H. Q., & Bian, Y. B. (2014). Quality grading method of
shiitake based on texture analysis. Nongye Gongcheng Xuebao/Transactions of the
Chinese Society of Agricultural Engineering, 30, 285–292.
Qiang Liu: Conceptualization, Methodology, Formal analysis, Duan, Z. J., Li, S. B., Hu, J. J., Yang, J., & Wang, Z. (2020). Review of deep learning based
Writing – review & editing, Project administration, All authors have object detection methods and their mainstream frameworks. Laser & Optoelectronics
read and agreed to the published version of the manuscript. Ming Fang: Progress, 57, Article 120005.
Ge, Z., Liu, S., Wang, F., Li, z., & Sun, J. (2021). Yolox: Exceeding yolo series in 2021.
Software, Validation, Investigation, Resources, Writing – original draft. Hinton, G. E., & Salakhutdinov, R. R. (2006). Reducing the dimensionality of data with
Yusheng Li: Conceptualization, Visualization. Mingwang Gao: neural networks. Science, 313, 504–507.

9
Q. Liu et al. LWT 168 (2022) 113902

Huang, G., Liu, Z., Laurens, V., & Weinberger, K. Q. (2016). Densely connected Ren, S., He, K., Girshick, R., & Sun, J. (2017). Faster r-cnn: Towardsreal-time object
convolutional networks. IEEE Computer Society. detection with region proposal networks. IEEE Transactions on Pattern Analysis and
Jiang, H. T., & Li, W. F. (2005). Review on export production technology of Lentinus Machine Intelligence, 39, 1137–1149.
edodes. Edible Fungi of China, 24, 3–5. Sergey, I., & Christian, S. (2015). Batch normalization: Accelerating deep network
Kong, Y. H., Zhu, C. C., & Che, L. L. (2018). Flower recognition in complex background training by reducing internal covariate shift. ICML, 1, 448–456.
and model pruning based on mobileNets. Science Technology and Engineering, 18, Shan, N. (2017). Edible fungus stand out, with Lentinus edodes leading the big pattern.
84–88. Journal of Changjiang Vegetables, 1–2, 000.
Lai, Y. J., Hao, S. F., & Huang, D. J. (2020). Methods and progress in deep neural network Su, F., Zhang, Z. X., Zhao, Y. P., Li, T. H., & Zu, L. L. (2022). Detection of mature green
model compression. Journal of East China Normal University, 5, 68–82. tomato based on lightweight YOLOv3. Journal of Chinese Agricultural Mechanization,
Li, J., Wang, J., Su, Y., & Rao, X. (2010). Detection and gradeing on exterior quality of 132–137.
fresh entinus edodes based on computer. Academic Periodical of Farm Products Szegedy, C., Liu, W., Jia, Y., Sermanet, P., & Rabinovich, A. (2014). Going deeper with
Processing, 4–7. convolutions. CVPR 2015, 07-12-June-2015.
Li, Y. (2005). Research status and prospect of Lentinus edodes. Microbiology China, 32, Wang, X. Y., Li, Y. X., Yang, Z. Y., Zhang, M., Wang, R. M., & Cui, L. X. (2021). Detection
149–152. method of clods and stones from impurified potatoes based on improved YOLO v4
Liu, Y. F. (2020). Research on mushroom detection and monocular camera positioning algorithm. Transactions of the Chinese Society for Agricultural, 52(8), 241–247.
technology based on YOLO v2 network. Dissertation. Henan University. Xie, Q. (2020). Visual sorting technology and graphic defect detection of external quality
Liu, W., Anguelov, D., Erhan, D., Szegedy, C., Reed, S., Fu, C. Y., et al. (2016). Ssd: Single of fresh Lentinus edodes. Edible Fungi of China, 39, 153–156.
shot multibox detector. ECCV, 9905 LNCS. Yang, M. D., Long, Z. F., & Jian, L. I. (2006). Study on Flavor Compounds in Lentinus
Liu, Y., Xie, Y. Q., Li, Z. B., Qi, J., & Li, S. N. (2021). Research progress of deep learning edodes. Food Science, 27, 223–226.
target detection algorithm in security field. Communications Technology, 54, Zhang, X. L. (2021). Convolutional neural network-based spectral analysis and its application
2063–2073. in quality evaluation of agro-products. Dissertation: Zhejiang University.
Medeiros, A., Bernardes, R. C., Silva, L., Freitas, B., & Silva, C. (2021). Deep learning- Zhang, X., & Wang, G. H. (2022). Stud pose detection based on photometric stereo and
based approach using x-ray images for classifying crambe abyssinica seed quality. lightweight YOLOv4. CAAI Transactions on Intelligence Technology, 2(1), 32–37.
Industrial Crops and Products, 164. Zou, Q. J., Xiong, K., Fang, Q., & Jiang, B. H. (2021). Deep imitation reinforcement
Redmon, J., Divvala, S., Girshick, R., & Farhadi, A. (2016). You only look once: Unified, learning for self-driving by vision. CAAI Transactions on Intelligence Technology, 6(4),
real-time object detection. IEEE. 493–503.
Redmon, J., & Farhadi, A. (2017). Yolo9000: Better, faster, stronger. IEEE. Xu, Y., M., & Zhang, R., Q. (2021). Analysis on the present situation and future
Redmon, J., & Farhadi, A. (2018). YOLOv3: An incremental improvement (arXiv-preprint). development of lentinus edodes industry in China. Edible Fungi of China, 40, 89–92.

10

You might also like