Lightweight fish bait pellet count method, system, electronic device, and medium
By performing hierarchical quantization and model pruning on the fish bait particle counting network, deep lightweight network weights are generated, solving the problem of excessive storage space and computational overhead on edge devices, and achieving efficient bait particle counting on edge devices.
Patent Information
- Application Number
- CN202211171435.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-26
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2042-09-26
AI Technical Summary
Existing fish bait particle counting methods based on deep convolutional neural networks are difficult to deploy on edge devices with limited computing resources, mainly due to excessive storage space and computational overhead, and the poor counting performance of traditional methods.
By performing hierarchical quantization sensitivity analysis and fine quantization processing on the pre-trained weights, and combining the L1 norm to obtain the pruning threshold, the fish bait particle counting network is pruned to generate deep lightweight network weights, which are then counted on edge devices.
Without compromising counting accuracy, the storage space and computational overhead of the fish bait particle counting network were reduced, and it was successfully deployed on an edge computing platform, achieving accurate bait particle counting.
Smart Images

Figure CN115345874B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of aquaculture, and in particular to a lightweight fish bait particle counting method, system, electronic equipment and medium. Background Art
[0002] In aquaculture, estimating the number of fish bait pellets helps reduce farming costs and provides a crucial reference for accurate feeding decisions by feeders. Due to the small size and dense density of bait pellets, methods based on acoustics or machine vision cannot effectively count bait pellets. These traditional algorithms are susceptible to noise and struggle with high-density, variable backgrounds. With the continued advancement of deep learning, bait pellet counting methods based on convolutional neural networks have achieved promising results.
[0003] Convolutional neural networks with more hidden layers typically have excellent feature learning and representation capabilities, but they also have a large number of parameters and high computational complexity. This makes bait particle counting methods based on deep convolutional neural networks difficult to deploy on edge embedded devices with limited computing resources. Therefore, research on lightweight convolutional neural networks has important theoretical and practical significance.
[0004] At present, most model compression algorithms are based on lightweight research of classical network architectures. However, it is still difficult to find an effective method that can effectively reduce the storage space and computing overhead required by the bait particle counting network without reducing the model counting accuracy, and alleviate the problems such as high power consumption that limit the deployment of models on edge computing platforms. Summary of the Invention
[0005] The purpose of the present invention is to provide a lightweight fish bait particle counting method, system, electronic device and medium, which can effectively reduce the storage space and computing overhead required by the fish bait particle counting network without reducing the counting accuracy, thereby successfully alleviating the high power consumption problem that limits the deployment of network models on edge computing platforms.
[0006] To achieve the above object, the present invention provides the following solutions:
[0007] In one aspect, the present invention provides a lightweight method for counting fish bait particles, comprising:
[0008] Acquiring image data of underwater fish feeding and training a fish bait particle counting network based on the image data to obtain pre-trained weights for the fish bait particle counting network; the image data includes an original image captured by a camera and an annotated image obtained by annotating the centers of bait particles in the original image;
[0009] Performing hierarchical quantization sensitivity analysis on the pre-trained weights, performing refined quantization processing based on the sensitivity, and obtaining a quantized weight file;
[0010] Obtaining a pruning threshold based on the L1 norm, and performing model pruning on the quantized weight file according to the pruning threshold to obtain a deep lightweight network weight;
[0011] The weights of the deep lightweight network are loaded into a fish bait particle counting network to output a bait particle density map, and the total number of bait particles is calculated based on the bait particle density map.
[0012] Optionally, the acquiring of image data of underwater fish feeding and training a fish bait particle counting network according to the image data to obtain pre-trained weights of the fish bait particle counting network specifically includes:
[0013] Obtain the original images of underwater fish feeding taken by the camera;
[0014] Obtaining a marked image by marking the centers of the bait particles in the original image;
[0015] generating a density map of bait particles according to the labeled map;
[0016] Construct a fish bait particle counting network based on the MCNN model;
[0017] The fish bait particle counting network is trained according to the original image and the density map to obtain pre-trained weights of the fish bait particle counting network.
[0018] Optionally, obtaining the labeled image by labeling the centers of the bait particles in the original image specifically includes:
[0019] Mark the original image The center of the bait pellet , and according to the formula Generate the annotation graph ;in represents the bait particle position function; Indicates the number of bait particles in the original image.
[0020] Optionally, generating a density map of the bait particles according to the labeled map specifically includes:
[0021] According to the marked diagram , using the formula Generate a density map of bait pellets ;in represents the Gaussian kernel; represents the Gaussian kernel variance; Indicates adjustable parameters; express The average Euclidean distance between a sample and its k nearest samples.
[0022] Optionally, performing hierarchical quantization sensitivity analysis on the pre-trained weights, performing refined quantization processing based on the sensitivity, and obtaining a quantized weight file specifically includes:
[0023] The pre-trained weights of each network layer of the fish bait particle counting network were quantized using INQ, and the sensitivity of each network layer to quantization was analyzed.
[0024] Based on the sensitivity of each network layer to quantization, a more refined quantized weight accumulation value and a higher bit width are allocated to the sensitive layer to obtain a quantized weight file.
[0025] Optionally, the obtaining of a pruning threshold based on the L1 norm and performing model pruning on the quantized weight file according to the pruning threshold to obtain a deep lightweight network weight specifically includes:
[0026] Obtaining a pruning threshold based on the L1 norm, wherein the pruning threshold is dynamically adjusted according to the standard deviation of the weights of each network layer of the fish bait particle counting network;
[0027] Obtain the quantized weight file to be pruned, prune the quantized weight file whose absolute value is lower than the pruning threshold, and obtain the deep lightweight network weight.
[0028] Optionally, the step of loading the deep lightweight network weights into a fish bait particle counting network to output a bait particle density map, and calculating the total number of bait particles based on the bait particle density map, specifically includes:
[0029] Loading the deep lightweight network weights into a fish bait particle counting network to generate a lightweight fish bait particle counting network;
[0030] Obtain an image of underwater fish feeding to be detected, taken by a camera;
[0031] Inputting the image to be detected into the lightweight fish bait particle counting network and outputting a bait particle density map;
[0032] The total number of bait particles is obtained by integrating and calculating the bait particle density map.
[0033] In another aspect, the present invention further provides a lightweight fish bait particle counting system comprising:
[0034] A data acquisition and network pre-training module is used to acquire image data of underwater fish feeding and train a fish bait particle counting network based on the image data to obtain pre-trained weights for the fish bait particle counting network; the image data includes the original image captured by the camera and an annotated image obtained by annotating the centers of bait particles in the original image;
[0035] A network weight lightweight processing module is used to perform hierarchical quantization sensitivity analysis on the pre-trained weights, implement refined quantization processing based on the sensitivity, and obtain a quantized weight file;
[0036] A network weight deep lightweight module is used to obtain a pruning threshold based on the L1 norm, and perform model pruning on the quantized weight file according to the pruning threshold to obtain a deep lightweight network weight;
[0037] The fish bait particle counting module is used to load the deep lightweight network weights into the fish bait particle counting network to output a bait particle density map, and calculate the total number of bait particles based on the bait particle density map.
[0038] On the other hand, the present invention also provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the lightweight fish bait particle counting method when executing the computer program.
[0039] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which implements the lightweight fish bait particle counting method when executed.
[0040] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0041] The present invention provides a lightweight fish bait particle counting method, system, electronic device and medium. The method includes: obtaining image data of underwater fish feeding and training a fish bait particle counting network based on the image data to obtain pre-trained weights of the fish bait particle counting network; the image data includes an original image taken by a camera and a labeled image obtained by marking the centers of bait particles in the original image; performing hierarchical quantization sensitivity analysis on the pre-trained weights, performing refined quantization processing based on the sensitivity, and obtaining a quantized weight file; obtaining a pruning threshold based on the L1 norm, and performing model pruning on the quantized weight file according to the pruning threshold to obtain a deep lightweight network weight; loading the deep lightweight network weights into the fish bait particle counting network to output a bait particle density map, and calculating the total number of bait particles based on the bait particle density map. The method of the present invention performs hierarchical quantization sensitivity analysis on the pre-trained weights, implements given quantization processing on each network layer, and flexibly balances model accuracy and performance, thereby reducing the impact of decreased model accuracy on the bait particle counting network; by obtaining the weight pruning threshold based on the L1 norm method, model pruning is performed on the weight file after quantization processing, which can achieve deep "compression" of network weights, reduce redundant and information-rich weights in the network, effectively reduce the storage and computing overhead of the running network, and thus alleviate the high power consumption problem that limits the deployment of models on edge computing platforms. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0043] Figure 1 A flowchart of a lightweight fish bait particle counting method provided by an embodiment of the present invention;
[0044] Figure 2 A schematic diagram of a lightweight fish bait particle counting system and its practical application provided by an embodiment of the present invention;
[0045] Figure 3 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0046] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0047] The purpose of the present invention is to provide a lightweight fish bait particle counting method, system, electronic device and medium, which can effectively reduce the storage space and computing overhead required by the fish bait particle counting network without reducing the counting accuracy, thereby successfully alleviating the high power consumption problem that limits the deployment of network models on edge computing platforms.
[0048] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0049] Figure 1 Flowchart of a lightweight fish bait particle counting method provided by an embodiment of the present invention. Figure 1 The present invention provides a lightweight method for counting fish bait particles, comprising:
[0050] Step 101: Acquire image data of underwater fish feeding and train a fish bait particle counting network based on the image data to obtain pre-trained weights of the fish bait particle counting network.
[0051] In this embodiment, it should be noted that the image data required for training the fish bait pellet counting network in step 101 includes the original image captured by the camera and a labeled map obtained by annotating the centers of bait pellets in the original image. The center points of each bait pellet in the original image are annotated, and an adaptive Gaussian kernel is used to generate a corresponding density map, i.e., the labeled file (ground truth), to predict the number of bait pellets in the image.
[0052] The step 101 acquires image data of underwater fish feeding and trains a fish bait particle counting network based on the image data to obtain pre-trained weights of the fish bait particle counting network, specifically including:
[0053] Step 1.1: Obtain the original image of underwater fish feeding taken by the camera;
[0054] Step 1.2: obtaining a labeled image by marking the centers of the bait particles in the original image;
[0055] Mark the original image The center of the bait pellet , which means the pixels in the original image There is a bait particle at position , which is represented as a delta function Therefore, a label has The labeled graph of bait particles can be expressed as a function, as shown in formula (1):
[0056] (1)
[0057] in is the labeling function representing the labeled graph; represents the bait particle position function; Indicates the number of bait particles in the original image.
[0058] Step 1.3: generating a density map of bait particles according to the labeled map;
[0059] Convert the function in formula (1) into a continuous density function, considering each bait particle The distance between the surrounding annotation points and the adaptive Gaussian convolution kernel Applied to it, we get the density map generation formula:
[0060] (2)
[0061] In formula (2), is the bait particle density function representing the bait particle density map; represents the Gaussian kernel; represents the variance of the Gaussian kernel; Indicates adjustable parameters; express The average Euclidean distance between a sample and its k nearest samples.
[0062] Step 1.4: Construct a fish bait particle counting network based on the MCNN model;
[0063] In this example, a fish bait particle counting network was constructed based on the Multi-Column Convolutional Neural Network (MCNN) model. Specifically, the constructed fish bait particle counting network consists of three parallel columns of CNNs: column L (large-scale convolution kernels: 9*9, 7*7, 7*7, 7*7), column M (medium-scale convolution kernels: 7*7, 5*5, 5*5, 5*5), and column S (small-scale convolution kernels: 5*5, 3*3, 3*3, 3*3). Among them, the L column uses 16 9*9 filter Conv convolution layers, 1 pooling layer, 32 7*7 filter Conv convolution layers, 1 pooling layer, 16 7*7 filter Conv convolution layers, and 8 7*7 filter Conv convolution layers; the M column uses 20 7*7 filter Conv convolution layers, 1 pooling layer, 40 5*5 filter Conv convolution layers, 1 pooling layer, 20 5*5 filter Conv convolution layers, and 10 5*5 filter Conv convolution layers; the S column uses 24 5*5 filter Conv convolution layers, 1 pooling layer, 48 3*3 filter Conv convolution layers, 1 pooling layer, 24 3*3 filter Conv convolution layers, and 12 3*3 filter Conv convolution layers.
[0064] Step 1.5: Train the fish bait particle counting network based on the original image and the density map to obtain pre-trained weights of the fish bait particle counting network.
[0065] During the network training process, the inputs of the three-column convolutional neural networks (L, M, and S) are all original images. The feature maps output by the three-column convolutional neural networks are merged to form a feature map block, which is convolved with a 1*1 convolution kernel to generate the output of the fish bait particle counting network, that is, the density map of fish bait particle estimation.
[0066] The embodiment of the present invention pre-sets the parameters such as the maximum number of iterations and learning rate of network training. Specifically, the batch size is set to 1 and the learning rate is The number of iterations is 2000, and the SGD (Stochastic Gradient Descent) algorithm is used for weight optimization. In order to improve the accuracy of bait particle counting, the embodiment of the present invention uses the Euclidean distance to measure the difference between the estimated density map and the true value. The loss function is defined as follows:
[0067] (3)
[0068] in, is a set of learnable parameters, N is the total number of training samples, is the t-th input image, yes The corresponding real density map is Density map showing the estimate; Indicates Euclidean distance.
[0069] Step 102: Perform hierarchical quantization sensitivity analysis on the pre-trained weights, implement refined quantization processing based on the sensitivity, and obtain a quantized weight file.
[0070] In this embodiment, it should be noted that the quantization sensitivity in step 102 is analyzed based on the INQ (Incremental Network Quantization) quantization method. Step 102 performs a hierarchical quantization sensitivity analysis on the pre-trained weights, performs a refined quantization process based on the sensitivity, and obtains a quantized weight file, which specifically includes:
[0071] Step 2.1: Perform INQ quantization on the pre-trained weights of each network layer of the fish bait particle counting network and analyze the sensitivity of each network layer to quantization;
[0072] The INQ algorithm mainly includes three operations, namely weight grouping, group-level quantization, and retraining. Specifically, weight grouping can be expressed as formula (4):
[0073] , (4)
[0074] in, represents the weight group that needs to be quantized, Represents the set of weights that need to be retrained. Represents the empty set. Indicates the first A set of pre-trained weights for each network layer; and These are the pre-trained weights for the fish bait particle counting network.
[0075] In addition, define a binary matrix To distinguish the two types of weight groups mentioned above. Specifically, express , express .
[0076] With the help of candidate sets Full precision Convert to low precision , as shown in formula (5).
[0077] (5)
[0078] in and are two integers that satisfy ≤ . is a set of pre-trained weights The abbreviation of The non-zero elements in are restricted to or In the final low-precision model, the absolute value is less than The network weights will be set to zero. and According to equations (6) and (7), we can obtain:
[0079] (6)
[0080] (7)
[0081] Among them, the intermediate parameters , abs ( ) means to find the absolute value, max( ) means to find the maximum value, floor ( ) means rounding down. is the bit-width.
[0082] Based on the determined candidate set Quantize the full-precision network. The quantization rule is as follows:
[0083] (8)
[0084] in, Represents the weight file after quantization, which can be abbreviated as α and β are The sgn() function is used to preserve the sign of the original full-precision weights for two adjacent elements in .
[0085] After completing weight grouping and group-level quantization, we enter the retraining phase, where we introduce an optimization problem:
[0086] (9)
[0087] In formula (9), represents the objective function to be optimized, It's the loss of the network. is the regularization term, λ is a positive coefficient, Indicates that by asking Minimize the objective function. Indicates traversal constraints; Represents a binary matrix used to distinguish weight groups, abbreviated as ; Represents the network layer, Indicates that the network has L layers.
[0088] Determined by group-level quantization operation, the binary matrix is the mask determined by the weight division operation. and It is known that SGD is used to solve the optimization problem (9). The retraining update strategy in INQ is shown in formula (10):
[0089] (10)
[0090] Where γ is a positive learning rate, represents the partial derivative, is the objective function Abbreviation, using binary matrix To control the weight Whether it has been updated.
[0091] The present invention uses formula (10) to solve the optimization problem in formula (9) using the popular stochastic gradient descent method, implementing the retraining phase of the three operations in the INQ algorithm. This phase is used to compensate for the loss of fish bait particle counting accuracy caused by quantization. This ensures that the storage space and computational overhead required by the bait particle counting network are effectively reduced without reducing the model's counting accuracy.
[0092] Using an INQ-based shift quantization algorithm, the bait particle counting network is lightweighted, converting a pre-trained full-precision convolutional neural network model into a low-precision version. After quantization, the network weights are replaced by powers of 2 or zero, replacing the original floating-point multiplication operations with more convenient binary bit shift operations. This significantly reduces computational cost while maintaining lossless counting accuracy.
[0093] Step 2.2: Based on the sensitivity of each network layer to quantization, assign a more refined quantized weight accumulation value and a higher bit width to the sensitive layer to obtain the quantized weight file.
[0094] The sensitivity-based refined quantization process in step 102 involves assigning finer quantized weight accumulation values and higher bit widths to sensitive layers based on their sensitivity. Specifically, during the INQ algorithm iterations, the cumulative portion of quantized weights is defined differently depending on the network architecture. For example, the cumulative portion of quantized weights for the VGG-16 network is set to {0.5, 0.75, 0.875, 1}. This means that for the VGG-16 network, the INQ algorithm completes the quantization process in four iterations, with the cumulative portion of quantized weights progressing from 50% to 75% to 87.5% to 100%. The bait particle counting network (MCNN) has 13 layers. Each layer is quantized separately to study its sensitivity to quantization. Based on the differences in model accuracy after quantization, finer quantized weight accumulation values or higher bit widths are assigned to layers with severe accuracy loss after quantization, while coarser quantized weight accumulation values or lower bit widths are retained for less sensitive layers.
[0095] In addition, the INQ quantization strategy is further optimized. According to formula (8), the quantization candidate value is finely processed and It is divided into four equal parts, and the form of power addition of 2 is introduced. The optimized quantization rule is shown in formula (11).
[0096] (11)
[0097] In formula (11), ,in , , . ( ) represents the weight The distance to the endpoint P is the smallest, and P takes the endpoints of four intervals: By introducing a power-of-two addition term to refine the quantization candidate values, a higher resolution is provided for the quantization level while retaining the advantages of shift quantization, effectively improving the problem of model accuracy degradation.
[0098] Usually, the accuracy of lightweight models will decrease. The present invention uses formula (11) to improve the INQ quantization strategy, which can improve the matching degree of the weight distribution of the model before and after lightweight processing, thereby improving the problem of decreased accuracy in fish bait particle counting after low-bit quantization and realizing lossless counting of fish bait particles.
[0099] Step 103: Obtain a pruning threshold based on the L1 norm, and perform model pruning on the quantized weight file according to the pruning threshold to obtain a deep lightweight network weight.
[0100] The pruning threshold in step 103 is dynamically adjusted according to the standard deviation of the weights of each layer of the network. The final pruning threshold is the quality parameter q multiplied by the standard deviation of the weights of each network layer. The pruning strategy based on the L1 norm consists of three steps: First, you need to obtain a weight file to be pruned Secondly, weights whose absolute values fall below a pruning threshold are pruned, removing redundant weights that appear near zero after quantization. Finally, retraining fine-tunes the remaining connections. By learning the important weights in the network, the computational overhead and storage space required to run the fish bait particle counting network are further reduced without compromising accuracy.
[0101] Therefore, step 103 obtains a pruning threshold based on the L1 norm, and performs model pruning on the quantized weight file according to the pruning threshold to obtain a deep lightweight network weight, specifically including:
[0102] Step 3.1: Obtaining a pruning threshold based on the L1 norm. The pruning threshold is dynamically adjusted based on the standard deviation of the weights of each network layer of the fish bait particle counting network. The pruning threshold is the product of the quality parameter q and the standard deviation of the weights of each network layer.
[0103] Step 3.2: Get the quantized weight file to be pruned , prune the quantized weight files whose absolute values are lower than the pruning threshold to obtain the deep lightweight network weights.
[0104] Step 104: Load the deep lightweight network weights into the fish bait particle counting network to output a bait particle density map, and calculate the total number of bait particles based on the bait particle density map.
[0105] The method for calculating the total number of bait particles based on the bait particle density map in step 104 is: loading the weights of the deep lightweight network into the fish bait particle counting network to generate a lightweight fish bait particle counting network; obtaining the image to be detected of underwater fish feeding taken by a camera; inputting the image to be detected into the lightweight fish bait particle counting network to output a bait particle density map; and obtaining the total number of bait particles by integrating the bait particle density map.
[0106] The lightweight fish bait particle counting method provided by the embodiment of the present invention inputs the original image and the labeled image into the fish bait particle counting network, performs quantization processing on the pre-trained weights obtained through training, flexibly processes each network layer based on the sensitivity difference, and seeks a balance between model accuracy and performance. By finely processing the quantized candidate values, not only the model expression ability is improved, but also the matching degree of the weight distribution before and after the model lightweight processing is effectively improved. In addition, the quantization and pruning fusion strategy based on the L1 norm effectively reduces the redundant information in the fish bait particle counting network, effectively reduces the storage space required for running the convolutional neural network, and alleviates the problem that deep learning results are difficult to deploy at the edge end with limited computing resources. The total number of bait particles is obtained by integrating and summing the network output density map. The counting method provided by the embodiment of the present invention is conducive to reducing labor and breeding costs, and has important theoretical significance and application value for improving the level of intelligence in aquaculture.
[0107] Figure 2 Schematic diagram of a lightweight fish bait particle counting system and its practical application provided by an embodiment of the present invention. Figure 2 In an embodiment of the present invention, a camera 205 is used to capture raw images of underwater fish feeding, which are then acquired by a lightweight fish bait particle counting system. This lightweight fish bait particle counting system can be deployed on an edge computing unit 207 or a computer. After processing by the edge computing unit 207 or the computer, the total number of remaining bait particles in the current aquaculture pond is obtained and a feeding control instruction is issued. The feeder 206 dynamically adjusts the feeder's switch according to the feeding control instruction, thereby achieving precise feeding of aquaculture fish. The edge computing unit 207 is a lightweight, low-power embedded edge computing device, such as NVIDIA's Jetson Xavier NX development board.
[0108] Wherein, the lightweight fish bait particle counting system comprises:
[0109] The data acquisition and network pre-training module 201 is used to acquire image data of underwater fish feeding and train a fish bait particle counting network based on the image data to obtain pre-trained weights for the fish bait particle counting network; the image data includes an original image captured by a camera and an annotated image obtained by annotating the centers of bait particles in the original image;
[0110] The network weight lightweight processing module 202 is used to perform hierarchical quantization sensitivity analysis on the pre-trained weights, implement refined quantization processing based on the sensitivity, and obtain a quantized weight file;
[0111] The network weight deep lightweight module 203 is used to obtain a pruning threshold based on the L1 norm, and perform model pruning on the quantized weight file according to the pruning threshold to obtain a deep lightweight network weight;
[0112] The fish bait particle counting module 204 is used to load the deep lightweight network weights into the fish bait particle counting network to output a bait particle density map, and calculate the total number of bait particles based on the bait particle density map.
[0113] The lightweight fish bait particle counting system provided in the embodiment of the present invention has similar working principles and beneficial effects to the lightweight fish bait particle counting method described in the above embodiment, so it will not be described in detail here. For specific details, please refer to the introduction of the above method embodiment.
[0114] Figure 3 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 3 As shown, the electronic device may include: a processor 301, a communication interface 302, a memory 303, and a communication bus 304. The processor 301, the communication interface 302, and the memory 303 communicate with each other via the communication bus 304. The processor 301 may invoke a computer program in the memory 303 to execute the lightweight fish bait particle counting method.
[0115] Furthermore, when the computer program in the aforementioned memory 303 is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a mobile hard drive, a read-only memory, a random access memory, a magnetic disk, or an optical disk.
[0116] Furthermore, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which can implement the lightweight fish bait particle counting method when executed.
[0117] Traditional methods for estimating bait particle numbers based on acoustics or machine vision have poor counting results. However, with the continuous development of deep learning, bait particle counting methods based on convolutional neural networks have achieved better results and can better handle problems such as scene adaptability and scale diversity. At the same time, the large number of parameters and computational overhead make bait particle counting methods based on deep convolutional neural networks difficult to deploy on embedded hardware devices with limited computing and storage resources. The lightweight fish bait particle counting method and system provided by the present invention can achieve lossless bait particle counting accuracy, reduce the storage space and computational overhead required for resource-constrained devices to operate on the network, and has broad application prospects.
[0118] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.
[0119] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The above examples are only intended to help understand the method and core concept of the present invention. At the same time, those skilled in the art will find that the specific implementation methods and application scopes may vary based on the concept of the present invention. In summary, the contents of this specification should not be construed as limiting the present invention.
Claims
1. A lightweight method for counting fish bait particles, characterized in that: include: Acquiring image data of underwater fish feeding and training a fish bait particle counting network based on the image data to obtain pre-trained weights for the fish bait particle counting network; the image data includes an original image captured by a camera and an annotated image obtained by annotating the centers of bait particles in the original image; Performing hierarchical quantization sensitivity analysis on the pre-trained weights, performing refined quantization processing based on the sensitivity, and obtaining a quantized weight file; The hierarchical quantization sensitivity analysis of the pre-trained weights is performed, and refined quantization processing is performed based on the sensitivity to obtain a quantized weight file, specifically including: The pre-trained weights of each network layer of the fish bait particle counting network were quantized using INQ, and the sensitivity of each network layer to quantization was analyzed. Based on the sensitivity of each network layer to quantization, a more refined quantized weight accumulation value and a higher bit width are assigned to the sensitive layer to obtain a quantized weight file; Obtaining a pruning threshold based on the L1 norm, and performing model pruning on the quantized weight file according to the pruning threshold to obtain a deep lightweight network weight; The obtaining of a pruning threshold based on the L1 norm and performing model pruning on the quantized weight file according to the pruning threshold to obtain a deep lightweight network weight specifically includes: Obtaining a pruning threshold based on the L1 norm, wherein the pruning threshold is dynamically adjusted according to the standard deviation of the weights of each network layer of the fish bait particle counting network; Obtaining the quantized weight files to be pruned, and pruning the quantized weight files whose absolute values are lower than the pruning threshold to obtain the deep lightweight network weights; The weights of the deep lightweight network are loaded into a fish bait particle counting network to output a bait particle density map, and the total number of bait particles is calculated based on the bait particle density map.
2. The lightweight fish bait particle counting method according to claim 1, characterized in that: The method of acquiring image data of underwater fish feeding and training a fish bait particle counting network according to the image data to obtain pre-trained weights of the fish bait particle counting network specifically includes: Get the original images of underwater fish feeding taken by the camera; Obtaining a marked image by marking the centers of the bait particles in the original image; generating a density map of bait particles according to the labeled map; Construct a fish bait particle counting network based on the MCNN model; The fish bait particle counting network is trained according to the original image and the density map to obtain pre-trained weights of the fish bait particle counting network.
3. The lightweight fish bait particle counting method according to claim 2, characterized in that: The method of obtaining a labeled image by labeling the centers of the bait particles in the original image specifically includes: Mark the bait particle center x of the i-th bait particle in the original image i , and according to the formula Generate the labeled graph H(x); where δ(xx i ) represents the bait particle position function; Y represents the number of bait particles in the original image.
4. The lightweight fish bait particle counting method according to claim 3, characterized in that: Generating a density map of bait particles according to the labeled map specifically includes: According to the labeled graph H(x), the formula Generate a density map F(x) of bait particles; where represents the Gaussian kernel; σ i represents the Gaussian kernel variance; ω represents an adjustable parameter; Represents x i The average Euclidean distance between a sample and its k nearest samples.
5. The lightweight fish bait particle counting method according to claim 1, characterized in that: The method of loading the deep lightweight network weights into a fish bait particle counting network to output a bait particle density map, and calculating the total number of bait particles based on the bait particle density map, specifically includes: Loading the deep lightweight network weights into a fish bait particle counting network to generate a lightweight fish bait particle counting network; Obtain an image of underwater fish feeding to be detected, taken by a camera; Inputting the image to be detected into the lightweight fish bait particle counting network and outputting a bait particle density map; The total number of bait particles is obtained by integrating and calculating the bait particle density map.
6. A lightweight fish bait particle counting system, characterized in that: Used to implement the lightweight fish bait particle counting method according to any one of claims 1 to 5; the lightweight fish bait particle counting system comprises: A data acquisition and network pre-training module is used to acquire image data of underwater fish feeding and train a fish bait particle counting network based on the image data to obtain pre-trained weights for the fish bait particle counting network; the image data includes the original image captured by the camera and an annotated image obtained by annotating the centers of bait particles in the original image; A network weight lightweight processing module is used to perform hierarchical quantization sensitivity analysis on the pre-trained weights, implement refined quantization processing based on the sensitivity, and obtain a quantized weight file; A network weight deep lightweight module is used to obtain a pruning threshold based on the L1 norm, and perform model pruning on the quantized weight file according to the pruning threshold to obtain a deep lightweight network weight; The fish bait particle counting module is used to load the deep lightweight network weights into the fish bait particle counting network to output a bait particle density map, and calculate the total number of bait particles based on the bait particle density map.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method for counting lightweight fish bait particles according to any one of claims 1 to 5 is implemented.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed, the lightweight fish bait particle counting method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Convolutional neural network low bit width quantization method based on weight distribution
CN110222821A
Quantification method of convolutional neural network based on knowledge distillation
CN112016674A