Identification of Peruvian timber species based on image processing and convolutional neural networks

The identification of timber species is highly important worldwide due to their global trade and the arising requirement of controlling, regulating and monitoring illegal logging. Peru has an important timber trade due to extensive forest resources in the Peruvian Amazon. This context makes it necessary to have technological tools for timber species identification using tree leaves, in an attempt to control deforestation in the Amazon forests. Current identification methods require manual labor, are subjective and inefficient regarding time, cost and precision. Moreover, the scientific literature does not include electronic devices nor algorithms which exclusively identify Peruvian timber species. With this in mind, this work proposes a portable electronic equipment that detects 11 timber species from the Peruvian jungle, based on image processing techniques and convolutional neural networks (CNN). The device consists of a carbon fiber structure, a keyboard, a 7-inch display, internal lighting and a tray for the leaf sample. The algorithm uses color filters, thresholding and other operations to segment the leaf and then input it to a neural network. After comparing the AlexNet, VGG-16 and MobileNet architectures, the last one shows the best performance, with an average precision of 98.64% when identifying the 11 timber species.


INTRODUCTION
The forestry industry is highly relevant to modern global economics.According to the International Tropical Timber Organization (ITTO), in 2020, global trade exchanged more than 2.5 trillions of cubic meters of timber (Ferreira et al., 2021).On the other hand, illegal logging is a growing issue which harms producers and consumers worldwide such as: Australia, Cambodia, China, the European Union, Indonesia and Peru (Winkel et al., 2017).Both timber global trade as well as illegal logging show the need to regulate forests and inspect the origin of commercialized timber in order to protect species diversity.In the case of Peru, SERFOR (the National Forestry and Wildlife Service) compels owners of forest areas to register them in the national registry of forest plantations, indicating the number of trees and species in the owned area for commercial purposes.A botanist identifies the timber species, firstly through visual means and, if required, through laboratory analysis using a dendrological manual.This manual process is time-consuming, costly and has low precision, so an automatic identification method would significantly reduce these issues and allow timber companies and research institutions to precisely monitor forests for an appropriate timber commercialization or for elaborating species protection plans.State-of-the-art solutions use algorithms with Support Vector Machines (SVM) or CNN which work with mobile applications, portable devices or graphical interfaces but do not solve the identified problems because of: high error rates, using public databases which do not have Peruvian timber species or comparing easily differentiable plant species, instead of comparing timber species.
Table 1 shows these proposals, as well as their strengths and weaknesses.As Table 1 shows, none of the previous works detect Peruvian timber species, but in-stead use public datasets or build their own datasets with fruit, medicinal or non-Peruvian plants.This is a problem since SERFOR requires Table 1.Proposed solutions in the state-of-the-art Reference Technique Application Strengths Weaknesses (Selda et al., 2017) Uses SIFT (Scale-Invariant Feature Transform) to obtain the leaf vein structure and SVM to classify the SIFT features.
Portable equipment with a Raspberry Pi to identify plants Integrates the SIFT and SVM algorithm in a portable device, adding a graphical user interface.
High error rate of 15.71% (Singh et al., 2020) Image pre-processing via noise reduction, border enhancing, binary thresholds and Fourier descriptors.
Uses a VGG-16-based CNN for classification.
Method for leaf recognition.
High algorithm precision (95%).The algorithm can recognize leaves damaged up to a 30% of their shape.
The algorithm is trained and tested with the Flavia public database, which has plant leaves and no timber species.

Algorithm which recognizes medicinal plants in Jocotitlan,
Mexico.
The algorithm identifies 11 plant species.
Training images show notable differences in their flowers, structure and color.The achieved precision is 84.07%(Song et al., 2019) Uses an ABCNN (Attention-Based Convolutional Neural Network), trained with the Leafsnap database.Image pre-processing via gamma transform, geometric transforms, smoothing filters and noise for data augmentation Method to recognize similar tree leaves.The achieved error rates are slightly high: 9.1% for the quadratic SVM, 10.6% for the cubic SVM, 10.2% for the medium Gaussian SVM.(Zarrin and Islam, 2019) Uses a Redmi 5A smartphone for leaf image acquisition and authors propose their own 9-layer CNN.
Leaf image classifier based on a CNN.
Algorithm achieves a precision of 99.4% for the 10 species.
All species are fruit trees and none are timber species.The algorithm has no electronic equipment.(Kang and Oh, 2018) Compares the following CNN models: AlexNet, VGG, GoogleNet; integrates the deep learning model with a mobile application which asks the uses to center the leaf with the phone camera.
Android application for plant classification in real time.
Achieves a 96.0%accuracy with VGG for 63 species.
The plant species in the dataset are from a field in a Korean university.(Varghese et al., 2020) Uses transfer learning with a MobileNet model connected to a mobile application through Firebase.
Android application for plant classification in real time.
Achieves a validation precision of 95%.
The training database consists of only 6 different medicinal plants from India.
registering Peruvian timber species mainly targeted by illegal loggers.Moreover, some works have high error rates, which could translate into financial penalties due to incorrectly registering misidentified species.Additionally, most proposals use mobile applications instead of their own portable devices for in situ image acquisition.Since the forest plantations are located deep in the Amazon rainforest, the use of an autonomous, portable device has two main advantages.Firstly, analyzing the samples in situ minimizes the need for taking the samples back to a stationary laboratory, which is time consuming.Secondly, performing the analysis in the device eliminates the requirement of a stable Internet connection, which is not available in the plantation locations.This work presents the design of a portable equipment which works jointly with the image preprocessing algorithms and the CNN model to classify 11 timber species, which were chosen because of their vulnerability to illegal logging and their ecological importance to the Peruvian amazon rainforest.
The main contributions of this work are: 1.A portable device for identifying 11 Peruvian timber species, consisting of a waterproof structure, a keyboard, an LCD screen, a single-board computer and image processing and artificial intelligence algorithms based on a CNN which achieve an average precision of 98.64%.2. A database with images from the 11 Peruvian timber species acquired with con-trolled lighting using the portable device.The latter guarantees that the images were acquired with a good quality to maximize the performance of the proposed algorithm.
The following sections describe the portable device, algorithms and results.

MATERIALS AND METHODS
This section details the materials and methods applied in both the hardware (electronics and mechanical structure of the device) and software (image processing and artificial intelligence algorithms) aspects.The chosen materials and methods are the result of a selection process which considered several experimental tests, application scenarios, ease of operation and transportation, energy autonomy, computational efficiency, species detection performance and engineering fundamentals.
The mechanical enclosure for the device is designed to be 3D printed in PETG filament.The structure is then reinforced with fiberglass and covered by a waterproof backpack to improve its portability and fall resistance.This design results in a structure which minimizes the impact of external light sources and shadow artifacts during the image acquisition.Thus, the device does not require additional image pre-processing such as the use of color format conversion (Ozturk and Akdemir, 2017) or thermal capture methods (Soetedjo and Hendriarianti, 2022), which generate high use of computational load.

Electronics and Structure of the Proposed Device
The electronics of the proposed device are made up of 4 functional parts: image acquisition, data processing, data visualization and power supply.Fig. 1 shows the pictorial diagram of the indicated parts.
The image acquisition subsystem consists of a Raspberry Pi camera using a resolution of 12.3M pixels (4056 × 3040 pixels) for still images and 1920 × 1080 for video (Raspberry Pi, 2020).These parameters enable an adequate image quality for a correct performance of the species identification algorithm due to a high image acquisition resolution which captures most of the details in the leaves while using a camera model compatible with the Raspberry Pi.Additionally, this camera may use different lenses to enhance its field of view (FOV).
The chosen camera guarantees compatibility with the Raspberry Pi computer and with C or SC type lenses and connects to the Pi with a special flat cable.The lens compatibility enables the possibility of using Arducam models, which have a variety of focal lengths to modify the A small single-board computer Raspberry Pi 4B performs the data processing and equipment control.This computer has enough resources to execute the image processing and artificial intelligence algorithms quickly, demonstrated by various applications such as gesture recognition, face detection, facial biometrics, etc. (Chen et al., 2021).Moreover, it has a lower cost and power consumption than other single-board computer alternatives.Some features of the 4B version are: 8GB RAM, 1.5 GHz CPU, 802.11ac and Bluetooth 5.0 wireless connectivity (electronicaplugandplay, n.d.).These features allow for a fast image processing pipeline and quick leaf classification.Additionally, all the device's peripherals are directly connected to the Pi since it has specific ports for each of them.
On the other hand, a 7-inch LCD screen shows the graphic user interface, through which users can operate the device as well as visualize information.The display has a resolution of 1024 × 600 pixels and connects to the Raspberry Pi via a micro-HDMI port.A Mini Leotec wireless keyboard serves to input data through the user interface, so that users have a comfortable way to interact with the device features, such as registering new plant species.The keyboard has a touch pad for users to navigate through the developed GUI and the device's operating system if needed.
The power supply consists of a 20100 mAh PowerCore.The energy consumption requirements are detailed in Fig. 2.

Fig. 2. Time diagram of estimated consumption for 1 h
The autonomy time is evaluated with Equation (1): Where: : autonomy time (h)   : battery capacity(Ah) D: system consumption(A) For 8 h of autonomy and a consumption per hour of 1.42 A, the required battery capacity is: Then, the real capacity of the powerbank is calculated using Equation (2).
Where: B cap : Battery capacity (Ah) E en : Energy efficiency (%) A 90% power bank efficiency is a reasonable assumption, so replacing in the data we have: Therefore, the PowerBank 20100 ensures the operational autonomy of 8 h of continuous execution of the species identification algorithm.
Regarding the structure of the equipment (see Fig. 3), this was manufactured with carbon fiber due to its resistance to elevated temperatures such as those in the Peruvian rainforest.Additionally, this material has a low density and high flexibility which enables improved ergonomics and aesthetics.The device has a total weight of 7.2 kg and is equipped with external waterproof plastic casing for adequate protection and transportation.The plastic casing allows the equipment to be carried out easily like a backpack, which is extremely helpful when identifying species deep inside the Peruvian Amazon, where walking is required to extract the leaf of said species.

Fig. 3. Developed device
Fig. 4 shows some main parts of the equipment such as the power supply, keyboard, screen and leaves tray.Each measurement shown in Fig. 5 is justified.In the first place, the width, length and depth of the screen are designed to prevent liquids from entering and also to create a shadow so that the screen can be viewed even in bright sunlight.Secondly, the thickness of the electronics area generates greater ventilation for the electronic boards inside and prevents overheating.Third, the diameter of the hole in the upper part provides access to the components area and the image acquisition area in case an adjustment is needed, especially regarding the lens calibration.Lastly, the width of the image acquisition area ensures that leaves up to 30 cm long can be captured without losing image quality.Finally, Fig. 6 shows in detail the internal electronic components and the main areas of the developed device.

Image Processing and Artificial Intelligence Algorithms
This section will detail the methods used for the image processing and artificial intelligence algorithms.Since the equipment has uniform acquisition conditions, the segmentation process is simplified and is performed with simple methods that reduce the computational load and allow to use greater resources for the leaf classification via artificial intelligence.Fig. 7 illustrates the block diagram of the proposed algorithm.As seen in Fig. 7, the input to the algorithm is the leaf image acquired under controlled lighting in the portable equipment.The first step consists of background elimination, using image processing techniques such as color filter, binary thresholds, morphological operations and border detection techniques.If the timber species has been previously registered, an artificial intelligence identifies it.If not, the segmented leaf image is stored in a database such that, when enough images are available, the neural network model can be trained again.The following section describes each step in the algorithm.

Image Acquisition
The input sample consists of the leaf of a tree from the Amazon rainforest, which must be in a good condition, without deformations and flattened out to avoid processing artifacts due to shadows.The device's dimensions are 410 × 342 × 250 mm and the leaf tray has a size of 365 × 243 mm, which is the maximum leaf size.Acquired images are 24 bits RGB (true color) with primary components I R (x, y) , I G (x, y) and I B (x, y).Here, (x, y) are the spatial coordinates of the image, where x = 0,1,…,M-1 and y = 0,1,…,N-1, for M = 1080 and N = 1920.
Considering the device dimensions, the following procedure determines the distance between the surface which holds the leaf and the acquisition camera.
Step 1: The chosen image resolution follows the criterion of achieving a performance of at least 90% in the identification of species, as well as a computational load where the algorithm execution time does not exceed 20 seconds.Empirical testing shows that a resolution of N = 1920 columns by M = 1080 rows is appropriate for image acquisition.
Step 2: Using the image resolution from step 1, the sensor dimensions are computed.The Raspberry Pi camera has a IMX477R sensor with square pixels of L p = 1.55μm, so Equations ( 3) and (4) show the sensor size: Where: Ls x : Sensor's vertical dimension (mm) Ls y : Sensor's horizontal dimension (mm) Step 3: The camera's focal distance serves to calculate the vertical   and horizontal   viewing angles, through Equations ( 5) and ( 6).This calculation uses the shortest focal distance in the multifocal camera lens, d f = 2.8 mm.
Step 4: Finally, Equation ( 7) shows the calculation of the distance D cs between the camera and the acquisition surface.
This calculation considers a rectangular image acquisition area with a length La y = 30 cm.
Then, Equation ( 8) computes the rectangle's width La x : 16.9 cm (8) Fig. 8 illustrates the dimensions of the acquisition area (FOV) and the distance between the camera and the acquisition surface.

Dataset
This section describes the two datasets used for the development of the leaf classification algorithm.The first one is used to classify a leaf from 11 possible species, while the second one is used to determine whether a leaf belongs to one of the species in the first dataset.Details of each of the datasets are given below.

Species Classification
The species classification dataset consists of images of leaves from 11 timber species from the Peruvian amazon rainforest, chosen due to their vulnerability to illegal logging and their economic and ecological importance.These species are among the most commercialized ones for timber production in Peru.The 11 selected species are accessible within a particular region of the Peruvian Amazon Rainforest.The developed device took pictures of the collected leaves, resulting in 100 images for each of 10 of the 11 species, and 120 images for the remaining one, since a collecting mission deep in the Peruvian Amazon was conducted and that was the number of available leaves.The application of data augmentation helps in building a more diverse dataset to avoid model overfitting.The augmentation transforms are random rotations in the range [-20°, 20°] and random horizontal flipping.Rotations provide better results than other geometric transformations in diverse augmentation tasks (Maharana et al., 2022), while flipping augmentation is necessary to recognize leaves wrongly inserted into the device.Fig. 9 illustrates the block diagram of the data augmentation process.
The final dataset after data augmentation consists of 13308 images, where 69.70% are used for training and 30.3%, for testing.Table 2 indicates the species distribution in the training and testing datasets, and Table 3 shows examples of the 11 species in the dataset.

Identification of Whether a Species belongs to the Built Dataset
This section describes an additional dataset used to train a neural network which distinguishes whether the leaf put in the device belongs to the species identification dataset.The additional dataset consists of some images from the 11 selected timber species, grouped in a "Known" class, and new images grouped in an "Unknown" class.The latter class consists of images from 8 fruit species, shown in Fig. 10, as well as images from the timber species with manual modifications such as shape deformations, cropped apex/bottom ends, margin undulations, etc.After building a balanced new dataset (50% of images in each class), it is enhanced using data augmentation, resulting in 9865 images split in 69.34% for training and 30.66% for testing.Table 4 shows the final data distribution.

Leaf Segmentation
The following computational procedure results in the leaf segmentation and elimination of unwanted objects and regions which could hamper the classification stage: Step 1: A color filter extracts most of the leaf section from the background.The original image with primary components I R (x, y) , I G (x, y) and I B (x, y) is converted to the HSV (Hue-Saturation-Value) color model (Gonzales and Woods, 2018), where H(x, y) is the hue, S(x, y) is the saturation and V(x, y)is the value component.An extensive evaluation of the histograms from the 3 components in plenty images with only background resulted in the thresholding mask Mas(x,y) in Equation ( 9) with thresholds illustrated in Fig. 11.Otoba glycycarpa Pointy apex and bottom end, ondulated margins, elliptical shape.

Cedrela odorata
Pointy bottom end, circular apex, blade is narrow near the stem.

Swietenia macrophylla
Visible stem in bottom end and apex, circular shape, visible vein structure.
Parahancornia peruviana Circular apex and bottom end, oval shape, only central vein is visible.

Caryocar glabrum
Pointy apex and bottom end, oval shape, blade is broader near the stem, diagonally oriented veins.

Guazuma crinita
Visible stem at the apex, vertically oriented veins, glossy and bright surface.

Dipteryx micrantha
Curved apex and bottom end, smallest size of the 11 chosen species.Step 2: The color filtered RGB image in Fig. 12 results from applying the mask in (7) to the original primary components, as per Equations ( 10)-( 12 Step 4: The image background is easily distinguishable and has few artifacts after the color filter.Thus, the grayscale image I(x,y) is thresholded to separate the background from the leaf, as per Equation ( 14): The binary threshold u a is computed using the Otsu method (Vijay andPatil, 2016, Hassanein et al., 2018), which employs the grayscale histogram to separate pixels into foreground and background classes.Then, it computes the interclass variance, and settles in a threshold value which minimizes this variance.This method achieves the best results and ensures that the pixels inside the image are assigned an intensity of 255 while the background ones get 0. The binary threhsold computation and the thresholding operation are performed with OpenCV, using the cv2.THRESH_OTSU and the cv2.threshold functions respectively.The thresholding operation receives the grayscale image, the binary threshold and the intensity value assigned to the pixels with intensity greater than the computer threshold.Fig. 14 shows the resulting thresholded binary image.

Fig. 14. Image after applying Otsu's method
Step 5: It is necessary to extract the edges of the binary image so that the largest contour (leaf shape) can be recognized and separated from the rest.To ensure an accurate edge detection, the Canny algorithm (Canny, 1986) is selected.This algorithm extracts the leaf edges in the thresholded binary image from the previous step.It is implemented using the cv2.Canny command from OpenCV library.It receives the input binary image from the previous step, the low gradient intensity threshold (0) and the high gradient intensity threshold ( 255).The result is stored in the binary image F Canny .Then, F Canny is morphologically dilated using Equation ( 15), to eliminate some artifacts after the Canny edge detector and connect any empty spaces in the leaf contour.
Where ES 2×5 is an all-one rectangular structuring element with 2 rows and 5 columns.Fig. 15 shows the image after the Canny edge detector and the morphological dilation:

Fig. 15. Image after Canny edge detector and morphological dilation
Step 6: The final leaf mask I seg (x,y) results from choosing the largest contour in "BC" and filling the surrounded region with an intensity of 255.The cv2.fillPoly function from OpenCV performs the contour filling.It requires the destination image to draw the resulting filled polygon, the coordinates of the largest contour and the fill color (white).The result is shown in Fig. 16.Step 7: The I seg (x,y) mask is applied to the original RGB image, resulting in the segmented leaf image at Fig. 17, with the following primary components: These methods achieve good leaf segmentation results, mostly due to the uniform acquisition conditions inside the developed equipment.These conditions allow the use of a straightforward image processing pipeline.

Re-scaling
The segmented images with primary components I FR (x,y) , I FG (x,y) and I FB (x,y) are rescaled to sizes 224 × 224 and 227 × 227 pixels, since these are the input sizes for the CNN models in this work.Image scaling is done via bilinear interpolation (Kirkland, 2010), since it achieves adequate results and has a lower computational load than other methods such as cubic interpolation.The resulting rescaled image has primary components I FFR (x,y) , I FFG (x,y)and I FFB (x,y), and is shown in Fig. 18.Overall, bilinear interpolation provides good results resizing the segmented images.The details observed in the leaf structure are preserved, which will be beneficial for the classification process.

Convolutional Neural Network
Transfer learning enables employing learnt features in pre-trained neural network models for a different application than it was originally trained for.The following 3 models are compared to choose the best CNN: AlexNet (Krizhevsky et al., 2017), MobileNet (Howard et al., 2017) and VGG-16 (Tammina, 2019).Said models were chosen due to the following reasons: • The classification task is focused on a single type of object (tree leaves).Thus, a simple model like AlexNet may achieve good results.• Since the project intends to add more species to the classification task in the future, new models will need to be trained.Therefore, a lightweight CNN model like MobileNet could help to store new trained models while keeping below the maximum storage capacity.• One of the goals of the portable equipment is to achieve an accuracy greater than 95%.In turn, a model like VGG-16 known for its high performances in classification tasks could achieve this.
In the 3 models, the last layer is changed to a softmax layer with 11 outputs for each of the timber species.MobileNet and VGG-16 are pre-trained in the ImageNet dataset, consisting of around 14 million images with more than 20000 classes (Ghorui et al., 2023).Training lasts for 20 epochs with a batch size of 32, using the Adam (Kingma and Ba, 2014) optimizer with a learning rate of 0.001.Limited memory resources result in using a small batch size, which in turn results in a small learning rate.Training is done with early stopping, after 12 epochs of continuous reduction in accuracy.Fig. 19 shows the CNN architectures and training parameters used for this comparison.The results obtained for each of the CNN models and other characteristics are compared in Table 5. Evidently, MobileNet achieves the best accuracy with the smallest memory footprint next to AlexNet or VGG-16.The MobileNet model uses separable depth convolutions followed by point convolutions to achieve its low memory footprint.It has a depth of 88 layers and uses ReLU activations (Howard et al., 2017).

Graphical User Interface and Device Operation
A graphical user interface made in Tkinter enables users to easily operate the device.Fig. 20 shows the leaf classification screen after the software has analyzed a leaf.The operation steps are described below: • Step 1: The user places the leaf in the sliding tray.
• Step 2: Using the mousepad, the user chooses the classification option in the graphical user interface menu.• Step 3: The user presses the "Capture" button, after which the captured (left) and segmented (right) images appear on screen.• Step 4: If user considers that the image is correctly taken, they press the "Identify" button; otherwise, they repeat the image acquisition with the "Repeat" button.• Step 5: After the algorithm has identified the leaf, the user may press the "Save" button if they desire to store the segmented image.
If the system detects that the leaf does not belong to any species in the dataset (see sections 2.3.2.), the interface shows a secondary screen as seen in Fig. 21.The operation steps are: • Step 1: The user presses the "Back" button in the upper left corner and chooses the species record from the menu.• Step 2: The user presses the "Capture" button and, if the image has been correctly taken, inputs a species name in the text box.Otherwise, the user can repeat the image acquisition.• Step 3: The user presses the "Upload" button.

Performance Evaluation Metrics
The following metrics are used to evaluate the equipment's performance: accuracy, precision, recall and F1-score.Each metric is described as follows: • Accuracy: Is the percentage of correctly classified images with regards to the total number of predictions (Tharwat, 2021).It is computed according to (19): • Precision: Represents the ratio of true positive samples with respect to the total number of positively classified samples (TP+FP) (Tharwat, 2021).It is computed as per ( 20

RESULTS AND DISCUSSION
Model evaluation is performed using Google Collab.30.30% of images are used to test the classification model while 30.66% of images are used to evaluate the model that determines whether an input belongs to the dataset.

Identification of whether the Image Belongs to the Classification Dataset
Figs. 22-24 show the obtained confusion matrices.Table 6 presents the metrics for each model, computed via the confusion matrices.The VGG-16 model achieves the lowest accuracy, at 91.57%.This might be explained due to VGG-16 having the largest number of parameters, which might result in the network overfitting during training.On the other hand, MobileNet achieves an accuracy of 99.34% and AlexNet, of 98.61%.Finally, the MobileNet model is chosen due to its higher accuracy and its lower memory footprint.7 shows the accuracy per timber species for the 3 evaluated models.Table 8 shows confusion matrix metrics (Precision, Accuracy, F1-score) for each model.Table 7 shows that AlexNet and VGG-16 perform poorly for some timber species, achieving an accuracy of less than 95% for Cedrela odorata, Swietenia macrophylla and Dipteryx micrantha.AlexNet has the worst performance, achieving a 95% accuracy for only 5 of the 11 species, while VGG-16 did so for 8 species and MobileNet, for 10 species.Nonetheless, MobileNet (87.5%) does not achieve the 95% accuracy threshold for Cedrela odorata, just as happens for AlexNet (71.67%) and VGG-16 (82.78%).This might be explained by the leaves having many similar features as other species, such as diverse margins (undulated or straight), apices and bottom ends.
In general terms, AlexNet achieves the lowest accuracy (86.11%) which is lower than 90%, while MobileNet (98.64%) and VGG-16 (95.35%) surpass the 90% threshold.Additionally, MobileNet's precision is 98.69% and its F1score, of 98.62%, which indicates that the model can correctly predict classes as well as avoid assigning incorrect classes to samples.
Figs. 28-30 show the accuracy and loss curves for each model during training.Fig. 28 shows that, for AlexNet, the validation loss slightly increases and the validation accuracy slightly decreases in the last epochs, which triggered the early stopping criterion at epoch 16.Fig. 29 shows that VGG-16 achieved a stable loss and accuracy from epoch 5 onwards.This stagnated loss and accuracy curve, coupled with the fact that the validation curve is somewhat far from the training curve, might indicate overfitting.Finally, Fig. 30 shows that MobileNet has a validation loss and accuracy spike at epoch 5 but both curves quickly close the gap to the training loss and accuracy, achieving a value of 0.1 (loss) and 98.69% (accuracy) by the last epoch.
Based on the Figs. and Tables shown above, the MobileNet architecture was selected because it has the highest accuracy of the 3 architectures (98.64%) and requires the least storage space per trained model (16MB).Thus, a new model can be trained in the network with more species and then update the one stored inside the equipment without requiring a large storage space.Moreover, a more lightweight model tends to have a lower computational load and thus, a lower power consumption.

Related Work Comparisons
Table 9 shows a comparison of the classification accuracy between the present work and related ones.
Two of the related works achieved an accuracy lower than 90%.One of these (Selda et al., 2017) relied on the leaf vein structure and an SVM, but did not take into account the leaf surface characteristic.
Likewise, authors at Monroy-de-Jesús et al. ( 2019) built a custom basic CNN with limited results.The proposed system achieved the third highest accuracy of the models.The proposal at Varguese et al. (2020) considered medicinal plants which could be easily distinguished and did not require a large dataset to train the neural network.Similarly, Zarrin and Islam (2019) evaluated fruit trees with somewhat distinguishable leaves and had a dataset with 10,000 images.

CONCLUSIONS AND FUTURE WORKS
The large amounts of globally traded timber require regulations and control of existing species to avoid issues such as illegal logging, and current methods are not sufficiently appropriate.This work presents a portable leaf image acquisition equipment whose design ensures good image capturing conditions.It works jointly with a Python algorithm and a graphical user interface which enables easy user operation.This device serves to identify species in situ and to build new species datasets through imaging and recording of unregistered species.
Apart from ensuring good capture conditions, the equipment was manufactured with carbon fiber and considering requirements such as: rigidity, low weight and portability in order to prevent health problems in the botanical experts who will operate said equipment in the long term.Also, thanks to the components inside the equipment, the illumination control and uniform background, the image segmentation is facilitated, which allows the software to work effectively without the need for complex processing or the use of high computational resources.
In addition to cutting computational resources from the segmentation process, the algorithm uses the MobileNet architecture, which due to its low memory footprint does not need to consume high resources to perform a classification and leaves plenty of space to train new models with updated datasets with more species in the future.MobileNet achieved 98.64% accuracy, superior to the AlexNet and VGG-16 models.Future works can improve these results by building larger datasets with thousands of images per species to improve the training process.
Finally, the device aims to be operated by forestry institutions or botanical to increase the analysis throughput and precision when identifying timber species from the Peruvian amazon rainforest.

Fig. 4 .
Fig. 4. External view of render of the device

Fig. 5 .
Fig. 5. Detailed views of the developed device, dimensions in millimeters

Fig. 9 .
Fig. 9. Block diagram of the data augmentation process

Fig. 20 .
Fig. 20.Main screen in the graphical user interface

Fig. 21 .
Fig. 21.Screen to record a new species

F1
of true positives (Images correctly classified as a particular class) FP: # of false positives (Images classified as a class but belonging to a different) • Recall: Ratio of true positive samples with respect to the total of predicted samples (TP+FN) (Tharwat, 2021).It is computed according to (21of false negatives (Images belonging to a class which were not classified as said class) • F1-score: It is the harmonic mean between precision and recall, and is computed by (22):

Table 2 .
Species distribution in the dataset, after data augmentation

Table 3 .
Selected eleven species from the Peruvian Amazon rainforest

Table 6 .
Model comparison, determination if an input

Table 8 .
General comparison of the 3 models (AlexNet,

Table 9 .
Results comparison with related work