Fish identification method for industrial aquaculture
By integrating FasterNet and designing a lightweight neck network in the YOLOv9 model, the FasterYOLOv9-Slim model was built, which solved the problems of high hardware requirements, insufficient environmental adaptability, and difficult to balance lightweight and precision in factory-based fish farming, and achieved efficient fish recognition effect.
Patent Information
- Application Number
- CN202411765139.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-04
AI Technical Summary
The existing factory-based fish identification technology has problems such as high hardware requirements, insufficient environmental adaptability, and difficulty in balancing lightweight and accuracy, especially in complex underwater environments with low recognition accuracy and robustness.
A fish recognition method for factory farming is proposed, based on the lightweight fish school target recognition model FasterYOLOv9-Slim, which is a lightweight fish school fusion with FasterNet. By reducing the scale of the backbone network using FasterNet, using high-dimensional detection head pruning, DFA-Neck lightweight neck network is designed to achieve efficient coordination between feature extraction, fusion and detection head output.
The comprehensive performance of the YOLOv9 model has been improved, and the problems of high hardware requirements, insufficient environmental adaptability and difficult to balance lightweight and precision are achieved, so as to achieve efficient fish identification in resource-constrained environments.
Smart Images

Figure CN119723613A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of intelligent identification, and specifically discloses a fish identification method for factory farming.
[0002] Background
[0003] Identification of factory-farmed fish is the key to smart fisheries, and it provides scientific guidance for fish farming monitoring. Deep learning visual technology, especially fish recognition technology that integrates algorithms such as R-CNN and YOLO, has become an important tool for fish farming monitoring due to its advantages of fast, accurate, efficient and contactless batch detection. These technologies overcome the limitations of traditional manual recognition methods in terms of fish damage, cost and efficiency, and achieve high precision, high reliability and real-time performance in intelligent farming monitoring and management. However, most of the existing fish recognition models based on deep learning algorithms require good hardware conditions, but in actual farming environments, computing resources are often limited. Therefore, how to achieve lightweight models so that they can still maintain recognition effects in resource-constrained environments is a problem that must be solved in the process of intelligent farming monitoring.
[0004] The YOLO series of algorithms have been widely used in the field of fish target recognition due to their high accuracy and fast detection. Although the early YOLOv3 model has achieved certain results in underwater video fish recognition, its recognition accuracy has been insufficient with the upgrade of the algorithm. The optimized YOLOv4 and YOLOv5 have significantly improved the recognition accuracy, but the recognition accuracy and robustness of the model are still low in scenes with blurred underwater imaging and texture distortion. To solve these problems, researchers have proposed a variety of improved algorithms, such as SK-Yv5 and DCM-ATM-YOLOOv5, which have made progress in dealing with blurred backgrounds and occlusion phenomena, but have also brought about the problems of increased model size and increased number of parameters, and have high requirements for hardware conditions. In addition, in order to adapt to environments with limited computing resources, researchers have tried a variety of methods to reduce the amount of model calculations, such as using SPPF to replace SPP, or developing lighter models such as YOLOv7-tiny. However, the recognition accuracy of these models under complex conditions such as small targets, blur and occlusion is still insufficient. In addition, lightweight models such as ShuffleNetv2, MobileNetv3, GhostNet, and Repvit also have similar problems. Although the models based on YOLOv8 and FasterNet have achieved a certain balance between accuracy and scale, they are mainly aimed at underwater target detection in wild environments, and their adaptability to aquaculture environments still needs to be improved.
[0005] In summary, the shortcomings of existing technologies in fish identification include: high requirements for hardware conditions, and reduced recognition effect when computing resources are limited; insufficient recognition accuracy and robustness in complex underwater environments, such as blur, occlusion, and too many fish; the process of model lightweighting is often accompanied by the sacrifice of recognition accuracy; lightweight work in different fields requires targeted optimization based on specific tasks and data characteristics, which is too costly. These problems indicate that fish identification technology still needs further development to adapt to diverse breeding environments, improve recognition accuracy, and reduce dependence on hardware conditions. In response to the above-mentioned problems, it is necessary to propose a new fish identification method for factory farming to overcome the problems existing in the existing factory farming fish identification. Summary of the invention
[0006] The present invention proposes a method for identifying fish in factory farming to solve the problems of high hardware requirements, insufficient environmental adaptability, and difficulty in balancing light weight and accuracy in complex water environments in existing factory farming fish identification.
[0007] The present invention provides a method for identifying fish for industrial farming, comprising the following steps:
[0008] S1. Collect fish images under different time periods, different lighting conditions, different water environments and different fish density, pre-process the fish images, construct a fish image dataset, and divide the fish image dataset into a fish image training set, a fish image verification set and a fish image test set in a ratio of 7:2:1;
[0009] S2. Constructing a FasterYOLOv9-Slim model, including: backbone network selection, detection head pruning, FasterRepNCSPELAN4 module optimization and neck network design, to obtain the FasterYOLOv9-Slim model;
[0010] S3. Input the fish image dataset constructed in step S1 into the FasterYOLOv9-Slim model constructed in step S2, and train the FasterYOLOv9-Slim model using the fish image dataset to obtain a trained FasterYOLOv9-Slim model;
[0011] S4. Input the fish image to be detected into the trained FasterYOLOv9-Slim model obtained in step S3, and output fish detection information.
[0012] According to a fish identification method for factory farming in some embodiments of the present application, the preprocessing of the fish image in step S1 includes: expanding the fish image data using an offline geometric data enhancement method of rotation and translation to obtain the fish image data set; wherein,
[0013] The rotating comprises calculating a rotation transformation matrix based on a rotation axis and a preset rotation angle, performing a rotation operation on the fish image, and saving the rotated fish image to the fish image data set;
[0014] The translation includes calculating a translation transformation matrix based on a preset translation direction and a preset offset, performing a translation operation on the fish image, and saving the translated fish image into the fish image data set.
[0015] According to a fish identification method for factory farming in some embodiments of the present application, the backbone network selection in step S2 includes: replacing the Conv convolution in the YOLOv9 model backbone network with a PConv module.
[0016] According to a fish identification method for factory farming in some embodiments of the present application, the PConv module is applied to the front c p Channel and back c p One of the channels.
[0017] According to a fish identification method for factory farming in some embodiments of the present application, the detection head pruning in step S2 includes pruning a high-dimensional detection head of an auxiliary branch and a corresponding high-dimensional detection head in a main branch structure.
[0018] According to a fish identification method for factory farming in some embodiments of the present application, the optimization of the FasterRepNCSPELAN4 module in step S2 includes introducing the PConv module and the FasterNet Block module into the FasterRepNCSPELAN4 module to obtain an optimized FasterRepNCSPELAN4 module.
[0019] According to a fish identification method for factory farming in some embodiments of the present application, the neck network design in step S2 includes:
[0020] Replace the RepNCSPELAN4 module in the neck network of the YOLOv9 model with the optimized FasterRepNCSPELAN4 module;
[0021] Replace the early input structure of the auxiliary branch of the YOLOv9 model from Conv→Conv→RepNCSPELAN4→Adown to DownSimpler→DownSimpler→FasterRepNCSPELAN4→Adown.
[0022] According to a fish identification method for factory farming in some embodiments of the present application,
[0023] The DownSimpler includes: a dilated convolution module with a convolution kernel size of 3x3 and a stride of 2, and a convolution module with a convolution kernel size of 1x1 and a stride of 1;
[0024] The Adown includes: a convolution module with a convolution kernel size of 3x3, a step size of 2, and an edge padding of 1, and a convolution module with a convolution kernel size of 1x1, a step size of 1, and an edge padding of 0.
[0025] According to a fish identification method for factory farming in some embodiments of the present application, step S3 includes:
[0026] S301. Initialize the FasterYOLOv9-Slim model parameters θ;
[0027] S302. Setting the hyper parameters of the FasterYOLOv9-Slim model includes: learning rate η, batch size, and number of iterations;
[0028] S303. For each batch of data, the predicted output as shown in formula (1) is calculated using the initialized parameter θ:
[0029] y'=f(x,θ) (1)
[0030] Wherein, y' represents the predicted output, x represents the input sample data, and f represents the FasterYOLOv9-Slim model;
[0031] S304. Calculate the difference between the predicted output and the true label, i.e., the loss, using the loss function. The loss is shown in formula (2):
[0032]
[0033] In the formula, J(θ) represents the loss, N represents the number of input sample data, and y i represents the true label of the i-th sample data, f(x i ,θ) represents the predicted output of the i-th sample data, and L represents the loss function;
[0034] S305. Calculate the rate of change of the loss in step S304 with respect to the parameter θ to obtain the gradient
[0035] S306. The gradient obtained in step S305 Update model parameters θ;
[0036] S307. Based on the fish image training set and the fish image verification set obtained by dividing the fish image data set in step S1, repeating steps S304-S306 until a preset maximum number of iterations is reached and the performance on the fish image verification set is no longer improved;
[0037] S308. Track the performance on the fish image validation set in steps S301-S307, and save the corresponding optimal model parameter θ when the performance on the fish image validation set no longer improves * , when the validation set loss J(θ) is minimum, record the corresponding weight;
[0038] S309. Using the fish image test set obtained by dividing the fish image data set in step S1 to test the optimal model parameter θ obtained in step S308. * The corresponding FasterYOLOv9-Slim model is used to obtain the trained FasterYOLOv9-Slim model.
[0039] According to a fish identification method for factory farming in some embodiments of the present application, the fish detection information output in step S4 includes: fish species, fish quantity, fish size, fish location, and fish survival status information.
[0040] The present invention proposes a fish identification method for factory farming, which is a lightweight fish target identification model FasterYOLOv9-Slim for factory farming based on YOLOv9 fusion FasterNet. FasterNet is used to reduce the size of the backbone network, high-dimensional detection head pruning is used to reduce the excessive accumulation of interference information in the later stage of the model, and the DFA-Neck lightweight neck network is designed to achieve efficient coordination between feature extraction, fusion, information transmission and detection head output, thereby improving the comprehensive performance of the YOLOv9 model and solving the problems of high hardware requirements, insufficient environmental adaptability, and difficulty in balancing lightweight and accuracy in fish identification due to the overly complex water environment in existing factory farming. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 It is a schematic diagram of the flow of a fish identification method for factory farming of the present invention;
[0042] Figure 2 A schematic diagram of the FasterYOLOv9-Slim structure provided in Example 3 of the present invention;
[0043] Figure 3 A schematic diagram of the structure of the FasterNet Block and PConv modules provided in Example 3 of the present invention;
[0044] Figure 4 A schematic diagram of the pruning and internal structure of the detection head provided in Example 3 of the present invention;
[0045] Figure 5 A schematic diagram comparing the network structures of RepNCSPELAN4 and FasterRepNCSPELAN4 provided in Example 3 of the present invention, wherein (A) is a schematic diagram of the network structure of RepNCSPELAN4, and (B) is a schematic diagram of the network structure of FasterRepNCSPELAN4;
[0046] Figure 6 ADown and DownSimpler network structure schematic diagram provided in Example 3 of the present invention, (A) is the ADown network structure schematic diagram, (B) is the DownSimpler network structure schematic diagram. DETAILED DESCRIPTION
[0047] The following embodiments of the present invention are described in further detail in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0048] Embodiment 1, this embodiment provides a method for identifying fish for factory farming, such as Figure 1 As shown, the following steps are included:
[0049] S1. Collect fish images under different time periods, different lighting conditions, different water environments and different fish density, pre-process the fish images, construct a fish image data set, and divide the fish image data set into a fish image training set, a fish image verification set and a fish image test set according to a ratio of 7:2:1. Preferably, the training set in this embodiment is the data set used for actual learning of the model. Through this data set, the algorithm will try to adjust its internal parameters to minimize the difference between the predicted value and the actual value. In short, the training set is the basis for the model to "learn" how to complete the farmed fish identification task. The verification set is mainly used to evaluate the performance of the model and tune the model parameters or select the best model configuration (such as selecting different features, adjusting hyperparameters, etc.) accordingly. The verification set helps prevent overfitting. By observing the performance changes of the model on the verification set, the developer can decide when to stop training or take other measures to improve the model performance. The test set is mainly used for the evaluation of the real performance of the model after model training and tuning. The test set provides a fair evaluation benchmark to measure the model's predictive ability for new data. It is important to note that, throughout the development process, except for the last step, no adjustments should be made to the model using information from the test set, so that the test results reflect the model's true level of processing of unknown data.
[0050] S2. Construct a FasterYOLOv9-Slim model, including: backbone network selection, detection head pruning, FasterRepNCSPELAN4 module optimization and neck network design to obtain the FasterYOLOv9-Slim model.
[0051] S3. Input the fish image dataset constructed in step S1 into the FasterYOLOv9-Slim model constructed in step S2, train the FasterYOLOv9-Slim model using the fish image dataset, and obtain the trained FasterYOLOv9-Slim model.
[0052] S4. Input the fish image to be detected into the trained FasterYOLOv9-Slim model obtained in step S3, and output fish detection information.
[0053] The fish identification method for factory farming proposed in this embodiment is a lightweight fish school target identification model FasterYOLOv9-Slim for factory farming based on YOLOv9 fusion FasterNet. FasterNet is used to reduce the size of the backbone network, high-dimensional detection head pruning is used to reduce the excessive accumulation of interference information in the later stage of the model, and the DFA-Neck lightweight neck network is designed to achieve efficient coordination between feature extraction, fusion, information transmission and detection head output, thereby improving the comprehensive performance of the YOLOv9 model and providing technical support for lightweight identification of fish schools in factory farming.
[0054] Embodiment 2: This embodiment provides a method for identifying fish for factory farming, comprising the following steps:
[0055] S1. Collect fish images under different time periods, different lighting conditions, different water environments and different fish density, pre-process the fish images, construct a fish image dataset, and divide the fish image dataset into a fish image training set, a fish image verification set and a fish image test set in a ratio of 7:2:1. Preferably, in this embodiment, the pre-processing of fish images includes: expanding the fish image data using an offline geometric data enhancement method of rotation and translation to obtain the fish image dataset; wherein the rotation includes calculating a rotation transformation matrix based on a rotation axis and a preset rotation angle, rotating the fish image, and saving the rotated fish image to the fish image dataset; the translation includes calculating a translation transformation matrix based on a preset translation direction and a preset offset, translating the fish image, and saving the translated fish image to the fish image dataset.
[0056] Preferably, in this embodiment, rotation refers to rotating the image around a certain center point (usually the geometric center of the image) by a certain angle, which can be clockwise or counterclockwise. The fish image rotation operation includes: determining the rotation center: usually selecting the center of the image; setting the rotation angle: selecting a rotation angle as needed, according to actual needs, such as 30 degrees, 45 degrees, etc.; calculating the rotation matrix: based on the selected angle and rotation center, calculate the transformation matrix required for rotation; applying the transformation: using the transformation matrix to rotate the original image. In this process, you may need to consider how to deal with the problem that part of the image exceeds the original boundary due to rotation. Common processing methods include cropping the excess part or filling the blank area with color (such as black); saving the result: saving the rotated image as a new file.
[0057] Translation refers to moving the entire image a certain distance horizontally or vertically. This transformation does not change the size and shape of the image, but only changes the position of the image. The fish image translation operation includes: Determine the offset: specify the displacement of the image along the X-axis (horizontal direction) and the Y-axis (vertical direction). These values can be positive (move right / downward) or negative (move left / upward); Create a transformation matrix: Construct a translation transformation matrix containing the required offset; Apply transformation: Use the transformation matrix to translate the original image. During the translation process, you need to pay attention to handling edge problems. For example, when a part of the image is moved out of the picture, you can choose to crop this part or fill it to keep the image size unchanged; Save the result: Save the translated image as a new training sample.
[0058] S2. Construct a FasterYOLOv9-Slim model, including: backbone network selection, detection head pruning, FasterRepNCSPELAN4 module optimization and neck network design to obtain the FasterYOLOv9-Slim model.
[0059] Preferably, the backbone network selection in this embodiment includes: replacing the Conv convolution in the YOLOv9 model backbone network with a PConv module, and applying the PConv module to the front c p Channel and back c p One of the channels.
[0060] Preferably, in this embodiment, the detection head pruning includes pruning a high-dimensional detection head of the auxiliary branch and a corresponding high-dimensional detection head in the main branch structure. The optimization of the FasterRepNCSPELAN4 module includes introducing a PConv module and a FasterNet Block module in the FasterRepNCSPELAN4 module to obtain an optimized FasterRepNCSPELAN4 module. The FasterRepNCSPELAN4 module has made many improvements to the original RepNCSPELAN4 in design to improve computational efficiency and reduce the amount of parameters while maintaining or even improving model performance. Specifically, in the initialization phase, FasterRepNCSPELAN4 uses PConv to replace the traditional 3x3 convolution layer, and introduces a new FasterNet Block to replace the original structure. PConv is a partial convolution or a convolution operation optimized for a specific task, which can process feature maps more efficiently, reduce unnecessary calculations and better retain local feature information; while FasterNet Block further reduces computational complexity and the number of parameters by integrating efficient residual connections and other optimization mechanisms, such as layer scaling. During the forward propagation, the input is also divided into two halves, but the difference is that half of the feature maps are processed by RepNCSP and PConv instead of the original RepNCSP and 3x3 convolution; the other half is processed by FasterNet Block, which replaces the original processing method. Finally, all processed feature maps are merged through torch.cat and the final convolution operation is performed. These changes not only enable the entire module to process data faster during the forward propagation process, but also reduce the demand for GPU memory, allowing larger batch sizes to be used for training, thereby speeding up the training process. In addition, by adopting more advanced feature fusion and enhancement techniques, FasterRepNCSPELAN4 not only improves the running speed of the model, but also enhances its adaptability and robustness under inputs of different scales, ensuring high performance while lightweighting the network. In short, these improvements aim to find a better balance between network performance and computational efficiency, making the model more suitable for real-time applications and deployment in resource-constrained environments.
[0061] Preferably, the neck network design in this embodiment includes: replacing the RepNCSPELAN4 module in the neck network of the YOLOv9 model with the optimized FasterRepNCSPELAN4 module. The early input structure of the auxiliary branch of the YOLOv9 model is replaced from Conv→Conv→RepNCSPELAN4→Adown to DownSimpler→DownSimpler→FasterRepNCSPELAN4→Adown. In the YOLOv9 model, the original structure consists of a series of layers, using two consecutive standard convolutional layers for feature extraction, and the RepNCSPELAN4 module further enhances the feature representation capability, and finally reduces the spatial dimension of the feature map through an adaptive downsampling layer. In order to simplify the network and speed up the calculation process, this embodiment replaces the above structure with DownSimpler→DownSimpler→FasterRepNCSPELAN4→Adown, where the DownSimpler layer is a lightweight and efficient downsampling method, which not only performs feature extraction, but also reduces the spatial resolution, thereby replacing the original two standard convolutional layers. FasterRepNCSPELAN4 is an improved version of RepNCSPELAN4, which aims to retain the original functions while improving the processing speed. Finally, the adaptive downsampling layer is still used to complete the spatial dimension reduction of the feature map. Among them, DownSimpler includes: a dilated convolution module with a convolution kernel size of 3x3 and a stride of 2, and a convolution module with a convolution kernel size of 1x1 and a stride of 1. Adown includes: a convolution module with a convolution kernel size of 3x3, a stride of 2, and an edge padding of 1, and a convolution module with a convolution kernel size of 1x1, a stride of 1, and an edge padding of 0.
[0062] S3. Input the fish image dataset constructed in step S1 into the FasterYOLOv9-Slim model constructed in step S2, and train the FasterYOLOv9-Slim model using the fish image dataset to obtain the trained FasterYOLOv9-Slim model. Preferably, the present embodiment includes the following steps:
[0063] S301. Initialize the FasterYOLOv9-Slim model parameters θ.
[0064] S302. Setting the hyper parameters of the FasterYOLOv9-Slim model includes: learning rate η, batch size, and number of iterations.
[0065] S303. For each batch of data, the predicted output as shown in formula (1) is calculated using the initialized parameter θ:
[0066] y'=f(x,θ) (1)
[0067] Wherein, y' represents the predicted output, x represents the input sample data, and f represents the FasterYOLOv9-Slim model.
[0068] S304. Calculate the difference between the predicted output and the true label, i.e., the loss, using the loss function. The loss is shown in formula (2):
[0069]
[0070] In the formula, J(θ) represents the loss, N represents the number of input sample data, and y i represents the true label of the i-th sample data, f(x i ,θ) represents the predicted output of the i-th sample data, and L represents the loss function.
[0071] S305. Calculate the rate of change of the loss in step S304 with respect to the parameter θ to obtain the gradient
[0072] S306. The gradient obtained in step S305 Update the model parameters θ.
[0073] S307. Based on the fish image training set and the fish image verification set obtained by dividing the fish image data set in step S1, steps S304-S306 are repeated until a preset maximum number of iterations is reached and the performance on the fish image verification set is no longer improved.
[0074] S308. Track the performance on the fish image validation set in steps S301-S307, and save the corresponding optimal model parameter θ when the performance on the fish image validation set no longer improves * , when the validation set loss J(θ) is minimized, record the corresponding weight.
[0075] S309. Using the fish image test set obtained by dividing the fish image data set in step S1 to test the optimal model parameter θ obtained in step S308. * The corresponding FasterYOLOv9-Slim model is used to obtain the trained FasterYOLOv9-Slim model.
[0076] S4. Input the fish image to be detected into the trained FasterYOLOv9-Slim model obtained in step S3, and output fish detection information. Preferably, the fish detection information in this embodiment includes: fish species, fish quantity, fish size, fish location, and fish survival status information.
[0077] The fish identification method for factory farming proposed in this embodiment is based on FasterYOLOv9-Slim, a lightweight fish school target identification model for factory farming that combines YOLOv9 with FasterNet. It can realize fast and efficient identification of farmed fish schools in a good identification environment, and provides technical support for lightweight identification of fish school targets in factory farming.
[0078] Embodiment 3: This embodiment provides a method for identifying fish for factory farming, comprising the following steps:
[0079] S1. Collect fish images under different time periods, different lighting conditions, different water environments and different fish density, pre-process the fish images, and construct a fish image data set. Preferably, in this embodiment, to ensure the authenticity and effectiveness of the method, the data set is collected from the real factory breeding workshop-Dalian Tianzheng Industrial Co., Ltd. Daheishi Red Fin Oriental Puffer Breeding Workshop, which contains a total of 2000 images of red fin Oriental puffer fish schools in a breeding environment with a resolution of 1920×1080. In order to fully reflect the real state of the red fin Oriental puffer fish school under the breeding environment, the collected data images cover the breeding red fin Oriental puffer fish schools under different time periods, different lighting conditions, different water environments and different fish density. It can be seen from the data example that in a real breeding environment, the fish school density is very large and there will be a phenomenon of aggregation and overlap, and the water quality will also affect the visual effect. At the same time, the humid fish breeding plant cannot deploy high-performance hardware, which requires the model to not only extract the key features of fish of different sizes in a complex breeding environment under a limited scale, but also exclude the interference information in the environment to achieve high-precision and rapid recognition. In order to ensure the original characteristics of the data and make reasonable model optimization, only the offline geometric data enhancement method of rotation and translation is needed to expand the data to a certain extent. At the same time, to ensure the validity of the results, a random division strategy of 7:2:1 is adopted for the fish image training set: fish image verification set: fish image test set.
[0080] S2. Construct a FasterYOLOv9-Slim model, including: backbone network selection, detection head pruning, FasterRepNCSPELAN4 module optimization and neck network design, to obtain a FasterYOLOv9-Slim model. Preferably, in this embodiment, FasterYOLOv9-Slim is based on the improvement of YOLOv9 and FasterNet for the data characteristics under factory farming conditions, and the model structure is as follows Figure 2As shown in the figure, the model is divided into four parts: input end, backbone network, neck network and head network. The input end is responsible for processing the fish data after offline data enhancement. The Silence module here facilitates the auxiliary branch to call the original image input to the network. It does not perform any calculations itself, and the output is completely consistent with the input, which can well preserve the original data characteristics of the fish school. The backbone network uses the FasterNet structure for feature extraction. FasterNet adopts a series of efficient architecture designs. While maintaining high accuracy and strong feature extraction capabilities, it achieves efficient calculation and model lightweight, reduces the huge amount of parameters and calculations brought by traditional convolution in the YOLOv9 backbone network, and extracts the key features of the fish body while reducing feature redundancy. The neck network fuses the low-level and high-level features extracted by the backbone network to obtain features with high details, high semantics and positioning information, and fuses the improved feature fusion module FasterRepNC SPELAN4 and two excellent downsampling modules, ADown and DownSimper, redesign the neck fusion network to achieve more effective multi-scale feature fusion on feature maps at different levels to adapt to the constant changes in fish density and size, better complete the fusion of key features, and further enhance the accuracy and real-time performance of model recognition; the head network processes the fused multi-scale features to complete the regression of the bounding box and the classification of categories. However, compared with the original backbone network of YOLOv9, lightweight backbone networks such as FasterNet have weakened feature expression capabilities when dealing with complex environments. By pruning a pair of high-dimensional detection heads, the influence of excessive accumulation of interference information from the aquaculture environment extracted by the model in the later stage due to the weakened feature expression ability on the recognition accuracy is weakened, thereby ultimately achieving accurate and rapid recognition of farmed fish under low computing power.
[0081] Preferably, the backbone network selection in this embodiment includes: replacing the Conv convolution in the YOLOv9 model backbone network with a PConv module. Compared with the Conv (Convolution) convolution operation in the original YOLOv9 backbone network, the PConv (Partial Convolution) used in the FasterNet basic feature extraction module FasterNet Block applies convolution operations to some channels of the input feature map, leaving other channels unchanged, effectively reducing computational redundancy. The design of FasterNet adopts a four-stage structure, with FasterNet Block stacked in each stage. This multi-stage structure can gradually extract features of different scales and enhance the model's ability to recognize multi-scale targets in farmed fish schools, such as Figure 3As shown in the FasterNet Block section, these blocks use activation (ReLU) and normalization (Norm) in the intermediate convolutional layer, and use residual connection structure in the entire block. The activation and normalization of the intermediate convolutional layer help improve the expressiveness of features, while the residual connection helps to transfer information and gradients more smoothly, thereby improving the overall performance and robustness of the model and better adapting to the changing breeding environment. PConv only uses the residual connection in some channels (c p ) is applied, and the calculation method is as follows Figure 3 As shown in the Partial Convolution (PConv) section, PConv is applied to the first c to ensure continuous or regular memory access. p or after c p On the channel, the number of floating point operations (FLOPs) of the module is only 1 / 2 of the conventional convolution. It effectively solves the problem of excessive model calculation caused by redundant feature map information and greatly improves the calculation efficiency of the model.
[0082] Preferably, in this embodiment, the detection head pruning includes pruning a high-dimensional detection head of the auxiliary branch and a corresponding high-dimensional detection head in the main branch structure. In order to reduce the excessive accumulation of interference information caused by the increase in the number of network layers, and further reduce the amount of model calculation and model size. Figure 4 As shown in the figure, the detection heads in the purple dotted part, i.e., a pair of high-dimensional detection heads corresponding to the auxiliary branch and the main branch structure, are pruned to reduce the network depth to reduce the interference caused by the accumulation of interference information in the later stage of calculation on the recognition result. At the same time, considering that the Head structure contains two branches, reg (regression branch) and cls (classification branch), and the feature map size remains unchanged during calculation and only the number of channels is changed, the target recognition task can be efficiently performed while ensuring the consistency of spatial position information, which not only ensures the accurate operation of the reg branch and the cls branch on the same position feature, but also reduces unnecessary calculations and improves the calculation efficiency of the model; in addition, the two branches share the convolutional layer to extract common features, and then optimize them for specific tasks through different branches, which can realize the effective reuse of fish body features and maintain the lightweight and high performance of the model. Therefore, when pruning, only the pair of detection heads with the highest dimension are pruned, and the other two pairs of detection heads with appropriate dimensions are retained, so that the accuracy and speed balance of the farmed fish identification model can be achieved while reducing interference.
[0083] Preferably, in this embodiment, the optimization of the FasterRepNCSPELAN4 module includes introducing the PConv module and the FasterNet Block module into the FasterRepNCSPELAN4 module to obtain the optimized FasterRepNCSPELAN4 module. The introduction of the lightweight backbone network and the pruning of the detection head realize the reasonable lightweighting of the model for the factory-farmed fish identification task with limited computing resources, but it also puts higher requirements on the neck fusion network. The neck network faces more complex tasks. It needs to efficiently fuse feature maps from different levels when the backbone network's feature expression ability is weakened, and enhance these features to make up for the information loss caused by the simplification of the backbone network. At the same time, it must ensure that the computational efficiency is not reduced, and can quickly adapt to inputs of different sizes and maintain performance stability. This requires the neck network to not only have powerful feature fusion and enhancement capabilities, but also to use lightweight modules and advanced mechanisms to ensure that it can process features efficiently while maintaining its lightweight. Figure 5 As shown in the figure, the feature fusion module FasterRepNCSPELAN4 is redesigned, and PConv and FasterNet Block modules are introduced into the original feature fusion module RepNCSPELAN4. PConv can retain more local information when processing feature maps, helping the neck network to better capture and maintain the details of fish features in a changing environment, while reducing unnecessary calculations and improving computing efficiency, which means faster reasoning speed and lower resource consumption for resource-constrained breeding plants; the residual connection and layer scaling in FasterNet Block can effectively enhance the feature representation, ensuring that the performance of the model can be maintained or even improved under lightweight design; the adaptability of the neck network to fish feature inputs of different scales is improved, and the expression of features is enhanced, ensuring that the key features of the fish are efficiently processed while maintaining lightweight, achieving a good balance between high performance and low latency.
[0084] Preferably, the neck network design in this embodiment includes: replacing the RepNCSPELAN4 module in the neck network of the YOLOv9 model with the optimized FasterRepNCSPELAN4 module. Replacing the early input structure of the auxiliary branch of the YOLOv9 model from Conv→Conv→RepNCSPELAN4→Adown with DownSimpler→DownSimpler→FasterRepNCSPELAN4→Adown. Figure 6As shown in the figure, p=1 means the number of padding is 1, d=3 means the use of dilated convolution, k=3 means the size of the convolution kernel is 3x3, and s=2 means the stride is 2. Compared with traditional Conv, DownSimpler and ADown can effectively capture the multi-scale features of the input data while reducing the spatial resolution by combining maximum pooling, average pooling and convolution kernels of different sizes, thereby enhancing the model's ability to capture different feature patterns. Therefore, the new structural model combines the structural advantages of DownSimpler, FasterRepNCSPELAN4 and ADown modules to ensure the effective transmission of the original feature information of the fish school data, and can significantly reduce the required computing resources while ensuring or even improving the performance of the model, speed up the model's operation, and greatly improve the overall efficiency and lightweight of the model.
[0085] S3. Input the fish image dataset constructed in step S1 into the FasterYOLOv9-Slim model constructed in step S2, train the FasterYOLOv9-Slim model using the fish image dataset, and obtain the trained FasterYOLOv9-Slim model.
[0086] S4. Input the fish image to be detected into the trained FasterYOLOv9-Slim model obtained in step S3, and output the fish detection information.
[0087] Preferably, this embodiment builds an experimental platform to train and evaluate the fish identification method for factory farming. All experiments of this method are based on the 11th Gen Core TM The test was conducted on a Windows 10 Professional computer with an i7-11700K CPU and an RTX 3090 GPU. The pre-trained YOLOv9 was used as the baseline model, with the batch size set to 8 and the number of epochs set to 300.
[0088] In order to comprehensively reflect the performance of all aspects of the model, the model evaluation uses average precision (AP), number of floating-point operations (FLOPs), number of parameters, inference speed and frames per second (FPS) as performance evaluation indicators.
[0089] The average precision is the integral of the PR curve, which reflects the detection ability of the model. Its calculation formula is:
[0090]
[0091] Among them, A AP represents the average precision, R represents the recall rate, and P(R) represents the precision at different recall levels.
[0092] FLOPs is usually used to measure the computational complexity of a model. It is the total number of floating point operations in the computational model. The calculation of FLOPs involves various operations in the model, such as multiplication, addition, etc. For a given convolutional layer, FLOPs can be estimated by the following formula:
[0093] FLOPs = H × W × C in ×C out ×K×K (2)
[0094] Among them, FLOPs represents the total number of floating-point operations, H×W represents the size of the input feature map, and C in Indicates the number of input channels, C out represents the number of output channels, and K×K represents the size of the convolution kernel.
[0095] It is usually stipulated that each element multiplication and subsequent accumulation is regarded as a floating-point operation. However, in practice, multiplication and addition are sometimes calculated separately, so the specific calculation method may be different. The above formula assumes that techniques such as grouped convolution or depth-separable convolution are not used, which will change the actual FLOPs calculation method. The actual FLOPs calculation also needs to consider other factors, such as activation functions, normalization layers, etc. The above formula is mainly used to represent the main computational cost of a convolutional layer. For the entire network of this method, the FLOPs parameter can be directly output through the model's built-in tools.
[0096] The number of parameters refers to the total number of all learnable parameters in the model, including weights and biases. The number of parameters is usually calculated by directly counting the number of parameters in each layer of the model; the inference speed refers to the speed at which the model makes predictions. These two parameters can also be directly output by the model's built-in tools.
[0097] Frames Per Second (FPS) is often used to measure the performance of a model when performing real-time reasoning or processing video streams. The higher the FPS, the faster the model processes data, which is crucial for real-time applications and lightweight model performance evaluation. It represents the number of image frames processed in one second, and its calculation formula is:
[0098]
[0099] Among them, FPS means the number of frames transmitted per second, and Processing time per frame means the processing time per frame.
[0100] In order to verify the effectiveness of the improvement, the following ablation test was designed: the backbone network of the YOLOv9 model was replaced, the detection head was pruned, and the neck network was improved. All experiments used the same dataset and performed the same rounds of model training and testing. The results are shown in Table 1. Notes in the table: DFA-Neck represents the neck network optimized by DownSimpler, FasterRepNCSPELAN4, and ADown modules, HDPrune represents high-dimensional detection head pruning, Indicates the ranking of the results from high to low. Analysis of the data in Table 1 shows that the introduction of the backbone network FasterNet, high-dimensional detection head pruning HDPrune and neck network optimization DFA-Neck have played a significant role in improving the amount of calculation, the amount of parameters and the speed of inference respectively. The improvements of DFA-Neck and HDPrune have improved the recognition accuracy while reducing the parameters and the amount of calculation, which shows the effectiveness of the improvement. Among them, the test results that include both FasterNet and HDPrune improvements are "abnormal" - the average accuracy is only 4.574%, indicating that the original neck network design does not fully integrate the features extracted by FasterNet, and will lead to incoordination between feature extraction, information transmission and detection head functions. It further reflects the key role and optimization effectiveness of the neck network DFA-Neck optimized based on DownSimpler, FasterRepNCSPELAN4, and ADown modules. Therefore, only by combining the three improved YOLOv9s of FasterNet, DFA-Neck and HDPrune can efficient coordination between feature extraction fusion, information transmission and detection head output be achieved to achieve a balance between model accuracy and model lightweight, and obtain the optimal effect of comprehensive performance, that is, while maintaining the optimal amount of calculation and parameter quantity, the accuracy, inference speed and FPS can maintain the minimum loss within a range of less than 1%, meeting the recognition needs under factory farming conditions.
[0101] Table 1 Impact of FasterNet, HDPrune and DFA-Neck improvements on YOLOv9 model performance
[0102]
[0103] In order to verify the effectiveness of FasterYOLOv9-Slim in this field, a comparative test was conducted with advanced real-time recognition lightweight models. The comparison models are: YOLOv10, YOLOv8, and YOLOv7 lightweight recognition models of the same scale. At the same time, the effectiveness of different advanced lightweight networks in improving this field was compared. All models participating in the comparative test used the same data set and set the same training parameters. According to the analysis of the test results in Table 2, the FasterYOLOv9-Slim model keeps the number of parameters to a minimum while the accuracy, computational complexity, inference speed, and FPS fluctuate within the range of 1%-2%, and the data meets the requirements of accuracy and speed for factory-farmed fish identification, achieving the best comprehensive performance. The advanced real-time recognition models in the YOLO series have good results in general tasks, but for the problems studied in this field, a single YOLO series model or a single advanced lightweight model FasterNet cannot balance the model accuracy and model scale well. When integrating the advantages of the two types of models to solve problems in the field, simple backbone network fusion cannot achieve ideal results. It is necessary to analyze specific problems in the field and reasonably design the model structure to achieve the optimization of the fusion of the advantages of the two types of models. In summary, the structural design of the FasterYOLOv9-Slim model is more suitable for lightweight farmed fish target recognition tasks.
[0104] Table 2 Performance comparison between different models and FasterYOLOv9-Slim
[0105]
[0106]
[0107] Compared with the existing fish target recognition tasks, the difficulty of this method lies in the fact that under the specific conditions of the factory farming environment, the best balance between model accuracy and lightweight must be achieved. To solve the above problems, through reasonable model structure design, the real-time performance of YOLOv9 and the lightweight of FasterNet are integrated to achieve the best balance between model accuracy and scale in the factory farming environment. Verification found that FasterYOLOv9-Slim has a similar recognition accuracy and faster reasoning speed when compared with YOLOv9 in identifying fish in complex farming environments. This shows that the structural design of FasterYOLOv9-Slim can well adapt to the factory farming fish identification environment with limited computing and network resources, and realize the rapid identification of farmed fish targets under conditions of few parameters and small scale.
[0108] The embodiments of the present invention are given for the purpose of illustration and description, and are not intended to be exhaustive or to limit the invention to the disclosed forms. Many modifications and variations will be apparent to those of ordinary skill in the art. The embodiments are selected and described in order to better illustrate the principles and practical applications of the present invention and to enable those of ordinary skill in the art to understand the present invention and thereby design various embodiments with various modifications suitable for specific uses.
Claims
1. A fish identification method for factory farming, characterized in that: The steps include: S1. Collect fish images under different time periods, different lighting conditions, different water environments and different fish density, pre-process the fish images, construct a fish image dataset, and divide the fish image dataset into a fish image training set, a fish image verification set and a fish image test set in a ratio of 7:2:1; S2. Constructing a FasterYOLOv9-Slim model, including: backbone network selection, detection head pruning, FasterRepNCSPELAN4 module optimization and neck network design, to obtain the FasterYOLOv9-Slim model; S3. Input the fish image dataset constructed in step S1 into the FasterYOLOv9-Slim model constructed in step S2, and train the FasterYOLOv9-Slim model using the fish image dataset to obtain a trained FasterYOLOv9-Slim model; S4. Input the fish image to be detected into the trained FasterYOLOv9-Slim model obtained in step S3, and output fish detection information.
2. A method for identifying fish for factory farming according to claim 1, characterized in that: The preprocessing of the fish image in step S1 includes: expanding the fish image data using an offline geometric data enhancement method of rotation and translation to obtain the fish image data set; wherein, The rotating comprises calculating a rotation transformation matrix based on a rotation axis and a preset rotation angle, performing a rotation operation on the fish image, and saving the rotated fish image to the fish image data set; The translation includes calculating a translation transformation matrix based on a preset translation direction and a preset offset, performing a translation operation on the fish image, and saving the translated fish image into the fish image data set.
3. The method for identifying fish for factory farming according to claim 2, characterized in that: The backbone network selection in step S2 includes: replacing the Conv convolution in the YOLOv9 model backbone network with a PConv module.
4. The method for identifying fish for factory farming according to claim 3, characterized in that: The PConv module is applied to the front c p Channel and back c p One of the channels.
5. The method for identifying fish for factory farming according to claim 4, characterized in that: The detection head pruning in step S2 includes pruning a high-dimensional detection head of the auxiliary branch and a corresponding high-dimensional detection head in the main branch structure.
6. The method for identifying fish for factory farming according to claim 5, characterized in that: The optimization of the FasterRepNCSPELAN4 module in step S2 includes introducing the PConv module and the FasterNet Block module into the FasterRepNCSPELAN4 module to obtain an optimized FasterRepNCSPELAN4 module.
7. The method for identifying fish for factory farming according to claim 6, characterized in that: The neck network design in step S2 includes: Replace the RepNCSPELAN4 module in the neck network of the YOLOv9 model with the optimized FasterRepNCSPELAN4 module; Replace the early input structure of the auxiliary branch of the YOLOv9 model from Conv→Conv→RepNCSPELAN4→Adown to DownSimpler→DownSimpler→FasterRepNCSPELAN4→Adown.
8. The method for identifying fish for factory farming according to claim 7, characterized in that: The DownSimpler includes: a dilated convolution module with a convolution kernel size of 3x3 and a stride of 2, and a convolution module with a convolution kernel size of 1x1 and a stride of 1; The Adown includes: a convolution module with a convolution kernel size of 3x3, a step size of 2, and an edge padding of 1, and a convolution module with a convolution kernel size of 1x1, a step size of 1, and an edge padding of 0.
9. The method for identifying fish for factory farming according to claim 8, characterized in that: The step S3 comprises: S301. Initialize the FasterYOLOv9-Slim model parameters θ; S302. Setting the hyper parameters of the FasterYOLOv9-Slim model includes: learning rate η, batch size, and number of iterations; S303. For each batch of data, the predicted output as shown in formula (1) is calculated using the initialized parameter θ: y'=f(x,θ)(1)wherein y' represents the predicted output, x represents the input sample data, and f represents the FasterYOLOv9-Slim model; S304. Calculate the difference between the predicted output and the true label, i.e., the loss, using the loss function. The loss is shown in formula (2): In the formula, J(θ) represents the loss, N represents the number of input sample data, and y i represents the true label of the i-th sample data, f(x i ,θ) represents the predicted output of the i-th sample data, and L represents the loss function; S305. Calculate the rate of change of the loss in step S304 with respect to the parameter θ to obtain the gradient S306. The gradient obtained in step S305 Update model parameters θ; S307. Based on the fish image training set and the fish image verification set obtained by dividing the fish image data set in step S1, repeating steps S304-S306 until a preset maximum number of iterations is reached and the performance on the fish image verification set is no longer improved; S308. Track the performance on the fish image validation set in steps S301-S307, and save the corresponding optimal model parameter θ when the performance on the fish image validation set no longer improves * , when the validation set loss J(θ) is minimum, record the corresponding weight; S309. Using the fish image test set obtained by dividing the fish image data set in step S1 to test the optimal model parameter θ obtained in step S308. * The corresponding FasterYOLOv9-Slim model is used to obtain the trained FasterYOLOv9-Slim model.
10. The method for identifying fish for factory farming according to claim 1, characterized in that: The fish detection information outputted in step S4 includes: fish species, fish quantity, fish size, fish location, and fish survival status information.
Citation Information
Patent Citations
Method for detecting positions of fish target individuals in cultured fish shoal based on improved YOLOv8 model
CN117058232A
Fish target individual position detection method based on improved YOLOv7 model
CN117237986A
Fish abnormal behavior detection method based on improved YOLOv9 model
CN118762395A
Cited By
Fish polyculture judgment method based on lightweight multi-task image recognition network and knowledge graph
CN120259802A
Fish polyculture judgment method based on lightweight multi-task image recognition network and knowledge graph
CN120259802B
Multi-mode fish school feeding intensity detection method, system, equipment, medium and product
CN120408384A
Pattern recognition method based on adaptive target enhancement and contrast learning framework
CN121686178A