## 3 Materials and Methods
### Training and Evaluating SSD Models  
The state-of-the-art has many frameworks for training and using deep learning algorithms [57; 58; 59; 60; 61]. However, TensorFlow [59], Darknet [60] and PyTorch [61] are the most known and used frameworks. Once we determined that our robot would use a TPU to detect tomatoes in the greenhouse, it needed a trained TensorFlow model. TensorFlow [59] is a machine learning system that operates at a large scale and in heterogeneous environments. It is easily scalable and allows researchers and engineers to experiment with and test new ML algorithms. Therefore, TensorFlow supports a large variety of ML algorithms, focusing mainly on DL. TensorFlow is distributed as an open-source framework belonging to Google. It can run in a large variety of applications and devices as a centralised or distributed system. During the development of the current evaluation of different models, only TensorFlow 1 had fully compatible tools to train and compile the models to the TPU. Therefore, the training and inference scripts used TensorFlow r1.15.0. Both scripts run in Google Colaboratory (Colab) notebooks (see [[http://colab.research.google.com](http://colab.research.google.com)]([http://colab.research.google.com](http://colab.research.google.com))) that offer free powerful GPU's and TPU's to train and infer deep learning models. The available GPUs varied each time we initialised a Colab session, but in this case, the NVIDIA Tesla T4 with a VRAM of 12 GB and 7.5 computation capability was the attributed GPU for all sessions. For benchmarking purposes, we considered four pre-trained SSD models from the TensorFlow database (see [[https://github.com/tensorflow/models/blob/master/research/object_detection/g3](https://github.com/tensorflow/models/blob/master/research/object_detection/g3) doc/tf1_detection_zoo.md]([https://github.com/tensorflow/models/blob/master/research/object_detection/g3](https://github.com/tensorflow/models/blob/master/research/object_detection/g3) doc/tf1_detection_zoo.md)): SSD MobileNet v2, SSD Inception v2, SSD ResNet 50, and SSD ResNet 101 (see Appendix A, Table A1, for the location of the different models); and the YOLOv4 Tiny model. The first three models and YOLOv4 Tiny were previously pre-trained using the COCO dataset, and SSD ResNet 101 was pre-trained using OID. For fine-tuning the pre-trained models, we considered the default values of the pre-training pipeline, adjusting the batch size for the capacity of the available GPU, according to Table 3. All training sessions ran for 50,000 epochs, and an evaluation session occurred at every 50 epochs. The experiments with the different models proved that they did not need more than 50,000 epoch to converge to the best solution in the solution space. In some cases, the models converged after 30,000 epochs. The evaluation session at every 50 epochs followed the standard value used by the pre-trained models. These evaluation \begin{table}
\begin{tabular}{c c} \hline \hline
**Transformation** & **Value** \\ \hline Rotation & \(-60^{\circ}\) to \(60^{\circ}\) \\ Scaling & 50 \% to 150 \% \\ Translation & 0 \% to 30 \% left or right \\ Flip & Image mirroring \\ Blur (Gaussian Filter) & \(\mathcal{N}(0,1\) to \(3)\) \\ Gaussian Noise & \(\mathcal{N}(0,0.03\cdot 255\) to \(0.07\cdot 255)\) \\ Combination3 & Random combination of three of the previous transformations with random values \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Transformations applied to the images of the split dataset for data augmentation and the characteristics of those transformations. sessions allowed monitoring the evolution of the training. If the evaluation loss started to increase while the training loss decreased or remained constant, the deep learning model was over-fit to the training data. This situation did not happen to any trained networks. YOLOv4 Tiny is not available for the TensorFlow framework, but is for the Darknet framework. The YOLOv4 Tiny model learned faster and only needed 2500 epochs for the training session.