Tobacco leaf looseness detection method and system based on YOLOv8
By installing light sensors and automated camera equipment in the YOLOv8 detection area, combining machine learning models to predict detection accuracy and dynamically adjust detection thresholds, the problem of interference in the detection accuracy of YOLOv8 model in complex backgrounds and severe lighting changes is solved, and more accurate and consistent detection of tobacco leaf scattering degree is achieved.
Patent Information
- Application Number
- CN202510000488.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2045-01-02
AI Technical Summary
The detection accuracy of the YOLOv8 model is disturbed in complex backgrounds and tobacco leaf production environments with severe light changes, resulting in inaccurate classification results of the degree of tobacco leaf, affecting quality assessment and production consistency.
Install a light sensor in the YOLOv8 detection area to monitor the light intensity change data in real time, and combine it with an automated camera equipment to collect the tobacco leaf scattered image data under different lighting conditions. Through preprocessing and feature extraction, the machine learning model is trained to predict the detection accuracy of the YOLOv8 model and divided into high-precision and low-precision detection according to the output results. For low-precision detection, further analyze the degree of abnormality and dynamically adjust the detection threshold to improve detection accuracy.
The accuracy of detection of tobacco leaf scattering degree in the YOLOv8 model in complex environments has been improved, the model's adaptability is optimized, the accuracy and consistency of tobacco leaf classification in the production process has been ensured, and the overall production quality control level has been improved.
Smart Images

Figure CN119399199B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of tobacco leaf detection, and in particular to a method and system for detecting the degree of looseness of tobacco leaves based on YOLOv8. Background Art
[0002] YOLOv8-based tobacco leaf looseness detection refers to the use of YOLOv8, a deep learning model, to identify and analyze the arrangement of tobacco leaves. YOLOv8 is the latest version of the "You Only Look Once" series and is a fast and accurate target detection algorithm. By training the model, it is possible to process images of loose tobacco leaves, automatically identify and classify tobacco leaves of different looseness, such as dividing tobacco leaves into different categories such as "tight", "medium" and "loose". However, when YOLOv8 detects targets in images, it usually assumes that the targets appear against a relatively simple background. However, in the actual production environment of tobacco leaves, the background is complex and the lighting changes dramatically (such as strong light, shadows or reflections), which may cause abnormalities in the model detection accuracy. At the same time, abnormal detection accuracy will directly affect the classification results of the looseness of tobacco leaves, resulting in inaccurate quality assessment. For example, tobacco leaves that are actually relatively tight may be misjudged as loose, or tobacco leaves with severe looseness may be considered normal. This erroneous quality assessment will interfere with subsequent production links, such as grading, packaging and processing, causing quality control failure, and thus affecting product consistency and market competitiveness. Summary of the invention
[0003] The purpose of the present invention is to provide a method and system for detecting the degree of looseness of tobacco leaves based on YOLOv8 to overcome the shortcomings of the background technology.
[0004] In order to achieve the above object, the present invention provides the following technical solution: a method for detecting the degree of looseness of tobacco leaves based on YOLOv8, comprising the following steps:
[0005] S1: Install several light sensors in the detection area of the image target by YOLOv8 to monitor in real time, obtain the light intensity change data in different time periods, and collect the image data of tobacco leaves under different light intensity conditions by combining with automated camera equipment;
[0006] S2: Preprocess the acquired light intensity change data and scattered tobacco leaf image data, perform feature extraction on the preprocessed data, and train a machine learning model for predicting the detection accuracy of the YOLOv8 model based on the extracted abnormal distribution features of the shadow area and the color change amplitude features;
[0007] S3: According to the output results of the machine learning model, the detection accuracy of the YOLOv8 model is determined and divided into two categories: high-precision detection and low-precision detection. The results of high-precision detection are directly used in subsequent production links;
[0008] S4: For the YOLOv8 model with low-precision detection, further analyze the abnormal degree of the YOLOv8 model detection accuracy, and dynamically adjust the detection threshold of the YOLOv8 model according to the analysis results to improve the detection accuracy.
[0009] Preferably, in S2, the acquired light intensity variation data and the scattered tobacco leaf image data are preprocessed, and feature extraction is performed on the preprocessed data, specifically:
[0010] The abnormal distribution features of the shadow area in the light intensity change data and the color change amplitude features in the scattered tobacco leaf image data are extracted respectively, and the shadow distribution abnormality index is generated based on the extracted abnormal distribution features of the shadow area. The method for obtaining the shadow distribution abnormality index is:
[0011] The light sensor is used to obtain the shadow distribution area data in the detection area in the s time period in real time and construct the corresponding data set, which is integrated into a feature matrix ,in, represents the data point of the i-th sample, and n is the total number of samples. GMM is used to fit the shadow distribution feature data through the expectation maximization algorithm, and the model expression is: ; Where K is the number of Gaussian distributions; is the weight of the kth Gaussian distribution, is the mean vector of the kth Gaussian distribution, is the covariance matrix of the kth Gaussian distribution, is the probability density function of the kth Gaussian distribution, and the formula is: ; Where T is the matrix transpose and d is the dimension of the feature; for each data point , calculate the probability density value of the entire model through the fitted GMM model , the expression is: ; Use the probability density value of the data point To calculate the shadow distribution anomaly index, the expression is: ; In the formula, is the shadow distribution anomaly index.
[0012] Preferably, a color fluctuation deviation index is generated based on the extracted color change amplitude feature, and the method for obtaining the color fluctuation deviation index is:
[0013] Extract the color change amplitude characteristics within the L time period and construct a time series , where t is the number of time steps, is the color change amplitude feature extracted at the tth moment; construct the autoregressive integrated moving average model ARIMA (p, d, q), where p is the order of the autoregressive term, d is the number of differences, and q is the order of the moving average term, which represents the prediction error of the previous q time steps. The expression is: ; In the formula, c is a constant term, is the autoregressive coefficient, which depends on the color change amplitude in the previous p time steps, is the sliding average coefficient, which depends on the prediction error of the previous q time steps, is the error term of the current time step, and the future time step is predicted through the ARIMA model. yes The error term at the moment, to obtain the predicted value at each time point t , the expression is: ; The residual reflects the difference between the actual color change and the predicted value. For each time step t, the residual The calculation formula is: The calculated residual is standardized, and the ratio of the residual to the standardized residual is calculated, that is, the color fluctuation deviation index is calculated.
[0014] Preferably, training a machine learning model for predicting the detection accuracy of the YOLOv8 model based on the extracted abnormal distribution characteristics of the shadow area and the color change amplitude characteristics specifically includes:
[0015] The shadow distribution anomaly index and the color fluctuation deviation index are converted into the first eigenvector, and the first eigenvector is used as the input of the machine learning model. The machine learning model predicts the YOLOv8 model detection accuracy value label for each group of first eigenvectors as the prediction target, and minimizes the sum of prediction errors of all YOLOv8 model detection accuracy value labels as the training target. The machine learning model is trained until the sum of prediction errors converges, and the model training is stopped. The YOLOv8 model detection accuracy value is determined according to the model output results, wherein the machine learning model is a polynomial regression model.
[0016] Preferably, in S3, the detection accuracy of the YOLOv8 model is determined according to the output result of the machine learning model, and is divided into two categories: high-precision detection and low-precision detection;
[0017] The obtained YOLOv8 model detection accuracy value is compared with the reference threshold of the YOLOv8 model detection accuracy value under the pre-set standard state. If the YOLOv8 model detection accuracy value is greater than or equal to the reference threshold of the YOLOv8 model detection accuracy value, it means that YOLOv8 can effectively identify the degree of looseness of tobacco leaves in the current environment, the classification and detection results of the model are accurate, and the YOLOv8 model detection accuracy is high. At this time, a high-precision detection signal is generated, which is divided into high-precision detection, and the result of the high-precision detection is directly used in subsequent production links; if the YOLOv8 model detection accuracy value is less than the reference threshold of the YOLOv8 model detection accuracy value, it means that the accuracy of the detection result is low. At this time, a low-precision detection signal is generated, which is divided into low-precision detection, and further analysis is performed on it.
[0018] Preferably, in S4, for the YOLOv8 model with low-precision detection, the abnormal degree of the detection accuracy of the YOLOv8 model is further analyzed, and the detection threshold of the YOLOv8 model is dynamically adjusted according to the analysis result, specifically:
[0019] For the YOLOv8 model with low-precision detection, that is, the YOLOv8 model detection accuracy value generated within a fixed time period is less than the reference threshold of the YOLOv8 model detection accuracy value, the abnormal degree of the YOLOv8 model detection accuracy is further analyzed, and the YOLOv8 model detection accuracy values generated within a subsequent fixed time period that are less than the reference threshold of the YOLOv8 model detection accuracy value are collected, and a data set is established. The mean and standard deviation of the data set are calculated. After analyzing the data set, the detection threshold of the YOLOv8 model is dynamically adjusted according to the analysis results to improve the detection accuracy.
[0020] Preferably, if the mean of the YOLOv8 model detection accuracy values in the data set is greater than or equal to the reference threshold of the mean of the YOLOv8 model detection accuracy values, and the standard deviation of the YOLOv8 model detection accuracy values is less than the reference threshold of the standard deviation of the YOLOv8 model detection accuracy values, the model performs well and is stable, and the detection threshold is increased;
[0021] If the mean of the YOLOv8 model detection accuracy values is greater than or equal to the reference threshold of the mean of the YOLOv8 model detection accuracy values, and the standard deviation of the YOLOv8 model detection accuracy values is greater than or equal to the reference threshold of the standard deviation of the YOLOv8 model detection accuracy values, the model performs well but has large fluctuations. Keep the threshold and reduce the fluctuations.
[0022] If the mean value of the YOLOv8 model detection accuracy is less than the reference threshold of the mean value of the YOLOv8 model detection accuracy, and the standard deviation of the YOLOv8 model detection accuracy is greater than or equal to the reference threshold of the standard deviation of the YOLOv8 model detection accuracy, the model performance is poor and fluctuates greatly, lower the threshold and optimize the model;
[0023] If the mean value of the YOLOv8 model detection accuracy is less than the reference threshold of the mean value of the YOLOv8 model detection accuracy, and the standard deviation of the YOLOv8 model detection accuracy is less than the reference threshold of the standard deviation of the YOLOv8 model detection accuracy, the model performs poorly but is stable. Adjust the threshold and improve the model performance.
[0024] The present invention also provides a tobacco leaf looseness detection system based on YOLOv8, including a data acquisition module, a model training module, a detection accuracy division module and an adjustment module;
[0025] Data acquisition module: install several light sensors in the detection area of the image target by YOLOv8, monitor in real time, obtain the light intensity change data in different time periods, and collect the image data of tobacco leaves under different light intensity conditions by combining with automated camera equipment;
[0026] Model training module: pre-process the acquired light intensity change data and tobacco leaf scattered image data, extract features from the pre-processed data, and train a machine learning model to predict the detection accuracy of the YOLOv8 model based on the extracted abnormal distribution features of the shadow area and the color change amplitude features;
[0027] Detection accuracy classification module: According to the output results of the machine learning model, the detection accuracy of the YOLOv8 model is determined and divided into two categories: high-precision detection and low-precision detection. The results of high-precision detection are directly used in subsequent production links;
[0028] Adjustment module: For the YOLOv8 model with low-precision detection, further analyze the abnormal degree of the YOLOv8 model's detection accuracy, and dynamically adjust the detection threshold of the YOLOv8 model based on the analysis results to improve the detection accuracy.
[0029] In the above technical solution, the technical effects and advantages provided by the present invention are:
[0030] 1. The present invention installs a light sensor in the YOLOv8 detection area and combines it with an automated camera device to monitor the light intensity in real time and collect image data of scattered tobacco leaves, thereby solving the problem of interference with model detection accuracy in production environments with complex backgrounds and drastic light changes. The acquired data is preprocessed and feature extracted, and a machine learning model is trained to predict the detection accuracy of the YOLOv8 model, and the detection results are divided into high-precision and low-precision categories according to the output of the model. High-precision detection results can be used directly in production, while low-precision detection further analyzes the degree of abnormality and dynamically adjusts the detection threshold to improve the accuracy and stability of detection.
[0031] 2. The present invention not only improves the detection accuracy of the YOLOv8 model on the degree of looseness of tobacco leaves in complex environments, but also optimizes the adaptive ability of the model through further analysis and adjustment of low-precision detection, so that the system can dynamically adjust the detection standard according to different lighting and background changes, ensuring the accuracy and consistency of tobacco leaf classification in the production process, thereby improving the overall production quality control level and reducing production interference and losses caused by detection errors. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0033] Figure 1 The figure is a flow chart of the method of the present invention.
[0034] Figure 2 It is a system module diagram of the present invention. DETAILED DESCRIPTION
[0035] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0036] Example 1, please refer to Figure 1 As shown, the method for detecting the degree of looseness of tobacco leaves based on YOLOv8 in this embodiment includes the following steps:
[0037] S1: Install several light sensors in the detection area of the image target by YOLOv8 to monitor in real time, obtain the light intensity change data in different time periods, and collect the image data of tobacco leaves under different light intensity conditions by combining with automated camera equipment;
[0038] S2: Preprocess the acquired light intensity change data and scattered tobacco leaf image data, perform feature extraction on the preprocessed data, and train a machine learning model for predicting the detection accuracy of the YOLOv8 model based on the extracted abnormal distribution features of the shadow area and the color change amplitude features;
[0039] S3: According to the output results of the machine learning model, the detection accuracy of the YOLOv8 model is determined and divided into two categories: high-precision detection and low-precision detection. The results of high-precision detection are directly used in subsequent production links;
[0040] S4: For the YOLOv8 model with low-precision detection, further analyze the abnormal degree of the YOLOv8 model detection accuracy, and dynamically adjust the detection threshold of the YOLOv8 model according to the analysis results to improve the detection accuracy.
[0041] In S1, several light sensors are installed in the detection area of the image target by YOLOv8 to monitor in real time and obtain the light intensity change data in different time periods. The image data of scattered tobacco leaves under different light intensity conditions are collected by combining with automated camera equipment.
[0042] The specific steps to install a light sensor and monitor light intensity changes in real time include:
[0043] Choose sensors suitable for detecting changes in light intensity in the production environment, such as digital light sensors (such as TCS34725, etc.), which can measure light intensity in the visible light range. Make sure that the selected sensor can adapt to the range of light changes in the production environment (such as from low light to strong light) and has sufficient accuracy to capture subtle light changes. Install light sensors in key locations in the YOLOv8 detection area. For example, sensors can be placed above and to the sides of tobacco inspection equipment to ensure that they can accurately capture the intensity and changes of the light source.
[0044] Install multiple sensors to ensure that light intensity is monitored at different angles and locations, especially in areas prone to shadows or reflections. After the sensors are installed, calibrate each sensor to ensure that they can accurately measure light intensity. Calibration can be adjusted by exposing the sensor to a light source of known intensity. Regularly check and recalibrate the sensors to ensure data accuracy as the production environment changes. Use the sensor control system to collect light intensity data in real time over different time periods. A microcontroller or microcontroller (such as Arduino, Raspberry Pi) can be used to collect and transmit data. Ensure that the sensor data collection is synchronized with the operating time of the production line so that the light intensity for each time period is accurately recorded. Store the light data in a database or cloud server for subsequent analysis. The recorded data should include timestamps, light intensity, and sensor location information.
[0045] The specific steps of collecting image data of scattered tobacco leaves under different light intensity conditions in combination with automated camera equipment include: Selecting industrial automated camera equipment that can adapt to different light intensity conditions. High dynamic range (HDR) cameras can handle complex lighting conditions such as strong light and shadows. Ensure that the camera has sufficient resolution and frame rate to accurately capture the details of the tobacco leaves. Equip the camera with adjustable lenses or filters to adapt to changing lighting conditions to ensure clear images under different light intensities.
[0046] Install the camera in an area suitable for photographing tobacco leaves, and ensure that the camera's field of view can cover all parts of the tobacco leaf inspection area. Adjust the camera angle to reduce blind spots caused by reflections or shadows. Install anti-vibration equipment on the camera to prevent image blur caused by production line movement or environmental vibration. If a single camera cannot fully cover all lighting conditions, consider using multiple cameras to photograph loose bundles of tobacco leaves from different angles to ensure comprehensive data collection. Enable the camera's automatic exposure function to adapt to scenes with different light intensities to ensure that the details of the tobacco leaves can still be clearly captured under strong or low light conditions. Set the camera's autofocus and white balance functions to ensure that the tobacco leaf images can maintain consistent color and clarity under different lighting conditions.
[0047] In the YOLOv8 detection area, combined with sensor data, the image data of scattered tobacco leaves under different lighting conditions is collected in real time. By synchronizing with the light sensor, it is ensured that the images taken under a specific light intensity match the light data. The collected images are stored and marked according to information such as light intensity and timestamp, so that images under different lighting conditions can be classified and analyzed later. When storing images, it is necessary to ensure sufficient storage space and data accessibility. For images with extreme lighting conditions (such as too bright or too dark), image enhancement techniques (such as contrast adjustment and denoising) can be used to ensure that the subsequent YOLOv8 model can accurately identify the degree of scattered tobacco leaves. Through the feedback mechanism, the camera parameters (such as exposure and focus) or sensor settings are automatically adjusted to ensure that high-quality images can be continuously obtained under different light intensities.
[0048] S2: Preprocess the acquired light intensity change data and tobacco leaf scattered image data, perform feature extraction on the preprocessed data, and train a machine learning model to predict the detection accuracy of the YOLOv8 model based on the extracted shadow area distribution abnormal features and color change amplitude features.
[0049] The preprocessing steps for light intensity change data include: checking the light intensity data and removing obvious outliers or sensor error readings (such as negative values or values outside the device range). Smoothing the light data using a moving average filter or a Gaussian filter to reduce short-term fluctuations in the measurement, thereby obtaining a more stable light intensity change curve. Scale the light intensity data to a uniform range (such as 0-1) to facilitate subsequent correlation analysis with image data. The light data can be scaled using the minimum-maximum normalization method or the Z-score normalization method. Light sensor data and image acquisition data usually have their own timestamps. During preprocessing, it is necessary to ensure that the two types of data are synchronized in time and associate the light intensity changes with the image data at the corresponding time point.
[0050] Preprocessing of the image data of the scattered tobacco leaves includes: detecting the collected image data and removing low-quality images caused by motion blur, lens dirt or camera failure. The clarity of the image can be checked by edge detection or Laplacian operator. For images with poor lighting or strong shadows, contrast adjustment is performed to enhance the visibility of tobacco leaf details. Histogram equalization or adaptive histogram equalization (CLAHE) can be used to enhance contrast. Denoising techniques such as Gaussian blur or median filtering are used to reduce image noise, especially for images in low light or high noise environments. Correct color distortion problems under the influence of lighting to ensure that the color characteristics of the tobacco leaves are consistent in the image. White balance adjustment can be used to handle image color differences under different lighting conditions. Scale all images to a uniform size (such as 416x416 or 640x640 for YOLOv8 standards) to ensure that the images input to the model have consistent resolution and avoid fluctuations in detection performance due to image size differences. Normalize image pixel values to a fixed range (such as 0-255 or 0-1) to ensure that the model remains consistent when processing images under different brightness or exposure conditions.
[0051] Feature extraction is performed on the preprocessed data of light intensity change data and scattered tobacco leaf image data, and the abnormal distribution characteristics of shadow area in the light intensity change data and the color change amplitude characteristics in the scattered tobacco leaf image data are extracted respectively.
[0052] The shadow distribution anomaly index is generated based on the extracted shadow area distribution anomaly features. The method for obtaining the shadow distribution anomaly index is as follows:
[0053] The light sensor is used to obtain the shadow distribution area data in the detection area in the s time period in real time and construct the corresponding data set, which is integrated into a feature matrix ,in, represents the data point of the i-th sample, and n is the total number of samples. GMM is used to fit the shadow distribution feature data through the expectation maximization algorithm, and the model expression is: ; where K is the number of Gaussian distributions (called “components” or “clusters”); is the weight of the kth Gaussian distribution, is the mean vector of the kth Gaussian distribution, is the covariance matrix of the kth Gaussian distribution, is the probability density function of the kth Gaussian distribution, and the formula is: ; Where T is the matrix transpose and d is the dimension of the feature; for each data point , calculate the probability density value of the entire model through the fitted GMM model , the expression is: ; Use the probability density value of the data point To calculate the shadow distribution anomaly index, the expression is: ; In the formula, is the shadow distribution anomaly index.
[0054] The larger the shadow distribution anomaly index is, the greater the deviation of the distribution characteristics of the shadow area from the normal distribution. The detection accuracy of the YOLOv8 model may be lower due to problems such as uneven lighting, strong shadows or reflections. This is because abnormal shadow distribution will interfere with the model's accurate identification of the degree of tobacco leaf dispersion, causing the model to misjudge or miss detection, thereby affecting the reliability of the classification results. Therefore, when the anomaly index increases, it often means that the detection accuracy of YOLOv8 has decreased in the current scenario and needs to be adjusted or further processed.
[0055] The color fluctuation deviation index is generated based on the extracted color change amplitude characteristics. The method for obtaining the color fluctuation deviation index is:
[0056] Extract the color change amplitude characteristics within the L time period and construct a time series , where t is the number of time steps, is the color change amplitude feature extracted at the tth moment; construct the autoregressive integrated moving average model ARIMA (p, d, q), which combines autoregressive AR and moving average MA. Among them, p is the order of the autoregressive term, that is, looking back at the color amplitude of the previous p time steps, d is the number of differences, which is used to stabilize the time series, and q is the order of the moving average term, which represents the prediction error of the previous q time steps. The expression is: ; In the formula, c is a constant term, is the autoregressive coefficient, which depends on the color change amplitude in the previous p time steps, is the sliding average coefficient, which depends on the prediction error of the previous q time steps, is the error term of the current time step, and the future time step is predicted through the ARIMA model. yes The error term at the moment, to obtain the predicted value at each time point t , the expression is: ; The residual reflects the difference between the actual color change and the predicted value. For each time step t, the residual The calculation formula is: The calculated residual is standardized, and the ratio of the residual to the standardized residual is calculated, that is, the color fluctuation deviation index is calculated.
[0057] The larger the color fluctuation deviation index, the more abnormal the color change in the image. It may be that factors such as drastic changes in lighting or color distortion interfere with the stability of image features, which in turn leads to a decrease in the detection accuracy of the YOLOv8 model. Abnormal color fluctuations will affect the model's normal recognition of tobacco leaves, which may lead to classification errors or missed detections. Therefore, a higher color fluctuation deviation index usually means that the detection accuracy of YOLOv8 in the current environment is reduced, and environmental adjustments or image preprocessing are required to improve accuracy.
[0058] The machine learning model for predicting the detection accuracy of the YOLOv8 model is trained based on the extracted abnormal distribution characteristics of the shadow area and the color change amplitude characteristics. Specifically, it includes:
[0059] The shadow distribution anomaly index and the color fluctuation deviation index are converted into the first eigenvector, and the first eigenvector is used as the input of the machine learning model. The machine learning model predicts the YOLOv8 model detection accuracy value label for each group of first eigenvectors as the prediction target, and minimizes the sum of prediction errors of all YOLOv8 model detection accuracy value labels as the training target. The machine learning model is trained until the sum of prediction errors converges, and the model training is stopped. The YOLOv8 model detection accuracy value is determined according to the model output results, wherein the machine learning model is a polynomial regression model.
[0060] The method for obtaining the detection accuracy value of the YOLOv8 model is: from the first feature vector training data of the trained machine learning model, obtain the corresponding function expression: ; In the formula, is the output function of the model, is the shadow distribution anomaly index, is the color fluctuation deviation index, Detection accuracy value of YOLOv8 model.
[0061] S3: According to the output results of the machine learning model, the detection accuracy of the YOLOv8 model is determined and divided into two categories: high-precision detection and low-precision detection. The results of high-precision detection are directly used in subsequent production links.
[0062] The obtained YOLOv8 model detection accuracy value is compared with the reference threshold of the YOLOv8 model detection accuracy value under the preset standard state. If the YOLOv8 model detection accuracy value is greater than or equal to the reference threshold of the YOLOv8 model detection accuracy value, it means that YOLOv8 can effectively identify the degree of looseness of tobacco leaves in the current environment, the classification and detection results of the model are accurate, and the YOLOv8 model detection accuracy is high. At this time, a high-precision detection signal is generated, which is divided into high-precision detection, and the result of the high-precision detection is directly used in subsequent production links; if the YOLOv8 model detection accuracy value is less than the reference threshold of the YOLOv8 model detection accuracy value, it means that the detection of the YOLOv8 model is affected, resulting in low accuracy of the detection result. At this time, a low-precision detection signal is generated, which is divided into low-precision detection, and further analysis is performed on it.
[0063] S4: For the YOLOv8 model with low-precision detection, further analyze the abnormal degree of the YOLOv8 model detection accuracy, and dynamically adjust the detection threshold of the YOLOv8 model according to the analysis results to improve the detection accuracy.
[0064] For the YOLOv8 model with low-precision detection, that is, the YOLOv8 model detection accuracy value generated within a fixed time period is less than the reference threshold of the YOLOv8 model detection accuracy value, the abnormal degree of the YOLOv8 model detection accuracy is further analyzed, and the YOLOv8 model detection accuracy values generated within a subsequent fixed time period that are less than the reference threshold of the YOLOv8 model detection accuracy value are collected, and a data set is established. The mean and standard deviation of the data set are calculated. After analyzing the data set, the detection threshold of the YOLOv8 model is dynamically adjusted according to the analysis results to improve the detection accuracy.
[0065] If the mean value of the YOLOv8 model detection accuracy in the data set is greater than or equal to the reference threshold of the mean value of the YOLOv8 model detection accuracy, and the standard deviation of the YOLOv8 model detection accuracy is less than the reference threshold of the standard deviation of the YOLOv8 model detection accuracy, it means that the overall detection accuracy is good and the detection accuracy fluctuation is small, and the model performance is stable. In this case, the existing detection threshold can be maintained to further improve the detection performance of the model in a stable environment. Because the error is small and the detection accuracy is stable, it can be regarded as a high-precision environment;
[0066] If the mean value of the YOLOv8 model detection accuracy is greater than or equal to the reference threshold of the mean value of the YOLOv8 model detection accuracy, and the standard deviation of the YOLOv8 model detection accuracy is greater than or equal to the reference threshold of the standard deviation of the YOLOv8 model detection accuracy, it means that the detection result fluctuates greatly, indicating that the model performs well in certain time periods, but is subject to external interference in other time periods. At this time, the existing detection threshold should be maintained, but the volatility can be reduced and the stability of the model can be improved through data enhancement, image preprocessing, or model adaptive parameter adjustment. For example, dynamically adjust the preprocessing algorithm under lighting conditions to reduce the impact of environmental changes on the model;
[0067] If the mean value of the YOLOv8 model detection accuracy is less than the reference threshold of the mean value of the YOLOv8 model detection accuracy, and the standard deviation of the YOLOv8 model detection accuracy is greater than or equal to the reference threshold of the standard deviation of the YOLOv8 model detection accuracy, it means that the overall accuracy of the model is poor, and it is significantly affected by the external environment and performs unstable. This may indicate serious environmental interference or the need to adjust the model parameters. At this time, the detection threshold should be lowered to enhance the robustness of the model so that it can maintain detection capabilities in more complex environments. At the same time, the feature extraction process of the model can be further optimized by analyzing environmental characteristics to reduce the impact of external factors;
[0068] If the mean value of the YOLOv8 model detection accuracy is less than the reference threshold of the mean value of the YOLOv8 model detection accuracy, and the standard deviation of the YOLOv8 model detection accuracy is less than the reference threshold of the standard deviation of the YOLOv8 model detection accuracy, it means that although the detection accuracy is not high, the performance of the model is relatively stable, indicating that the performance of the model is limited and may not be able to adapt to the current detection task or there are systematic deviations. The detection threshold of the model should be adjusted, and the overall performance of the model should be improved by retraining or introducing new data. The features of the current scenario can be added to the model training data, especially when the model performs poorly, more relevant data can be collected to further optimize the detection accuracy.
[0069] In this embodiment, by installing a light sensor in the YOLOv8 detection area, real-time monitoring of light intensity, and combining with automated camera equipment, scattered tobacco leaf image data under different lighting conditions are collected. After preprocessing these data, the abnormal distribution characteristics of the shadow area and the color change amplitude characteristics are extracted, and the machine learning model is trained to predict the detection accuracy of YOLOv8. According to the output results of the model, the detection is divided into high-precision and low-precision categories, and the high-precision detection results are directly used in the production link. For low-precision detection, the detection accuracy of YOLOv8 is improved by further analyzing the degree of abnormality and dynamically adjusting the detection threshold.
[0070] Example 2, please refer to Figure 2As shown, the tobacco leaf looseness detection system based on YOLOv8 in this embodiment includes a data acquisition module, a model training module, a detection accuracy division module and an adjustment module;
[0071] Data acquisition module: install several light sensors in the detection area of the image target by YOLOv8, monitor in real time, obtain the light intensity change data in different time periods, and collect the image data of tobacco leaves under different light intensity conditions by combining with automated camera equipment;
[0072] Model training module: pre-process the acquired light intensity change data and tobacco leaf scattered image data, extract features from the pre-processed data, and train a machine learning model to predict the detection accuracy of the YOLOv8 model based on the extracted abnormal distribution features of the shadow area and the color change amplitude features;
[0073] Detection accuracy classification module: According to the output results of the machine learning model, the detection accuracy of the YOLOv8 model is determined and divided into two categories: high-precision detection and low-precision detection. The results of high-precision detection are directly used in subsequent production links;
[0074] Adjustment module: For the YOLOv8 model with low-precision detection, further analyze the abnormal degree of the YOLOv8 model's detection accuracy, and dynamically adjust the detection threshold of the YOLOv8 model based on the analysis results to improve the detection accuracy.
[0075] The above formulas are all dimensionless and numerical calculations. The formula is a formula for the most recent real situation obtained by collecting a large amount of data and performing software simulation. The preset parameters in the formula are set by technicians in this field according to actual conditions.
[0076] The above embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented by software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0077] It should be understood that the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship, but it may also indicate an "and / or" relationship. Please refer to the context for specific understanding.
[0078] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0079] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0080] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. A method for detecting the degree of looseness of tobacco leaves based on YOLOv8, characterized in that: The following steps are involved: S1: Install several light sensors in the detection area of the image target by YOLOv8 to monitor in real time, obtain the light intensity change data in different time periods, and collect the image data of tobacco leaves under different light intensity conditions by combining with automated camera equipment; S2: Preprocess the acquired light intensity change data and tobacco leaf scattered image data, perform feature extraction on the preprocessed data, and train a machine learning model for predicting the detection accuracy of the YOLOv8 model based on the extracted abnormal distribution features of the shadow area and the color change amplitude features. Specifically: The abnormal distribution features of the shadow area in the light intensity change data and the color change amplitude features in the scattered tobacco leaf image data are extracted respectively, and the shadow distribution abnormality index is generated based on the extracted abnormal distribution features of the shadow area. The method for obtaining the shadow distribution abnormality index is: The light sensor is used to obtain the shadow distribution area data in the detection area in the s time period in real time and construct the corresponding data set, which is integrated into a feature matrix ,in, represents the data point of the i-th sample, and n is the total number of samples. GMM is used to fit the shadow distribution feature data through the expectation maximization algorithm, and the model expression is: ; Where K is the number of Gaussian distributions; is the weight of the kth Gaussian distribution, is the mean vector of the kth Gaussian distribution, is the covariance matrix of the kth Gaussian distribution, is the probability density function of the kth Gaussian distribution, and the formula is: ; Where T is the matrix transpose and d is the dimension of the feature; for each data point , calculate the probability density value of the entire model through the fitted GMM model , the expression is: ; Use the probability density value of the data point To calculate the shadow distribution anomaly index, the expression is: ; In the formula, is the shadow distribution anomaly index; The color fluctuation deviation index is generated based on the extracted color change amplitude characteristics. The method for obtaining the color fluctuation deviation index is: Extract the color change amplitude characteristics within the L time period and construct a time series , where t is the number of time steps, is the color change amplitude feature extracted at the tth moment; construct the autoregressive integrated moving average model ARIMA (p, d, q), where p is the order of the autoregressive term, d is the number of differences, and q is the order of the moving average term, which represents the prediction error of the previous q time steps. The expression is: ; In the formula, c is a constant term, is the autoregressive coefficient, which depends on the color change amplitude in the previous p time steps, is the sliding average coefficient, which depends on the prediction error of the previous q time steps, is the error term of the current time step. The ARIMA model is used to predict future time steps to obtain the predicted value at each time point t. , the expression is: ; The residual reflects the difference between the actual color change and the predicted value. For each time step t, the residual The calculation formula is: ; The calculated residual is standardized, and the ratio of the residual to the standardized residual is calculated, that is, the color fluctuation deviation index is calculated; Training a machine learning model for predicting the detection accuracy of the YOLOv8 model based on the extracted abnormal distribution features of the shadow area and the color change amplitude features specifically includes: converting the shadow distribution abnormality index and the color fluctuation deviation index into a first eigenvector, using the first eigenvector as the input of the machine learning model, the machine learning model predicts the YOLOv8 model detection accuracy value label for each group of first eigenvectors as a prediction target, minimizing the sum of prediction errors for all YOLOv8 model detection accuracy value labels as a training target, training the machine learning model until the sum of prediction errors reaches convergence, stopping the model training, and determining the YOLOv8 model detection accuracy value according to the model output result, wherein the machine learning model is a polynomial regression model; The method for obtaining the detection accuracy value of the YOLOv8 model is: from the first feature vector training data of the trained machine learning model, obtain the corresponding function expression: ; In the formula, is the output function of the model, is the shadow distribution anomaly index, is the color fluctuation deviation index, It is the accuracy value of YOLOv8 model detection; S3: According to the output results of the machine learning model, the detection accuracy of the YOLOv8 model is determined and divided into two categories: high-precision detection and low-precision detection. The results of high-precision detection are directly used in subsequent production links; S4: For the YOLOv8 model with low-precision detection, further analyze the abnormal degree of the YOLOv8 model detection accuracy, and dynamically adjust the detection threshold of the YOLOv8 model according to the analysis results to improve the detection accuracy.
2. The method for detecting the degree of looseness of tobacco leaves based on YOLOv8 according to claim 1, characterized in that: In S3, the detection accuracy of the YOLOv8 model is determined based on the output results of the machine learning model, and is divided into two categories: high-precision detection and low-precision detection; The obtained YOLOv8 model detection accuracy value is compared with the reference threshold of the YOLOv8 model detection accuracy value under the pre-set standard state. If the YOLOv8 model detection accuracy value is greater than or equal to the reference threshold of the YOLOv8 model detection accuracy value, it means that YOLOv8 can effectively identify the degree of looseness of tobacco leaves in the current environment, the classification and detection results of the model are accurate, and the YOLOv8 model detection accuracy is high. At this time, a high-precision detection signal is generated, which is divided into high-precision detection, and the result of the high-precision detection is directly used in subsequent production links; if the YOLOv8 model detection accuracy value is less than the reference threshold of the YOLOv8 model detection accuracy value, it means that the accuracy of the detection result is low. At this time, a low-precision detection signal is generated, which is divided into low-precision detection, and further analysis is performed on it.
3. The method for detecting the degree of looseness of tobacco leaves based on YOLOv8 according to claim 1, characterized in that: In S4, for the YOLOv8 model with low-precision detection, the abnormal degree of the detection accuracy of the YOLOv8 model is further analyzed, and the detection threshold of the YOLOv8 model is dynamically adjusted according to the analysis results, specifically: For the YOLOv8 model with low-precision detection, that is, the YOLOv8 model detection accuracy value generated within a fixed time period is less than the reference threshold of the YOLOv8 model detection accuracy value, the abnormal degree of the YOLOv8 model detection accuracy is further analyzed, and the YOLOv8 model detection accuracy values generated within a subsequent fixed time period that are less than the reference threshold of the YOLOv8 model detection accuracy value are collected, and a data set is established. The mean and standard deviation of the data set are calculated. After analyzing the data set, the detection threshold of the YOLOv8 model is dynamically adjusted according to the analysis results to improve the detection accuracy.
4. The method for detecting the degree of looseness of tobacco leaves based on YOLOv8 according to claim 3, characterized in that: If the mean of the YOLOv8 model detection accuracy values in the data set is greater than or equal to the reference threshold of the mean of the YOLOv8 model detection accuracy values, and the standard deviation of the YOLOv8 model detection accuracy values is less than the reference threshold of the standard deviation of the YOLOv8 model detection accuracy values, the model performs well and is stable, and the detection threshold is increased; If the mean of the YOLOv8 model detection accuracy values is greater than or equal to the reference threshold of the mean of the YOLOv8 model detection accuracy values, and the standard deviation of the YOLOv8 model detection accuracy values is greater than or equal to the reference threshold of the standard deviation of the YOLOv8 model detection accuracy values, the model performs well but has large fluctuations. Keep the threshold and reduce the fluctuations. If the mean value of the YOLOv8 model detection accuracy is less than the reference threshold of the mean value of the YOLOv8 model detection accuracy, and the standard deviation of the YOLOv8 model detection accuracy is greater than or equal to the reference threshold of the standard deviation of the YOLOv8 model detection accuracy, the model performance is poor and fluctuates greatly, lower the threshold and optimize the model; If the mean value of the YOLOv8 model detection accuracy is less than the reference threshold of the mean value of the YOLOv8 model detection accuracy, and the standard deviation of the YOLOv8 model detection accuracy is less than the reference threshold of the standard deviation of the YOLOv8 model detection accuracy, the model performs poorly but is stable. Adjust the threshold and improve the model performance.
5. A tobacco leaf looseness detection system based on YOLOv8, used to implement the tobacco leaf looseness detection method based on YOLOv8 according to any one of claims 1 to 4, characterized in that: It includes data acquisition module, model training module, detection accuracy division module and adjustment module; Data acquisition module: install several light sensors in the detection area of the image target by YOLOv8, monitor in real time, obtain the light intensity change data in different time periods, and collect the image data of tobacco leaves under different light intensity conditions by combining with automated camera equipment; Model training module: pre-process the acquired light intensity change data and tobacco leaf scattered image data, extract features from the pre-processed data, and train a machine learning model to predict the detection accuracy of the YOLOv8 model based on the extracted abnormal distribution features of the shadow area and the color change amplitude features; Detection accuracy classification module: According to the output results of the machine learning model, the detection accuracy of the YOLOv8 model is determined and divided into two categories: high-precision detection and low-precision detection. The results of high-precision detection are directly used in subsequent production links; Adjustment module: For the YOLOv8 model with low-precision detection, further analyze the abnormal degree of the YOLOv8 model's detection accuracy, and dynamically adjust the detection threshold of the YOLOv8 model based on the analysis results to improve the detection accuracy.
Citation Information
Patent Citations
Flue-cured tobacco leaf spot disease detection method based on image processing
CN117351474A
Deep learning-based tea plant disease and insect pest detection method and computer device
CN119206521A