CN115661628A - Fish detection method based on improved YOLOv5S model - Google Patents
Fish detection method based on improved YOLOv5S model Download PDFInfo
- Publication number
- CN115661628A CN115661628A CN202211339303.7A CN202211339303A CN115661628A CN 115661628 A CN115661628 A CN 115661628A CN 202211339303 A CN202211339303 A CN 202211339303A CN 115661628 A CN115661628 A CN 115661628A
- Authority
- CN
- China
- Prior art keywords
- model
- yolov5s
- improved
- fish
- prediction
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02A—TECHNOLOGIES FOR ADAPTATION TO CLIMATE CHANGE
- Y02A40/00—Adaptation technologies in agriculture, forestry, livestock or agroalimentary production
- Y02A40/80—Adaptation technologies in agriculture, forestry, livestock or agroalimentary production in fisheries management
- Y02A40/81—Aquaculture, e.g. of fish
Landscapes
- Image Analysis (AREA)
Abstract
The invention discloses a fish detection method based on an improved YOLOv5S model, which comprises the following steps: collecting a fish image dataset; performing data enhancement processing on the data set; improving a YOLOv5s neural network; including (1) adding an SE attention module to the C3 module. (2) The underlying convolution operation in CSP is replaced with a deep separable convolution. (3) Changing a frame loss function in the original YOLOv5 from a complete intersection ratio loss function (CIOU) to an effective intersection ratio loss function (EIOU); after the data set is subjected to labeling processing, the data set is sent to an improved YOLOv5s neural network for training and then is tested. The invention can realize the detection and identification of fish, can better protect marine fish resources and promote the healthy and sustainable development of the fish resources; and can provide a reference scheme for the monitoring and identification of other marine organisms.
Description
Technical Field
The invention relates to the field of deep learning target detection, in particular to a fish detection method based on an improved YOLOv5S model.
Background
The ocean is the largest ecosystem on earth, which contains an extremely abundant biological resource. Although the ocean area of China is more than 300 ten thousand square kilometers, fishery resources are extremely important resources in ocean resources, and the trend of continuous decline is shown in recent years. This is mainly because of the increasing of fishing strength for fish resources and the unordered fishing for fish resources in recent years. This fishing greatly impairs the otherwise fragile marine ecological environment. It is therefore necessary to monitor the species and quantity of fish.
The traditional monitoring method mainly depends on supervision of an observer on a ship or carries out manual analysis after a fishing video is shot by using a camera of a fishing boat, and the like, but the modes have stronger dependence on people, and the working state of the people is often influenced by external factors. After long repetitive work, the physical state and emotion of a person may fluctuate greatly. And the problems of overhigh cost, low efficiency and the like can also exist by depending on manual supervision.
Disclosure of Invention
The invention aims to provide a fish detection algorithm based on an improved YOLOv5S model, which can overcome many defects existing in the traditional manual fish species identification, and can automatically detect the fish and identify the species to which the fish belongs by the method;
in order to achieve the above purpose, the technical scheme adopted by the invention comprises the following steps:
s1, obtaining fish image data, labeling the data, and dividing the labeled fish image data into a training set, a verification set and a test set;
and S2, constructing a YOLOv5S model, wherein the model specifically comprises Backbone, sock and Prediction. The backhaul is a core module of a YOLOv5S model and consists of Focus, C3, SPP and other modules; the neck consists of an FPN + PAN structure; the Prediction is a loss function of the detection model; an improvement to the YOLOv5S model involves adding the SE attention module to the C3 module in the YOLOv5S model, using deep separable convolution instead of the basic convolution operation in CSP. And changing the frame loss function in the original YOLOv5s from a complete cross ratio loss function (CIOU) to an effective cross ratio loss function (EIOU). Obtaining an improved YOLOv5S model;
s3, sending the training set obtained in the step S1 into the improved YOLOv5S model obtained in the step S2 for training; then, verification is carried out through the verification set obtained in the step S1, and parameter tuning is carried out on the improved YOLOv5S model according to the verification result; finally, carrying out model test on the improved YOLOv5S model through the test set obtained in the step S1, storing the model after the test is passed and taking the model as a detection model;
s4, inputting Chinese medicinal material image data to be detected into the detection model, and detecting the Chinese medicinal material image to be detected through the detection model;
further, labeling each traditional Chinese medicine picture by using a LabelImg tool in the step S1;
further, the division ratio of the training set, the verification set and the test set in the step S1 is 7:2: 1;
further, the SE attention module in step S2 performs global average pooling on the input feature map to reduce the feature map to 1 × 1, then establishes connection between channels using two full connection layers and a nonlinear activation function, finally obtains normalized weight through a Sigmoid activation function, and then weights the original feature map channel by channel through multiplication to complete recalibration of the original feature;
further, in the step S2, EIOU is:
wherein, E Iou Represents the loss of the intersection ratio IoU of the overlapping portions of two rectangular frames, L dis Denotes the distance loss, L asp Represents the side length loss; rho 2 (b,b gt ) Representing Euclidean distance between the center points of the prediction frame and the real frame, b representing the coordinate of the center point of the prediction frame, b gt Coordinates representing the center point of the real box, gt represents the real value, c represents the diagonal distance of the minimum closure area that can contain both the predicted box and the real box,ρ 2 (w,w gt ) Euclidean distance representing the width of the prediction frame and the real frame, w represents the width of the prediction frame, w gt Width of the real box, C w Width, ρ, representing the minimum closure area that can contain both the prediction box and the real box 2 (h,h gt ) The Euclidean distance representing the height of the prediction frame and the real frame, h represents the height of the prediction frame gt Representing the height of the real box; c h A height representing a minimum closure area that can contain both the prediction box and the real box;
further, in the step S3, the data in the training set is subjected to rotation, translation, scaling, random illumination and Mosaic8 enhancement operations. Then, the processed data is sent to an improved YOLOv5S model for training;
compared with the prior art, the invention has the beneficial effects that: the fish detection model built by the single-stage detection model based on the improved YOLOv5S has the advantages of high identification speed and capability of processing a large number of fish pictures. Meanwhile, the added SE attention module can enable the model to pay more attention to certain discriminative characteristics of the fishes, so that the detection precision is improved. The use of depth separable convolution can further reduce the amount of parameters and thus increase the detection speed. The EIoU frame regression loss function is used, the loss function unpacks the influence factors of the aspect ratio on the basis of the penalty term of the original CIOU loss function to respectively calculate the loss functions of the height and the width of the target frame and the anchor frame, and the new width and height loss directly minimizes the difference between the width and the height of the target frame and the anchor frame, so that the convergence speed is higher;
drawings
Fig. 1 is a schematic flow chart based on an improved YOLOv5S model according to the present invention.
Fig. 2 is a schematic diagram of a channel-by-channel convolution based on the improved YOLOv5S model according to the present invention.
FIG. 3 is a schematic diagram of a point-by-point convolution based on the improved YOLOv5S model according to the present invention.
FIG. 4 is a schematic flow chart of the present invention for enhancing motion data based on the improved YOLOv5S model.
Detailed Description
Example (b):
fig. 1 is a flowchart of a fish detection method based on an improved YOLOV5S model according to an embodiment of the present invention. The specific steps are as follows:
s1, collecting fish image data, performing labeling processing and normalization processing on the fish image data, and dividing the fish image data into a training set, a verification set and a test set;
and S11, labeling by using a LabelImg tool, wherein the labeling can generate an XML label file, and the file name corresponds to the picture name. Then carrying out normalization processing on the obtained product;
a further, normalized formula is:
wherein, (width, height) represents the original width of the picture, (x) max ,y max ),(x min ,y min ) Position information of the upper left corner and the lower right corner of the original sample bounding box, (x, y), (w, h) are respectively the coordinate of the central point and the width and the height after target normalization;
and S12, dividing the processed data into a training set, a verification set and a test set. The ratio of the components is 7:2: 1;
s2, constructing an improved YOLOv5S network model;
s21 adds an SE attention module to the C3 module of the original YOLOv5S network. The SE attention module performs global average pooling on the input feature map to reduce the feature map to 1 × 1, then establishes connection between channels by using two full-connection layers and a nonlinear activation function, finally obtains normalized weight through a Sigmoid activation function, and then weights the original feature map channel by channel through multiplication to complete recalibration of the original feature;
s22 replaces the underlying convolution operation in the CSP module of the original YOLOv5S network with a deep separable convolution. The depth separable convolution is mainly divided into two steps, channel-by-channel convolution and point-by-point convolution. Firstly, channel-by-channel convolution is performed, as shown in fig. 2, the number of convolution kernels is equal to the dimension of the input feature diagram, and different from ordinary convolution, each convolution kernel corresponds to one channel in channel-by-channel convolution. Next, point-by-point convolution is performed, schematically shown in fig. 3, which is similar to the ordinary convolution, where the size of the convolution kernel is M × 1, and M is the number of channels of the feature map output by the previous layer, and the convolution operation here weights and combines the feature maps generated by the channel-by-channel convolution in the channel direction to generate a new feature map;
s23, changing the frame loss function in the original YOLOv5S from a complete cross ratio loss function (CIOU) to an effective cross ratio loss function (EIOU). The expression of EIOU is shown below;
expression of EIOU:
E Iou represents the loss of the intersection ratio IoU of the overlapping portions of two rectangular frames, L dis Denotes the distance loss, L asp Representing the loss of side length; ρ is a unit of a gradient 2 (b,b gt ) Euclidean distance representing the central points of the prediction frame and the real frame, b represents the coordinate of the central point of the prediction frame, b gt Coordinates representing the center point of the real box, gt represents the real value, c represents the diagonal distance of the minimum closure area capable of containing both the predicted box and the real box, ρ 2 (w,w gt ) Euclidean distance representing the width of the prediction frame and the real frame, w represents the width of the prediction frame, w gt Width, C, representing real box w Width, ρ, representing the minimum closure area that can contain both the prediction box and the real box 2 (h,h gt ) The Euclidean distance representing the height of the prediction frame and the real frame, h represents the height of the prediction frame gt Representing the height of the real box; c h Represents the height of the minimum closure area that can contain both the prediction box and the real box;
s3, training and testing the built YOLOv5S neural network model;
firstly, carrying out image data enhancement processing on a training set;
s31, the data enhancement processing comprises the steps of carrying out random gamma transformation, random perspective transformation, random brightness-contrast transformation and noise-motion blur addition on the image;
s32 needs to be subjected to dynamic data enhancement processing after the enhancement processing. The motion flow is shown in fig. 4, and the motion data enhancement processing is to splice four images by means of random scaling, random clipping and random arrangement of each four image data; the data set can be effectively enriched by using motion data enhancement processing, the number of targets is increased, four pictures are spliced together, namely phase change is realized, the BatchSize is improved, and the statistics of variance and mean value can be better carried out during batch averaging processing;
and then training the improved YOLOv5S neural network by using the training set and the verification set and testing the trained model by using the test set, wherein the method specifically comprises the following steps:
s33, preparing two folders which are respectively a label folder and an image data set folder, wherein three folders are arranged below the image data set folder and respectively correspond to the divided training set, the divided verification set and the divided testing set. XML label files are stored in the label folder;
s34, training by using a PyTorch neural network framework;
s35, setting model hyper-parameters including BatchSize, iteration times, learning rate adjustment strategy and selection of an optimizer;
and S36, training to model convergence by using the training set, and performing verification and parameter tuning by using the verification set in the training process. Storing the obtained weight file after passing the test;
s37, testing the trained model by using the test set data in the step S33;
s4, inputting Chinese medicinal material image data to be detected into the tested detection model, and then detecting and processing the Chinese medicinal material image to be detected through the detection model;
the previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (6)
1. A fish detection method based on an improved YOLOv5S model is characterized in that: the method comprises the following steps:
s1, obtaining fish image data, labeling the data, and dividing the labeled fish image data into a training set, a verification set and a test set;
s2, constructing a YOLOv5S model, wherein the model specifically comprises Backbone, sock and Prediction; the Backbone is a core module of a YOLOv5S model and consists of Focus, C3, SPP and other modules; the neck consists of an FPN + PAN structure; the Prediction is a loss function of the detection model; the improvement to the YOLOv5S model includes adding an SE attention module to the C3 module in the YOLOv5S model, using deep separable convolution instead of the basic convolution operation in CSP; and changing the frame loss function in the original YOLOv5s from a complete cross ratio loss function (CIOU) to an effective cross ratio loss function (EIOU); obtaining an improved YOLOv5S model;
s3, performing data enhancement processing on the training set obtained in the step S1, and then sending the training set to the improved YOLOv5S model obtained in the step S2 for training; then, verification is carried out through the verification set obtained in the step S1, and parameter tuning is carried out on the improved YOLOv5S model according to the verification result; finally, performing model test on the improved YOLOv5S model through the test set obtained in the step S1, and storing the model after the test is passed and using the model as a detection model;
and S4, inputting the Chinese medicinal material image data to be detected into the detection model, and then detecting and processing the Chinese medicinal material image to be detected through the detection model.
2. The fish detection method based on the improved YOLOv5S model as claimed in claim 1, wherein in step S1, labelImg tool is used to label each Chinese medicine picture.
3. The fish detection method based on the improved YOLOv5S model of claim 1, wherein the training set, the verification set and the test set are divided into 7:2:1.
4. the fish detection method based on the improved YOLOv5S model as claimed in claim 1, wherein in step S2, the SE attention module performs global average pooling on the input feature map to reduce the feature map to 1 × 1, then establishes inter-channel connections using two fully connected layers and a nonlinear activation function, finally obtains normalized weights through a Sigmoid activation function, and then weights the original feature map channel by channel through multiplication to complete the recalibration of the original feature.
5. The fish detection method based on the improved YOLOv5S model of claim 1, wherein the EIOU loss function in step S2 is:
wherein E is Iou Represents the loss of the intersection ratio IoU of the overlapping portions of the two rectangular frames, L dis Denotes the distance loss, L asp Represents the side length loss; rho 2 (b,b gt ) Representing Euclidean distance between the center points of the prediction frame and the real frame, b representing the coordinate of the center point of the prediction frame, b gt Coordinates representing the center point of the real box, gt represents the real value, c represents the diagonal distance of the minimum closure area that can contain both the prediction box and the real box, ρ 2 (w,w gt ) Euclidean distance representing the width of the prediction frame and the real frame, w represents the width of the prediction frame, w gt Width, C, representing real box w Width, ρ, representing the minimum closure area that can contain both the prediction box and the real box 2 (h,h gt ) The Euclidean distance representing the height of the prediction frame and the real frame, h represents the height of the prediction frame gt Representing the height of the real box; c h Represents the height of the minimum closure area that can contain both the prediction box and the real box.
6. The fish detection method based on the improved YOLOv5S model of claim 1, wherein in step S3, the data in the training set is subjected to rotation, translation, scaling, random illumination and Mosaic8 enhancement operations; and then the processed data is sent to an improved YOLOv5S model for training.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211339303.7A CN115661628A (en) | 2022-10-28 | 2022-10-28 | Fish detection method based on improved YOLOv5S model |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211339303.7A CN115661628A (en) | 2022-10-28 | 2022-10-28 | Fish detection method based on improved YOLOv5S model |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115661628A true CN115661628A (en) | 2023-01-31 |
Family
ID=84992765
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211339303.7A Pending CN115661628A (en) | 2022-10-28 | 2022-10-28 | Fish detection method based on improved YOLOv5S model |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115661628A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115588117A (en) * | 2022-10-17 | 2023-01-10 | 华南农业大学 | Citrus psylla detection method and system based on YOLOv5s-BC |
CN116245732A (en) * | 2023-03-13 | 2023-06-09 | 江南大学 | Yolov 5-based small-target reflective garment identification and detection method |
CN116704487A (en) * | 2023-06-12 | 2023-09-05 | 三峡大学 | License plate detection and recognition method based on Yolov5s network and CRNN |
CN117036985A (en) * | 2023-10-09 | 2023-11-10 | 武汉工程大学 | Small target detection method and device for video satellite image |
-
2022
- 2022-10-28 CN CN202211339303.7A patent/CN115661628A/en active Pending
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115588117A (en) * | 2022-10-17 | 2023-01-10 | 华南农业大学 | Citrus psylla detection method and system based on YOLOv5s-BC |
CN115588117B (en) * | 2022-10-17 | 2023-06-09 | 华南农业大学 | Method and system for detecting diaphorina citri based on YOLOv5s-BC |
CN116245732A (en) * | 2023-03-13 | 2023-06-09 | 江南大学 | Yolov 5-based small-target reflective garment identification and detection method |
CN116704487A (en) * | 2023-06-12 | 2023-09-05 | 三峡大学 | License plate detection and recognition method based on Yolov5s network and CRNN |
CN116704487B (en) * | 2023-06-12 | 2024-06-11 | 三峡大学 | License plate detection and identification method based on Yolov s network and CRNN |
CN117036985A (en) * | 2023-10-09 | 2023-11-10 | 武汉工程大学 | Small target detection method and device for video satellite image |
CN117036985B (en) * | 2023-10-09 | 2024-02-06 | 武汉工程大学 | Small target detection method and device for video satellite image |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN115661628A (en) | Fish detection method based on improved YOLOv5S model | |
CN113537106B (en) | Fish ingestion behavior identification method based on YOLOv5 | |
CN105069746B (en) | Video real-time face replacement method and its system based on local affine invariant and color transfer technology | |
CN111340141A (en) | Crop seedling and weed detection method and system based on deep learning | |
CN113435282B (en) | Unmanned aerial vehicle image ear recognition method based on deep learning | |
CN111738344A (en) | Rapid target detection method based on multi-scale fusion | |
CN107657008A (en) | Across media training and search method based on depth discrimination sequence study | |
CN111242127A (en) | Vehicle detection method with granularity level multi-scale characteristics based on asymmetric convolution | |
CN113420643B (en) | Lightweight underwater target detection method based on depth separable cavity convolution | |
CN110163798B (en) | Method and system for detecting damage of purse net in fishing ground | |
CN115205667A (en) | Dense target detection method based on YOLOv5s | |
CN110827312A (en) | Learning method based on cooperative visual attention neural network | |
CN117029673B (en) | Fish body surface multi-size measurement method based on artificial intelligence | |
CN112668445A (en) | Vegetable type detection and identification method based on yolov5 | |
CN115601562A (en) | Fancy carp detection and identification method using multi-scale feature extraction | |
CN115063650A (en) | Light-weight real-time target detection method | |
Kiratiratanapruk et al. | Automatic detection of rice disease in images of various leaf sizes | |
CN112070181B (en) | Image stream-based cooperative detection method and device and storage medium | |
CN116805360B (en) | Obvious target detection method based on double-flow gating progressive optimization network | |
CN117079125A (en) | Kiwi fruit pollination flower identification method based on improved YOLOv5 | |
CN115588117B (en) | Method and system for detecting diaphorina citri based on YOLOv5s-BC | |
CN116452965A (en) | Underwater target detection and recognition method based on acousto-optic fusion | |
CN115578624A (en) | Agricultural disease and pest model construction method, detection method and device | |
CN113673478A (en) | Port large-scale equipment detection and identification method based on depth panoramic stitching | |
CN113284164A (en) | Shrimp swarm automatic counting method and device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |