An image recognition-based ginger stem and leaf disease and pest identification optimization method
By analyzing the topology of the ginger stem and leaf pest and disease identification model and collecting targeted training samples, the problem of decreased identification accuracy under environmental changes was solved, the model's stability and efficient updating were achieved, and the long-term adaptability and monitoring capability of the ginger pest and disease identification system were ensured.
Patent Information
- Application Number
- CN202610450227.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-08
- Publication Date
- 2026-06-05
- Estimated Expiration
- 2046-04-08
AI Technical Summary
Existing ginger stem and leaf disease and pest identification models are unable to adapt to feature drift when faced with changes in the pathogen population of ginger diseases and pests and dynamic changes in external conditions, resulting in a decrease in identification accuracy and failing to meet the needs of long-term stable monitoring.
By acquiring the topological structure analysis of the current and historical feature sets, calculating the topological dissimilarity, determining whether the model needs to be updated, and collecting new training sample images in the field for parameter optimization, the classification model is updated.
The model has achieved stability and adaptability in the face of environmental changes, improved the recognition accuracy, ensured the long-term monitoring capability of the ginger pest and disease identification system, and improved the efficiency and accuracy of model updates.
Smart Images

Figure CN121982705B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image data processing technology, and more specifically, to an optimized method for identifying diseases and pests in ginger stems and leaves based on image recognition. Background Technology
[0002] In ginger cultivation, timely and accurate identification of stem and leaf diseases and pests is a prerequisite for effective prevention and control. Existing technologies can employ image recognition methods for assisted identification. This typically involves acquiring digital images of ginger stems and leaves, preprocessing the images to improve quality, extracting disease- and pest-related features from the images, and then using a pre-trained classification model based on sample data to make judgments, ultimately outputting the disease / pest category identification result.
[0003] However, once the classification model used for discrimination in the above method is trained, its internal parameters and decision rules remain fixed. In the actual production environment, the pathogen population or external conditions of ginger pests and diseases may change, causing the symptom features presented in the image to undergo non-significant dynamic evolution. The fixed classification model is difficult to adapt to this slow feature drift, which leads to the model's accuracy in identifying actual pests and diseases in the field gradually decreasing over time, failing to meet the agricultural management needs for long-term and stable monitoring of pests and diseases. Summary of the Invention
[0004] In order to overcome the above-mentioned defects of the prior art, the present invention provides an optimized method for identifying diseases and pests in ginger stems and leaves based on image recognition to solve the problems mentioned in the background art.
[0005] To achieve the above objectives, the present invention provides the following technical solution:
[0006] An optimized method for identifying diseases and pests in ginger stems and leaves based on image recognition includes the following steps:
[0007] S1. Obtain digital images of ginger stems and leaves for the current period, and use the deployed classification model to identify the digital images of ginger stems and leaves to obtain the current identification result and the corresponding current feature set.
[0008] S2. Obtain multiple historical feature sets generated by the classification model in multiple consecutive historical periods, and perform topological structure analysis on each of the multiple historical feature sets to obtain their respective historical topological structure description information.
[0009] S3. Compare the current feature set with the historical topological structure description information, and calculate the topological difference degree, which characterizes the degree of deviation of the current feature set structure.
[0010] S4. Based on the topological dissimilarity, determine whether the classification model needs to be updated;
[0011] S5. When an update is needed, identify the core feature fuzzy region that causes confusion in the classification model based on the misjudged data in the current and historical recognition results, and collect new training sample images from the actual field area corresponding to the core feature fuzzy region.
[0012] S6. Extract features from the new training sample images and optimize the parameters of the classification model to complete the update.
[0013] Furthermore, S1 includes:
[0014] Acquire multiple digital images of ginger stems and leaves under different lighting conditions within the current period;
[0015] Multiple digital images of ginger stems and leaves are input into the deployed classification model. The classification model outputs the pest and disease category of each digital image of ginger stems and leaves as the current recognition result, and the activation values of the preset layer in the classification model are extracted simultaneously to form the image feature vector of the corresponding image.
[0016] The set of image feature vectors of all images belonging to the current period is determined as the current feature set.
[0017] Furthermore, S2 includes:
[0018] Obtain multiple sets of historical features stored by the classification model in multiple consecutive historical periods, where each set of historical features contains the historical feature vectors of all images in the corresponding historical period;
[0019] For each set of historical features, calculate the distance between any two historical feature vectors in the set, and construct a graph structure representing the connection relationship between historical feature vectors based on the distance threshold.
[0020] Analyze the number and scale distribution of connected components in the graph structure corresponding to each historical feature set, and generate historical topological structure description information to describe the spatial topological morphology of each historical cycle feature.
[0021] Furthermore, S3 includes:
[0022] Based on the distance between any two current feature vectors in the current feature set, and according to the same distance threshold as the information describing the historical topology, construct the current graph structure corresponding to the current feature set;
[0023] Analyze the number and size distribution of connected components in the current graph structure to obtain the current topology description information;
[0024] The current topology description information is matched and compared with each historical topology description information, and the distribution distance between the description information on multi-dimensional features is calculated.
[0025] The distribution distances corresponding to all historical periods are aggregated and calculated to obtain the topological difference degree, which characterizes the degree of deviation of the current feature set structure.
[0026] Furthermore, the distribution distance is obtained by calculating the statistical distance between the current topology description information and each historical topology description information on the scale distribution of connected components.
[0027] Furthermore, S4 includes:
[0028] Obtain the current topological dissimilarity and the historical topological dissimilarity sequence corresponding to multiple consecutive historical periods;
[0029] Analyze the statistical distribution characteristics of historical topological dissimilarity sequences to determine the range of dissimilarity fluctuations;
[0030] The current topological dissimilarity is compared with the dissimilarity fluctuation range, and if the current topological dissimilarity continues to exceed the dissimilarity fluctuation range, it is determined that the classification model needs to be updated.
[0031] Furthermore, S5 includes:
[0032] Extract the misclassified feature vectors corresponding to samples misclassified by the classification model from the current recognition results and historical recognition results;
[0033] In the feature space, density clustering is performed on the misjudged feature vectors to identify the densely distributed regions of the misjudged feature vectors as the core feature fuzzy regions.
[0034] Based on the location information of the original image corresponding to the misjudged feature vector in the blurred area of the core feature, the geographical range that needs to be sampled in the actual field area is determined;
[0035] New digital images of ginger stems and leaves were collected within a defined geographical area to serve as new training sample images.
[0036] Furthermore, density clustering employs a density-based noise-applied spatial clustering method, identifying ambiguous regions of core features by setting neighborhood radius and minimum sample number parameters.
[0037] Furthermore, S6 includes:
[0038] Extract image feature vectors from new training sample images to form a new sample feature set;
[0039] The new sample feature set is merged with the sample feature vectors selected from the historical feature set to form the model optimization training set;
[0040] Based on the model optimization training set, the parameters of the classification model are iteratively optimized.
[0041] The update is completed by replacing the deployed classification model with the optimized classification model.
[0042] Furthermore, the parameter iterative optimization process adds a constraint term to the loss function to limit the variation of the output results of the optimized classification model on the historical feature set relative to the deployed classification model.
[0043] Compared with the prior art, the present invention has the following beneficial effects:
[0044] 1. By continuously monitoring the topological stability of the feature space on which the classification model relies, it is possible to promptly detect intrinsic feature drift caused by changes in the environment or pathogens. Compared with traditional methods that only monitor the decline in recognition accuracy, changes in topological dissimilarity can provide early warning of whether the cognitive foundation of the model has been shaken before the actual performance of the model deteriorates significantly. This provides a more sensitive and forward-looking decision-making basis for model updates, ensuring that the ginger pest and disease identification system can adapt to dynamic changes in the field in the long term and maintain stable monitoring capabilities.
[0045] 2. After determining that the model needs to be updated, instead of simply expanding the training data, we reverse-engineer the core feature ambiguity areas that cause model confusion based on historical misjudgment data, and collect targeted samples at the actual field locations corresponding to these areas. This closed-loop update strategy, which traces data errors back to their spatial roots and then supplements data in a targeted manner, enables each model optimization to efficiently focus on the weakest and most in need of correction at present. This significantly improves the efficiency of improving model performance with limited new samples, and achieves accurate correction of model defects and optimized utilization of resources. Attached Figure Description
[0046] Figure 1 This is a flowchart of an image recognition-based optimization method for identifying diseases and pests in ginger stems and leaves according to the present invention. Detailed Implementation
[0047] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0048] Example: Figure 1 This invention presents an optimized method for identifying diseases and pests in ginger stems and leaves based on image recognition, comprising the following steps:
[0049] S1. Obtain digital images of ginger stems and leaves for the current period, and use the deployed classification model to identify the digital images of ginger stems and leaves to obtain the current identification result and the corresponding current feature set.
[0050] S2. Obtain multiple historical feature sets generated by the classification model in multiple consecutive historical periods, and perform topological structure analysis on each of the multiple historical feature sets to obtain their respective historical topological structure description information.
[0051] S3. Compare the current feature set with the historical topological structure description information, and calculate the topological difference degree, which characterizes the degree of deviation of the current feature set structure.
[0052] S4. Based on the topological dissimilarity, determine whether the classification model needs to be updated;
[0053] S5. When an update is needed, identify the core feature fuzzy region that causes confusion in the classification model based on the misjudged data in the current and historical recognition results, and collect new training sample images from the actual field area corresponding to the core feature fuzzy region.
[0054] S6. Extract features from the new training sample images and optimize the parameters of the classification model to complete the update.
[0055] In one specific implementation, step S1 is carried out as follows: Obtain digital images of ginger stems and leaves for the current period. The current period refers to a preset fixed time interval, such as 1 day, 7 days, or a specific growth stage of ginger, which is preset according to the agricultural plan for ginger cultivation management. To cover different light conditions, multiple digital images of ginger stems and leaves need to be obtained within the current period. Different light conditions refer to the differences in natural light when images are taken at different times or under different weather conditions. For example, taking pictures in the morning, noon, and evening during the day can obtain images with different light intensities and angles; taking pictures on sunny and cloudy days when the weather changes can obtain images with different direct and diffused light. Obtaining multiple digital images of ginger stems and leaves can be accomplished using an automatic shooting device installed at a fixed location in the field. This device automatically triggers shooting at different time points according to a preset program. Alternatively, multiple digital images of ginger stems and leaves can be obtained manually by using a handheld shooting device to take multiple pictures at different time points in the field.
[0056] Multiple digital images of ginger stems and leaves are input into a pre-deployed classification model. This model is a pre-trained convolutional neural network (CNN) containing sequentially connected convolutional, pooling, and fully connected layers. The model is trained to convergence using a historical image dataset containing numerous labeled images of ginger stems and leaves with pest and disease categories. When a digital image of a ginger stem and leaf is input, the image data undergoes forward propagation computation within the network. The network structure includes a pre-defined layer designated as a feature extraction layer, such as the last pooling layer or the first fully connected layer. When the forward propagation reaches this pre-defined layer, the output values of all neurons in that layer are recorded, and these output values are combined into a one-dimensional array according to the order of the neurons. This one-dimensional array is the image feature vector corresponding to the digital image of the ginger stem and leaf. The length dimension of the image feature vector is equal to the total number of neurons in that pre-defined layer. Simultaneously, the classification model, based on the computation results of its final output layer, provides a label representing the category as the recognition result. The category label for the recognition result could be, for example, healthy, ginger wilt, or leaf spot disease. A digital image of ginger stems and leaves, after being processed by the classification model, simultaneously produces two outputs: one is the current recognition result for this digital image of ginger stems and leaves, and the other is the image feature vector of this digital image of ginger stems and leaves.
[0057] The above input and processing procedures are performed on each digital image of ginger stems and leaves acquired within the current period. After processing all images, multiple current recognition results and multiple image feature vectors are obtained, equal to the number of images. All these image feature vectors belonging to the current period are aggregated to form a set, which is determined as the current feature set. Each element in the current feature set is an image feature vector, and each image feature vector uniquely corresponds to a digital image of ginger stems and leaves acquired within the current period and the current recognition result generated by that image. Through the above process, step S1 completes image acquisition, model recognition, and feature extraction, and generates the current feature set for subsequent topology analysis.
[0058] In one specific implementation, step S2 is implemented as follows: Multiple historical feature sets generated by the classification model over several consecutive historical periods are obtained. A historical period refers to several time intervals prior to the current period where image acquisition and recognition processing have been completed. For example, if the current period is day 30, the historical periods could be day 29, day 28, and day 27. Multiple consecutive historical periods mean that these periods are sequential and uninterrupted in time. When the classification model executes step S1 in each historical period, in addition to outputting the current recognition result, it also stores the current feature set generated in step S1 as historical data. The storage medium can be a computer's hard disk drive or a database. During storage, each historical feature set is associated with the unique identifier information of that historical period, for example, stored as a data file containing a timestamp and a feature vector array. When needed, the corresponding data file is read from the storage medium by querying the timestamp information, thereby obtaining multiple historical feature sets. Each historical feature set contains historical feature vectors of all images within the corresponding historical period. That is, within the historical period, each digital image of ginger stems and leaves processed by step S1 corresponds to a historical feature vector, and the set of all these historical feature vectors constitutes the historical feature set of the historical period.
[0059] For each acquired historical feature set, a topological structure analysis is required. First, the distance between any two historical feature vectors in the set is calculated. The distance is calculated using the Euclidean distance formula: for a historical feature vector A containing N values and another historical feature vector B containing N values, the distance between them is equal to the square root of the sum of the squares of the differences between the values at each position in vector A and the corresponding values at each position in vector B. This distance is a dimensionless value used to measure the proximity of two historical feature vectors in N-dimensional space. After calculating the distances between all pairwise historical feature vectors in the set, a graph structure is constructed based on a preset distance threshold. The distance threshold is a pre-defined positive value. The method for setting the distance threshold can be: calculating the average distance between all pairwise historical feature vectors in the set, multiplying it by a coefficient, with the coefficient ranging from, for example, 0.5 to 1.5 (e.g., 0.8). The product of the calculated average and the selected coefficient is used as the distance threshold. When constructing the graph structure, each historical feature vector is considered a node in the graph structure. Then, all paired nodes are traversed. If the distance between the two historical feature vectors corresponding to a pair of nodes is less than or equal to a set distance threshold, an edge is established between the two nodes to indicate that there is a connection between them; if the distance is greater than the distance threshold, no edge is established between the two nodes. In this way, a graph structure consisting of nodes and edges that can represent the proximity connection relationship between historical feature vectors is constructed.
[0060] This analysis examines the number and size distribution of connected components in the graph structure corresponding to each set of historical features. A connected component is a subgraph within a graph structure where any two nodes are connected by a path, and the subgraph is not connected to any other nodes. The analysis process is as follows: First, identify all connected components in the graph structure. The algorithm for identifying connected components can be either depth-first search (DFS) or breadth-first search (BFS). Taking DFS as an example, starting with an unvisited node, visit that node and mark it as visited. Then, find all unvisited nodes directly connected to that node by edges. For each such adjacent node, recursively perform the same DFS process. When all nodes reachable from the starting node have been marked, these nodes together constitute a connected component. Next, find the next unvisited node in the graph and repeat the above process until all nodes have been visited, thus obtaining all connected components. Second, count the number of connected components, i.e., the total number of identified connected components. Then, analyze the size of each connected component, which refers to the number of nodes contained in that connected component. Finally, generate a size distribution list, which records the size values of each connected component in sequence. Based on the list of the number and size distribution of connected components, historical topological structure description information is generated to describe the spatial topological morphology of each historical period. This historical topological structure description information can be a data structure, such as a record containing two fields: the first field is the number of connected components, and the second field is an array listing the size values of all connected components in order. Through the above analysis of each historical feature set, multiple historical topological structure description information corresponding one-to-one with multiple consecutive historical periods are finally obtained.
[0061] In a specific implementation, step S3 is implemented as follows: Based on the distance between any two current feature vectors in the current feature set, and according to the same distance threshold as the historical topology description information, the current graph structure corresponding to the current feature set is constructed. The distance between any two current feature vectors in the current feature set is calculated. The distance is calculated using the Euclidean distance formula, and this distance is a dimensionless value. After calculating the distances between all pairwise current feature vectors, the current graph structure is constructed based on the distance threshold. The distance threshold is the same value used when constructing the historical graph structure in step S2. The distance threshold is preset in step S2. The preset distance threshold value is directly applied in step S3. When constructing the current graph structure, each current feature vector is considered as a node in the current graph structure. All paired nodes are traversed. If the distance between the two current feature vectors corresponding to a pair of nodes is less than or equal to the distance threshold, an edge is established between these two nodes. If the distance is greater than the distance threshold, no edge is established between the two nodes. The current graph structure is constructed through this process.
[0062] Analyze the number and size distribution of connected components in the current graph structure to obtain the current topology description. A connected component is a subgraph in the current graph structure where any two nodes are connected by a path, and the subgraph is not connected to any other nodes. Identify all connected components in the current graph structure. The identification algorithm uses a depth-first search algorithm. Starting from an unvisited node in the current graph structure, visit the node and mark it as visited. Find all unvisited nodes directly connected to this node by edges, and recursively perform a depth-first search on each such neighboring node. When all nodes accessible from the starting node have been marked, these nodes constitute a connected component. Find the next unvisited node in the current graph structure and repeat the above process until all nodes have been visited, thus obtaining all connected components. Count the total number of connected components as the number of connected components. Analyze the size of each connected component, which is the number of nodes contained in the connected component. Generate a size distribution list, recording the size values of each connected component in order. Based on the number of connected components and the size distribution list, generate the current topology description. The current topology description uses the same data structure as the historical topology description, such as a record containing two fields. The first field is the number of connected components, and the second field is an array that lists the size values of all connected components in order.
[0063] The current topology description is matched against each historical topology description, and the distribution distance between the descriptions on multidimensional features is calculated. Each historical topology description comes from step S2. The matching object is the current topology description and a specific historical topology description. The multidimensional features include at least two dimensions. The first dimension is the number of connected components. The second dimension is the shape of the scale distribution of the connected components. The distribution distance is obtained by calculating the statistical distance between the current topology description and a historical topology description on the scale distribution of the connected components. When calculating the statistical distance, the scale distribution list in the current topology description is first converted into a discrete probability distribution. The conversion method is to divide each scale value in the list by the sum of all scale values to obtain a set of normalized current probability values. The same operation is performed on the scale distribution list in the historical topology description to obtain a set of normalized historical probability values. Then the statistical distance between these two sets of probability values is calculated. The statistical distance can be calculated using Euclidean distance, which is the square root of the sum of the squares of the differences between the current probability value and the historical probability value at the corresponding position. The statistical distance can also be calculated using Wasserstein distance. To calculate the Wasserstein distance, a cumulative distribution function is first constructed based on the current probability value, and another cumulative distribution function is constructed based on the historical probability values. The absolute value of the difference between the two cumulative distribution functions at each corresponding point is calculated, and the integral of these absolute values is used as the Wasserstein distance. This process yields a numerical distributional distance between the current topology description and a specific historical topology description.
[0064] The distribution distances corresponding to all historical periods are aggregated to obtain the topological dissimilarity, which characterizes the degree of deviation of the current feature set structure. Assuming there are M consecutive historical periods, there are corresponding M distribution distance values. Aggregation calculation combines these M distribution distance values into a single comprehensive value. One method of aggregation calculation is to calculate the arithmetic mean of the M distribution distance values and use the arithmetic mean as the topological dissimilarity. Another method is to calculate the median of the M distribution distance values and use the median as the topological dissimilarity. Yet another method is to find the maximum value among the M distribution distance values and use the maximum value as the topological dissimilarity. The final topological dissimilarity is a single value that comprehensively reflects the degree of deviation of the current feature set from the overall feature space topology of a historical period. This topological dissimilarity will be used in step S4 to determine whether the model needs to be updated.
[0065] In one specific implementation, step S4 is implemented as follows: Obtain the current topology difference degree and the historical topology difference degree sequence corresponding to multiple consecutive historical periods. The current topology difference degree is a specific value calculated in step S3. The historical topology difference degree sequence corresponding to multiple consecutive historical periods is a set of values arranged in chronological order. The method for obtaining the historical topology difference degree sequence is that step S3 has been executed and a historical topology difference degree has been calculated for each historical period. After each historical topology difference degree is calculated, it is stored in the computer's hard disk storage or database along with the identification information of that historical period. When it is necessary to obtain the historical topology difference degree sequence, based on the time identification information, starting from the most recent historical period, the historical topology difference degree values corresponding to a predetermined number of historical periods are read and arranged in chronological order from earliest to latest to form a historical topology difference degree sequence. For example, if the number of historical periods to be traced is set to 20, then the historical topology difference degrees of the most recent 20 historical periods are read to form a historical topology difference degree sequence containing 20 values.
[0066] Analyzing the statistical distribution characteristics of historical topological dissimilarity sequences determines the range of dissimilarity fluctuations. The range of dissimilarity fluctuations is a numerical interval used to determine whether the current topological dissimilarity is abnormal. The analysis process first requires calculating several key statistics of the historical topological dissimilarity sequence. Calculate the arithmetic mean of all values in the historical topological dissimilarity sequence. Calculate the standard deviation of all values in the historical topological dissimilarity sequence; the standard deviation is the square root of the average of the squares of the differences between each value and the mean. Calculate the quartiles of all values in the historical topological dissimilarity sequence, including the first and third quartiles. Based on the calculated statistics, the range of dissimilarity fluctuations is determined. One method for determining the range of dissimilarity fluctuations is based on the mean and standard deviation. Adding K times the standard deviation to the mean of the historical topological dissimilarity sequence is used as the upper bound of the range of dissimilarity fluctuations, and subtracting K times the standard deviation from the mean of the historical topological dissimilarity sequence is used as the lower bound of the range of dissimilarity fluctuations. K is a coefficient greater than 0, for example, K can be 2 or 3. The range of dissimilarity fluctuations determined in this way is a closed interval. Another method for determining the range of dissimilarity fluctuations is based on quartiles. The interquartile range (IQM) is calculated as the difference between the first and third quartiles. The third quartile plus L times the IQM is used as the upper bound of the IQM range, and the first quartile minus L times the IQM is used as the lower bound. L is a coefficient greater than 0, for example, L can be 1.5. The determined IQM range is stored in memory as a data structure containing both the lower and upper bounds.
[0067] The current topological dissimilarity is compared to the dissimilarity fluctuation range. The comparison operation determines whether the current topological dissimilarity falls within the closed interval of the dissimilarity fluctuation range. The judgment logic is as follows: if the current topological dissimilarity is greater than or equal to the lower bound of the dissimilarity fluctuation range and simultaneously less than or equal to the upper bound, then the current topological dissimilarity is considered to be within the dissimilarity fluctuation range. If the current topological dissimilarity is less than the lower bound or greater than the upper bound, then the current topological dissimilarity is considered to exceed the dissimilarity fluctuation range. When the current topological dissimilarity continuously exceeds the dissimilarity fluctuation range, it is determined that the classification model needs to be updated. Continuous exceedance means that within a continuous period, every calculated current topological dissimilarity exceeds the dissimilarity fluctuation range used in that period. A continuous period threshold is set, for example, 3 periods. Starting from the current period, if the current topological dissimilarity in the current period exceeds the dissimilarity fluctuation range defined for the current period, an exceedance event is recorded. Waiting for the next cycle, when executing steps S3 and S4 in the next cycle, the current topological difference degree of the next cycle is obtained and compared with the difference degree fluctuation range determined for that next cycle; if it exceeds the range again, it is recorded again. If the number of consecutively recorded exceedance events reaches or exceeds the duration period threshold, for example, if the current topological difference degree of three consecutive cycles exceeds the difference degree fluctuation range corresponding to their respective cycles, it is determined to be a continuous exceedance, thus generating a determination result that the classification model needs to be updated. If the duration period threshold is not reached, for example, only one or two cycles exceed the range, and then it returns to the difference degree fluctuation range, it is determined that the classification model does not need to be updated. The determination result is a Boolean value, true indicates that an update is needed, and false indicates that an update is not needed. This determination result will be passed to the subsequent step S5 to determine whether to execute the subsequent update process.
[0068] In one specific implementation, step S5 is implemented as follows: Extract the misclassified feature vectors corresponding to samples misclassified by the classification model from the current and historical recognition results. The current and historical recognition results are the outputs generated and stored in step S1 at each cycle. Determining whether a sample is a misclassified sample requires the use of a true category label. The true category label is obtained by manually re-confirming and labeling the image. For example, in each batch of collected images, a portion of the images are randomly selected and independently classified and labeled by agricultural experts based on visual inspection, generating true category labels. Compare the current or historical recognition results output by the classification model with the true category label corresponding to the same image. If the category label output by the model is inconsistent with the true category label, the sample is marked as a misclassified sample. For each marked misclassified sample, its corresponding misclassified feature vector is known. In step S1, when the classification model processes an image and outputs a recognition result, it synchronously generates and stores the image feature vector of that image. Therefore, based on the unique identifier of the image corresponding to the misjudged sample, the image feature vector of the image generated and saved in step S1 can be retrieved from the storage system. This retrieved image feature vector is the misjudged feature vector corresponding to the misjudged sample. The misjudged feature vectors of all misjudged samples extracted from the current period and multiple pre-set historical periods constitute the input dataset for subsequent density clustering.
[0069] In the feature space, density clustering is performed on the misclassified feature vectors to identify the densely distributed regions of misclassified feature vectors as the core feature blur regions. The feature space is a multidimensional space composed of the dimensions of image feature vectors, and each misclassified feature vector is a point in this space. Density clustering employs a density-based noise-applied spatial clustering method, namely the DBSCAN method. The DBSCAN method requires setting two key parameters: a neighborhood radius parameter and a minimum sample number parameter. The neighborhood radius parameter is a distance threshold used to define the neighborhood range of a point in the space. One way to set the neighborhood radius parameter is to calculate the Euclidean distances between all pairwise misclassified feature vectors in the input dataset, calculate the average of these distances, and then multiply this average by a coefficient to obtain the neighborhood radius parameter. This coefficient can be selected from a range, for example, the range of the coefficient is 0.5 to 1.5, and 0.8 is selected as the coefficient. The minimum sample number parameter is a quantity threshold used to determine whether a point is a core point. One way to set the minimum sample number parameter is to determine it based on the total number of misclassified feature vectors in the input dataset. The total number of misclassified feature vectors is calculated by multiplying it by a scaling factor, which ranges from, for example, 0.05 to 0.1. The product is then rounded up to obtain the minimum sample size parameter, which must be at least 2. The DBSCAN clustering process is as follows: First, all misclassified feature vector points in the input dataset are traversed. For the currently traversed point, its Euclidean distance to all other misclassified feature vector points in the dataset is calculated. The total number of points falling within the hypersphere centered at the current point and with a neighborhood radius parameter as its radius is counted, including the current point itself. If the total count is greater than or equal to the minimum sample size parameter, the current point is marked as a core point. If the total count is less than the minimum sample size parameter, the current point is temporarily marked as a noise point. Second, for each marked core point, all points whose Euclidean distance is less than the neighborhood radius parameter are grouped into the same cluster. This process is recursively or iteratively merged points within the neighborhood of a core point, as well as points within the neighborhood of new core points among these points, until no new points can be added to the current cluster. Finally, all points not assigned to any cluster at the end of the process are considered noise points. A set of points formed by the core point and all points connected to it through neighborhood relationships is identified as a cluster. In the feature space, each such cluster corresponds to a region with a dense distribution of misclassified feature vectors; this region is defined as a core feature fuzzy region. There may be one or more core feature fuzzy regions.
[0070] Based on the location information of the original images corresponding to the misjudged feature vectors in the blurred core feature region, the geographical area to be sampled in the actual field area is determined. Each misjudged feature vector corresponds to an original digital image of ginger stems and leaves. The geographical location information of this original image was recorded by the GPS module integrated into the acquisition device during acquisition, and the geographical location information is stored in latitude and longitude coordinate format. For an identified blurred core feature region, all misjudged feature vector points contained in this region correspond to a set of original digital images of ginger stems and leaves. The latitude and longitude coordinates recorded in this set of original images are obtained. One method to determine the geographical area to be sampled is to find the largest latitude value, smallest latitude value, largest longitude value, and smallest longitude value from this set of latitude and longitude coordinates. A coordinate point is formed using the smallest latitude and smallest longitude values, and another coordinate point is formed using the largest latitude and largest longitude values. The rectangular geographical area delineated with these two coordinate points as diagonal vertices is the geographical area to be sampled. Another method to determine the geographical area to be sampled is to calculate the geometric center point of this set of latitude and longitude coordinates. Calculate the average of all latitude values as the latitude of the center point, and calculate the average of all longitude values as the longitude of the center point. Draw a circle with this center point as the center and a preset radius. This circular geographical area is the geographical range to be sampled. The preset radius can be set by calculating the average distance from all coordinate points to the center point and adding one times the standard deviation of the average distance. The final determined geographical range is a geographical area with clearly defined boundaries.
[0071] Within a defined geographical area, new digital images of ginger stems and leaves are collected as new training sample images. The collection operation is performed by personnel or automated equipment. First, the boundaries of the defined geographical area are described, such as the coordinates of the diagonal vertices of a rectangle or the coordinates of the center and radius of a circle, and input into a mobile navigation device or drone aerial photography control system. Personnel carrying image acquisition equipment or a drone automatically flies to the actual field area corresponding to this geographical area. Within this actual field area, images of ginger stems and leaves are collected according to a preset sampling strategy. The preset sampling strategy can be uniform grid sampling, which divides the geographical area into grids of equal area and selects a ginger plant near the center point of each grid to photograph its stems and leaves. Alternatively, the preset sampling strategy can be random point sampling, which randomly generates several coordinate points within the geographical area and selects a ginger plant near each coordinate point to photograph it. The number of images collected needs to reach a preset lower limit, for example, a lower limit of 50 images and an upper limit of 200 images. When acquiring images, similar shooting specifications to those used for historical image acquisition should be followed, such as maintaining the camera lens at a height of approximately 50 cm from the plant leaves, ensuring the lens optical axis is roughly perpendicular to the ground, and setting the image resolution to 20 megapixels. A new digital image of ginger stems and leaves should be obtained each time an image is taken within the sampling geographic area. The collection of all newly acquired digital images of ginger stems and leaves in this task constitutes the new training sample images output in step S5.
[0072] In one specific implementation, step S6 is carried out as follows: Image feature vectors are extracted from new training sample images to form a new sample feature set. The specific operation for extracting image feature vectors is consistent with the method described in step S1. Each new training sample image is input into the currently deployed classification model. When the image data propagates forward through the network to a preset layer designated as the feature extraction layer, the output values of all neurons in that layer are recorded, and these values are arranged into a one-dimensional array according to the order of the neurons. This one-dimensional array is the image feature vector of that image. This operation is repeated for all new training sample images obtained in step S5 to obtain multiple image feature vectors. The set of all these image feature vectors is defined as the new sample feature set.
[0073] The new sample feature set is merged with a subset of sample feature vectors selected from the historical feature set to form the model optimization training set. The historical feature set is the set of feature vectors from various historical periods obtained and stored in step S2. The process of selecting a subset of sample feature vectors from the historical feature set involves setting a sampling ratio coefficient for each historical feature set. The sampling ratio coefficient, for example, takes a value between 0.1 and 0.3. The total number of image feature vectors in the historical feature set is calculated, multiplied by the sampling ratio coefficient, and then the product is rounded up to obtain the number of samples to be extracted from the historical feature set. A specified number of image feature vectors are randomly selected from the historical feature set using a random number generation algorithm, and each image feature vector is selected only once. All historical image feature vectors extracted in this way from all historical feature sets are merged with all image feature vectors in the new sample feature set to form a unified feature vector set, which is the model optimization training set. Each feature vector in the model optimization training set needs to be associated with its true class label. For image feature vectors from a new sample feature set, the true class labels of the corresponding new training sample images need to be obtained through manual annotation, such as by agricultural experts reviewing the images and determining and recording the class. For historical image feature vectors extracted from a historical feature set, the true class labels of the original images stored in the historical period are used.
[0074] Based on the model optimization training set, the classification model undergoes iterative parameter optimization. The optimization process uses the gradient descent algorithm. First, a loss function is constructed. The loss function consists of two parts. The first part is the standard classification loss, which uses the cross-entropy loss function. For an image feature vector in the model optimization training set, it is input into the currently optimized classification model, and the model outputs a predicted probability distribution vector. The true class label corresponding to this image feature vector is converted into a one-hot encoded vector. The cross-entropy between the predicted probability distribution vector and the one-hot encoded vector is calculated. The arithmetic mean of the cross-entropies calculated on all image feature vectors in the model optimization training set is used to obtain the standard classification loss value. The second part is a constraint term, used to limit the variation of the output results of the parameter-optimized classification model relative to the deployed classification model on the historical feature set. The complete historical feature set of the most recent historical period is selected as the reference set. All historical image feature vectors in the reference set are input one by one into the currently deployed classification model, and a set of probability distribution vectors output by it is recorded. At the same time, all historical image feature vectors in the same reference set are input one by one into the classification model undergoing parameter iterative optimization, and another set of probability distribution vectors output by it is recorded. The difference between these two sets of probability distribution vectors is calculated as the constraint term. The difference is calculated using the mean squared error method, which involves subtracting the two probability values at corresponding positions, squaring the result, summing the squared values for all positions and all samples, and then dividing by the total number of calculations to obtain the average. The total loss function is a weighted sum of the standard classification loss value and the constraint term. A constraint term weight coefficient is set to adjust the influence of the constraint term; for example, the constraint term weight coefficient is between 0.01 and 0.1. The total loss function equals the standard classification loss value plus the constraint term weight coefficient multiplied by the constraint term value. The parameter iterative optimization process involves initializing the classification model's parameters to the currently deployed model's parameter values. A learning rate is set, for example, 0.001. In each iteration, the gradient of the current total loss function with respect to all trainable parameters of the model is calculated. Then, each parameter value is updated to its original value minus the learning rate multiplied by the gradient value of that parameter. The iterative process continues until the change in the total loss function value over 10 consecutive iterations is less than a threshold, for example, a threshold set to 0.0001, or until a preset maximum number of iterations is reached, for example, 1000 iterations. After the iteration stops, the classification model with optimized parameters is obtained.
[0075] The update process involves replacing the deployed classification model with the optimized one. All parameter values of the optimized classification model are exported and stored as a new model parameter file. In the production system environment, the model parameter file corresponding to the currently used (deployed) classification model is located, and it is overwritten with the new model parameter file, or the system configuration file is modified to point to the new model parameter file. After the file replacement or configuration update is complete, the system reloads the model. Thereafter, when the system recognizes any newly input digital images of ginger stems and leaves, it will use the optimized classification model for calculation and judgment. This completes one full update process for the classification model.
[0076] All calculations involved in the embodiments are dimensionless numerical calculations, and the preset parameters and thresholds in the calculations are set by those skilled in the art according to the actual situation.
[0077] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, in the form of a computer program product.
[0078] Those skilled in the art will recognize that the modules and algorithm steps of the various examples 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 implemented in hardware or software depends on the specific application and inventive constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0079] In addition, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.
[0080] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0081] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0082] In conclusion, the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. An optimized method for identifying diseases and pests in ginger stems and leaves based on image recognition, characterized in that, Includes the following steps: S1. Obtain digital images of ginger stems and leaves for the current period, and use the deployed classification model to identify the digital images of ginger stems and leaves to obtain the current identification result and the corresponding current feature set. S2. Obtain multiple historical feature sets generated by the classification model in multiple consecutive historical periods, and perform topological structure analysis on each of the multiple historical feature sets to obtain their respective historical topological structure description information. S3. Compare the current feature set with the historical topological structure description information, and calculate the topological difference degree, which characterizes the degree of deviation of the current feature set structure. S4. Based on the topological dissimilarity, determine whether the classification model needs to be updated; S5. When an update is needed, identify the core feature fuzzy region that causes confusion in the classification model based on the misjudged data in the current and historical recognition results, and collect new training sample images from the actual field area corresponding to the core feature fuzzy region. S6. Extract features from the new training sample images and optimize the parameters of the classification model to complete the update.
2. The method for optimizing the identification of diseases and pests in ginger stems and leaves based on image recognition according to claim 1, characterized in that, S1 includes: Acquire multiple digital images of ginger stems and leaves under different lighting conditions within the current period; Multiple digital images of ginger stems and leaves are input into the deployed classification model. The classification model outputs the pest and disease category of each digital image of ginger stems and leaves as the current recognition result, and the activation values of the preset layer in the classification model are extracted simultaneously to form the image feature vector of the corresponding image. The set of image feature vectors of all images belonging to the current period is determined as the current feature set.
3. The method for optimizing the identification of diseases and pests in ginger stems and leaves based on image recognition according to claim 1, characterized in that, S2 include: Obtain multiple sets of historical features stored by the classification model in multiple consecutive historical periods, where each set of historical features contains the historical feature vectors of all images in the corresponding historical period; For each set of historical features, calculate the distance between any two historical feature vectors in the set, and construct a graph structure representing the connection relationship between historical feature vectors based on the distance threshold. Analyze the number and scale distribution of connected components in the graph structure corresponding to each historical feature set, and generate historical topological structure description information to describe the spatial topological morphology of each historical cycle feature.
4. The method for optimizing the identification of diseases and pests in ginger stems and leaves based on image recognition according to claim 1, characterized in that, S3 includes: Based on the distance between any two current feature vectors in the current feature set, and according to the same distance threshold as the information describing the historical topology, construct the current graph structure corresponding to the current feature set; Analyze the number and size distribution of connected components in the current graph structure to obtain the current topology description information; The current topology description information is matched and compared with each historical topology description information, and the distribution distance between the description information on multi-dimensional features is calculated. The distribution distances corresponding to all historical periods are aggregated and calculated to obtain the topological difference degree, which characterizes the degree of deviation of the current feature set structure.
5. The method for optimizing the identification of diseases and pests in ginger stems and leaves based on image recognition according to claim 4, characterized in that, The distribution distance is obtained by calculating the statistical distance between the current topology description information and each historical topology description information on the scale distribution of connected components.
6. The method for optimizing the identification of diseases and pests in ginger stems and leaves based on image recognition according to claim 1, characterized in that, S4 include: Obtain the current topological dissimilarity and the historical topological dissimilarity sequence corresponding to multiple consecutive historical periods; Analyze the statistical distribution characteristics of historical topological dissimilarity sequences to determine the range of dissimilarity fluctuations; The current topological dissimilarity is compared with the dissimilarity fluctuation range, and if the current topological dissimilarity continues to exceed the dissimilarity fluctuation range, it is determined that the classification model needs to be updated.
7. The method for optimizing the identification of diseases and pests in ginger stems and leaves based on image recognition according to claim 1, characterized in that, S5 include: Extract the misclassified feature vectors corresponding to samples misclassified by the classification model from the current recognition results and historical recognition results; In the feature space, density clustering is performed on the misjudged feature vectors to identify the densely distributed regions of the misjudged feature vectors as the core feature fuzzy regions. Based on the location information of the original image corresponding to the misjudged feature vector in the blurred area of the core feature, the geographical range that needs to be sampled in the actual field area is determined; New digital images of ginger stems and leaves were collected within a defined geographical area to serve as new training sample images.
8. The method for optimizing the identification of diseases and pests in ginger stems and leaves based on image recognition according to claim 7, characterized in that, Density clustering employs a density-based noise-based spatial clustering method, identifying ambiguous regions with core features by setting neighborhood radius and minimum sample number parameters.
9. The method for optimizing the identification of diseases and pests in ginger stems and leaves based on image recognition according to claim 1, characterized in that, S6 include: Extract image feature vectors from new training sample images to form a new sample feature set; The new sample feature set is merged with the sample feature vectors selected from the historical feature set to form the model optimization training set; Based on the model optimization training set, the parameters of the classification model are iteratively optimized. The update is completed by replacing the deployed classification model with the optimized classification model.
10. The method for optimizing the identification of diseases and pests in ginger stems and leaves based on image recognition according to claim 9, characterized in that, The parameter iterative optimization process adds a constraint term to the loss function to limit the variation of the output results of the optimized classification model on the historical feature set relative to the deployed classification model.
Citation Information
Patent Citations
Explanatable model robust training method based on topological regular terms
CN120125933A
Power distribution network defect identification method and device based on unmanned aerial vehicle inspection, terminal equipment and storage medium
CN121811108A
