## 2 Materials and Methods
The final step was to generate extra images from the original dataset using common augmentation techniques. The process begun with the bounding boxes defined by 9 anchors that limit the area and the aspect ratio of the object. In order to stablish the bounding box priors, clustering of k-means was used on the dataset, using the Euclidean distance metric as the algorithm for clustering. The idea behind k-means is that the data come from the k precise center plus certain noise in the Gaussian form. The algorithm initially selects k points (randomly) for centroid candidates, and then assigns every data point to their nearest cluster centroids. After that, the centroids are recalculated on the formed clusters after each iteration. This process of assigning and evaluating the centroids is repeated until the centroids are finally stabilized, or when a limit of iterations is reached. At last, the ultimate anchor size corresponds to the center of the polygon formed by the 9 clusters. This methodology helps alleviating the learning challenge for the model and improves the model's ability to detect bounding boxes. For the context of identifying mussel larvae in their three primary stages (40, 100, and 180 ), the images have to be obtained at a specific zoom factor, according to the zoom the model was trained; consequently, no change of scale was needed. The input image is divided into grids of P \(\times\) P, where the objects are to be detected and their bounding boxes need to be centered. Once divided in grids, the neural network generates the maps, extracting the features from each division. After that, the Feature Piramid Network [32] employs upsampling of the output feature maps and subsequently concatenates them with the output from the preceding convolutional layer. The next step consists of a layer of attention, to focus the network on the key features for every channel. If we call \(F_{in}\) the \(a\times p\) dimensions of the convolution layer with \(n\) channels, then the feature \(\mathbf{f_{i}}\) of channel number \(l\), having \(l\) in [1,..., n], will be \(F_{in}\) = {\(\mathbf{f_{i}}\), \(\mathbf{f_{2}}\),..., \(\mathbf{f_{i}}\)}. In every convolution, a squeeze operation is performed on \(F_{in}\) through the \(a\times p\) dimensions, generating global features \(\mathbf{r}\in R^{n}\), encoding the features on each channel. Consequently, dimension feature number \(i\) can be calculated as follows:  
\[r_{i}=F_{e}(f_{i})=\frac{1}{a\times p}\sum_{i=1}^{a}\sum_{j=9}^{p}\mathbf{f_{i }}(\mathbf{i},\mathbf{j}) \tag{3}\]  
From there on, the excitation was conducted on the global features. In order to capture the non-linear relation among the individual channels, we employed a straightforward gating method with an activation sigmoid function. \[act=F_{e}(z,p)=\sigma(p_{2}(\tau p_{1}r)) \tag{4}\]  
\(\sigma\) is the Rectifier Linear Unit; \(p_{1}\) represents the weight of the first fully connected layer that performs a compression in the parameters of the channels; \(p_{2}\) denotes the weight of the second fully connected layer, to restore back the number of channels; and finally, the sigmoid function is represented by \(\tau\). At last, we propose the following:  
\[\widetilde{\mathbf{f}_{i}}=F_{es}(\mathbf{f_{i}},\;\mathbf{y_{i}})=\mathbf{f_ {i}}\cdot\text{act}_{d} \tag{5}\]  
Which is the scaling function, where the \(\mathbf{y_{i}}\) parameter is a scalar that multiplies the feature of the d channel and obtains the output of this block of layers as \(\{\widetilde{\mathbf{f}_{1}},\widetilde{\mathbf{f}_{2}},\ldots,\widetilde{ \mathbf{f}_{n}}\}\) for every channel. As in the YOLO function, the function that evaluates the total loss can be calculated as the sum of the losses of each step (classification loss, Confidence loss, and bounding box loss).