# GBCNet: In-Field Grape Berries Counting for Yield Estimation by Dilated CNNs
## 4 Results and Discussion  
As explained in Section 1, we explore two different strategies for yield estimation using deep learning. The former, based on Equation (2), has images taken at small distances with only one grape bunch on focus, while the latter considers panoramic images collected from a distance of 1-2 m that potentially can capture a wide portion of the field (in the order of thousands of berries). In the first case, the majority of the image pixels consist of berries, while in the panoramic view the fraction of image containing background is much larger. We present here berries counting performances of GBCNet on the two datasets CR1 and CR2 as a test of the feasibility of the two approaches. By applying five-fold cross validation on CR1, an average number of 2671 berries was selected for each fold and 3653 berries were used for testing. Results on CR2 are reported using three-fold cross validation, for an average number of 6207 berries per fold. In all the experiments we employed the Adam optimizer [55], setting the initial learning rate as \(10^{-5}\) and \(10^{-4}\) for CR1 and CR2 respectively, dropping the learning rate by an order of magnitude every 50 epochs. Considering the small amount of images of the two datasets, we froze the feature extraction layers (i.e., the first ten VGG-16 layers) and updated only the dilated CNN layer weights for density map generation. With this approach, all the training processes converged in less than 200 epochs, and we evaluated the performances of GBCNet using the weights of the last training epoch. Finally,the number of patches for each iteration (i.e., the batch size) was set to 20 for CR1 and 4 for CR2, given the memory restrictions on the machine used for training and the larger size of CR2 images. For each patch there are an average of 71 berries for CR1 and 427 berries for CR2. In Table 4, the results for GBCNet on CR1 are presented both for 5-CV and test. We report both the error per image and the overall error. The latter is important in the assumption of having a unique grape bunch in the picture and being interested in the average number of berries per bunch: considering the full dataset helps averaging the over/under-estimation of the network on the single images. It is quite impressive to observe the drop in the percentage error when considering the whole dataset from 10% to less than 1% in test, showing the importance of averaging on many pictures. While the error on single image predictions is similar to the CR2 one, the overall MAE suggests that GBCNet reaches better performances with close-up images. An interesting aspect of the network behavior occurs when having a single cluster on focus in the CR1 dataset. In fact, due to the closeness of the camera to the main photographed cluster, bunches in the background are out of focus. Since only the foremost clusters were labeled in CR1 images, the network automatically learns to ignore background berries and considers only those present in the foreground. The probable learning mechanism employed by the network is to use features like sharpness and sizes of berry edges as discriminant (Figure 4). However, there are cases in which GBCNet highlights green background regions as berry. This effect, which leads to an overestimation error, is associated with patterns affected by a high local variability in brightness and contrast, as shown in Figure 5. \begin{table}
\begin{tabular}{c c r r r r} \hline \hline  & & \(n\) & **MAE** & **MAE (\%)** & **MSE** \\ \hline \multirow{2}{*}{5-CV} & Per Image & 20.4 & 13.66 \(\pm\) 4.70 & 11.16\% \(\pm\) 2.70\% & 18.33 \(\pm\) 6.33 \\  & Overall & 2670.6 & 56.48 \(\pm\) 60.08 & 2.13\% \(\pm\) 1.97\% & \\ \hline \multirow{2}{*}{Test} & Per Image & 26 & 13.25 & 10.32\% & 16.07 \\  & Overall & 3653 & 10.65 & 0.29\% & \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Application of GBCNet on CR1 5-CV and test sets. The \(n\) column refers to the average number of images and berries per fold and in the test set.