You are on page 1of 5

Agroindustrial plant for the classification of Hass avocados in real-time with

ResNet-18 architecture

Oscar Jhon Vera Ramirez José Emmanuel Cruz de la Cruz Wilson Antony Mamani Machaca
Electronic Engineering Electronic Engineering Electronic Engineering
Universidad Nacional de Moquegua Universidad Nacional del Altiplano Universidad Nacional del Altiplano
Moquegua, Perú Puno, Perú Puno, Perú
overar@unam.edu.pe josecruz@unap.edu.pe wilmamanimac@est.unap.edu.pe

Abstract— The avocado is the fruit with a growing trend in networks, of apples in four grades, grade 1 being the best
production due to its demand in the world market. Peru quality and grade 4 the damaged ones, I use preprocessing that
currently ranks third in the export of Hass type avocados. For consists of segmentation techniques and elimination of
the efficient classification of avocados in good or bad condition, antecedents to extract the area of the fruit, the network I used
a ResNet-18 algorithm applied to a robust agro-industrial plant 90% of data for training and obtained a precision of 85% [4].
was implemented. By using a non-invasive classification we [5] coincides with the image processing to identify the state of
reduce handling damage. The plant consists of a feeder system the avocado leaf, it uses k-means, in a saturation-value space
that continues with a conveyor belt, followed by the image at the superpixel level, to segment the leaf from the uniform
acquisition system with its lighting system, finally, there is the
background from images captured in the field under semi-
classification system formed by the pneumatic system consisting
of pistons that will deposit the avocados in the right containers.
controlled conditions; and a shallow neural network to classify
The treatment of the images was developed in three stages: histograms composed of leaves segmented into 4 states:
acquisition, training, and implementation of the neural network. healthy, iron deficiency, magnesium deficiency, and spider
The Deep Learning algorithm used is ResNet-18, and the mite infestation, the proposed method separates the leaf from
hyperparameters of the convolutional network were adjusted to the background with a mean F score of 0.98 and classifies the
obtain a precision of 98.72%, a specificity of 98.52%, and an F1 blade condition with an overall accuracy of 96.8%. For the
score of 98.08%. classification of the fruit by using the oriented gradient
function histogram and extreme learning machine, it uses the
Keywords— Classification, ResNet-18, Avocado, industrial oriented gradient histogram: Extreme Learning Machine
plant. (ELM), achieving a precision of 95%, in this study an SVM
comparison classifier obtaining a precision of 97.3%; To
I. INTRODUCTION extract the characteristics, the Gradient Histogram (HOG)
There are five hundred species of avocados of which the function was used with 9 containers representing gradient
most appreciated are Hass, Fuerte, Bacon, Reed, Pikerton, angles 0, 20, 40… 160 [6]. [7] maintains that for the maturity
Gween avocados. The worldwide consumption of Hass classification of the fresh palm fruit bunch oil (FFB), an
avocado represents 80% of production, with Peru being the artificial neural network (ANA) was used on a total of 80 oil
third-largest exporter of avocados of this type worldwide. The palm samples, the segmentation method used was k-means,
small and medium-scale agri-food industry has problems with applied on a multilayer perceptron (MLP). One of the types of
properly qualified personnel and long processing times, losing neural networks found in the state of the art in image
the quality of classification due to staff fatigue and classification is ResNet. For example [8] proposes a modified
subjectivities. By automating this process, the percentage of ResNet network through adjustable direct access connections,
quality is increased and the selected time is reduced. Sorting achieving a 3.66% improvement over the original ResNet
technology consists of hardware and software that are network, using the CIFAR 10 dataset to carry out its tests. [9]
integrated to speed up industrial processes. There are several It also proposes a modification of ResNet called LDS-ResNet
methods of fruit classification such as: [1] that for the inspired by residual blocks of linear dynamic systems, the test
detection of mangoes used CCD cameras in a real plant to is carried out on three image databases: CIFAR-10, CIFAR-
detect color, volume, size, shape, and density using artificial 100, and ImageNet, indicating that the proposed system
intelligence techniques, focusing on the physical design of the exceeds the original ResNet system. [10] proposes a
plant. Also [2] for the classification of diseases of banana, modification of a convolutional neural network called
apple, and cherry used convolutional neural networks, this FusionNet for the detection of invasive ductal carcinoma and
classification contains 28 layers that were trained from the subtypes of breast cancer lymphoma, achieving a 5.06%
Imagenet dataset achieving a precision of 78.1%, which is improvement in the F parameters compared to other methods
retrained using the technique of learning transfer. The system such as UNet and ResNet. [11] uses Inception ResNet to detect
proposed by [3] classifies the fruit based on the percentage of polyps, taking as a CVC-Clinic polyp frame database, the tests
infection, the system is developed in TensorFlow, the research are performed not only on images but also on videos. [12]
for classification that explores a convolutional neural network proposes a combination of optimized S transform and a
model taking into account the learning rate, the batch size, and ResNet network to detect from the respiratory sounds: normal,
epoch number, three parameters that influence network wheezing, and adventitious crunching diseases such as
performance. The experimental results show that when other asthma, obstructive pulmonary diseases, pneumonia,
parameters remain unchanged, the errors trained by the bronchitis, achieving an accuracy close to 99%. [13] uses
network model decrease significantly as the learning rate ResNet and VGG to identify people by voice, with the
increases. For the classification by deep convolutional neural VoxCeleb database improving performance by 0.9% over

XXX-X-XXXX-XXXX-X/XX/$XX.00 ©20XX IEEE


traditional methods such as VoxCeleb. This article seeks to A. Data acquisition
classify avocados in good or bad conditions using an agro- For the network training stage, 492 images obtained from
industrial plant and an image recognition algorithm using a the fruit 360 dataset were used.
deep convolutional neural network with Resnet-18
architecture. The contributions of the article are:
- Implementation of real smart agriculture using a real-
time avocado sorting plant composed of industrial
elements such as PLCs, variable speed drives,
pneumatic systems, and infrared sensors.
- Implementation of a deep neural network of ResNet-
18 architecture by optimizing parameters such as
geometric transformations, to train the network
properly, learning rate, and times in the training phase
to correct overfitting errors and data mismatch.
II. SYSTEM DESCRIPTION
The plant is located in the robotics laboratory of the
National University of Moquegua that is shown in Fig. 1.

Fig. 2. Sample of the dataset used.

As can be seen in Fig. 2, the avocados are classified by


color determining if they are in good or bad condition.
B. ResNet-18 Architecture
Decision-making from images is a developing area that
has been applied in all fields of science. For this, we have
artificial neural networks that, from directly connected layers,
Fig. 1. Avocado sorting plant. manage to classify the images according to the chosen criteria.
A variant of artificial neural networks is convolutional neural
The plant consists of the Othelo w360 Micronics camera networks, which use the principle of deep neural networks to
with a resolution of 640x480 pixels with 06 built-in LED achieve their objective. The architecture of deep neural
lights. The Core I7 data processor (PC) with 16G RAM with networks allows, from their convolutional layers and their
a GeForce GTX 1650 GPU. The sorting plant has a routed non-linear activation function, to extract specific
characteristics from the images to be classified. Due to the
conveyor belt controlled by a 1HP 3-phase motor at a
process of convolution and application of the activation
constant speed. The plant feeder is controlled by a 1/2 HP
function (softmax), it happens that the resulting matrices each
motor. The pneumatic sorting mechanism has 6 cylinders that time decrease in size, eliminating characteristics that are
control the final sorting system. This whole system is probably desirable for classification. To solve this, deep
governed by an S7 1200 PLC. The software stage is made up residual networks are used by adding identity mappings as
of TIA PORTAL (OPC), a sequential algorithm, and the shown in Fig. 3.
ResNet-18 neural network that classifies avocados.
The classification process begins when the avocados,
after passing through the feeder stage, are deposited on the
conveyor belt, pass through the Othelo w360 Micronics
chamber, and the constant lighting system of 2356 lux and at
a height of 40cm. The camera detects the avocados and sends
the information to the computer, which has a ResNet-18
neural network that classifies avocados in good and bad
condition, activating pistons through pneumatic actuators, the
plant will deposit the avocados in the respective categories of
Fig. 3. Residual learning: a building block.
containers. The presence of avocados is detected by six
infrared sensors that send information to the computer to In the present study, ResNet-18, a residual network of 18
classify them. The conveyor belt has a length of 5 m. The convolutional layers, was used to extract the essential
sensors are located 25cm from each other on one side of the characteristics of the avocados to be classified, without
routed conveyor belt. reaching the degradation implied by using more convolutional
layers. The architecture used is shown in Fig. 4.
There are four stages to classification in software:
Fig. 4. ResNet-18 architecture used.

The system first read the input resized images of 224 x 224
x 3 with the value of 3 representing the three color channels
used. After clustering in the last convolutional layer, it is fed
to the next stage which is a fully connected neural network to
achieve the final classification result.
C. Training
The size of the images was reduced to 224x224 pixels,
geometric transformations such as rotation, and translation
were performed. The learning range was established between
1x10-6 and 1x10-4 to obtain high accuracy and thus condition
the pre-trained network to classify the avocados in the plant.
D. Implementation of the trained network Fig. 6. Classification plant flow chart.
It is the stage responsible for identifying and making
decisions for the classification of each avocado, taking as Fig. 7 shows the number of images classified correctly and
reference the weights established in the neural network incorrectly, having 67 true negatives, 1 false positive, 2 false
acquired in the learning stage. negatives, and 77 true positives.

Fig. 5 shows the avocados in the lighting system


transported by the routed belt that will be later classified by
the ResNet-18 algorithm.

Fig. 5. Images of avocados to be classified. Fig. 7. Confusion matrix.

III. RESULTS AND DISCUSSION Fig. 8 shows the loss vs the learning rate of the ResNet-18
The equipment is turned on and the plant is initialized network, which has a linear learning rate model in the range
through Tia Portal, at the same time the python script is 1e-06 to 1e-01.
started. Subsequently, the avocados that enter the image
acquisition system are fed, which are transferred to the trained
algorithm (ResNet-18 architecture) for classification. The
ResNet-18 architecture sends a signal to the selection stage
composed of infrared sensors and pistons that deposit the
avocado in the appropriate container, performing this entire
process iteratively. In Fig. 6 the described system is detailed
through a flow chart:

Fig. 8. Loss vs Learning Rate.


Fig. 9 shows the behavior of the ResNet-18 neural network agriculture solution was implemented using a real-time
with the training and validation data, it can be seen in the avocado sorting plant composed of industrial elements such as
following figure that indicates that when iterating the neural PLC's, variable speed drives, pneumatic systems, and infrared
network, the loss is reduced making the classification more sensors in combination with the software formed by ResNet-
optimal obtaining a minimum loss: 18 neural networks, managing to classify avocados in good or
poor condition through the optimization of the parameter such
as Learning rate, epochs, and geometric transformations to
avoid overfitting and data mismatch. Taking as a reference a
previous work in the same plant, which was carried out with a
dataset of 154 avocados, obtaining a precision of 60%; In this
article, a data set of 492 avocados was used to train it with a
ResNet-18 type neural network. An accuracy of 97.95% was
obtained, improving the system by 37.95% compared to the
study mentioned above. The sensitivity reached values of
97.46%. The positive predictions (Precision) reached 98.71%
and the F1 parameter reached a value of 98.08%. The system
can be improved by increasing the number of images for the
training phase or by applying a hybrid method for the neural
network, such as increasing the number of layers for the
Fig. 9. Lost in Data. convolution phase or for the fully connected network.

TABLE I. RESNET-18 TRAINING STATISTICS REFERENCES


Epoch Train loss Valid Loss Accuracy Time
[1] N. D. Thong, N. T. Thinh and H. T. Cong, "Mango Classification
3 0.722525 0.179696 0.979592 00:04 System Uses Image Processing Technology and Artificial
Intelligence," 2019 International Conference on System Science and
Engineering (ICSSE), Dong Hoi, Vietnam, 2019, pp. 45-52, doi:
Table I shows the training of the ResNet-18 neural 10.1109/ICSSE.2019.8823119.
network was carried out in 3 periods with a final loss of 0.722 [2] M. Nikhitha, S. Roopa Sri and B. Uma Maheswari, "Fruit Recognition
and Grade of Disease Detection using Inception V3 Model," 2019 3rd
and 0.179 in the training and validation data respectively, an International conference on Electronics, Communication and
accuracy of 97.95% was obtained. The neural network Aerospace Technology (ICECA), Coimbatore, India, 2019, pp. 1040-
training process was 4 seconds. 1043, doi: 10.1109/ICECA.2019.8822095.
[3] N. Xu, "Research on the Influence of Convolutional Neural Network
TABLE II. CLASS STATISTICS Parameters on Fruit Classification," 2019 3rd International Conference
on Electronic Information Technology and Computer Engineering
Misclassification False (EITCE), Xiamen, China, 2019, pp. 606-610, doi:
Accuracy Sensitivity
rate positive rate 10.1109/EITCE47263.2019.9094902.
0,979591 0,0375 0,974683 0,014705 [4] A. Pande, M. Munot, R. Sreeemathy and R. V. Bakare, "An Efficient
Approach to Fruit Classification and Grading using Deep
TABLE III. CLASS STATISTICS Convolutional Neural Network," 2019 IEEE 5th International
Conference for Convergence in Technology (I2CT), Bombay, India,
Specificity Precision F1 score 2019, pp. 1-7, doi: 10.1109/I2CT45611.2019.9033957.
[5] I. F. Salazar-Reque, A. G. Pacheco, R. Y. Rodriguez, J. G. Lezama and
0,985294 0,987179 0,980891
S. G. Huamán, "An image processing method to automatically identify
Avocado leaf state," 2019 XXII Symposium on Image, Signal
Processing and Artificial Vision (STSIVA), Bucaramanga, Colombia,
The previous research work was carried out on the same 2019, pp. 1-5, doi: 10.1109/STSIVA.2019.8730218.
plant with a data set of 154 avocados and an accuracy of 60% [6] Rismiyati and H. A. Wibawa, "Snake Fruit Classification by Using
was obtained [14]. In this article, a 492 avocado data set was Histogram of Oriented Gradient Feature and Extreme Learning
used to train it with a ResNet-18 type neural network. Given Machine," 2019 3rd International Conference on Informatics and
Computational Sciences (ICICoS), Semarang, Indonesia, 2019, pp. 1-
that the classes of the data set are balanced, in Table II and 5, doi: 10.1109/ICICoS48119.2019.8982528.
Table III the class statistics are obtained, which indicates that [7] N. Fadilah, J. M. Saleh, H. Ibrahim and Z. A. Halim, "Oil palm fresh
the precision of 97.95% obtained is adequate as a metric for fruit bunch ripeness classification using artificial neural network,"
comparison, improving the system by 37.95%. compared to 2012 4th International Conference on Intelligent and Advanced
the study mentioned above. The percentage of wrong Systems (ICIAS2012), Kuala Lumpur, 2012, pp. 18-21, doi:
predictions was 3.75%. The sensitivity reached values of 10.1109/ICIAS.2012.6306151.
97.46% while the false positive rate reached 1.47%. On the [8] B. Li and Y. He, "An Improved ResNet Based on the Adjustable
Shortcut Connections," in IEEE Access, vol. 6, pp. 18967-18974, 2018,
other hand, the specificity reached 98.52% and the percentage doi: 10.1109/ACCESS.2018.2814605.
of positive predictions that were correct (Precision) reached [9] A. Dimou, D. Ataloglou, K. Dimitropoulos, F. Alvarez and P. Daras,
98.71%. To be able to compare precision performance "LDS-Inspired Residual Networks," in IEEE Transactions on Circuits
combined with integrity, we found the F1 parameter with a and Systems for Video Technology, vol. 29, no. 8, pp. 2363-2375, Aug.
value of 98.08%. 2019, doi: 10.1109/TCSVT.2018.2869680.
[10] N. Brancati, G. De Pietro, M. Frucci and D. Riccio, "A Deep Learning
IV. CONCLUSIONS Approach for Breast Invasive Ductal Carcinoma Detection and
Lymphoma Multi-Classification in Histological Images," in IEEE
Currently, Peru ranks third in the export of Hass type Access, vol. 7, pp. 44709-44720, 2019, doi:
avocados, its demand is growing worldwide. An intelligent 10.1109/ACCESS.2019.2908724.
[11] Y. Shin, H. A. Qadir, L. Aabakken, J. Bergsland and I. Balasingham,
"Automatic Colon Polyp Detection Using Region Based Deep CNN
and Post Learning Approaches," in IEEE Access, vol. 6, pp. 40950-
40962, 2018, doi: 10.1109/ACCESS.2018.2856402.
[12] H. Chen, X. Yuan, Z. Pei, M. Li and J. Li, "Triple-Classification of
Respiratory Sounds Using Optimized S-Transform and Deep Residual
Networks," in IEEE Access, vol. 7, pp. 32845-32852, 2019, doi:
10.1109/ACCESS.2019.2903859.
[13] N. N. An, N. Q. Thanh and Y. Liu, "Deep CNNs With Self-Attention
for Speaker Identification," in IEEE Access, vol. 7, pp. 85327-85337,
2019, doi: 10.1109/ACCESS.2019.2917470.
[14] J. E. Cruz de la Cruz and O. J. Vera Ramirez, "Convolutional neural
networks for the Hass avocado classification using LabVIEW in an
agro-industrial plant," 2020 IEEE XXVII International Conference on
Electronics, Electrical Engineering and Computing (INTERCON),
Lima, Peru, 2020, pp. 1-4, doi:
10.1109/INTERCON50315.2020.9220246.

You might also like