A fish counting method based on density map regression

By constructing U-Fish network and using image enhancement methods, the problem of water surface reflection and fish submersion in fish population counting is solved, which improves counting accuracy and reduces the computational complexity.

CN119380379BActive Publication Date: 2025-03-14SICHUAN AGRI UNIV
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411946125.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-03-14
Estimated Expiration
2044-12-27

AI Technical Summary

Technical Problem

The existing fish school counting methods have problems such as water surface reflection, fish school overlap, model details loss and large model parameters, resulting in low counting accuracy and high calculation complexity.

Method used

The fish population counting method based on density map regression is adopted, and the U-Fish network architecture is constructed, and the detailed information is retained using jump connection and attention mechanisms, combined with the lightweight Ghost module to reduce the amount of parameters, and the image enhancement method is used to optimize image quality.

Benefits of technology

Effectively overcome the influence of water surface reflection and fish overlap, improve counting accuracy, and reduce model calculation complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119380379B_ABST
    Figure CN119380379B_ABST
Patent Text Reader

Abstract

The present invention discloses a fish counting method based on density map regression, comprising the following steps: step S1: constructing a fish data set of different densities; step S2: constructing a U-Fish network architecture; step S3: constructing a U-Fish loss function; step S4: optimizing the image quality by using an image enhancement method, and mixing the original image with the enhanced image to train the constructed U-Fish model, and obtaining a fish counting model after the training; step S5: inputting the image to be detected and its corresponding enhanced image into the trained fish counting model, and the model outputs a density map and a counting result. The present invention can effectively overcome the influence of water surface reflection and fish overlap, improve the counting accuracy, and reduce the complexity of model calculation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of fishery counting, and in particular to a fish school counting method based on density map regression. Background Art

[0002] The production mode of aquaculture has changed from extensive to intensive, the production structure has been continuously adjusted and upgraded, and the production level has been continuously improved. In fish farming, regular asset inventory, fish survival rate assessment, and stocking density control all require the counting of fish. Traditional fish counting methods mostly use manual counting methods such as weighing and screening, which are not only costly and inefficient, but also cause certain damage to the fish. In recent years, deep learning has attracted widespread attention from researchers for its efficient computing power and powerful automatic feature extraction capabilities. Counting based on deep learning has been widely used in many fields, such as crowd counting, livestock breeding counting, forest counting, cell counting, mosquito counting, and shrimp seedling counting. Using deep learning methods to count fish can not only improve the counting efficiency of fish, save time and financial costs, but also ensure the normal activities of individual fish and avoid stress damage to the fish.

[0003] At present, relevant researchers in the counting field have designed some methods to replace the traditional manual counting method. For example, Publication No. CN116452473A discloses a new sturgeon counting and positioning method. This method uses the fluorescent markers carried by sturgeons as a breakthrough point. Through image processing algorithms such as histogram equalization, circle detection and contour detection, it overcomes practical problems such as water surface reflection and fish school occlusion, and realizes the automatic counting of sturgeons in aquaculture scenarios. Compared with deep learning, this solution saves labeling costs, but this solution requires the fish to carry fluorescent markers, which is inconsistent with most real aquaculture scenarios; Publication No. CN118429892A discloses A method for counting duck flocks based on a density map of fused deep semantic features and spatial channel attention solves the problem of low accuracy in counting duck flocks in the prior art. It can accurately count duck flocks in the presence of mutual occlusion, complex backgrounds, and perspective effects. However, counting fish flocks is different from counting duck flocks. The situation in the water is complex, and the influence of light will cause reflections and other problems. Publication No. CN118097262A discloses a VGG-CD network bait counting method and system based on density map regression, which solves the problems of complex models and large computational complexity in existing small target recognition methods. Unlike static bait counting, fish The school of fish swims dynamically, which may cause the collected images to appear blurred; Publication No. CN117953361A discloses a method for robust counting of small underwater fish targets based on density maps, which uses low-resolution dense fish sonar images containing strong noise interference combined with the VGG19 model to achieve accurate and stable counting of fish schools, solving the problem that the existing counting methods have too many interference factors, making it difficult to distinguish fish from the background, and the free movement of fish causes the underwater images to have different shapes, distortion, blur, occlusion and overlap. However, this solution is aimed at sonar images and is more suitable for marine scenes, and this solution does not target fish. The model is further optimized based on the characteristics of the group image; Publication No. CN113240650A discloses a fry counting system and counting method based on deep learning density map regression, which combines the fry counting model of deep learning density map regression with embedded devices, can well solve the adhesion problem and ensure the accurate counting results. The scheme extracts more comprehensive information through a multi-scale method to improve the detection accuracy of the model, and achieves good results in speed and accuracy, but the scheme does not take into account the situation of densely stacked fry; The existing fish counting methods have problems such as water surface reflection, fish overlap, loss of model details and large number of model parameters. Summary of the invention

[0004] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a fish counting method based on density map regression, which can effectively overcome the influence of water surface reflection and fish overlap, improve counting accuracy and reduce the complexity of model calculation.

[0005] The object of the present invention is achieved through the following technical scheme: a fish counting method based on density map regression, comprising the following steps:

[0006] Step S1: constructing fish school data sets of different densities;

[0007] Step S2: construct U-Fish network architecture;

[0008] Step S3: construct U-Fish loss function;

[0009] Step S4: Use image enhancement methods to optimize image quality, and mix the original image with the enhanced image to train the constructed U-Fish model, and obtain a fish counting model after the training;

[0010] Step S5: Input the image to be detected and its corresponding enhanced image into the trained fish counting model, and the model outputs a density map and counting results.

[0011] Furthermore, the step S1 of constructing a fish school dataset of different densities includes the following steps:

[0012] Step S101: Collecting overhead images of fish schools of different densities;

[0013] Step S102: using open source labeling software CCLabeler to label the fish position data in the image;

[0014] Step S103: Based on the position data, a Gaussian kernel function is applied to generate a continuous density distribution map;

[0015] Step S104: integrating the data set to ensure a one-to-one mapping relationship between the fish school image, location data and density map;

[0016] Step S105: construct a fish density map count data set, and divide the integrated data set into a training set, a validation set, and a test set.

[0017] Furthermore, the U-Fish described in step S2 adopts a U-shaped structure, and uses jump connections to effectively integrate the feature map in the encoder with the corresponding layer in the decoder. This design helps to retain more detailed information, thereby improving the quality of density map generation and enhancing the accuracy of counting. In the encoder part, a lightweight Ghost module is used to replace the traditional convolution, effectively reducing the number of parameters of the model. The encoder reduces the width and height of the image to 1 / 8 of the original size through three downsampling operations. In the decoder part, an attention mechanism is introduced, and the SE module is used to weight the integrated shallow and deep features on the channel, and then two convolutions are used to further extract features, which strengthens the network's ability to capture shallow detail features and deepens the network's understanding of deep semantic information, thereby effectively improving the network's ability to integrate information, so as to effectively overcome the impact of fish school overlap and avoid detail loss. The decoder performs three upsampling operations to ensure that the output density map is consistent with the original image size.

[0018] The U-Fish network includes modules 1 to 8, where modules 1 to 4 are encoders and modules 5 to 8 are decoders. Modules 5 to 7 include SE modules, which recalibrate the relationship between channels through the attention mechanism and enhance the network's ability to recognize and utilize features.

[0019] The U-Fish network processes the input image as follows:

[0020] The input image passes through module 1: Conv module, Conv module to obtain feature i1;

[0021] Feature i1 passes through module 2: 2x2 maximum pooling module, Ghost module, and Ghost module to obtain feature i2;

[0022] Feature i2 passes through module 3: 2x2 maximum pooling module, Ghost module, and Ghost module to obtain feature i3;

[0023] Feature i3 passes through module 4: 2x2 maximum pooling module, Ghost module, Ghost module, 2x2 transposed convolution module to obtain feature i4;

[0024] Feature i4 and feature i3 pass through module 5: Concat module, SE module, Conv module, Conv module, 2x2 transposed convolution module to obtain feature o3. Feature i4 and feature i3 are concatenated in the channel direction through the Concat module to obtain feature i3', and then feature i3' passes through the SE module, two Conv modules and 2x2 transposed convolution module in sequence to obtain feature o3;

[0025] Feature o3 and feature i2 are passed through module 6: Concat module, SE module, Conv module, Conv module, 2x2 transposed convolution module to obtain feature o2. Feature o3 and feature i2 are concatenated in the channel direction through the Concat module to obtain feature i2', and then feature i2' is passed through the SE module, two Conv modules and 2x2 transposed convolution module in sequence to obtain feature o2;

[0026] Feature o2 and feature i1 pass through module 7: Concat module, SE module, Conv module, Conv module, 2x2 transposed convolution module to obtain feature o1. Feature o2 and feature i1 are concatenated in the channel direction through the Concat module to obtain feature i1', and then feature i1' passes through the SE module, two Conv modules and 2x2 transposed convolution module in sequence to obtain feature o1;

[0027] Feature o1 passes through module 8: a convolution module with a 1×1 convolution kernel to obtain a density map.

[0028] The Ghost module is a lightweight module, which is lighter than ordinary convolution, so the complexity of the U-Fish network can be effectively reduced;

[0029] Furthermore, the U-Fish loss function described in step S3 includes:

[0030] Euclidean distance loss, multi-scale density level consistency loss, and structural similarity loss.

[0031] The Euclidean distance loss formula is as follows:

[0032]

[0033] in, is the number of images in a batch, is the training image The estimated density map of . yes The actual density map of .

[0034] The multi-scale density level consistency loss formula is as follows:

[0035]

[0036] in, is the number of images in a batch, is the number of scale levels used for consistency checking, is the average pooling operation, is the training image The estimated density map of is the specified output size for average pooling, For training images The true density map of

[0037] The structural similarity loss function is as follows:

[0038]

[0039]

[0040]

[0041] SSIM, or structural similarity, is an indicator used to evaluate the similarity between two images. The closer the SSIM value is to 1, the more similar the two images are. is the training image The estimated density map of , yes The actual density map of and They are and The mean of and They are and The variance of for and The covariance between . is the number of images in a batch. and It is a small constant to prevent the denominator from being 0;

[0042] The overall loss function formula is as follows:

[0043]

[0044] in , is the balance coefficient, Take 0.1, Take 0.01. Based on this loss function, the trained U-Fish model can effectively improve the counting accuracy.

[0045] Furthermore, the image quality is optimized by using the image enhancement method described in step S4, and the original image is mixed with the enhanced image to train the constructed U-Fish model. The characteristics are as follows: in the model training stage, a random image enhancement strategy is adopted: with equal probability, the original image is used in half of the cases, and the image enhanced by CLAHE is used in the other half of the cases for training, which can overcome the influence of water surface reflection. The training details include:

[0046] During the training process of the U-Fish model, the Adam optimizer and learning rate decay strategy were used to improve the training efficiency. The model was iterated multiple times on the training set, and the optimal weights were selected by the mean absolute error on the validation set. To enhance the generalization ability of the model, all training images were subjected to a unified data preprocessing step, including random cropping and random flipping. Random cropping allows the model to adapt to inputs of different sizes, supports multi-batch training, and can more comprehensively cover different areas of the image by dynamically cropping in each iteration. The cropped images are then randomly flipped to further increase the diversity of the data, thereby improving the robustness of the model. Finally, in multiple iterations, the weight with the smallest mean absolute error on the validation set is selected as the weight of the fish counting model.

[0047] Furthermore, step S5 specifically includes the following steps:

[0048] Step S501: Use CLAHE to enhance the image;

[0049] Step S502: input the original image and the image enhanced by CLAHE into the trained model together;

[0050] Step S503: the model outputs density maps corresponding to the original image and the enhanced image respectively;

[0051] Step S504: Integrate the density map to obtain a counting result;

[0052] Step S505: taking the average of the counting result of the original image and the counting result of the enhanced image as the final counting number.

[0053] The beneficial effects of the present invention are as follows: the present invention can effectively overcome the influence of water surface reflection and fish school overlap, improve counting accuracy, and reduce the complexity of model calculation. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 It is a flow chart of the present invention.

[0055] Figure 2 This is the U-Fish network structure diagram.

[0056] Figure 3This is the Ghost lightweight module diagram.

[0057] Figure 4 Diagram of the SE attention module. DETAILED DESCRIPTION

[0058] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings, but the protection scope of the present invention is not limited to the following.

[0059] like Figure 1 As shown, a fish counting method based on density map regression includes:

[0060] Step S1: constructing fish school data sets of different densities;

[0061] Step S2: construct U-Fish network architecture;

[0062] Step S3: construct U-Fish loss function;

[0063] Step S4: using image enhancement methods to optimize image quality, and mixing the original image with the enhanced image to train the constructed U-Fish model;

[0064] Step S5: Input the image to be detected and its corresponding enhanced image into the trained fish counting model, and the model will output the density map and counting results

[0065] Furthermore, the construction of the fish counting data set described in step S1 includes the following steps:

[0066] Step S101: Collecting overhead images of fish schools of different densities;

[0067] Step S102: using open source labeling software CCLabeler to label the fish position data in the image;

[0068] Step S103: Based on the position data, a Gaussian kernel function is applied to generate a continuous density distribution map;

[0069] Step S104: integrating the data set to ensure a one-to-one mapping relationship between the fish school image, location data and density map;

[0070] Step S105: construct a fish density map count data set, and divide the integrated data set into a training set, a validation set, and a test set.

[0071] It should be noted that the position of the school of fish described in step S102 can be expressed as:

[0072]

[0073] in, For each fish target's position coordinates, is the impulse function.

[0074] It should be noted that, in step S103, in order to make the density map correspond to the number of fry, a density map is generated based on a geometric adaptive Gaussian kernel function, and the relationship of the density map F is as follows:

[0075]

[0076]

[0077] in For each target, the corresponding Gaussian distribution is For each fish body, Equal to the closest The mean distance to the targets.

[0078] Furthermore, if Figure 2 , the U-Fish network architecture described in step S2 adopts a U-shaped structure, and uses jump connections to effectively integrate the feature map in the encoder with the corresponding layer in the decoder. This design helps to retain more detailed information, thereby improving the quality of density map generation and enhancing the accuracy of counting. In the encoder part, a lightweight Ghost module is used to replace the traditional convolution, which effectively reduces the number of parameters of the model. The encoder reduces the width and height of the image to 1 / 8 of the original size through three downsampling operations. In the decoder part, an attention mechanism is introduced, and the SE module is used to weight the integrated shallow and deep features on the channel, and then two convolutions are used to further extract features, which strengthens the network's ability to capture shallow detail features and deepens the network's understanding of deep semantic information, thereby effectively improving the network's ability to integrate information. The decoder performs three upsampling operations to ensure that the output density map is consistent with the original image size.

[0079] The U-Fish network includes modules 1 to 8, where modules 1 to 4 are encoders and modules 5 to 8 are decoders. Modules 5 to 7 include SE modules, which recalibrate the relationship between channels through the attention mechanism and enhance the network's ability to recognize and utilize features.

[0080] The U-Fish network processes the input image as follows:

[0081] The input image passes through module 1: Conv module, Conv module to obtain feature i1;

[0082] Feature i1 passes through module 2: 2x2 maximum pooling module, Ghost module, and Ghost module to obtain feature i2;

[0083] Feature i2 passes through module 3: 2x2 maximum pooling module, Ghost module, and Ghost module to obtain feature i3;

[0084] Feature i3 passes through module 4: 2x2 maximum pooling module, Ghost module, Ghost module, 2x2 transposed convolution module to obtain feature i4;

[0085] Feature i4 and feature i3 pass through module 5: Concat module, SE module, Conv module, Conv module, 2x2 transposed convolution module to obtain feature o3. Feature i4 and feature i3 are concatenated in the channel direction through the Concat module to obtain feature i3', and then feature i3' passes through the SE module, two Conv modules and 2x2 transposed convolution module in sequence to obtain feature o3;

[0086] Feature o3 and feature i2 are passed through module 6: Concat module, SE module, Conv module, Conv module, 2x2 transposed convolution module to obtain feature o2. Feature o3 and feature i2 are concatenated in the channel direction through the Concat module to obtain feature i2', and then feature i2' is passed through the SE module, two Conv modules and 2x2 transposed convolution module in sequence to obtain feature o2;

[0087] Feature o2 and feature i1 pass through module 7: Concat module, SE module, Conv module, Conv module, 2x2 transposed convolution module to obtain feature o1. Feature o2 and feature i1 are concatenated in the channel direction through the Concat module to obtain feature i1', and then feature i1' passes through the SE module, two Conv modules and 2x2 transposed convolution module in sequence to obtain feature o1;

[0088] Feature o1 passes through module 8: a convolution module with a 1×1 convolution kernel to obtain a density map.

[0089] It should be noted that the Conv module in module 1 is composed of a 3x3 convolution, BatchNorm normalization, and ReLU activation function in series.

[0090] It should be noted that the Ghost module, such as Figure 3 , while maintaining similar accuracy to ordinary convolution, it can significantly reduce the amount of calculation and improve the speed.

[0091] It should be noted that the SE module, such as Figure 4By learning the relationship between channels, the channels of the feature map are re-weighted to improve the network's attention to key features. The SE module is introduced after the Concat module to perform detailed channel-level weight allocation for the fused shallow and deep features, which not only strengthens the capture of shallow detail features, but also deepens the understanding of deep semantic information, thereby effectively improving the network's ability to integrate information.

[0092] Furthermore, the U-Fish loss function described in step S3 includes:

[0093] Euclidean distance loss, multi-scale density level consistency loss, and structural similarity loss.

[0094] The Euclidean distance loss formula is as follows:

[0095]

[0096] in is the number of images in a batch, is the training image The estimated density map of . yes The actual density map of .

[0097] Euclidean distance loss is used as the loss function for group counting, which only considers pixel errors. Multi-scale density level consistency loss divides the density map into different sub-regions and forms a pooled representation to illustrate the density levels at different locations. It considers the global and local density level consistency between the estimated density map and the true value, which can improve the detection accuracy. The formula for multi-scale density level consistency loss is as follows:

[0098]

[0099] in, is the number of images in a batch, is the number of scale levels used for consistency checking, is the average pooling operation, is the training image The estimated density map of is the specified output size for average pooling, For training images The true density map of

[0100] The structural similarity loss combined with the Euclidean distance loss can enhance the structural similarity of the density map and the label. The SSIM value ranges from -1 to 1, and the value is 1 when the two images are the same. The structural similarity loss function is as follows:

[0101]

[0102]

[0103]

[0104] is the training image The estimated density map of , yes The actual density map of and They are and The mean of and They are and The variance of for and The covariance between . is the number of images in a batch. and It is a small constant to prevent the denominator from being 0;

[0105] The overall loss function formula is as follows:

[0106]

[0107] in , is the balance coefficient, Take 0.01, Take 0.01.

[0108] Further, the U-Fish model constructed by using the image enhancement method to optimize the image quality in step S4 and mixing the original image with the enhanced image for training is characterized in that: in the model training stage, a random image enhancement strategy is adopted: with equal probability, the original image is used in half of the cases, and the image enhanced by CLAHE is used in the other half for training. The training details include: in the training process of the U-Fish model, the Adam optimizer and the learning rate decay strategy are used to improve the training efficiency. The model is iterated multiple times on the training set, and the optimal weight is selected by the mean absolute error on the validation set. In order to enhance the generalization ability of the model, all training images have undergone a unified data preprocessing step, including random cropping and random flipping. Random cropping allows the model to adapt to inputs of different sizes, supports multi-batch training, and can more comprehensively cover different areas of the image by dynamically cropping in each iteration. The cropped image is then randomly flipped to further increase the diversity of the data, thereby improving the robustness of the model. Finally, in multiple iterations, the weight with the smallest mean absolute error on the validation set is selected as the weight of the fish counting model.

[0109] It should be noted that the image enhancement method described in step S4 specifically refers to CLAHE image enhancement. As an effective image enhancement technology, CLAHE can improve the visual effect and analysis quality of the image without introducing additional noise by adaptively adjusting the local contrast of the image and limiting over-enhancement. CLAHE can perform contrast enhancement on areas where pixel values ​​are densely distributed, such as reflective areas. Compared with conventional histogram equalization methods, CLAHE can prevent noise amplification caused by excessive concentration of local histograms. In this way, CLAHE not only enhances the visibility of low-contrast areas in the image, but also maintains the overall naturalness and detail richness of the image.

[0110] It should be noted that, ideally, the application of image enhancement technology can improve the accuracy of fish counting. However, the findings of related studies indicate that the increased clarity of image enhancement may have a negative impact on the detection accuracy of the model. In order to alleviate this accuracy degradation, the original image and the CLAHE-enhanced image are used for training during the model training phase. During the validation and testing phase of the model, the original image and the CLAHE-enhanced image are input into the model together, and the final result is the average of the two counts. This method aims to optimize the performance of the model by combining the advantages of the two images to ensure the accuracy and reliability of the counting results.

[0111] It should be noted that the minimum mean absolute error refers to the general training method of artificial intelligence models, that is, the weight with the best mean absolute error in the validation set is saved as the final counting model in multiple trainings. The formula for the mean absolute error is as follows:

[0112]

[0113] in, is the total number of images, represents the predicted number of fish, Indicates the actual number of fish.

[0114] Furthermore, step S5 specifically includes the following steps:

[0115] Step S501: Use CLAHE to enhance the image;

[0116] Step S502: input the original image and the image enhanced by CLAHE into the trained model together;

[0117] Step S503: the model outputs density maps corresponding to the original image and the enhanced image respectively;

[0118] Step S504: Integrate the density map to obtain a counting result;

[0119] Step S505: Take the average of the counting result of the original image and the counting result of the enhanced image as the final count number

[0120] This embodiment is only a preferred specific implementation of the present invention, but the protection scope of the present invention is not limited thereto.

[0121] Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A fish counting method based on density map regression, characterized in that: The following steps are involved: Step S1: constructing fish school data sets of different densities; Step S2: construct U-Fish network architecture; The U-Fish network architecture in step S2 adopts a U-shaped structure, and uses skip connections to effectively integrate the feature map in the encoder with the corresponding layer in the decoder: In the encoder part, a lightweight Ghost module is used to replace the traditional convolution. The encoder reduces the width and height of the image to 1 / 8 of the original size through three downsampling operations. In the decoder part, the attention mechanism is introduced, and the SE module is used to distribute the weights of the integrated shallow and deep features on the channel, and then two convolutions are used to further extract features; the decoder performs three upsampling operations to ensure that the output density map is consistent with the original image size; The U-Fish network consists of modules 1 to 8, where modules 1 to 4 are encoders and modules 5 to 8 are decoders; modules 5 to 7 include SE modules, which recalibrate the relationship between channels through the attention mechanism to enhance the network's ability to recognize and utilize features; The U-Fish network processes the input image as follows: The input image is in module 1 and processed by Conv module and Conv module in turn to obtain feature i1; In module 2, feature i1 is processed by 2x2 maximum pooling module, Ghost module, and Ghost module in sequence to obtain feature i2; In module 3, feature i2 is processed by 2x2 maximum pooling module, Ghost module, and Ghost module in sequence to obtain feature i3; In module 4, feature i3 is processed by 2x2 maximum pooling module, Ghost module, Ghost module, and 2x2 transposed convolution module to obtain feature i4; In module 5, feature i4 and feature i3 are concatenated by the Concat module to obtain feature i3', and then feature i3' is processed by the SE module, two Conv modules and 2x2 transposed convolution modules in sequence to obtain feature o3; In module 6, feature o3 and feature i2 are concatenated by the Concat module to obtain feature i2', and then feature i2' is processed by the SE module, two Conv modules and 2x2 transposed convolution modules in sequence to obtain feature o2; Feature o2 and feature i1 are concatenated in module 7 through the Concat module to obtain feature i1', and then feature i1' is processed by the SE module, two Conv modules and 2x2 transposed convolution modules in sequence to obtain feature o1; Feature o1 is processed by a convolution module with a 1×1 convolution kernel in module 8 to obtain a density map; Step S3: construct U-Fish loss function; Step S4: Use image enhancement methods to optimize image quality, and mix the original image with the enhanced image to train the constructed U-Fish model, and obtain a fish counting model after the training; Step S5: Input the image to be detected and its corresponding enhanced image into the trained fish counting model, and the model outputs a density map and counting results.

2. The fish counting method based on density map regression according to claim 1, characterized in that: The step S1 comprises the following sub-steps: Step S101: Collecting overhead images of fish schools of different densities; Step S102: using open source labeling software CCLabeler to label the fish position data in the image; Step S103: Based on the position data, a Gaussian kernel function is applied to generate a continuous density distribution map; Step S104: integrating the data set to ensure a one-to-one mapping relationship between the fish school image, location data and density map; Step S105: construct a fish density map count data set, and divide the integrated data set into a training set, a validation set, and a test set.

3. The fish counting method based on density map regression according to claim 1, characterized in that: The U-Fish loss function in step S3 is composed of Euclidean distance loss, multi-scale density level consistency loss and structural similarity loss, where: The Euclidean distance loss formula is as follows: in, is the number of images in a batch, is the training image The estimated density map of ; For training images The true density map of represents the L2 norm, is the square of the L2 norm; The multi-scale density level consistency loss formula is as follows: in, is the number of scale levels used for consistency checking, is the average pooling operation, is the specified output size for average pooling, represents the L1 norm; The structural similarity loss function is as follows: SSIM, or structural similarity, is an indicator used to evaluate the similarity between two images. The closer the SSIM value is to 1, the more similar the two images are. The parameters are , and They are and The mean of and They are and The variance of for and The cooperation between and It is a small constant to prevent the denominator from being 0; The overall loss function formula is as follows: in , is the balance coefficient, Take 0.1, Take 0.

01.

4. The fish counting method based on density map regression according to claim 1, characterized in that: The mixing of the original image and the enhanced image to train the constructed U-Fish model in step S4 includes: in the model training stage, a random image enhancement strategy is adopted: with equal probability, the original image is used in half of the cases, and the image enhanced by CLAHE image is used for training in the other half of the cases, wherein CLAHE refers to limited contrast adaptive histogram equalization.

5. The fish counting method based on density map regression according to claim 4 is characterized in that: During the training process of the U-Fish model, the Adam optimizer and learning rate decay strategy are used to improve training efficiency; The model was iterated multiple times on the training set, and the optimal weights were selected by the mean absolute error on the validation set. To enhance the generalization ability of the model, all training images underwent a unified data preprocessing step, including random cropping and random flipping. Random cropping allows the model to adapt to inputs of different sizes, supports multi-batch training, and covers different areas of the image more comprehensively by dynamically cropping in each iteration. The cropped images were randomly flipped to further increase the diversity of the data, thereby improving the robustness of the model. Finally, in multiple iterations, the weight with the smallest mean absolute error on the validation set was selected as the weight of the fish counting model. The mean absolute error formula is as follows: in, is the total number of images, represents the predicted number of fish, Indicates the actual number of fish.

6. The fish counting method based on density map regression according to claim 1, characterized in that: The step S5 specifically comprises the following steps: Step S501: Use CLAHE to enhance the image; Step S502: input the original image and the image enhanced by CLAHE into the trained model together; Step S503: the model outputs density maps corresponding to the original image and the enhanced image respectively; Step S504: Integrate the density map to obtain a counting result; Step S505: taking the average of the counting result of the original image and the counting result of the enhanced image as the final counting number.

Citation Information

Patent Citations

  • Fry counting system and method based on deep learning density map regression

    CN113240650A

  • Novel sturgeon counting and positioning method

    CN116452473A

  • Underwater fish school small target robust counting method based on density map

    CN117953361A

  • VGG-CD network bait counting method and system based on density map estimation

    CN118097262A

  • Duck group density map counting method based on fusion of deep semantic features and spatial channel attention

    CN118429892A