## 2 Materials and Methods
### Weed Classification
#### 2.4.2 Data Preprocessing  
For this work, the dataset underwent preprocessing, consisting of applying the color-based segmentation method to each of the images contained in the dataset in order to extract the shape of the undergrowth so the CNN models further classified each of the weed species. The conversion from an RGB to an HSV color space model is defined by Equations (1)-(3) [31]:  
\[H=\left\{ \begin{aligned} 0,\quad si\ Max=Min\\ \left(60^{\circ}\times\frac{G-B}{Max-Min}+360^{\circ}\right) \times mod\ 360^{\circ},\quad si\ Max=R\\ 60^{\circ}\times\frac{B-R}{Max-Min}+120^{\circ},\quad si\ Max=G\\ 60^{\circ}\times\frac{R-G}{Max-Min}+240^{\circ},\quad si\ Max=B \end{aligned} \right. \tag{1}\]  
\[S=\left\{ \begin{aligned} 0,\quad si\ Max=0\\ \frac{Max-Min}{Max},\quad any\ other\ value\end{aligned} \right. \tag{2}\]  
\[V=Max \tag{3}\]  
where \(Max\) is the maximum value of the RGB color model components, \(Min\) is the minimum value of those same components, and \(mod\) is a modular operation with 360 degrees. Figure 5 represents the process of the color conversion and masking of the preprocessed images. The procedure to carry out the segmentation of the dataset images consisted of (a) converting the red-green-blue (RGB) color images to hue saturation value (HSV); once this was complete, the masking was performed (b), and finally, the shapes of each of the weeds (c) were obtained. It is important to mention that all the preprocessing of the images was performed using the OpenCV library; so, only the functions corresponding to each process were applied, and we considered a vector of features with green hues defined between 50 and 150 [32]. The effectiveness of the color-based segmentation for weed detection depends on the color properties of the weed and the background, as well as the lighting conditions and the camera settings used to capture the image. In some cases, other features such as texture, shape, or size may need to be used in combination with color-based segmentation for more accurate weed detection. Figure 4: Samples of the images contained in the dataset “DeepWeeds”: (**a**) Chinee apple, (**b**) Lantana, (**c**) Parkinsonia, (**d**) Parthenium, (**e**) prickly acacia, (**f**) rubber vine, (**g**) Siam weed, and (**h**) snakeweed [22]. 2.4.3. Training and Evaluation of the CNN for Weed Classification  
Once the preprocessing was complete, two CNN models were used to train and classify the different classes of weed species found in the \"DeepWeeds\" dataset, Inception V3 and VGG16. The CNN InceptionV3 architecture is one of the widely used image recognition models, which was shown to achieve greater than 78.1% accuracy on the ImageNet dataset. The model is made up of symmetric and asymmetric building blocks including convolutions, average-pooling, max-pooling, concatenations, pullbacks, fully connected layers, batch normalization, and trigger inputs, and the losses are calculated via a Softmax function [33]. The following image shows an example of the CNN InceptionV3 architecture. The architecture of the CNN VGG16 is formed by 13 convolutional layers, two fully connected layers, and a Softmax classifier; this network was created in order to use only 3 \(\times\) 3 convolutional layers stacked one on top of the other. It is one of the CNNs that offers the ability to extract features from the images; so, it is widely used when large amounts of these need to be processed [34]. 2.4.4. Distributed DL Using Horovod  
Thus far, we have explained how the HPCC was used, the preprocessing of the images, and the models of convolutional neural networks that were used. Now, we briefly explain how the distributed DL was conducted, for which the Horovod framework was used. We decided to use the Horovod framework as, in terms of acceleration, it allows for reducing processing times when processing large amounts of data in a distributed manner [35].