Hippocampus skin state detection method and system based on improved YOLOv5 algorithm
Through the optimization of the YOLOv5 algorithm, including histogram equalization preprocessing and module improvement, the problems of low efficiency and low accuracy of traditional hippocampal detection are solved, and efficient detection of hippocampal abnormal state is achieved.
Patent Information
- Application Number
- CN202411091360.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2024-11-29
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional hippocampal abnormality detection relies on artificial fishing, which is inefficient and cannot detect the disease of hippocampal population in a timely and accurate manner. The YOLOv5 algorithm is unstable in identifying multiple tail-entangled hippocampals, with a long training time and low practical value.
By acquiring hippocampal images for normal and abnormal annotation, using histogram equalization preprocessing, adding CBAM module and SPPF+ module, optimizing the YOLOv5 network model, using an effective crossover loss function, and improving detection accuracy and speed.
The accuracy and speed of hippocampal abnormality detection was improved, the problems of low efficiency of artificial fishing and long model training time were overcome, and timely and accurate detection of the disease of hippocampal population was achieved.
Smart Images

Figure CN119048447A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image detection and recognition, and in particular to a method and system for detecting hippocampal skin status based on an improved YOLOv5 algorithm. Background Art
[0002] Seahorses have high medicinal and economic value. As wild resources continue to decrease, artificial breeding of seahorses has become the main way to meet the growing market demand. However, due to excessive breeding density and poor water circulation during the breeding process, the water quality in the farms is poor, which is easy to breed bacteria. In this environment, seahorses are more likely to suffer from enteritis. The skin of the head, trunk, abdomen and tail of seahorses with enteritis will show white spots or abnormalities. In addition, the entanglement of the tails of seahorses also increases the scope of infection of bacteria, increases the probability of seahorses getting sick, and reduces economic benefits.
[0003] Regular abnormal state detection of farmed seahorses can prevent large-scale outbreaks of seahorse diseases. Traditional abnormal state detection of seahorses often relies on random fishing by farmers and random sampling for detection, but manual fishing requires a lot of manpower and material resources. Since seahorses swim in seawater, the probability of catching sick seahorses is low, and it is impossible to detect the disease of the seahorse population in a timely and accurate manner in the early stage of seahorse disease. Compared with the traditional method of manual random fishing detection, applying image detection technology to underwater robots to allow them to directly detect abnormal states of seahorses underwater can overcome the inconvenience of manual fishing and the limitations of detection cycles, and detect abnormal states of farmed seahorses in a timely manner. Compared with traditional target detection algorithms such as CNN and RNN, the YOLOv5 algorithm can achieve rapid detection while maintaining high detection accuracy. However, due to the influence of the simplification of the network model, when the YOLOv5 algorithm is affected by the simplification of the network model, when the recognition object is multiple seahorses with intertwined tails and clustered together, the recognition accuracy is unstable, and a large amount of training data is required to achieve a high accuracy rate, which makes the model training time longer and the practical value is not high. Summary of the invention
[0004] In view of the above problems, the present invention provides a hippocampal skin state detection method based on an improved YOLOv5 algorithm, the method comprising:
[0005] S1, obtaining a hippocampus image, and annotating the normal skin and abnormal skin of the obtained hippocampus image to obtain an original hippocampus dataset;
[0006] S2, preprocessing the original hippocampus data set to obtain a preprocessed hippocampus data set;
[0007] S3. Optimize YOLOv5 using the CBAM module, SPPF+ module and the effective intersection-over-union loss function.
[0008] S4. Use the preprocessed hippocampus dataset to train the optimized YOLOv5 network model, and use the trained model to detect the skin condition of artificially cultured hippocampus.
[0009] Optionally, in S1, a hippocampus image is obtained, and normal skin annotation and abnormal skin annotation are performed on the obtained hippocampus image to obtain the content of the original hippocampus data set, and the specific method includes:
[0010] A hippocampus image in seawater is obtained, and body parts of a normal hippocampus and an abnormal hippocampus in the hippocampus image are annotated, wherein the annotated contents include head annotating, trunk annotating, abdomen annotating and tail annotating of a normal hippocampus; and head annotating, trunk annotating, abdomen annotating and tail annotating of an abnormal hippocampus.
[0011] Optionally, in S2, the method of preprocessing the original hippocampal dataset to obtain the preprocessed hippocampal dataset specifically includes:
[0012] Use histogram equalization to preprocess the original hippocampus images in the original hippocampus dataset:
[0013] S21, calculating the normalized frequency of the grayscale statistical histogram of the original hippocampal image, specifically comprising:
[0014]
[0015] Among them, p r (r k ) is the normalized frequency of the grayscale statistical histogram of the original hippocampal image, r k is the normalized gray level, n k is the number of pixels with gray level k in the image, k = 0, 1, 2, ..., L-1, represents the gray level before normalization, L is the number of gray levels, and N is the total number of pixels in the original image;
[0016] S22, approximating the frequency distribution to a probability distribution, calculating a transformation function of the histogram equalization, and obtaining a grayscale cumulative histogram of the original hippocampal image through the transformation function, specifically including:
[0017]
[0018] Among them, T(r k ) is a transformation function of histogram equalization, and a processed image after histogram equalization can be obtained according to the transformation function;
[0019] S23, increasing the dynamic range of pixel grayscale values according to the grayscale cumulative histogram, enhancing the overall contrast of the image, and obtaining a preprocessed hippocampal image, which together with the annotated content constitutes a preprocessed hippocampal data set.
[0020] Optionally, in S3, the method for optimizing and improving the YOLOv5 network model using the CBAM module, the SPPF module and the effective intersection-over-union loss function specifically includes:
[0021] S31. The method for optimizing and improving the YOLOv5 network model using the CBAM module includes: adding the CBAM module to the Backbone network to optimize the YOLOv5 network model; the specific method is to add the CBAM module after the convolution layer of the Backbone network, input the output of the convolution layer into the CBAM module, extract the key features of the hippocampal skin abnormalities in the pre-processed hippocampal data set, adjust the spatial dimension of the feature map, and obtain the output of the CBAM module;
[0022] S32. The method for optimizing and improving the YOLOv5 network model using the SPPF+ module includes: replacing the SPPF module in the Neck network with SPFF+ to optimize the YOLOv5 network model. The specific method includes: the structure of the original SPPF module is: the output of the CBAM module is serially input to three 5×5 MaxPooling layers, and then the outputs of the three MaxPooling layers are fused with the output of the CBAM module, and after the convolution operation, the output result of the Backbone network is obtained; the output of the CBAM module is serially input to two 3×3 MaxPooling layers and two 5×5 MaxPooling layers, and the outputs of the four MaxPooling layers are fused with the output of the CBAM module, and after the convolution operation, the output result of the Backbone network is obtained;
[0023] S33. Methods for optimizing and improving the YOLOv5 network model using an effective intersection-over-union loss function include:
[0024] Use the effective intersection-over-union loss function EIoU to optimize and improve the YOLOv5 network model:
[0025]
[0026] Among them, EIoU represents the loss of the intersection of the target bounding rectangle box and the predicted bounding rectangle box, Io U represents the ratio of the intersection of the target box and the predicted box to the union of the target box and the predicted box, ρ 2 (b,b gt ) represents the Euclidean distance between the center point of the prediction box and the target box, b represents the coordinates of the center point of the prediction box, and b gt represents the coordinates of the center point of the target box, c represents the diagonal distance of the minimum rectangle containing the prediction box and the target box, ρ 2 (w,w gt) represents the Euclidean distance between the prediction box and the target box width, w represents the width of the prediction box, and w gt Indicates the width of the target box, c w Represents the width of the minimum rectangle containing the prediction box and the target box, ρ 2 (h,h gt ) represents the Euclidean distance between the height of the prediction box and the target box, h represents the height of the prediction box, and h gt Indicates the height of the target box, c h Indicates the height of the minimum rectangle that can contain both the prediction box and the target box.
[0027] Optionally, the process of using the preprocessed hippocampus dataset to train the optimized YOLOv5 network model and using the trained model to detect the state of artificially cultured hippocampus specifically includes:
[0028] The improved YOLOv5 network model is trained using the pre-processed hippocampal dataset, the pre-processed hippocampal dataset is data-enhanced and input into the improved YOLOv5 network model, and the Backbone network of the improved YOLOv5 network model extracts the abnormal features of the hippocampal skin from the dataset;
[0029] The Head network block of the YOLOv5 network model is used to divide the image into several grids, and the state of the artificially cultured seahorse is detected based on the grids.
[0030] The present invention also discloses a hippocampal skin state detection system based on an improved YOLOv5 algorithm, the system comprising an image acquisition module, a preprocessing module, a network improvement module and a state detection module;
[0031] The image acquisition module is used to acquire a hippocampus image, and perform normal skin labeling and abnormal skin labeling on the acquired hippocampus image to obtain an original hippocampus data set;
[0032] The preprocessing module is used to preprocess the original hippocampal dataset to obtain a preprocessed hippocampal dataset;
[0033] The network improvement module is used to optimize YOLOv5 using the CBAM module, the SPPF+ module and the effective intersection-over-union loss function;
[0034] The state detection module is used to train the optimized YOLOv5 network model using the preprocessed hippocampus data set, and use the trained model to detect the skin state of artificially cultured hippocampus.
[0035] Optionally, the implementation process of the image acquisition module specifically includes:
[0036] Calculating the normalized frequency of the grayscale statistical histogram of the original hippocampus image in the original hippocampus data set specifically includes:
[0037]
[0038] Among them, p r (r k ) is the normalized frequency of the grayscale statistical histogram of the original hippocampal image, r k is the normalized gray level, n k is the number of pixels with gray level k in the image, k = 0, 1, 2, ..., L-1, indicating the gray level before normalization, L is the number of gray levels, and N is the total number of pixels in the original hippocampal image;
[0039] Approximate the frequency distribution to the probability distribution, calculate the transformation function of the histogram equalization, and obtain the grayscale cumulative histogram of the image through the transformation function, including:
[0040]
[0041] Among them, T(r k ) is a transformation function of histogram equalization, and a processed image after histogram equalization can be obtained according to the transformation function;
[0042] The dynamic range of the pixel grayscale value is increased according to the grayscale cumulative histogram, the overall contrast of the image is enhanced, and a preprocessed hippocampal image is obtained, which together with the annotation content constitutes a preprocessed hippocampal data set.
[0043] Optionally, the implementation process of the network improvement module includes:
[0044] The method for optimizing and improving the YOLOv5 network model using the CBAM module includes: adding the CBAM module to the Backbone network to optimize and improve the YOLOv5 network model; the specific method is to add the CBAM module after the convolution layer of the Backbone network, input the output of the convolution layer into the CBAM module, extract the key features of the hippocampal skin abnormality in the image, adjust the spatial dimension of the image feature map, and obtain the output of the CBAM module;
[0045] The method for optimizing and improving the YOLOv5 network model using the SPPF+ module includes: replacing the SPPF module in the Neck network with SPFF+ to optimize the YOLOv5 network model. The specific method includes: the structure of the original SPPF module is: the output of the CBAM module is serially input to three 5×5 MaxPooling layers, and then the outputs of the three MaxPooling layers are fused with the output of the CBAM module, and after the convolution operation, the output result of the Backbone network is obtained; the output of the CBAM module is serially input to two 3×3 MaxPooling layers and two 5×5 MaxPooling layers, and the outputs of the four MaxPooling layers are fused with the output of the CBAM module, and after the convolution operation, the output result of the Backbone network is obtained;
[0046] Methods for optimizing and improving the YOLOv5 network model using an effective intersection-over-union loss function include:
[0047] Use the effective intersection-over-union loss function EIoU to optimize and improve the YOLOv5 network model:
[0048]
[0049] Among them, EIoU represents the loss of the intersection of the target bounding rectangle box and the predicted bounding rectangle box, Io U represents the ratio of the intersection of the target box and the predicted box to the union of the target box and the predicted box, ρ 2 (b,b gt ) represents the Euclidean distance between the center point of the prediction box and the target box, b represents the coordinates of the center point of the prediction box, and b gt represents the coordinates of the center point of the target box, c represents the diagonal distance of the minimum rectangle containing the prediction box and the target box, ρ 2 (w,w gt ) represents the Euclidean distance between the prediction box and the target box width, w represents the width of the prediction box, and w gt Indicates the width of the target box, c w Represents the width of the minimum rectangle containing the prediction box and the target box, ρ 2 (h,h gt ) represents the Euclidean distance between the height of the prediction box and the target box, h represents the height of the prediction box, and h gt Indicates the height of the target box, c h Indicates the height of the minimum rectangle that can contain both the prediction box and the target box.
[0050] Optionally, the implementation process of the status detection module includes: using the pre-processed hippocampus data set to train the optimized YOLOv5 network model, and the process of using the trained model to detect the status of artificially cultured hippocampus specifically includes:
[0051] The improved YOLOv5 network model is trained using the pre-processed hippocampal dataset, the pre-processed hippocampal dataset is data-enhanced and input into the improved YOLOv5 network model, and the Backbone network of the improved YOLOv5 network model extracts the abnormal features of the hippocampal skin from the dataset;
[0052] The Head network block of the YOLOv5 network model is used to divide the image into several grids, and the state of the artificially cultured seahorse is detected based on the grids.
[0053] Compared with the prior art, the present invention has the following beneficial effects:
[0054] The present invention aims at the fact that artificial random sampling detection cannot timely and accurately detect the disease conditions of the hippocampus group, and proposes a method for detecting the skin state of cultured hippocampus based on the improved YOLOv5 algorithm. The method is an improvement on the YOLOv5 algorithm, including using histogram equalization to perform data preprocessing on the collected original hippocampus images, and enhancing the brightness of the local image by adjusting the contrast of the image; adding a CBAM attention module to the Backbone network, and forming a C3CBAM module together with the C3 module. This structure can improve the detection accuracy of abnormal hippocampal states; replacing SPPF in the Neck network of the YOLOv5 model with SPPF+, reducing the amount of calculation in the model training process, and improving the model convergence speed. Compared with the original algorithm, the improved YOLOv5 algorithm improves the detection accuracy and detection speed of abnormal hippocampal states. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0056] Figure 1 A flowchart of the state detection method of farmed seahorses to improve the YOLOv5 algorithm;
[0057] Figure 2 To improve the network structure diagram of the YOLOv5 algorithm;
[0058] Figure 3 This is the structure diagram of the SPFF+ module after SPFF optimization. DETAILED DESCRIPTION
[0059] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0060] Embodiment 1
[0061] The present invention provides a hippocampal skin state detection method based on an improved YOLOv5 algorithm, such as Figure 1 As shown, the method includes:
[0062] S1. Obtaining a hippocampus image in seawater, annotating the hippocampus image as normal and abnormal, and obtaining an original hippocampus data set; Obtaining a hippocampus image in seawater, and annotating various body parts of normal hippocampus and abnormal hippocampus, respectively, in order to increase the diversity of recognized species, including the head, trunk, abdomen and tail of normal hippocampus, and the head, trunk, abdomen and tail of abnormal hippocampus, so that the hippocampus data set covers a total of 8 biological features.
[0063] In this embodiment, the original hippocampus dataset is used to label the hippocampus image: the image is imported into the labelImg tool, and labels are set, such as abnormal words such as "white spots" and "ulceration", and the corresponding positions of the image are manually marked with rectangular boxes to generate a txt text document, which contains the coordinates and labels of the marked rectangular boxes. In this process, the hippocampus image does not retain label traces. The hippocampus image and the label file are collectively referred to as the original hippocampus dataset.
[0064] S2. Preprocessing the original hippocampal dataset to obtain a preprocessed hippocampal dataset.
[0065] The original hippocampus image is preprocessed using histogram equalization. First, the normalized frequency of the grayscale statistical histogram of the original hippocampus image is calculated, and the frequency distribution is approximated as a probability distribution. Then, the transformation function of the histogram equalization is calculated. The grayscale cumulative histogram of the image can be obtained through the transformation function. According to the grayscale cumulative histogram, the dynamic range of the pixel grayscale value is increased, and the overall contrast of the image is enhanced to obtain the preprocessed hippocampus data set, which specifically includes:
[0066] First, calculate the normalized frequency of the grayscale statistical histogram of the original hippocampal image:
[0067]
[0068] Among them, p r (r k ) is the normalized frequency of the grayscale statistical histogram of the original hippocampal image, r k is the normalized gray level, n kis the number of pixels with gray level k in the image, k = 0, 1, 2, ..., L-1, indicating the gray level before normalization, L is the number of gray levels, and N is the total number of pixels in the original hippocampal image;
[0069] Next, calculate the transformation function of histogram equalization:
[0070]
[0071] Among them, T(r k ) is the transformation function of histogram equalization, and the processed image after histogram equalization can be obtained according to the transformation function.
[0072] S3. Use the CBAM module, SPPF+ module and effective intersection-over-union loss function to optimize and improve the YOLOv5 network model.
[0073] The problem of low accuracy in detecting abnormal states of multiple tail-entangled and mutually clustered hippocampi in the YOLOv5 network was optimized, including adding the CBAM attention module to the Backbone network, replacing SPPF with SPFF+ in the Neck network, and replacing the loss function in the YOLOv5 network with EIoU, thus obtaining an abnormal state detection model for farmed hippocampi using the improved YOLOv5 algorithm. The optimization of the YOLOv5 model in S3 is specifically S31-S33:
[0074] S31: Since the accuracy of detecting abnormal entangled hippocampal states using the optimized YOLOv5 network model is not high, a CBAM attention module is added to the Backbone network. The CBAM attention module includes a channel attention module and a spatial attention module. The channel attention module is used to adjust the proportion of the feature map in the channel dimension and extract the key features in the image. First, the feature map is averaged and pooled to obtain a global description vector. Then, the channel maximum value and channel average value are generated through the fully connected layer, and the activation function and normalization processing are performed to obtain the channel attention vector. Finally, the channel attention vector is vector-multiplied with the input feature map to adjust the channel dimension of the feature map. The spatial attention module is used to adjust the spatial dimension of the feature map. First, the feature map is averaged and pooled at different sizes. The average pooling operation of the degree is performed, and the obtained pooled feature map is spliced into a vector. The spatial maximum value and spatial average value are generated through the fully connected layer, and the activation function and normalization processing are performed to obtain the spatial attention vector. Finally, the spatial attention vector is vector-multiplied with the input feature map to adjust the spatial dimension of the feature map; the CBAM module automatically obtains the importance of each hippocampal image feature channel and feature space by learning, extracts the key features of the abnormal hippocampal state in the image, and adjusts the spatial dimension of the image feature map, so that the YOLOv5 model focuses on the annotation information of the abnormal hippocampal state, thereby improving the detection accuracy of the entangled hippocampal state; the CBAM module is added after the C3 module, and together with the C3 module, it constitutes the C3CBAM module. The improved model structure diagram is as follows Figure 2 As shown;
[0075] S32: Optimize the SPPF module of the Neck network in the YOLOv5 model and define the optimized SPPF as the SPPF+ module, with the following structure: Figure 3 As shown in the figure, the output of the CBAM module is serially passed through two 3×3 MaxPooling layers and two 5×5 MaxPooling layers. The output of the four MaxPoolging layers and the output of the CBAM module are introduced into Concat for further fusion. The effect of serially passing two 3×3 MaxPooling layers and two 5×5 MaxPooling layers is equivalent to a 13×13 MaxPooling layer, but the SPPF+ module has less computational complexity and is more efficient.
[0076] S33: Replace the intersection-over-union (CIoU) loss function in the YOLOv5 model with the effective intersection-over-union (EIoU) loss function. The advantage of EIoU is that the aspect ratio of the target box and the prediction box in the penalty term is calculated separately, which reduces the difference in width and height between the target box and the prediction box during model training and speeds up the model training process. The mathematical expression of the EIoU loss function is:
[0077]
[0078] Among them, EIoU represents the loss of the intersection of the target bounding rectangle box and the predicted bounding rectangle box, Io U represents the ratio of the intersection of the target box and the predicted box to the union of the target box and the predicted box, ρ 2 (b,b gt ) represents the Euclidean distance between the center point of the prediction box and the target box, b represents the coordinates of the center point of the prediction box, and b gt represents the coordinates of the center point of the target box, c represents the diagonal distance of the minimum rectangle containing the prediction box and the target box, ρ 2 (w,w gt ) represents the Euclidean distance between the prediction box and the target box width, w represents the width of the prediction box, and w gt Indicates the width of the target box, c w Represents the width of the minimum rectangle containing the prediction box and the target box, ρ 2 (h,h gt ) represents the Euclidean distance between the predicted box and the target box height, h represents the height of the predicted box, and h gt Indicates the height of the target box, c h Indicates the height of the minimum rectangle that can contain both the prediction box and the target box.
[0079] S4. Use the pre-processed hippocampus data set to train the optimized YOLOv5 network model, and use the trained model to detect the status of artificially cultured hippocampus.
[0080] The optimized model is trained using the S2 preprocessed hippocampus dataset. First, data augmentation is performed on the preprocessed hippocampus dataset. Data augmentation includes Moasic data augmentation, Copy paste data augmentation, and Randomomaffine. Moasic data augmentation is to splice four images into one image, which is equivalent to increasing the batch size (BatchSize), so that the variance can be effectively reduced during the model training process to achieve the effect of increasing data diversity; Copy paste data augmentation is to copy the manually annotated targets in different images and splice them into other images; Random affire data augmentation includes randomly rotating, scaling, translating, and shearing the image.
[0081] The model is used to detect the state of artificially cultured seahorses. After data enhancement, the image is processed and the features of abnormal seahorse states are extracted through the Backbone network. The input image is a 640*640*3 seahorse image. After multiple convolution operations of the Backbone network, a 20*20*1024 feature map is obtained. Finally, the image is divided into several grids through the Head network, and the grid at the center of the detection target is responsible for completing the abnormal detection of the seahorse state in the image.
[0082] Embodiment 2
[0083] A hippocampal skin condition detection system based on an improved YOLOv5 algorithm, the system includes an image acquisition module, a preprocessing module, a network improvement module and a condition detection module;
[0084] The image acquisition module is used to acquire a hippocampus image, and perform normal skin labeling and abnormal skin labeling on the acquired hippocampus image to obtain an original hippocampus data set;
[0085] The preprocessing module is used to preprocess the original hippocampal dataset to obtain a preprocessed hippocampal dataset;
[0086] The network improvement model is used to optimize and improve the YOLOv5 network model using the CBAM module, the SPPF+ module and the effective intersection-over-union loss function;
[0087] The condition detection module is used to train the optimized YOLOv5 network model using the preprocessed hippocampus data set, and use the trained model to detect the skin condition of artificially cultured hippocampi.
[0088] Optionally, the implementation process of the image acquisition module specifically includes:
[0089] Calculating the normalized frequency of the grayscale statistical histogram of the original hippocampal image in the original hippocampal data set;
[0090] Approximate the frequency distribution to the probability distribution, calculate the transformation function of the histogram equalization, and obtain the grayscale cumulative histogram of the image through the transformation function;
[0091] According to the grayscale cumulative histogram, the dynamic range of the pixel grayscale value is increased to enhance the overall contrast of the image, and a preprocessed hippocampal image is obtained, which together with the annotation content constitutes a preprocessed hippocampal data set, specifically including:
[0092] Calculate the normalized frequency of the grayscale statistical histogram of the original hippocampal image:
[0093]
[0094] Among them, p r (r k ) is the normalized frequency of the grayscale statistical histogram of the original hippocampal image, r k is the normalized gray level, n k is the number of pixels with gray level k in the image, k = 0, 1, 2, ..., L-1, indicating the gray level before normalization, L is the number of gray levels, and N is the total number of pixels in the original hippocampal image;
[0095] Approximate the frequency distribution to the probability distribution, calculate the transformation function of the histogram equalization, and obtain the grayscale cumulative histogram of the image through the transformation function:
[0096]
[0097] Among them, T(r k ) is the transformation function of histogram equalization, and the processed image after histogram equalization can be obtained according to the transformation function.
[0098] Optionally, the implementation process of the network improvement module includes:
[0099] The method for optimizing and improving the YOLOv5 network model using the CBAM module includes: adding the CBAM module to the Backbone network to optimize the YOLOv5 network model; the specific method is to add the CBAM module after the convolution layer of the Backbone network, input the output of the convolution layer into the CBAM module, extract the key features of the hippocampal skin abnormality in the image, adjust the spatial dimension of the image feature map, and obtain the output of the CBAM module;
[0100] The method for optimizing and improving the YOLOv5 network model using the SPPF+ module includes: replacing the SPPF module in the Neck network with SPFF+ to optimize the YOLOv5 network model. The specific method includes: the structure of the original SPPF module is to input the output of the CBAM module serially into three 5×5 MaxPooling layers, and then fuse the output of the three MaxPooling layers with the output of the CBAM module. After the convolution operation, the output result of the Backbone network is obtained; the optimized SPPF+ module is as follows Figure 3 As shown, the structure is that the output of the CBAM module is serially input into two 3×3 MaxPooling layers and two 5×5 MaxPooling layers, and the output of the four MaxPooling layers and the output of the CBAM module are fused, and after the convolution operation, the output result of the Backbone network is obtained;
[0101] Methods for optimizing and improving the YOLOv5 network model using an effective intersection-over-union loss function include:
[0102] Use the effective intersection-over-union loss function EIoU to optimize and improve the YOLOv5 network model:
[0103]
[0104] Among them, EIoU represents the loss of the intersection of the target bounding rectangle box and the predicted bounding rectangle box, Io U represents the ratio of the intersection of the target box and the predicted box to the union of the target box and the predicted box, ρ 2 (b,b gt ) represents the Euclidean distance between the center point of the prediction box and the target box, b represents the coordinates of the center point of the prediction box, and b gt represents the coordinates of the center point of the target box, c represents the diagonal distance of the minimum rectangle containing the prediction box and the target box, ρ 2 (w,w gt ) represents the Euclidean distance between the prediction box and the target box width, w represents the width of the prediction box, and w gt Indicates the width of the target box, c w Represents the width of the minimum rectangle containing the prediction box and the target box, ρ 2 (h,h gt ) represents the Euclidean distance between the height of the prediction box and the target box, h represents the height of the prediction box, and h gt Indicates the height of the target box, c h Indicates the height of the minimum rectangle that can contain both the prediction box and the target box.
[0105] The implementation process of the status detection module includes: using the preprocessed seahorse dataset to train the optimized YOLOv5 network model, and using the trained model to detect the status of artificially cultured seahorses specifically includes:
[0106] The improved YOLOv5 network model is trained using the preprocessed hippocampal dataset. The preprocessed dataset images are augmented and input into the improved YOLOv5 network model. The optimized Backbone network of the YOLOv5 network model extracts the abnormal features of the hippocampal skin from it.
[0107] The Head network block of the optimized YOLOv5 network model is used to divide the image into several grids, and the state detection of artificially cultured seahorses is achieved based on the grids.
[0108] The embodiments described above are only descriptions of the preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope determined by the claims of the present invention.
Claims
1. A hippocampal skin state detection method based on an improved YOLOv5 algorithm, characterized in that: The method comprises: S1, obtaining a hippocampus image, and annotating the normal skin and abnormal skin of the obtained hippocampus image to obtain an original hippocampus dataset; S2, preprocessing the original hippocampus data set to obtain a preprocessed hippocampus data set; S3. Optimize YOLOv5 using the CBAM module, SPPF+ module and the effective intersection-over-union loss function. S4. Use the preprocessed hippocampus dataset to train the optimized YOLOv5 network model, and use the trained model to detect the skin condition of artificially cultured hippocampus.
2. The hippocampal skin state detection method based on the improved YOLOv5 algorithm according to claim 1, characterized in that: In S1, a hippocampus image is obtained, and normal skin annotation and abnormal skin annotation are performed on the obtained hippocampus image to obtain the content of the original hippocampus data set. The specific method includes: A hippocampus image in seawater is obtained, and body parts of a normal hippocampus and an abnormal hippocampus in the hippocampus image are annotated, wherein the annotated contents include head annotating, trunk annotating, abdomen annotating and tail annotating of a normal hippocampus; and head annotating, trunk annotating, abdomen annotating and tail annotating of an abnormal hippocampus.
3. The hippocampal skin state detection method based on the improved YOLOv5 algorithm according to claim 2, characterized in that: In S2, the method of preprocessing the original hippocampal dataset to obtain the preprocessed hippocampal dataset specifically includes: Use histogram equalization to preprocess the original hippocampus images in the original hippocampus dataset: S21, calculating the normalized frequency of the grayscale statistical histogram of the original hippocampal image, specifically comprising: Among them, p r (r k ) is the normalized frequency of the grayscale statistical histogram of the original hippocampal image, r k is the normalized gray level, n k is the number of pixels with gray level k in the image, k = 0, 1, 2, ..., L-1, represents the gray level before normalization, L is the number of gray levels, and N is the total number of pixels in the original image; S22, approximating the frequency distribution to a probability distribution, calculating a transformation function of the histogram equalization, and obtaining a grayscale cumulative histogram of the original hippocampal image through the transformation function, specifically including: Among them, T(r k ) is a transformation function of histogram equalization, and a processed image after histogram equalization can be obtained according to the transformation function; S23, increasing the dynamic range of pixel grayscale values according to the grayscale cumulative histogram, enhancing the overall contrast of the image, and obtaining a preprocessed hippocampal image, which together with the annotated content constitutes a preprocessed hippocampal data set.
4. The hippocampal skin state detection method based on the improved YOLOv5 algorithm according to claim 1, characterized in that: In S3, the method for optimizing and improving the YOLOv5 network model using the CBAM module, the SPPF module and the effective intersection-over-union loss function specifically includes: S31. The method for optimizing and improving the YOLOv5 network model using the CBAM module includes: adding the CBAM module to the Backbone network to optimize the YOLOv5 network model; the specific method is to add the CBAM module after the convolution layer of the Backbone network, input the output of the convolution layer into the CBAM module, extract the key features of the hippocampal skin abnormalities in the pre-processed hippocampal data set, adjust the spatial dimension of the feature map, and obtain the output of the CBAM module; S32. The method for optimizing and improving the YOLOv5 network model using the SPPF+ module includes: replacing the SPPF module in the Neck network with SPFF+ to optimize the YOLOv5 network model. The specific method includes: the structure of the original SPPF module is: the output of the CBAM module is serially input to three 5×5 MaxPooling layers, and then the outputs of the three MaxPooling layers are fused with the output of the CBAM module, and after the convolution operation, the output result of the Backbone network is obtained; the output of the CBAM module is serially input to two 3×3 MaxPooling layers and two 5×5 MaxPooling layers, and the outputs of the four MaxPooling layers are fused with the output of the CBAM module, and after the convolution operation, the output result of the Backbone network is obtained; S33. Methods for optimizing and improving the YOLOv5 network model using an effective intersection-over-union loss function include: Use the effective intersection-over-union loss function EIoU to optimize and improve the YOLOv5 network model: Among them, EIoU represents the loss of the intersection of the target bounding rectangle box and the predicted bounding rectangle box, Io U represents the ratio of the intersection of the target box and the predicted box to the union of the target box and the predicted box, ρ 2 (b,b gt ) represents the Euclidean distance between the center point of the prediction box and the target box, b represents the coordinates of the center point of the prediction box, and b gt represents the coordinates of the center point of the target box, c represents the diagonal distance of the minimum rectangle containing the prediction box and the target box, ρ 2 (w,w gt ) represents the Euclidean distance between the prediction box and the target box width, w represents the width of the prediction box, and w gt Indicates the width of the target box, c w Represents the width of the minimum rectangle containing the prediction box and the target box, ρ 2 (h,h gt ) represents the Euclidean distance between the height of the prediction box and the target box, h represents the height of the prediction box, and h gt Indicates the height of the target box, c h Indicates the height of the minimum rectangle that can contain both the prediction box and the target box.
5. The hippocampal skin state detection method based on the improved YOLOv5 algorithm according to claim 1, characterized in that: The process of training the optimized YOLOv5 network model using the pre-processed hippocampus dataset and detecting the state of artificially cultured hippocampus using the trained model specifically includes: The improved YOLOv5 network model is trained using the pre-processed hippocampal dataset, the pre-processed hippocampal dataset is data-enhanced and input into the improved YOLOv5 network model, and the Backbone network of the improved YOLOv5 network model extracts the abnormal features of hippocampal skin from the dataset; The Head network block of the YOLOv5 network model is used to divide the image into several grids, and the state of the artificially cultured seahorse is detected based on the grids.
6. A hippocampal skin state detection system based on an improved YOLOv5 algorithm, the system being used to implement the state detection method according to any one of claims 1 to 5, characterized in that: The system includes an image acquisition module, a preprocessing module, a network improvement module and a condition detection module; The image acquisition module is used to acquire a hippocampus image, and perform normal skin labeling and abnormal skin labeling on the acquired hippocampus image to obtain an original hippocampus data set; The preprocessing module is used to preprocess the original hippocampal dataset to obtain a preprocessed hippocampal dataset; The network improvement module is used to optimize YOLOv5 using the CBAM module, the SPPF+ module and the effective intersection-over-union loss function; The state detection module is used to train the optimized YOLOv5 network model using the preprocessed hippocampus data set, and use the trained model to detect the skin state of artificially cultured hippocampus.
7. The hippocampal skin state detection system based on the improved YOLOv5 algorithm according to claim 6, characterized in that: The implementation process of the image acquisition module specifically includes: Calculating the normalized frequency of the grayscale statistical histogram of the original hippocampus image in the original hippocampus data set specifically includes: Among them, p r (r k ) is the normalized frequency of the grayscale statistical histogram of the original hippocampal image, r k is the normalized gray level, n k is the number of pixels with gray level k in the image, k = 0, 1, 2, ..., L-1, indicating the gray level before normalization, L is the number of gray levels, and N is the total number of pixels in the original hippocampal image; Approximate the frequency distribution to the probability distribution, calculate the transformation function of the histogram equalization, and obtain the grayscale cumulative histogram of the image through the transformation function, including: Among them, T(r k ) is a transformation function of histogram equalization, and a processed image after histogram equalization can be obtained according to the transformation function; The dynamic range of the pixel grayscale value is increased according to the grayscale cumulative histogram, the overall contrast of the image is enhanced, and a preprocessed hippocampal image is obtained, which together with the annotation content constitutes a preprocessed hippocampal data set.
8. The hippocampal skin state detection system based on the improved YOLOv5 algorithm according to claim 6, characterized in that: The implementation process of the network improvement module includes: The method for optimizing and improving the YOLOv5 network model using the CBAM module includes: adding the CBAM module to the Backbone network to optimize and improve the YOLOv5 network model; the specific method is to add the CBAM module after the convolution layer of the Backbone network, input the output of the convolution layer into the CBAM module, extract the key features of the hippocampal skin abnormalities in the image, adjust the spatial dimension of the image feature map, and obtain the output of the CBAM module; The method for optimizing and improving the YOLOv5 network model using the SPPF+ module includes: replacing the SPPF module in the Neck network with SPFF+ to optimize the YOLOv5 network model. The specific method includes: the structure of the original SPPF module is: the output of the CBAM module is serially input to three 5×5 MaxPooling layers, and then the outputs of the three MaxPooling layers are fused with the output of the CBAM module, and after the convolution operation, the output result of the Backbone network is obtained; the output of the CBAM module is serially input to two 3×3 MaxPooling layers and two 5×5 MaxPooling layers, and the outputs of the four MaxPooling layers are fused with the output of the CBAM module, and after the convolution operation, the output result of the Backbone network is obtained; Methods for optimizing and improving the YOLOv5 network model using an effective intersection-over-union loss function include: Use the effective intersection-over-union loss function EIoU to optimize and improve the YOLOv5 network model: Among them, EIoU represents the loss of the intersection of the target bounding rectangle box and the predicted bounding rectangle box, Io U represents the ratio of the intersection of the target box and the predicted box to the union of the target box and the predicted box, ρ 2 (b,b gt ) represents the Euclidean distance between the center point of the prediction box and the target box, b represents the coordinates of the center point of the prediction box, and b gt represents the coordinates of the center point of the target box, c represents the diagonal distance of the minimum rectangle containing the prediction box and the target box, ρ 2 (w,w gt ) represents the Euclidean distance between the prediction box and the target box width, w represents the width of the prediction box, and w gt Indicates the width of the target box, c w Represents the width of the minimum rectangle containing the prediction box and the target box, ρ 2 (h,h gt ) represents the Euclidean distance between the height of the prediction box and the target box, h represents the height of the prediction box, and h gt Indicates the height of the target box, c h Indicates the height of the minimum rectangle that can contain both the prediction box and the target box.
9. The hippocampal skin state detection system based on the improved YOLOv5 algorithm according to claim 6, characterized in that: The implementation process of the status detection module includes: using the pre-processed hippocampus data set to train the optimized YOLOv5 network model, and using the trained model to detect the status of artificially cultured hippocampus specifically includes: The improved YOLOv5 network model is trained using the pre-processed hippocampal dataset, the pre-processed hippocampal dataset is data-enhanced and input into the improved YOLOv5 network model, and the Backbone network of the improved YOLOv5 network model extracts the abnormal features of hippocampal skin from the dataset; The Head network block of the YOLOv5 network model is used to divide the image into several grids, and the state of the artificially cultured seahorse is detected based on the grids.
