Plant disease detection method and device combining SRGAN and YOLOV8
By combining SRGAN and YOLOV8 networks, high-resolution image reconstruction and detail texture enhancement are achieved, which solves the problem of insufficient detection of small target diseases in traditional detection methods and improves the accuracy and adaptability of plant disease detection.
Patent Information
- Application Number
- CN202510672900.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-23
- Publication Date
- 2025-09-05
AI Technical Summary
Traditional plant disease detection relies on manual inspections, which is time-consuming and labor-intensive. Existing machine vision technology performs poorly in detecting low disease severity and small targets, making it difficult to distinguish between different diseases and lacking generalization capabilities.
Combining SRGAN and YOLOV8 networks, through image super-resolution reconstruction and the introduction of small target detection layer and triple attention mechanism, the image resolution and detail texture quality are improved, and the detection ability of small target diseases is enhanced.
It significantly improves the accuracy and robustness of plant disease detection, reduces missed detections and false detections, and enhances the adaptability of the model in complex agricultural environments.
Smart Images

Figure CN120599400A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of image detection technology, and in particular to a plant disease detection method and device combining SRGAN and YOLOV8. Background Art
[0002] Traditionally, plant disease detection has relied on manual labor, requiring experienced farmers to patrol the fields and inspect each plant individually. This is undoubtedly a time-consuming and labor-intensive task. However, the rapid development of machine vision technology has led to its widespread application in agriculture. The application of visual inspection technology enables intelligent identification of plant diseases, freeing up human resources, significantly reducing costs, and effectively ensuring the quality and safety of agricultural products. Vision-based inspection technology relies on image feature extraction and pattern recognition. Deep learning networks demonstrate significant advantages in this regard, particularly the YOLO object detection network, which boasts high accuracy and speed.
[0003] However, the performance of this network depends on image quality. When plant disease severity is low, the targets are relatively small, occupying fewer pixels in the image, making it difficult for the target detection network to capture these subtle features. Furthermore, the image features of different diseases are relatively similar and not very distinct, making it difficult for the target detection network to accurately distinguish between them, leading to frequent false positives. Furthermore, while deep learning networks excel on specific datasets, their generalization and robustness are clearly insufficient when applied to the natural environments found in real agricultural scenarios. Therefore, a technology that can adapt to natural environments, distinguish between different diseases, and accurately detect small targets is urgently needed. Summary of the Invention
[0004] The purpose of the present invention is to provide a plant disease detection method and device combining SRGAN and YOLOV8 to address the deficiencies in the prior art, improve the resolution of images, enhance the quality of detail textures, and improve the detection capability of diseases, especially small target diseases.
[0005] One embodiment of the present application provides a plant disease detection method combining SRGAN and YOLOV8, the method comprising:
[0006] Obtain a dataset containing disease images for plant disease detection, annotate the dataset, generate XML tags, convert the XML tags into TXT tags, and divide the dataset into a training set, a validation set, and a test set;
[0007] Performing data augmentation on the diseased images in the dataset and performing image super-resolution reconstruction using the SRGAN model, wherein the SRGAN model adopts a generative adversarial network framework to achieve image super-resolution restoration through adversarial training;
[0008] Using the dataset, a YOLOV8 network with a small target detection layer and a triple attention mechanism is trained to obtain a trained YOLOV8 network to achieve plant disease detection.
[0009] Optionally, obtaining a data set containing disease images for plant disease detection includes:
[0010] A depth camera was used in an orchard to collect disease images in a greenhouse environment under different lighting backgrounds to obtain a self-collected dataset.
[0011] A public data set is obtained, and the self-collected data set and the public data set are used as a data set containing disease images for plant disease detection.
[0012] Optionally, the SRGAN model includes:
[0013] A generator network and a discriminator network, wherein the training process of the generator network is optimized and guided based on content loss and adversarial loss, the content loss can be measured using mean squared error based on feature space, and during training, the total loss function of the generator network is obtained by weighted summation of content loss and adversarial loss.
[0014] Optionally, the small target detection layer includes:
[0015] The Upsample-Concat-C2f structure module and the CBS-Concat-C2f structure module are added after the head output of the fifteenth layer of the existing YOLOV8 network, where:
[0016] The Upsample-Concat-C2f structure module is designed to specifically serve the output of the small target branch 160x160 head. It can upsample and fuse the features related to the small target to enhance the expressiveness of the small target features.
[0017] The CBS-Concat-C2f structure uses its convolution function to convert the 160x160 convolution into 80x80, thereby transforming the size of the feature map so that it can be spliced with the 80x80 head output of the fifteenth layer.
[0018] Optionally, the triple attention mechanism consists of three branch modules, which capture the dependencies between different dimensions of the input tensor (C, H), (C, W) and (H, W) respectively through rotation operations, where the input tensor X∈R C×H×W , where C represents the number of channels of the input feature map, H represents the height of the input feature map, and W represents the width of the input feature map.
[0019] Optionally, the data set is used to train a YOLOv8 network that introduces a small target detection layer and a triple attention mechanism to obtain a trained YOLOv8 network, including:
[0020] Use public datasets to pre-train the YOLOV8 network with a small object detection layer and triple attention mechanism to obtain the optimal initial weights;
[0021] The YOLOV8 network with the optimal initial weights is migrated to a self-collected dataset under a natural background for secondary training to obtain the optimal weights, and the trained YOLOV8 network with the optimal weights is obtained.
[0022] Another embodiment of the present application provides a plant disease detection device combining SRGAN and YOLO V8, the device comprising:
[0023] An acquisition module is used to acquire a dataset containing disease images for plant disease detection, annotate the dataset, generate XML tags, convert the XML tags into TXT tags, and divide the dataset into a training set, a validation set, and a test set;
[0024] An enhancement module is used to perform data enhancement operations on the diseased images in the dataset and perform image super-resolution reconstruction using the SRGAN model, wherein the SRGAN model adopts the framework of a generative adversarial network and achieves image super-resolution restoration through adversarial training;
[0025] A training module is used to use the data set to train the YOLOV8 network that introduces a small target detection layer and a triple attention mechanism to obtain a trained YOLOV8 network to achieve plant disease detection.
[0026] Yet another embodiment of the present application provides a storage medium, wherein the storage medium stores a computer program, wherein the computer program is configured to execute any of the above methods when run.
[0027] Yet another embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute any of the above methods.
[0028] Compared with the prior art, the present invention provides a plant disease detection method combining SRGAN and YOLOv8, which obtains a data set containing disease images for plant disease detection, annotates the data set, generates XML tags, converts the XML tags into TXT tags, and divides the data set into a training set, a validation set, and a test set; performs data enhancement on the disease images in the data set, and uses the SRGAN model to perform image super-resolution reconstruction, wherein the SRGAN model adopts the framework of a generative adversarial network and realizes image super-resolution restoration through adversarial training; uses the data set to train a YOLOv8 network that introduces a small target detection layer and a triple attention mechanism to obtain a trained YOLOv8 network to realize plant disease detection, thereby improving the resolution of the image and enhancing the quality of detailed texture, so as to improve the detection capability of diseases, especially small target diseases. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 A hardware structure block diagram of a computer terminal for a plant disease detection method combining SRGAN and YOLOV8 provided in an embodiment of the present invention;
[0030] Figure 2 A schematic diagram of a process for plant disease detection combining SRGAN and YOLOV8 provided in an embodiment of the present invention;
[0031] Figure 3 A super-resolution image enhancement effect diagram provided by an embodiment of the present invention;
[0032] Figure 4 A comparison chart of the SRGAN enhancement and original image detection effects provided by an embodiment of the present invention;
[0033] Figure 5 An improved YOLOV8 network model structure diagram provided by an embodiment of the present invention;
[0034] Figure 6 A structural diagram of a triple attention model provided by an embodiment of the present invention;
[0035] Figure 7 A comparison chart of the detection effects of a method combining SRGAN and an improved YOLOV8 with the original method provided by an embodiment of the present invention;
[0036] Figure 8 A schematic diagram of the structure of a plant disease detection device combining SRGAN and YOLOV8 provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0037] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and are not to be construed as limiting the present invention.
[0038] The present invention is mainly used to solve the problem that traditional target detection networks lack learning of target disease features, resulting in the omission of small target diseases and confusion of similar diseases. The present invention provides a disease detection method based on an improved YOLOV8 network. A small target detection layer and a triplet attention mechanism are introduced into the YOLOV8 network. At the same time, the SRGAN (Super-Resolution Generative Adversarial Network) network model is combined with image super-resolution reconstruction to enhance the realism of generated high-resolution images. This method can not only improve the resolution of the image, but also enhance the quality of the detailed texture, so as to improve the detection ability of diseases, especially small target diseases.
[0039] The embodiment of the present invention first provides a plant disease detection method combining SRGAN and YOLOV8, which can be applied to electronic devices such as computer terminals, specifically ordinary computers.
[0040] The following describes it in detail by taking running on a computer terminal as an example. Figure 1 The hardware structure block diagram of a computer terminal for a plant disease detection method combining SRGAN and YOLOV8 provided in an embodiment of the present invention. Figure 1 As shown, the computer terminal may include one or more ( Figure 1 Only one is shown) a processor 102 (the processor 102 may include but is not limited to a microprocessor MCU or a programmable logic device FPGA and other processing devices) and a memory 104 for storing data. Optionally, the computer terminal may also include a transmission device 106 for communication functions and an input and output device 108. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above-mentioned computer terminal. For example, the computer terminal may also include Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.
[0041] The memory 104 can be used to store software programs and modules for application software, such as the program instructions / modules corresponding to the plant disease detection method combining SRGAN and YOLO V8 in the embodiments of the present application. The processor 102 executes the software programs and modules stored in the memory 104 to perform various functional applications and data processing, thereby implementing the above-mentioned methods. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories may be connected to the computer terminal via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0042] The transmission device 106 is used to receive or send data via a network. A specific example of the aforementioned network may include a wireless network provided by a communications provider of a computer terminal. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0043] See also Figure 2-Figure 7 , an embodiment of the present invention provides a plant disease detection method combining SRGAN and YOLOV8, the method may include the following steps:
[0044] S201, obtaining a dataset containing disease images for plant disease detection, annotating the dataset, generating XML tags, converting the XML tags into TXT tags, and dividing the dataset into a training set, a validation set, and a test set;
[0045] Specifically, obtaining a data set containing disease images for plant disease detection includes:
[0046] A depth camera is used in an orchard to collect disease images in a greenhouse environment under different lighting backgrounds to obtain a self-collected dataset; a public dataset is obtained, and the self-collected dataset and the public dataset are used as a dataset containing disease images for plant disease detection.
[0047] S202, performing data augmentation on the diseased images in the dataset, and performing image super-resolution reconstruction using an SRGAN model, wherein the SRGAN model adopts a generative adversarial network framework and achieves image super-resolution restoration through adversarial training;
[0048] Specifically, the SRGAN model includes: a generator network and a discriminator network, wherein the training process of the generator network is optimized and guided based on content loss and adversarial loss, and the content loss can be measured using the mean square error based on the feature space. During the training process, the total loss function of the generator network is obtained by weighted summation of the content loss and adversarial loss.
[0049] S203: Using the data set, training the YOLOv8 network that introduces a small target detection layer and a triple attention mechanism to obtain a trained YOLOv8 network to achieve plant disease detection.
[0050] Specifically, the small target detection layer includes: an Upsample-Concat-C2f structure module and a CBS-Concat-C2f structure module added after the head output of the fifteenth layer of the existing YOLOV8 network, wherein: the Upsample-Concat-C2f structure module is specifically used to serve the output of the small target branch 160x160head, and can upsample and fuse the small target related features to enhance the expressiveness of the small target features; the CBS-Concat-C2f structure uses its convolution function to convert the 160x160 convolution into 80x80, thereby realizing the transformation of the feature map size so that it can be spliced with the 80x80 head output of the fifteenth layer.
[0051] Specifically, the triple attention mechanism consists of three branch modules, which capture the dependencies between different dimensions of the input tensor (C, H), (C, W) and (H, W) through rotation operations, where the input tensor X∈R C×H×W , where C represents the number of channels of the input feature map, H represents the height of the input feature map, and W represents the width of the input feature map.
[0052] Specifically, the dataset is used to train the YOLOv8 network that introduces a small target detection layer and a triple attention mechanism to obtain a trained YOLOv8 network, including:
[0053] Use public datasets to pre-train the YOLOV8 network with a small object detection layer and triple attention mechanism to obtain the optimal initial weights;
[0054] The YOLOV8 network with the optimal initial weights is migrated to a self-collected dataset under a natural background for secondary training to obtain the optimal weights, and the trained YOLOV8 network with the optimal weights is obtained.
[0055] The present invention is a small target disease detection method that combines SRGAN and YOLOV8. The improved YOLOV8 network model structure is shown in the figure below: Figure 5 The specific steps include:
[0056] Step S1: Use the Intel Real Sense D455 depth camera in the orchard to collect disease images in a greenhouse environment under different lighting backgrounds to ensure the diversity of the dataset and enhance the generalization ability of the model; at the same time, in order to increase the number of samples, some public datasets are used as supplements.
[0057] Step S2: Labelimg is used to annotate the dataset and generate XML tags. The XML tags are converted into TXT tags using a Python script and the dataset is divided into a training set (train), a validation set (val), and a test set (text) with a ratio of 8:1:1.
[0058] Step S3: performing data augmentation operations on the collected fruit images, including brightness adjustment, contrast-limited adaptive histogram equalization (CLAHE), multi-scale training, and noise addition to improve the robustness of the model;
[0059] Step S4: Use the SRGAN model (the enhancement effect of the SRGAN network on the image is as follows Figure 3 As shown in the figure, the image after super-resolution enhancement has higher clarity) is used for image super-resolution reconstruction tasks. The framework of generative adversarial network is adopted to achieve high-quality image super-resolution restoration through adversarial training. It is used to improve the detection accuracy of the model and the detection ability of small target diseases. The improvement of detection ability using this model is compared with Figure 4 As shown in the figure, the image detection effect is better after being enhanced using the SRGAN network. During the super-resolution model training process, the training epochs were set to 200. The maximum learning rate was set to 0.0002. The input high-resolution images were uniformly sized at 256×256, and the input low-resolution images were sized at 1024×1024. A batch size of 8 was used, and the model performed a fourfold upsampling operation.
[0060] Step S5: Introduce a small target detection layer into the YOLOV8 network to improve the detection capability of small targets.
[0061] Step S6: Introduce the triple attention mechanism into the YOLOV8 network to improve the network's ability to focus on subtle features. Figure 6 This is the structure diagram of the triple attention model.
[0062] Step S7: Run the train.py file and pre-train using a public dataset. After obtaining the optimal initial weights, transfer the model to a self-collected dataset with a natural background for secondary training. Set the number of iterations to 200 and the number of images trained in a single batch to 8. The Adam algorithm is used to optimize the adaptive learning rate of each weight parameter, with an initial learning rate of 0.001 and a minimum learning rate of 0.00001. After training, obtain the trained weights best.pt.
[0063] Step S8: Load the best training weight file into the prediction script, add the prediction set image, and evaluate the improved YOLOV8 model for small target disease detection. The comparison of disease detection effects before and after improvement is shown in the figure below. Figure 7 As shown, it can be clearly seen that the improved method reduces the probability of false detection, missed detection and re-detection, and improves the detection accuracy.
[0064] Furthermore, the SRGAN model, used for image super-resolution reconstruction tasks, adopts the framework of generative adversarial networks and achieves high-quality image super-resolution restoration through adversarial training. The model consists of two main components: a generator network and a discriminator network. The training process of the generator network is optimized and guided by two core loss functions. The content loss can be measured using the mean squared error based on the feature space, and its expression is:
[0065]
[0066] Among them, G i is the generator network (Generator), H i is the feature map height, W i is the feature map width, is the eigenvalue of the real high-resolution image y at position (h, w) in the j-th layer feature map, It is the feature value of the super-resolution image G(x) output by the generator at position (h, w) in the j-th layer feature map, y is the real high-resolution image, and x is the input low-resolution image.
[0067] The adversarial loss can be expressed as:
[0068] L adv (G) = log D (y) + log (1 - D (G (x)))
[0069] Among them, D(y) is the discriminator's probability of distinguishing the real image y (that is, the probability that the discriminator thinks y is a real image), D(G(x)) is the discriminator's probability of distinguishing the generated image G(x) (that is, the probability that the discriminator thinks G(x) is a real image), G(x) is the super-resolution image generated by the generator based on the input x, x is the input low-resolution image, y is the generated real high-resolution image, and G is the generator network.
[0070] During training, the total loss function of the generator is expressed as:
[0071] L G =αL content (G)+βL adv (G)
[0072] Among them, α is the weight coefficient of content loss, which is used to control the importance of feature matching, and β is the weight coefficient of adversarial loss, which is used to balance the authenticity of the generated image.
[0073] Furthermore, an Upsample-Concat-C2f module has been added to the output of the 15th layer of the existing YOLOV8 head. This module is specifically designed to serve the output of the 160x160 head of the small object branch. It can effectively upsample and fuse features related to small objects, thereby enhancing the expressiveness of small object features to a certain extent, allowing subsequent processing to better utilize this enhanced feature information.
[0074] Next, a CBS-Concat-C2f architecture was employed. Within this architecture, convolution is first used to convert the 160x160 convolution to 80x80. This process effectively transforms the feature map size, enabling effective splicing (contact) with the 80x80 head output from the fifteenth layer. This splicing process organically integrates small-target-related features extracted from different layers, enabling the model to obtain more usable feature information. This helps improve the model's ability to detect small-target diseases on tomato leaves, enabling more accurate identification and location of small-target diseases with less obvious features.
[0075] Furthermore, the triple attention mechanism is an innovative neural network module. Triple attention is different from the traditional way of calculating channel importance weights. It is mainly composed of three branches. The three branch modules capture the dependencies between different dimensions of the input tensor (C, H), (C, W) and (H, W) through rotation operations. The following figure is its complete structure diagram. Input tensor, where C represents the number of channels of the input for the input feature map, H represents the height of the input feature map, and W represents the width of the input feature map. Z Pool is a pooling operation that performs average pooling and maximum pooling on the input tensor in the channel dimension and splices the results in the channel dimension, which enables the layer to retain the rich representation of the actual tensor while reducing its depth to reduce the amount of computation. Z Pool can be expressed by the formula:
[0076] Zpool(x)=[MaxPool 0d (x),AvgPool 0d (x)]
[0077] Among them, MaxPool 0d (x) is the maximum pooling operation performed on dimension d, and the output retains the maximum value along this dimension, AvgPool 0d (x) is the average pooling operation performed on dimension d, and the output is the average value along this dimension. x is the number of input feature maps, and d is the dimension of the pooling operation.
[0078] The top branch calculates the dependency between the attention channel dimension C and the spatial dimension H. First, the input tensor x is rotated 90° counterclockwise along the H axis, and the dimension is reduced by the Z Pool layer to a (2×H×C) tensor. Then, it is subjected to k×k convolution and batch normalization to generate a (1×H×C) tensor. The attention weight is obtained by Sigmoid activation, and finally, it is rotated 90° clockwise along the H axis to restore the original shape.
[0079] The middle branch calculates the dependency between the channel dimension C and the spatial dimension W. Similar to the top branch, it first rotates 90° counterclockwise along the W axis, performs dimensionality reduction through the Z Pool layer, then performs k×k convolution and batch normalization to generate a (1×C×W) tensor, activates it with Siqmoid to obtain the weights, and finally restores it by rotating 90° clockwise along the W axis.
[0080] The bottom branch establishes a dependency between the spatial dimensions H and W. This is directly reduced to a channel dimension of 2 via a Z Pool layer, resulting in a (2 × H × W) tensor. This is then convolved with a kernel size of k and batch normalized to generate a (1 × H × W) tensor. This is then weighted by a Sigmoid activation and applied to the input. Finally, the refined (C × H × W) tensors generated by the three branches are simply averaged and aggregated to produce the final output.
[0081] The technical solution of this invention offers significant advantages in detecting small plant disease targets, significantly improving detection accuracy and resolving the difficulty in distinguishing similar diseases. By introducing the SRGAN network for image super-resolution reconstruction, its generative adversarial network framework and unique loss function settings effectively improve image spatial resolution and enhance detail texture quality, enabling the model to capture more subtle disease features, reducing missed and false detections caused by low image resolution, and significantly enhancing the ability to detect small disease targets. Furthermore, the YOLOV8 network structure is optimized.
[0082] The introduced small target detection layer works together through the Upsample-Concat-C2f and CBS-Concat-C2f structural modules to upsample, fuse, resize, and splice and integrate small target features, effectively enhancing the expressiveness of small target features, overcoming the limitations of traditional YOLOv8 in handling small target diseases, and improving the detection accuracy of small target diseases.
[0083] A triple attention mechanism is also incorporated. Its three branches, through rotation operations, capture the dependencies between different dimensions of the input tensor and perform a Z-pooling operation. Each branch undergoes convolution, normalization, and activation to generate attention weights and aggregate the outputs. This allows the detection model to precisely focus on key feature areas, further improving network accuracy, effectively reducing the false detection rate of similar diseases, and enhancing the ability to detect small-target diseases. This also significantly improves model performance and generalization capabilities. Data augmentation operations, including brightness adjustment, CLAHE, multi-scale training, and noise addition, enhance the model's adaptability to diverse environments and effectively improve generalization capabilities, making it more robust in complex and changing real-world agricultural scenarios and reducing the impact of environmental changes on detection results.
[0084] It can be seen that a data set containing disease images for plant disease detection is obtained, the data set is annotated, and xml tags are generated at the same time. The xml tags are converted into txt tags, and the data set is divided into a training set, a validation set, and a test set; data enhancement operations are performed on the disease images in the data set, and the SRGAN model is used to perform image super-resolution reconstruction, wherein the SRGAN model adopts the framework of a generative adversarial network and realizes image super-resolution restoration through adversarial training; the data set is used to train the YOLOV8 network that introduces a small target detection layer and a triple attention mechanism to obtain a trained YOLOV8 network to realize plant disease detection, thereby improving the resolution of the image and enhancing the quality of detailed texture, so as to improve the detection capability of diseases, especially small target diseases.
[0085] Another embodiment of the present invention provides a plant disease detection device combining SRGAN and YOLOV8, see Figure 8, the device may include:
[0086] Acquisition module 801 is used to acquire a dataset containing disease images for plant disease detection, annotate the dataset, generate XML tags, convert the XML tags into TXT tags, and divide the dataset into a training set, a validation set, and a test set;
[0087] An enhancement module 802 is configured to perform data enhancement on the diseased images in the dataset and perform image super-resolution reconstruction using an SRGAN model, wherein the SRGAN model uses a generative adversarial network framework to achieve image super-resolution restoration through adversarial training.
[0088] The training module 803 is used to use the data set to train the YOLOV8 network that introduces a small target detection layer and a triple attention mechanism to obtain a trained YOLOV8 network to achieve plant disease detection.
[0089] It can be seen that a data set containing disease images for plant disease detection is obtained, the data set is annotated, and xml tags are generated at the same time. The xml tags are converted into txt tags, and the data set is divided into a training set, a validation set, and a test set; data enhancement operations are performed on the disease images in the data set, and the SRGAN model is used to perform image super-resolution reconstruction, wherein the SRGAN model adopts the framework of a generative adversarial network and realizes image super-resolution restoration through adversarial training; the data set is used to train the YOLOV8 network that introduces a small target detection layer and a triple attention mechanism to obtain a trained YOLOV8 network to realize plant disease detection, thereby improving the resolution of the image and enhancing the quality of detailed texture, so as to improve the detection capability of diseases, especially small target diseases.
[0090] An embodiment of the present invention further provides a storage medium storing a computer program, wherein the computer program is configured to execute the steps of any one of the above method embodiments when running.
[0091] Specifically, in this embodiment, the above-mentioned storage medium may be configured to store a computer program for performing the following steps:
[0092] S201, obtaining a dataset containing disease images for plant disease detection, annotating the dataset, generating XML tags, converting the XML tags into TXT tags, and dividing the dataset into a training set, a validation set, and a test set;
[0093] S202, performing data augmentation on the diseased images in the dataset, and performing image super-resolution reconstruction using an SRGAN model, wherein the SRGAN model adopts a generative adversarial network framework and achieves image super-resolution restoration through adversarial training;
[0094] S203: Using the data set, training the YOLOv8 network that introduces a small target detection layer and a triple attention mechanism to obtain a trained YOLOv8 network to achieve plant disease detection.
[0095] Specifically, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0096] It can be seen that a data set containing disease images for plant disease detection is obtained, the data set is annotated, and xml tags are generated at the same time. The xml tags are converted into txt tags, and the data set is divided into a training set, a validation set, and a test set; data enhancement operations are performed on the disease images in the data set, and the SRGAN model is used to perform image super-resolution reconstruction, wherein the SRGAN model adopts the framework of a generative adversarial network and realizes image super-resolution restoration through adversarial training; the data set is used to train the YOLOV8 network that introduces a small target detection layer and a triple attention mechanism to obtain a trained YOLOV8 network to realize plant disease detection, thereby improving the resolution of the image and enhancing the quality of detailed texture, so as to improve the detection capability of diseases, especially small target diseases.
[0097] An embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any one of the above method embodiments.
[0098] Specifically, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0099] Specifically, in this embodiment, the processor may be configured to execute the following steps through a computer program:
[0100] S201, obtaining a dataset containing disease images for plant disease detection, annotating the dataset, generating XML tags, converting the XML tags into TXT tags, and dividing the dataset into a training set, a validation set, and a test set;
[0101] S202, performing data augmentation on the diseased images in the dataset, and performing image super-resolution reconstruction using an SRGAN model, wherein the SRGAN model adopts a generative adversarial network framework and achieves image super-resolution restoration through adversarial training;
[0102] S203: Using the data set, training the YOLOv8 network that introduces a small target detection layer and a triple attention mechanism to obtain a trained YOLOv8 network to achieve plant disease detection.
[0103] Specifically, the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0104] It can be seen that a data set containing disease images for plant disease detection is obtained, the data set is annotated, and xml tags are generated at the same time. The xml tags are converted into txt tags, and the data set is divided into a training set, a validation set, and a test set; data enhancement operations are performed on the disease images in the data set, and the SRGAN model is used to perform image super-resolution reconstruction, wherein the SRGAN model adopts the framework of a generative adversarial network and realizes image super-resolution restoration through adversarial training; the data set is used to train the YOLOV8 network that introduces a small target detection layer and a triple attention mechanism to obtain a trained YOLOV8 network to realize plant disease detection, thereby improving the resolution of the image and enhancing the quality of detailed texture, so as to improve the detection capability of diseases, especially small target diseases.
[0105] The above describes in detail the structure, features and effects of the present invention based on the embodiments shown in the drawings. The above is only a preferred embodiment of the present invention, but the scope of implementation of the present invention is not limited to what is shown in the drawings. Any changes made in accordance with the concept of the present invention, or modifications to equivalent embodiments with equivalent changes, which do not exceed the spirit covered by the description and drawings, should be within the scope of protection of the present invention.
Claims
1. A plant disease detection method combining SRGAN and YOLOV8, characterized in that: The method comprises: Obtain a dataset containing disease images for plant disease detection, annotate the dataset, generate XML tags, convert the XML tags into TXT tags, and divide the dataset into a training set, a validation set, and a test set; Performing data augmentation on the diseased images in the dataset and performing image super-resolution reconstruction using the SRGAN model, wherein the SRGAN model adopts a generative adversarial network framework to achieve image super-resolution restoration through adversarial training; Using the dataset, a YOLOV8 network with a small target detection layer and a triple attention mechanism is trained to obtain a trained YOLOV8 network to achieve plant disease detection.
2. The method according to claim 1, characterized in that The step of obtaining a data set containing disease images for plant disease detection includes: A depth camera was used in an orchard to collect disease images in a greenhouse environment under different lighting backgrounds to obtain a self-collected dataset. A public data set is obtained, and the self-collected data set and the public data set are used as a data set containing disease images for plant disease detection.
3. The method according to claim 2, characterized in that The SRGAN model includes: A generator network and a discriminator network, wherein the training process of the generator network is optimized and guided based on content loss and adversarial loss, the content loss can be measured using mean squared error based on feature space, and during training, the total loss function of the generator network is obtained by weighted summation of content loss and adversarial loss.
4. The method according to claim 3, characterized in that The small target detection layer includes: The Upsample-Concat-C2f structure module and the CBS-Concat-C2f structure module are added after the head output of the fifteenth layer of the existing YOLOV8 network, where: The Upsample-Concat-C2f structure module is designed to specifically serve the output of the small target branch 160x160 head. It can upsample and fuse the features related to the small target to enhance the expressiveness of the small target features. The CBS-Concat-C2f structure uses its convolution function to convert the 160x160 convolution into 80x80, thereby transforming the size of the feature map so that it can be spliced with the 80x80 head output of the fifteenth layer.
5. The method according to claim 4, characterized in that The triple attention mechanism consists of three branch modules, which capture the dependencies between different dimensions of the input tensor (C, H), (C, W) and (H, W) through rotation operations, where the input tensor X∈R C×H×W , where C represents the number of channels of the input feature map, H represents the height of the input feature map, and W represents the width of the input feature map.
6. The method according to claim 5, characterized in that The dataset is used to train the YOLOV8 network that introduces a small target detection layer and a triple attention mechanism to obtain a trained YOLOV8 network, including: Use public datasets to pre-train the YOLOV8 network with a small object detection layer and triple attention mechanism to obtain the optimal initial weights; The YOLOV8 network with the optimal initial weights is migrated to a self-collected dataset under a natural background for secondary training to obtain the optimal weights, and the trained YOLOV8 network with the optimal weights is obtained.
7. A plant disease detection device combining SRGAN and YOLOV8, characterized in that: The device comprises: An acquisition module is used to acquire a dataset containing disease images for plant disease detection, annotate the dataset, generate XML tags, convert the XML tags into TXT tags, and divide the dataset into a training set, a validation set, and a test set; An enhancement module is used to perform data enhancement operations on the diseased images in the dataset and perform image super-resolution reconstruction using the SRGAN model, wherein the SRGAN model adopts the framework of a generative adversarial network and achieves image super-resolution restoration through adversarial training; A training module is used to use the data set to train the YOLOV8 network that introduces a small target detection layer and a triple attention mechanism to obtain a trained YOLOV8 network to achieve plant disease detection.
8. The device according to claim 7, characterized in that The acquisition module is specifically used to: A depth camera was used in an orchard to collect disease images in a greenhouse environment under different lighting backgrounds to obtain a self-collected dataset. A public data set is obtained, and the self-collected data set and the public data set are used as a data set containing disease images for plant disease detection.
9. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 6 when executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 6.