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

By improving the YOLOv8 network model, combining depthwise separable convolution, contextual interaction fusion module and lightweight detection head, and combining image enhancement algorithm, the problems of low accuracy and poor real-time performance of weed detection in vegetable fields are solved, and efficient and environmentally friendly weed identification and weed control are achieved.

CN119229283BActive Publication Date: 2025-10-10SOUTH CHINA AGRICULTURAL UNIVERSITY +1
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the existing technology, the accuracy of weed detection in vegetable fields is low and the real-time performance is poor. Traditional methods are time-consuming and labor-intensive, with high risks of environmental pollution, and traditional identification methods have poor robustness.

Method used

An improved yolov8 network model was adopted to construct a weed detection model for vegetable fields by introducing the depthwise separable convolution (DSConv), the contextual interaction fusion module (CIFM) and the lightweight detection head (LSCD). The image was enhanced in combination with the MSRCP algorithm.

Benefits of technology

It achieves fast and accurate weed detection, improves weed control efficiency and accuracy, reduces environmental pollution, and promotes the modernization and sustainable development of agricultural production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119229283B_ABST
    Figure CN119229283B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on improved yolov8 network's vegetable field weed model construction method, comprising: S1: collection vegetable field weed image, constructs vegetable weed data set, and vegetable weed data set is divided into training set, verification set and test set according to preset proportion;S2: improved yolov8 network model is constructed to establish vegetable field weed detection model;S3: training set is input to the improved yolov8 network model and is trained, and the performance of model is verified using verification set and the parameters of model are adjusted according to the evaluation result of verification set, finally the performance of model is evaluated using the test set, and the final vegetable field weed detection model is obtained;In the step S2, it includes: S21: depth separable convolution DSConv is introduced in original yolov8 network model;S22: the Concat module in neck layer is replaced by context interaction fusion module CIFM;S23: Head detection head is replaced by lightweight LSCD detection head.The application realizes the quick and accurate detection of vegetable and weed.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

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

[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, which seriously affects the yield and quality of vegetables. In addition, some weeds may become the host of pests and diseases, exacerbating the occurrence of vegetable pests and diseases, further threatening the safety and efficiency of agricultural production. Traditional weed control methods mainly rely on manual weeding and chemical herbicides. Manual weeding is effective, but it is time-consuming and labor-intensive, and the cost is high, especially in large-scale planting, which is inefficient. While chemical herbicides are convenient and fast-acting, 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 weed control method has become a hot spot in current agricultural technology research.

[0003] Traditional weed identification methods usually rely on the analysis of plant texture, color, shape and other features. However, these features need to be extracted manually, the algorithm design is complex, and there are defects such as low recognition accuracy and poor robustness. With the progress of science and technology, automated weed control 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 technology greatly improves the efficiency and accuracy of weeding, reduces the risk of environmental pollution, and promotes the modernization and sustainable development of agricultural production. SUMMARY

[0004] The present application aims to overcome at least one of the above-mentioned defects (shortcomings) of the 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 accuracy and poor real-time performance in weed detection. By improving the original yolov8 network to train a vegetable weed detection model, it can accurately identify vegetables and weeds, thereby accurately weeding or targeting spraying 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 application is a vegetable field weed model construction method based on an improved yolov8 network, which comprises:

[0006] S1: Collecting vegetable field weed images, constructing a vegetable weed dataset, and dividing the vegetable weed dataset into a training set, a validation set and a test set according to a predetermined proportion;

[0007] S2: Build 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 depthwise 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. The model is used to detect weeds in the field environment. It can quickly and accurately detect different types of weeds and accurately locate the positions of weeds, thereby accurately performing mechanical weeding or targeted herbicide spraying 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 channel-by-channel convolved maps in the depth direction and outputs them.

[0015] In the present application, the original yolov8 network is optimized and improved, first, the deep separable convolution DSConv is introduced in the Backbone layer and the Neck layer of the original network, the original ordinary convolution and the ordinary convolution in the C2f module are replaced with the deep separable convolution DSConv, under the condition of maintaining the output feature map size and channel size of the convolution consistent with the original network and not damaging the model performance, significantly reducing the parameters and calculation load of the model, at the same time enhancing the receptive field and generalization ability, so as to improve the overall model efficiency and application performance.

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

[0017] S221: receiving high-dimensional feature F h Input and receive low-dimensional feature F l Input;

[0018] S222: connect the high-dimensional feature F h Input and low-dimensional feature F l Input to generate connection features;

[0019] S223: global average pooling processing is performed on the connection features, and first linear transformation is performed, then ReLU function is activated, then second linear transformation is performed, and finally Sigmoid function is activated to generate weight coefficients;

[0020] S224: the weight coefficients are multiplied with the high-dimensional feature F h Input element by element to obtain a first multiplication result; the weight coefficients are multiplied with the low-dimensional feature F l Input element by element to obtain a second multiplication result;

[0021] S225: add the high-dimensional feature F h Input and the second multiplication result to obtain a first addition result; add the received low-dimensional feature F l Input and 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 the final fusion feature F f .

[0023] Therefore, by using the more complex interaction mechanism of the context interaction fusion module CIFM to fuse feature information of different levels and sources, it helps the network to understand and integrate the relationship between features more deeply, thereby enhancing the representation ability of the features, realizing multi-scale perception and fusion of the 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 model complexity and number of parameters can be significantly reduced while ensuring model performance. Reducing the number of parameters and complexity not only reduces the computational overhead of the model during the inference phase, but also accelerates the model training process, significantly saving time and computing resources, making the model more versatile and adaptable.

[0026] Preferably, the GroupNorm convolutional layer is a regularization method that divides the feature channels into several groups and performs normalization within 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 of different detection heads are consistent, thereby solving the problem of inconsistent target scales.

[0031] Preferably, in step S1, the collecting of 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, by collecting images of vegetable seedlings and weeds at different tilt angles and in different scenes to increase the diversity of the dataset, the model can learn a wider range of features and scene changes, improve the generalization ability of the model in practical applications, and thus improve the accuracy and reliability of the model prediction.

[0033] In another aspect, the present application also provides a method for detecting weeds in vegetable fields based on an improved yolov8 network, which comprises the following steps:

[0034] S01: enhancing the image of the vegetable weed to be detected by using the MSRCP algorithm;

[0035] S02: inputting the enhanced image of the vegetable weed to be detected into the weed detection model for vegetable fields obtained according to the construction method to perform detection, and obtaining a weed detection result.

[0036] In the present application, the details and contrast of the image of the vegetable weed to be detected are first enhanced by using the MSRCP algorithm, and then the enhanced image is input into the trained weed detection model for vegetable fields to perform detection, so as to improve the speed and accuracy of the detection of the vegetable weed, thereby realizing accurate 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 combines a color preservation technique, performs Retinex enhancement on different scales by performing multi-scale processing on the image, and then fuses the enhanced results, so as to improve 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] wherein I nt represents an intensity image gray value; I R , I G , and I B represent R, G, and B channel components of the original image; I nti represents a single-channel intensity image gray value; the subscript i represents a pixel index; R(x, y) represents an enhanced image value; and I (R,G,B) (x, y) represents an RGB feature image value of the image at coordinates (x, y).

[0044] Before the image of the vegetable weed to be detected is input into the model for detection in the application, an optimization processing of the image by using an MSRCP algorithm is further included, a multiscale method is used to process the image, not only the global illumination change is considered, but also the local uneven illumination and the detail information can be processed, the detail information of different spatial frequencies is captured through multiscale decomposition, so that the visual effect of the image is more comprehensively enhanced, and the color preservation technology is introduced, so that the color characteristics of the original image are as much as possible maintained in the enhancement process, so that the details and contrast of the vegetable weed image to be detected are enhanced.

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

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

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

[0048] (3) The application replaces the detection head in the original yolov8 network with an LSCD detection head, greatly reduces the parameter amount while ensuring the detection accuracy, and lays a foundation for deployment to embedded devices.

[0049] (4) The application uses the MSRCP algorithm to enhance the details and contrast of the vegetable weed image to be detected, and improves the recognition accuracy of the vegetable weed detection model. BRIEF DESCRIPTION OF DRAWINGS

[0050] Figure 1 The overall flowchart of the vegetable field weed model construction method based on the improved yolov8 network provided by the application is shown.

[0051] Figure 2 The improved yolov8 network structure diagram in the application is shown.

[0052] Figure 3 The structure diagram of the context interaction fusion module proposed in the application is shown.

[0053] Figure 4 The structure diagram of the lightweight scale perception convolution detection head used in the application is shown.

[0054] Figure 5The overall flowchart of the vegetable field weed detection method based on the improved yolov8 network provided by the present application is shown in the figure.

[0055] Figure 6 The structural schematic diagram of the electronic device provided by the present application is shown in the figure. DETAILED DESCRIPTION

[0056] The drawings of the present application are only used for illustrative description, and cannot be understood as a limitation of the present application. In order to better illustrate the following embodiments, some components in the drawings may be omitted, enlarged or reduced, and do not represent the size of the actual product; it is understandable for those skilled in the art that some well-known structures and their descriptions in the drawings may be omitted.

[0057] Embodiment 1

[0058] The technical scheme adopted in this embodiment is a vegetable field weed model construction method based on an improved yolov8 network, as shown in the figure, the construction method comprises: Figure 1

[0059] S1: collecting vegetable field weed images, constructing a vegetable weed dataset, and dividing the vegetable weed dataset into a training set, a validation set and a test set according to a preset ratio;

[0060] S2: constructing an improved yolov8 network model to establish a vegetable field weed detection model;

[0061] S3: inputting the training set into the improved yolov8 network model for training, using the validation set to verify the performance of the model and adjusting the parameters of the model according to the evaluation result of the validation set, finally using the test set to evaluate the performance of the model, and obtaining 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. The model can quickly and accurately detect different types of weeds and accurately locate the position of the weeds, so as to accurately perform mechanical weeding or targeted spraying of herbicides, avoid damage to surrounding crops, improve the precision and efficiency of weeding, and promote the automation and intelligentization of agricultural management.

[0063] ​Preferably, in the step S1, the collecting the vegetable field weed image comprises: collecting the vegetable seedling and weed images with a plurality of different inclination angles between the crop growth plane and the image sensor, at least including inclination angles of 90°, 75°, 45°, etc., and collecting the vegetable seedling and weed images in the cases of weed accompanying crops, weed away from crops, dense distribution of weeds, and crops existing alone, etc., and then performing image labeling by using LabelImg software to construct a vegetable weed dataset. When the vegetable weed dataset is divided, it can be divided according to a ratio of 8:1:1 or according to a ratio of 7:2:1, thereby improving the objectivity and reliability of model evaluation, helping to effectively manage data and optimize the performance and generalization ability of the model.

[0064] Therefore, by collecting the vegetable seedling and weed images under different inclination angles and different scenes to increase the diversity of the dataset and dividing the dataset by a specific ratio, the model can learn more extensive features and scene changes, improve the generalization ability of the model in actual application, and thus improve the accuracy and reliability of the model prediction.

[0065] In addition, in the embodiment, in addition to using LabelImg software for image labeling, image labeling tools and platforms such as LabelMe, CVAT, Labelbox, VGG Image Annotator, Supervisely, and DatumBox can also be used for image labeling. Those skilled in the art can select and combine according to the requirements of specific tasks, and selecting appropriate methods can effectively improve the quality and applicability of the dataset.

[0066] Preferably, as shown in Figure 2 , Figure 2 The improved yolov8 network structure diagram, the improvement of the yolov8 network model in the step S2 comprises:

[0067] S21: introducing a depth separable convolution DSConv into the original yolov8 network model;

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

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

[0070] In the step S21, the depth separable convolution DSConv is introduced into the Backbone layer and the Neck layer of the original yolov8 network model, as shown in Figure 2As shown in the figure, the original ordinary convolution and the ordinary convolution in the C2f module are replaced with 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, while 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 count, and can significantly reduce the computational load of each layer, thereby 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 cost of depth-wise 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 inference 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 wider range of pixels in the input image. This is very beneficial for capturing wider and deeper features in the Backbone layer and Neck layer, and helps to improve the performance of the model in complex scenarios.

[0078] Preferably, in step S22, as Figure 2 As shown in the figure, 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 is combined with 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 Multiply the input element-by-element to get 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 the 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 from different levels and sources, the network can be helped to understand and integrate the relationship between features more deeply, thereby enhancing the representation ability of features and realizing multi-scale perception and fusion of features. Through effective information interaction, it helps to reduce redundant information in 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 lightweight LSCD detection heads. By introducing the LSCD detection head, the number of parameters is effectively reduced and the detection head has 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 instead of the two ordinary convolution layers used by the Head detection head, and uses a scale layer to scale the features, solving the problem of inconsistent target scales detected by each detection head.

[0087] By using a shared GroupNorm convolution layer instead of two ordinary convolution layers, the complexity and parameter quantity of the model can be significantly reduced while ensuring the performance of the model, and the detection head has higher multi-scale perception ability. Reducing the number of parameters and complexity not only reduces the computational overhead of the model in the inference stage, but also speeds up 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 that divides the feature channels into groups and normalizes each group. Specifically, the operation steps of GroupNorm are as follows:

[0089] ①Grouping: Divide the feature channels of each sample into multiple groups (usually a subset of the number of feature channels), each group containing a certain number of feature channels.

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

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

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

[0093] where the regularization formula is as follows:

[0094]

[0095] where, is the normalized feature, x i is the original feature, μ G is the mean of the Gth group, is the variance of the Gth group, and ∈ is a small constant 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 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 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 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 performance 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 includes:

[0101] S01: Use the MSRCP algorithm to enhance the image of vegetables and 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 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 herbicide spraying, 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 to enhance the details and contrast of an 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 to improve the overall brightness and contrast of the image.

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

[0106] I nt R G B

[0107]

[0108] Ri Gi Bi

[0109] (R,G,B)

[0110] nt R G B nti (R,G,B)

[0111] In this embodiment, before the image of the vegetable weed to be detected is input into the model for detection, the image of the vegetable weed to be detected is processed by using the MSRCP algorithm. The image is processed by using a multi-scale method, which not only considers global light changes but also processes local light unevenness and detail information. By multi-scale decomposition, different spatial frequency detail information is captured, so that the visual effect of the image is more comprehensively enhanced. The MSRCP also emphasizes the protection of color information of the image. In order to avoid color distortion or changes, 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 image of the vegetable weed to be detected and achieving the image enhancement effect.

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

[0113] Embodiment 3

[0114] In this embodiment, an electronic device is provided, as shown in Figure 6 Figure 6 ​​​​​​​​​​​​​​​​​​A structural schematic diagram of an electronic device is provided for the embodiment. The electronic device can include a processor 610, a communications interface 620, a memory 630, and a communications bus 640, wherein the processor 610, the communications interface 620, and the memory 630 complete mutual communication through the communications bus 640. The processor 610 can invoke a logical instruction in the memory 630 to execute the improved yolov8 network-based vegetable field weed model construction method described in embodiment 1 and / or the improved yolov8 network-based vegetable field weed detection method described in embodiment 2.

[0115] In addition, the logical instruction in the memory 630 described above can be implemented in the form of a software function unit and sold or used as an independent product, which can be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the present scheme or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present scheme. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

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

[0117] In yet another aspect, the embodiment also provides a computer-readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement the improved yolov8 network-based vegetable field weed model construction method described in embodiment 1 and / or implement the improved yolov8 network-based vegetable field weed detection method described in embodiment 2 when the computer program is executed.

[0118] Obviously, the above embodiments of the present invention are merely examples for the purpose of clearly illustrating the technical solutions 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 within the scope of protection 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 training set, validation set, and test set according to the preset ratio; S2: Build 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 depthwise 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; 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 is combined with 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 Multiply the input element-by-element to get 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 the final fusion feature F f .

2. The method for constructing a vegetable field weed model based on the improved yolov8 network according to claim 1, characterized in that: In the step S21, specifically, the depthwise 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 depthwise separable convolution DSConv first performs a convolution operation on the input image in space, and then performs a weighted combination of the channel-by-channel convolution maps in the depth direction as output.

3. The method for constructing a vegetable field weed model based on an improved yolov8 network according to claim 1, wherein: 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 processing on the features.

4. The method for constructing a vegetable field weed model based on the improved yolov8 network according to claim 3, characterized in that: The GroupNorm convolutional layer is a regularization method that divides the feature channels into several groups and performs normalization within 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.

5. The method for constructing a vegetable field weed model based on the improved yolov8 network according to claim 4, characterized in that: The scaling process of the features using the scale layer includes 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.

6. The method for constructing a vegetable field weed model based on an improved yolov8 network according to any one of claims 1 to 5, characterized in that: In step S1, the collecting of images of weeds in vegetable fields includes: collecting images of vegetable seedlings and weeds at several different tilt 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.

7. 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 vegetables and 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 6 for detection to obtain a weed detection result.

8. The method for detecting weeds in vegetable fields based on the improved yolov8 network according to claim 7, characterized in that: The MSRCP algorithm combines 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.

9. The method for detecting weeds in vegetable fields based on the improved yolov8 network according to claim 8, 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 intensity image grayscale value; 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 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