Crop target detection method, device and equipment and computer storage medium
Patent Information
- Application Number
- CN202611196750.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-07
- Publication Date
- 2026-10-30
AI Technical Summary
[0004]本申请的主要目的在于提供一种作物目标检测方法,旨在解决如何提升作物目标检测的检测精度的技术问题
[0015]本申请提出了一种作物目标检测方法、装置、设备及计算机存储介质,所述方法包括:获取待检测作物图像,并对所述待检测作物图像进行尺寸预处理,得到预设输入尺寸的输入图像;将所述输入图像输入至预先构建的骨干特征提取网络,提取具有不同空间分辨率的骨干特征,并基于所述骨干特征构建依次记为P3至P7的五级输入特征,其中,P3特征的空间分辨率最高,P7特征的空间分辨率最低;在首轮双向特征融合网络的输入预处理阶段,利用双尺度选择性核注意力模块,分别对所述P3输入特征和P4输入特征进行预增强处理;利用至少一轮双向特征融合网络,对P3至P7特征进行自顶向下融合和自底向上融合,并在每一轮双向特征融合网络的P4自顶向下融合节点、P3自顶向下融合节点和P4自底向上融合节点中,利用所述双尺度选择性核注意力模块对相应融合特征进行增强处理;基于最后一轮双向特征融合网络输出的P3至P7多尺度融合特征,对所述待检测作物图像中的作物目标进行类别识别和位置回归,得到检测结果。
Smart Images

Figure CN123016204A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image detection technology, and in particular to a method, apparatus, device, and computer storage medium for crop target detection. Background Technology
[0002] Crop target detection is a key technology in precision agriculture and agricultural automation monitoring. It aims to automatically identify and locate crops by analyzing field images collected by drones, providing data support for seedling condition assessment, density statistics, and replanting decisions.
[0003] Existing methods generally employ feature fusion modules such as Bidirectional Feature Pyramid Network (BiFPN) or Path Aggregation Network (PANet). However, since BiFPN and PANet typically use a single convolutional kernel (such as 3×3 or 5×5), they are unable to simultaneously adapt to crop images with inconsistent resolutions caused by UAVs flying at a fixed altitude (crops in the foreground are large and clear, while crops in the distance are small and blurry), resulting in low detection accuracy of crop images. Summary of the Invention
[0004] The main purpose of this application is to provide a crop target detection method, which aims to solve the technical problem of how to improve the detection accuracy of crop targets.
[0005] To achieve the above objectives, this application proposes a crop target detection method, the method comprising: Acquire an image of the crop to be detected, and perform size preprocessing on the image to be detected to obtain an input image with a preset input size; The input image is fed into a pre-constructed backbone feature extraction network to extract backbone features with different spatial resolutions. Based on the backbone features, five levels of input features are constructed, which are sequentially labeled P3 to P7. Among them, the spatial resolution of the P3 feature is the highest and the spatial resolution of the P7 feature is the lowest. In the input preprocessing stage of the first-round bidirectional feature fusion network, the P3 input features and P4 input features are pre-enhanced using a dual-scale selective kernel attention module. Using at least one round of bidirectional feature fusion network, top-down and bottom-up fusion are performed on features P3 to P7. In each round of bidirectional feature fusion network, the corresponding fused features are enhanced using the dual-scale selective kernel attention module. Based on the P3 to P7 multi-scale fusion features output by the last round of bidirectional feature fusion network, the crop targets in the crop image to be detected are classified and their positions are regressed to obtain the detection results. The dual-scale selective kernel attention module performs the following enhancement operations on the input features: Perform a first-scale convolution on the input features to obtain the first-scale features; The first-scale feature is further processed by the second-scale convolution to obtain the second-scale feature. The effective receptive field of the second-scale convolution is larger than that of the first-scale convolution. The first scale feature and the second scale feature are respectively adjusted by channel, and the first scale feature and the second scale feature after channel adjustment are concatenated in the channel dimension to obtain the concatenated feature; The average feature and the maximum feature are calculated along the channel dimension of the splicing feature, and spatial attention weights corresponding to the first scale feature and the second scale feature are generated according to the average feature and the maximum feature, respectively. Based on the spatial attention weights, the first-scale features and the second-scale features after channel adjustment are weighted and summed, and the result of the weighted sum is restored to the number of channels of the input features. The features after restoring the number of channels are multiplied element-wise with the input features to obtain the enhanced output features.
[0006] In one embodiment, in the dual-scale selective kernel attention module, the first-scale convolution is a depthwise convolution with a kernel size of 5×5, a stride of 1, and padding of 2. The second-scale convolution is a depthwise convolution with a kernel size of 7×7, a stride of 1, an inflation rate of 3, and a padding of 9. The first scale feature and the second scale feature are each reduced to half the number of input feature channels through 1×1 convolution; The average feature and the maximum feature are concatenated and then used to generate two spatial attention weights through a convolution with a kernel size of 7×7, padding of 3, and output channels of 2, followed by Sigmoid activation.
[0007] In one embodiment, the backbone features include three backbone features sequentially labeled C3, C4, and C5, and the step of constructing five levels of input features sequentially labeled P3 to P7 based on the backbone features includes: Channel adjustments were performed on C3, C4, and C5 respectively to obtain input features P3, P4, and P5; The channel-adjusted C5 backbone features are subjected to max pooling with a kernel size of 3×3 and a stride of 2 to obtain the P6 input features. Max pooling with a kernel size of 3×3 and a stride of 2 is performed again on the input features of P6 to obtain the input features of P7.
[0008] In one embodiment, the step of enhancing the corresponding fused features using the dual-scale selective kernel attention module includes: In the bidirectional feature fusion network, each fusion node sets a learnable scalar weight for each input feature, performs non-negation processing on the learnable scalar weight, and normalizes each learnable scalar weight according to the sum of the non-negation weights and a preset stability term to obtain normalized weights. The input features are weighted and summed according to the normalized weights, and the weighted summation result is then subjected to nonlinear activation, 3×3 depthwise convolution and 1×1 pointwise convolution in sequence. In the P4 top-down fusion node, the P3 top-down fusion node, and the P4 bottom-up fusion node, the dual-scale selective kernel attention enhancement is performed after the 1×1 pointwise convolution and before the batch normalization.
[0009] In one embodiment, the nonnegativity process employs the ReLU function, and the preset stable term is 10. -4 The nonlinear activation employs either the Swish or SiLU function; The scaling transformation in top-down fusion uses interpolation upsampling with a magnification factor of 2, where the interpolation upsampling is either nearest neighbor interpolation or bilinear interpolation; The scaling transformation in bottom-up fusion uses max pooling with a kernel size of 3×3 and a stride of 2.
[0010] In one embodiment, the step of performing category recognition and location regression on the crop targets in the crop image to be detected to obtain the detection result includes: The classification network outputs several category prediction values for each anchor box, and performs Sigmoid activation on each of the category prediction values to obtain the category information of the crop target in the crop image to be detected. A bounding box regression network outputs a preset number of bounding box regression parameters for each anchor box, and the location information of the crop target in the crop image to be detected is obtained based on the bounding box regression parameters. The detection result of the crop target in the crop image to be detected is obtained based on the category information and the location information; The classification network and the bounding box regression network each include four depthwise separable convolutional blocks arranged sequentially and one depthwise separable output convolutional block. Each depthwise separable convolutional block includes a 3×3 depthwise convolution, a 1×1 pointwise convolution, a scale-corresponding batch normalization, and a Swish activation. The convolutional parameters in the same network are shared between P3 and P7, and different scales use mutually independent batch normalization parameters.
[0011] In one embodiment, nine preset anchor frames are set at each feature location from P3 to P7, the nine preset anchor frames being composed of scale factors 1 and 2. (1 / 3) and 2 (2 / 3) It is formed by combining length-to-width ratios of 1:1, 2:1, and 1:2, with a basic anchor frame dimensional parameter of 4.
[0012] Furthermore, to achieve the above objectives, this application also proposes a crop target detection device, the device comprising: The image processing module is used to acquire the image of the crop to be detected and to perform size preprocessing on the image of the crop to be detected to obtain an input image of a preset input size; The feature extraction module is used to input the input image into a pre-constructed backbone feature extraction network, extract backbone features with different spatial resolutions, and construct five levels of input features, sequentially labeled P3 to P7, based on the backbone features, where P3 features have the highest spatial resolution and P7 features have the lowest spatial resolution. The feature enhancement module is used to pre-enhance the P3 input features and P4 input features respectively in the input preprocessing stage of the first round of bidirectional feature fusion network using a dual-scale selective kernel attention module. The feature fusion module is used to perform top-down and bottom-up fusion of features P3 to P7 using at least one round of bidirectional feature fusion network, and to enhance the corresponding fused features using the dual-scale selective kernel attention module in the P4 top-down fusion node, P3 top-down fusion node and P4 bottom-up fusion node of each round of bidirectional feature fusion network. The result detection module is used to perform category recognition and location regression on crop targets in the crop image to be detected based on the P3 to P7 multi-scale fusion features output by the last round of bidirectional feature fusion network, and obtain the detection result.
[0013] In addition, to achieve the above objectives, this application also proposes a crop target detection device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the crop target detection method as described above.
[0014] In addition, to achieve the above objectives, this application also proposes a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the crop target detection method described above.
[0015] This application proposes a crop target detection method, apparatus, device, and computer storage medium. The method includes: acquiring a crop image to be detected and performing size preprocessing on the crop image to obtain an input image of a preset input size; inputting the input image into a pre-constructed backbone feature extraction network to extract backbone features with different spatial resolutions, and constructing five levels of input features, sequentially labeled P3 to P7, based on the backbone features, where P3 features have the highest spatial resolution and P7 features have the lowest spatial resolution; in the first round of bidirectional feature fusion network input preprocessing stage, dual-scale selective kernel attention is used. The module performs pre-enhancement processing on the P3 and P4 input features respectively; it uses at least one round of bidirectional feature fusion network to perform top-down and bottom-up fusion of features P3 to P7, and in each round of bidirectional feature fusion network, the dual-scale selective kernel attention module enhances the corresponding fused features; based on the P3 to P7 multi-scale fused features output by the last round of bidirectional feature fusion network, it performs category recognition and location regression on the crop targets in the crop image to be detected, and obtains the detection results.
[0016] The crop target detection method and device of this application can be equipped with a detection mechanism based on dual-scale selective kernel attention and multi-round bidirectional feature fusion. It can acquire the crop image to be detected and perform size preprocessing to obtain the input image. A backbone feature extraction network is used to obtain five levels of input features from P3 to P7 (P3 has the highest spatial resolution, P7 the lowest). In the input preprocessing stage of the first round of bidirectional feature fusion network, the dual-scale selective kernel attention module is used to pre-enhance the P3 and P4 features. Then, at least one round of bidirectional feature fusion network is used to fuse the P3 to P7 features from top to bottom and bottom to top. The attention module is used to enhance the fused features in the P4, P3 top-down nodes, and P4 bottom-up nodes of each fusion round. Finally, the multi-scale fused features output from the last round are used for category recognition and location regression. Furthermore, in the actual detection process, the system dynamically fuses feature information from different receptive fields at key fusion nodes through the dual-scale selective kernel attention module, effectively extracting and enhancing the multi-scale features of the crop target, enabling the network to adapt to seedling targets of different sizes simultaneously. Compared to existing feature fusion methods that use a single convolutional kernel and struggle to address the issue of inconsistent crop scales in UAV imagery, this application introduces a dual-scale selective kernel attention mechanism at key locations in feature fusion. This mechanism enhances the expressive power of multi-scale features while maintaining computational efficiency. Consequently, users can directly obtain more accurate and robust detection results when performing crop target detection, thereby improving the accuracy and reliability of intelligent agricultural monitoring. 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 of the first embodiment of the crop target detection method proposed in this application; Figure 2 This is a flowchart of the second embodiment of the crop target detection method proposed in this application; Figure 3 This is a flowchart of the third embodiment of the crop target detection method proposed in this application; Figure 4 This is a system example block diagram of the crop target detection method proposed in the embodiments of this application; Figure 5This is a schematic diagram of the ablation experiment results in the crop target detection method proposed in this application embodiment; Figure 6 A diagram of a crop target detection device provided in an embodiment of this application; Figure 7 A schematic diagram of the structure of a crop target detection device suitable for implementing 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 only used to explain the technical solutions of this application and are not intended to limit this application.
[0022] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0023] It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of this application are only used to explain the relative positional relationship and movement of each component in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indication will also change accordingly.
[0024] Understandably, crop target detection is a key technology in precision agriculture and agricultural automation monitoring. It aims to automatically identify and locate crops by analyzing field images collected by drones, providing data support for seedling condition assessment, density statistics, and replanting decisions.
[0025] Existing methods generally employ feature fusion modules such as Bidirectional Feature Pyramid Network (BiFPN) or Path Aggregation Network (PANet). However, since BiFPN and PANet typically use a single convolutional kernel (such as 3×3 or 5×5), they are unable to simultaneously adapt to crop images with inconsistent resolutions caused by UAVs flying at a fixed altitude (crops in the foreground are large and clear, while crops in the distance are small and blurry), resulting in low detection accuracy of crop images.
[0026] Therefore, to solve the above-mentioned technical problems, this embodiment proposes a crop target detection method, which includes: acquiring an image of the crop to be detected and performing size preprocessing on the image to obtain an input image of a preset input size; inputting the input image into a pre-constructed backbone feature extraction network to extract backbone features with different spatial resolutions, and constructing five levels of input features, sequentially labeled P3 to P7, based on the backbone features, where P3 features have the highest spatial resolution and P7 features have the lowest spatial resolution; in the input preprocessing stage of the first-round bidirectional feature fusion network, a dual-scale selective kernel attention model is used. The system performs pre-enhancement processing on the P3 and P4 input features respectively. It then utilizes at least one round of bidirectional feature fusion network to perform top-down and bottom-up fusion on the P3 to P7 features. In each round of the bidirectional feature fusion network, the corresponding fused features are enhanced using a dual-scale selective kernel attention module at the P4 top-down fusion node, P3 top-down fusion node, and P4 bottom-up fusion node. Based on the P3 to P7 multi-scale fusion features output from the last round of the bidirectional feature fusion network, the system performs category recognition and location regression on the crop targets in the crop image to be detected, obtaining the detection results.
[0027] The crop target detection method and device in this embodiment can be equipped with a detection mechanism based on dual-scale selective kernel attention and multi-round bidirectional feature fusion. It can acquire the crop image to be detected and perform size preprocessing to obtain the input image. A backbone feature extraction network is used to obtain five levels of input features from P3 to P7 (P3 has the highest spatial resolution, P7 the lowest). In the first round of bidirectional feature fusion network input preprocessing stage, the dual-scale selective kernel attention module is used to pre-enhance the P3 and P4 features. Then, at least one round of bidirectional feature fusion network is used to fuse the P3 to P7 features from top to bottom and bottom to top. The attention module is used to enhance the fused features in the P4, P3 top-down nodes, and P4 bottom-up nodes of each fusion round. Finally, based on the multi-scale fused features output in the last round, category recognition and location regression are performed. Furthermore, in the actual detection process, the system dynamically fuses feature information from different receptive fields at key fusion nodes through the dual-scale selective kernel attention module, effectively extracting and enhancing the multi-scale features of the crop target, enabling the network to adapt to seedling targets of different sizes simultaneously. Compared to existing feature fusion methods that use a single convolutional kernel and struggle to address the issue of inconsistent crop scales in UAV imagery, this embodiment introduces a dual-scale selective kernel attention mechanism at key locations in feature fusion. This mechanism enhances the expressive power of multi-scale features while maintaining computational efficiency. Consequently, users can directly obtain more accurate and robust detection results when performing crop target detection, thereby improving the accuracy and reliability of intelligent agricultural monitoring.
[0028] This embodiment uses convolution kernels of different sizes to extract and fuse multi-scale image features in parallel, which can adaptively enhance the recognition of crops at different scales, thereby improving the detection accuracy of crop images.
[0029] For ease of understanding, the following is combined with Figures 1 to 7 The crop target detection method provided in the embodiments of this application, as well as the crop target detection method, apparatus and equipment provided in the following embodiments, will be described in detail.
[0030] This application provides a crop target detection method, referring to... Figure 1 , Figure 1 This is a flowchart of the first embodiment of the crop target detection method proposed in this application.
[0031] like Figure 1 As shown, the method includes: Step S10: Obtain the crop image to be detected, and perform size preprocessing on the crop image to be detected to obtain an input image with a preset input size.
[0032] It should be explained that the aforementioned crop images to be detected can be farmland image data collected by a camera device mounted on a drone, such as aerial images of fields containing corn seedlings, wheat seedlings, or rice seedlings. The aforementioned size preprocessing can be an image processing operation that uniformly adjusts images of different original sizes to a preset input size, for example, by scaling or cropping the image to fit the size required for subsequent network processing. The aforementioned preset input size can be a pre-set fixed image pixel size, such as adjusting the image to a standard size with a width and height of 640 pixels. The aforementioned input image can be image data with uniform size specifications obtained after size preprocessing.
[0033] In its implementation, the aforementioned device acquires an image of the crop to be detected. This image can be obtained by a drone flying over farmland, capturing images in real-time via an onboard camera and transmitting them to a ground receiver, or it can be retrieved from historical aerial imagery data pre-stored in the device's internal or external storage. Subsequently, the device performs size preprocessing on the crop image. During size preprocessing, the device can process the original image using various image size adjustment methods according to preset input size requirements. For example, the device can scale the original image proportionally to match the longer or shorter side to the preset size, and fill any edge areas that are smaller than the preset size with pixels; alternatively, it can directly stretch the image non-proportionally to perfectly match the width and height of the preset size. After the aforementioned size preprocessing, the device obtains an input image with the preset input size.
[0034] Step S20: Input the input image into a pre-constructed backbone feature extraction network to extract backbone features with different spatial resolutions, and construct five levels of input features, sequentially labeled P3 to P7, based on the backbone features. Among them, the spatial resolution of the P3 feature is the highest and the spatial resolution of the P7 feature is the lowest.
[0035] It should be explained that the aforementioned backbone feature extraction network can be a deep convolutional network structure that extracts basic image features from the input image. The aforementioned backbone features can be a set of feature maps with different spatial resolutions and channel numbers output from different network layers of the backbone feature extraction network after the input image has passed through them. The aforementioned spatial resolution can be the pixel size of the feature map in the width and height directions, reflecting the downsampling factor of the feature map relative to the input image. The aforementioned input features can be multi-scale feature layers obtained after further processing based on the backbone features, used for subsequent feature fusion.
[0036] In its implementation, the device feeds the input image into a pre-constructed backbone feature extraction network. This network consists of multiple sequentially connected convolutional modules stacked on top of each other. The input image is processed sequentially by these modules, each extracting higher-level semantic information while reducing the spatial resolution of the feature maps through downsampling. The device acquires backbone features with different spatial resolutions from different depth levels of the backbone feature extraction network. Higher-level backbone features have higher semantic abstraction and lower spatial resolution, while lower-level features retain richer spatial details and higher spatial resolution. Subsequently, the device further processes the acquired backbone features to construct five levels of input features. During this construction process, the device directly uses some backbone features as input features for corresponding levels and performs additional downsampling operations on some backbone features to generate input features with even lower spatial resolution. The five levels of input features mentioned above are named P3, P4, P5, P6 and P7 features in descending order of spatial resolution. Among them, P3 features have the highest spatial resolution and P7 features have the lowest spatial resolution, thus forming an input feature pyramid covering different scale ranges.
[0037] Step S30: In the input preprocessing stage of the first round of bidirectional feature fusion network, the P3 input features and P4 input features are pre-enhanced using the dual-scale selective kernel attention module.
[0038] It should be explained that the aforementioned first-round bidirectional feature fusion network can be the network structure that performs bidirectional feature fusion operation for the first time in the entire feature fusion process. This bidirectional feature fusion network can be a network structure that bidirectionally transfers and fuses high-resolution low-semantic features with low-resolution high-semantic features, achieving full interaction of multi-scale features through top-down and bottom-up paths. The aforementioned input preprocessing stage can be a stage that preprocesses and enhances the input features before they formally enter the main fusion process of the bidirectional feature fusion network. The aforementioned dual-scale selective kernel attention module can be a feature processing module that extracts multi-scale feature information based on convolutional operations with two different receptive fields and adaptively assigns attention weights to different spatial locations. The aforementioned pre-enhancement processing can be a processing operation that pre-enhances and optimizes the input features at a specific level before feature fusion.
[0039] In its implementation, the device selects P3 and P4 input features from the constructed five-level input features (P3 to P7) during the initial input preprocessing stage of the bidirectional feature fusion network. These two input features are then pre-enhanced using a dual-scale selective kernel attention module. For each of the P3 and P4 input features, the device first inputs it into the dual-scale selective kernel attention module. Within this module, the device performs feature extraction based on two different receptive fields to obtain two scale features containing contextual information of different ranges. Subsequently, the device adjusts and integrates the channel dimensions of these two scale features and calculates spatial attention weights based on the integrated features. These spatial attention weights reflect the importance of different spatial locations in the two scale features. Based on the calculated spatial attention weights, the device performs a weighted combination of the two scale features and fuses the result with the original input features to output the enhanced features. Through this method, the device completes pre-enhancing processing on the P3 and P4 input features respectively, obtaining pre-enhanced P3 and P4 features.
[0040] Specifically, the dual-scale selective kernel attention module performs the following enhancement operations on the input features: Perform a first-scale convolution on the input features to obtain the first-scale features; The first-scale feature is further processed by the second-scale convolution to obtain the second-scale feature. The effective receptive field of the second-scale convolution is larger than that of the first-scale convolution. The first scale feature and the second scale feature are respectively adjusted by channel, and the first scale feature and the second scale feature after channel adjustment are concatenated in the channel dimension to obtain the concatenated feature; The average feature and the maximum feature are calculated along the channel dimension of the splicing feature, and spatial attention weights corresponding to the first scale feature and the second scale feature are generated according to the average feature and the maximum feature, respectively. Based on the spatial attention weights, the first-scale features and the second-scale features after channel adjustment are weighted and summed, and the result of the weighted sum is restored to the number of channels of the input features. The features after restoring the number of channels are multiplied element-wise with the input features to obtain the enhanced output features.
[0041] It should be explained that the aforementioned first-scale convolution can be a computational process of performing a convolution operation on the input features using a first-scale kernel size. The aforementioned first-scale feature can be a feature map obtained after performing a first-scale convolution on the input features. The aforementioned second-scale convolution can be a computational process of continuing to perform a convolution operation on the first-scale feature using a second-scale kernel size, with an effective receptive field larger than that of the first-scale convolution. The aforementioned effective receptive field can be the size of the spatial range that the convolution operation can actually perceive on the input feature map. The aforementioned channel adjustment can be an operation that changes the number of channels in the feature map, for example, adjusting the feature from a higher number of channels to a lower number of channels through pointwise convolution. The aforementioned concatenated feature can be a comprehensive feature map obtained by merging multiple feature maps along the channel dimension. The aforementioned average feature can be a single-channel spatial feature map obtained by calculating the mean of the concatenated features along the channel dimension. The aforementioned maximum feature can be a single-channel spatial feature map obtained by taking the maximum value of the concatenated features along the channel dimension. The aforementioned spatial attention weight can be a weight value used to measure the importance of different spatial locations on the feature map, used to weight and combine features of two scales. The weighted summation described above can be an operation of multiplying each of the two feature maps by its corresponding spatial attention weight and then adding them together. The element-wise multiplication described above can be an operation of multiplying the values at corresponding positions of two feature maps with the same dimension one by one.
[0042] In its implementation, after the dual-scale selective kernel attention module receives input features, the device performs a first-scale convolution on these features to obtain first-scale features. Subsequently, the device performs a second-scale convolution on these first-scale features to obtain second-scale features. The effective receptive field of the second-scale convolution is larger than that of the first-scale convolution, allowing the second-scale features to capture a wider range of contextual information than the first-scale features. After obtaining the first and second-scale features, the device performs channel adjustment on both features, adjusting the number of channels to a preset target number. After channel adjustment, the device concatenates the channel-adjusted first and second-scale features along the channel dimension to obtain concatenated features. These concatenated features integrate feature information from two different scale receptive fields. Next, the device calculates the average feature and the maximum feature along the channel dimension of the concatenated features. The average feature reflects the average response intensity of the concatenated features at each spatial location, and the maximum feature reflects the strongest response intensity of the concatenated features at each spatial location. The device further processes the average and maximum features to generate spatial attention weights corresponding to the first and second-scale features, respectively. Subsequently, the device performs a weighted summation of the channel-adjusted first-scale and second-scale features based on the aforementioned spatial attention weights, obtaining a weighted fused feature. The device then restores the channel count of the weighted fusion result, ensuring the number of channels in the feature map matches the number of channels in the input features. Finally, the device performs element-wise multiplication of the restored channel count feature with the original input features to obtain the enhanced output feature.
[0043] Step S40: Using at least one round of bidirectional feature fusion network, perform top-down and bottom-up fusion on features P3 to P7, and in each round of bidirectional feature fusion network, use the dual-scale selective kernel attention module to enhance the corresponding fused features.
[0044] It should be explained that the top-down fusion described above can be a process of transferring information from a feature layer with low spatial resolution and high semantic information to a feature layer with high spatial resolution and low semantic information. It gradually restores the spatial size of the feature map through upsampling operations, enabling high-level semantic information to guide the expression of low-level features. The bottom-up fusion described above can be a process of transferring information from a feature layer with high spatial resolution and low semantic information to a feature layer with low spatial resolution and high semantic information. It gradually compresses the spatial size of the feature map through downsampling operations, enabling low-level spatial detail information to supplement the localization capabilities of high-level features. The fusion node described above can be a specific location in a bidirectional feature fusion network where multiple features from different paths are gathered, weighted, and integrated. The fused feature described above can be a comprehensive feature expression obtained by weighting and combining multiple input features from different feature layers at the fusion node.
[0045] In its implementation, the aforementioned device utilizes at least one round of bidirectional feature fusion network to perform feature fusion processing on features P3 to P7. In each round of the bidirectional feature fusion network, the device first executes a top-down fusion path. During the top-down fusion process, the device starts from the P7 feature layer with the lowest spatial resolution, gradually enlarging the spatial size of higher-level features through upsampling operations. The upsampled features are then weighted and combined with features from the previous layer at the corresponding fusion nodes, and sequentially passed to the P6 fusion node, P5 fusion node, P4 fusion node, and P3 fusion node.
[0046] Subsequently, the device executes a bottom-up fusion path. In this bottom-up fusion process, starting from the P3 fusion node with the highest spatial resolution, the device progressively compresses the spatial size of low-level features through downsampling operations. The downsampled features are then weighted and combined with features from the corresponding levels in the top-down path and the original input features at the corresponding fusion nodes, and this process is sequentially passed to the P4, P5, P6, and P7 fusion nodes. In each round of fusion, at the three specific locations of the P4 top-down, P3 top-down, and P4 bottom-up fusion nodes, the device enhances the fused features generated by the current node using a dual-scale selective kernel attention module. Specifically, the device feeds the fused features output from these three nodes into the dual-scale selective kernel attention module. This module extracts multi-scale information and calculates spatial attention weights through convolution operations at two different scales. Based on these weights, it adaptively weights and combines the multi-scale features, ultimately outputting the enhanced fused features. Through this method, the device completes one round of bidirectional feature fusion.
[0047] Step S50: Based on the P3 to P7 multi-scale fusion features output by the last round of bidirectional feature fusion network, perform category recognition and location regression on the crop targets in the crop image to be detected to obtain the detection results.
[0048] It should be explained that the aforementioned final round of bidirectional feature fusion network can be the fusion network structure used as the final output round during multi-round bidirectional feature fusion. The aforementioned multi-scale fusion features can be a set of feature maps containing different spatial resolutions and rich semantic information, output after at least one round of bidirectional feature fusion. The aforementioned category recognition can be the process of determining the category of each target in the image based on the fusion features, such as determining whether the detected target is a corn seedling, wheat seedling, or rice seedling. The aforementioned location regression can be the process of calculating the specific coordinates of the target's location in the image based on the fusion features, such as outputting the location parameters of the bounding box containing the target.
[0049] In its implementation, after completing all fusion operations in the final round of the bidirectional feature fusion network, the device obtains the P3 to P7 multi-scale fusion features output from this round. These multi-scale fusion features encompass feature maps at five different scales, from high spatial resolution to low spatial resolution, where each scale's feature map incorporates semantic and spatial detail information from different paths. Subsequently, the device performs target detection based on these five-level multi-scale fusion features. For each feature layer from P3 to P7, the device performs category recognition and location regression. During category recognition, the device analyzes each spatial location on each feature layer to determine whether the location corresponds to a crop target and the specific category to which the target belongs. During location regression, the device predicts the bounding box parameters for each spatial location on each feature layer to determine the precise location of the crop target in the input image coordinate system. The device then summarizes all category recognition and location regression results from the five feature layers to obtain a preliminary detection result set.
[0050] Furthermore, in the dual-scale selective kernel attention module, the first-scale convolution is a depthwise convolution with a kernel size of 5×5, a stride of 1, and padding of 2. The second-scale convolution is a depthwise convolution with a kernel size of 7×7, a stride of 1, an inflation rate of 3, and a padding of 9. The first scale feature and the second scale feature are each reduced to half the number of input feature channels through 1×1 convolution; The average feature and the maximum feature are concatenated and then used to generate two spatial attention weights through a convolution with a kernel size of 7×7, padding of 3, and output channels of 2, followed by Sigmoid activation.
[0051] It should be explained that the aforementioned depthwise convolution can be a convolution method that executes the convolution operation independently for each channel of the input feature map, with the number of groups equal to the number of channels in the input feature map. The aforementioned dilated depthwise convolution can be a convolution method that introduces dilation on top of depthwise convolution; by increasing the dilation rate, the receptive field can be expanded without increasing the number of kernel parameters. The aforementioned dilation rate can be a parameter controlling the spacing between elements of the convolution kernel; the larger the dilation rate, the wider the sampling range of the convolution kernel on the input feature map. The aforementioned 1×1 convolution can be a convolution operation with a kernel size of 1×1, mainly used to adjust the number of channels in the feature map. The aforementioned sigmoid activation can be a non-linear activation function that maps input values to the interval between 0 and 1.
[0052] In its implementation, the dual-scale selective kernel attention module performs convolution operations on the input features. The first-scale convolution uses a 5×5 kernel with a stride of 1 and padding of 2, extracting features at a medium scale while maintaining the input feature space size. The second-scale convolution uses a 7×7 kernel with a stride of 1, a dilation rate of 3, and padding of 9. This dilation rate further expands the effective receptive field of the kernel while maintaining the input feature space size, thus capturing a wider range of contextual information. After the first and second-scale features are generated, the device performs channel adjustment on both features using 1×1 convolutions, reducing the number of channels in both features to half the number of channels in the input features. After channel adjustment, the device concatenates the two features along the channel dimension to obtain a concatenated feature. Subsequently, the device calculates the average and maximum features along the channel dimension of the concatenated feature. The device concatenates the average feature and the maximum feature along the channel dimension, and feeds the concatenated feature into a convolutional layer with a kernel size of 7×7, padding of 3, and output channels of 2 for processing. Then, it performs non-linear mapping through the Sigmoid activation function to finally generate two spatial attention weights, which correspond to the first scale feature and the second scale feature after channel adjustment, respectively.
[0053] Further, the backbone features include three backbone features sequentially labeled C3, C4, and C5, and the step of constructing five levels of input features sequentially labeled P3 to P7 based on the backbone features includes: Channel adjustments were performed on C3, C4, and C5 respectively to obtain input features P3, P4, and P5; The channel-adjusted C5 backbone features are subjected to max pooling with a kernel size of 3×3 and a stride of 2 to obtain the P6 input features. Max pooling with a kernel size of 3×3 and a stride of 2 is performed again on the input features of P6 to obtain the input features of P7.
[0054] It should be explained that the aforementioned backbone features can be the basic feature maps output from different levels of the backbone feature extraction network after the input image has passed through them. These maps exhibit decreasing spatial resolution and increasing semantic abstraction from lower to higher levels. The aforementioned channel adjustment can be achieved by changing the number of channels in the feature map through convolution operations to meet the channel dimensions required for subsequent processing. The aforementioned max pooling can be a downsampling operation that selects the maximum value within a local region of the feature map as the output for that region, thereby reducing the spatial resolution of the feature map.
[0055] In its implementation, the aforementioned backbone feature extraction network outputs three backbone features, which are sequentially labeled C3, C4, and C5. C3, C4, and C5 have different spatial resolutions, with C3 having the highest and C5 the lowest. During the construction of the five levels of input features (P3 to P7), the device first adjusts the channels of the C3 backbone feature to obtain the P3 input feature, adjusts the channels of the C4 backbone feature to obtain the P4 input feature, and adjusts the channels of the C5 backbone feature to obtain the P5 input feature. This channel adjustment unifies the number of channels for each backbone feature to a preset target number, facilitating subsequent feature fusion processing. Subsequently, to construct an input feature layer with even lower spatial resolution, the device performs a downsampling operation on the channel-adjusted C5 backbone feature to obtain the P6 input feature. Then, the device performs another downsampling operation on the P6 input feature to obtain the P7 input feature. In the above manner, the device obtains a total of five input feature layers from P3 to P7. Among them, P3, P4 and P5 are derived from the backbone features C3, C4 and C5 respectively, while P6 and P7 are obtained by downsampling the P5 feature step by step.
[0056] The crop target detection method and device in this embodiment can be equipped with a detection mechanism based on dual-scale selective kernel attention and multi-round bidirectional feature fusion. It can acquire the crop image to be detected and perform size preprocessing to obtain the input image. A backbone feature extraction network is used to obtain five levels of input features from P3 to P7 (P3 has the highest spatial resolution, P7 the lowest). In the first round of bidirectional feature fusion network input preprocessing stage, the dual-scale selective kernel attention module is used to pre-enhance the P3 and P4 features. Then, at least one round of bidirectional feature fusion network is used to fuse the P3 to P7 features from top to bottom and bottom to top. The attention module is used to enhance the fused features in the P4, P3 top-down nodes, and P4 bottom-up nodes of each fusion round. Finally, based on the multi-scale fused features output in the last round, category recognition and location regression are performed. Furthermore, in the actual detection process, the system dynamically fuses feature information from different receptive fields at key fusion nodes through the dual-scale selective kernel attention module, effectively extracting and enhancing the multi-scale features of the crop target, enabling the network to adapt to seedling targets of different sizes simultaneously. Compared to existing feature fusion methods that use a single convolutional kernel and struggle to address the issue of inconsistent crop scales in UAV imagery, this embodiment introduces a dual-scale selective kernel attention mechanism at key locations in feature fusion. This mechanism enhances the expressive power of multi-scale features while maintaining computational efficiency. Consequently, users can directly obtain more accurate and robust detection results when performing crop target detection, thereby improving the accuracy and reliability of intelligent agricultural monitoring.
[0057] Based on the first embodiment, in the second embodiment, the content that is the same as or similar to that in Embodiment 1 above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2 , Figure 2 This is a flowchart of the second embodiment of the crop target detection method proposed in this application. Further, to improve the accuracy of crop target detection, the step of enhancing the corresponding fused features using the dual-scale selective kernel attention module includes: Step S41: Each fusion node in the bidirectional feature fusion network sets learnable scalar weights for each input feature, performs non-negation processing on the learnable scalar weights, and normalizes each learnable scalar weight according to the sum of the non-negation weights and a preset stability term to obtain normalized weights. Step S42: Perform a weighted summation on each of the input features according to the normalized weights, and sequentially perform non-linear activation, 3×3 depthwise convolution and 1×1 pointwise convolution on the weighted summation result; Step S43: In the P4 top-down fusion node, the P3 top-down fusion node and the P4 bottom-up fusion node, perform the dual-scale selective kernel attention enhancement after the 1×1 pointwise convolution and before the batch normalization.
[0058] It should be explained that the aforementioned learnable scalar weights can be numerical parameters that are continuously adjusted and updated through backpropagation during network training, used to control the contribution of different input features during fusion. The aforementioned nonnegativity processing can be an operation that constrains the weight values to non-negative numbers to ensure that the weights have physical meaning in the subsequent normalization process. The aforementioned preset stabilization term can be a pre-set minimal constant used to prevent the denominator from being zero during normalization. The aforementioned normalized weights can be the final weight values obtained after nonnegating and normalizing the learnable scalar weights, satisfying that the sum of the weights of each input feature is a fixed value. The aforementioned weighted summation can be an operation that multiplies multiple input features by their corresponding normalized weights and then adds them together. The aforementioned nonlinear activation can be an activation function that introduces a nonlinear transformation to enhance the network's expressive power. The aforementioned depthwise convolution can be a convolution method that executes the convolution operation independently for each channel of the input feature map. The aforementioned pointwise convolution can be a convolution operation with a kernel size of 1×1, used to integrate information from the channel dimensions of the feature map.
[0059] In its implementation, at each fusion node in the aforementioned bidirectional feature fusion network, the device assigns a learnable scalar weight to each input feature participating in the fusion at that node. During each forward computation round, the device first performs nonnegation processing on each of the learnable scalar weights, making all weight values non-negative. Then, the device calculates the sum of all nonnegated weight values and, based on this sum and a preset stabilization term, normalizes each learnable scalar weight, ensuring the sum of the normalized weights equals a fixed value. After obtaining the normalized weights, the device multiplies each input feature by its corresponding normalized weight and sums the products to obtain a weighted sum. Next, the device sequentially performs nonlinear activation processing and convolution operations on the weighted sum to further optimize the feature representation. When the above fusion operations are executed up to the P4 top-down fusion node, the P3 top-down fusion node, and the P4 bottom-up fusion node, after the device completes the processing sequence of nonlinear activation, depthwise convolution, and pointwise convolution, and before the batch normalization operation is executed, the fusion features output by the current node are sent to the dual-scale selective kernel attention module for enhancement processing.
[0060] Furthermore, the nonnegativity process employs the ReLU function, and the preset stable term is 10. -4 The nonlinear activation employs either the Swish or SiLU function; The scaling transformation in top-down fusion uses interpolation upsampling with a magnification factor of 2, where the interpolation upsampling is either nearest neighbor interpolation or bilinear interpolation; The scaling transformation in bottom-up fusion uses max pooling with a kernel size of 3×3 and a stride of 2.
[0061] It should be explained that the ReLU function mentioned above can be an activation function that sets all negative numbers in the input to zero and keeps positive numbers unchanged, with the mathematical form f(x) = max(0,x). The Swish function mentioned above can be a self-gated activation function, with the mathematical form f(x) = x·sigmoid(x). The SiLU function mentioned above is equivalent to the Swish function in implementation, also f(x) = x·sigmoid(x). The interpolation upsampling mentioned above can be an operation that increases the spatial resolution of the feature map by inserting new pixel values between adjacent pixels. The magnification factor of 2 means that the size of the output feature map in both the width and height directions is twice that of the input feature map. The nearest neighbor interpolation mentioned above can be a simple interpolation method that directly selects the pixel value closest to the target position as the interpolation result during upsampling. The bilinear interpolation mentioned above can be an interpolation method that uses the weighted average of the four nearest neighbor pixels around the target position to calculate the interpolation result during upsampling. The max pooling mentioned above can be a downsampling operation that selects the maximum value in a local region of the feature map as the output of that region.
[0062] In its implementation, the bidirectional feature fusion network uses the ReLU function as a non-negativity processing method when processing the learnable scalar weights of each fusion node. Values less than zero in the learnable scalar weights are set to zero, while values greater than or equal to zero remain unchanged. During the normalization process, a preset stabilizing term is used in the calculation. This term has a value of 10 to the power of negative fourth to prevent the denominator from approaching zero during normalization. After obtaining the weighted summation result, the device performs nonlinear activation using either the Swish function or the SiLU function. These two activation functions are functionally interchangeable, both used to introduce nonlinear transformations to enhance the network's expressive power.
[0063] In the aforementioned top-down fusion path, the device employs interpolation upsampling with a magnification factor of 2 when performing scale transformation. The device can choose either nearest-neighbor interpolation or bilinear interpolation as the specific implementation method for upsampling, depending on actual needs. Nearest-neighbor interpolation has lower computational cost and preserves the discreteness of features, while bilinear interpolation yields smoother interpolation results. Both interpolation methods can achieve magnification of the feature map space size.
[0064] In the aforementioned bottom-up fusion path, the device employs max pooling as a downsampling operation during scaling. In this max pooling operation, the device slides a pooling window with a 3×3 kernel size and a stride of 2 across the feature map. Each time, the maximum value within the area covered by the pooling window is selected as the value at the corresponding position in the output feature map, thereby reducing the size of the output feature map to half that of the input feature map in both width and height directions.
[0065] Based on the first and second embodiments, in the third embodiment, the content that is the same as or similar to that in Embodiments 1 and 2 above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 3 , Figure 3 This is a flowchart of the third embodiment of the crop target detection method proposed in this application. Further, the step of performing category recognition and location regression on the crop targets in the crop image to be detected to obtain the detection result includes: Step S51: Output several category prediction values for each anchor box through the classification network, and perform Sigmoid activation on each of the category prediction values to obtain the category information of the crop target in the crop image to be detected; Step S52: Output a preset number of bounding box regression parameters for each anchor box through the bounding box regression network, and obtain the location information of the crop target in the crop image to be detected based on each bounding box regression parameter; Step S53: Obtain the detection result of the crop target in the crop image to be detected based on the category information and the location information.
[0066] It should be explained that the anchor boxes mentioned above can be a predefined set of reference boxes with different sizes and aspect ratios at each spatial location on the feature map, used as initial references for target location regression. The category prediction values mentioned above can be numerical values that quantify the probability that the target contained in each anchor box belongs to each category. The sigmoid activation mentioned above can be a non-linear activation function that maps input values to the interval between 0 and 1; the value obtained after sigmoid activation can be used to represent the probability that the target belongs to that category. The bounding box regression parameters mentioned above can be transformation parameters required to adjust the position of the anchor boxes, used to correct the anchor boxes into bounding boxes that more accurately surround the target object. The category information mentioned above can be data indicating the category to which the detected target belongs. The location information mentioned above can be data indicating the location of the detected target in the image, usually represented in the coordinates of the bounding box.
[0067] In its implementation, the device uses the P3 to P7 multi-scale fusion features output by the last round of the bidirectional feature fusion network to perform target detection at each spatial location on each feature layer. For each spatial location, the device pre-sets multiple anchor boxes. During category recognition, the device outputs several category prediction values for each anchor box through a classification network, the number of which equals the total number of preset crop categories. The device performs Sigmoid activation on each category prediction value, mapping each prediction value to a probability range of 0 to 1, thus obtaining the probability of each anchor box corresponding to each category. Based on these probabilities, the device determines the predicted target category of the anchor box, thereby obtaining the category information of the crop target in the crop image to be detected. During location regression, the device outputs a preset number of bounding box regression parameters for each anchor box through a bounding box regression network. Based on these bounding box regression parameters, the device transforms and adjusts the initial position and size of the anchor box, calculating the coordinate values of the predicted bounding box that can tightly surround the target crop, thereby obtaining the location information of the crop target in the crop image to be detected. The device integrates the category information and location information mentioned above to generate a complete detection result for each detected target, including category label and bounding box coordinates.
[0068] It should be emphasized that the classification network and the bounding box regression network each include four depthwise separable convolutional blocks arranged in sequence and one depthwise separable output convolutional block. Each depthwise separable convolutional block includes a 3×3 depthwise convolution, a 1×1 pointwise convolution, scale-corresponding batch normalization, and Swish activation. The convolutional parameters in the same network are shared between P3 and P7, and different scales use mutually independent batch normalization parameters.
[0069] It should be explained that the aforementioned depthwise separable convolutional block can be a convolutional module that decomposes standard convolution into two independent steps: depthwise convolution and pointwise convolution. It reduces computational complexity by performing spatial convolution and channel convolution separately. The aforementioned depthwise separable output convolutional block can be a convolutional module located at the end of the depthwise separable convolutional block sequence, used to map intermediate features to the target output dimension. The aforementioned batch normalization can be an operation that standardizes each channel of the feature map, stabilizing the numerical distribution of each channel to accelerate network training and improve convergence stability. The aforementioned sharing can be achieved by using the same set of network parameters for computation on different feature layers, while the aforementioned independence can be achieved by using different network parameters for computation on different feature layers.
[0070] In its implementation, the classification network and the bounding box regression network described above share the same network structure. When constructing the classification network, the device sets it to consist of four sequentially connected depthwise separable convolutional blocks and a depthwise separable output convolutional block following these four blocks. The bounding box regression network also employs the same structural setup. Within each depthwise separable convolutional block, the device sequentially performs the following operations: extracting spatial features from the input features using a 3×3 depthwise convolution; integrating channel-dimensional information from the output of the depthwise convolution using a 1×1 pointwise convolution; performing batch normalization; and finally, applying the Swish activation function for non-linear mapping. The depthwise separable output convolutional block further convolves the outputs of the preceding four depthwise separable convolutional blocks, mapping them to the desired number of output channels. In the classification network, the device uses the same convolution parameters for the five feature layers P3 to P7, meaning it uses the same set of weights for both depthwise and pointwise convolutions on different feature layers. In the batch normalization operation, the device configures a set of independent batch normalization parameters for each feature layer from P3 to P7. The batch normalization parameters between feature layers are not shared to adapt to the differences in feature distribution at different scales.
[0071] Furthermore, nine preset anchor frames are set at each feature location from P3 to P7, and the nine preset anchor frames are composed of scale factors 1 and 2. (1 / 3) and 2 (2 / 3) It is formed by combining length-to-width ratios of 1:1, 2:1, and 1:2, with a basic anchor frame dimensional parameter of 4.
[0072] It should be explained that the aforementioned feature locations can be any spatial coordinate point on the feature map. The aforementioned preset anchor boxes can be a set of reference boxes with different sizes and aspect ratios predefined at each spatial location on the feature map, serving as the initial reference for subsequent target bounding box regression. The aforementioned scale coefficients can be scaling factors used to control the size of the anchor boxes. The aforementioned aspect ratio can be the ratio of the anchor box's width to its height. The aforementioned basic anchor box scale parameter can be a pre-set basic size value, which, when multiplied by each scale coefficient, yields anchor boxes of different sizes. Its specific value is related to the size of the input image and the downsampling factor of the backbone feature network.
[0073] In its implementation, the device sets nine preset anchor frames at each feature location across the five feature layers (P3 to P7). The size and shape of these nine preset anchor frames are determined by a combination of scale parameters and aspect ratio parameters. Specifically, the device uses three different scale coefficients and three different aspect ratios, combining them pairwise to obtain nine different anchor frame configurations. To determine the specific dimensions of each anchor frame, the device uses a pre-defined base anchor frame scale parameter, multiplying it by each scale coefficient to obtain the base dimension value of each anchor frame. Then, combining this with the corresponding aspect ratio, the width and height values of each anchor frame are calculated. Through this method, the device obtains nine preset anchor frames of varying sizes and shapes at each feature location.
[0074] To facilitate understanding, the following explanation uses examples, but does not impose specific limitations on this embodiment. For example, assume the above device is a ground station server. The server first acquires an aerial image of farmland recently transmitted by a drone, using EfficientNet-B0 as the backbone network (which can be replaced with EfficientNet-B1~B7 depending on accuracy requirements). The core building block is MBConv (moving inverse residual convolution), and the structure of MBConv is "1×1 convolution (dimensionality increase) → depthwise separable convolution (feature extraction) → BN (batch normalization) → Swish activation → 1×1 convolution (dimensionality reduction) → residual connection". Through the stacking of MBConv blocks, the backbone network outputs feature layers at three key scales: C3: Extracted by 4 MBConv blocks, with 40 channels and a resolution of 1 / 8 of the input image; C4: Extracted by 6 MBConv blocks, with 112 channels and a resolution of 1 / 16 of the input image; C5: Extracted from 8 MBConv blocks, with 320 channels and a resolution of 1 / 32 of the input image; Assuming the input image is The features extracted by EfficientNet are:
[0075] in It is a feature extraction function consisting of k MBConv blocks.
[0076] Subsequently, assuming the original number of channels is 320, the device first adjusts the number of channels of this feature to 64 using a 1×1 convolution. Then, the device simultaneously feeds the adjusted 64-channel feature into two convolutional branches: Branch 1: 5×5 standard depth convolution (groups=dim, dim is the number of input feature channels), capturing medium-scale crop features (such as 15×15~30×30 pixel crops). Branch 2: 7×7 dilated depthwise convolution (dilation=3, groups=dim), with an equivalent receptive field of 7+(7-1)×(3-1)=19×19, captures large-scale / low-resolution crop features (such as 5×5~15×15 pixel crops); padding ensures that the output feature size is consistent with the input (5×5 convolution padding=2, 7×7 dilated convolution padding=9).
[0077] That is, assuming the input features of the DSKA module are ( The two-branch convolution process is as follows:
[0078] in This represents a depthwise separable convolution, where k is the kernel size, p is the padding, d is the dilation rate, and g is the number of groups.
[0079] A 1×1 convolution is used to reduce the number of channels in A1 and A2 from dim to dim / 2. The dimensionality-reduced bi-branch features are then concatenated along the channel dimension to restore the current number of channels to dim. Spatial information is aggregated using global mean pooling and global max pooling to generate two single-channel features. These are then activated using a 7×7 convolution (padding=3) and a sigmoid activation function to generate attention weights at two scales (corresponding to the bi-branch features). This can be further explained using mathematical formulas.
[0080] Where S=[s1,s2], (s1,s2) are the attention weights of A1' and A2', respectively.
[0081] The dual-branch dimensionality-reduced features are weighted and summed using attention weights, then restored to the original number of channels using a 1×1 convolution. Finally, element-wise multiplication is performed with the input feature X to enhance key crop features. This can be further explained using mathematical formulas.
[0082] Where Y represents the output enhancement feature of the DSKA module.
[0083] This embodiment adopts the DSKA-BiFPN architecture. Based on the traditional BiFPN, a DSKA module is embedded after the channel downsampling module. The specific process is divided into three parts: "feature preprocessing", "upsampling fusion (top-down)" and "downsampling fusion (bottom-up)". Channel adjustment is performed on C3, C4, and C5 output from the backbone network (unified to N channels, N=64), and enhanced through the DSKA module;
[0084] in( , ) represents the original skip connection feature, used to preserve detailed information about the backbone network. This refers to the two-branch convolution process mentioned in the previous example.
[0085] Upsampling fusion (top-down, conveying high semantic information) starts from the lowest resolution feature layer P7_in, and fuses it with the next layer's features through bilinear interpolation upsampling (scale=2). During fusion, learnable attention weights (wij) are introduced to dynamically adjust the contribution of each feature. Finally, features are optimized using a 1×1 convolution and the Swish activation function. As shown below: ; ; ; ; Where wij represents the learnable attention weights. Upsampling (scale=2) To prevent tiny values from being divided by zero.
[0086] Downsampling fusion (bottom-up, passing high-resolution details) starts from the highest resolution feature layer P3_up, and fuses with the features of the previous layer through 3×3 max pooling downsampling (stride=2). During fusion, the original skip connection features and upsampling fused features are introduced at the same time to further enhance the detail information.
[0087] ; ; ; ; in This is for downsampling (max pooling, kernel=3, stride=2).
[0088] The DSKA-BiFPN outputs five feature layers: P3_up (1 / 8 resolution), P4_down (1 / 16 resolution), P5_down (1 / 32 resolution), P6_down (1 / 64 resolution), and P7_down (1 / 128 resolution). Each feature layer corresponds to a detector head, which consists of two 3×3 convolutions and one 1×1 convolution. Classification Header: Predicts the crop category probability for each anchor frame (this embodiment supports 3 crop categories, so the number of output channels = 3 × A, where A is the number of anchor frames, and in this embodiment A = 9). Regression head: Predicts the bounding box offset for each anchor box (output channel number = 4 × A, 4 corresponds to the x, y, w, h offsets of the bounding box).
[0089] Let the k-th feature layer be ( The output of the detection head is:
[0090] Where K is the number of categories, A is the number of anchor boxes at each location, and the detection results are finally output through non-maximum suppression (NMS).
[0091] refer to Figure 4 , Figure 4 This is a system example block diagram of the crop target detection method proposed in this application. For ease of understanding, the following is illustrated by examples, but it does not limit the scope of this embodiment. Figure 4 As shown, the input is first the original plant scene image on the left, and then it enters the backbone network composed of 5 MBConv modules connected in series. Each MBConv module performs Batchnorm, Conv1x1, Batchnorm+gelu activation, DepthwiseConv3x3 depthwise separable convolution, Batchnorm+gelu activation, and Conv1x1 in sequence, and realizes feature reuse through residual connections. Finally, it outputs multi-scale basic feature maps (P3_0, P4_0, P5_0, P6_0, P7_0).
[0092] These feature maps enter the Neck Feature Fusion Module, which incorporates a self-developed DSKA dual-branch feature enhancement module. The input to DSKA is a feature map at a certain scale (PX_X). The upper branch captures locally dense features through Conv5x5, Conv1x1, and Avgpool, while the lower branch expands the receptive field to obtain globally sparse features through DilatedConv7x7 (dilated convolution), Conv1x1, and Maxpool. The dual-branch features are concatenated and then output as an enhanced feature map (PX_X+1) through a 1×1 convolution. The right side shows the intermediate visualization results of the DSKA module, including an "RGBProcessedImage (LSKModule)" and a multi-channel feature heatmap.
[0093] In Neck, after multiple rounds of feature fusion and DSKA enhancement, five enhanced feature maps, P3_6, P4_6, P5_6, P6_6, and P7_6, are generated. These maps are then fed in parallel into two branches of the Head detection head: the classification branch (ClassInfo) predicts the target category through two convolutional layers, and the localization branch (LocationInfo) predicts the bounding box coordinates through two convolutional layers. Finally, the output is a plant detection result image with green detection boxes and category labels.
[0094] refer to Figure 5 , Figure 5 This diagram illustrates the ablation experiment results in the crop target detection method proposed in this application. To systematically verify the performance improvement effect of the proposed DSKA module on the model, this embodiment designed a controlled variable ablation experiment. Using the ORI model without an additional attention mechanism as the baseline, the DSKA module was compared with the classic ECA and SE channel attention modules. The experimental results are as follows: Figure 5As shown. To reveal the differences in the roles of different modules from the feature representation level, the quantitative indicators validated results in line with the qualitative analysis: In terms of the mean precision of the core evaluation indicator, the DSKA model significantly outperformed ECA (91.96%), SE (91.53%), and ORI (91.11%) with a precision of 92.75%, representing improvements of 0.79, 1.22, and 1.64 percentage points, respectively; in terms of accuracy, the DSKA model achieved 90.92%, showing varying degrees of improvement over other comparative models, demonstrating superior target recognition accuracy. Regarding the F1 score, the DSKA model was on par with the ORI model (0.88) and higher than ECA (0.83) and SE (0.86), indicating a good balance between recall and precision. Notably, the DSKA model's FPS was 19.10, slightly lower than ECA (19.73) and ORI (19.73), but within the same order of magnitude, indicating no significant loss in inference efficiency. The combined qualitative and quantitative experimental results show that the DSKA module can effectively improve the model's feature extraction capability and recognition performance, and has good efficiency compatibility.
[0095] This embodiment also provides a first embodiment of a crop target detection device, please refer to... Figure 6 , Figure 6 This is a diagram of a crop target detection device provided in an embodiment of this application. The crop target detection device includes: The image processing module is used to acquire the image of the crop to be detected and to perform size preprocessing on the image of the crop to be detected to obtain an input image of a preset input size; The feature extraction module is used to input the input image into a pre-constructed backbone feature extraction network, extract backbone features with different spatial resolutions, and construct five levels of input features, sequentially labeled P3 to P7, based on the backbone features, where P3 features have the highest spatial resolution and P7 features have the lowest spatial resolution. The feature enhancement module is used to pre-enhance the P3 input features and P4 input features respectively in the input preprocessing stage of the first round of bidirectional feature fusion network using a dual-scale selective kernel attention module. The feature fusion module is used to perform top-down and bottom-up fusion of features P3 to P7 using at least one round of bidirectional feature fusion network, and to enhance the corresponding fused features using the dual-scale selective kernel attention module in the P4 top-down fusion node, P3 top-down fusion node and P4 bottom-up fusion node of each round of bidirectional feature fusion network. The result detection module is used to perform category recognition and location regression on crop targets in the crop image to be detected based on the P3 to P7 multi-scale fusion features output by the last round of bidirectional feature fusion network, and obtain the detection result.
[0096] The crop target detection device provided in this embodiment employs the crop target detection method described in the above embodiments, and can solve the technical problems mentioned above. Compared with the prior art, the beneficial effects of the crop target detection device provided in this embodiment are the same as those of the crop target detection method provided in the above embodiments, and other technical features in the crop target detection device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0097] This embodiment provides a crop target detection 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 crop target detection method in the first embodiment described above.
[0098] The following is for reference. Figure 7 , Figure 7 This is a schematic diagram of the structure of a crop target detection device suitable for implementing the embodiments of this application. The crop target detection 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), and PADs (Portable Application Description), as well as fixed terminals such as digital TVs and desktop computers. Figure 7 The crop target detection 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.
[0099] like Figure 7As shown, the crop target detection device may include a processing unit 1001 (e.g., an AIoT SoC K230 series chip). The K230 series chip integrates dual RISC-V processor cores and a KPU neural network acceleration unit, providing neural network inference capabilities and supporting image processing-related hardware acceleration functions as well as various peripheral interfaces, meeting the functional requirements of image acquisition, target detection, data processing, and communication. The processing unit 1001 can perform various actions and processes according to programs stored in read-only memory (ROM) 1002 or programs loaded from storage device 1003 into random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the crop target detection device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An 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, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the crop target detection equipment to communicate wirelessly or wiredly with other devices to exchange data. Although crop target detection equipment with various systems is shown in the figure, 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.
[0100] Specifically, according to this embodiment, the process described above with reference to the flowchart can be implemented as a computer software program. For example, this embodiment includes 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 flowchart. In such an embodiment, 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 disclosed embodiments of this embodiment.
[0101] The crop target detection device provided in this embodiment, employing the crop target detection method described in the above embodiments, can solve the technical problem of how to improve the accuracy of crop target detection. Compared with the prior art, the beneficial effects of the crop target detection device provided in this embodiment are the same as those of the crop target detection method described in the above embodiments, and other technical features of this crop target detection device are the same as those disclosed in the method of the previous embodiment, and will not be repeated here.
[0102] It should be understood that the various parts disclosed in this embodiment 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.
[0103] The above description is merely a specific implementation of this embodiment, but the protection scope of this embodiment is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this embodiment should be included within the protection scope of this embodiment. Therefore, the protection scope of this embodiment should be determined by the protection scope of the claims.
[0104] This embodiment provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, which are used to execute the crop target detection method in the above embodiment.
[0105] The computer-readable storage medium provided in this embodiment 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 with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), 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.
[0106] The aforementioned computer-readable storage medium may be included in the crop target detection device; or it may exist independently and not be assembled into the crop target detection device.
[0107] The aforementioned computer-readable storage medium carries one or more programs, which, when executed by the crop target detection device, cause the crop target detection device to perform crop target detection.
[0108] Computer program code for performing the operations of this embodiment can be written in one or more programming languages or a combination thereof. These programming languages include object-oriented programming languages—such as Java, Smalltalk, and C++—and 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 a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0109] 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 embodiment. 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 the 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.
[0110] The modules described in this embodiment can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0111] The readable storage medium provided in this embodiment is a computer-readable storage medium, which stores computer-readable program instructions (i.e., a computer program) for executing the above-described crop target detection method, and can solve the technical problem of how to improve the accuracy of crop target detection. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this embodiment are the same as the beneficial effects of the crop target detection method provided in the above embodiments, and will not be repeated here.
[0112] The above descriptions are only some embodiments and do not limit the patent scope of this embodiment. All equivalent structural transformations made based on the technical concept of this application and the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included within the patent protection scope of this application.
Claims
1. A method for detecting crop targets, characterized in that, The method includes: Acquire an image of the crop to be detected, and perform size preprocessing on the image to be detected to obtain an input image with a preset input size; The input image is fed into a pre-constructed backbone feature extraction network to extract backbone features with different spatial resolutions. Based on the backbone features, five levels of input features are constructed, which are sequentially labeled P3 to P7. Among them, the spatial resolution of the P3 feature is the highest and the spatial resolution of the P7 feature is the lowest. In the input preprocessing stage of the first-round bidirectional feature fusion network, the P3 input features and P4 input features are pre-enhanced using a dual-scale selective kernel attention module. Using at least one round of bidirectional feature fusion network, top-down and bottom-up fusion are performed on features P3 to P7. In each round of bidirectional feature fusion network, the corresponding fused features are enhanced using the dual-scale selective kernel attention module. Based on the P3 to P7 multi-scale fusion features output by the last round of bidirectional feature fusion network, the crop targets in the crop image to be detected are classified and their positions are regressed to obtain the detection results. The dual-scale selective kernel attention module performs the following enhancement operations on the input features: Perform a first-scale convolution on the input features to obtain the first-scale features; The first-scale feature is further processed by the second-scale convolution to obtain the second-scale feature. The effective receptive field of the second-scale convolution is larger than that of the first-scale convolution. The first scale feature and the second scale feature are respectively adjusted by channel, and the first scale feature and the second scale feature after channel adjustment are concatenated in the channel dimension to obtain the concatenated feature; The average feature and the maximum feature are calculated along the channel dimension of the splicing feature, and spatial attention weights corresponding to the first scale feature and the second scale feature are generated according to the average feature and the maximum feature, respectively. Based on the spatial attention weights, the first-scale features and the second-scale features after channel adjustment are weighted and summed, and the result of the weighted sum is restored to the number of channels of the input features. The features after restoring the number of channels are multiplied element-wise with the input features to obtain the enhanced output features.
2. The method as described in claim 1, characterized in that, In the dual-scale selective kernel attention module, the first-scale convolution is a depthwise convolution with a kernel size of 5×5, a stride of 1, and padding of 2. The second-scale convolution is a depthwise convolution with a kernel size of 7×7, a stride of 1, an inflation rate of 3, and a padding of 9. The first scale feature and the second scale feature are each reduced to half the number of input feature channels through 1×1 convolution; The average feature and the maximum feature are concatenated and then used to generate two spatial attention weights through a convolution with a kernel size of 7×7, padding of 3, and output channels of 2, followed by Sigmoid activation.
3. The method as described in claim 1, characterized in that, The backbone features include three backbone features sequentially labeled C3, C4, and C5. The step of constructing five levels of input features, sequentially labeled P3 to P7, based on the backbone features includes: Channel adjustments were performed on C3, C4, and C5 respectively to obtain input features P3, P4, and P5; The channel-adjusted C5 backbone features are subjected to max pooling with a kernel size of 3×3 and a stride of 2 to obtain the P6 input features. Max pooling with a kernel size of 3×3 and a stride of 2 is performed again on the input features of P6 to obtain the input features of P7.
4. The method as described in claim 1, characterized in that, The step of enhancing the corresponding fused features using the dual-scale selective kernel attention module includes: In the bidirectional feature fusion network, each fusion node sets a learnable scalar weight for each input feature, performs non-negation processing on the learnable scalar weight, and normalizes each learnable scalar weight according to the sum of the non-negation weights and a preset stability term to obtain normalized weights. The input features are weighted and summed according to the normalized weights, and the weighted summation result is then subjected to nonlinear activation, 3×3 depthwise convolution and 1×1 pointwise convolution in sequence. In the P4 top-down fusion node, the P3 top-down fusion node, and the P4 bottom-up fusion node, the dual-scale selective kernel attention enhancement is performed after the 1×1 pointwise convolution and before the batch normalization.
5. The method as described in claim 4, characterized in that, The nonnegativity processing uses the ReLU function, the preset stability term is 10⁻⁴, and the nonlinear activation uses the Swish or SiLU function; The scaling transformation in top-down fusion uses interpolation upsampling with a magnification factor of 2, where the interpolation upsampling is either nearest neighbor interpolation or bilinear interpolation; The scaling transformation in bottom-up fusion uses max pooling with a kernel size of 3×3 and a stride of 2.
6. The method as described in claim 1, characterized in that, The step of performing category recognition and location regression on the crop targets in the crop image to be detected to obtain the detection result includes: The classification network outputs several category prediction values for each anchor box, and performs Sigmoid activation on each of the category prediction values to obtain the category information of the crop target in the crop image to be detected. A bounding box regression network outputs a preset number of bounding box regression parameters for each anchor box, and the location information of the crop target in the crop image to be detected is obtained based on the bounding box regression parameters. The detection result of the crop target in the crop image to be detected is obtained based on the category information and the location information; The classification network and the bounding box regression network each include four depthwise separable convolutional blocks arranged sequentially and one depthwise separable output convolutional block. Each depthwise separable convolutional block includes a 3×3 depthwise convolution, a 1×1 pointwise convolution, a scale-corresponding batch normalization, and a Swish activation. The convolutional parameters in the same network are shared between P3 and P7, and different scales use mutually independent batch normalization parameters.
7. The method as described in claim 6, characterized in that, Nine preset anchor frames are set at each feature location from P3 to P7, and the nine preset anchor frames are composed of scale factors 1 and 2. (1 / 3) and 2 (2 / 3) It is formed by combining length-to-width ratios of 1:1, 2:1, and 1:2, with a basic anchor frame dimensional parameter of 4.
8. A crop target detection device, characterized in that, The device includes: The image processing module is used to acquire the image of the crop to be detected and to perform size preprocessing on the image of the crop to be detected to obtain an input image of a preset input size; The feature extraction module is used to input the input image into a pre-constructed backbone feature extraction network, extract backbone features with different spatial resolutions, and construct five levels of input features, sequentially labeled P3 to P7, based on the backbone features, where P3 features have the highest spatial resolution and P7 features have the lowest spatial resolution. The feature enhancement module is used to pre-enhance the P3 input features and P4 input features respectively in the input preprocessing stage of the first round of bidirectional feature fusion network using a dual-scale selective kernel attention module. The feature fusion module is used to perform top-down and bottom-up fusion of features P3 to P7 using at least one round of bidirectional feature fusion network, and to enhance the corresponding fused features using the dual-scale selective kernel attention module in the P4 top-down fusion node, P3 top-down fusion node and P4 bottom-up fusion node of each round of bidirectional feature fusion network. The result detection module is used to perform category recognition and location regression on crop targets in the crop image to be detected based on the P3 to P7 multi-scale fusion features output by the last round of bidirectional feature fusion network, and obtain the detection result.
9. A crop target detection device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the crop target detection method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the crop target detection method according to any one of claims 1 to 7.
