Intelligent wheatgrass spike counting method based on self-supervised Transform and multi-scale expansion convolution
By employing a self-supervised Transformer and multi-scale dilated convolution method, combined with the DINO backbone network and a multi-granularity gated fusion module, high-precision, low-cost, and real-time intelligent counting of icegrass spikes was achieved, solving the problems of low efficiency, high annotation requirements, and limited receptive field in existing technologies.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-04
- Publication Date
- 2026-03-10
AI Technical Summary
Existing icegrass ear counting technologies suffer from low efficiency due to manual counting, high labeling costs, high model complexity, and limited receptive field, making it difficult to achieve real-time and accurate ear counts on resource-constrained agricultural edge devices.
A self-supervised Transformer and multi-scale dilated convolution method is adopted to extract high-dimensional feature maps through the DINO backbone network, and combined with a multi-granularity gating fusion module and a lightweight regression head to achieve intelligent counting of icegrass spikes.
Under weak supervision, it achieves higher accuracy in ear count (MAE=2.2), lower annotation cost (single icon annotation time <1 minute) and stronger edge deployment capability (inference latency <20ms), solving the problems of insufficient long-range dependency modeling and high model complexity in traditional methods.
Smart Images

Figure CN121640433A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of agricultural image recognition technology, specifically to an intelligent counting method for icegrass spikes based on self-supervised Transformer and multi-scale dilated convolution. Background Technology
[0002] With the rapid development of smart agriculture and high-throughput phenotyping technologies, the automatic counting of key crop organs (such as ears, flowers, and fruits) has become a core element in accelerating the breeding process and improving field management efficiency. As an important perennial high-quality forage grass in northern my country, the number of ears per unit area of ice grass (Agropyron cristatum) is directly related to dry matter yield and seed propagation potential, making it a core agronomic trait in variety selection. Traditional methods relying on manual visual inspection or grid sampling for counting are not only labor-intensive and time-consuming but also significantly influenced by subjective judgment, making it difficult to support the data requirements of modern breeding, which involve "thousands of materials and tens of thousands of replicates."
[0003] In recent years, deep learning-based computer vision methods have been widely introduced into agricultural phenotypic analysis. The mainstream technical approaches can be divided into two categories: instance-level supervised methods and image-level supervised methods. The former locates each target through bounding boxes (such as Faster R-CNN) or point annotations, and then counts the number. While this method offers high accuracy, the annotation cost is extremely high (5–8 minutes per image), making it almost impractical in dense canopy scenes such as ice grass. The latter method only requires a total count label for each image (i.e., weak supervision), significantly reducing the manual burden and becoming the preferred approach for large-scale field deployment.
[0004] However, existing image-level supervision methods mostly use traditional convolutional neural network (CNN) architectures (such as VGG and ResNet). Due to the limited local receptive field characteristics of convolutional operations, they struggle to model the long-range spatial dependencies between sparse spikelets at the edges and dense spikelets in the center of the ice grass canopy, leading to systematic underestimation in high-density areas. Although some studies have attempted to introduce Vision Transformer (ViT) or MLP-Mixer to achieve global modeling, these models typically employ single-scale interactions, lack adaptive perception capabilities for different density regions, and have a large number of parameters, making them difficult to deploy on resource-constrained edge devices.
[0005] The most traditional existing technology is CSNet, proposed by Li et al. in their 2024 paper "CSNet: A Count-Supervised Network via Multiscale MLP-Mixer for Wheat Ear Counting" published in the journal *Plant Phenomics* (DOI:10.34133 / plantphenomics.0236). This work was the first to systematically introduce pure image-level supervision (i.e., using only the total number of ears per image as a label, without any location information such as bounding boxes, points, or density maps) into the wheat ear counting task, significantly reducing the cost of data annotation.
[0006] The overall process of CSNet is as follows: Backbone: The first 10 layers of VGG16 (including 3 max pooling layers) are used as the basic feature extractor and pre-trained on ImageNet; Convolutional Block Attention Module (CBAM): A dual channel and spatial attention mechanism is introduced after the backbone output to suppress background interference such as weeds and soil; Multi-Scale Perception Module (MPM): The feature map output by CBAM is divided into patches of three scales: 16×16, 8×8 and 4×4. The global token relationship is modeled in each scale through the MLP-Mixer structure, and the three scale features are then concatenated and fused through a unified Mixer layer; Counting Module (CM): It consists of two fully connected layers and one average pooling layer, which directly regresses the number of ears in the whole image.
[0007] CSNet achieved an MAE of 2.94 on the GWHD_2020 dataset, significantly outperforming earlier CNN methods. However, it still has significant limitations: High model complexity: Although it does not use Transformer, its multi-scale MLP-Mixer structure results in a parameter count as high as 101.3M. Inference with 512×512 input requires a large amount of GPU memory and cannot run smoothly on Jetson Xavier; Limited receptive field: Although VGG16 expands the receptive field through stacked convolutions, it is still a local operation and cannot explicitly model the semantic associations between distant spikelets. The missed count rate increases significantly in denser and more morphologically complex canopies such as icegrass; High inference latency: The inference time is high, far exceeding the <20ms requirement for real-time field operations.
[0008] While CSNet has made progress in weakly supervised counting, its architecture has failed to effectively integrate the three key elements of strong semantic representation, multi-scale adaptation, and edge lightweighting, which is precisely the technological gap that this invention aims to fill.
[0009] In summary, existing icegrass spike counting technologies face three core challenges:
[0010] (1) Manual counting is inefficient and highly subjective: The traditional method of relying on manual visual counting is time-consuming and laborious (a single plot of 2m*2m takes more than 15 minutes on average), and is easily affected by factors such as fatigue and experience differences. Repeatability and accuracy are difficult to guarantee, and cannot meet the needs of modern breeding for high-throughput phenotypic data.
[0011] (2) There is a contradiction between supervision granularity and deployment cost. Although instance-level supervision methods (such as bounding boxes or point annotations) have high accuracy, the annotation cost is extremely high (5-8 minutes / image), which is not suitable for large-scale field applications. On the other hand, existing image-level supervision methods (such as CSNet) reduce the annotation cost, but due to the complex model structure and large number of parameters, the memory usage is high and the inference speed is slow at 512×512 resolution, making it difficult to achieve real-time operation on agricultural edge computing devices such as Jetson Nano / Xavier.
[0012] (3) Traditional CNN architectures have rigid constraints on receptive fields. CNNs, such as VGG16, have difficulty modeling long-range associations in their local receptive fields. On the other hand, using standard global models such as ViT or MLP-Mixer directly results in insufficient robustness in counting because of the fixed-scale interaction mechanism, which cannot adaptively distinguish the differentiated contextual requirements between sparse edge spikes and highly overlapping central spikes in the ice grass canopy.
[0013] Against this backdrop, there is an urgent need for a novel counting architecture that can acquire strong generalized representations using self-supervised learning, adaptively model complex canopy structures through multi-scale mechanisms, and simultaneously meet the requirements of edge computing efficiency. Summary of the Invention
[0014] The purpose of this invention is to address the shortcomings of existing technologies in accurately counting icegrass spikes by providing an intelligent counting method for icegrass spikes based on self-supervised Transformer and multi-scale dilated convolution.
[0015] To achieve the above objectives, the technical solution of the present invention is as follows:
[0016] A smart counting method for icegrass spikes based on self-supervised Transformer and multi-scale dilated convolution includes the following steps:
[0017] Image acquisition and preprocessing;
[0018] Set up the DINO backbone network and extract high-dimensional feature maps;
[0019] Configure a multi-granularity gating fusion module;
[0020] Set up a lightweight regression head and output the counting results.
[0021] The image acquisition and preprocessing steps are as follows: use an RGB camera to take pictures of a 2m×2m area of ice grass plot at a height of 1.2 meters above the ground and from a vertical top-down angle to obtain the original RGB image; then crop and scale it to 512×512 pixels, and normalize the pixel values to the [0,1] range.
[0022] The process of setting up the DINO backbone network and extracting high-dimensional feature maps includes the following steps:
[0023] Configure the DINO backbone network;
[0024] The preprocessed images are fed into the DINO backbone network for training. During the training phase, Self-Distillation Loss is introduced to perform knowledge distillation, enabling the student network to learn global context representations under the guidance of the teacher network, thereby enhancing its ability to represent complex canopy structures. Finally, a high-dimensional feature map with dimensions H×W×C is output, where H and W are the spatial dimensions of the feature map, and C is the number of channels.
[0025] The setting of the multi-granularity gating fusion module includes the following steps:
[0026] Parallel dilated convolution branch processing:
[0027] The high-dimensional feature map of H×W×C is fed into three independent 1×1 convolutional layers to compress the channels to 128 dimensions, and then fed into 3×3 dilated convolutional layers with dilation rates of 1, 3 and 5 respectively to generate three sets of feature maps with different receptive fields: dilation rate 1: captures local details, dilation rate 3: models medium-range correlations; dilation rate 5: perceives large-range context.
[0028] Global pooling and concatenation:
[0029] For each feature map obtained after dilated convolution, global average pooling is applied to average the feature values at each spatial location, thereby converting each feature map into a spatially independent 128-dimensional vector. These three 128-dimensional vectors processed by GAP are then concatenated to form a 384-dimensional joint representation vector.
[0030] Shared gate weight generation and weighted fusion:
[0031] A shared, lightweight gated network containing 1×1 convolutions, ReLU, and Softmax is used to generate normalized weights that satisfy... + + =1;
[0032] in, , , These are all normalized weights generated by the gating network; they reflect the importance of feature maps under different receptive fields, ensuring the final fused feature vector. Adaptively emphasize the most relevant scale information;
[0033] The original three feature vectors after GAP processing are weighted and summed using normalized weights to obtain the final fused feature vector F. fuse The formula is:
[0034] ,
[0035] in, , , These are 128-dimensional vectors obtained by GAP processing of feature maps with dilation rates of 1, 3, and 5, respectively.
[0036] Setting up the lightweight regression head and outputting the counting results includes the following steps:
[0037] Channel compression layer processing:
[0038] The fused feature map Ffuse obtained through the multi-granularity gated fusion module is input into a 1×1 convolutional layer. This convolutional layer is used to reduce the number of channels in the feature map, compressing it from 128 dimensions to 64 dimensions.
[0039] Global average pooling operation:
[0040] For the 64-dimensional feature map after channel compression, global average pooling is applied. This operation averages the values of each feature map in the spatial dimension and converts it into a 64-dimensional vector that is independent of spatial location.
[0041] Linear prediction layer output:
[0042] The 64-dimensional feature map is input into a fully connected layer, namely the linear prediction layer, which consists of a 64->1 linear transformation and outputs a scalar value representing the total number of predicted icegrass spikes.
[0043] The DINO backbone network is configured to consist of multiple Transformer Encoders, each layer including a self-attention mechanism and a feedforward network; the steps include:
[0044] Image segmentation and embedding:
[0045] The input 512×512 pixel RGB image is divided into 256 non-overlapping 32×32 pixel blocks; each block is mapped to a 768-dimensional embedding vector through linear projection; a learnable positional code is added to each embedding vector to preserve the spatial location information of the image. The resulting sequence of 256 768-dimensional embedding vectors is then used as input to the TransformerEncoder.
[0046] Transformer Encoder stack:
[0047] The DINO backbone network consists of 12 standard Transformer Encoder layers, each of which comprises two parts:
[0048] Multi-head self-attention mechanism: Performs self-attention computation on the input embedding vector sequence to generate a new representation and capture the dependencies between different positions;
[0049] Feedforward network: The embedding vector at each position passes through a two-layer fully connected network. The first layer expands the dimension, and the second layer restores the original dimension, processing and transforming the feature representation.
[0050] Self-distillation training mechanism:
[0051] A momentum-updated teacher network is set up, whose parameters are updated from the student network via an exponential moving average; the student network receives the input image during training and outputs logits; the teacher network receives the same input image and outputs its own logits; the student network learns a global context representation under the guidance of the teacher network by minimizing the cross-entropy loss between the output logits of the student network and the teacher network.
[0052] Feature map output:
[0053] After processing by 12 Transformer Encoders, the output feature map of the last Encoder is taken; this feature map is then reshaped into a 32×32×768 high-dimensional feature map; this high-dimensional feature map contains rich semantic information and effectively represents the morphological features of the icegrass spike, serving as the input to the multi-granularity gated fusion module.
[0054] A computer-readable storage medium storing a computer program that, when executed by a processor, enables an intelligent counting method for icegrass spikes based on self-supervised Transformer and multi-scale dilated convolution.
[0055] A computer device is characterized by comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it can realize an intelligent counting method for ice grass spikes based on self-supervised Transformer and multi-scale dilated convolution.
[0056] Beneficial effects
[0057] The intelligent counting method for icegrass spikes based on self-supervised Transformer and multi-scale dilated convolution of the present invention achieves higher accuracy (MAE=2.2), lower annotation cost (single icon annotation time <1 minute) and stronger edge deployment capability (inference latency <20ms) under weak supervision with only image-level labels compared with the prior art. It effectively solves the core problems of traditional methods such as insufficient long-range dependency modeling, high model complexity and poor field robustness.
[0058] First, regarding feature representation capabilities, this invention employs the DINO backbone network as the feature extractor. Through a self-supervised pre-training mechanism, DINO can learn highly robust global semantic features to changes in ice plant morphology without manual annotation. This strong generalization capability enables the model to exhibit higher stability and accuracy when facing challenges such as complex canopy structures, lighting variations, and cluttered backgrounds, thus solving the problem of insufficient long-range spatial correlation modeling caused by the limitation of local receptive fields in traditional CNN architectures. In contrast, existing technologies such as CSNet rely on traditional CNN architectures such as VGG16, whose fixed local receptive fields make it difficult to effectively capture the long-range dependencies between sparsely distributed edge spikelets and highly overlapping central dense spikelets, easily leading to missed or incorrect counts in high-density areas.
[0059] Secondly, this invention designs an innovative multi-granularity gating fusion module, utilizing convolution operations with different dilation rates to achieve dynamic multi-scale perception. This design can automatically adjust the receptive field size according to the local density of the image, thereby more accurately capturing texture and structural information at different scales. The shared, lightweight gating network generates normalized weights, ensuring effective fusion of features at various scales and further enhancing the model's responsiveness to dense and sparse regions. Furthermore, the minimally designed lightweight regression head not only has a low parameter count (<50M), ensuring efficient operation on resource-constrained agricultural edge computing devices, but also achieves an end-to-end inference latency of less than 20ms. This solves the problem of high memory consumption and slow inference speed caused by excessive model complexity in existing methods, enabling this invention to meet real-time requirements while satisfying high-precision counting. In summary, this invention, through a series of innovative designs, successfully achieves high-throughput, low-power, edge-deployable intelligent counting of icegrass spikes, providing strong technical support for complex forage phenotypic analysis. Attached Figure Description
[0060] Figure 1 This is a sequence diagram of the method of the present invention;
[0061] Figure 2 This is a system framework diagram of the present invention;
[0062] Figure 3 This is a structural diagram of the multi-granularity gating fusion module involved in the present invention;
[0063] Figure 4 This is a diagram illustrating the actual effect of the invention. Detailed Implementation
[0064] To provide a better understanding of the structural features and effects achieved by the present invention, a detailed description is provided below, accompanied by preferred embodiments and accompanying drawings:
[0065] like Figure 1 and Figure 2 As shown, the intelligent counting method for icegrass spikes based on self-supervised Transformer and multi-scale dilated convolution of the present invention includes the following steps:
[0066] The first step is image acquisition and preprocessing. A 512×512 pixel RGB image of the icegrass canopy is acquired for photographing in the field. Adjustable LED supplementary lights can be used, arranged around the lens, to provide uniform supplementary lighting in cloudy or uneven lighting conditions. An RGB camera is used to photograph a 2m×2m icegrass plot at a height of 1.2 meters above the ground from a vertical top-down angle to obtain the original RGB image. This image is then cropped and scaled to 512×512 pixels, with pixel values normalized to the [0,1] range, and sent as input to the subsequent processing module.
[0067] The second step is to set up the DINO backbone network and extract high-dimensional feature maps.
[0068] The DINO backbone network is based on the Vision Transformer (ViT) architecture and employs a self-supervised pre-training strategy, enabling it to learn strong generalized feature representations without manual annotation. Its structure includes:
[0069] Image Patch Embedding: The input 512×512 image is divided into 256 non-overlapping image patches of 32×32 pixels. Each patch is linearly projected and mapped to a 768-dimensional embedding vector, and a learnable positional code is superimposed.
[0070] Transformer Encoder Stack: Contains 12 standard Transformer Encoder layers, each consisting of a Multi-Head Self-Attention (MHSA) network and a Feedforward Network (FFN);
[0071] Self-distillation training mechanism: During the training phase, a momentum-updating teacher network and a student network are set up. By minimizing the cross-entropy loss between the output logits of the two networks (i.e., Self-Distillation Loss), the model focuses on semantically consistent regions, thereby improving its robustness to changes in the morphology of icegrass spikes.
[0072] Feature map output: Take the output of the last layer Encoder and reshape it into a high-dimensional feature map of 32×32×768, which will be used as the input of the subsequent fusion module.
[0073] This design avoids the receptive field limitations of traditional CNNs, while utilizing self-supervised pre-training to alleviate the problem of insufficient label information in weakly supervised scenarios.
[0074] The preprocessed image is divided into multiple non-overlapping image patches, which are mapped to sequence embedding vectors through a patch embedding layer and then input into the DINO backbone network. The DINO backbone consists of multiple Transformer Encoders, each containing a self-attention mechanism and a feedforward network (FFN). During the training phase, Self-Distillation Loss (such as cross-entropy loss) is introduced to perform knowledge distillation, allowing the student network to learn global context representations under the guidance of the teacher network, thereby enhancing its ability to represent complex canopy structures. Finally, a high-dimensional feature map (dimensions H×W×C) is output, where H and W are the feature map spatial dimensions, and C is the number of channels.
[0075] By utilizing a self-supervised pre-training mechanism, DINO is able to learn global semantic features that are highly robust to changes in the morphology of ice grass without the need for manual annotation, thereby improving the stability and accuracy of the model when faced with challenges such as complex canopy structures, changes in illumination, and cluttered backgrounds.
[0076] The third step is to set up a multi-granularity gating fusion module.
[0077] like Figure 3 As shown, this module aims to extract multi-scale contextual information from the single-scale features output by DINO. Its specific structure is as follows:
[0078] Parallel dilated convolution branch: The 32×32×768 feature map is fed into three independent 1×1 convolutional layers (for channel compression to 128 dimensions), and then fed into 3×3 dilated convolutional layers with dilation rates of 1, 3, and 5 respectively, generating three sets of feature maps with different receptive fields:
[0079] Expansion Rate 1: Captures local details (such as the outline of a single ear of grain);
[0080] Expansion rate 3: Modeling medium-range associations (such as adjacent ear groups);
[0081] Inflation rate 5: Perceives a wide range of contexts (such as the overall density distribution of the canopy).
[0082] Global pooling and concatenation: Each feature map is compressed into a spatially independent 128-dimensional vector through global average pooling (GAP), and the three are concatenated to form a 384-dimensional joint representation;
[0083] Shared gated weight generator: Input the concatenated vector into a lightweight network containing 128→3 fully connected layers + Softmax, and output normalized weights;
[0084] Weighted fusion: The original three-way pooling features are summed according to their weights to obtain the final fused features.
[0085] A shared, lightweight gated network containing 1×1 convolutions, ReLU, and Softmax is used to generate normalized weights that satisfy... + + = 1;
[0086] in, , , These are all normalized weights generated by the gating network; they reflect the importance of feature maps under different receptive fields, ensuring the final fused feature vector. Adaptively emphasize the most relevant scale information;
[0087] The original three feature vectors after GAP processing are weighted and summed using normalized weights to obtain the final fused feature vector F. fuse The formula is:
[0088] ,
[0089] in, , , These are 128-dimensional vectors obtained by GAP processing of feature maps with dilation rates of 1, 3, and 5, respectively.
[0090] By setting different expansion rates, the model can flexibly adapt to the characteristic requirements of different density regions, improve the ability to capture the long-range dependence between sparse ears at the edge and dense ears in the center, and thus improve the counting accuracy.
[0091] The fourth step is to set up a lightweight regression head and output the counting results.
[0092] To adapt to the resource constraints of edge devices, the regression head adopts a minimalist design: Channel compression layer: 1×1 convolution (128→64) to reduce computational cost; Global average pooling: further compresses the spatial dimension and outputs a 64-dimensional vector; Linear prediction layer: a single fully connected layer (64→1) that directly outputs scalar count values.
[0093] The entire regression head contains only about 8,000 parameters, with an inference latency of less than 1ms, resulting in almost no performance burden on the Jetson platform.
[0094] The lightweight regression head and output of counting results include the following steps:
[0095] (1) Channel compression layer processing:
[0096] The fused feature map Ffuse obtained through the multi-granularity gated fusion module is input into a 1×1 convolutional layer. This convolutional layer is used to reduce the number of channels in the feature map, compressing it from 128 dimensions to 64 dimensions.
[0097] (2) Global average pooling operation:
[0098] For the 64-dimensional feature map after channel compression, global average pooling is applied. This operation averages the values of each feature map in the spatial dimension and converts it into a 64-dimensional vector that is independent of spatial location.
[0099] (3) Output of the linear prediction layer:
[0100] The 64-dimensional feature map is input into a fully connected layer, namely the linear prediction layer, which consists of a 64->1 linear transformation and outputs a scalar value representing the total number of predicted icegrass spikes.
[0101] like Figure 4 As shown, the visualization results of the MGG-ISCNet model's predictions on icegrass spike samples are presented. The top image shows the original icegrass spike samples, while the bottom image visually presents the model's focus on the target region in the form of a heatmap. The green text below represents the model's prediction results, and the black text represents the actual ground truth labels.
[0102] The lightweight regression head of this invention, with its minimalist design, not only has a low number of parameters, ensuring efficient operation on resource-constrained agricultural edge computing devices, but also achieves the goal of end-to-end inference latency of less than 20ms, solving the problem of high memory consumption and slow inference speed caused by excessive model complexity in existing methods.
[0103] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention. The scope of protection claimed by the appended claims and their equivalents is defined.
Claims
1. A method for counting the number of spikelets of ice grass based on self-supervised Transformer and multi-scale dilated convolution, characterized in that, Comprising the following steps: 11) Image acquisition and preprocessing; 12) Set DINO backbone network and extract high-dimensional feature map; 13) Set multi-granularity gated fusion module; 14) Set lightweight regression head and output counting results.
2. The method of claim 1, wherein the method is based on self-supervised Transformer and multi-scale dilated convolution for spike counting of ice grasses. The image acquisition and preprocessing step is: using an RGB camera to shoot a 2m×2m area of the ice grass plot at a height of 1.2 meters from the ground and a vertical viewing angle, to obtain an original RGB image; then crop and scale it to 512×512 pixels, and normalize the pixel value to the [0,1] interval.
3. The method of claim 1, wherein the method is based on self-supervised Transformer and multi-scale dilated convolution for wheat spikelet intelligent counting. The setting of the DINO backbone network and the extraction of the high-dimensional feature map include the following steps: 31) Set DINO backbone network; 32) Send the preprocessed image into the DINO backbone network for training; in the training stage, introduce Self-Distillation Loss for knowledge distillation, so that the student network learns the global context representation under the guidance of the teacher network, thereby enhancing the representation ability of complex canopy structure; finally output a high-dimensional feature map with a dimension of H×W×C, where H and W are the spatial dimensions of the feature map, and C is the number of channels.
4. The method of claim 1, wherein the method is based on self-supervised Transformer and multi-scale dilated convolution for wheat spikelet intelligent counting. The setting of the multi-granularity gated fusion module includes the following steps: 41) Parallel dilated convolution branch processing: Send the high-dimensional feature map of H×W×C into three independent 1×1 convolution layers respectively, for channel compression to 128 dimensions, and then respectively access 3×3 dilated convolution layers with dilated rates of 1, 3 and 5 to generate three groups of feature maps with different receptive fields: among them, dilated rate 1: capture local details, dilated rate 3: model medium-range correlation; dilated rate 5: perceive large-scale context; 42) Global pooling and splicing: For the feature map obtained after each dilated convolution, apply global average pooling to average the feature values at each spatial position, thereby converting each feature map to a spatially independent 128-dimensional vector; splice the three 128-dimensional vectors after GAP processing to form a 384-dimensional joint representation vector; 43) Shared gating weight generation and weighted fusion: The shared co-right lightweight gating network, including 1x1 convolution + ReLU + Softmax, generates normalized weights, satisfying + + = 1; wherein, , , are normalized weights generated by the gating network, which reflect the importance of feature maps under different receptive fields, ensuring that the final fusion feature vector adaptively emphasizes the most relevant scale information; The original three-path GAP-processed feature vectors are weighted and summed using the normalized weights to obtain the final fused feature vector F fuse The formula is: , wherein, , , are 128-dimensional vectors obtained by GAP processing of the feature maps with expansion rates of 1, 3 and 5, respectively.
5. The method of claim 1, wherein the method is based on self-supervised Transformer and multi-scale dilated convolution for wheat spikelet intelligent counting. The setting of the lightweight regression head and the output of the counting results includes the following steps: 51) Channel compression layer processing: Input the fusion feature map Ffuse obtained through the multi-granularity gated fusion module into a 1×1 convolution layer, which is used to reduce the number of channels of the feature map from 128 to 64; 52) Global average pooling operation: For the 64-dimensional feature map after channel compression, apply global average pooling, which averages the values in the spatial dimension of each feature map and converts it into a 64-dimensional vector independent of the spatial position; 53) Linear prediction layer output: Input the 64-dimensional feature map into a fully connected layer, i.e. a linear prediction layer, which consists of a 64->1 linear transformation, outputting a scalar value representing the predicted total number of ice grass spikes.
6. The method of claim 3, wherein the method is based on self-supervised Transformer and multi-scale dilated convolution for wheat spikelet intelligent counting. The setting of the DINO backbone network is composed of multiple layers of Transformer Encoder, each containing self-attention mechanism and feedforward network; including the following steps: 61) Image blocking and embedding: The input 512x512 pixel RGB image is divided into 256 non-overlapping 32x32 pixel patches; each patch is mapped to a 768-dimensional embedding vector by linear projection; a learnable position encoding is added to each embedding vector to preserve the spatial position information of the image. Finally, 256 768-dimensional embedding vector sequences are obtained as the input of the Transformer Encoder; 62) Transformer Encoder stack: The DINO backbone network contains 12 layers of standard Transformer Encoder, and each layer of Transformer Encoder consists of two parts: Multi-head self-attention mechanism: self-attention calculation is performed on the input embedding vector sequence to generate a new representation and capture the dependency between different positions; Feedforward network: the embedding vector of each position is processed through a two-layer fully connected network, the first layer expands the dimension, and the second layer restores the original dimension to process and convert the feature representation; 63) Self-distillation training mechanism: Set a momentum-updated teacher network, whose parameters are updated from the student network through exponential moving average; the student network receives the input image during training and outputs logits; the teacher network receives the same input image and outputs its own logits; by minimizing the cross-entropy loss between the logits output by the student network and the teacher network, the student network learns the global context representation under the guidance of the teacher network; 64) Feature map output: After processing by the 12-layer Transformer Encoder, the output feature map of the last Encoder is taken; the feature map is reshaped into a 32x32x768 high-dimensional feature map; this high-dimensional feature map contains rich semantic information and effectively represents the morphological characteristics of the ice grass spike, serving as the input of the multi-granularity gated fusion module.
7. A computer readable storage medium characterized in that, The storage medium has a computer program stored thereon, and when the computer program is executed by the processor, the ice grass spike intelligent counting method based on self-supervised Transformer and multi-scale dilated convolution of any one of claims 1-6 can be realized.
8. A computer device, comprising: The computer program stored on the storage medium and executable on the processor can realize the ice grass spike intelligent counting method based on self-supervised Transformer and multi-scale dilated convolution of any one of claims 1-6 when the processor executes.