Improvement of yolo v5 network-based illegal grazing detection method and system
By improving the YOLOv5 network, replacing the network structure and convolution method, and building a lightweight model, the problems of detection speed and accuracy in UAV inspection were solved, and efficient detection of illegal sheep grazing was achieved.
Patent Information
- Application Number
- CN202310698648.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-13
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2043-06-13
AI Technical Summary
Existing target detection methods struggle to improve detection speed while maintaining sufficient accuracy, especially in drone inspections where computational resources are limited, and suitable algorithm models are lacking.
An improved YOLOv5 network model was trained for sheep violation detection by replacing the BottleNeckCSP module with the GhostBottleNeck module, replacing ordinary convolutions with depthwise separable convolutions, and constructing training and dataset sets.
It improves the efficiency and accuracy of detecting illegal sheep grazing, reduces network parameters, improves computational efficiency, realizes lightweight model design, and enhances robustness to spatial layout and target recognition.
Smart Images

Figure CN116778361B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of beach area inspection and prevention technology, and in particular to a method and system for detecting illegal sheep grazing based on an improved YOLOv5 network. Background Technology
[0002] The statements in this section merely refer to the background art related to this invention and do not necessarily constitute prior art.
[0003] In recent years, drone technology has been widely used in many fields, especially in inspection and prevention. By mounting cameras and transmitting real-time footage, drones can largely replace manual inspections and significantly improve inspection efficiency. Furthermore, the real-time drone footage, combined with backend image processing algorithms, enables automatic and rapid target detection.
[0004] In recent years, deep learning algorithms related to object detection have developed rapidly, and various methods derived from Convolutional Neural Networks (CNNs) have been widely used. Among them, the YOLOv5 algorithm has far surpassed previous generations of algorithms in terms of detection accuracy and speed, enabling it to greatly meet the real-time requirements of UAV inspection processes.
[0005] On the other hand, the inspection function has high requirements for real-time target detection, but the onboard computing resources of UAVs are limited, making it difficult to deploy real-time detection models and improve real-time detection speed. Overall, the effectiveness and performance of current deep learning-based UAV target detection algorithms still have considerable room for improvement, requiring high-performance computing and a large amount of memory, and lacking suitable algorithm models that can be deployed on practical project platforms.
[0006] The inventors discovered that the existing technology has the following technical problems: existing target detection methods are difficult to improve detection speed while ensuring sufficient accuracy. Summary of the Invention
[0007] To address the shortcomings of existing technologies, this invention provides a method and system for detecting illegal sheep grazing based on an improved YOLOv5 network; it can be applied to the automatic detection of illegal sheep grazing in the field of beach area inspection and prevention.
[0008] In a first aspect, the present invention provides a method for detecting illegal sheep herding based on an improved YOLOv5 network;
[0009] A method for detecting illegal sheep herding based on an improved YOLOv5 network includes:
[0010] Acquire images of the beach area collected by drones;
[0011] The acquired images are input into the trained improved YOLOv5 network, which outputs the result of whether there is illegal grazing in the beach area.
[0012] Secondly, this invention provides a system for detecting illegal sheep grazing based on an improved YOLOv5 network;
[0013] A violation grazing detection system based on an improved YOLOv5 network includes:
[0014] The acquisition module is configured to acquire images of the beach area collected by the drone;
[0015] The detection module is configured to input the acquired images into the trained improved YOLOv5 network and output the result of whether there is illegal grazing in the beach area.
[0016] Thirdly, the present invention also provides an electronic device, comprising:
[0017] Memory, used for non-transitory storage of computer-readable instructions; and
[0018] Processor, for executing the computer-readable instructions,
[0019] When the computer-readable instructions are executed by the processor, they perform the method described in the first aspect above.
[0020] Fourthly, the present invention also provides a storage medium for non-transitory storage of computer-readable instructions, wherein, when the non-transitory computer-readable instructions are executed by a computer, the instructions for executing the method described in the first aspect are executed.
[0021] Fifthly, the present invention also provides a computer program product, including a computer program that, when run on one or more processors, is used to implement the method described in the first aspect above.
[0022] Compared with the prior art, the beneficial effects of the present invention are:
[0023] This invention acquires images of illegally grazing sheep from a drone's perspective, identifies the sheep in the images, and applies flipping and varying degrees of Gaussian blur to create an enhanced dataset, which is then categorized into a training set and a test set. An improved YOLOv5 network model is used, replacing the BottleNeckCSP module with a GhostBottleNeck1 module (stride 1) and replacing convolutional layers with a GhostBottleNeck2 module (stride 2) for downsampling and feature extraction. Depthwise separable (DW) convolutions replace the ordinary convolutions in the original PANet module for the neck region. The improved YOLOv5 network model is trained using the training set until it meets the testing requirements of the test set, resulting in the final detection model. Drone-view images of illegally grazing sheep in a beach area are acquired as input images, and the final detection model is used to identify the illegally grazing sheep. The above content is integrated and can be configured on relevant hardware.
[0024] This invention can effectively improve the detection efficiency and accuracy of illegal sheep grazing and can be applied to routine inspection and prevention operations in riverbank areas. This invention can effectively reduce network parameters, improve computational efficiency during network training, achieve lightweight model design, and simultaneously extract spatial feature information of different sizes, improving the model's robustness to spatial layout and target recognition. Attached Figure Description
[0025] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.
[0026] Figure 1 This is a flowchart illustrating the illegal sheep grazing detection method based on the improved YOLOv5 network shown in this invention;
[0027] Figure 2 This is a diagram of the improved YOLOv5 network model structure shown in this invention;
[0028] Figure 3 This is a structural diagram of the Ghost module shown in this invention;
[0029] Figure 4 This is a diagram of the DW convolution structure shown in this invention;
[0030] Figures 5(a)-5(d) This is a test result diagram of the illegal sheep grazing detection method based on the improved YOLOv5 network shown in this invention. Detailed Implementation
[0031] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0032] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments of the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. Furthermore, it should be understood that the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0033] Example 1
[0034] This embodiment provides a method for detecting illegal sheep grazing based on an improved YOLOv5 network;
[0035] like Figure 1 As shown, the method for detecting illegal shepherding based on the improved YOLOv5 network includes:
[0036] S101: Acquire images of the beach area collected by the drone;
[0037] S102: Input the acquired image into the trained improved YOLOv5 network and output the result of whether there is illegal grazing in the beach area.
[0038] Furthermore, such as Figure 2 As shown, the improved YOLOv5 network after training has the following network structure:
[0039] The following modules are connected in sequence: input layer, focus layer, first depthwise separable convolutional layer (DW), first GhostBottleNeck1 module, first GhostBottleNeck2 module, second GhostBottleNeck1 module, second GhostBottleNeck2 module, third GhostBottleNeck1 module, second depthwise separable convolutional layer (DW), SPP module, fourth GhostBottleNeck1 module, first convolutional layer, first upsampling module, first fusion module, second convolutional layer, fifth GhostBottleNeck1 module, third convolutional layer, second upsampling module, second fusion module, fourth convolutional layer, sixth GhostBottleNeck1 module, and fifth convolutional layer.
[0040] The sixth GhostBottleNeck1 module is connected to the sixth convolutional layer, the sixth convolutional layer is connected to the third fusion module, the third fusion module is connected to the seventh GhostBottleNeck1 module, and the seventh GhostBottleNeck1 module is connected to the seventh convolutional layer.
[0041] The seventh GhostBottleNeck1 module is connected to the eighth convolutional layer, the eighth convolutional layer is connected to the fourth fusion module, the fourth fusion module is connected to the eighth GhostBottleNeck1 module, and the eighth GhostBottleNeck1 module is connected to the ninth convolutional layer.
[0042] Specifically, the second GhostBottleNeck1 module is connected to the second fusion module, the third GhostBottleNeck1 module is connected to the first fusion module, the fourth GhostBottleNeck1 module is connected to the fourth fusion module, and the third convolutional layer is connected to the third fusion module.
[0043] Furthermore, such as Figure 4 As shown, the internal structures of the first depthwise separable convolutional layer (DW) and the second depthwise separable convolutional layer (DW) are the same. The first depthwise separable convolutional layer (DW) includes:
[0044] The convolutional layer, batch normalization layer, and activation function layer are connected in sequence.
[0045] Furthermore, the first depthwise separable convolutional layer (DW) and the second depthwise separable convolutional layer (DW) are used to further compress model parameters, achieve lightweight model design, and extract spatial feature information of different sizes, thereby improving the model's robustness to spatial layout and target recognition.
[0046] Furthermore, the first, second, third, fourth, fifth, sixth, seventh, and eighth GhostBottleNeck1 modules have the same internal structure; the first GhostBottleNeck1 module includes:
[0047] The system consists of a first Ghost Module, a first batch normalization layer, an activation function layer, a second Ghost Module, a second batch normalization layer, and a first adder.
[0048] The input of the first Ghost Module is also connected to the input of the first adder.
[0049] Furthermore, the first GhostBottleNeck1 module's operation includes:
[0050] The first Ghost Module increases the number of channels, while the second Ghost Module reduces the number of channels to match the number of input channels.
[0051] Furthermore, the first GhostBottleNeck2 module and the second GhostBottleNeck2 module have the same internal structure; the first GhostBottleNeck2 module includes:
[0052] The third Ghost Module, the third batch normalization layer, the activation function layer, the depthwise separable convolutional layer, the fourth batch normalization layer, the fourth Ghost Module, the fifth batch normalization layer, and the second adder are connected in sequence.
[0053] The input of the third Ghost Module is also connected to the input of the second adder.
[0054] Furthermore, the first GhostBottleNeck2 module's operation includes:
[0055] The third Ghost Module increases the number of channels, while the fourth Ghost Module reduces the number of channels to match the number of input channels. At the same time, a separable convolutional layer with a stride of 2 is connected between the third and fourth Ghost Modules to reduce the feature map size to half that of the input, thus achieving downsampling.
[0056] Furthermore, the GhostBottleNeck1 and GhostBottleNeck2 modules are used to reduce the model size, achieving faster detection speeds without sacrificing significant accuracy.
[0057] Furthermore, such as Figure 3 As shown, the first Ghost Module, the second Ghost Module, the third Ghost Module, and the fourth Ghost Module have the same internal structure. The first Ghost Module includes:
[0058] First, feature maps are generated from the input through convolution operations;
[0059] Then, similar feature maps are obtained by using depthwise separable convolution (DW) on the generated feature maps;
[0060] Subsequently, the feature map generated by the convolution operation is concatenated and fused with similar feature maps to obtain the output result.
[0061] Furthermore, the first fusion module, the second fusion module, the third fusion module, and the fourth fusion module are all used to achieve the serial splicing of features.
[0062] Furthermore, the Focus layer includes: performing a slice operation on the input image, splitting the high-resolution image / feature map into multiple low-resolution images / feature maps by sampling every other column, concatenating them, and then performing a convolution (CBL) operation to obtain the output result.
[0063] Furthermore, the Focus layer is used to slice the input data to improve the quality of image feature extraction.
[0064] Furthermore, the SPP module includes:
[0065] The first, second, and third max-pooling layers are connected in parallel;
[0066] The input terminals of the first max pooling layer, the second max pooling layer, and the third max pooling layer are all used as input terminals of the SPP module.
[0067] The output terminals of the first max pooling layer, the second max pooling layer, and the third max pooling layer are connected to the input terminal of the sixth fusion module. The output terminal of the sixth fusion module is connected to the input terminal of the second CBL module. The output terminal of the second CBL module serves as the output terminal of the SPP module.
[0068] The input of the SPP module is also connected to the input of the sixth fusion module.
[0069] Furthermore, the sixth fusion module is used for feature splicing.
[0070] Furthermore, the internal structure of the first CBL module is the same as that of the second CBL module. The first CBL module includes: a convolutional layer, a batch normalization layer (BN), and an activation function layer.
[0071] Furthermore, the SPP module is used to pool feature maps of different sizes, thereby enhancing the model's ability to perceive targets at different scales.
[0072] It should be understood that the improved YOLOv5 network includes: replacing the BottleNeckCSP module with a stride of 1 GhostBottleNeck module, replacing the convolutional layers with a stride of 2 GhostBottleNeck module for downsampling and feature extraction, and replacing the ordinary convolutions in the original PANet module with depthwise separable (DW) convolutions in the neck portion.
[0073] Furthermore, such as Figure 2 As shown, the working principle of the improved YOLOv5 network after training includes:
[0074] First, the input image passes through the Focus layer at the very front of the network. The Focus layer is used to slice the input data.
[0075] Then, the output of the Focus layer is fed into the first depthwise separable convolutional layer DW to extract spatial feature information of different sizes;
[0076] Subsequently, the result of the first depthwise separable convolutional layer (DW) is fed into the first GhostBottleNeck1 module, the first GhostBottleNeck2 module, and the second GhostBottleNeck1 module.
[0077] The first GhostBottleNeck1 module and the second GhostBottleNeck1 module are both composed of two GhostModule modules connected in series. The first GhostModule module is used to increase the number of channels, and the second GhostModule module is used to reduce the number of channels to be consistent with the number of input channels.
[0078] The first GhostBottleNeck2 module replaces the convolutional layer for downsampling and feature extraction operations. The first GhostBottleNeck2 module adds a depthwise separable convolutional layer with a stride of 2 between the two Ghost Module modules, reducing the feature map size to 1 / 2 of the input and realizing the downsampling operation.
[0079] The second GhostBottleNeck1 module outputs the first intermediate processing result;
[0080] The third GhostBottleNeck1 module outputs the second intermediate processing result;
[0081] The fourth GhostBottleNeck1 module outputs the third intermediate processing result;
[0082] The first upsampling module outputs the fourth intermediate processing result;
[0083] The third convolutional layer outputs the fifth intermediate processing result;
[0084] The second upsampling module outputs the sixth intermediate processing result;
[0085] The sixth convolutional layer outputs the seventh intermediate processing result;
[0086] The eighth convolutional layer outputs the eighth intermediate processing result;
[0087] The fourth intermediate processing result and the second intermediate processing result are sent to the first fusion module for series splicing;
[0088] The sixth intermediate processing result and the first intermediate processing result are sent to the second fusion module for series splicing;
[0089] The seventh intermediate processing result and the fifth intermediate processing result are sent to the third fusion module for series splicing;
[0090] The eighth intermediate processing result and the third intermediate processing result are sent to the fourth fusion module for series splicing.
[0091] The SPP (Spatial Pyramid Pooling) module is used to pool feature maps of different sizes, thereby enhancing the model's ability to perceive targets at different scales.
[0092] Furthermore, the training process of the improved YOLOv5 network after training includes:
[0093] Construct a training set, a test set, and a validation set, which include: mudflat images collected by drones that indicate whether there is any illegal grazing.
[0094] The training set is fed into the improved YOLOv5 network for training. Training is stopped when the network's loss function value no longer decreases or when the number of iterations exceeds a set number.
[0095] The test set is fed into the initially trained, improved YOLOv5 network for testing;
[0096] The validation set is fed into the trained and improved YOLOv5 network that has passed the test to validate it, optimize the network parameters, and use the validated network as the final trained and improved YOLOv5 network.
[0097] Furthermore, the construction of the training set, test set, and validation set requires necessary preprocessing operations on the images, such as calibration, random scaling, cropping, translation, shearing, and rotation.
[0098] It should be understood that the dataset is obtained by capturing images of the beach area using drones (such as the DJI Mavic Pro) to photograph illegal grazing within the beach area. To ensure data diversity, the following factors were carefully considered during the filming process:
[0099] Different flight attitudes of drones, such as hovering, takeoff and landing, and steady flight; different environmental factors, such as sunny or cloudy weather and light intensity.
[0100] A manual labeling method was adopted, selecting representative sheep from images of illegal grazing as the initial dataset for labeling. The labeling was performed using the labelImg software.
[0101] In addition, considering that drones may exhibit tilting or other attitudes during flight, this embodiment performs the following augmentation operations on the dataset images to make the training data more effective and improve the network's generalization ability:
[0102] The images were rotated in increments of 20° from 0 to 340° using a flip matrix, and then Gaussian blurred. The augmented dataset consisted of 3554 images, which were divided into training and testing sets in a 4:1 ratio.
[0103] This embodiment makes two improvements to the YOLOv5s algorithm model. Ablation experiments are then used to investigate whether both improvements are effective and whether there is any interaction between them. The basic training parameters are set as follows:
[0104] A gradient descent strategy was adopted, with momentum and weight decay set to 0.937 and 0.0005 respectively, an initial learning rate of 0.001, and a batch size of 16. Other settings followed the basic training strategy of YOLOv5. The reference metric for real-time performance on the airborne end was FPS on the CPU, and the results are shown in Table 1.
[0105] Table 1 shows the ablation experiment results of the improved YOLOv5 network model shown in this invention, with FPS on CPU as the real-time performance reference indicator.
[0106]
[0107] As shown in Table 1, the addition of the GhostBottleNeck module and DW convolution reduced the model size from 14.4MB to 3.8MB. The network structure was adjusted, the computational complexity was reduced, and mAP50 was reduced by 4.2%. Although some detection accuracy was lost, FPS@CPU reached 21, and the real-time performance of the algorithm model on the CPU was improved by 31.25%.
[0108] The improved model is primarily designed for mobile devices. The improved YOLOv5s algorithm (Ghost-DW-YOLOv5 algorithm) is compared with lightweight object detection algorithms such as YOLOv3-tiny, SlimYOLOv3-SPP3-95, YOLOv4-tiny, YOLOv5s, and YOLOv5-MobileNetv3Small. Test experiments were conducted using the same platform and equipment. The mAP50 and FPS@CPU results of different models on the Violation Herding dataset were used as evaluation metrics. The results are shown in Table 2.
[0109] Table 2 compares the performance metrics of the improved YOLOv5 network model shown in this invention with other models.
[0110]
[0111] Figures 5(a)-5(d) This is a test result diagram of the illegal sheep grazing detection method based on the improved YOLOv5 network shown in this invention.
[0112] Example 2
[0113] This embodiment provides a system for detecting illegal sheep grazing based on an improved YOLOv5 network;
[0114] A violation grazing detection system based on an improved YOLOv5 network includes:
[0115] The acquisition module is configured to acquire images of the beach area collected by the drone;
[0116] The detection module is configured to input the acquired images into the trained improved YOLOv5 network and output the result of whether there is illegal grazing in the beach area.
[0117] It should be noted that the acquisition module and detection module described above correspond to steps S101 to S102 in Embodiment 1. The examples and application scenarios implemented by the modules and corresponding steps are the same, but are not limited to the content disclosed in Embodiment 1. It should also be noted that the modules described above, as part of the system, can be executed in a computer system such as a set of computer-executable instructions.
[0118] The descriptions of each embodiment in the above embodiments have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0119] The proposed system can be implemented in other ways. For example, the system embodiments described above are merely illustrative, and the division of modules described above is only a logical functional division. In actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed.
[0120] Example 3
[0121] This embodiment also provides an electronic device, including: one or more processors, one or more memories, and one or more computer programs; wherein, the processor is connected to the memory, and the one or more computer programs are stored in the memory. When the electronic device is running, the processor executes the one or more computer programs stored in the memory to cause the electronic device to perform the method described in Embodiment 1.
[0122] It should be understood that in this embodiment, the processor can be a central processing unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.
[0123] Memory may include read-only memory and random access memory, and provides instructions and data to the processor. A portion of memory may also include non-volatile random access memory. For example, memory may also store information about the device type.
[0124] In the implementation process, each step of the above method can be completed by the integrated logic circuits in the processor hardware or by software instructions.
[0125] The method in Embodiment 1 can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor. The software modules can reside in readily available storage media in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory; the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, a detailed description is not provided here.
[0126] Those skilled in the art will recognize that the units and algorithm steps described in connection with the various examples of this embodiment can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this invention.
[0127] Example 4
[0128] This embodiment also provides a computer-readable storage medium for storing computer instructions, which, when executed by a processor, complete the method described in Embodiment 1.
[0129] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for detecting illegal grazing based on an improved YOLOv5 network, characterized in that, The method comprises: acquiring a beach area image collected by a UAV; inputting the acquired image into a trained improved YOLOv5 network to output a result of whether there is illegal grazing in the beach area; the trained improved YOLOv5 network has a network structure comprising: an input layer, a Focus layer, a first deep separable convolutional layer DW, a first GhostBottleNeck1 module, a first GhostBottleNeck2 module, a second GhostBottleNeck1 module, a second GhostBottleNeck2 module, a third GhostBottleNeck1 module, a second deep separable convolutional layer DW, an SPP module, a fourth GhostBottleNeck1 module, a first convolutional layer, a first upsampling module, a first fusion module, a second convolutional layer, a fifth GhostBottleNeck1 module, a third convolutional layer, a second upsampling module, a second fusion module, a fourth convolutional layer, a sixth GhostBottleNeck1 module, and a fifth convolutional layer connected in sequence; the sixth GhostBottleNeck1 module is connected with the sixth convolutional layer, the sixth convolutional layer is connected with the third fusion module, the third fusion module is connected with the seventh GhostBottleNeck1 module, and the seventh GhostBottleNeck1 module is connected with the seventh convolutional layer; the seventh GhostBottleNeck1 module is connected with the eighth convolutional layer, the eighth convolutional layer is connected with the fourth fusion module, the fourth fusion module is connected with the eighth GhostBottleNeck1 module, and the eighth GhostBottleNeck1 module is connected with the ninth convolutional layer; wherein the second GhostBottleNeck1 module is connected with the second fusion module, the third GhostBottleNeck1 module is connected with the first fusion module, the fourth GhostBottleNeck1 module is connected with the fourth fusion module, and the third convolutional layer is connected with the third fusion module.
2. The method of claim 1, wherein the improved YOLOv5 network-based illegal herding detection method is characterized by, The internal structures of the first deep separable convolutional layer DW and the second deep separable convolutional layer DW are the same, and the first deep separable convolutional layer DW comprises: a convolutional layer, a batch normalization layer, and an activation function layer connected in sequence; the first deep separable convolutional layer DW and the second deep separable convolutional layer DW are used for further compressing model parameters and extracting spatial feature information of different sizes.
3. The method of claim 1, wherein the improved YOLOv5 network-based illegal herding detection method is characterized by, The first GhostBottleNeck1 module, the second GhostBottleNeck1 module, the third GhostBottleNeck1 module, the fourth GhostBottleNeck1 module, the fifth GhostBottleNeck1 module, the sixth GhostBottleNeck1 module, the seventh GhostBottleNeck1 module and the eighth GhostBottleNeck1 module have the same internal structure; the first GhostBottleNeck1 module comprises: a first Ghost Module, a first batch normalization layer, an activation function layer, a second Ghost Module, a second batch normalization layer and a first adder; the input end of the first Ghost Module is also connected with the input end of the first adder; the working process of the first GhostBottleNeck1 module comprises: the first Ghost Module expands the channel number, and the second Ghost Module reduces the channel number to be consistent with the input channel number.
4. The method of claim 3, wherein the improved YOLOv5 network-based illegal herding detection method is characterized by, The first GhostBottleNeck2 module and the second GhostBottleNeck2 module have the same internal structure; the first GhostBottleNeck2 module comprises: a third Ghost Module, a third batch normalization layer, an activation function layer, a depth separable convolution layer, a fourth batch normalization layer, a fourth Ghost Module, a fifth batch normalization layer and a second adder connected in sequence; the input end of the third Ghost Module is also connected with the input end of the second adder; the working process of the first GhostBottleNeck2 module comprises: the third Ghost Module expands the channel number, and the fourth Ghost Module reduces the channel number to be consistent with the input channel number, while the depth separable convolution layer with a step equal to 2 connected between the third Ghost Module and the fourth Ghost Module reduces the feature map size to 1 / 2 of the input, realizing down-sampling operation; The first Ghost Module, the second Ghost Module, the third Ghost Module and the fourth Ghost Module have the same internal structure; the first Ghost Module comprises: first, generating a feature map through convolution operation on the input; then, obtaining a similar feature map through depth separable convolution DW on the generated feature map; subsequently, splicing and fusing the feature map generated through convolution operation and the similar feature map to obtain an output result.
5. The method of claim 1, wherein the improved YOLOv5 network-based illegal herding detection method is characterized by, The working principle of the trained improved YOLOv5 network comprises: Firstly, the input image passes through the Focus layer located at the front end of the network, and the Focus layer is used for slice operation on the input data; Then, the output result of the Focus layer enters the first depth separable convolution layer DW to extract spatial feature information of different sizes; Subsequently, the result of the first depth separable convolution layer DW enters the first GhostBottleNeck1 module, the first GhostBottleNeck2 module and the second GhostBottleNeck1 module; The first GhostBottleNeck1 module and the second GhostBottleNeck1 module are both composed of two GhostModule modules in series, wherein the first GhostModule module is used to expand the channel number, and the second GhostModule module is used to reduce the channel number to be consistent with the input channel number; The first GhostBottleNeck2 module replaces the convolution layer to perform downsampling and feature extraction operations; the first GhostBottleNeck2 module adds a depth separable convolution layer with a step equal to 2 between the two GhostModule modules, reduces the feature map size to 1 / 2 of the input, and realizes the downsampling operation; The second GhostBottleNeck1 module outputs a first intermediate processing result; the third GhostBottleNeck1 module outputs a second intermediate processing result; the fourth GhostBottleNeck1 module outputs a third intermediate processing result; the first upsampling module outputs a fourth intermediate processing result; the third convolution layer outputs a fifth intermediate processing result; the second upsampling module outputs a sixth intermediate processing result; the sixth convolution layer outputs a seventh intermediate processing result; and the eighth convolution layer outputs an eighth intermediate processing result; The fourth intermediate processing result and the second intermediate processing result are input into the first fusion module for series splicing; The sixth intermediate processing result and the first intermediate processing result are input into the second fusion module for series splicing; The seventh intermediate processing result and the fifth intermediate processing result are input into the third fusion module for series splicing; The eighth intermediate processing result and the third intermediate processing result are input into the fourth fusion module for series splicing.
6. The method of claim 1, wherein the improved YOLOv5 network-based illegal herding detection method is characterized by, The trained improved YOLOv5 network, the training process includes: Building a training set, a test set and a validation set, the training set, the test set and the validation set including: tidal flat images collected by a UAV whether there is a rule-breaking sheep grazing situation; Input the training set into the improved YOLOv5 network, and train it, when the loss function value of the network no longer decreases, or the iteration number exceeds the set number of times, stop training; Input the test set into the improved YOLOv5 network after preliminary training, and test it; Input the validation set into the trained improved YOLOv5 network that passes the test, and verify it, optimize the network parameters, and take the network that passes the verification as the final trained improved YOLOv5 network; The training set, test set and validation set are constructed, and during the construction process, the images are calibrated and randomly scaled, cropped, translated, cut and rotated.
7. The system for detecting illegal grazing based on the improved YOLOv5 network, characterized in that, Comprise: An acquisition module configured to acquire a beach image collected by a UAV; A detection module configured to input the acquired image into a trained improved YOLOv5 network and output a result of whether there is illegal grazing in the beach; The network structure of the trained improved YOLOv5 network comprises: An input layer, a Focus layer, a first deep separable convolution layer DW, a first GhostBottleNeck1 module, a first GhostBottleNeck2 module, a second GhostBottleNeck1 module, a second GhostBottleNeck2 module, a third GhostBottleNeck1 module, a second deep separable convolution layer DW, an SPP module, a fourth GhostBottleNeck1 module, a first convolution layer, a first upsampling module, a first fusion module, a second convolution layer, a fifth GhostBottleNeck1 module, a third convolution layer, a second upsampling module, a second fusion module, a fourth convolution layer, a sixth GhostBottleNeck1 module, and a fifth convolution layer connected in sequence; The sixth GhostBottleNeck1 module is connected with the sixth convolution layer, the sixth convolution layer is connected with the third fusion module, the third fusion module is connected with the seventh GhostBottleNeck1 module, and the seventh GhostBottleNeck1 module is connected with the seventh convolution layer; The seventh GhostBottleNeck1 module is connected with the eighth convolution layer, the eighth convolution layer is connected with the fourth fusion module, the fourth fusion module is connected with the eighth GhostBottleNeck1 module, and the eighth GhostBottleNeck1 module is connected with the ninth convolution layer; The second GhostBottleNeck1 module is connected with the second fusion module, the third GhostBottleNeck1 module is connected with the first fusion module, the fourth GhostBottleNeck1 module is connected with the fourth fusion module, and the third convolution layer is connected with the third fusion module.
8. An electronic device, comprising: a memory for non-transiently storing computer readable instructions; and a processor for running the computer readable instructions, wherein the computer readable instructions, when executed by the processor, perform the method of any one of claims 1-6.
9. A storage medium characterized by, Non-transiently storing computer readable instructions, wherein when the non-transient computer readable instructions are executed by a computer, the instructions perform the method of any one of claims 1-6.