Sick fish detection method, device and equipment, storage medium and product
By combining the backbone network, SPPF layer and FPN layer in the fish detection model, combined with the target detection and semantic segmentation network, the problem of fish disease diagnosis in high-density farming is solved, and real-time and efficient diseased fish detection and lesion assessment are achieved. , reducing economic losses.
Patent Information
- Application Number
- CN202410563328.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-08
- Publication Date
- 2024-08-30
AI Technical Summary
The existing technology lacks efficient methods for detecting diseased fish, making it difficult to diagnose fish diseases in a timely manner under high-density farming conditions, resulting in economic losses.
A diseased fish detection model trained based on sample fish images and labels is used, including the backbone network layer, SPPF layer, FPN layer, target detection network branch and semantic segmentation network branch, through feature extraction, pooling processing and multi-scale feature maps Generate, realize real-time detection of diseased fish and their infected areas, and then evaluate the degree of disease.
It achieves real-time and efficient detection of diseased fish and assessment of disease severity, and avoids economic losses caused by the spread of fish diseases.
Smart Images

Figure CN118570837A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a diseased fish detection method, device, equipment, storage medium and product. Background Art
[0002] Fish, as a key part of aquaculture, are rich in phosphorus, calcium, beneficial fats, high-quality protein and other nutrients, and are an important source of protein for human daily diet. At present, the fish farming model is gradually transforming into a new factory-based, intelligent and intensive farming model. While greatly improving the farming efficiency, it also faces new difficulties and challenges: under high-density farming conditions, fish diseases are prone to collective infection, causing irreparable losses. Therefore, timely diagnosis and detection of sick fish and avoiding large-scale deaths of fish under factory-based high-density farming conditions are of great practical significance for improving the economic benefits of factories and enterprises.
[0003] Diagnosis of fish diseases requires professional knowledge and experience. In the prior art, the system used for diagnosing fish diseases can only provide relevant knowledge for diagnosing and identifying fish diseases, but cannot detect sick fish in real time. Therefore, there is no efficient method for detecting sick fish. Summary of the invention
[0004] The present invention provides a diseased fish detection method, device, equipment, storage medium and product, which are used to solve the defect that there is no efficient diseased fish detection method in the prior art.
[0005] The present invention provides a method for detecting diseased fish, comprising: obtaining an image of a fish to be detected; inputting the image of the fish to be detected into a diseased fish detection model to obtain a diseased fish detection result and diseased infected area pixels output by the diseased fish detection model; determining the disease degree of the fish to be detected based on the diseased infected area pixels; wherein the diseased fish detection model is obtained by training based on sample fish images, sample diseased fish detection result labels corresponding to the sample fish images, and sample diseased infected area pixel category labels corresponding to the sample fish images.
[0006] According to a diseased fish detection method provided by the present invention, a diseased fish detection model includes a backbone network layer, an SPPF layer, an FPN layer, a target detection network branch and a semantic segmentation network branch; the backbone network layer, the SPPF layer and the FPN layer are connected in sequence; the FPN layer is respectively connected to the target detection network branch and the semantic segmentation network branch.
[0007] According to a diseased fish detection method provided by the present invention, the backbone network layer is used to extract features of the fish image to be detected to obtain feature data of the fish image to be detected; the SPPF layer is used to perform pooling processing on the feature data to generate a feature vector; the FPN layer is used to generate a multi-scale feature map based on the feature vector; the target detection network branch is used to perform target detection based on the multi-scale feature map, generate and output diseased fish detection results; the semantic segmentation network branch is used to identify diseased areas based on the multi-scale feature map, and generate and output pixels of diseased infected areas.
[0008] According to a diseased fish detection method provided by the present invention, before obtaining the fish image to be detected, the method further includes: obtaining a sample fish image, a sample diseased fish detection result label corresponding to the sample fish image, and a sample diseased infected area pixel category label corresponding to the sample fish image; based on the sample fish image, the sample diseased fish detection result label corresponding to the sample fish image, and the sample diseased infected area pixel category label corresponding to the sample fish image, an initial diseased fish detection model is trained to obtain a diseased fish detection model; wherein the diseased fish detection model is trained using a preset total loss function, and the preset total loss function L all The calculation formula is:
[0009]
[0010] Among them, σ 1 is the first model parameter; σ 2 is the second model parameter; L det is the target detection loss of the target detection network branch; L seg is the prediction loss of the semantic segmentation network branch.
[0011] According to a diseased fish detection method provided by the present invention, the target detection loss L of the target detection network branch is det The calculation formula is:
[0012] L det =α 1 *L cls +α 2 *L iou +α 3 *L dfl ;
[0013] Among them, L cls is the classification loss of the target detection network branch; L iou is the first bounding box regression loss of the object detection network branch; L dfl is the second bounding box regression loss of the object detection network branch; α 1 is the weight corresponding to the classification loss; α 2is the weight corresponding to the first bounding box regression loss; α 3 is the weight corresponding to the second bounding box regression loss.
[0014] According to a diseased fish detection method provided by the present invention, a sample fish image, a sample diseased fish detection result label corresponding to the sample fish image, and a sample diseased infected area pixel category label corresponding to the sample fish image are obtained, including: obtaining an unlabeled fish image; labeling the unlabeled fish image to generate an initial sample fish image, a sample diseased fish detection result label corresponding to the initial sample fish image, and a sample diseased infected area pixel category label corresponding to the initial sample fish image; performing data enhancement processing on the initial sample fish image, the sample diseased fish detection result label corresponding to the initial sample fish image, and the sample diseased infected area pixel category label corresponding to the initial sample fish image to obtain the sample fish image, the sample diseased fish detection result label corresponding to the sample fish image, and the sample diseased infected area pixel category label corresponding to the sample fish image.
[0015] The present invention also provides a diseased fish detection device, comprising: an acquisition module, used to acquire a fish image to be detected; a detection module, used to input the fish image to be detected into a diseased fish detection model, and obtain the diseased fish detection results and diseased infected area pixels output by the diseased fish detection model; an evaluation module, used to determine the disease degree of the fish to be detected based on the diseased infected area pixels; wherein the diseased fish detection model is trained based on sample fish images, sample diseased fish detection result labels corresponding to the sample fish images, and sample diseased infected area pixel category labels corresponding to the sample fish images.
[0016] 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 when the processor executes the program, the method for detecting diseased fish as described above is implemented.
[0017] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the diseased fish detection method as described in any one of the above is implemented.
[0018] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method for detecting diseased fish as described above is implemented.
[0019] The present invention provides a method, device, equipment, storage medium and product for detecting sick fish, which obtain the image of the fish to be detected; input the image of the fish to be detected into a sick fish detection model, obtain the sick fish detection result and the pixels of the sick infected area output by the sick fish detection model; determine the disease degree of the fish to be detected based on the pixels of the sick infected area; wherein the sick fish detection model is trained based on the sample fish image, the sample sick fish detection result label corresponding to the sample fish image and the sample sick infected area pixel category label corresponding to the sample fish image. Through the above method, the image of the fish to be detected is input into the sick fish detection model, the sick fish detection result and the pixels of the sick infected area output by the sick fish detection model are obtained, and the disease degree of the fish to be detected is determined based on the pixels of the sick infected area, which can not only detect the sick fish in real time and efficiently, but also detect the disease degree of the sick fish, and avoid the economic losses caused by the spread of fish diseases. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0021] Figure 1 It is a schematic flow chart of the method for detecting diseased fish provided by the present invention;
[0022] Figure 2 It is a schematic diagram of the training process of the diseased fish detection model provided by the present invention;
[0023] Figure 3 It is a schematic diagram of the testing process of the diseased fish detection model provided by the present invention;
[0024] Figure 4 It is a structural schematic diagram of a diseased fish detection device provided by the present invention;
[0025] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are 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 creative work are within the scope of protection of the present invention.
[0027] See also Figure 1 , Figure 1 : is a flow chart of the diseased fish detection method provided by the present invention. In this embodiment, the diseased fish detection method specifically includes steps S110 to S130, and each step is specifically as follows:
[0028] S110: Acquire an image of a fish to be detected.
[0029] S120: Inputting the fish image to be detected into the diseased fish detection model to obtain the diseased fish detection results and diseased infected area pixels output by the diseased fish detection model.
[0030] S130: Determine the disease degree of the fish to be tested based on the pixels of the diseased and infected area.
[0031] Among them, the diseased fish detection model is trained based on sample fish images, sample diseased fish detection result labels corresponding to the sample fish images, and sample diseased infection area pixel category labels corresponding to the sample fish images.
[0032] Generally, the disease severity of diseased fish is determined based on the size of the diseased infected area (i.e., the diseased area). The larger the diseased infected area, the more serious the disease severity, and the smaller the diseased infected area, the lighter the disease severity. An image is composed of pixels, and the diseased infected area can be determined based on the pixels of the diseased infected area.
[0033] The present embodiment provides a method for detecting sick fish, which includes obtaining an image of a fish to be detected; inputting the image of the fish to be detected into a sick fish detection model, obtaining the sick fish detection result and sick infection area pixels output by the sick fish detection model; and determining the disease degree of the fish to be detected based on the sick infection area pixels; wherein the sick fish detection model is trained based on sample fish images, sample sick fish detection result labels corresponding to the sample fish images, and sample sick infection area pixel category labels corresponding to the sample fish images. In the above manner, the image of the fish to be detected is input into the sick fish detection model, obtaining the sick fish detection result and sick infection area pixels output by the sick fish detection model, and determining the disease degree of the fish to be detected based on the sick infection area pixels. This method can not only detect sick fish in real time and efficiently, but also detect the disease degree of sick fish, thereby avoiding economic losses caused by the spread of fish diseases.
[0034] In some embodiments, the diseased fish detection model includes a backbone network layer, an SPPF layer, an FPN layer, a target detection network branch and a semantic segmentation network branch; the backbone network layer, the SPPF layer and the FPN layer are connected in sequence; the FPN layer is respectively connected to the target detection network branch and the semantic segmentation network branch.
[0035] In this embodiment, the diseased fish detection model is constructed based on the YOLOv8 network framework. The existing YOLOv8 network framework lacks a semantic segmentation network branch, and the diseased fish detection model adds a semantic segmentation network on the basis of the existing YOLOv8 network framework.
[0036] Specifically, the diseased fish detection model includes a backbone network layer, an SPPF layer, an FPN layer, a target detection network branch, and a semantic segmentation network branch.
[0037] Among them, the backbone network is used to extract features of the input fish images to be detected.
[0038] The SPPF layer is improved from the SPP (Spatial Pyramid Pooling) layer and is used to perform multi-scale pooling on feature data to enhance the receptive field and robustness of the features, so that the subsequently generated feature maps can adapt to inputs of various sizes.
[0039] The FPN (Feature Pyramid Network) layer belongs to the neck (the connection layer used to connect the backbone network and the head) part of the YOLOv8 network framework. It is a network architecture used for target detection and semantic segmentation.
[0040] Specifically, the backbone network layer, SPPF layer and FPN layer are connected in sequence, and the FPN layer is connected to the target detection network branch and the semantic segmentation network branch respectively.
[0041] The backbone network of the existing YOLOv8 network framework only contains the target detection network branch, which can be used to perform target detection based on the multi-scale feature map output by the FPN layer and generate diseased fish detection results.
[0042] Among them, the multi-scale feature map includes the underlying feature map.
[0043] In this embodiment, an additional semantic segmentation network branch is added to the existing backbone network to identify the diseased area based on the underlying feature map in the multi-scale feature map output by the FPN layer, and generate pixels of the diseased infected area.
[0044] Specifically, the target detection network branch and the semantic segmentation network branch both include output ends; the output end of the target detection network branch can output diseased fish detection results, and the output end of the semantic segmentation network branch can output diseased infected area pixels.
[0045] A diseased fish detection method provided in this embodiment builds a diseased fish detection model based on the YOLOv8 network framework, and adds an additional semantic segmentation network branch to the backbone network of the existing YOLOv8 network framework. While detecting diseased fish, pixels in diseased and infected areas can be detected, and the degree of lesions in the diseased fish can be evaluated based on the pixels in the diseased and infected areas.
[0046] In some embodiments, the backbone network layer is used to extract features of the fish image to be detected to obtain feature data of the fish image to be detected.
[0047] The SPPF layer is used to perform pooling on feature data and generate feature vectors.
[0048] The FPN layer is used to generate multi-scale feature maps based on feature vectors.
[0049] The target detection network branch is used to perform target detection based on multi-scale feature maps and generate and output diseased fish detection results.
[0050] The semantic segmentation network branch is used to identify the diseased area based on the underlying feature map in the multi-scale feature map, and generate and output pixels of the diseased infected area.
[0051] Preferably, the upsampling layer of the semantic segmentation network branch uses the nearest neighbor interpolation method instead of the deconvolution method, which can effectively reduce the amount of model calculation and improve the inference speed of the model while ensuring a certain accuracy.
[0052] Preferably, in the semantic segmentation network branch, a category balancing method is adopted, that is, different weights are assigned to different pixel categories according to the number of samples of the pixel category in the data set, so as to ensure that each category can have a reasonable impact on the loss function during training, and can also adapt to different data sets.
[0053] In some embodiments, before obtaining the fish image to be detected, the method further includes: obtaining a sample fish image, a sample diseased fish detection result label corresponding to the sample fish image, and a sample diseased infection area pixel category label corresponding to the sample fish image; based on the sample fish image, the sample diseased fish detection result label corresponding to the sample fish image, and the sample diseased infection area pixel category label corresponding to the sample fish image, an initial diseased fish detection model is trained to obtain a diseased fish detection model; wherein the diseased fish detection model is trained using a preset total loss function, and the preset total loss function L all The calculation formula is:
[0054]
[0055] Among them, σ 1 is the first model parameter; σ 2is the second model parameter; L det is the target detection loss of the target detection network branch; L seg is the prediction loss of the semantic segmentation network branch.
[0056] See also Figure 2 , Figure 2 It is a schematic diagram of the training process of the diseased fish detection model provided by the present invention.
[0057] like Figure 2 As shown, in the preliminary preparation stage of training, sample fish images containing diseased fish are first collected to form a sample fish image dataset.
[0058] Preferably, the number of sample fish images in the sample fish image dataset is greater than or equal to 3000.
[0059] Furthermore, the sample fish image dataset is partitioned, and the sample fish images are randomly divided into a training set and a validation set according to a preset ratio.
[0060] Among them, the sample fish images in the training set are training images, and the sample fish images in the validation set are test images.
[0061] Furthermore, the annotation tools are used to annotate the labels required for the target detection network branch and the semantic segmentation network branch.
[0062] Specifically, the rectangular box of the labelImg annotation tool is used to annotate each healthy fish or diseased fish in each sample fish image in the training set and the validation set, and a name representing "healthy" or "disease" is input as the sample diseased fish detection result label; the polygonal box of the labelme annotation tool is used to annotate the mask of the diseased infected area (i.e., the diseased area) on the surface of the diseased fish in each sample fish image in the training set and the validation set, and the pixel category name representing the diseased infected area is input as the sample diseased infected area pixel category label; wherein, the degree of disease is determined based on the size of the diseased infected area, and the size of the diseased infected area can be determined according to the pixels of the diseased infected area.
[0063] The diseased fish detection model also includes an input end, which is used to perform data augmentation processing on the data in the training set to enhance the generalization of the model, and to perform adaptive scaling processing on the sample fish images to adjust the sample fish images to the input size required by the YOLOv8 network framework to meet the YOLOv8 specifications.
[0064] Furthermore, based on the labeled and data-enhanced sample fish images in the training set, the sample diseased fish detection result labels corresponding to the sample fish images, and the sample diseased infection area pixel category labels corresponding to the sample fish images, the initial diseased fish detection model is trained to obtain the diseased fish detection model.
[0065] Specifically, Figure 2 As shown in Figure 1, the diseased fish detection model includes a backbone network layer, an SPPF layer, an FPN layer, a target detection network branch, and a semantic segmentation network branch. Among them, the backbone network layer, the SPPF layer, and the FPN layer are shared layers of the model.
[0066] Specifically, the sample fish images in the training set that have been labeled and data enhanced are input into the backbone network layer of the initial diseased fish detection model, and the features of the sample fish images are extracted through the backbone network layer to learn the feature data of the sample fish images.
[0067] Furthermore, the feature data of the sample fish images learned by the backbone network layer are input into the SPPF layer of the initial diseased fish detection model. The feature data of the sample fish images are pooled through the SPPF layer, which adapts to input data of various sizes, and learns and generates feature vectors corresponding to the sample fish images.
[0068] Furthermore, the feature vector learned and generated by the SPPF layer is input into the FPN layer of the initial diseased fish detection model. The feature vector is further learned and processed by the FPN layer to generate a multi-scale feature map corresponding to the sample fish image, so that the model can detect targets at different scales.
[0069] Specifically, the multi-scale feature map output by the FPN layer includes three feature maps of different scales, wherein the three feature maps of different scales include the underlying feature map and two feature maps of other scales.
[0070] The bottom feature map will be input to the semantic segmentation network branch of the initial diseased fish detection model. The semantic segmentation network branch can receive the bottom feature map from the bottom output of the FPN layer. After three upsampling and several convolutional layers in the segmentation head of the semantic segmentation network branch, the size of the bottom feature map will be restored to (W, H, 2), which can represent the probability that each pixel in the input sample fish image is a diseased body surface. W is the width of the original image input to the network, and H is the height of the original image input to the network.
[0071] During the training process, the semantic segmentation network branch will learn to identify diseased and infected areas based on the pixel category labels of the diseased and infected areas of the samples, generate diseased and infected area masks for the diseased fish in the sample fish images, and calculate the loss between the diseased and infected area masks generated by the semantic segmentation network branch and the masks actually annotated by the labelme annotation tool to obtain the prediction loss of the semantic segmentation network branch.
[0072] Specifically, the prediction loss of the semantic segmentation network branch adopts the cross entropy (CE) loss.
[0073] The feature maps of three different scales will be input into the target detection network branch of the initial diseased fish detection model.
[0074] Specifically, the PAN (Path Aggregation Network) in the target detection network branch will fuse the three feature maps of different scales from the FPN layer from the bottom to the top, and then generate three new features which are input into the decoupled detection head. The detection head will learn based on the three new features to generate the confidence, classification results and predicted bounding boxes of the predicted targets for the diseased fish individuals in the sample fish images. The classification results and predicted bounding boxes will be calculated with the loss of the real boxes annotated by the labelImg annotation tool to obtain the target detection loss of the target detection network branch.
[0075] Specifically, the target detection loss of the target detection network branch includes classification loss and bounding box regression loss, and the bounding box regression loss is divided into a first bounding box regression loss and a second bounding box regression loss.
[0076] Specifically, the classification loss adopts the binary cross entropy loss (BCE) loss, the first bounding box regression loss adopts the CIOU (Complete Intersection over Union) loss, and the second bounding box regression loss adopts the DFL (Distribution Focal Loss) loss.
[0077] Specifically, the diseased fish detection model is trained using a preset total loss function, which can be calculated at the output end of the model. The preset total loss function is based on the prediction loss of the semantic segmentation network branch and the target detection loss of the target detection network branch, and is fused using the Weight Uncertainty method.
[0078] Specifically, the output end calculates the CE loss of the semantic segmentation network branch, the BCE loss of the target detection network branch, the DFL loss and the CIOU loss, and uses the uncertainty weight method and the PCGrad method in the multi-task optimization strategy to weigh the loss weights from the semantic segmentation network branch and the target detection network branch and the conflicting gradients that may exist during the optimization training process. After back-propagation of the accumulated gradients, the weight parameters of the network can be updated so that the preset total loss function of the final model meets the requirements, and the final diseased fish detection model is obtained.
[0079] Among them, the preset total loss function L all The calculation formula is:
[0080]
[0081] Among them, σ 1 is the first model parameter; σ 2 is the second model parameter; L det is the target detection loss of the target detection network branch; L seg is the prediction loss of the semantic segmentation network branch, and CE loss is used.
[0082] In some embodiments, the object detection loss L of the object detection network branch is det The calculation formula is:
[0083] L det =α 1 *L cls +α 2 *L iou +α 3 *L dfl ;
[0084] Among them, L cls is the classification loss of the target detection network branch, using BCE loss; L iou is the first bounding box regression loss of the target detection network branch, using CIOU loss; L dfl is the second bounding box regression loss of the target detection network branch, using DFL loss; α 1 is the weight corresponding to the classification loss; α 2 is the weight corresponding to the first bounding box regression loss; α 3 is the weight corresponding to the second bounding box regression loss.
[0085] Among them, the CIOU loss comprehensively considers factors such as the distance, overlap rate, scale similarity and aspect ratio between the predicted box and the actual box. The DFL loss optimizes the probability of the two positions closest to the offset in the label in the form of cross entropy, so that the network can focus on the distribution of the area near the target position more quickly.
[0086] Please continue reading Figure 2 ,After completing the training of the diseased fish detection model, the ,data of the validation set can be used for testing. If the test result shows that the ,model converges, the training is completed. Otherwise, the training steps are repeated until the ,model converges, and the final diseased fish detection model is ,obtained.
[0087] By repeating the training process to gradually converge the model and continuously adjusting the parameters through testing on the validation set, the generalization ability and accuracy of the model can be improved.
[0088] Preferably, during the model training process, an anchor-free method can be used to directly predict the offsets of the four sides of the bounding box, avoiding the generation of a large number of redundant candidate boxes and the introduction of prior knowledge, so that the model can be more adaptable to targets of different scales and proportions.
[0089] Preferably, in terms of the positive and negative sample allocation strategy, a dynamic allocation strategy Task-AlignedAssigner can be adopted. This strategy uses a task-based adaptive dynamic threshold to determine the allocation of positive and negative samples when calculating the IOU between the anchor and the Ground Truth Box, and flexibly adjusts the allocation ratio of positive and negative samples.
[0090] In some embodiments, obtaining a sample fish image, a sample diseased fish detection result label corresponding to the sample fish image, and a sample diseased infected area pixel category label corresponding to the sample fish image includes: obtaining an unlabeled fish image; labeling the unlabeled fish image to generate an initial sample fish image, a sample diseased fish detection result label corresponding to the initial sample fish image, and a sample diseased infected area pixel category label corresponding to the initial sample fish image; performing data enhancement processing on the initial sample fish image, the sample diseased fish detection result label corresponding to the initial sample fish image, and the sample diseased infected area pixel category label corresponding to the initial sample fish image to obtain the sample fish image, the sample diseased fish detection result label corresponding to the sample fish image, and the sample diseased infected area pixel category label corresponding to the sample fish image.
[0091] Specifically, data augmentation refers to increasing the amount of data through slightly modified copies of existing data or newly created synthetic data from existing data.
[0092] See also Figure 3 , Figure 3 It is a schematic diagram of the testing process of the diseased fish detection model provided by the present invention.
[0093] like Figure 3 As shown in FIG. 1 , after the model training is completed, the images of fish to be detected that have not been labeled in the actual scene can be input into the trained model to obtain the output of the model to verify the performance of the model.
[0094] During the actual testing process, the target detection network branch can generate prediction boxes and detection results for the fish images to be detected.
[0095] Specifically, the target detection network branch can simultaneously generate multiple prediction boxes for the fish image to be detected, and use the non-maximum suppression method to remove redundant prediction boxes, thereby generating the final prediction box and diseased fish detection results for the fish image to be detected.
[0096] The semantic segmentation network branch can generate a mask of the infected area on the body surface of the diseased fish for the fish image to be detected; then, the degree of disease of the diseased fish is determined by calculating the ratio of the pixel area of the infected area mask within each prediction box to the area of the prediction box.
[0097] The present invention also provides a device for detecting diseased fish, see Figure 4 , Figure 4 4 is a schematic diagram of the structure of the diseased fish detection device provided by the present invention. In this embodiment, the diseased fish detection device includes an acquisition module 410, a detection module 420 and an evaluation module 430.
[0098] The acquisition module 410 is used to acquire the image of the fish to be detected.
[0099] The detection module 420 is used to input the fish image to be detected into the diseased fish detection model to obtain the diseased fish detection results and diseased infected area pixels output by the diseased fish detection model.
[0100] The evaluation module 430 is used to determine the disease degree of the fish to be detected based on the pixels of the diseased and infected area.
[0101] Among them, the diseased fish detection model is trained based on sample fish images, sample diseased fish detection result labels corresponding to the sample fish images, and sample diseased infection area pixel category labels corresponding to the sample fish images.
[0102] In some embodiments, the diseased fish detection model includes a backbone network layer, an SPPF layer, an FPN layer, a target detection network branch and a semantic segmentation network branch; the backbone network layer, the SPPF layer and the FPN layer are connected in sequence; the FPN layer is respectively connected to the target detection network branch and the semantic segmentation network branch.
[0103] In some embodiments, the backbone network layer is used to extract features of the fish images to be detected and obtain feature data of the fish images to be detected; the SPPF layer is used to perform pooling processing on the feature data and generate feature vectors; the FPN layer is used to generate multi-scale feature maps based on the feature vectors; the target detection network branch is used to perform target detection based on the multi-scale feature maps, generate and output diseased fish detection results; the semantic segmentation network branch is used to identify diseased areas based on the multi-scale feature maps, and generate and output pixels of diseased infected areas.
[0104] In some embodiments, the detection module 420 is used to obtain a sample fish image, a sample diseased fish detection result label corresponding to the sample fish image, and a sample diseased infection area pixel category label corresponding to the sample fish image; based on the sample fish image, the sample diseased fish detection result label corresponding to the sample fish image, and the sample diseased infection area pixel category label corresponding to the sample fish image, an initial diseased fish detection model is trained to obtain a diseased fish detection model; wherein the diseased fish detection model is trained using a preset total loss function, and the preset total loss function L all The calculation formula is:
[0105]
[0106] Among them, σ 1 is the first model parameter; σ 2 is the second model parameter; L det is the target detection loss of the target detection network branch; L seg is the prediction loss of the semantic segmentation network branch.
[0107] In some embodiments, the object detection loss L of the object detection network branch is det The calculation formula is:
[0108] L det =α 1 *L cls +α 2 *L iou +α 3 *L dfl ;
[0109] Among them, L cls is the classification loss of the target detection network branch; L iou is the first bounding box regression loss of the object detection network branch; L dfl is the second bounding box regression loss of the object detection network branch; α 1 is the weight corresponding to the classification loss; α 2 is the weight corresponding to the first bounding box regression loss; α 3 is the weight corresponding to the second bounding box regression loss.
[0110] In some embodiments, the detection module 420 is used to obtain unlabeled fish images; label the unlabeled fish images to generate an initial sample fish image, a sample diseased fish detection result label corresponding to the initial sample fish image, and a sample diseased and infected area pixel category label corresponding to the initial sample fish image; perform data enhancement processing on the initial sample fish image, the sample diseased fish detection result label corresponding to the initial sample fish image, and the sample diseased and infected area pixel category label corresponding to the initial sample fish image to obtain the sample fish image, the sample diseased fish detection result label corresponding to the sample fish image, and the sample diseased and infected area pixel category label corresponding to the sample fish image.
[0111] The present invention also provides an electronic device, Figure 5 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 5 As shown, the electronic device may include: a processor 510, a communications interface 520, a memory 530 and a communications bus 540, wherein the processor 510, the communications interface 520 and the memory 530 communicate with each other via the communications bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the method for detecting diseased fish.
[0112] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0113] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the diseased fish detection method provided by the above methods is implemented.
[0114] The present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the diseased fish detection methods provided by the above methods.
[0115] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0116] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0117] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting diseased fish, characterized in that: include: Acquire the fish image to be detected; Inputting the fish image to be detected into a diseased fish detection model to obtain diseased fish detection results and diseased infected area pixels output by the diseased fish detection model; Determining the disease degree of the fish to be detected based on the pixels of the diseased infected area; Among them, the diseased fish detection model is trained based on sample fish images, sample diseased fish detection result labels corresponding to the sample fish images, and sample diseased infection area pixel category labels corresponding to the sample fish images.
2. The method for detecting diseased fish according to claim 1, characterized in that: The diseased fish detection model includes a backbone network layer, an SPPF layer, an FPN layer, a target detection network branch and a semantic segmentation network branch; The backbone network layer, the SPPF layer and the FPN layer are connected in sequence; The FPN layer is connected to the target detection network branch and the semantic segmentation network branch respectively.
3. The method for detecting diseased fish according to claim 2, characterized in that: The backbone network layer is used to extract features of the fish image to be detected, so as to obtain feature data of the fish image to be detected; The SPPF layer is used to perform pooling processing on the feature data to generate a feature vector; The FPN layer is used to generate a multi-scale feature map based on the feature vector; The target detection network branch is used to perform target detection based on the multi-scale feature map, and generate and output the diseased fish detection result; The semantic segmentation network branch is used to identify the diseased area based on the multi-scale feature map, and generate and output the pixels of the diseased infected area.
4. The method for detecting diseased fish according to claim 2, characterized in that: Before obtaining the image of the fish to be detected, the method further includes: Obtain the sample fish image, the sample diseased fish detection result label corresponding to the sample fish image, and the sample diseased infection area pixel category label corresponding to the sample fish image; Based on the sample fish image, the sample diseased fish detection result label corresponding to the sample fish image, and the sample diseased infection area pixel category label corresponding to the sample fish image, an initial diseased fish detection model is trained to obtain the diseased fish detection model; The diseased fish detection model is trained using a preset total loss function, where the preset total loss function L all The calculation formula is: Among them, σ1 is the first model parameter; σ2 is the second model parameter; L det is the target detection loss of the target detection network branch; L seg is the prediction loss of the semantic segmentation network branch.
5. The method for detecting diseased fish according to claim 4, characterized in that: The target detection loss L of the target detection network branch det The calculation formula is: L det =α1*L cls +α2*L iou +α3*L dfl ; Among them, L cls is the classification loss of the target detection network branch; L iou is the first bounding box regression loss of the object detection network branch; L dfl is the second bounding box regression loss of the target detection network branch; α1 is the weight corresponding to the classification loss; α2 is the weight corresponding to the first bounding box regression loss; α3 is the weight corresponding to the second bounding box regression loss.
6. The method for detecting diseased fish according to claim 4, characterized in that: The step of obtaining the sample fish image, the sample diseased fish detection result label corresponding to the sample fish image, and the sample diseased infected area pixel category label corresponding to the sample fish image comprises: Obtain unlabeled fish images; Annotating the unlabeled fish image to generate an initial sample fish image, a sample diseased fish detection result label corresponding to the initial sample fish image, and a sample diseased infection area pixel category label corresponding to the initial sample fish image; Data enhancement processing is performed on the initial sample fish image, the sample diseased fish detection result label corresponding to the initial sample fish image, and the sample diseased infection area pixel category label corresponding to the initial sample fish image to obtain the sample fish image, the sample diseased fish detection result label corresponding to the sample fish image, and the sample diseased infection area pixel category label corresponding to the sample fish image.
7. A device for detecting diseased fish, characterized in that: include: An acquisition module, used for acquiring images of fish to be detected; A detection module, used for inputting the fish image to be detected into a diseased fish detection model, and obtaining the diseased fish detection result and diseased infected area pixels output by the diseased fish detection model; An evaluation module, used for determining the disease degree of the fish to be detected based on the pixels of the diseased infected area; Among them, the diseased fish detection model is trained based on sample fish images, sample diseased fish detection result labels corresponding to the sample fish images, and sample diseased infection area pixel category labels corresponding to the sample fish images.
8. 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 program, the method for detecting diseased fish as described in any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for detecting diseased fish as claimed in any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for detecting diseased fish as claimed in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Road surface garbage sensing method for intelligent road sweeping
CN111985316A
Detection method and system for multiple target images
CN114927236A
Pointer type instrument detection and reading identification method based on deep learning technology
CN115841669A
Fish disease real-time detection system based on YOLO-v5
CN116012700A
Fish disease automatic detection method, system and device and storage medium
CN117457138A
Cited By
Fish body growth prediction method
CN119027797A
Fish disease detection method, device, equipment and medium
CN119622444A
Fish disease detection method and device, computer equipment and storage medium
CN119672296A
A fish disease detection method and device, computer equipment and storage medium
CN119672296B
Fish disease detection method and device, electronic equipment and storage medium
CN120783366A
