# Deep Learning for Detecting Verticillium Fungus in Olive Trees: Using YOLO in UAV Imagery
## 4 Materials and Methods  
Our areas of study were three olive fields, Fields A, E and K, located in Northern Greece (Figure 2), photographed at midday between the 5 th of October and the 4 th of November of 2022. The UAV used to gather the images was an Air Surveyor 4 equipped with a SONY IICE-6000 camera. The camera was running the 3.21 version of its software and captured images at \(8\times 10^{-4}\)-second exposure time with the use of SAMYANG AF 24 mm F2.8 lens. The produced RGB images where 6000 \(\times\) 4000 pixels. Figure 2: Locations of the olive fields. After the images were collected by the UAV, they were separated depending on what field they originated from and images from the same field were stitched together to create an orthomosaic. Every created field orthomosaic was then cut in tiles of size 3000 \(\times\) 2000 (pixels) and was annotated with the use of the Labelimg package (Figure 3) to create the data that were provided to the YOLO algorithm. The annotations were produced in the YOLO format, where for each image a text file with the same name storing the results of the annotation was created, and in every text file, each instance (tree) was represented as a line of text. The annotations had the form of bounding rectangles, and were represented in text as follows: the first number in the line conveyed the class to which the instance belonged, encoded as an integer, while the next four numbers represented the coordinates of the bounding boxes, with the first two being the centers of the bounding box in the X and Y axis divided by the height and width of the image, respectively, and the last two being the width and height of the bounding box divided by the height and width of the image, respectively. The classes that every tree was classified into were two: either damaged or healthy. The annotation process had two parts: initially, the bounding boxes were created by visually determining the borders of each tree, while the second part--the class annotation--was performed by experts based on what constitutes as damage caused by the verticillium wilt--the damaged trees had a visibly altered color, the result of the withering effect that the wilt has on olive tree leaves (Figure 4). Figure 4: Comparison of a damaged tree (**left**) and a healthy one (**right**). Figure 3: Annotating trees with bounding boxes through the Labelimg graphical interface. The annotated images were randomly split into train, validation and test datasets. The split happened so that the training dataset contained 60% of the data while validation and testing contained 20% each. To avoid providing the algorithm with datasets of different percentages of damaged trees, and thus to ensure that the three fields were equally represented in the splits, the splitting of the data was stratified to account for the field from which the tiles originated. The YOLOv5n, YOLOv5s and YOLOv5m models were applied on the dataset at two different image scales, utilizing network weights created from pretraining on the COCO128 dataset. The models were trained on a desktop computer equipped with an Intel(R) Core(TM) i7-10700 CPU running at 2.90 GHz and 16 GB of RAM. The results were evaluated with the metrics commonly used in evaluating YOLO model performance that are described in detail below:  
1. Precision: \[\frac{TP}{TP+FP},\] (1)
2. Recall: \[\frac{TP}{TP+FN},\] (2) where \(TP\) = true positives, \(FP\) = false positives, \(FN\) = false negatives. 3. Mean Average Precision, or \(mAP\), which is the mean of Average Precision (\(AP\)) values calculated for a certain threshold (e.g., \(mAP\) [0.5]: \(mAP\) for threshold value of 0.5) or range of thresholds (e.g., \(mAP\) [0.5:0.95]: \(mAP\) for threshold values of 0.5 up to 0.95 with a step of 0.05) for all classes: \[mAP=\frac{1}{n}\sum_{n}AP_{n}\] (3) with \[AP_{n}=\frac{1}{101}\sum_{r\in\{0.0,...,1.0\}}\max_{r\geq r}PRC(\widetilde{r}),\] (4) where \(PRC\) is the precision-recall curve, \(\widetilde{r}\) is the 101-point interpolated recall value and \(n\) is the class.