## 3 Materials and Methods
Loss Function and Optimizer Selection
* Loss Function and Optimizer: A suitable loss function for object detection, such as focal loss, was selected, taking into account the issue of class imbalance. Model Training and Fine-tuning
* Training and Fine-tuning: The model was trained and fine-tuned by monitoring the loss function and evaluation metrics. Model Evaluation
* Evaluation: The model's performance was evaluated using overall accuracy, class-specific accuracy (for male and female fish), error rates, and processing time. These simplified evaluation methods allow for a quick assessment of the model's performance in real-world aquaculture scenarios. YOLO Loss Function  
The YOLO loss function is a composite loss function consisting of multiple components, including bounding box loss, object loss, non-object loss, and classification loss. Each part of the loss function measures the difference between the model's predictions and the ground truth. The purpose of this loss function design is not only to accurately locate the target object's position but also to ensure that the model can accurately classify the object. This comprehensive approach ensures that the model is well prepared to handle the challenges of real-world scenarios, such as varying lighting conditions and the presence of environmental noise, while maintaining high accuracy in the gender identification of fish. \[\text{L}=\lambda_{\text{coord}}\times\text{L}_{\text{box}}+\lambda_{\text{ obj}}\times\text{L}_{\text{obj}}+\lambda_{\text{noobj}}\times\text{L}_{\text{ noobj}}+\lambda_{\text{class}}\times\text{L}_{\text{class}} \tag{1}\]  
Variable Descriptions:  
L: total loss;  
L: box: bounding box loss;  
L: obj: object loss;  
L: noobj: non-object loss;  
L: class: classification loss;  
\(\lambda_{\text{coord}}\), \(\lambda_{\text{obj}}\), \(\lambda_{\text{noobj}}\), \(\lambda_{\text{class}}\): weight coefficients for each component. Cosine Annealing learning rate scheduling is a learning rate adjustment strategy used to gradually decrease the learning rate during the training process. The core idea is to allow the learning rate to follow a cosine curve throughout training, starting with a higher learning rate at the beginning and gradually reducing it as training progresses, eventually converging to a smaller value. This approach helps prevent premature convergence, enabling the model to better explore the parameter space during training, thereby achieving improved performance. \[\eta_{\text{t}}=\eta_{\text{min}}+0.5\times(\eta_{\text{max}}-\eta_{\text{ min}})\times(1+\text{cos}(\text{t}\times\pi/\text  
When evaluating a model, especially in specific application scenarios, using simple and intuitive evaluation methods can more directly reflect the model's performance. Simplified evaluation methods include calculating overall accuracy, class-specific accuracy, error rate, and processing time. These indicators allow for a quick assessment of the model's basic performance and its effectiveness in real-world applications without the need for more complex statistical analysis tools. These methods are particularly suitable for rapid and effective performance evaluation when actual samples are available. Since this study involves real-world aquaculture fish data for validation, a simplified evaluation approach is adopted.  
Overall Accuracy \[\text{Accuracy}=\text{(Number of correctly classified fish)}/\text{(Total number of fish)}\] (3)  
Class-Specific Accuracy  
Male Fish Accuracy = (Number of correctly classified male fish)/(Total number of male fish) (4)  
Female Fish Accuracy = (Number of correctly classified female fish)/(Total number of female fish) (5)  
Error Rate = (Number of incorrectly classified fish)/(Total number of fish) (6)  
In this study, we chose the YOLO model primarily due to its advantages in scenarios requiring real-time processing, offering fast inference speed alongside high accuracy.