## 2 Materials and Methods
The loss produced in the classification step can be obtained using categorical cross entropy, as given by the following:  
\[L_{cl}=-\sum_{x=0}^{P^{2}}B_{xy}^{m}\sum_{g~{}in~{}classes}[\widehat{Prob_{xy}}Ln \big{(}Prob_{xy}\big{)}+(1-\widehat{Prob_{xy}})Ln\big{(}1-Prob_{xy}\big{)}] \tag{6}\]  
where \(B_{xy}^{m}\) denotes the y box preceding in the x grid cell (P \(\times\) P grid); in case that preceding bounding box can predict the location of the target bounding box, \(B_{xy}^{m}\) will be 1, and zero in other case. \(\widehat{Prob_{xy}}\) represents the estimation of the probability that the larva belongs to class g, and \(Prob_{xy}\) is the label of the ground truth. The loss originated by the Confidence function has been selected as a modification of focal loss [33], which addresses the class imbalance by reshaping the standard cross entropy loss such that it down-weights the loss assigned to well-classified examples [33]; their strategy focuses training on a sparse set of hard examples and prevents the vast number of easy negatives from overwhelming the detector during training [34]. In our case, no weight was used to address the scale issue since the dataset and the samples were obtained using a specific zoom to handle the different sizes of the mussels in their growth; consequently, the proposed equation is as follows:  
\[L_{co}=-\sum_{x=0}^{P^{2}}\sum_{y=0}^{C}\Big{[}\beta\big{(}1-C_{xy}\big{)}^{ \delta}\widehat{C_{xy}}Ln(\widehat{C_{xy}})+(1-\beta)C_{xy}^{\delta}\Big{(}1- \widehat{C_{xy}}\Big{)} \tag{7}\]  
where \(\widehat{C_{xy}}\) stands for the prediction of the Confidence, and \(C_{xy}\) is the Confidence of the ground truth box. The values of \(\beta\) and \(\delta\) were obtained during the tests, with values of 0.75 and 2, respectively. Finally, the loss of the localization of the bounding box prediction is given by MSE (Mean Squared Method), which quantifies the difference between the coordinates of the predicted bounding box and the coordinates of the ground truth bounding box. The operation is performed separately for the coordinates of the center of each bounding box and for the size of each bounding (for every bounding box found in the image). Using MSE, the average squared difference between the parameters of the bounding boxes (predicted and ground truth) can be estimated, using not only the accuracy of the location but also the accuracy of the size; minimizing this MSE value during the training step, the prediction mussel locations of the model is improved [35]. The dataset was also augmented in order to mitigate overfitting, by using two different mechanisms; the idea is to enhance the model's generalization capacity by using a greater quantity of images (since manual data collection and annotation involves an important amount of effort, we expanded the dataset). The first data augmentation technique used was CutMix [36]. This technique, instead of just deleting pixels, substitutes the erased areas with small patches sourced from other images. At the same time, the ground truth labels are adjusted in proportion to the cumulative pixel count of the merged images. This methodology allows us to avoid pixels with little to no information during training, thereby improving training efficiency, while still keeping the benefits of regional dropout. Moreover, the introduced patches augment the model's localization ability by necessitating the identification of objects from partial perspectives [36]. In this research, CutMix provided different contexts that improved our generalization capabilities, minimized overfitting, and worked as a regularizer; it provided identification even when the larvae were under other ones, and reduced the time to create the dataset database. The second data augmentation technique used was a rotation of the image. The rationale is the same: the number of images available for training is limited, so it is interesting to use data augmentation techniques to increase the number of images we have.