# Deep Learning-Based Method for Accurate Real-Time Seed Detection in Glass Bottle Manufacturing
## 3 Materials and Methods
### Proposed SW Solution: The Image Algorithm
#### 3.3.3 Deep Learning-Based Classification Model  
Although the candidate selection is quite good in clean glass, it can be improved. It was identified that a certain percentage of grease stains and other types of irregularities, such as the seal or joint of the bottle, become the cause of false positives. These types of elements often have an appearance very similar to that of a seed (see Figure 6), and after an analysis at the pixel level and considering shape of the clusters of pixels in a blob, the algorithms are not always able to filter them successfully. As a result, a bottle with abundant grease stains can erroneously increase the count of seeds and blisters detected, especially in the large category, which masks the true measurement in these cases. This last stage of the proposed method is based on supervised deep learning techniques. In this way, the model will be able to learn the precise morphological characteristics of a bubble, a stain or a joint, and generalize this classification for situations of uncertainty that take place during the inspection. These artificial intelligence technologies allow a detailed analysis of the scene, so that the processing grows in complexity and the algorithms are capable of contextualizing the features extracted from the image, similar to how the brain does. The idea for the classification model is to receive all the candidates detected in an image in the previous stage and to act as the final element responsible for filtering out everything that is not a seed in glass. For the development of the deep learning-based classification model, the following steps were followed. First, the dataset was carefully reviewed to make sure the annotated images fit in the assigned category. Images with the \"doubftul\" label are removed from the dataset. Next, the model is trained with different parameters, and best performing weights are chosen. Finally, the metrics for the test subset are obtained. The detailed methodology is as follows. Dataset for Deep Learning Model  
The images collected to train a deep learning model is known as a dataset, and it is, in fact, one of the most critical tasks, since it contains the information that will be transferred to the model. It can be said that, regardless of the complexity of the developed software, the quality of the final classification is strongly dependent on the quality of the examples shown to the model during training. In this case it is a supervised training process, which means that all the images used in the training process were previously annotated, and there was an output associated to an input. The number of images used in a dataset depends on several factors, such as the number of classes, the homogeneity or heterogeneity of the classes that are intended to  
Figure 6: Examples of grease stains in the bottle. be discriminated, or the complexity of the architecture of the network used for training. In addition, it can be stated that an excess of similar images, or the use of unbalanced image sets (in terms of the number of images for each type of class) can cause unexpected behavior in the classification, so that a model with outstanding metrics in training may not be able to generalize when exposed to previously unseen examples. The dataset to develop the model proposed in this paper was gathered from manufacturing lines of three sites of Vidrala, sites in Castell and in Aiala--Liodio, both placed in Spain, and another site in Elton, UK. The dataset contains around 1500 images that were acquired with the Line Scan camera used in the system. This dataset was used to tackle the different stages in the processing algorithm. On the one hand, the full image was used for the bottle detection algorithm and candidate selection, and full validation of the system. On the other hand, the ad hoc dataset for the generation of the deep learning-based model was also created. The dataset for the deep learning-based model contains two classes (or sets) of images, identified as \"seed\" and \"non-seed\".