FBHA-Yolov8-based detection method for Atlantic salmon in industrial aquaculture
By introducing the C2f-FastBlock module, a hybrid attention converter and Inner-ShapeIoU loss function in the Yolov8 network, the problem of high complexity, slow speed and frequent false detection in factory farming environments is solved, and high-precision and high-efficiency target detection are achieved.
Patent Information
- Application Number
- CN202510289559.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-12
- Publication Date
- 2025-04-29
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing underwater object detection algorithms have problems such as high model complexity, slow inference speed, frequent false detection and error detection in factory farming environments, which are difficult to meet the real-time detection needs.
A detection method based on FBHA-Yolov8 is proposed. By introducing the C2f-FastBlock module, a hybrid attention converter and Inner-ShapeIoU loss function in the Yolov8 network, the detection accuracy and speed of the model are improved, and false detection and false detection are reduced.
It improves the accuracy and speed of target detection in factory farming environments, accurately divides overlapping fish, reduces the occurrence of false detection and mis-testing, and is suitable for real-time detection needs.
Smart Images

Figure CN119904739A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of aquaculture and the field of computer vision, and in particular to a method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8. Background Art
[0002] In recent years, the proportion of marine fishing has continued to rise, and the output of aquaculture has also continued to increase to reduce fishing pressure. With the continuous expansion of aquaculture and the increase in the cost of manual monitoring, how to quickly and accurately detect and track fish in factory farming to determine the health status of fish has become an important research topic for farmers to control the risk of fish mortality. However, underwater target tracking has not been widely used. One of the main reasons is that the performance of existing detection algorithms is insufficient. In many cases, manual intervention is still required to assist in judgment. Traditional target detection algorithms are difficult to meet the needs of complex underwater farming scenarios in terms of accuracy and real-time performance. With the intelligent development of computer vision, target detection algorithms based on deep learning have made significant progress. Therefore, to promote the development of this field, it is urgent to solve several key problems: enriching factory farming image data sets, improving the accuracy and speed of algorithms, enhancing the robustness of algorithms in complex environments, improving their generalization ability, and reducing the computational complexity of models. These challenges need to be overcome to promote the application of underwater target detection technology.
[0003] Around 2017, researchers began to apply the three popular general target detection models (YOLO family, SSD series and R-CNN family) to fish detection, achieving significantly better results than traditional algorithms. With the establishment of more and more underwater datasets, more and more studies have begun to apply general models to underwater target detection, and have made varying degrees of improvements in backbone networks, neck modules and detection heads. At present, underwater target detection algorithms based on deep learning are divided into single-stage target detection methods and two-stage target detection methods. The two-stage target detection method is better than the single-stage target detection method in terms of accuracy, but the speed is slower. However, these models are highly complex and slow in inference, and cannot meet the requirements of real-time scenarios.
[0004] The above studies have made significant progress in the field of target detection, but there are problems with high model complexity and slow inference speed, which limits the application and practicality in real-time scenarios. In addition, in factory farming environments, poor lighting conditions, high fish density and mutual occlusion often lead to false detection and misdetection. In order to address these challenges, this paper proposes an Atlantic salmon target detection method based on the improved Yolov8 algorithm. The algorithm can improve the accuracy and speed of target detection in factory farming environments, accurately divide overlapping fish schools, and reduce the occurrence of false detection and misdetection. Summary of the invention
[0005] In view of the shortcomings of the prior art, the present invention proposes a detection method for Atlantic salmon in factory farming based on FBHA-Yolov8, which improves the accuracy and speed of model detection through partial convolution, enhancement of local details, understanding of global layout and cross-window information interaction, and solves the problems of false detection and wrong detection.
[0006] In order to solve the above technical problems, the technical solution of the present invention is:
[0007] A method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8, comprising the following steps:
[0008] Step 1: Collect underwater videos of Atlantic salmon, and extract frames from the collected videos to obtain underwater fish school images.
[0009] Step 2: Manually label the images.
[0010] Step 3: Enhance the underwater fish school image data and divide it into a self-built data set.
[0011] Step 4: Configure the training environment.
[0012] Step 5, construct the FBHA-Yolov8 network model. The FBHA-Yolov8 uses Yolov8 as the basic network, designs the C2f-FastBlock module as a new feature extraction module, integrates the hybrid attention transformer (HAttention) into the Yolov8 backbone, and designs and adopts the Inner-ShapeIoU loss function.
[0013] Step 6: Use the self-built dataset to train and verify the FBHA-Yolov8 network model.
[0014] Step 7: Use the underwater Atlantic salmon image to be detected as input for target detection through the pre-trained FBHA-Yolov8 network model.
[0015] Preferably, the underwater video of the Atlantic Ocean is collected by using an underwater motion camera, with the shooting angle in the horizontal direction, the shooting time is recorded between 09:00 and 16:00, the resolution of the camera is 1920×1080 pixels, and the frame rate is 30f / s. The video was collected at Guoxin Dongfang (Yantai) Circulating Water Aquaculture Technology Co., Ltd., which uses land-based circulating water to culture Atlantic salmon. The breeding pond has a diameter of 6.8m and a depth of 2.5m. The average body length is 60cm, the mass is 2.5-3kg, the breeding density is 7 / m3, and the breeding temperature is a constant temperature of 14.5-15.5℃.
[0016] Preferably, the frame extraction is: extracting a picture every 5 frames to obtain 1300 pictures.
[0017] Preferably, the manual labeling is: using LabelImg software to draw a rectangular box on the image to label a single Atlantic salmon, and generate a labeling file for training the target detection model.
[0018] Preferably, the data enhancement includes: translating, rotating, flipping, cropping, changing brightness and Gaussian noise processing on 1,300 pictures, and expanding the data set to 3,900 pictures by generating corresponding annotation files and picture files. The data set is divided into a training set, a validation set and a test set in a ratio of 7:1:2, wherein the training set is 2,730 pictures, the validation set is 390 pictures, and the test set is 780 pictures.
[0019] Preferably, in step 5, all C2f modules in the backbone and neck parts of the original Yolov8 network are replaced with C2f-FastBlock modules.
[0020] In the above technical solution, the C2f-FastBlock module uses the FastNet Block module to replace the DarknetBottleneck module in the C2f module. C2f-FastBlock achieves fast and efficient feature extraction, reduces the amount of calculation and memory access, and improves the model's reasoning speed without sacrificing accuracy, thereby solving the problems of slow reasoning speed and high training difficulty of existing models.
[0021] Preferably, the method for extracting features by the C2f-FastBlock module is:
[0022] First, a 1×1 convolution layer is used to double the number of feature map channels. Then, the input feature map is evenly divided into two parts through the Split function, one part enters the FastNet Block module, and the other part is used for subsequent splicing. The segmented feature map is processed layer by layer in multiple FastNet Block modules to extract deeper features. Finally, a 1×1 convolution layer is used to compress the spliced feature map to obtain the output channel number.
[0023] Preferably, the method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8 is characterized in that the method for extracting features by the hybrid attention transformer is:
[0024] First, a convolutional layer is used to extract shallow features, and then a series of residual hybrid attention groups (RHAGs) and a 3×3 convolutional layer (HConv) are used to extract deep features. Next, a global residual connection is added to fuse the shallow features with the deep features, and then a high-resolution output is generated through the reconstruction module.
[0025] Preferably, the FBHA-Yolov8 network model is designed and adopts the Inner-ShapeIoU loss function, which is composed of the ShapeIoU loss function and the InnerIoU loss function, and its algorithm is as follows:
[0026] L Inner-ShapeIoU =L ShapeIoU +IoU-IoU inner
[0027] Preferably, the method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8 is characterized in that the ShapeIoU algorithm is as follows:
[0028] L Shape-IoU =1-IoU+distance shape +0.5×Ω shape
[0029] Where, distance shape Represents shape deviation, Ω shape stands for aspect ratio loss.
[0030] Preferably, the method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8 is characterized in that the InnerIoU algorithm is as follows:
[0031] L Inner-IoU =1-IoU inner
[0032] In the above technical solution, in order to solve the problem of false detection caused by the high overlap of fish schools in the lightweight model, the present invention designs a new IoU calculation method Inner-ShapeIoU, which is a method that reduces the reliance on external features of the frame (center point, aspect ratio) by matching pixel-level or key point-level shape similarity within the frame, so that the model can pay more attention to the details of the internal area of the target, and directly penalizes the shape difference by introducing the shape similarity within the frame in the IoU calculation, so that the frame fits the actual target better. Inner-ShapeIoU can better solve the limitations of CIoU in complex scenes by incorporating internal shape similarity into the loss function, and is particularly suitable for highly overlapping target detection tasks.
[0033] Preferably, the training method of the FBHA-Yolov8 model is: training on a self-built data set, using SGD (stochastic gradient descent) as the optimization function, 100 epochs as the cycle, the learning rate is set to 0.01, the number of single training samples is 32, the number of threads used by the CPU during data loading is 4, the input image size is 640×640, and after the training is completed, the relevant indicators are recorded and the training weights are saved. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly describe the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can also be obtained based on these drawings without creative work.
[0035] Figure 1 A method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8 provided in an embodiment of the present invention; an overall structural diagram of FBHA-Yolov8;
[0036] Figure 2 for Figure 1 C2f-FastBlock module diagram;
[0037] Figure 3 for Figure 2 FastNet Block module diagram;
[0038] Figure 4 for Figure 3 PConv module diagram;
[0039] Figure 5 for Figure 1 HAttention module diagram;
[0040] Figure 6 Comparison of the model detection results of this embodiment Figure 1 ;
[0041] Figure 7 Comparison of the model detection results of this embodiment Figure 2 ;
[0042] Figure 8 Comparison of the model detection results of this embodiment Figure 3 ;
[0043] Fig. 9 This is a comparison chart of the mAP50 accuracy and FPS model of the model comparison experiment in this embodiment. DETAILED DESCRIPTION
[0044] The following is a clear and complete description of the technical solution of the present invention in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the present invention, not all embodiments. According to the embodiments of the present invention, those skilled in the art can obtain all other embodiments without paying creative work, and these embodiments all belong to the protection scope of the present invention.
[0045] The purpose of the present invention is to solve the above problems and propose a detection method for Atlantic salmon in factory farming based on FBHA-Yolov8.
[0046] Step 1: Collect underwater videos of Atlantic salmon, and extract frames from the collected videos to obtain underwater fish school images.
[0047] Specifically, the data was collected from Guoxin Dongfang (Yantai) Recirculating Aquaculture Technology Co., Ltd., which uses land-based recirculating water to cultivate Atlantic salmon. The diameter of the breeding pond is 6.8m, the depth is 2.5m, the average body length is 60cm, the mass is 2.5-3kg, the breeding density is 7 / m3, and the breeding temperature is a constant temperature of 14.5-15.5℃. The underwater sports camera GoPro HERO12 was used for collection. The shooting angle was horizontal. The shooting time was recorded between 09:00 and 16:00. The camera collection resolution was 1920×1080 pixels and the frame rate was 30f / s. The collected video was extracted at a frequency of one picture every 5 frames to obtain pictures, and the pictures were selected so that the data samples included pictures of Atlantic salmon with overlapping fish schools, different distances, and different lighting conditions. After selection, 1,300 original pictures were obtained. Step 2: Manually annotate the pictures.
[0048] Specifically, LabelImg software was used to draw rectangular boxes on the images to label individual Atlantic salmon, and a labeling file was generated for training the target detection model. 1,300 original images were labeled, and overlapping fish groups were carefully separated and labeled in the PascalVOC format.
[0049] Step 3: Enhance the underwater fish school image data and divide it into a self-built data set.
[0050] Specifically, in order to enhance the generalization performance of the network, 1,300 images were translated, rotated, flipped, cropped, brightness changed, and Gaussian noise processed, and the data set was expanded to 3,900 images by generating corresponding annotation files and image files. The data set was divided into training set, validation set, and test set in a ratio of 7:1:2, with 2,730 images in the training set, 390 images in the validation set, and 780 images in the test set; images and labels folders were created, and train, test, and val folders were created in them respectively. All image paths were counted and written into corresponding txt files, which were train.txt, val.txt, and test.txt. The txt file, image path, and annotation file path together constitute the data set.
[0051] Step 4: Configure the training environment.
[0052] Specifically, create a coco.yml file, specify the path of the coco folder, the paths of train.txt, val.txt and test.txt, and specify the recognized categories. In the training phase, SGD (stochastic gradient descent) is used as the optimization function, 100 epochs are used as the cycle, the learning rate is set to 0.01, the number of single training samples is 32, the number of threads used by the CPU when loading data is 4, and the input image size is 640×640. The experimental environment uses the Linux operating system. The server configuration includes an Intel(R) Xeon(R) CPU E5-2698v4@2.20GHz processor, 250GB memory, and three NVIDIAA100 PCIe graphics cards with 40GB video memory, using the 12.4CUDA driver version. The deep learning framework environment is torch2.1.0+cu121, python3.9.7.
[0053] Step 5: Build the FBHA-Yolov8 network model.
[0054] Specifically, Figure 1 As shown in the figure, the FBHA-Yolov8 network model uses the Yolov8 network as the basic network and consists of three parts: the backbone, the neck and the head. The backbone extracts features from the image through operations such as convolution and pooling to form a feature map. The neck fuses the feature map in a top-down and bottom-up manner to comprehensively utilize feature semantic information at different levels, thereby improving the detection performance. Finally, the final detection result, i.e., target category, location coordinates, confidence and other information, is generated through the detection head of the head.
[0055] Further configuration of this embodiment is as follows: Figure 1 and Figure 2As shown in Figure 1, the C2f modules in the backbone and neck parts of the Yolov8 network are replaced with C2f-FastBlock modules.
[0056] Specifically, the C2f-FastBlock module introduces the FastNet Block module of FastNet. Compared with the original C2f, C2f-FastBlock uses FastNet Block instead of DarknetBottleneck, and only performs necessary calculations to achieve the purpose of fusion features, reducing the computational overhead of the model and making the model more efficient.
[0057] Furthermore, the C2f-FastBlock module reduces redundant calculations and memory accesses, which improves the inference speed while maintaining the high accuracy of the model. The C2f-FastBlock module structure is shown in the attached figure. Figure 2 As shown in the figure, a 1×1 convolution layer is first used to double the number of feature map channels. Then, the input feature map is evenly divided into two parts through the Split function, one part enters the FastNet Block module, and the other part is used for subsequent splicing. The segmented feature map is processed layer by layer in multiple FastNet Block modules to extract deeper features. Finally, a 1×1 convolution layer is used to compress the spliced feature map to obtain the output channel number.
[0058] FasterNet Block consists of a PConv layer and two PWConv (i.e. 1×1Conv) layers, forming an inverted residual block structure. The number of channels in the middle layer is expanded, and the input features are reused through shortcut connections. To maintain feature diversity and reduce latency, normalization and activation layers are only applied after the middle layer. In addition, batch normalization (BatchNormalization, BN) is selected instead of other alternatives. Its advantage is that it can be merged with adjacent convolutional layers to speed up the inference process. For the selection of activation layers, ReLU is used based on operating efficiency and effect.
[0059] Further PConv layers Partial convolution (PConv) perform spatial feature extraction by applying regular convolution operations to only some of the input channels, leaving the other channels unchanged. To achieve continuous or regular memory access, the previous or last The continuous channels are regarded as representatives of the entire feature map for calculation. Under the premise of maintaining generality, it is assumed that the number of channels of the input and output feature maps is the same. Therefore, the flop of PConv can be mathematically expressed as:
[0060]
[0061] When the typical partial ratio is set to When , the FLOPs of PConv is only 1 / 2 of that of ordinary convolution. In addition, PConv also has smaller memory accesses, namely:
[0062]
[0063] That is to say, when When , the FLOPs of PConv is only 1 / 2 of that of ordinary convolution. In addition, PConv's memory access is also smaller, further improving computational efficiency.
[0064] The present invention is further configured as follows: Figure 1 and Figure 5 As shown in Figure 2, the HAttention mechanism is integrated before the 0th convolution layer of the backbone network. The structure of the HAttention module is shown in the attached figure. Figure 5 As shown in the figure. By introducing the HAttention mechanism, the model can effectively improve the performance of single image super-resolution reconstruction by fusing channel attention and self-attention mechanisms. Channel attention focuses on which channels are more important, while self-attention focuses on the relationship between various positions within the image, thereby effectively integrating global pixel information and providing more accurate upsampling results, enabling the model to better reconstruct high-frequency details and improve the quality and accuracy of the reconstructed image.
[0065] The HAttention module consists of three parts: shallow feature extraction, deep feature extraction, and image reconstruction. First, a convolutional layer is used to extract shallow features, and then a series of residual hybrid attention groups (RHAGs) and a 3×3 convolutional layer (HConv) are used to extract deep features. Next, a global residual connection is added to fuse the shallow features with the deep features, and then a reconstruction module is used to generate a high-resolution output. Figure 5 As shown in Figure 1, each RHAG consists of several hybrid attention blocks (HABs), an overlapping cross attention block (OCAB), and a 3×3 convolutional layer with residual connections. The reconstruction module uses the pixel shuffle method to upsample the fused features. Figure 5 As shown in Figure 2, after the first LayerNorm (LN) layer, a channel attention block (CAB) is inserted into the standard Swin Transformer block in parallel with the window-based multi-head self-attention (W-MSA) module to form a HAB module, and the whole process is calculated as
[0066] X N =LN(X),
[0067] X M =(S)W_MSA(X N)+αCAB(X N )+X,
[0068] Y = MLP(LN(X M ))+X M ,
[0069] In the formula, X N and X M represents the intermediate feature, Y represents the output of HAB, and MLP represents the multi-layer perceptron. Given an input feature of size H×W×C, first divide it into M×M The local window of the window, after which self-attention is calculated in each window. The query, key, and value matrices are calculated as Q, K, and V through linear mapping. The formula for calculating the window self-attention mechanism is as follows
[0070]
[0071] Where d represents the query / key dimension, B is the relative position encoding, where a large window size is used to calculate self-attention, a shifted window partitioning method is used, and the shift size is set to half the window size to establish connections between adjacent non-overlapping windows. CAB consists of two standard convolutional layers, one of which is a GELU activation and the other is a channel attention (CA) module, such as Figure 5 As shown in the figure. Since transformer-based structures usually require a large number of channels for token embedding, directly using fixed-width convolutions will incur a large computational cost. Therefore, the number of channels of the two convolutional layers is compressed to a constant β. For input features with C channels, the number of channels of the output features after the first convolution is compressed to C / β, and then the feature is expanded to C channels through the second layer. Next, the standard CA module is used to adaptively readjust the channel features. OCAB is introduced to directly establish cross-window connections to enhance the effective features of the self-attention mechanism, such as Figure 5 As shown, OCAB consists of overlapping criss-cross attention (OCA) layers and MLP layers. OCA uses pixel tokens to calculate the criss-cross attention inside each window feature.
[0072] The present invention is further configured to solve the problem of false detection caused by the high overlap of fish schools in the lightweight model. The present invention designs a new IoU calculation method Inner-ShapeIoU, which is a method that reduces the reliance on the external features of the frame (center point, aspect ratio) by matching pixel-level or key point-level shape similarity within the frame, so that the model can pay more attention to the details of the internal area of the target, and directly penalizes the shape difference by introducing the shape similarity within the frame in the IoU calculation, so that the frame fits the actual target better. Inner-ShapeIoU can better solve the limitations of CIoU in complex scenes by incorporating internal shape similarity into the loss function, and is particularly suitable for highly overlapping target detection tasks.
[0073] The Inner-ShapeIoU algorithm is as follows:
[0074] L Inner-ShapeIoU =1-IoU+distance shape +0.5×Ω shape +IoU-IoU inner
[0075] Where, distance shape Represents shape deviation, Ω shape stands for aspect ratio loss.
[0076] Finally, this embodiment combines the accompanying drawings and data to illustrate the effectiveness of this invention. In order to test the effect of the improved model, the proposed improved modules are added to the Yolov8 model, and the ablation experiment is performed using a self-built data set. The experimental results are shown in Table 1. Compared with the original model, the C2f-FastBlock module formed by using the FastBlock module to improve the C2f module is compared with the original model Yolov8, and the mAP50, mAP50-95, precision, and recall rate are increased by 2.0%, 0.9%, 3.8%, and 0.3%, respectively. At the same time, the frame rate per second (FPS) is increased by 7.26%, the number of parameters is reduced from 3.0×106 to 2.3×106, and the computational complexity is reduced from 8.1 to 6.4, indicating that the module can effectively reduce the number of parameters of the model and make network training easier. By adding the HAttention module before the first convolution layer of the backbone, under the same computational complexity, compared with the original model Yolov8, mAP50, mAP50-95, precision, and recall rate are increased by 1.6%, 1.6%, 2.0%, and 0.2%, respectively. At the same time, the frame rate per second (FPS) is increased by 36.3%, indicating that the model can effectively capture the long-distance dependencies and global information of the target, so as to better extract the features of blurred and occluded areas. Compared with the original model Yolov8, the boundary regression loss function uses Inner-ShapeIoU, and the mAP50, mAP50-95, and precision are increased by 1.7%, 0.8%, and 6.0%, respectively. At the same time, the frame rate per second (FPS) is increased by 7.96%. Compared with the original model Yolov8, the improved algorithm FBHA-Yolov8 proposed in this paper has improved mAP50, mAP50-95, precision, and recall by 2.5%, 1.3%, 4.0%, and 0.1% respectively. At the same time, the frame rate per second (FPS) is increased by 7.9%, and the computational complexity is reduced from 8.1 to 6.4, which proves the effectiveness of the loss function. From the results of the ablation experiment analysis, it can be seen that the algorithm FBHA-Yolov8 proposed in this paper has improved both speed and accuracy while reducing the computational complexity.
[0077] Table 1. Comparison of ablation experiments
[0078]
[0079] In order to verify the effectiveness of the FBHA-Yolov8 model in detecting Atlantic salmon in factory farming, the present invention uses Fast-RCNN, SSD, Yolov3, Yolov4, Yolov5s, and Yolov7 to conduct comparative experiments on the YYSALMON dataset. Fast-RCNN generates potential targets through candidate regions (Region Proposal), and then extracts features through convolutional neural networks. The image blur and detail loss caused by insufficient illumination make it impossible for the features in the candidate region to represent the target well, thereby affecting the subsequent classification and positioning accuracy. SSD performs target detection through convolutional feature maps of different scales, and particularly relies on the spatial information and scale features of the image. However, insufficient illumination can cause the feature information in the image to be lost or blurred, making it difficult to accurately detect targets of different scales. Therefore, it can be seen from the results analysis in the table that the mAP50 and FPS performances of Fast-RCNN and SSD are unsatisfactory. Compared with Yolov3, Yolov4, Yolov5s, and Yolov7 single-stage target detection algorithms, our model has improved mAP50 by 3.1%, 2.8%, 3.2%, and 12.9%, respectively, and mAP50-95 by 1.3%, 1.9%, 3.4%, and 11.6%, respectively. In addition, our model has improved the frame rate per second (FPS) by 32.2%, 42.4%, 19.9%, and 152.8%, respectively, and the FPS has been improved. The computational complexity of our model is reduced by 148.9, 14.4, 9.5, and 98.7, respectively, which shows that our model is easier to train. The experimental results show that compared with the current mainstream algorithms, the FBHA-Yolov8 algorithm has the lowest computational complexity, while improving accuracy and speed, and has higher detection efficiency, making it more suitable for real-time detection of Atlantic salmon in factory farming environments. The model comparison experiment is shown in Table 2 below, and the model comparison line chart is as follows Fig. 9 The comparison of Yolov8 and FBHA-Yolov8 model detection results is as follows Figure 6 , Figure 7 , Figure 8 shown.
[0080] Table 2 Model comparison experiment
[0081]
[0082] In order to demonstrate the effect achieved by the invention, Figure 6-Figure 8 Explanation: Compare the original image, the original model inspection image and the improved model inspection image, as shown in the attached figure. Figure 6 As shown in the figure, the original model missed two detections. The first one was the blurry area on the left, which missed the blurry image caused by insufficient light. The other one was the overlapping area of the fish school, which missed the small target fish in the overlapping area of the fish school. Figure 7As shown in the figure, the original model has multiple missed detections, which is caused by the blurry picture caused by insufficient light underwater. Figure 8 As shown in the figure, the original model had one missed detection and three false detections. The missed detection was caused by the blurry picture caused by insufficient light, and the false detection was caused by the high overlap of fish schools.
[0083] The basic principle of the present invention is to reduce the amount of model parameters, lower the calculation complexity, improve the model detection efficiency and training speed, solve the problems of false detection and missed detection, and improve the model detection accuracy.
[0084] The main features and advantages of the present invention are:
[0085] (1) The C2f-FastBlock module was designed and introduced. It uses efficient residual connections and lightweight convolution operations to enhance feature extraction capabilities, reduce computational overhead, make the model easier to train, and improve model performance while maintaining lightweight.
[0086] (2) The HAttention mechanism is introduced to dynamically allocate weights during the feature extraction process. It combines multi-level feature representation and adaptive weight adjustment to effectively capture the long-distance dependencies and global information of the target, thereby better extracting blurred and occluded feature information.
[0087] (3) The Inner-ShapeIoU loss function is designed and adopted to replace the CIoU loss function in Yolov8, which further improves the detection performance of the model under occlusion and achieves a good balance between speed and accuracy of underwater target detection.
[0088] For those skilled in the art, it should be understood that the present invention is not limited to the embodiments described above. The descriptions in these embodiments and the specification are only examples of the present invention and are not intended to be limiting. Without violating the core concept and protection scope of the present invention, the present invention can be subjected to various changes and improvements according to actual needs. These changes and improvements should all be deemed to be included in the protection scope of the present invention. Ultimately, the protection scope of the present invention will be defined by the attached claims and their equivalents, and is intended to cover all technical solutions that conform to the principles, features and advantages of the present invention.
Claims
1. A method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8, characterized in that: The steps include: Step 1: Collect underwater videos of Atlantic salmon, and extract frames from the collected videos to obtain underwater fish school images; Step 2: Manually label the image; Step 3: Enhance the underwater fish school image data and divide it into a self-built data set; Step 4: Configure the training environment. Step 5, construct the FBHA-Yolov8 network model. The FBHA-Yolov8 uses Yolov8 as the basic network, designs the C2f-FastBlock module as a new feature extraction module, integrates the hybrid attention transformer (HAttention) into the Yolov8 backbone, and designs and adopts the Inner-ShapeIoU loss function; Step 6: Use the self-built data set to train and verify the FBHA-Yolov8 network model; Step 7: Use the FBHA-Yolov8 network model to perform target detection on the underwater Atlantic salmon image to be detected. The water quality prediction method according to claim 1 is characterized in that the large model preprocesses the data; before the time series data is input into the model, the large model is used to preprocess the data, and the large model is used to identify patterns and trends in the time series data, and learn its periodicity, seasonality, trend and other characteristics.
2. The method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8 according to claim 1, characterized in that: The data enhancement is as follows: 1300 images are translated, rotated, flipped, cropped, brightness changed and Gaussian noise processed, and the data set is expanded to 3900 images by generating corresponding annotation files and image files. The data set is divided into training set, validation set and test set in a ratio of 7:1:2, with 2730 images in the training set, 390 images in the validation set and 780 images in the test set.
3. The method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8 according to claim 1, characterized in that: In step 5, all C2f modules in the backbone and neck parts of the original Yolov8 network are replaced with C2f-FastBlock modules.
4. The method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8 according to claim 1, characterized in that: The C2f-FastBlock module uses the FastNet Block module to replace the DarknetBottleneck module in the C2f module.
5. The method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8 according to claim 1, characterized in that: The method for extracting features of the C2f-FastBlock module is: First, a 1×1 convolution layer is used to double the number of feature map channels. Then, the input feature map is evenly divided into two parts through the Split function, one part enters the FastNet Block module, and the other part is used for subsequent splicing. The segmented feature map is processed layer by layer in multiple FastNet Block modules to extract deeper features. Finally, a 1×1 convolution layer is used to compress the spliced feature map to obtain the output channel number.
6. The method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8 according to claim 1, characterized in that: The method of extracting features by the hybrid attention transformer is: First, a convolutional layer is used to extract shallow features, and then a series of residual hybrid attention groups (RHAGs) and a 3×3 convolutional layer (HConv) are used to extract deep features. Next, a global residual connection is added to fuse the shallow features with the deep features, and then a high-resolution output is generated through the reconstruction module.
7. The method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8 according to claim 1, characterized in that: The FBHA-Yolov8 network model is designed and adopts the Inner-ShapeIoU loss function, which is composed of the ShapeIoU loss function and the InnerIoU loss function. The algorithm is as follows: L Inner-ShapeIoU =I ShapeIoU +IoU-IoU inner 。 8. The method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8 according to claim 1, characterized in that: The ShapeIoU algorithm is as follows: L Shape-IoU =1-IoU+distance shape +0.5×Ω shape Where, distance shape Represents shape deviation, Ω shape stands for aspect ratio loss.
9. The method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8 according to claim 1, characterized in that: The InnerIoU algorithm is as follows: L Inner-IoU =1-IoU inner .
10. The method for detecting Atlantic salmon in factory farming based on FBHA-Yolov8 according to claim 1, characterized in that: The training method of the FBHA-Yolov8 model is as follows: training is performed on a self-built data set, using SGD (stochastic gradient descent) as the optimization function, 100 epochs as the cycle, the learning rate is set to 0.01, the number of single training samples is 32, the number of threads used by the CPU during data loading is 4, the input image size is 640×640, and after the training is completed, the relevant indicators are recorded and the training weights are saved.