## 2 Experimental Setup and Detection Method
### Proposed Method for Flower Cluster Detection  
Figure 9 shows the process that was taken to create the results shown in Section 3. Before anything can be started, data to train and test the model is needed. As stated before, this was collected at the Simcoe Research Station. Images and videos of the apple tree were collected, and the number of fruit flower clusters per tree were hand-counted to provide a direct comparison for studying the performance of the model. This comparison shows the level of performance of the model in estimating the yield of the apples from the fruit flower clusters.  
Figure 8: Example of zero padding on an image.  
Figure 9: Flowchart of the data collection and results process.  
YOLOv4 will be used for the detector of the fruit flower estimation model. This method has high accuracy and speed produced from the detector (as well, it was the most advanced detector while conducting the trials). YOLOv4 introduced many new features compared to YOLOv3 which was already considered a very good one-stage detector.  
This version of YOLO improved YOLOv3's accuracy and speed by 10% and 12%, respectively [27]. Two new data augmentation training methods were included with YOLOv4. The first being Mosaic Training and the second, Self-Adversarial Training (SAT) [27]. Mosaic Training combines 4 training images into a single input photo to allow for detections outside the normal environment due to YOLO using the entire images features to identify the object [27]. The SAT data augmentation method operates in 2 stages. During the first stage, the neural network changes the inputted images as if there is no desired image present. Therefore, when entering the second stage, the model is trained to detect the desired object based on the altered image [27]. In general, the architecture of YOLOv4 is as follows: CSPDarknet53 backbone, Spatial Pyramid Pooling (SPP) [33] additional module, Path Aggregation Network (PANet) [34] instead of FPN for neck, and YOLOv3 head [27], which can be seen in Figure 10. With these changes, YOLOv4 is expected to produce results that outperform other state-of-the-art object detection algorithms, such as SSD, RetinaNet and Faster R-CNN in both speed and accuracy [27].  
After the dataset was created, some additional changes were needed in order to obtain the desired result of estimating the yield of the apple trees. Before describing what was added, the method on how to estimate the yield of the apple trees will be explained first. The reason for the need to detect the fruit flower clusters of the apple trees is that each fruit flower tree corresponds to a potential apple growing on the tree. A fruit flower cluster usually consists of 3 flowers, with one being the master and can be identified due to blooming faster than the others. Due to this, a method of counting the total number of fruit flower clusters per tree needs to be collected. The model needed to keep track of each tree and update the count per tree. An Intersection-Over-Union (IOU) tracker was introduced, as well as a maximum fruit flower cluster counter.  
The IOU tracker works by checking the bounding boxes in the detection and comparing each bounding box with another bounding box to identify which one has the greatest overlap.  
As the tracking is only needed for the tree class, the IOU calculation was only conducted on the bounding boxes with the class \"Tree\". This allowed the model to remember the trees which was needed for the next step. The next step was saving the maximum number of fruit flower clusters detected for each specific tree. By keeping track of the trees and its corresponding cluster detections, the number of clusters per tree can be collected.