Vegetable field weed model construction and detection method based on improved yov8 network

By improving the yolov8 network, combining the deep separation convolution, context interaction fusion module and multi-scale Retinex image enhancement algorithm, the problems of low recognition accuracy and poor real-time performance in field weed detection are solved, and efficient and environmentally friendly vegetable field miscellaneous Grass testing has promoted the modernization and sustainable development of agricultural production.

CN119229283AActive Publication Date: 2024-12-31SOUTH CHINA AGRICULTURAL UNIVERSITY +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411271308.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-11
Publication Date
2024-12-31
Estimated Expiration
2044-09-11

AI Technical Summary

Technical Problem

The prior art has problems of low recognition accuracy and poor real-time performance in field weed detection, traditional methods are time-consuming and labor-intensive, and chemical herbicides are potentially harmful to the environment and human health.

Method used

By improving the yolov8 network, deep separable convolution, context interaction fusion module and lightweight detection head are introduced, combined with multi-scale Retinex image enhancement algorithm, a vegetable field weed detection model is built to achieve fast and accurate detection.

Benefits of technology

It improves the accuracy and efficiency of field weed detection, reduces the risk of environmental pollution, and promotes the modernization and sustainable development of agricultural production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119229283A_ABST
    Figure CN119229283A_ABST
Patent Text Reader

Abstract

The invention discloses a vegetable field weed model construction method based on an improved yolov8 network, and the method comprises the steps: S1, collecting a vegetable field weed image, constructing a vegetable weed data set, and dividing the vegetable weed data set into a training set, a verification set and a test set according to a preset proportion; s2, constructing an improved yolov8 network model to establish a vegetable field weed detection model; and S3, inputting the training set into the improved yolov8 network model for training, verifying the performance of the model by using the verification set, adjusting the parameters of the model according to the evaluation result of the verification set, and finally evaluating the performance of the model by using the test set to obtain a final vegetable field weed detection model. The step S2 comprises the following steps of: S21, introducing a depth separable convolution DSConv into an original yolov8 network model; s22, replacing a Concat module in the check layer with a context interactive fusion module (CIFM); and S23, replacing the Head detection head with a lightweight LSCD detection head. According to the invention, rapid and accurate detection of vegetables and weeds is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of vegetable weed detection, and more specifically, to a vegetable field weed model construction and detection method based on an improved yolov8 network. Background Art

[0002] In agricultural production, the management of field weeds is one of the important links to ensure the healthy growth and high yield of crops. Weeds compete with vegetable crops for sunlight, water and nutrients, seriously affecting the yield and quality of vegetables. In addition, some weeds may become hosts for pests and diseases, aggravating the occurrence of vegetable pests and diseases, and further threatening the safety and benefits of agricultural production. Traditional weeding methods mainly rely on manual weeding and chemical herbicides. Although manual weeding is effective, it is time-consuming, labor-intensive, and costly, especially in the case of large-scale planting. Although chemical herbicides are easy to use and effective, long-term use can lead to soil pollution, pesticide residues, and potential harm to the ecological environment and human health. Therefore, finding an efficient, environmentally friendly and economically feasible weeding method has become a hot topic in current agricultural science and technology research.

[0003] Traditional weed identification methods usually rely on analyzing plant features such as texture, color, and shape. However, these features need to be manually extracted, the algorithm design is complex, and there are defects such as low recognition accuracy and poor robustness. With the advancement of science and technology, automated weeding technology based on machine vision and artificial intelligence has gradually entered people's field of vision. These technologies can accurately identify vegetables and weeds through real-time processing and analysis of field images, thereby achieving precise mechanical weeding or targeted spraying of herbicides. Such technologies have greatly improved the efficiency and accuracy of weeding, reduced the risk of environmental pollution, and promoted the modernization and sustainable development of agricultural production. Summary of the invention

[0004] The present invention aims to overcome at least one defect (shortcoming) of the above-mentioned prior art, and provides a vegetable field weed model construction and detection method based on an improved yolov8 network, which is used to solve the problems of low weed detection accuracy and poor real-time performance. By improving the original yolov8 network to train a vegetable weed detection model, it is possible to accurately identify vegetables and vegetables, thereby accurately mechanically weeding or targeted spraying of herbicides, improving the efficiency and accuracy of weeding, reducing environmental pollution, and promoting the modernization and sustainable development of agricultural production.

[0005] The technical solution adopted by the present invention is a method for constructing a vegetable field weed model based on an improved yolov8 network, and the construction method comprises:

[0006] S1: Collect images of weeds in vegetable fields, construct a vegetable weed dataset, and divide the vegetable weed dataset into a training set, a validation set, and a test set according to a preset ratio;

[0007] S2: Construct an improved yolov8 network model to establish a weed detection model in vegetable fields;

[0008] S3: input the training set into the improved yolov8 network model for training, use the validation set to verify the performance of the model and adjust the parameters of the model according to the evaluation results of the validation set, and finally use the test set to evaluate the performance of the model to obtain the final vegetable field weed detection model;

[0009] Preferably, step S2 includes:

[0010] S21: Introducing deep separable convolution DSConv into the original yolov8 network model;

[0011] S22: Replace the Concat module in the neck layer of the original yolov8 network model with the context interaction fusion module CIFM;

[0012] S23: Replace the Head detection head of the original yolov8 network model with a lightweight LSCD detection head.

[0013] In the present invention, the original yolov8 model is improved and trained to obtain a vegetable field weed detection model, which is used to detect weeds in the field environment. Different types of weeds can be detected quickly and accurately, and the positions of weeds can be accurately located, so that mechanical weeding or targeted spraying of herbicides can be accurately performed to avoid damage to surrounding crops, improve the accuracy and efficiency of weeding, and promote the automation and intelligence of agricultural management.

[0014] Preferably, in the step S21, the depth separable convolution DSConv is introduced in the Backbone layer and the Neck layer of the original yolov8 network model; the DSConv is divided into two parts, one is the Depthwise channel-by-channel convolution applied on a single input channel, and the other is the Pointwise point-by-point convolution with a kernel size of 1×1; the convolution first performs a convolution operation on the input image in space, and then performs a weighted combination of the maps that have undergone the channel-by-channel convolution in the depth direction and outputs them.

[0015] In the present invention, the original yolov8 network is optimized and improved. First, the deep separable convolution DSConv is introduced into the Backbone layer and Neck layer of the original network, and the original ordinary convolution and the ordinary convolution in the C2f module are replaced with the deep separable convolution DSConv. While maintaining the output feature map size and channel size of the convolution consistent with the original network and without damaging the model performance, the parameters and computational load of the model are significantly reduced, and the receptive field and generalization ability are enhanced, thereby improving the overall model efficiency and application performance.

[0016] Preferably, in step S22, the fusion features of high-dimensional information and low-dimensional information are obtained by introducing CIFM, including:

[0017] S221: Receive high-dimensional features F h Input and receive low-dimensional features F l enter;

[0018] S222: The high-dimensional feature F h Input and low-dimensional features F l The inputs are concatenated to generate concatenated features;

[0019] S223: performing global average pooling processing on the connection features and performing a first linear transformation, then activating them using a ReLU function, then performing a second linear transformation, and finally activating them using a Sigmoid function to generate a weight coefficient;

[0020] S224: The weight coefficient and the high-dimensional feature F h Input element-by-element multiplication to obtain the first multiplication result; the weight coefficient is combined with the low-dimensional feature F l The input is multiplied element by element to obtain the second multiplication result;

[0021] S225: High-dimensional features F h The input is added to the second multiplication result to obtain the first addition result; the low-dimensional feature F is received l The input is added to the first multiplication result to obtain a second addition result;

[0022] S226: Connect the outputs of the first addition result and the second addition result to generate a final fusion feature F f .

[0023] Therefore, by utilizing the more complex interaction mechanism of the context interaction fusion module CIFM to fuse feature information at different levels and sources, the network can be helped to more deeply understand and integrate the relationship between features, thereby enhancing the feature representation ability, realizing multi-scale perception and fusion of features, improving the effect and performance of feature fusion, and enhancing the generalization ability of the model.

[0024] Preferably, in step S23, the LSCD detection head uses a shared GroupNorm convolutional layer to replace the two common convolutional layers used by the Head detection head, and uses a scale layer to perform scale scaling processing on the features.

[0025] By using a shared GroupNorm convolutional layer instead of two ordinary convolutional layers, the complexity and number of parameters of the model can be significantly reduced while ensuring the performance of the model. Reducing the number and complexity of parameters not only reduces the computational overhead of the model in the inference phase, but also accelerates the training process of the model, significantly saving time and computing resources, making the model more versatile and adaptable.

[0026] Preferably, the GroupNorm convolution layer is a regularization method, which divides the feature channels into several groups and performs normalization processing in each group; wherein the regularization calculation formula is as follows:

[0027]

[0028] in, is the normalized feature, x i is the original feature, μ G is the mean of group G, is the variance of the Gth group, and ∈ is a small constant used to avoid division by zero.

[0029] GroupNorm effectively improves the model's ability to handle small batches of data and irregular data sizes through intra-group normalization, while reducing its dependence on batch size, making it more adaptable to images.

[0030] Preferably, the scaling process of the features by using the scale layer includes: adjusting the resolution of the feature map by upsampling or downsampling so that the feature scales between different detection heads are consistent, thereby solving the problem of inconsistent target scales.

[0031] Preferably, in step S1, collecting images of weeds in vegetable fields includes: collecting images of vegetable seedlings and weeds at several different inclination angles between the crop growth plane and the image sensor; collecting images of vegetable seedlings and weeds in which weeds are associated with crops, weeds are far away from crops, weeds are densely distributed, and crops exist alone.

[0032] In this application, the diversity of the data set is increased by collecting images of vegetable seedlings and weeds at different tilt angles and in different scenes, which helps the model learn a wider range of features and scene changes, improves the generalization ability of the model in practical applications, and thus improves the accuracy and reliability of the model's predictions.

[0033] On the other hand, the present invention also provides a method for detecting weeds in vegetable fields based on an improved yolov8 network, the detection method comprising:

[0034] S01: Use the MSRCP algorithm to enhance the image of vegetable weeds to be detected;

[0035] S02: Inputting the enhanced vegetable weed image to be detected into the vegetable field weed detection model obtained according to the above-mentioned construction method for detection to obtain a weed detection result.

[0036] In the present invention, the MSRCP algorithm is first used to enhance the details and contrast of the vegetable weed image to be detected, and then the image is input into a trained vegetable field weed detection model for detection, thereby improving the speed and accuracy of vegetable weed detection, thereby achieving precise mechanical weeding or targeted spraying of herbicides, reducing the risk of environmental pollution, and promoting the modernization and sustainable development of agricultural production.

[0037] Preferably, the MSRCP algorithm is combined with a color preservation technique, and performs multi-scale processing on the image, performs Retinex enhancement at different scales, and then fuses the enhanced results, thereby improving the overall brightness and contrast of the image.

[0038] Further preferably, the calculation formula of the MSRCP algorithm is as follows:

[0039] I nt =(I R +I G +I B ) / 3;

[0040]

[0041] B=max(I Ri +I Gi +I Bi );

[0042] R(x, y) = AI (R,G,B) (x, y);

[0043] Among them, I nt Represents the grayscale value of the intensity image; I R , I G , I B Represents the R, G, and B channel components of the original image; I nti Represents the grayscale value of a single-channel intensity image; subscript i represents the pixel index; R(x, y) represents the enhanced image value; I (R,G,B) (x, y) represents the RGB feature image value of the image at the coordinate (x, y).

[0044] In the present invention, before the image of vegetable weeds to be detected is input into the model for detection, it also includes using the MSRCP algorithm to optimize the processing thereof, using a multi-scale method to process the image, not only considering the global illumination change, but also processing the local illumination unevenness and detail information, and capturing the detail information of different spatial frequencies through multi-scale decomposition, thereby more comprehensively enhancing the visual effect of the image, and also introducing color preservation technology to ensure that the color characteristics of the original image are maintained as much as possible during the enhancement process, thereby enhancing the details and contrast of the vegetable weed image to be detected.

[0045] Compared with the prior art, the present invention has the following beneficial effects:

[0046] (1) The present invention replaces the convolution modules of the Backbone and Neck layers of the original yolov8 network with the deep separable convolution DSConv, which greatly reduces the overall computational complexity and parameter amount of the network model while maintaining the output feature map size and channel size of the convolution consistent with the original network, and improves the real-time performance of vegetable weed detection.

[0047] (2) The present invention proposes a context interaction fusion module CIFM and introduces the module into the original yolov8 network to obtain the fusion features of high-dimensional and low-dimensional information, realize multi-scale perception and fusion of features, and is more conducive to extracting the feature information of the target.

[0048] (3) The present invention replaces the detection head in the original yolov8 network with the LSCD detection head, which greatly reduces the number of parameters while ensuring the detection accuracy, laying the foundation for deployment in embedded devices.

[0049] (4) The present invention adopts the MSRCP algorithm to enhance the details and contrast of the vegetable weed image to be detected, thereby improving the recognition accuracy of the vegetable weed detection model. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 The present invention provides an overall flow chart of the method for constructing a vegetable field weed model based on the improved yolov8 network.

[0051] Figure 2 This is a schematic diagram of the improved yolov8 network structure in the present invention.

[0052] Figure 3 This is a structural diagram of a context interaction fusion module proposed in the present invention.

[0053] Figure 4 This is a structural diagram of the lightweight scale-aware convolutional detection head used in the present invention.

[0054] Figure 5The overall flow chart of the vegetable field weed detection method based on the improved yolov8 network provided by the present invention.

[0055] Figure 6 This is a schematic structural diagram of an electronic device provided by the present invention. DETAILED DESCRIPTION

[0056] The drawings of the present invention are only for illustrative purposes and should not be construed as limiting the present invention. In order to better illustrate the following embodiments, some parts of the drawings may be omitted, enlarged or reduced, and do not represent the size of the actual product; it is understandable to those skilled in the art that some well-known structures and their descriptions in the drawings may be omitted.

[0057] Example 1

[0058] The technical solution adopted in this embodiment is a method for constructing a vegetable field weed model based on an improved yolov8 network. Figure 1 As shown, the construction method includes:

[0059] S1: Collect images of weeds in vegetable fields, construct a vegetable weed dataset, and divide the vegetable weed dataset into a training set, a validation set, and a test set according to a preset ratio;

[0060] S2: Construct an improved yolov8 network model to establish a weed detection model in vegetable fields;

[0061] S3: input the training set into the improved yolov8 network model for training, use the validation set to verify the performance of the model and adjust the parameters of the model according to the evaluation results of the validation set, and finally use the test set to evaluate the performance of the model to obtain the final vegetable field weed detection model;

[0062] In this embodiment, the original yolov8 model is improved and trained to obtain a vegetable field weed detection model, which is used to detect weeds in the field environment. Different types of weeds can be detected quickly and accurately, and the position of the weeds can be accurately located, so that mechanical weeding or targeted spraying of herbicides can be accurately performed to avoid damage to surrounding crops, improve the accuracy and efficiency of weeding, and promote the automation and intelligence of agricultural management.

[0063] Preferably, in step S1, the collection of vegetable field weed images includes: collecting vegetable seedlings and weed images at different inclination angles between the crop growth plane and the image sensor, including at least 90°, 75°, 45° and other inclination angles, and collecting vegetable seedlings and weed images in which weeds are associated with crops, weeds are far away from crops, weeds are densely distributed, and crops exist alone, and then LabelImg software is used to annotate the images to construct a vegetable weed data set. When dividing the vegetable weed data set, it can be divided according to a ratio of 8:1:1 or a ratio of 7:2:1, so as to improve the objectivity and reliability of model evaluation, help effectively manage data and optimize the performance and generalization ability of the model.

[0064] Therefore, by collecting images of vegetable seedlings and weeds at different tilt angles and in different scenes, the diversity of the data set is increased and divided according to specific proportions. This helps the model learn a wider range of features and scene changes, improves the generalization ability of the model in practical applications, and thus improves the accuracy and reliability of the model's predictions.

[0065] In addition, in this embodiment, in addition to using LabelImg software for image annotation, image annotation tools and platforms such as LabelMe, CVAT, Labelbox, VGG Image Annotator, Supervisely, DatumBox, etc. can also be used to annotate image data. Those skilled in the art can select and combine them according to the requirements of specific tasks. Choosing an appropriate method can effectively improve the quality and applicability of the data set.

[0066] Preferably, if Figure 2 As shown, Figure 2 The improved yolov8 network structure diagram is shown in step S2. The improvement of the yolov8 network model includes:

[0067] S21: Introducing deep separable convolution DSConv into the original yolov8 network model;

[0068] S22: Replace the Concat module in the neck layer of the original yolov8 network model with the context interaction fusion module CIFM;

[0069] S23: Replace the Head detection head of the original yolov8 network model with a lightweight LSCD detection head.

[0070] Among them, in the step S21, specifically, the depth separable convolution DSConv is introduced into the Backbone layer and the Neck layer of the original yolov8 network model, such as Figure 2As shown in the figure, the original ordinary convolution and the ordinary convolution in the C2f module are replaced with the depthwise separable convolution DSConv. While maintaining the output feature map size and channel size of the convolution consistent with the original network and without compromising the model performance, the model parameters and computational load are significantly reduced, while the receptive field and generalization ability are enhanced, thereby improving the overall model efficiency and application performance.

[0071] The DSConv splits the standard convolution into two parts, one is the Depthwise channel-by-channel convolution applied on a single input channel, and the other is the Pointwise point-by-point convolution with a kernel size of 1×1; the channel-by-channel convolution processes the convolution operation of each input channel, and the point-by-point convolution merges its results into the final output. First, the channel-by-channel convolution performs a convolution operation on each input image in space, and then the point-by-point convolution performs a weighted combination of the maps that have undergone the channel-by-channel convolution in the depth direction as the final output, allowing the network to use fewer parameters to learn feature maps, thereby reducing the overall model parameter amount, and can significantly reduce the computational load of each layer, improving the inference speed of the model.

[0072] When the input feature map is h×w×C in , the output feature map is h′×w′×C out , when the convolution kernel size is k,

[0073] The amount of conventional convolution calculation is:

[0074] k×k×h′×w′×C out ×C in

[0075] The computational complexity of depth-separable convolution is:

[0076] k×k×h′×w′×C in +h′×w′×C in ×C out .

[0077] It can be seen that by using DSConv, the computational load of each layer can be significantly reduced, the reasoning speed of the model can be improved, and it can also help to increase the receptive field (Receptive Field), so that the model has the ability to perceive a larger range of pixels in the input image, which is very beneficial for capturing wider and deeper features in the Backbone layer and the Neck layer, and helps to improve the performance of the model in complex scenarios.

[0078] Preferably, in step S22, Figure 2 As shown, the four Concat modules in the neck layer of the original yolov8 network are replaced by the context interaction fusion module CIFM. The context interaction fusion module CIFM is as follows Figure 3As shown, by introducing CIFM, the fusion features of high-dimensional information and low-dimensional information are obtained, and the fusion features include:

[0079] S221: Receive high-dimensional features F h Input and receive low-dimensional features F l enter;

[0080] S222: The high-dimensional feature F h Input and low-dimensional features F l The inputs are concatenated to generate concatenated features;

[0081] S223: performing global average pooling processing on the connection features and performing a first linear transformation, then activating them using a ReLU function, then performing a second linear transformation, and finally activating them using a Sigmoid function to generate a weight coefficient;

[0082] S224: The weight coefficient and the high-dimensional feature F h Input element-by-element multiplication to obtain the first multiplication result; the weight coefficient is combined with the low-dimensional feature F l The input is multiplied element by element to obtain the second multiplication result;

[0083] S225: High-dimensional features F h The input is added to the second multiplication result to obtain the first addition result; the low-dimensional feature F is received l The input is added to the first multiplication result to obtain a second addition result;

[0084] S226: Connect the outputs of the first addition result and the second addition result to generate a final fusion feature F f .

[0085] Therefore, by utilizing the more complex interaction mechanism of the context interaction fusion module CIFM to fuse feature information at different levels and sources, the network can be helped to more deeply understand and integrate the relationship between features, thereby enhancing the feature representation ability and realizing multi-scale perception and fusion of features. Through effective information interaction, it helps to reduce redundant information in the features, thereby improving the computational efficiency and reasoning speed of the model, improving the effect and performance of feature fusion, enhancing the generalization ability of the model, and making the model more versatile and adaptable.

[0086] Preferably, in step S23, the three Head detection heads in the original YOLOv8 network model are replaced with a lightweight LSCD detection head. By introducing the LSCD detection head, the number of parameters is effectively reduced and the detection head has a higher multi-scale perception capability. The LSCD detection head is as follows: Figure 4As shown, the LSCD detection head uses a shared GroupNorm convolution layer to replace the two common convolution layers used by the Head detection head, and uses a scale layer to scale the features to solve the problem of inconsistent target scales detected by each detection head.

[0087] By using a shared GroupNorm convolutional layer instead of two ordinary convolutional layers, the complexity and number of parameters of the model can be significantly reduced while ensuring the performance of the model, and the detection head can have higher multi-scale perception capabilities. Reducing the number and complexity of parameters not only reduces the computational overhead of the model in the inference stage, but also accelerates the training process of the model, significantly saving time and computing resources, making the model more versatile and adaptable.

[0088] Preferably, the GroupNorm convolution layer is a regularization method, which divides the feature channels into several groups and performs normalization processing in each group; specifically, the operation steps of the GroupNorm are as follows:

[0089] ① Grouping: Divide the feature channels of each sample into multiple groups (usually several subsets of the number of feature channels), each group contains a certain number of feature channels;

[0090] ② Calculate the mean and variance: Calculate the mean and variance of the feature in each group. The mean and variance here are calculated within a specific group, not within the entire batch;

[0091] ③ Normalization: Normalize the features using the mean and variance calculated within each group. Specifically, for each feature channel, subtract the mean and then divide it by the standard deviation (the variance plus a small constant to prevent division by zero);

[0092] ④ Scaling and biasing: The normalized features can be optionally scaled and biased, that is, multiplied by a learnable scaling factor and added with a learnable bias term.

[0093] The regularization calculation formula is as follows:

[0094]

[0095] in, is the normalized feature, x i is the original feature, μ G is the mean of group G, is the variance of the Gth group, and ∈ is a small constant used to avoid division by zero.

[0096] GroupNorm effectively improves the model's ability to handle small batches of data and irregular data sizes through intra-group normalization, while reducing its dependence on batch size, making it more adaptable to images.

[0097] Further preferably, the scaling process of the features by using the scale layer includes: adjusting the resolution of the feature map by upsampling or downsampling so that the feature scales between different detection heads are consistent, thereby solving the problem of inconsistent target scales.

[0098] Preferably, in the step S3, the input image size of the model training is set to 640×640, the batch size is 16, the number of training iterations is 200, and the initial learning rate is 0.01. After the training is completed, the model saves the best weight file best.pt with the best training result. There is no need to train the model again to achieve the same performance level, which saves time and computing resources for repeated training, and ensures that a stable and good version is used when deploying or further evaluating the model.

[0099] Example 2

[0100] This embodiment provides a method for detecting weeds in vegetable fields based on an improved yolov8 network. Figure 5 As shown, the detection method comprises:

[0101] S01: Use the MSRCP algorithm to enhance the image of vegetable weeds to be detected;

[0102] S02: Inputting the enhanced image of the vegetable weeds to be detected into the vegetable field weed detection model obtained according to the construction method described in Example 1 for detection to obtain a weed detection result.

[0103] In this embodiment, the MSRCP algorithm is first used to enhance the details and contrast of the vegetable weed image to be detected, and then the image is input into the trained vegetable field weed detection model for detection, thereby improving the speed and accuracy of vegetable weed detection, thereby achieving precise mechanical weeding or targeted spraying of herbicides, reducing the risk of environmental pollution, and promoting the modernization and sustainable development of agricultural production.

[0104] Preferably, the MSRCP algorithm is a multi-scale Retinex algorithm combined with color preservation technology, which is used to enhance the details and contrast of the image while retaining the natural color of the image; the algorithm performs multi-scale processing on the image, performs Retinex enhancement at different scales, and then fuses the enhanced results, thereby improving the overall brightness and contrast of the image.

[0105] Further preferably, the calculation formula of the MSRCP algorithm is as follows:

[0106] I nt =(I R , I G , I B ) / 3;

[0107]

[0108] B=max(I Ri , I Gi , I Bi );

[0109] R(x, y) = AI (R,G,B) (x, y);

[0110] Among them, I nt Represents the grayscale value of the intensity image; I R , I G , I B Represents the R, G, and B channel components of the original image; I nti Represents the grayscale value of a single-channel intensity image; subscript i represents the pixel index; R(x, y) represents the enhanced image value; I (R,G,B) (x, y) represents the RGB feature image value of the image at the coordinate (x, y).

[0111] In this embodiment, before the vegetable weed image to be detected is input into the model for detection, the MSRCP algorithm is also used to optimize the vegetable weed image to be detected. The multi-scale method is used to process the image, which not only considers the global illumination change, but also processes the local illumination unevenness and detail information. Through multi-scale decomposition, the detail information of different spatial frequencies is captured, so as to more comprehensively enhance the visual effect of the image. Moreover, MSRCP also emphasizes the protection of the color information of the image. In order to avoid color distortion or change, a color protection mechanism is introduced to ensure that the color characteristics of the original image are maintained as much as possible during the enhancement process, thereby enhancing the details and contrast of the vegetable weed image to be detected, and achieving the image enhancement effect.

[0112] Finally, in step S02, the best.pt weight file with the best training result saved in step S3 is used as the weight file for detecting weeds in vegetable fields, and then the image of the vegetable weeds to be detected after image enhancement is input as a data source into the vegetable field weed model for detection to obtain the detection result of the vegetable field weed detection.

[0113] Example 3

[0114] In this embodiment, an electronic device is provided, such as Figure 6 As shown, Figure 6A schematic diagram of the structure of an electronic device provided in this embodiment. The electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute the method for constructing a vegetable field weed model based on the improved yolov8 network described in Example 1, and / or the method for detecting vegetable field weeds based on the improved yolov8 network described in Example 2.

[0115] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of this solution is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of this solution. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0116] On the other hand, the present embodiment also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the vegetable field weed model construction method based on the improved yolov8 network described in Example 1, and / or implement the vegetable field weed detection method based on the improved yolov8 network described in Example 2 when executing the computer program.

[0117] On the other hand, the present embodiment also provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method for constructing a vegetable field weed model based on an improved yolov8 network described in Example 1 is implemented, and / or when the computer program is executed, the method for detecting vegetable field weeds based on an improved yolov8 network described in Example 2 is implemented.

[0118] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solution of the present invention, and are not intended to limit the specific implementation methods of the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the claims of the present invention shall be included in the protection scope of the claims of the present invention.

Claims

1. A method for constructing a vegetable field weed model based on an improved yolov8 network, comprising: S1: Collect images of weeds in vegetable fields, construct a vegetable weed dataset, and divide the vegetable weed dataset into a training set, a validation set, and a test set according to a preset ratio; S2: Construct an improved yolov8 network model to establish a weed detection model in vegetable fields; S3: input the training set into the improved yolov8 network model for training, use the validation set to verify the performance of the model and adjust the parameters of the model according to the evaluation results of the validation set, and finally use the test set to evaluate the performance of the model to obtain the final vegetable field weed detection model; It is characterized in that the step S2 includes: S21: Introducing deep separable convolution DSConv into the original yolov8 network model; S22: Replace the Concat module in the neck layer of the original yolov8 network model with the context interaction fusion module CIFM; S23: Replace the Head detection head of the original yolov8 network model with a lightweight LSCD detection head.

2. The method for constructing a vegetable field weed model based on an improved yolov8 network according to claim 1, characterized in that: In the step S21, specifically, a depth separable convolution DSConv is introduced into the Backbone layer and the Neck layer of the original yolov8 network model; the DSConv is divided into two parts, one is the Depthwise channel-by-channel convolution applied on a single input channel, and the other is the Pointwise point-by-point convolution with a kernel size of 1×1; the convolution first performs a convolution operation on the input image in space, and then performs a weighted combination of the maps that have undergone the channel-by-channel convolution in the depth direction and outputs them.

3. The method for constructing a vegetable field weed model based on an improved yolov8 network according to claim 1, characterized in that: In step S22, the fusion features of high-dimensional information and low-dimensional information are obtained by introducing CIFM, including: S221: Receive high-dimensional features F h Input and receive low-dimensional features F l enter; S222: The high-dimensional feature F h Input and low-dimensional features F l The inputs are concatenated to generate concatenated features; S223: performing global average pooling processing on the connection features and performing a first linear transformation, then activating them using a ReLU function, then performing a second linear transformation, and finally activating them using a Sigmoid function to generate a weight coefficient; S224: The weight coefficient and the high-dimensional feature F h Input element-by-element multiplication to obtain the first multiplication result; the weight coefficient is combined with the low-dimensional feature F l The input is multiplied element by element to obtain the second multiplication result; S225: High-dimensional features F h The input is added to the second multiplication result to obtain the first addition result; the low-dimensional feature F is received l The input is added to the first multiplication result to obtain a second addition result; S226: Connect the outputs of the first addition result and the second addition result to generate a final fusion feature F f .

4. The method for constructing a vegetable field weed model based on an improved yolov8 network according to claim 1, characterized in that: In step S23, the LSCD detection head uses a shared GroupNorm convolutional layer to replace the two common convolutional layers used by the Head detection head, and uses a scale layer to perform scale scaling processing on the features.

5. The method for constructing a vegetable field weed model based on an improved yolov8 network according to claim 4, characterized in that: The GroupNorm convolution layer is a regularization method that divides the feature channels into several groups and performs normalization processing in each group. The regularization calculation formula is as follows: in, is the normalized feature, x i is the original feature, μ G is the mean of group G, is the variance of the Gth group, and ∈ is a small constant used to avoid division by zero.

6. The method for constructing a vegetable field weed model based on an improved yolov8 network according to claim 5, characterized in that: The scale layer is used to scale the features, including: adjusting the resolution of the feature map by upsampling or downsampling, so that the feature scales of different detection heads are consistent, thereby solving the problem of inconsistent target scales.

7. The method for constructing a vegetable field weed model based on an improved yolov8 network according to any one of claims 1 to 6, characterized in that: In step S1, the collecting of weed images in the vegetable field includes: collecting images of vegetable seedlings and weeds at different inclination angles between the crop growth plane and the image sensor; collecting images of vegetable seedlings and weeds in which weeds are associated with crops, weeds are far away from crops, weeds are densely distributed, and crops exist alone.

8. A method for detecting weeds in vegetable fields based on an improved yolov8 network, characterized in that: The method comprises: S01: Use the MSRCP algorithm to enhance the image of vegetable weeds to be detected; S02: Inputting the enhanced image of the vegetable weeds to be detected into the vegetable field weed detection model obtained by the construction method according to any one of claims 1 to 7 for detection to obtain a weed detection result.

9. The method for detecting weeds in vegetable fields based on the improved yolov8 network according to claim 8, characterized in that: The MSRCP algorithm combines the color preservation technology, performs multi-scale processing on the image, performs Retinex enhancement at different scales, and then fuses the enhanced results, thereby improving the overall brightness and contrast of the image.

10. The method for detecting weeds in vegetable fields based on the improved yolov8 network according to claim 9, characterized in that: The calculation formula of the MSRCP algorithm is as follows: I nt =(I R +I G +I B ) / 3; B=max(I Ri +I Gi +I Bi ); R(x,y)=AI (R,G,B) (x,y); Among them, I nt Represents the grayscale value of the intensity image; I R , I G , I B Represents the R, G, and B channel components of the original image; I nti Represents the grayscale value of a single-channel intensity image; subscript i represents the pixel index; R(x, y) represents the enhanced image value; I (R,G,B) (x, y) represents the RGB feature image value of the image at the coordinate (x, y).

Citation Information

Patent Citations

  • Small pest detection system and method based on improved YOLOv3

    CN114219984A

  • Field wheat ear detection method based on YOLOv8

    CN117173571A

  • Field weed detection method based on YOLOv8 optimization

    CN118314438A

  • Deep learning-based targeted removal method and system for weeds in corn field

    CN118608946A