Fish anomaly detection method based on deep separation convolution and deformable self-attention
By adopting the improved DETR model in fish abnormal behavior detection, using depth separation convolution and deformable self-attention mechanism, the problem of low detection accuracy and efficiency is solved, and high efficiency under complex background and low visibility water quality conditions is achieved. detection.
Patent Information
- Application Number
- CN202410826554.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-10-29
AI Technical Summary
Existing abnormal fish behavior detection methods have low detection accuracy and low efficiency, especially under complex background and low visibility water quality conditions, which are difficult to effectively detect.
An improved DETR model based on depth-separated convolution and deformable self-attention is adopted, the SE attention mechanism in the EfficientNet backbone network is replaced by introducing the SimAM weighted attention module, and the Slim-Neck module and Focal Loss loss function are combined to optimize feature extraction and detection process.
It improves the accuracy and efficiency of abnormal fish behavior detection, can accurately detect abnormal fish behavior under low visibility water quality conditions, meets the real-time detection needs of aquaculture, and improves detection accuracy and efficiency.
Smart Images

Figure CN118865484A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of intelligent detection, and specifically discloses a fish anomaly detection method based on deep separation convolution and deformable self-attention.
[0002] Background
[0003] When conducting research on abnormal behavior detection of fish, the challenges faced by traditional methods are many problems such as low detection accuracy and low efficiency. In the past, researchers often relied on manual observation and analysis to detect abnormal behavior of fish, but this method has disadvantages such as complicated detection process, long time consumption, and easy subjective bias. Traditional methods often cannot meet the requirements of high accuracy, high efficiency and automated detection. However, with the rise and rapid development of deep learning technology, target detection models based on deep learning technology have been proposed as a solution. This new technology uses complex neural network structures and deep learning algorithms to detect abnormal behavior of fish more accurately. Compared with traditional methods, this technology can significantly improve detection efficiency while improving detection accuracy, and achieve a higher level of automated detection, bringing unprecedented convenience and practicality to researchers. The target detection model of deep learning technology can not only understand the behavioral characteristics of fish more comprehensively, but also detect abnormal behavior more accurately, which helps to discover potential problems in advance and take timely measures. The application of this technology not only improves the work efficiency of researchers, but also saves human resources and time costs, thereby promoting the development of fish research and related fields. For example, SIFT and HOG extract features and use support vector machines (SVM) for classification and positioning. In recent years, the rise of deep learning technology has completely changed target detection. Deep learning models, especially convolutional neural networks (CNNs), have greatly improved the accuracy and robustness of target detection algorithms. Famous Transformer-based target detection models include R-CNN, YOLO, DETR, etc. They have made significant progress based on deep learning technology and achieved more effective feature representation through end-to-end learning, thereby improving the performance and effect of target detection.
[0004] Deformable-DETR is an open-source Transformer-based variable self-attention mechanism target detection model. It uses the Transformer self-attention mechanism as a feature extractor to extract features from images, and introduces position encoding to represent the position information of the target. By combining the attention mechanism to directly perform object detection on the feature map, the problem of independently predicting the target position in traditional target detection algorithms is avoided. Deformable-DETR uses a global attention mechanism to treat the target detection task as an end-to-end sequence transformation task, without the need to generate and process candidate boxes. Then, the Hungarian matching algorithm is used to remove redundant predicted boxes. In terms of loss function, Deformable-DETR adopts a novel loss function design. During the training process, classification loss and position loss are considered at the same time, and the Hungarian matching algorithm is used to establish a correspondence between the predicted box and the true box, achieving end-to-end optimization. While maintaining high detection accuracy, Deformable-DETR reduces the computational complexity and improves the detection speed, making it have better efficiency and performance in practical applications. This innovative method is of great significance to promoting the development of the target detection field. However, the Deformable DETR model may have reduced detection accuracy when dealing with complex backgrounds and scenes with low fish coverage, and further optimization and improvement of the model structure and training strategy are needed to improve the overall performance. In view of the above problems, it is necessary to study and design a new fish anomaly detection method based on deep separation convolution and deformable self-attention to overcome the problems existing in the existing fish abnormal behavior detection methods. Summary of the invention
[0005] In order to solve the problems of low detection accuracy, low efficiency and difficulty in detection under low visibility water conditions existing in existing fish abnormal behavior detection methods, the present invention proposes a fish abnormality detection method based on deep separation convolution and deformable self-attention.
[0006] The present invention provides a fish anomaly detection method based on deep separation convolution and deformable self-attention, comprising the following steps:
[0007] S1. Collecting fish images in water areas as images to be detected, preprocessing the images to be detected, and obtaining a fish image dataset;
[0008] S2. Improve the DETR model to obtain an improved DETR model including an improved EfficientNet backbone network, a Slim spatial attention module, a Deformable-Transformer Encoder layer, and a Deformable-Transformer Decoder layer. Specifically, the SE attention mechanism in the EfficientNet backbone network is replaced by the SimAM weighted attention module to obtain an improved EfficientNet backbone network, the improved EfficientNet backbone network is used as the backbone feature extraction network of the improved DETR model, and the Slim-Neck module is introduced into the neck of the DETR model to obtain a Slim spatial attention module.
[0009] S3. Input the fish image data set obtained after preprocessing in step S1 into the improved DETR model obtained in step S2, train the improved DETR model through the Focal Loss function, and obtain the trained improved DETR model;
[0010] S4. Input the fish image to be detected into the trained improved DETR model obtained in step S3 to obtain the fish abnormal behavior detection result and the position information of the individual fish target.
[0011] According to some embodiments of the present application, a fish abnormality detection method based on deep separation convolution and deformable self-attention is described. In the step S1, the fish image in the water area is collected; the image as the image to be detected includes collecting the fish in the water area through a camera to obtain an RGB image with a resolution of 2560×1440; the preprocessing includes adjusting the size of the image, and marking the fish behavior and fish position in the image through labels, the fish behavior includes normal, high temperature abnormality, low temperature abnormality, pH abnormality and hypoxia abnormality, and the fish position includes the coordinates of the center point of the bounding box, the width of the bounding box and the height of the bounding box.
[0012] According to a fish abnormality detection method based on deep separation convolution and deformable self-attention in some embodiments of the present application, in step S2, the improved EfficientNet backbone network includes 16 improved lightweight flipping bottleneck convolution modules, and the SE attention mechanism in each of the improved lightweight flipping bottleneck convolution modules is replaced by a SimAM weighted attention module.
[0013] According to a fish abnormality detection method based on deep separation convolution and deformable self-attention in some embodiments of the present application, the SimAM weight attention module is used to generate a real 3D weight for each neuron of the improved EfficientNet backbone network.
[0014] According to a fish abnormality detection method based on deep separation convolution and deformable self-attention in some embodiments of the present application, in step S2, the Slim-Neck module includes a GSConv module and a VOV-GSCSP module.
[0015] According to a fish anomaly detection method based on deep separation convolution and deformable self-attention in some embodiments of the present application, in step S3, the Focal Loss loss function is as shown in formula (1):
[0016] FL(p t )=-α t (1-p t ) γ log(p t ) (1)
[0017] Among them, p t Represents the predicted probability of the true category of the sample, α t represents the balance parameter, α t ∈[0,1], γ represents the variable focusing parameter,
[0018] The predicted probability p of the true category of the sample t As shown in formula (2):
[0019]
[0020] Among them, p represents the predicted probability and y represents the true category.
[0021] According to a fish abnormality detection method based on deep separation convolution and deformable self-attention in some embodiments of the present application, in step S3, training the improved DETR model by the fish image dataset includes training the improved DETR model based on the fish image dataset until the training is completed when a set learning round is reached, thereby obtaining the trained improved DETR model.
[0022] According to a fish anomaly detection method based on deep separation convolution and deformable self-attention in some embodiments of the present application, step S4 includes the following steps:
[0023] S401. The fish image to be detected is passed into the improved EfficientNet backbone network to obtain feature maps P1, feature map P2 and feature map P3 of three different scales;
[0024] S402. Input the feature map P1, feature map P2 and feature map P3 obtained in step S401 into the Slim spatial attention module. The Slim spatial attention module passes the feature map P3 through the GSConv module to obtain the feature map P4. The feature map P4 is upsampled and concatenated with the feature map P2, and then passes through the VoV-GSCSP module and the GSConv module to obtain the feature map Head0. The feature map Head0 is upsampled and concatenated with the feature map P1, and then passes through the VoV-GSCSP module and the GSConv module to obtain the feature map Head1. The feature map Head1 is concatenated with the feature map Head0 through the GSConv module, and then passes through the VoV-GSCSP module to obtain the feature map Head2. The feature map Head2 is concatenated with the feature map P4 through the GSConv module, and then passes through the VoV-GSCSP module to obtain the feature map Head3.
[0025] S403. The feature graphs Head1, Head2 and Head3 obtained in step S402 are subjected to dimension transformation and concatenation operations to obtain a feature sequence, and the feature sequence is input into the Deformable-TransformerEncoder layer for feature encoding operation to obtain an output feature sequence;
[0026] S404. The output feature sequence obtained in step S403 is input into the Deformable-TransformerDecoder layer for decoding operation. The predicted value is matched with the target one-to-one through the Hungarian matching algorithm to obtain the fish abnormal behavior detection result and the location information of the individual fish target.
[0027] According to a fish anomaly detection method based on deep separation convolution and deformable self-attention in some embodiments of the present application, step S401 includes:
[0028] Step a. The fish image is subjected to feature extraction using a 3×3 convolution kernel to obtain a feature map S0;
[0029] Step b. passing the feature map S0 obtained in step a into the first improved lightweight flip bottleneck convolution module;
[0030] Step c. The feature map S0 is subjected to feature extraction by a 1×1 convolution kernel, and then a feature map S1 is obtained by standardization and activation operations. The feature map S1 is passed into a k×k deep convolution kernel for feature extraction, and then a feature map S2 is obtained by standardization and activation operations, wherein the value of k is 3 or 5. The feature map S2 is passed into the SimAM weighted attention module for 3D attention feature extraction to obtain a feature map S3. The feature map S3 is subjected to standardization and DropOut operations to obtain a feature map S4. The feature map S4 is added to the feature map S0 to obtain an output feature map.
[0031] Step d. Pass the output feature map obtained in step c into the next improved lightweight flip bottleneck convolution module, repeat the operation of step c until all the improved lightweight flip bottleneck convolution modules are traversed, and multiple output feature maps of different sizes are obtained, and only the output feature maps obtained for the last three times are retained. The output feature maps obtained for the last three times are respectively subjected to ordinary convolution to adjust the number of channels to 256, and feature maps P1, feature map P2 and feature map P3 are obtained.
[0032] According to some embodiments of the present application, a fish abnormality detection method based on deep separation convolution and deformable self-attention is provided, and the fish abnormal behavior detection results output by the improved DETR model include normal, high temperature abnormality, low temperature abnormality, pH abnormality and hypoxia abnormality.
[0033] The present invention proposes a method for detecting abnormal fish based on deep separation convolution and deformable self-attention. The improved EfficientNet backbone network with SimAM weight attention module is used as the backbone feature extraction network. 3D weights are added to effectively solve the problem of difficulty in extracting target features when there is target overlap and water surface reflection. The Slim-Neck module is introduced into the neck of the DETR model to prevent the loss of some semantic information when spatial information is converted to channel information. The training cost of the network model is also reduced. The Focal Loss loss function is used to effectively improve the accuracy of model target detection. The method of the present invention not only improves the extraction of position information, but also can detect abnormal behavior of fish under low visibility water quality conditions, and also meets the requirements of real-time detection of abnormal behavior of fish in aquaculture. It can also improve detection accuracy and detection efficiency, can improve fishery production efficiency, and has important significance in protecting aquatic ecological environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 A schematic diagram of a flow chart of a fish anomaly detection method based on deep separation convolution and deformable self-attention of the present invention;
[0035] Figure 2 Schematic diagram of the structure of the improved DETR model in Example 2 of the present invention;
[0036] Figure 3 This is a schematic diagram of the structure of the SimAM weighted attention module in Example 2 of the present invention;
[0037] Figure 4 This is a schematic diagram of the structure of an improved lightweight flip bottleneck convolution module in Example 2 of the present invention;
[0038] Figure 5 This is a schematic diagram of the Slim-Neck module structure in Example 2 of the present invention;
[0039] Figure 6 This is a graph showing the detection results of the improved DETR model in Example 3 of the present invention. DETAILED DESCRIPTION
[0040] 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.
[0041] Example 1
[0042] This embodiment provides a fish anomaly detection method based on deep separation convolution and deformable self-attention. Figure 1 As shown, the following steps are included:
[0043] S1. Collect fish images in the water area as images to be detected, preprocess the images to be detected, and obtain a fish image dataset;
[0044] S2. Improve the DETR model to obtain an improved DETR model including an improved EfficientNet backbone network, a Slim spatial attention module, a Deformable-Transformer Encoder layer, and a Deformable-Transformer Decoder layer. Specifically, the SE attention mechanism in the EfficientNet backbone network is replaced by the SimAM weighted attention module to obtain an improved EfficientNet backbone network. The improved EfficientNet backbone network is used as the backbone feature extraction network of the improved DETR model. The Slim-Neck module is introduced into the neck of the DETR model to obtain the Slim spatial attention module.
[0045] S3. Input the fish image dataset obtained after preprocessing in step S1 into the improved DETR model obtained in step S2, train the improved DETR model through the Focal Loss function, and obtain the trained improved DETR model;
[0046] S4. Input the fish image to be detected into the trained improved DETR model obtained in step S3 to obtain the fish abnormal behavior detection result and the location information of the individual fish target.
[0047] Example 2
[0048] This embodiment provides a method for detecting abnormal behavior of fish based on an improved DETR network, comprising the following steps:
[0049] S1. Collect fish images in the water area as images to be detected, preprocess the images to be detected, and obtain a fish image dataset;
[0050] Specifically, fish images in water areas are collected; the images to be detected include collecting fish in water areas through a camera to obtain RGB images with a resolution of 2560×1440; preprocessing includes adjusting the size of the image, and marking the fish behaviors and fish positions in the image through labels, the fish behaviors include normal, abnormal high temperature, abnormal low temperature, abnormal pH and abnormal hypoxia, and the fish positions include the coordinates of the center point of the bounding box, the width of the bounding box and the height of the bounding box;
[0051] S2. Improve the DETR model, such as Figure 2 As shown, an improved DETR model including an improved EfficientNet backbone network, a Slim spatial attention module, a Deformable-Transformer Encoder layer and a Deformable-Transformer Decoder layer is obtained. Specifically, the SE attention mechanism in the EfficientNet backbone network is replaced by the SimAM weighted attention module to obtain an improved EfficientNet backbone network, the improved EfficientNet backbone network is used as the backbone feature extraction network of the improved DETR model, and the Slim-Neck module is introduced into the neck of the DETR model to obtain the Slim spatial attention module;
[0052] Specifically, the improved EfficientNet backbone network includes 16 improved lightweight flip bottleneck convolution modules, and the SE attention mechanism in each improved lightweight flip bottleneck convolution module is replaced by a SimAM weight attention module; the SimAM weight attention module is used to generate a real 3D weight for each neuron in the improved EfficientNet backbone network; the Slim-Neck module includes a GSConv module and a VOV-GSCSP module;
[0053] In the detection of abnormal behavior of fish, there are target overlap and water surface reflection, which makes it difficult to extract target features and is not conducive to the model's detection of abnormal behavior of fish. In order to improve the target feature extraction ability, the improved EfficientNet backbone network is selected as the backbone feature extraction network, specifically the improved EfficientNet-b2. EfficientNet-b2 is a lightweight model that optimizes the design of three dimensions such as network depth, number of channels and resolution through the model compound scaling method, which reduces model parameters and calculation while improving accuracy. The EfficientNet-b2 model structure is composed of 16 lightweight Mobile Inverted Bottleneck Convolution (MBConv) stacked modules. Each MBConv module adds a squeeze and excitation (SE) attention mechanism. The SE attention module adjusts the feature map through 1×1 convolution to fuse global information, helping the network to better understand and capture target features. The SE attention mechanism can help the network better handle complex situations such as target overlap and water surface reflection, thereby improving detection performance. In fish farming environments, image data often has a lower resolution due to water quality and other reasons, resulting in unclear features of abnormal fish. At the same time, the original DETR model is sensitive to the resolution of the input image. In visual tasks, both the channel domain and the spatial domain play an important role, and the two jointly affect the selection of visual information. However, the lightweight flipping bottleneck convolution module in the original EfficientNet only focuses on the feature information between channels, and does not fully consider the key spatial position information in the task of abnormal behavior detection of fish, which affects the feature extraction ability to a certain extent. In order to enhance the feature extraction ability of the model and improve the detection performance of the model, a 3-D weighted attention module-SimAM weighted attention module is introduced to further improve and optimize the original EfficientNet. Taking into account the low input resolution, the SimAM weighted attention module ensures that the model can accurately locate small targets or details. The SimAM weighted attention module generates real 3D weights for each neuron in the improved EfficientNet backbone network; such as Figure 3 As shown in the figure, the characteristic of the parameter-free attention of the SimAM weighted attention module is that it does not introduce additional parameters to the module. It introduces three-dimensional attention to the network without increasing the number of module parameters. Compared with the SE module used in the original EfficientNet, the weights generated by the SimAM weighted attention module are not only in the channel or spatial dimension. This comprehensive attention mechanism can capture important feature information more accurately. The network structure of the improved EfficientNet backbone network is shown in the figure. Figure 4 shown.
[0054] The Slim-Neck module is introduced in the neck of the DETR model to fuse and process the features before they enter the transformer encoder. In the traditional DETR model, this step is omitted, resulting in the loss of some semantic information when the spatial information is converted to channel information. In order to avoid this situation, the Slim-Neck module is introduced to retain the hidden connections between channels as much as possible while maintaining a low time complexity. The Slim-Neck module adopts the GSConv module and the VOV-GSCSP module to construct an efficient neural network neck, namely the deep separation convolution. In the Slim spatial attention module, feature maps of different scales are first processed by the GSConv module, and then combined with feature maps of other scales through upsampling and splicing operations. The feature maps processed in this way pass through the GSConv module again, and finally the VOV-GSCSP module is used to further extract and fuse features to prepare the final detection head (head-1, head-2, head-3) for target detection. The specific architecture of the Slim spatial attention module is as follows Figure 5 shown.
[0055] S3. Input the fish image dataset obtained after preprocessing in step S1 into the improved DETR model obtained in step S2, train the improved DETR model through the Focal Loss function, and obtain the trained improved DETR model;
[0056] The loss function of the original DETR model is divided into two main components: classification loss function and bounding box regression loss function. First, the classification loss function measures the difference between the category predicted by the model and the true category through the cross entropy loss function. For each target detection image, the original DETR model assigns a category label to each predicted box (including the background) and calculates the cross entropy loss between the predicted category and the true category. The purpose of the classification loss function is to encourage the original DETR model to predict the correct category on each predicted box. Secondly, the bounding box regression loss function uses a smooth L1 loss function to measure the difference between the predicted bounding box and the true bounding box. The original DETR model predicts the offset of each bounding box relative to the true box, usually including the offset of the center coordinates, the scaling of the width and height, and then calculates the smooth L1 loss between the predicted bounding box and the true bounding box. The purpose of the bounding box regression loss function is to enable the model to accurately predict the location of the target.
[0057] In order to improve the position accuracy of defect detection, accelerate the convergence speed of model training, and improve the robustness and stability of the model in the task of abnormal behavior detection of fish, the Focal Loss loss function is used to calculate the loss and optimize the loss function of the original DETR model. Specifically, the Focal Loss loss function is shown in formula (1):
[0058] FL(p t )=-α t (1-p t ) γ log(p t ) (1)
[0059] Among them, p t Represents the predicted probability of the true category of the sample, α t represents the balance parameter, α t ∈[0,1], γ represents the variable focusing parameter. In order to balance the loss, the balance parameter α is introduced t ∈[0,1] for classes 1 and 1-α t For other categories, for convenience, we will denote them as α t , and add a regulation factor (1-p t ) γ , where γ is the variable focusing parameter,
[0060] The predicted probability p of the true category of the sample t As shown in formula (2):
[0061]
[0062] Among them, p represents the predicted probability and y represents the true category;
[0063] Improving the DETR model through training of the fish image data set includes training the improved DETR model based on the fish image data set until the training is completed when a set learning round is reached, thereby obtaining the trained improved DETR model;
[0064] The imbalance of sample categories, such as foreground and background, is the main reason for the low accuracy. The traditional method uses grids to divide small windows in the input image, and most of the windows do not contain the target. If the original cross entropy loss is used directly, the proportion of negative samples will be very large, dominating the optimization direction of the gradient, that is, the network will tend to predict the foreground as the background. Even if the OHEM (Online Hard Sample Mining) algorithm is used to deal with the imbalance problem, although it increases the weight of misclassified samples, it is also easy to ignore easy-to-classify samples. The Focal Loss loss function focuses on training a sparse set of difficult samples. By directly improving on the standard cross entropy loss, two penalty factors are introduced to reduce the weight of easy-to-classify samples, so that the improved DETR model is more focused on difficult samples during training;
[0065] S4. Input the fish image to be detected into the trained improved DETR model obtained in step S3 to obtain the fish abnormal behavior detection result and the location information of the individual fish target.
[0066] Specifically, step S4 includes the following steps:
[0067] S401. The fish image to be detected is passed into the improved EfficientNet backbone network to obtain feature maps P1, feature map P2 and feature map P3 of three different scales;
[0068] Step S401 includes:
[0069] Step a. The fish image is subjected to feature extraction using a 3×3 convolution kernel to obtain a feature map S0;
[0070] Step b. Pass the feature map S0 obtained in step a into the first improved lightweight flip bottleneck convolution module;
[0071] Step c. After feature extraction is performed on feature map S0 through a 1×1 convolution kernel, feature map S1 is obtained through normalization and activation operations. Feature map S1 is passed into a k×k deep convolution kernel for feature extraction, and feature map S2 is obtained through normalization and activation operations, where k is 3 or 5. Feature map S2 is passed into the SimAM weighted attention module for 3D attention feature extraction to obtain feature map S3. Feature map S3 is subjected to normalization and DropOut operations to obtain feature map S4. Feature map S4 is added to feature map S0 to obtain the output feature map.
[0072] Step d. Pass the output feature map obtained in step c to the next improved lightweight flip bottleneck convolution module, repeat the operation of step c until all improved lightweight flip bottleneck convolution modules are traversed to obtain multiple output feature maps of different sizes, and only retain the output feature maps obtained in the last three times. The output feature maps obtained in the last three times are respectively subjected to ordinary convolution to adjust the channel number size to 256, and obtain feature maps P1, feature maps P2 and feature maps P3;
[0073] S402. Input the feature map P1, feature map P2 and feature map P3 obtained in step S401 into the Slim spatial attention module. The Slim spatial attention module passes the feature map P3 through the GSConv module to obtain the feature map P4. After upsampling, the feature map P4 is spliced with the feature map P2 and then passes through the VoV-GSCSP module and the GSConv module to obtain the feature map Head0. After upsampling, the feature map Head0 is spliced with the feature map P1 and then passes through the VoV-GSCSP module and the GSConv module to obtain the feature map Head1. After the feature map Head1 is spliced with the feature map Head0 through the GSConv module and then passes through the VoV-GSCSP module to obtain the feature map Head2. After the feature map Head2 is spliced with the feature map P4 through the GSConv module and then passes through the VoV-GSCSP module to obtain the feature map Head3.
[0074] S403. The feature maps Head1, Head2 and Head3 obtained in step S402 are transformed in dimension and concatenated to obtain a feature sequence, and the feature sequence is input into the Deformable-Transformer Encoder layer for feature encoding to obtain an output feature sequence;
[0075] S404. The output feature sequence obtained in step S403 is input into the Deformable-Transformer Decoder layer for decoding operation, and the predicted value is matched with the target one-to-one through the Hungarian matching algorithm to obtain the fish abnormal behavior detection result and the position information of the individual fish target;
[0076] The abnormal behavior detection results of fish output by the improved DETR model include normal, abnormal high temperature, abnormal low temperature, abnormal pH and abnormal hypoxia.
[0077] Example 3
[0078] In complex underwater aquaculture scenarios, a rich and effective data set is one of the key factors for the accuracy of target detection. According to the actual needs of fish abnormal behavior detection, a fish abnormal behavior detection system was built. The Hikvision UD14490B camera model was selected to collect RGB images with a resolution of 2560×1440. During the fish image acquisition process, the camera maintains a fixed distance from the water surface to effectively avoid distortion or loss of target information. At the same time, the influence of lighting conditions on the detection results is considered to ensure that the collected images are not distorted, and the LED ring light source is used to compensate for the lighting of the aquaculture environment. In this embodiment, the data set FISH_Abnorm2023 is used, which contains a total of 6,000 pictures in high temperature environment, low temperature environment, abnormal pH environment, hypoxia environment and normal environment scenes. The abnormal behaviors of fish include normal, abnormal high temperature, abnormal low temperature, abnormal pH and abnormal hypoxia, of which 80% are used for training and 20% are used for verification. The test pictures use data taken from the breeding workshop of Tianzheng Breeding Company. Taking the coco2017 dataset format as a template, the LabelImg image annotation software was used to annotate the dataset. The labels in the high temperature environment were "normal" and "high temperature abnormality", the labels in the low temperature environment were "normal" and "low temperature abnormality", the labels in the pH abnormal environment were "normal" and "pH abnormality", and the labels in the hypoxic environment were "normal" and "hypoxic abnormality". Then a Python script was used for format conversion.
[0079] The experiment of this embodiment uses the Pytorch 1.12.0 framework, the python version is 3.9, the GPU is NVIDIA GeForce RTX 4090, and the other contents of this embodiment are the same as those of Example 2. The experiment of this embodiment uses the common evaluation indicators of the target detection task to evaluate the algorithm performance, including: mean average precision mAP@0.5 / % (mean average precision), training rounds (epoch) and parameter amount M (Params).
[0080] In order to verify the effectiveness of various improvements to DETR, five sets of ablation experiments were designed and conducted on the processed FISH_Abnorm2023 dataset. The ablation experiments and results are shown in Table 1.
[0081] Table 1 Ablation experiment
[0082]
[0083] Among them, No. 1 is the original DETR model, No. 2 is the original DETR model using the EfficientNet backbone network as the backbone feature extraction network, No. 3 is the original DETR model using the improved EfficientNet backbone network as the backbone feature extraction network, No. 4 is the original DETR model using the Slim spatial attention module, No. 5 is the original DETR model using the Focal Loss loss function, and No. 6 is the improved DETR model in Example 2. From the results in Table 1, it can be seen that compared with the original DETR model, the mAP of the original DETR model result using the EfficientNet backbone network as the backbone feature extraction network in No. 2 is increased by 2.6%, the mAP of the original DETR model result using the improved EfficientNet backbone network as the backbone feature extraction network in No. 3 is increased by 4.4%, the mAP of the original DETR model result using the Slim spatial attention module in No. 4 is increased by 7.2%, the mAP of the original DETR model result using the Focal Loss loss function in No. 5 is increased by 2.5%, and the mAP of the improved DETR model in Example 2 in No. 6 is increased by 15.1% compared with the original DETR model result. The ablation experiment results show that compared with the original DETR algorithm, the detection effect of the improved DETR model on images with complex backgrounds and large target scale changes is improved.
[0084] This embodiment also conducts comparative experiments with advanced underwater target detection models to verify the superiority of the improved DETR model. The advanced underwater target detection models include DETR, Conditional-DETR, Anchor-DETR, Deformable-DETR and DAB-DETR. The experimental results are shown in Table 2.
[0085] Table 2 Performance comparison of different algorithms
[0086]
[0087] From the results in Table 2, we can see that compared with the original DETR model, the mAP of the improved DETR model results is increased by 15.1%, compared with Conditional-DETR, the mAP of the improved DETR model results is increased by 13.0%, compared with Anchor-DETR, the mAP of the improved DETR model results is increased by 6.7%, compared with Deformable-DETR, the mAP of the improved DETR model results is increased by 8.8%, compared with DAB-DETR, the mAP of the improved DETR model results is increased by 5.3%. The detection results of the improved DETR model are shown as follows: Figure 6 shown.
[0088] The present invention proposes a method for detecting abnormal behavior of fish based on an improved DETR network. In order to solve the problem that the key features in the abnormal behavior images of fish are difficult to extract due to complex background information, overlapping targets and turbid water quality, the Resnet network structure in the original Backbone feature extraction module is replaced with an improved EfficientNet backbone network with a SimAM weighted attention module. In view of the problems that Transformer includes multiple attention heads and multiple layers, so its computational cost is relatively high, and compared with the traditional region-based target detection method, the training and tuning process of DETR may be more complicated, etc., a deformable attention mechanism is used to replace the original attention mechanism of DETR, reducing the training cost of the network model. The combination of Focal Loss and Smooth L1 functions is used to calculate the loss, which optimizes the loss function of the original model and effectively improves the accuracy of abnormal behavior target detection of fish.
[0089] 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 anomaly detection method based on deep separable convolution and deformable self-attention, characterized in that: The steps include: S1. Collecting fish images in water areas as images to be detected, preprocessing the images to be detected, and obtaining a fish image dataset; S2. Improve the DETR model to obtain an improved DETR model including an improved EfficientNet backbone network, a Slim spatial attention module, a Deformable-Transformer Encoder layer, and a Deformable-Transformer Decoder layer. Specifically, the SE attention mechanism in the EfficientNet backbone network is replaced by the SimAM weighted attention module to obtain an improved EfficientNet backbone network, the improved EfficientNet backbone network is used as the backbone feature extraction network of the improved DETR model, and the Slim-Neck module is introduced into the neck of the DETR model to obtain a Slim spatial attention module. S3. Input the fish image data set obtained after preprocessing in step S1 into the improved DETR model obtained in step S2, train the improved DETR model through the Focal Loss function, and obtain the trained improved DETR model; S4. Input the fish image to be detected into the trained improved DETR model obtained in step S3 to obtain the fish abnormal behavior detection result and the position information of the individual fish target.
2. According to claim 1, a method for detecting fish anomalies based on deep separation convolution and deformable self-attention is characterized in that: In the step S1, the fish image in the water area is collected; the image to be detected includes collecting the fish in the water area through a camera to obtain an RGB image with a resolution of 2560×1440; the preprocessing includes adjusting the size of the image, and marking the fish behavior and fish position in the image through labels, the fish behavior includes normal, high temperature abnormality, low temperature abnormality, pH abnormality and hypoxia abnormality, and the fish position includes the coordinates of the center point of the bounding box, the width of the bounding box and the height of the bounding box.
3. The method for detecting fish anomalies based on deep separable convolution and deformable self-attention according to claim 1, characterized in that: In step S2, the improved EfficientNet backbone network includes 16 improved lightweight flip bottleneck convolution modules, and the SE attention mechanism in each of the improved lightweight flip bottleneck convolution modules is replaced by a SimAM weighted attention module.
4. The method for detecting fish anomalies based on deep separable convolution and deformable self-attention according to claim 3, characterized in that: The SimAM weight attention module is used to generate true 3D weights for each neuron of the improved EfficientNet backbone network.
5. The method for fish anomaly detection based on deep separable convolution and deformable self-attention according to claim 1, characterized in that: In step S2, the Slim-Neck module includes a GSConv module and a VOV-GSCSP module.
6. The method for detecting fish anomalies based on deep separable convolution and deformable self-attention according to claim 1, characterized in that: In step S3, the Focal Loss function is as shown in formula (1): FL(p t )=-a t (1-p t ) γ log(p t ) (1) Among them, p t Represents the predicted probability of the true category of the sample, α t represents the balance parameter, α t ∈[0,1], γ represents the variable focusing parameter, The predicted probability p of the true category of the sample t As shown in formula (2): Among them, p represents the predicted probability and y represents the true category.
7. A method for detecting fish anomalies based on deep separable convolution and deformable self-attention according to any one of claims 1 to 6, characterized in that: In the step S3, the training of the improved DETR model by the fish image dataset includes training the improved DETR model based on the fish image dataset until the training is completed when a set learning round is reached, thereby obtaining the trained improved DETR model.
8. A method for detecting fish anomalies based on deep separable convolution and deformable self-attention according to any one of claims 1 to 6, characterized in that: The step S4 comprises the following steps: S401. The fish image to be detected is passed into the improved EfficientNet backbone network to obtain feature maps P1, feature map P2 and feature map P3 of three different scales; S402. Input the feature map P1, feature map P2 and feature map P3 obtained in step S401 into the Slim spatial attention module. The Slim spatial attention module passes the feature map P3 through the GSConv module to obtain the feature map P4. The feature map P4 is upsampled and concatenated with the feature map P2, and then passes through the VoV-GSCSP module and the GSConv module to obtain the feature map Head0. The feature map Head0 is upsampled and concatenated with the feature map P1, and then passes through the VoV-GSCSP module and the GSConv module to obtain the feature map Head1. The feature map Head1 is concatenated with the feature map Head0 through the GSConv module, and then passes through the VoV-GSCSP module to obtain the feature map Head2. The feature map Head2 is concatenated with the feature map P4 through the GSConv module, and then passes through the VoV-GSCSP module to obtain the feature map Head3. S403. The feature graphs Head1, Head2 and Head3 obtained in step S402 are subjected to dimension transformation and concatenation operations to obtain a feature sequence, and the feature sequence is input into the Deformable-Transformer Encoder layer for feature encoding operation to obtain an output feature sequence; S404. The output feature sequence obtained in step S403 is input into the Deformable-Transformer Decoder layer for decoding operation. The predicted value is matched with the target one-to-one through the Hungarian matching algorithm to obtain the fish abnormal behavior detection result and the location information of the individual fish target.
9. The method for detecting fish anomalies based on deep separable convolution and deformable self-attention according to claim 8, characterized in that: The step S401 includes: Step a. The fish image is subjected to feature extraction using a 3×3 convolution kernel to obtain a feature map S0; Step b. passing the feature map S0 obtained in step a into the first improved lightweight flip bottleneck convolution module; Step c. The feature map S0 is subjected to feature extraction by a 1×1 convolution kernel, and then a feature map S1 is obtained by standardization and activation operations. The feature map S1 is passed into a k×k deep convolution kernel for feature extraction, and then a feature map S2 is obtained by standardization and activation operations, wherein the value of k is 3 or 5. The feature map S2 is passed into the SimAM weighted attention module for 3D attention feature extraction to obtain a feature map S3. The feature map S3 is subjected to standardization and DropOut operations to obtain a feature map S4. The feature map S4 is added to the feature map S0 to obtain an output feature map. Step d. Pass the output feature map obtained in step c into the next improved lightweight flip bottleneck convolution module, repeat the operation of step c until all the improved lightweight flip bottleneck convolution modules are traversed, and multiple output feature maps of different sizes are obtained, and only the output feature maps obtained for the last three times are retained. The output feature maps obtained for the last three times are respectively subjected to ordinary convolution to adjust the number of channels to 256, and feature maps P1, feature map P2 and feature map P3 are obtained.
10. The method for detecting fish anomalies based on deep separable convolution and deformable self-attention according to claim 1, characterized in that: The abnormal behavior detection results of fish output by the improved DETR model include normal, abnormal high temperature, abnormal low temperature, abnormal pH and abnormal hypoxia.
Citation Information
Cited By
Transform-based marine organism population anomaly monitoring method and system
CN119399572A
A Transformer-based method and system for abnormal monitoring of marine biological populations
CN119399572B
Improved ocean fishery high-precision target detection method based on RT-DETR
CN119963986A
Visual SLAM method in dynamic environment based on YOLOv8 model
CN120070863A
Fish abnormal behavior monitoring, description and diagnosis method
CN120783398A
