Disease category identification methods, devices and equipment
By using box counting to perform grid partitioning and feature fusion on high-level feature maps, the problem of accuracy and lightweight deployment for disease identification on low-cost edge devices is solved, improving disease differentiation capabilities and reducing deployment complexity.
Patent Information
- Application Number
- CN202611586620.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-14
- Publication Date
- 2026-11-10
AI Technical Summary
Existing technologies struggle to achieve both accurate fine-grained disease identification and lightweight deployment on low-cost edge devices, particularly in distinguishing between anthracnose and leaf spot. Furthermore, traditional methods require external preprocessing, resulting in high deployment costs.
Box counting is used to divide the high-level feature map into grids, and the number of occupied boxes in each channel is counted. Combined with semantic feature vectors and spatial complexity parameters, the data is embedded into the network to identify disease categories, thus avoiding external preprocessing.
It improves the ability to distinguish fine-grained diseases, reduces deployment complexity, and enables efficient disease identification on low-cost edge devices.
Smart Images

Figure CN123071748A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image recognition, and in particular to a method, apparatus and equipment for identifying disease categories. Background Technology
[0002] Currently, lightweight network-based disease identification methods based on global average pooling only calculate the average response intensity of each channel. They output similar semantic vectors under activation modes with similar average responses but different spatial distributions, making it difficult to distinguish between fine-grained diseases such as anthracnose and leaf spot. Traditional fractal features require preprocessing such as pyramid decomposition and edge detection outside the network, resulting in disconnect from deep features and high deployment costs. Lightweight networks, with limited labeled samples, struggle to stably learn the degree of lesion boundary fragmentation and cross-scale diffusion morphology. In summary, existing methods cannot simultaneously meet the requirements of accurate identification and lightweight deployment of fine-grained diseases on low-cost edge devices. Summary of the Invention
[0003] The main objective of this application is to provide a method, apparatus, and device for disease category identification, which aims to solve the technical problem of simultaneously meeting the requirements for accurate identification of fine-grained diseases and lightweight deployment on low-cost edge devices.
[0004] To achieve the above objectives, this application provides a disease category identification method, the disease category identification method comprising: The preprocessed blade image is input into the feature extraction network to obtain a high-level feature map containing multiple channels; Global statistics are performed on the high-level feature map to obtain semantic feature vectors; Multiple box scales are used to divide the feature map corresponding to each channel in the high-level feature map into a grid, resulting in the divided feature map corresponding to each channel. The box scale is the side length of each box when dividing the grid in the box counting method. The number of occupied boxes in the feature map corresponding to each channel at each box scale is counted. The occupied box is a local box that meets a preset condition. The local box is a grid in the feature map after partitioning. The spatial complexity parameters corresponding to each channel in the high-level feature map are determined based on the relationship between the box size and the number of occupied boxes. Based on the semantic feature vector and the space complexity parameters corresponding to each channel, the fusion feature is obtained; The disease category of the leaf image is determined based on the fusion features.
[0005] Optionally, the step of using multiple box scales to mesh the feature map corresponding to each channel in the high-level feature map to obtain the meshed feature map corresponding to each channel, wherein the box scale is the side length of each box when meshing in the box counting method, includes: Perform intra-channel normalization processing on the feature maps corresponding to each channel in the high-level feature map to obtain normalized feature maps for each channel; Based on a preset threshold, the normalized feature maps of each channel are converted into binary activation maps; Based on the aforementioned box scales, the binary activation map is divided into multiple non-overlapping local boxes, which serve as the segmented feature maps corresponding to each channel.
[0006] Optionally, the step of dividing the binary activation map into multiple non-overlapping local boxes based on the box scales, as the divided feature maps corresponding to each channel, includes: The multiple box scales are traversed, and the traversed box scale is taken as the current box scale; If the spatial size of the binary activation map is not divisible by the current box scale, the spatial size of the binary activation map is adjusted until the adjusted spatial size is divisible by the current box scale. Based on the current box scale, the adjusted binary activation map is divided into multiple non-overlapping local boxes; After the traversal is completed, the segmented feature map corresponding to each channel is determined based on the multiple non-overlapping local boxes.
[0007] Optionally, the step of counting the number of occupied boxes in the segmented feature map corresponding to each channel at each box scale, wherein the occupied box is a local box that meets a preset condition, and the local box is a grid in the segmented feature map, includes: The maximum value reduction is performed on the feature maps corresponding to each channel after partitioning to obtain the maximum value reduction result; Based on the result of the maximum value reduction, it is determined whether there is an activation position in the local box of the feature map after the division of each channel; If an activation location exists, count the number of local boxes with activation locations, and use this count as the number of occupied boxes at each box scale.
[0008] Optionally, the step of performing global statistics on the high-level feature map to obtain the semantic feature vector includes: Global average pooling is performed on each channel of the high-level feature map to obtain the global average response value of each channel; The global average response values of each channel are combined in channel order to obtain a semantic feature vector.
[0009] Optionally, the step of obtaining the fused features based on the semantic feature vector and the space complexity parameters corresponding to each channel includes: The space complexity parameters corresponding to each channel are arranged into a space complexity vector in channel order; The semantic feature vector and the space complexity vector are fused according to the feature dimension to obtain the fused feature.
[0010] Optionally, the step of determining the disease category of the leaf image based on the fusion features includes: The fused features are input into the classifier to obtain scores for each disease category; The scores for each disease category are normalized to obtain the probability of each disease category; The disease category with the highest probability among the probabilities of each disease category is selected as the identification result.
[0011] Optionally, after the step of selecting the disease category with the highest probability among the probabilities of each disease category as the identification result, the method further includes: Determine whether the maximum probability is greater than a preset confidence threshold; If the maximum probability is greater than or equal to a preset confidence threshold, output the disease category and confidence level corresponding to the maximum probability; If the maximum probability is less than the preset confidence threshold, output an unknown category or a low confidence result.
[0012] Furthermore, to achieve the above objectives, this application also proposes a disease category identification device, which includes: The feature map extraction module is used to input the preprocessed leaf image into the feature extraction network to obtain a high-level feature map containing multiple channels; The semantic feature extraction module is used to perform global statistics on the high-level feature map to obtain semantic feature vectors. The partitioning module is used to partition the feature map corresponding to each channel in the high-level feature map into a grid using multiple box scales, so as to obtain the partitioned feature map corresponding to each channel. The box scale is the side length of each box when partitioning the grid in the box counting method. The statistics module is used to count the number of occupied boxes in the feature map of each channel corresponding to each box scale. The occupied box is a local box that meets a preset condition. The local box is a grid in the feature map after partitioning. The space complexity determination module is used to determine the space complexity parameters corresponding to each channel in the high-level feature map based on the relationship between the box size and the number of occupied boxes. The fusion module is used to obtain fused features based on the semantic features and the space complexity parameters corresponding to each channel; The result output module is used to determine the disease category of the leaf image based on the fusion features.
[0013] In addition, to achieve the above objectives, this application also proposes a disease category identification device, which includes a memory, a processor, and a disease category identification program stored in the memory and executable on the processor. The disease category identification program is configured to implement the disease category identification method as described above.
[0014] In addition, to achieve the above objectives, this application also proposes a storage medium storing a disease category identification program, which, when executed by a processor, implements the disease category identification method as described above.
[0015] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a disease category identification program, and the disease category identification program implements the disease category identification method as described above when executed by a processor.
[0016] One or more technical solutions proposed in this application have at least the following technical effects: This application discloses a method for inputting a preprocessed blade image into a feature extraction network to obtain a high-level feature map containing multiple channels; performing global statistics on the high-level feature map to obtain semantic feature vectors; dividing the feature map corresponding to each channel in the high-level feature map into a grid using multiple box scales to obtain the divided feature map corresponding to each channel, wherein the box scale is the side length of each box when dividing the grid in the box counting method; counting the number of occupied boxes in the divided feature map corresponding to each channel at each box scale, wherein the occupied box is a local box that meets preset conditions, and the local box is a grid in the divided feature map; and determining the corresponding feature map for each channel in the high-level feature map based on the relationship between the box scale and the number of occupied boxes. The spatial complexity parameter is obtained; based on the semantic feature vector and the spatial complexity parameter corresponding to each channel, the fusion feature is obtained; the disease category of the leaf image is determined according to the fusion feature; since this application uses multiple box scales to count the number of occupied boxes of each channel feature map at different scales, and determines the spatial complexity parameter according to the relationship between the number of occupied boxes and the box scale, the degree of dispersion of the activation region and the degree of boundary fragmentation are quantitatively characterized. After the parameter is fused with the semantic feature, the discrimination criterion includes both response intensity and spatial morphology information, which improves the fine-grained disease discrimination ability. Moreover, the box count is embedded in the network, which does not require external preprocessing and reduces the deployment complexity. Attached Figure Description
[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a flowchart illustrating the first embodiment of the disease category identification method of this application; Figure 2 A schematic diagram illustrating the occupancy statistics of boxes at different box scales; Figure 3 This is a flowchart illustrating the second embodiment of the disease category identification method of this application; Figure 4 This is a flowchart illustrating the third embodiment of the disease category identification method of this application; Figure 5 This is a schematic diagram of the overall process of a lightweight litchi leaf disease identification method; Figure 6 Flowchart for the conversion from a trained model to a K230 edge executable model; Figure 7 A schematic diagram of a lightweight litchi leaf disease edge recognition system; Figure 8 This is a schematic diagram of the module structure of the disease category identification device according to an embodiment of this application; Figure 9 This is a schematic diagram of the equipment structure of the hardware operating environment involved in the disease category identification method in the embodiments of this application.
[0020] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0021] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0022] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0023] This application provides a method for identifying disease categories, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the disease category identification method of this application.
[0024] In the first embodiment, the disease category identification method includes: Step S10: Input the preprocessed blade image into the feature extraction network to obtain a high-level feature map containing multiple channels.
[0025] It should be noted that the executing entity in this embodiment may be a disease category identification device with data processing, network communication and program running functions, such as an electronic computing device, or other electronic devices that can achieve the same or similar functions. This embodiment does not limit this.
[0026] It should be understood that the preprocessed blade image refers to the image data obtained after performing any of the following processing methods on the original blade image: resizing, cropping or padding, color channel conversion, pixel value scaling, mean and variance standardization, and tensor layout conversion. For example, the preprocessed blade image can be an image tensor that has been resized to 224×224 pixels, converted from BgR to RgB color space, scaled to the [0, 1] range, standardized according to the three-channel mean [0.485, 0.456, 0.406] and standard deviation [0.229, 0.224, 0.225], and converted to an NCHW tensor layout.
[0027] It should be understood that feature extraction networks refer to deep convolutional neural networks that extract high-level semantic features from input images. These can be lightweight convolutional neural networks, such as MobileNetV3-Small, MobileNetV2, GhostNet, ShuffleNet, or EfficientNet-Lite, or other lightweight networks composed of deep convolutional layers, pointwise convolutional layers, and inverse residual connection structures.
[0028] It should be noted that a high-level feature map refers to the feature map tensor output from the end or near the end of the network after the feature extraction network performs multi-layer convolution operations on the preprocessed leaf image. A high-level feature map contains multiple channels, each corresponding to a two-dimensional spatial response map. Each position on the two-dimensional spatial response map represents the response intensity of the corresponding receptive field region of the preprocessed leaf image to a specific semantic pattern. It should be noted that the "corresponding receptive field region" refers to the actual range on the original input image corresponding to a pixel on the feature map. For example, the shape of a high-level feature map can be B×C×H×W, where B represents the batch size, C represents the number of channels, H represents the height of the feature map, and W represents the width of the feature map. The spatial size of the feature map is smaller than the spatial size of the input image, but its semantic abstraction level is higher than that of shallow feature maps.
[0029] In the specific implementation, for ease of understanding, the following example is provided. Assume that the preprocessed leaf image is an NCHW format tensor with shape (1, 3, 224, 224) as the input tensor. Then, the input tensor is subjected to a 3×3 convolution operation with a stride of 2 through the initial convolutional layer of the feature extraction network, and the output is an initial feature map with shape (1, 16, 112, 112). Subsequently, the initial feature map is subjected to multiple depthwise separable convolution operations through inverted residual blocks, gradually expanding the number of channels and compressing the spatial size. After processing through the last inverted residual block, the feature map is channel-integrated through the final 1×1 convolutional layer of the feature extraction network, and the output is a high-level feature map with shape (1, 576, 7, 7).
[0030] Step S20: Perform global statistics on the high-level feature map to obtain semantic feature vectors.
[0031] It should be noted that a semantic feature vector is a one-dimensional vector composed of the global statistical values of each channel of the high-level feature map arranged in channel order. Moreover, each element in the semantic feature vector corresponds to a channel, representing the overall response intensity of that channel in the entire spatial dimension.
[0032] It should be understood that global statistics refers to the aggregation operation performed on the high-level feature map in the spatial dimension. The aggregation operation can compress the two-dimensional spatial response map of each channel into a scalar value, including but not limited to global average pooling, global max pooling, or global second-order statistics.
[0033] In the specific implementation, a global average pooling operation is performed on the high-level feature map of shape B×C×H×W. Specifically, for each channel of the high-level feature map, the arithmetic mean of all feature values in the spatial dimensions (i.e., the height H direction and the width W direction) is calculated as the global average response value of that channel. For example, for the b-th sample of the c-th channel, the H×W feature values of that channel are added together and then divided by the total number of spatial locations (H×W) to obtain the global average response value of that channel. This global average pooling operation does not change the batch size B and the number of channels C, but only compresses the spatial dimension H×W of each channel into a scalar, resulting in a pooling result of shape B×C, where each batch of samples corresponds to a C-dimensional set of global average response values. Subsequently, the C global average response values of each sample are arranged in channel order and combined into a C-dimensional semantic feature vector.
[0034] Step S30: Use multiple box scales to divide the feature map corresponding to each channel in the high-level feature map into a grid, and obtain the divided feature map corresponding to each channel. The box scale is the side length of each box when dividing the grid in the box counting method.
[0035] It should be understood that box scale refers to the side length of each local box when using box counting to mesh a two-dimensional feature map, usually expressed in pixels. For example, box scale k represents dividing the feature map into k×k pixel non-overlapping local boxes. When multiple box scales are used, the set of box scales can be represented as K = {k1, k2, ..., k}. M}, where M≥2. For example, the box scale set is {1, 2, 4}, that is, the feature map is divided into grids using square boxes with side lengths of 1 pixel, 2 pixels, and 4 pixels, respectively.
[0036] It should be noted that the post-partition feature map refers to the feature map containing multiple non-overlapping local boxes obtained after mesh partitioning. The post-partition feature map maintains the same spatial dimensions as the initial feature map, but its structure is divided into a set of local boxes, each corresponding to a k×k pixel region.
[0037] In the specific implementation, refer to Figure 2 , Figure 2 This is a statistical diagram of occupied boxes at different box scales. Each box scale is taken as the current box scale k and the step size is used. Starting from the top left corner of the feature map corresponding to each channel in the high-level feature map, multiple local boxes are successively divided in the row and column directions with a step size k. The size of each local box is k×k pixels, and adjacent local boxes do not overlap. All channels and all box scales of the high-level feature map are traversed, and the feature map of each channel after division at each box scale is recorded.
[0038] Step S40: Count the number of occupied boxes in the feature map after partitioning for each channel at each box scale. The occupied box is a local box that meets the preset conditions. The local box is a grid in the feature map after partitioning.
[0039] In the specific implementation, for each local box in the segmented feature map corresponding to each channel at each box scale, it is determined whether there is an activation position in the local box: if there is at least one activation position in the middle of the local box, the local box is determined to meet the preset condition and is marked as an occupied box; if there is no activation position in the local box, the local box is determined not to meet the preset condition and is not marked. After the determination of all local boxes is completed, the number of local boxes marked as occupied boxes is counted to obtain the number of occupied boxes in the current channel at the current box scale. This process is repeated for all box scales and all channels to obtain the number of occupied boxes in the segmented feature map corresponding to each channel at each box scale.
[0040] Step S50: Determine the spatial complexity parameters corresponding to each channel in the high-level feature map based on the relationship between the box size and the number of occupied boxes.
[0041] It should be understood that the "variation relationship" refers to the trend of the number of occupied boxes changing with the box scale across multiple box scales. In box counting analysis, as the box scale k increases, the granularity of the mesh becomes coarser, and the pixel area covered by each local box becomes larger. Therefore, the number of occupied boxes usually decreases as the box scale increases. However, different spatial distribution patterns of active regions exhibit different variation relationships: the more dispersed the active regions and the more fragmented the boundaries, the faster the rate of decay of the number of occupied boxes with increasing box scale; conversely, the more concentrated the active regions and the more regular the boundaries, the slower the rate of decay of the number of occupied boxes with increasing box scale.
[0042] It should be noted that the spatial complexity parameter is a numerical indicator used to quantify the spatial distribution complexity of the activation regions of each channel. For example, a larger spatial complexity parameter value indicates that the activation regions of the channel are more dispersed and the boundaries are more fragmented; a smaller spatial complexity parameter value indicates that the activation regions of the channel are more concentrated and the boundaries are more regular.
[0043] In the specific implementation, for each channel, a correspondence is established between the number of occupied boxes at each box scale and the box scale itself, resulting in multiple sets of box scale-occupied box number data points. Then, a curve or straight line showing the change of the number of occupied boxes with the box scale is fitted based on these multiple sets of data points. Finally, the spatial complexity parameter of the channel is determined based on the change characteristics of the fitted curve or straight line. Taking log-linear regression fitting as an example, the slope of the linear regression between the logarithm of the reciprocal of each box scale and the logarithm of the corresponding number of occupied boxes is calculated, and the slope obtained from the regression is used as the spatial complexity parameter of the channel. The regression slope reflects the decay rate of the number of occupied boxes with the change of box scale; that is, the larger the absolute value of the slope, the faster the number of occupied boxes decays with the increase of box scale, and the more dispersed and fragmented the activation region; the smaller the absolute value of the slope, the slower the number of occupied boxes decays with the increase of box scale, and the more concentrated and regular the activation region. The above process is repeated for all channels in the high-level feature map to obtain the spatial complexity parameter corresponding to each channel.
[0044] For ease of understanding, the following references Figure 3 This explanation is provided, but does not impose specific limitations on this embodiment. For the two-dimensional feature response F of the b-th sample and the c-th channel... b,c Its spatial dimensions are H×W. First, in-channel min-max normalization is performed to reduce the impact of differences in response amplitude between different channels on space occupancy statistics:
[0045] Where i is the row (height) index of the feature map, with a value of 1 to H; j is the column (width) index, with a value of 1 to W; To prevent the stability constant from having a denominator of zero, this embodiment can take a value of 0.00001; This represents finding the minimum response value for all H×W spatial locations under fixed sample b and fixed channel c, where u∈{1,…,H} and v∈{1,…,W}. The range of values is consistent with the minimum value mentioned above, representing the maximum response value in the two-dimensional response graph of this channel. This represents the feature response value of the c-th channel of the b-th sample at the position of row u and column v. ∈R H×W This represents the two-dimensional feature response map of the b-th sample and c-th channel in the high-level feature tensor F. Then, based on the activation threshold... Convert the continuous response into a binary activation map:
[0046] Where τ is the binary activation threshold, which can be set to 0.5 in this embodiment; I(·) is the indicator function: it takes 1 when the condition in parentheses is true and 0 when it is false, therefore B b,c (i,j) is a binary activation graph. To illustrate the theoretical basis of the complexity parameters used, the classical box-counting dimension D can be expressed as:
[0047] In the classic definition of box counting dimension, N(r) represents the number of boxes required to cover the target region when the box side length is r, where r represents the continuous or normalized box side length, and r approaching 0 indicates that the scale is gradually refined. For neural network feature maps of finite size, an integer pixel box scale k is used for implementation; r and k both conceptually represent box scale, but they are not exactly the same, where r is the continuous or normalized scale, and k is the discrete pixel box side length in the implementation.
[0048]
[0049] For any box scale k in the finite scale set K, the binary activation map is divided into non-overlapping k×k local boxes. If the spatial size is not divisible by k, it can be cropped to the largest divisible region, or zero-padding, mirror filling, or box statistics with incomplete edges can be used. If at least one activation location exists in a local box, the box is marked as occupied. Let P... k =floor(H / k), Q k =floor(W / k), then p=0, ..., P k-1 and q=0, ...,Q k-1 Ω represents the local box at row p and column q, where uppercase P_k and Q_k represent the total number of local boxes along the height and width directions at the current box scale; lowercase p and q represent the row and column indices of the specific local box, respectively, and have different meanings; p,q (k)This represents the corresponding k×k pixel / feature location set. The number of occupied boxes is:
[0050] Where, N b,c (k) represents the number of boxes occupied by the b-th sample and the c-th channel at box size k. It is assumed that the number of occupied boxes and the box size follow an approximately power-law relationship, and at finite discrete scales, its logarithmic form is linear:
[0051] Where b0 is the intercept of the log-linear regression, representing the position of the fitted line along the vertical axis; N(k) in the formula corresponds to the number of boxes occupied by the current sample and channel at box scale k, i.e., N b,c (k).
[0052] Define the regression x-axis and y-axis for the m-th discrete scale:
[0053] The space complexity parameters for finite-scale box counting in each channel are calculated using least-squares regression:
[0054] in, Let be the space complexity parameter for the c-th channel of the b-th sample. Combine all channel parameters in channel order as follows:
[0055] in, Let C be a vector consisting of channel complexity parameters. Let represent a C-dimensional real vector space. Since the actual feature map size is finite and the scale set is discrete, this parameter can be expressed as a "finite-scale box counting space complexity parameter" or a "space complexity descriptor based on box counting slope".
[0056] Step S60: Based on the semantic feature vector and the space complexity parameters corresponding to each channel, obtain the fused features.
[0057] It should be noted that the space complexity vector is a one-dimensional vector composed of the space complexity parameters corresponding to each channel of the high-level feature map, arranged in channel order. Each element in the space complexity vector corresponds to a channel, representing the spatial distribution complexity of the activation region of that channel. For example, the dimension of the space complexity vector is the same as the dimension of the semantic feature vector, both being C-dimensional, where C is the number of channels in the high-level feature map.
[0058] It should be understood that fused features refer to the joint feature representation obtained by merging semantic feature vectors and spatial complexity vectors according to feature dimensions. It can simultaneously contain the response intensity information of each channel of the high-level feature map (derived from the semantic feature vector) and the spatial distribution morphology information of the activation regions of each channel (derived from the spatial complexity vector). In the specific implementation, the space complexity parameters corresponding to each channel of the high-level feature map are first arranged in channel order and combined into a space complexity vector. Then, the semantic feature vector and the space complexity vector are merged according to the feature dimension to obtain the fused feature.
[0059] For ease of understanding, the following examples are provided, but they do not impose specific limitations on this embodiment. First, the semantic branch performs global average pooling on the same high-level feature tensor:
[0060] Among them, g b,c This represents the global average response of the b-th sample and the c-th channel, reflecting the overall semantic activation strength of that channel across the entire feature map. The global average responses of each channel are then arranged in channel order to form a semantic feature vector.
[0061] Let be the C-dimensional semantic feature vector of the b-th sample. The semantic feature vector and the space complexity vector are concatenated along their feature dimensions to form a fused feature:
[0062] z b =[g b ;d b [] represents the concatenation result of semantic features and complexity features along the feature dimension; the semicolon indicates vector concatenation. This represents a 2C-dimensional real vector space, reflecting that the feature dimension after concatenation is twice the original number of channels. The fused features are then input into a two-layer multilayer perceptron classifier.
[0063]
[0064] h b This is the hidden feature vector obtained after fusing the features through the first fully connected layer and Hardswish activation. W1 is the trainable weight matrix of the first fully connected layer. b1∈R L y is the trainable bias vector for the first fully connected layer. b Let W2 be the K-dimensional category score (Logits) vector corresponding to the b-th sample, which has not yet been normalized to probability. (K×L)is the trainable weight matrix for the second fully connected layer, used to map hidden features to K-class scores. Dropout is a random deactivation operation during training to suppress overfitting; in this embodiment, p can be taken as . d =0.2; No random deactivation during the inference phase, equivalent to an identity mapping. b2∈R K This is the trainable bias vector for the second fully connected layer. The class probabilities are calculated using the Softmax function:
[0065] The output vector is the Logits for each disease category. X b Let be the b-th input image; t be the target category index; s be the summation category index; s is used here to distinguish it from the scale variable r in the aforementioned classic box counting formula; b,t Let be the logits of class t; exp(·) is an exponential function with base e. p(y=t|Xb) is the class probability, t, s∈{1,…,K}. b ) is the sample X b The predicted probability of belonging to category t.
[0066] Step S70: Determine the disease category of the leaf image based on the fusion features.
[0067] In the specific implementation, the fused features are input into the classifier. It should be noted that the classifier refers to the machine learning model used to map the fused features to scores for each disease category. It can be a single-layer fully connected network, a multilayer perceptron, a support vector machine, or any other classification model capable of mapping features to category scores. Specifically, the fused features first undergo a linear transformation through the first fully connected layer of the classifier, then the fused features are mapped from the fused feature dimension to an intermediate dimension, outputting intermediate features. The intermediate features then undergo a non-linear transformation through an activation layer to enhance the classifier's expressive power, outputting activated features. The activated features then pass through a random deactivation layer, where some feature values are randomly discarded with a preset probability during the training phase to suppress overfitting, and all feature values are kept unchanged but scaled proportionally during the inference phase, outputting deactivated features. The deactivated features then undergo a linear transformation through a second fully connected layer, mapping the intermediate dimension to the total number of categories, outputting the score for each disease category. The scores for each disease category are then subjected to probability normalization, i.e., the scores for each disease category are input into a Softmax function, which performs exponential operations and normalization on each score, outputting the probability of each disease category. The probability value represents the confidence level of the classifier in determining that the input leaf image belongs to the corresponding disease category. The highest probability is then selected from the probabilities of each disease category, and the disease category corresponding to the highest probability is output as the recognition result.
[0068] This embodiment uses multiple box scales to count the number of occupied boxes in the feature map of each channel at different scales, and determines the spatial complexity parameter based on the relationship between the number of occupied boxes and the box scale. This quantitatively characterizes the dispersion of the activation region and the degree of boundary fragmentation. Subsequently, after fusing this parameter with semantic features, the discrimination criteria include both response intensity and spatial morphology information, which improves the ability to distinguish fine-grained diseases. Moreover, the box count is embedded inside the network, eliminating the need for external preprocessing and reducing deployment complexity.
[0069] Reference Figure 3 , Figure 3 This is a flowchart illustrating the second embodiment of the disease category identification method of this application, based on the above. Figure 1 The first embodiment shown presents a second embodiment of the disease category identification method of this application.
[0070] In the second embodiment, step S30 includes: Step S301: Perform intra-channel normalization processing on the feature maps corresponding to each channel in the high-level feature map to obtain normalized feature maps of each channel.
[0071] In the specific implementation, for each channel feature map (i.e., a two-dimensional response map of shape H×W) in the high-level feature map, all feature points in the current channel feature map are scanned to find the maximum and minimum values of the current channel feature map. Then, based on the maximum and minimum values of the current channel feature map, the normalized value of each feature point in the channel is calculated. The original values of all feature points in the current channel feature map are then replaced with the calculated normalized values to form the normalized channel feature map. The above process is repeated for each channel in the high-level feature map to obtain the normalized channel feature maps for all channels. It should be understood that the normalized channel feature maps have the same spatial size H×W and the same number of channels C as the unnormalized channel feature maps, but the response value of each channel is mapped to the interval [0, 1].
[0072] Step S302: Based on a preset threshold, convert the normalized feature maps of each channel into binary activation maps.
[0073] It should be noted that the preset threshold refers to a pre-set numerical limit used to determine whether the normalized feature response value constitutes a valid activation. The preset threshold can be a fixed constant or a value dynamically determined according to the channel activation distribution characteristics, such as the mean, median or quantile of the response values within the channel.
[0074] It should be understood that a binary activation map is a binary image obtained by thresholding the normalized feature maps of each channel. In a binary activation map, each pixel takes a first value or a second value. The first value can indicate that there is an activation response at that location, while the second value can indicate that there is no activation response at that location. For example, the first value can be 1 and the second value can be 0.
[0075] In the specific implementation, the normalized response value at each position in each normalized channel feature map is read pixel by pixel. This normalized response value is compared with a preset threshold. If the normalized response value at the current position is greater than or equal to the preset threshold, the position is marked as an active position, and the corresponding position in the binary activation map is assigned a value of 1. If the normalized response value at the current position is less than the preset threshold, the position is marked as an inactive position, and the corresponding position in the binary activation map is assigned a value of 0. After completing the above comparison and assignment for all pixels in the channel feature map, the binary activation map for that channel is obtained. This process is repeated for all normalized channel feature maps to obtain the binary activation map corresponding to each channel.
[0076] Step S303: Based on the scale of each box, the binary activation map is divided into multiple non-overlapping local boxes, which serve as the segmented feature maps corresponding to each channel.
[0077] In the specific implementation, when dividing the current box scale k, starting from the top left corner of the current channel binary activation map with a step size of k, multiple local boxes are successively divided in the row and column directions with a step size of k. The size of each local box is k×k pixels, and adjacent local boxes do not overlap. Traversing all channels and all box scales, the grid division of the corresponding binary activation map of each channel at each box scale is completed, and the divided feature map of each channel at each box scale is obtained.
[0078] Furthermore, in order to achieve the effect of full-area coverage of the activation map for each channel, step S303 includes: traversing the multiple box scales and taking the traversed box scale as the current box scale; if the spatial size of the binary activation map cannot be divided by the current box scale, adjusting the spatial size of the binary activation map until the adjusted spatial size can be divided by the current box scale; dividing the adjusted binary activation map into multiple non-overlapping local boxes based on the current box scale; after traversal, determining the segmented feature map corresponding to each channel based on the multiple non-overlapping local boxes.
[0079] In the specific implementation, multiple box scales are traversed, and the traversed box scale is taken as the current box scale. For each channel's binary activation map under the current box scale, it is first determined whether the spatial dimensions (height H and width W) of the binary activation map are divisible by the current box scale. If the spatial dimensions of the binary activation map are not divisible by the current box scale, the spatial dimensions of the binary activation map are adjusted (for example, by cropping the binary activation map to the largest integer multiple of the current box scale, or by padding the edges of the binary activation map with zeros or mirroring), until the adjusted spatial dimensions are divisible by the current box scale. The box scale is divided by integers. Then, the disease category identification device uses the current box scale as the step size and starts from the upper left corner of the adjusted binary activation map, and divides it into multiple local boxes in the row and column directions with a step size of k. Each local box is k×k pixels in size, and adjacent local boxes do not overlap. After the division at the current box scale is completed, the next box scale is traversed and the above judgment, adjustment and division operations are repeated. After traversing all box scales, the segmented feature map corresponding to each channel is determined based on the multiple non-overlapping local boxes obtained from the division at multiple box scales.
[0080] Furthermore, in order to achieve full-area coverage of the activation map for each channel and structured determination of the activation state within each local box, the step of counting the number of occupied boxes in the segmented feature map corresponding to each channel at each box scale, wherein the occupied box is a local box that meets preset conditions and the local box is a grid in the segmented feature map, includes: performing maximum value reduction on the segmented feature map corresponding to each channel to obtain the maximum value reduction result; determining whether there is an activation position in the local box of the segmented feature map corresponding to each channel based on the maximum value reduction result; if there is an activation position, counting the number of local boxes with activation positions as the number of occupied boxes at each box scale.
[0081] It should be noted that reduction refers to the operation of compressing a set of data into a single value through a certain operation, but it is not limited to maximum value reduction, average value reduction, summation reduction, etc. Among them, maximum value reduction refers to a method of aggregating the pixel values within each local box in the segmented feature map, and taking the maximum value of all pixel values within the local box as the reduction result of that local box.
[0082] In the specific implementation, for the segmented feature maps corresponding to each channel at each box scale, maximum value reduction is performed independently for each local box. This involves scanning all pixel values within the current local box and taking the maximum value as the reduction result. In the context of a binary activation map, a maximum value reduction result of 1 indicates that there is at least one activation location in the local box, while a reduction result of 0 indicates that there is no activation location in the local box. The local boxes are then judged based on their maximum value reduction results. Local boxes with a reduction result of 1 satisfy a preset condition and are marked as occupied boxes; local boxes with a reduction result of 0 do not satisfy the preset condition and are not marked as occupied boxes. After completing the reduction and judgment of all local boxes, the number of local boxes marked as occupied boxes is counted to obtain the number of occupied boxes for the current channel at the current box scale. Then, all box scales and all channels are traversed to obtain the number of occupied boxes for each channel corresponding to each box scale.
[0083] Furthermore, in order to achieve the effect of quantitatively representing the overall response intensity of each channel, the step of performing global statistics on the high-level feature map to obtain the semantic feature vector includes: performing global average pooling on each channel of the high-level feature map to obtain the global average response value of each channel; and combining the global average response values of each channel in channel order to obtain the semantic feature vector.
[0084] It should be understood that global average pooling refers to the aggregation operation performed on each channel of the high-level feature map in the spatial dimension, compressing the two-dimensional spatial response map of each channel into a scalar value, which is the overall representation of the high-level semantic information contained in the high-level feature map.
[0085] It should be noted that the global average response value refers to the scalar result obtained by performing global average pooling on all feature values in a certain channel of the high-level feature map. It can represent the average response intensity of the current channel across the entire spatial dimension.
[0086] It should be understood that a semantic feature vector is a one-dimensional vector composed of the global average response values of each channel of a high-level feature map arranged in channel order. Each element in the semantic feature vector corresponds to a channel and represents the average response intensity of that channel across the entire spatial dimension.
[0087] In the specific implementation, a global average pooling operation is performed on the high-level feature map with shape B×C×H×W. For each channel of the high-level feature map, the arithmetic mean of all feature values is calculated in the spatial dimension. Specifically, for the b-th sample of the c-th channel, the H×W feature values of the channel are added together and divided by the total number of spatial positions H×W to obtain the global average response value of the channel, resulting in a pooling result of shape B×C. Each batch of samples corresponds to a C-dimensional set of global average response values. Then, the global average response values of each channel are extracted according to the channel order. Specifically, the global average response values of each channel are taken out in order from channel index 1 to C as the corresponding position elements of the semantic feature vector. All C global average response values are combined into a C-dimensional semantic feature vector, and the order of elements in the semantic feature vector strictly corresponds to the channel order of the high-level feature map. For example, when the number of channels is 576, global average pooling is performed on each of the 576 channels to obtain the global average response value g1 of the first channel, g2 of the second channel, ..., g of the 576th channel. 576 The global average response value of each channel is extracted sequentially according to the channel index from 1 to 576. That is, g1 is used as the first element of the semantic feature vector, g2 is used as the second element of the semantic feature vector, and so on up to g. 576 As the 576th element of the semantic feature vector, it is combined to form a 576-dimensional semantic feature vector g = (g1, g2, ..., g...). 576 ).
[0088] This embodiment performs intra-channel normalization on the feature maps corresponding to each channel, mapping the response amplitude of each channel to a unified numerical range, thereby eliminating the difference in response amplitude between different channels. Then, by using a preset threshold or a threshold determined by the channel activation distribution, the normalized feature maps of each channel are converted into binary activation maps, which clearly defines the location of the activation region of each channel. This makes the criteria for determining the effective activation location uniform and comparable across channels, so that subsequent box-scale grid division and occupancy box number statistics can objectively reflect the independent spatial distribution complexity of each channel, avoiding the interference of channel response amplitude differences on spatial occupancy statistics.
[0089] Reference Figure 4 , Figure 4 This is a flowchart illustrating the third embodiment of the disease category identification method of this application. Based on the above embodiments, a third embodiment of the disease category identification method of this application is proposed.
[0090] In the third embodiment, step S50 includes: Step S501: Arrange the space complexity parameters corresponding to each channel into a space complexity vector according to the channel order.
[0091] In the specific implementation, the space complexity parameters of each channel are extracted sequentially according to the channel index from 1 to C. The space complexity parameter of the first channel is taken as the first element of the space complexity vector, the space complexity parameter of the second channel is taken as the second element of the space complexity vector, and so on, until the space complexity parameter of the Cth channel is taken as the Cth element of the space complexity vector. The space complexity parameters of all channels are arranged and combined in sequence to form a C-dimensional space complexity vector.
[0092] Step S502: Fuse the semantic feature vector and the space complexity vector according to the feature dimension to obtain the fused feature.
[0093] In the specific implementation, the semantic feature vector and the space complexity vector are concatenated end to end along the feature dimension. That is, all elements of the semantic feature vector are used as the first half of the fused feature, and all elements of the space complexity vector are used as the second half of the fused feature. The concatenation results in the fused feature, and the dimension of the fused feature is equal to the sum of the dimensions of the semantic feature vector and the space complexity vector.
[0094] Furthermore, in order to achieve the effect of nonlinear mapping and compact encoding of high-dimensional fusion features, the step of determining the disease category of the leaf image based on the fusion features includes: inputting the fusion features into a classifier to obtain the score of each disease category; performing probability normalization on the scores of each disease category to obtain the probability of each disease category; and selecting the disease category corresponding to the highest probability among the probabilities of each disease category as the recognition result.
[0095] In the specific implementation, the obtained fused features are input into the classifier. The fused features first undergo a linear transformation through the classifier's first fully connected layer, mapping the fused features from the fused feature dimension to an intermediate dimension, outputting intermediate features. The intermediate features then undergo a non-linear transformation through an activation layer to enhance the classifier's expressive power, outputting activated features. The activated features then pass through a random deactivation layer. During the training phase, some feature values are randomly discarded with a preset probability to suppress overfitting; during the inference phase, all feature values remain unchanged but are scaled proportionally, outputting deactivated features. The deactivated features then undergo a linear transformation through a second fully connected layer, mapping the intermediate dimension to the total number of categories, outputting the score for each disease category. After the classifier outputs the scores for each disease category, the disease category identification device performs probability normalization on the scores of each disease category. That is, the scores of each disease category are input into a Softmax function, which performs exponential operations and normalization on each score, outputting the probability of each disease category. The probability value of each disease category represents the confidence level of the classifier in determining that the input leaf image belongs to the corresponding disease category. The disease category identification device selects the disease category with the highest probability from the probabilities of each disease category and outputs the disease category corresponding to the highest probability as the identification result. For ease of understanding, the following example illustrates this, but does not limit the specific implementation of this embodiment. For instance, if the total number of disease categories is 10, the score vector of each disease category output by the classifier is (2.3, 1.5, 0.2, -0.8, 0.9, -1.2, 0.5, -0.3, 1.8, -0.5). After Softmax probability normalization, the probability vector of each disease category is (0.25, 0.12, 0.03, 0.01, 0.06, 0.01, 0.04, 0.02, 0.15, 0.01). The first category has the highest probability of 0.25, so the first disease category is selected as the identification result, and the output shows that the leaf image belongs to the first disease category.
[0096] Furthermore, in order to achieve the effect of nonlinear mapping and compact encoding of high-dimensional fusion features, after the step of selecting the disease category corresponding to the highest probability among the probabilities of each disease category as the identification result, the method further includes: determining whether the highest probability is greater than a preset confidence threshold; if the highest probability is greater than or equal to the preset confidence threshold, outputting the disease category and confidence level corresponding to the highest probability; if the highest probability is less than the preset confidence threshold, outputting an unknown category or a low confidence result.
[0097] It should be understood that the pre-set reliability threshold refers to the probability threshold value set in advance to determine whether the classification result is reliable.
[0098] It should be understood that confidence level is a quantitative measure of the reliability of the classifier's recognition results.
[0099] In the specific implementation, after selecting the highest probability, a preset confidence threshold is obtained, and the highest probability is compared with the preset confidence threshold. If the highest probability is greater than or equal to the preset confidence threshold, the current classification result is determined to be reliable, and the disease category corresponding to the highest probability is output as the recognition result. Simultaneously, the value of the highest probability is also output as the confidence level, with the output format being "Disease Category + Confidence Level". If the highest probability is less than the preset confidence threshold, the current classification result is determined to be unreliable, and an unknown category or low confidence result is output. When using the unknown category output method, "Unknown Category" is output to indicate that the classifier cannot recognize the current leaf image; when using the low confidence result output method, the disease category corresponding to the highest probability and the highest probability value are output, and a prompt message such as "Insufficient confidence, result for reference only" is marked in the output information. For example, the preset confidence threshold is preferably 0.5, that is, when the highest probability is greater than or equal to 0.5, the disease category and confidence level are output; when the highest probability is less than 0.5, the unknown category is output.
[0100] This embodiment achieves vector-level integration of semantic features and spatial complexity features by fusing semantic feature vectors and spatial complexity vectors according to feature dimensions. This enables the simultaneous acquisition of response intensity information (how strong each channel is activated) and spatial morphology information (how dispersed each channel is activated) at the input level.
[0101] For ease of understanding, the following references Figure 5 For example, among which Figure 5This is a schematic diagram of the overall process of a lightweight litchi leaf disease identification method, but it is not limited to this application. As an example, assume that a litchi leaf image is acquired and the image is resized (e.g., scaled from a 1920×1080 pixel original image to 224×224 pixels), format converted (e.g., the image channel order is adjusted to the same RGB order as when the feature extraction network was pre-trained), and normalized (the pixel values are mapped from [0, 255] to the [0, 1] interval and standardized by mean and standard deviation) to obtain an input tensor; the input tensor is fed into a lightweight feature extraction network (e.g., MobileNetV3-Small), and after multiple convolution operations, a high-level feature map with shape [1, 576, 7, 7] is obtained. The high-level feature map is simultaneously fed into two parallel branches. Specifically, in the first branch, global average pooling is performed on the high-level feature map. The arithmetic mean of all feature values for each channel is calculated in the spatial dimension, resulting in 576 global average response values, which are then combined into a semantic feature vector G. This vector records the overall response intensity of each channel. In the second branch, intra-channel normalization and thresholding are performed on each channel of the high-level feature map to obtain a binary activation map. Then, multiple box scales (e.g., k=1, 2, 4) are used to perform non-overlapping mesh partitioning on the binary activation maps of each channel. The number of local boxes containing activation positions at each box scale is counted as the number of occupied boxes. The spatial complexity parameter of each channel is determined based on the relationship between each box scale and the corresponding number of occupied boxes (e.g., through the slope of log-linear regression). The spatial complexity parameters of all channels are then grouped in channel order. The spatial complexity vector D is combined to record the spatial distribution complexity of the activation regions of each channel. The semantic feature vector G and the spatial complexity vector D are concatenated along the feature dimension to obtain the fusion feature Z=[G;D]. The fusion feature contains both the response intensity information and spatial distribution morphology information of each channel. The fusion feature is input into the classifier, and after processing through the first fully connected layer, activation layer, random deactivation layer and the second fully connected layer, the scores Logits of each disease category are output. Softmax probability normalization is performed on the Logits to obtain the probability of each disease category. The disease category corresponding to the highest probability is selected as the preliminary identification result. If the highest probability is greater than or equal to the preset confidence threshold (e.g., 0.5), the disease category and confidence are output. If it is less than the threshold, the unknown category or low confidence result is output.
[0102] The above examples also include the conversion from trained models to K230 edge executable models, see reference. Figure 6 Provide an explanation, among which Figure 6This is a flowchart illustrating the conversion from the trained model to a K230 edge executable model. A publicly available litchi leaf disease dataset was used, containing 3768 high-quality images divided into 10 categories. Data collection covered different locations, lighting conditions, and complex backgrounds. To simulate insufficient expert-annotated samples in agricultural scenarios, 20% of the images were used as training data, with the remainder for evaluation; additionally, 10% and 40% training ratios were set for low-data-volume analysis. The dataset labels are shown in the table below:
[0103] The training platform included an Intel i7-12700H processor, 32 GB of RAM, and an RTX 2080Ti graphics card, with PyTorch 2.1 as the software environment. Input images were uniformly adjusted to 224×224 and enhanced with random flipping, etc.; the batch size was 4; the optimizer was Adam, with β1 and β2 values of 0.9 and 0.999, respectively; the initial learning rate was 1×10⁻⁶. - ³, and reduced to 1×10 using cosine annealing. -5 The total number of training rounds is 200; the backbone network is not frozen; the loss function is cross-entropy; the backbone is preferably loaded with ImageNet pre-trained weights.
[0104] The lightweight feature extraction network uses MobileNetV3-Small. The network consists of an initial 3×3 stride 2-channel convolution, 11 inverse residual blocks, and terminal 1×1 convolutions. The inverse residual blocks include optional 1×1 extended convolutions, depthwise convolutions, optional compression activation modules, 1×1 projective convolutions, and residual connections enabled when size and channels are consistent. The network uses ReLU or Hardswish activation. The number of terminal high-level feature channels is 576 in this embodiment.
[0105] The original MobileNetV3 classification head has been replaced by the Hybrid Fractal Head. This head includes: an adaptive global average pooling branch, a FractalPooling2D branch, and a two-layer classifier. The FractalPooling2D has a box scale set of {1, 2, 4}, an activation threshold of 0.5, and a stability constant of 10. -6 The GAP outputs a 576-dimensional vector, the complexity branch outputs a 576-dimensional vector, and the two are concatenated to form a 1152-dimensional fused feature. The first fully connected layer maps to 1024 dimensions, and then passes through Hardswish and Dropout (p=0.2). The second fully connected layer outputs a 10-dimensional category score.
[0106] For feature map edges that are not divisible by the box scale, this embodiment clips the height and width to integer multiples of the corresponding box scale. After rearranging the binary image to [B, C, H / k, k, W / k, k], maximum reduction is performed within the boxes, and N(k) is obtained by summing over all boxes. Then, log(1 / k) and log(N(k)+ε) are calculated, and the slope of each channel is obtained using the closed least squares formula.
[0107] The input image undergoes high-level feature extraction via a lightweight backbone, then simultaneously enters both the GAP branch and the channel-level box counting complexity branch; the fused features are then used by a classifier to output class scores. Supervised training employs cross-entropy loss.
[0108] in, B is the cross-entropy loss for mini-batch classification; B is the batch size. The true class label for the b-th sample; The model is assigned the predicted probability of the true class. During training, the backbone network parameters and classifier head parameters are updated by minimizing this loss. The GAP branch represents the overall response intensity of the channel, and the box counting complexity branch represents the cross-scale occupancy and spatial fragmentation of the activation region; the two are complementary. The model parameters are optimized by minimizing the aforementioned cross-entropy loss, with optimization variables including the backbone network parameters and the fused classifier head parameters. The thresholding and box occupancy rules in the current implementation use preset parameters; regarding the differentiability of the hard threshold and the optional continuous approximation scheme, during training, the image outputs high-level features F through the backbone network. The GAP branch outputs g, the box counting branch outputs d, and the two are concatenated to form z, which is then output through the classifier. The cross-entropy loss is calculated and the trainable parameters are updated. The current implementation of binary thresholding is a hard comparison, and the threshold and box scale themselves are not used as trainable parameters. The backbone network can still obtain gradients through the GAP branch and subsequent classification loss, and the fusion classifier learns based on the two types of features. During offline ONNX testing, the input image can be centrally cropped, scaled to 224×224, BGR converted to RGB, divided by 255, and standardized according to the three-channel mean [0.485, 0.456, 0.406] and standard deviation [0.229, 0.224, 0.225] before being converted to NCHW. The edge implementation uses AI2D to directly scale video frames. To reduce the distribution differences between training, offline testing, and edge inference, the official product should uniformly use either central cropping or direct scaling. Subsequently, the model conversion script reads the ONNX model and parses the input nodes, performs shape inference based on the fixed input shape [1, 3, 224, 224], and then uses onnxsim to simplify the graph and verify the simplification results. The nncase compilation options are set to target platform k230, input type uint8, input range [0, 1], layout NCHW, quantization type uint8, and configured with mean and standard deviation consistent with training.
[0109] Representative calibration samples are set during the post-training quantization phase. The current code uses 20 samples_count; the paper's implementation example uses a larger calibration set covering 10 classes. It is recommended that the actual number of calibration samples, class distribution, and quantization method used be recorded during formal implementation, and that the measured accuracy be used as the benchmark. The compiler supports calibration methods such as NoClip or KLD, as well as different weight and activation combinations of uint8 / int16.
[0110] After conversion, the float32 input binary required by ONNX and the uint8 input binary required by KMODEL can be saved respectively. The ONNX Runtime and nncase Simulator can be used to perform inference on the same input and calculate the output cosine similarity to verify the consistency of the model conversion.
[0111] Additionally, the above examples also include a CanMV K230 edge recognition system, see reference. Figure 7The following describes the edge system. Specifically, it may include a camera sensor, a CanMV K230 development board, a memory card, a display screen, or an HDMI display device. The K230 runs the MicroPython / CanMV framework, and model files are stored, for example, in " / sdcard / best_cpu.kmodel". The system can be configured for a 3.5-inch screen with resolutions of 800×480, a 2.4-inch screen with resolutions of 640×480, or an HDMI output of 1920×1080. The camera frame format is RGB888, and AI2D adjusts the input to 224×224 using a bilinear half-pixel method and constructs an NCHW uint8 tensor. The inference program loads 10 class labels and a 0.5 confidence threshold, repeatedly acquires video frames, and calls the model inference interface to obtain class logits. Post-processing converts the output into a Python list, uses a Softmax algorithm to calculate probabilities by subtracting the maximum value; if the maximum probability is higher than the threshold, the corresponding class and score are output; otherwise, "Unknown" is output. The OSD layer displays "result, score" and real-time FPS, and then outputs to an LCD or HDMI. Garbage collection is performed within the loop, and the display and memory bus load can be reduced by limiting the refresh rate. Based on this system, the quantization model accuracy can reach 96.95%, with an inference latency of approximately 62.5 ms / frame and approximately 16 FPS. The system can further transmit the recognition results to the orchard management platform via serial port, Ethernet, Wi-Fi, or cellular network, and can be connected to audible and visual warning or spraying decision modules.
[0112] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the disease category identification method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.
[0113] This application also provides a disease category identification device, please refer to... Figure 8 The disease category identification device includes: The feature map extraction module 10 is used to input the preprocessed leaf image into the feature extraction network to obtain a high-level feature map containing multiple channels. The semantic feature extraction module 20 is used to perform global statistics on the high-level feature map to obtain a semantic feature vector; The partitioning module 30 is used to partition the feature map corresponding to each channel in the high-level feature map into a grid using multiple box scales, so as to obtain the partitioned feature map corresponding to each channel. The box scale is the side length of each box when partitioning the grid in the box counting method. The statistics module 40 is used to count the number of occupied boxes in the feature map after partitioning for each channel at each box scale. The occupied box is a local box that meets a preset condition, and the local box is a grid in the feature map after partitioning. The space complexity determination module 50 is used to determine the space complexity parameters corresponding to each channel in the high-level feature map based on the relationship between the box size and the number of occupied boxes. The fusion module 60 is used to obtain fused features based on the semantic features and the spatial complexity parameters corresponding to each channel; The result output module 70 is used to determine the disease category of the leaf image based on the fusion features.
[0114] The disease category identification device provided in this application, employing the disease category identification method in the above embodiments, can solve the technical problem of simultaneously meeting the requirements for accurate identification of fine-grained diseases and lightweight deployment on low-cost edge devices. Compared with the prior art, the beneficial effects of the disease category identification device provided in this application are the same as those of the disease category identification method provided in the above embodiments, and other technical features in the disease category identification device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0115] This application provides a disease category identification device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the disease category identification method in the above embodiment 1.
[0116] The following is for reference. Figure 9 The diagram illustrates a structural schematic suitable for implementing the disease category identification device in the embodiments of this application. The disease category identification device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 9 The disease category identification device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0117] like Figure 9As shown, the disease category identification device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in ROM (Read Only Memory) 1002 or a program loaded from storage device 1003 into RAM (Random Access Memory) 1004. RAM 1004 also stores various programs and data required for the operation of the disease category identification device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via bus 1005. Input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, LCDs (Liquid Crystal Displays), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the disease classification identification device to communicate wirelessly or wiredly with other devices to exchange data. Although disease classification identification devices with various systems are shown in the figures, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented alternatively.
[0118] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0119] The disease category identification device provided in this application, employing the disease category identification method in the above embodiments, can solve the technical problem of simultaneously meeting the requirements for accurate identification of fine-grained diseases and lightweight deployment on low-cost edge devices. Compared with the prior art, the beneficial effects of the disease category identification device provided in this application are the same as those of the disease category identification method provided in the above embodiments, and other technical features in this disease category identification device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0120] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0121] 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.
[0122] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the disease category identification method in the above embodiments.
[0123] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, RAM (Random Access Memory), ROM (Read Only Memory), EPROM (Erasable Programmable Read Only Memory), or flash memory, optical fiber, CD-ROM (CD-Read Only Memory), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0124] The aforementioned computer-readable storage medium may be included in the disease category identification device; or it may exist independently and not assembled into the disease category identification device.
[0125] The aforementioned computer-readable storage medium carries one or more programs, which, when executed by the disease category identification device, cause the disease category identification device to perform the aforementioned disease category identification method.
[0126] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including LAN (Local Area Network) or WAN (Wide Area Network)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0127] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0128] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0129] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described disease category identification method. This solves the technical problem of simultaneously meeting the requirements for accurate identification of fine-grained diseases and lightweight deployment on low-cost edge devices. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the disease category identification method provided in the above embodiments, and will not be repeated here.
[0130] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the disease category identification method as described above.
[0131] The computer program product provided in this application solves the technical problem of simultaneously meeting the requirements for accurate identification of fine-grained diseases and lightweight deployment on low-cost edge devices. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the disease category identification method provided in the above embodiments, and will not be repeated here.
[0132] The above description is only a part of the embodiments of this application and does not limit the scope of this application. All equivalent structural transformations made under the technical concept of this application and using the content of this application specification and drawings, or direct / indirect applications in other related technical fields, are included within the protection scope of this application.
[0133] It should be noted that the data collection, tag management, rule setting, and push decision-making processes involved in this application are designed to work with other technical features to solve technical problems. They do not involve or support any illegal activities. Any data processing that may violate laws and regulations (such as unauthorized collection of privacy data, generation of discriminatory tags, setting unfair rules, or pushing illegal information) is not within the scope of protection of this application's technical solution. Of course, the user data in this application will be encrypted, anonymized, or de-identified before storage to ensure user data security.
Claims
1. A method for identifying disease categories, characterized in that, The disease category identification method includes: The preprocessed blade image is input into the feature extraction network to obtain a high-level feature map containing multiple channels; Global statistics are performed on the high-level feature map to obtain semantic feature vectors; Multiple box scales are used to divide the feature map corresponding to each channel in the high-level feature map into a grid, resulting in the divided feature map corresponding to each channel. The box scale is the side length of each box when dividing the grid in the box counting method. The number of occupied boxes in the feature map after partitioning for each channel at each box scale is counted. The occupied box is a local box that meets a preset condition. The local box is a grid in the feature map after partitioning. The spatial complexity parameters corresponding to each channel in the high-level feature map are determined based on the relationship between the box size and the number of occupied boxes. Based on the semantic feature vector and the space complexity parameters corresponding to each channel, the fusion feature is obtained; The disease category of the leaf image is determined based on the fusion features.
2. The disease category identification method as described in claim 1, characterized in that, The step of dividing the feature map corresponding to each channel in the high-level feature map into a mesh using multiple box scales to obtain the divided feature map corresponding to each channel, wherein the box scale is the side length of each box when dividing the mesh in the box counting method, includes: Perform intra-channel normalization processing on the feature maps corresponding to each channel in the high-level feature map to obtain normalized feature maps for each channel; Based on a preset threshold, the normalized feature maps of each channel are converted into binary activation maps; Based on the aforementioned box scales, the binary activation map is divided into multiple non-overlapping local boxes, which serve as the segmented feature maps for each channel.
3. The disease category identification method as described in claim 2, characterized in that, The step of dividing the binary activation map into multiple non-overlapping local boxes based on the box scales, as the segmented feature maps corresponding to each channel, includes: The multiple box scales are traversed, and the traversed box scale is taken as the current box scale; If the spatial size of the binary activation map is not divisible by the current box scale, the spatial size of the binary activation map is adjusted until the adjusted spatial size is divisible by the current box scale. Based on the current box scale, the adjusted binary activation map is divided into multiple non-overlapping local boxes; After the traversal is completed, the segmented feature map corresponding to each channel is determined based on the multiple non-overlapping local boxes.
4. The disease category identification method according to any one of claims 1 to 3, characterized in that, The step of calculating the number of occupied boxes in the segmented feature map corresponding to each channel at each box scale, wherein the occupied box is a local box that meets preset conditions, and the local box is a grid in the segmented feature map, includes: The maximum value reduction is performed on the feature maps corresponding to each channel after partitioning to obtain the maximum value reduction result; Based on the result of the maximum value reduction, it is determined whether there are active positions in the local boxes of the feature maps after the division of each channel; If an activation location exists, count the number of local boxes with activation locations, and use this count as the number of occupied boxes at each box scale.
5. The disease category identification method as described in claim 1, characterized in that, The step of performing global statistics on the high-level feature map to obtain semantic feature vectors includes: Global average pooling is performed on each channel of the high-level feature map to obtain the global average response value of each channel; The global average response values of each channel are combined in channel order to obtain a semantic feature vector.
6. The disease category identification method as described in claim 1, characterized in that, The step of obtaining the fused features based on the semantic feature vector and the space complexity parameters corresponding to each channel includes: The space complexity parameters corresponding to each channel are arranged into a space complexity vector in channel order; The semantic feature vector and the space complexity vector are fused according to the feature dimension to obtain the fused feature.
7. The disease category identification method as described in claim 1, characterized in that, The step of determining the disease category of the leaf image based on the fusion features includes: The fused features are input into the classifier to obtain scores for each disease category; The scores for each disease category are normalized to obtain the probability of each disease category; The disease category with the highest probability among the probabilities of each disease category is selected as the identification result.
8. The disease category identification method as described in claim 7, characterized in that, After the step of selecting the disease category with the highest probability among the probabilities of each disease category as the identification result, the method further includes: Determine whether the maximum probability is greater than a preset confidence threshold; If the maximum probability is greater than or equal to a preset confidence threshold, output the disease category and confidence level corresponding to the maximum probability; If the maximum probability is less than the preset confidence threshold, output an unknown category or a low confidence result.
9. A disease category identification device, characterized in that, The disease category identification device includes: The feature map extraction module is used to input the preprocessed leaf image into the feature extraction network to obtain a high-level feature map containing multiple channels; The semantic feature extraction module is used to perform global statistics on the high-level feature map to obtain semantic feature vectors. The partitioning module is used to partition the feature map corresponding to each channel in the high-level feature map into a grid using multiple box scales, so as to obtain the partitioned feature map corresponding to each channel. The box scale is the side length of each box when partitioning the grid in the box counting method. The statistics module is used to count the number of occupied boxes in the feature map of each channel corresponding to each box scale. The occupied box is a local box that meets a preset condition. The local box is a grid in the feature map after partitioning. The space complexity determination module is used to determine the space complexity parameters corresponding to each channel in the high-level feature map based on the relationship between the box size and the number of occupied boxes. The fusion module is used to obtain fused features based on the semantic features and the space complexity parameters corresponding to each channel; The result output module is used to determine the disease category of the leaf image based on the fusion features.
10. A disease category identification device, characterized in that, The disease category identification device includes: a memory, a processor, and a disease category identification program stored in the memory and executable on the processor. When the disease category identification program is executed by the processor, it implements the disease category identification method as described in any one of claims 1 to 8.
