Target detection method, system, electronic device, and medium

CN122597932APending Publication Date: 2026-08-18ANHUI AGRICULTURAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610742845.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-27
Publication Date
2026-08-18

AI Technical Summary

Technical Problem

[0003]然而,采用这种方式,通常采用单一尺度特征提取或简单的特征叠加方式完成特征处理,最终基于融合特征完成检测,仅可以对特征进行单次或有限次的基础融合,会造成在枝叶遮挡、果实密集的场景中,特征表征能力不足,容易出现漏检、误检的问题,导致在真实果园场景中检测准确率低下

Benefits of technology

本申请实施例中,提供一种目标检测方法,通过获取待检测的目标图像;对所述目标图像进行预处理,得到所述目标图像对应的图像张量;利用训练后的目标检测模型中的特征融合模块,对所述图像张量在通道维度上进行迭代多次的融合处理,得到所述目标图像对应的多个第一融合特征;其中,所述第一融合特征为融合所述目标图像中果实的局部特征信息以及所述目标图像中果实与枝叶的相对位置信息的特征;不同的所述第一融合特征的空间尺寸不同;利用所述目标检测模型中的特征金字塔网络,对多个所述第一融合特征在空间维度上进行多尺度融合处理,得到所述目标图像对应的第二融合特征;其中,所述第二融合特征为融合所述目标图像中果实的空间位置信息的特征;基于所述第二融合特征,得到在所述目标图像中检测到的果实对象的类别与位置信息。这样,通过在通道维度上对图像张量进行迭代多次的融合处理,能够充分提取并深度融合果实局部特征信息以及果实与枝叶的相对位置信息,增强对遮挡、密集果实场景的特征表达能力,避免相关技术中因特征融合单一、表征不足而导致的漏检、误检问题,可以提高果实检测的准确性;以及通过采用通道迭代融合与空间多尺度融合结合的特征提取方式,能够精准聚焦果实的局部细节特征、果枝相对位置信息以及空间位置信息,有效过滤枝叶、光照、复杂背景带来的干扰,使特征表达更贴合果实检测任务需求,进一步提高检测结果的准确性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122597932A_ABST
    Figure CN122597932A_ABST
Patent Text Reader

Abstract

This application discloses a target detection method, system, electronic device, and medium. It includes: acquiring a target image to be detected; preprocessing the target image to obtain an image tensor corresponding to the target image; using a feature fusion module in a trained target detection model to iteratively fuse the image tensor multiple times along the channel dimension to obtain multiple first fusion features corresponding to the target image; wherein the first fusion features are features that fuse local feature information of fruit in the target image and the relative position information of fruit and branches in the target image; using a feature pyramid network in the target detection model to perform multi-scale fusion processing on the multiple first fusion features along the spatial dimension to obtain second fusion features corresponding to the target image; and based on the second fusion features, obtaining the category and location information of the fruit object detected in the target image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to, but is not limited to, the field of image detection technology, and in particular to a target detection method, system, electronic device, and medium. Background Technology

[0002] With the rapid development of smart agriculture, deep learning-based fruit target detection technology has been widely applied in scenarios such as automated orchard harvesting, yield estimation, and growth status monitoring. In existing technologies, fruit target detection typically involves first acquiring an image of the orchard scene to be detected, performing preprocessing such as scaling and normalization, extracting image features through a convolutional neural network, and then outputting the fruit's category and location information through feature fusion and prediction.

[0003] However, this approach typically employs single-scale feature extraction or simple feature overlay to complete feature processing, and ultimately performs detection based on fused features. This approach can only perform basic fusion of features once or a limited number of times, which can lead to insufficient feature representation capabilities in scenarios with foliage obstruction and dense fruit, resulting in missed detections and false detections, and ultimately low detection accuracy in real orchard scenarios. Summary of the Invention

[0004] This application provides at least one target detection method, system, electronic device, and medium.

[0005] The technical solution of this application embodiment is implemented as follows: On one hand, embodiments of this application provide a target detection method, the method comprising: acquiring a target image to be detected; preprocessing the target image to obtain an image tensor corresponding to the target image; using a feature fusion module in a trained target detection model to perform iterative fusion processing on the image tensor in the channel dimension to obtain multiple first fusion features corresponding to the target image; wherein, the first fusion features are features that fuse local feature information of fruit in the target image and relative position information of fruit and branches in the target image; different first fusion features have different spatial dimensions; using a feature pyramid network in the target detection model to perform multi-scale fusion processing on the multiple first fusion features in the spatial dimension to obtain a second fusion feature corresponding to the target image; wherein, the second fusion feature is a feature that fuses spatial position information of fruit in the target image; based on the second fusion feature, obtaining the category and position information of the fruit object detected in the target image.

[0006] Secondly, embodiments of this application provide a target detection system, the system comprising: an input processing module, a feature fusion module, a feature pyramid network, and a detection module, wherein the input processing module is used to acquire a target image to be detected; preprocess the target image to obtain an image tensor corresponding to the target image; the feature fusion module is used to perform iterative fusion processing on the image tensor in the channel dimension multiple times to obtain multiple first fusion features corresponding to the target image; wherein the first fusion features are features that fuse local feature information of fruit in the target image and relative position information of fruit and branches in the target image; different first fusion features have different spatial dimensions; the feature pyramid network is used to perform multi-scale fusion processing on multiple first fusion features in the spatial dimension to obtain a second fusion feature corresponding to the target image; wherein the second fusion feature is a feature that fuses spatial position information of fruit in the target image; the detection module is used to obtain the category and position information of the fruit object detected in the target image based on the second fusion feature.

[0007] Thirdly, embodiments of this application provide an electronic device, which includes the method provided in the first aspect of embodiments of this application.

[0008] Fourthly, embodiments of this application provide a computer storage medium storing executable instructions, wherein when the executable instructions are executed by a processor, the processor executes the method provided in the first aspect of embodiments of this application.

[0009] Fifthly, embodiments of this application provide a computer program product, including a computer program or instructions, which, when executed by a processor, implement the method provided in the first aspect of embodiments of this application.

[0010] The beneficial effects of this application are: This application provides a target detection method, which involves acquiring a target image to be detected; preprocessing the target image to obtain an image tensor corresponding to the target image; using a feature fusion module in a trained target detection model to iteratively fuse the image tensor multiple times along the channel dimension to obtain multiple first fusion features corresponding to the target image; wherein, the first fusion features are features that fuse local feature information of fruit in the target image and the relative position information of fruit and branches in the target image; different first fusion features have different spatial dimensions; using a feature pyramid network in the target detection model to perform multi-scale fusion processing on the multiple first fusion features along the spatial dimension to obtain a second fusion feature corresponding to the target image; wherein, the second fusion feature is a feature that fuses the spatial position information of fruit in the target image; based on the second fusion feature, the category and position information of the fruit object detected in the target image are obtained. In this way, by iteratively fusing the image tensor multiple times along the channel dimension, the local feature information of the fruit and the relative position information of the fruit and branches can be fully extracted and deeply fused. This enhances the feature representation ability for scenes with occlusion and dense fruit, avoiding the problems of missed detection and false detection caused by single feature fusion and insufficient representation in related technologies, thus improving the accuracy of fruit detection. Furthermore, by adopting a feature extraction method that combines channel iterative fusion and spatial multi-scale fusion, the local detail features of the fruit, the relative position information of the fruit and branches, and spatial position information can be accurately focused. This effectively filters out interference from branches, lighting, and complex backgrounds, making the feature representation more in line with the needs of the fruit detection task and further improving the accuracy of the detection results.

[0011] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of this application. Attached Figure Description

[0012] Figure 1 This is a schematic diagram illustrating the implementation process of a target detection method provided in an embodiment of this application; Figure 2 This is a schematic diagram of a feature fusion module provided in an embodiment of this application; Figure 3 This is a schematic diagram illustrating the difference between the source domain channel response and the accumulated target domain statistical data provided in an embodiment of this application; Figure 4 This is a schematic diagram of the execution flow of a second domain adaptation module provided in an embodiment of this application; Figure 5 This is a schematic diagram of the composition structure of a target detection system provided in an embodiment of this application; Figure 6This is a schematic diagram of the hardware entity of an electronic device provided in the embodiments of this application; Figure 7 This is a schematic diagram of an image sample provided in an embodiment of this application; Figure 8 This is a schematic diagram of a candidate bounding box and a true bounding box provided in an embodiment of this application; Figure 9 This is a schematic diagram of the operation interface of a target detection system provided in an embodiment of this application; Figure 10 This is a schematic diagram of the detection results for a different environmental scenario provided in the embodiments of this application.

[0013] It should be noted that the terms "first" and "second" mentioned above are only used to distinguish between different options and do not represent the degree of superiority or inferiority of the options or their priority in the implementation process. Detailed Implementation

[0014] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application are further described in detail below with reference to the accompanying drawings and embodiments. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0015] In the following description, references to "some embodiments" are made, which describe a subset of all possible embodiments. However, it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict. The terms "first / second / third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first / second / third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0016] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. The terminology used herein is for descriptive purposes only and is not intended to limit the scope of this application.

[0017] Currently, with the continuous development of smart agriculture and intelligent equipment technology, deep learning-based visual inspection technology has become a core supporting technology for automated orchard harvesting, accurate yield estimation, fruit tree growth monitoring, and quality grading. In this technology, images of the orchard scene to be inspected are typically acquired first. These images undergo preprocessing operations such as scaling and pixel normalization to convert them into image tensors that can be processed by deep learning models. Then, a convolutional neural network is used as the backbone network for feature extraction to complete image feature extraction. Subsequently, a simple feature fusion structure is used to integrate the extracted features, and finally, the detection and prediction head outputs the category and location coordinates of the fruit target.

[0018] These detection methods can achieve certain detection results in ideal environments with sufficient lighting, simple backgrounds, and unobstructed fruit. However, they have significant limitations in real-world, complex orchard environments. Because existing technologies generally employ single-scale feature extraction or rely solely on simple feature stitching and weighted overlay, they can only perform basic fusion of image features once or a limited number of times. This makes it difficult to fully explore key features such as the local texture and contour details of the fruit, and also fails to effectively model the relative positional relationship between the fruit and surrounding branches and leaves. Consequently, in real-world orchard scenarios with severe foliage occlusion, dense fruit distribution, and significant differences in target scale, the model's feature representation ability is significantly insufficient, leading to a substantial decrease in target discrimination ability. This results in frequent problems such as missed fruit detection, false background detection, and positioning errors, making it difficult to meet the accuracy requirements of actual agricultural production.

[0019] To address the aforementioned issues, this application proposes a target detection method, system, electronic device, and medium. By iteratively fusing the image tensor multiple times along the channel dimension, it is possible to fully extract and deeply fuse local fruit features and the relative position information of the fruit and branches, enhancing the feature representation capability for occluded and densely fruited scenes. This avoids the missed detection and false detection problems caused by single feature fusion and insufficient representation in related technologies, thereby improving the accuracy of fruit detection. Furthermore, by employing a feature extraction method that combines channel iterative fusion with spatial multi-scale fusion, it is possible to accurately focus on the local detailed features of the fruit, the relative position information of the fruit and branches, and spatial position information, effectively filtering out interference from branches, lighting, and complex backgrounds. This makes the feature representation more aligned with the needs of the fruit detection task, further improving the accuracy of the detection results.

[0020] Figure 1 This is a schematic diagram illustrating the implementation flow of a target detection method provided in an embodiment of this application. The following will be combined with... Figure 1 The steps shown are explained below. It should be noted that, for example... Figure 1 As shown, the method includes the following steps S101 to S105: Step S101: Obtain the target image to be detected.

[0021] The target image may include, but is not limited to, real-time images of the orchard, real-time images collected by the picking robot, aerial images taken by drones, video frames recorded by surveillance cameras, locally stored digital images, image data transmitted over the network, or image files that have undergone format conversion; the target image may contain various fruit targets such as pears, apples, and citrus, as well as orchard background information such as branches, leaves, trunks, and soil.

[0022] In this step, the orchard scene can be captured in real time or stored orchard image data can be read through image acquisition devices to obtain the target image to be detected, which contains the fruit target. The image can come from camera shooting, video frame capture, local image reading or cloud data transmission, etc., to provide the original data foundation for subsequent feature extraction and target detection.

[0023] Step S102: Preprocess the target image to obtain the image tensor corresponding to the target image.

[0024] In this embodiment, the image tensor can be a four-dimensional tensor after size scaling, pixel normalization, channel order adjustment, color gamut conversion, or padding. Specifically, it can be represented as a tensor format of batch number × channel number × height × width or batch number × height × width × channel number.

[0025] In practical implementation, the target images are uniformly scaled to a specified resolution according to the input requirements of the target detection model, and the image pixel values ​​are mapped to a standard numerical range of 0 to 1 or -1 to 1. At the same time, channel dimension adjustment and boundary filling are completed according to the data format supported by the model, so that target images acquired from different devices, different scenes and different sizes are all converted into standard image tensors with uniform format and consistent specifications. This can avoid interference from image format mismatch and scale inconsistency on subsequent feature extraction, channel iterative fusion and detection results, and can improve the detection accuracy of the target detection model.

[0026] Step S103: Using the feature fusion module in the trained target detection model, the image tensor is iteratively fused multiple times in the channel dimension to obtain multiple first fused features corresponding to the target image.

[0027] The first fusion feature is a feature that fuses the local feature information of the fruit in the target image and the relative position information of the fruit and branches in the target image; different first fusion features have different spatial dimensions.

[0028] In this embodiment, the feature fusion module in the trained target detection model may include a C3k2-BSD module, which is a dual-scale feature enhancement structure obtained by improving the C3k module in the YOLO11 framework.

[0029] Because natural orchard scenes commonly present problems such as foliage occlusion, dense fruit distribution, large differences in target scale, and cluttered backgrounds, relying solely on local fruit features can easily lead to feature loss due to occlusion, blurring, and overlap, resulting in missed detections and false detections. However, the relative positional information between fruits and branches constitutes stable contextual structure information, providing crucial discrimination criteria for the model when local features fail, effectively resisting occlusion and interference. Therefore, in this embodiment, the C3k2BSD module can be used to deeply fuse these two types of information at the channel dimension, enabling the first fused feature to possess both detail discrimination capability and spatial structure perception capability.

[0030] Specifically, the feature fusion module first performs channel expansion on the input image tensor using 1×1 pointwise convolution. Then, it employs two parallel depthwise separable convolutional branches to achieve dual-scale feature extraction. The 1×1 convolutional branch extracts fine-grained local channel features of the fruit, while the 3×3 convolutional branch captures the spatial context and relative position information between the fruit and the branches. After the two features are fused along the channel dimension, cross-channel information interaction is enhanced through the channel shuffling unit in the feature fusion module. Finally, a 1×1 pointwise convolution compresses the number of channels back to the original dimension, and the output is fused with the input image tensor via residual connections to obtain a first fused feature corresponding to the target image.

[0031] In this embodiment, multiple cascaded C3k2-BSD modules can be used to iteratively fuse the image tensor across multiple channel dimensions. Specifically, the first fusion feature output by the previous C3k2BSD module is used as the input feature of the next C3k2BSD module. Multiple rounds of dual-scale feature extraction, fusion, and enhancement operations across the channel dimensions are performed sequentially. After each level of feature extraction and iterative fusion, a first fusion feature corresponding to the receptive field and resolution is output, thereby forming multiple first fusion features with progressively decreasing spatial dimensions and progressively enhanced semantic information.

[0032] The first fusion feature at each level can retain the local fine-grained features of the fruit and the relative position information of the fruit, branches and leaves. It can effectively adapt to the complex situation in orchard scenes where the fruit is severely occluded, has large scale differences and is densely distributed, and improve the model's structural modeling ability and feature representation ability in complex environments.

[0033] Step S104: Using the feature pyramid network in the target detection model, multiple first fusion features are fused at multiple scales in the spatial dimension to obtain the second fusion features corresponding to the target image.

[0034] The second fusion feature is the feature that fuses the spatial location information of the fruit in the target image.

[0035] In this embodiment, the feature pyramid network in the target detection model can be a multi-scale feature fusion network adapted to the YOLO11 architecture, used to perform top-down information transmission and spatial dimension fusion of first fusion features with different spatial sizes and different semantic levels.

[0036] This feature pyramid network can receive first fusion features with progressively decreasing spatial size output from multiple cascaded C3k2-BSD modules. Through operations such as upsampling, feature concatenation, and convolution calibration, it complementarily fuses the spatial positioning information of high-resolution shallow features with the semantic discriminative information of low-resolution deep features, so that the fused features retain both fine-grained positional information and strong discriminative semantic information.

[0037] In practical implementation, the first fusion feature with low resolution and high semantic level can be upsampled to make its spatial size consistent with the adjacent high resolution and low level first fusion feature. Then, the upsampled feature is spliced ​​and fused with the high resolution first fusion feature in the channel dimension. The multi-scale feature fusion is completed step by step from top to bottom. The local features of the fruit, the relative position information of the fruit and branches and leaves, and the global spatial distribution information under different scales and different receptive fields are fully integrated to obtain the second fusion feature. The final second fusion feature can fully carry the size, position, distribution and spatial structure information of the fruit in the target image, which can improve the positioning accuracy and detection accuracy of the target detection model for fruits at different scales.

[0038] Step S105: Based on the second fusion feature, obtain the category and location information of the fruit objects detected in the target image.

[0039] In this embodiment, the second fused feature, which incorporates the spatial location information of the fruit, is first input into the detection head branch of the target detection model. The detection head is then used to perform category classification and bounding box regression prediction, outputting the coordinate information of multiple candidate bounding boxes, the confidence level of the fruit category, and the confidence level of the target presence. Subsequently, the coordinates of the candidate bounding boxes are decoded, and the feature map coordinates are restored to the original image size space of the target image. Target bounding boxes that meet the confidence requirements are selected according to a preset confidence threshold. Then, a non-maximum suppression algorithm is used to remove overlapping redundant bounding boxes, retaining the optimal target bounding box and its corresponding category information. Finally, the precise category and pixel-level location information of all fruit objects in the target image are output.

[0040] By employing the above technical solution, iterative fusion processing of image tensors along the channel dimension can fully extract and deeply fuse local fruit features and the relative position information of fruits and branches, enhancing the feature representation capability for occluded and densely packed fruit scenes. This avoids the problems of missed detection and false detection caused by single feature fusion and insufficient representation in related technologies, thus improving the accuracy of fruit detection. Furthermore, by using a feature extraction method that combines channel iterative fusion with spatial multi-scale fusion, it can accurately focus on the local detailed features of fruits, the relative position information of fruit branches, and spatial position information, effectively filtering out interference from branches, lighting, and complex backgrounds. This makes the feature representation more aligned with the needs of fruit detection tasks, further improving the accuracy of detection results.

[0041] In some embodiments, step S103 can be implemented by the following steps.

[0042] Step S1031: Input the image tensor into the feature extraction backbone network in the target detection model.

[0043] The feature extraction backbone network can be the native YOLO11 backbone network, which is composed of multiple cascaded convolutional basic modules and C3k2-BSD modules stacked together.

[0044] Step S1032: The image tensor is iteratively fused multiple times in the channel dimension by multiple cascaded feature fusion modules in the feature extraction backbone network to obtain multiple first fused features corresponding to the target image.

[0045] In this embodiment, the feature extraction backbone network can be configured with multiple cascaded C3k2-BSD feature fusion modules along the forward propagation direction of the network. The image tensors initially extracted by the shallow layer of the backbone network are sequentially input into each level of the feature fusion module. Each level of the feature fusion module independently performs dual-scale feature extraction, channel expansion, cross-channel information interaction, and residual fusion processing on the input features in the channel dimension, so as to progressively mine the local texture details of the fruit in the target image, as well as the relative positional context features between the fruit and the branches and leaves.

[0046] The first fused feature output by the previous feature fusion module can be directly used as the input data for the next feature fusion module, thereby completing multiple iterative channel fusions. The feature maps output by each feature fusion module have different spatial dimensions and receptive field sizes. Each level of feature simultaneously retains local fruit feature information and the relative position information of the fruit and branches, ultimately outputting multiple first fused features with different spatial dimensions.

[0047] By adopting the above technical solution, the basic feature extraction capabilities of the YOLO11 native backbone network can be utilized, combined with the multi-level cascaded C3k2-BSD module to perform iterative deep fusion in the channel dimension. This not only fully preserves the local fine-grained features such as the texture and contour of the fruit itself, but also effectively models the spatial positional relationship and contextual structure information between the fruit and the branches and leaves. At the same time, by generating first fusion features of multiple spatial dimensions through stepwise downsampling, the hierarchical expression of feature information under different receptive fields can be realized, enhancing the model's feature performance in complex orchard scenarios with branch and leaf occlusion, dense fruit, and varying scales, and reducing missed detections and false detections in the fruit detection process.

[0048] In some embodiments, each feature fusion module includes at least a first convolutional branch and a second convolutional branch in parallel.

[0049] The first convolutional branch is used to extract local feature information of the fruit in the target image based on the image tensor; the second convolutional branch is used to extract the relative position information of the fruit and branches in the target image based on the image tensor.

[0050] In this embodiment, multiple rounds of fusion processing operations can be performed based on multiple cascaded feature fusion modules to obtain intermediate fusion features output in each round; then, the intermediate fusion features output in multiple rounds can be used as multiple first fusion features corresponding to the target image.

[0051] The fusion processing operation is used in the feature fusion module of this round to fuse the local feature information extracted by the first convolution branch with the relative position information extracted by the second convolution branch in the channel dimension to generate the intermediate fused feature of the output of this round. The local feature information and relative position information are extracted from the intermediate fused feature determined in the previous round. The local feature information and relative position information extracted in the feature fusion module of the first round are extracted from the image tensor.

[0052] In actual implementation, such as Figure 2 As shown, the initial image tensor can be fed into the first-round feature fusion module. The first and second convolutional branches within this module independently extract local fruit features and the relative position information of the fruit and branches from the image tensor, respectively. Feature merging and information interaction are then performed at the channel dimension to generate the corresponding intermediate fusion features for the first round. These intermediate fusion features are then input into the next-level feature fusion module as the base input, and the dual-branch feature extraction and channel fusion process is repeated to obtain a new round of intermediate fusion features. This process is passed sequentially level by level, completing one round of channel-dimensional iterative fusion each time a feature fusion module is used. Each round of output intermediate fusion features possesses an independent spatial size and receptive field, and simultaneously carries both local fruit detail features and the relative positional association information between the fruit and branches.

[0053] By summarizing all the intermediate fusion features output after each round of iteration, multiple first fusion features with different spatial sizes and progressively deeper semantic levels can be formed. In this way, feature information can be strengthened and iteratively optimized layer by layer, while retaining the ability to express features at multiple scales. This can adapt to the detection needs of orchard scenes with fruit occlusion, dense distribution and large scale differences.

[0054] For example, each feature fusion module includes at least a first convolutional branch and a second convolutional branch in parallel. In this embodiment, these two branches are specifically implemented in the following way: The first convolutional branch can correspond to the 1×1 depthwise separable convolutional branch in the C3k2-BSD module. In this embodiment, for the input feature X (or the intermediate fused feature from the previous round in the iteration process), the channel dimension can first be reduced from C to X using a 1×1 pointwise convolution. in Expand to 2C in Subsequently, after batch normalization (BN) and the LeakyReLU activation function, extended features F are generated. exp1 Among them, the first extended feature F exp1 This can be achieved using the following formula (1): F exp1 =LeakyReLU(BN(Conv1×1(X))) Formula (1); The second convolutional branch corresponds to the 3×3 depthwise separable convolutional branch in the C3k2-BSD module. This branch receives the same extended feature F. exp1 As input, a second extended feature F is generated through a 3×3 depthwise convolution operation with a large receptive field. exp2 This captures the surrounding foliage structure and local spatial context. This branch is configured to extract the spatial interaction between the fruit and surrounding occlusions (foliage), i.e., the relative positional information of the fruit and foliage. The second extended feature F... exp2 This can be achieved using the following formula (2): F exp2 =LeakyReLU(BN(Conv3×3(X))) Formula (2); The first and second extended features output from the two branches can be summed element-wise to obtain the aggregate feature Fbs. The feature Fbs can be achieved using the following formula (3): Fbs=LeakyReLU(BN(Conv1×1(X)))+LeakyReLU(BN(Conv3×3(X))) Formula (3); To overcome the limitations of depthwise convolution in inter-channel information exchange, the aggregated feature Fb can be further enhanced by channel shuffling. Subsequently, 1×1 sequential convolution can be applied for batch normalization to restore the channel dimension to the original number of channels. Combined with the residual connection mechanism, the input of the module (i.e., the intermediate fusion feature determined in the previous round) is added to the processing result of the current module to obtain the first fusion feature of the final output of this round.

[0055] By employing the above technical solution, parallel dual convolutional branches can be set within each feature fusion module to achieve the separate extraction and channel fusion of local fruit features and the relative positional features of fruit branches and leaves. Simultaneously, multi-level cascaded feature fusion modules complete multiple rounds of iterative feature enhancement. On one hand, the first convolutional branch stably captures fine-grained local features such as fruit texture, contour, and shape, avoiding the loss of target features due to occlusion by branches and leaves. On the other hand, the second convolutional branch effectively models the spatial layout and neighborhood relationships of the fruit and surrounding branches and leaves, compensating for the insufficient discriminative ability of single local features in complex scenes. Through a serial iterative approach where the output features of the preceding stage are used as the input of the following stage, the semantic expression of features is deepened layer by layer, the receptive field is expanded layer by layer, and intermediate fusion features of different spatial sizes are generated step by step and used as the first fusion feature, achieving multi-scale and multi-level feature representation.

[0056] In some embodiments, step S104 can be implemented by the following steps.

[0057] Step S1041: Input multiple first fusion features with different spatial sizes into the feature pyramid network.

[0058] In this embodiment, the feature pyramid network adopts a combination of top-down structure and lateral connection. It receives multiple first fusion features with progressively decreasing resolution output by the backbone network. Through upsampling, feature concatenation, and convolution calibration operations, it deeply fuses the precise positioning information of high-resolution features with the high-level semantic information of low-resolution features.

[0059] It should be noted that the Feature Pyramid Network has an embedded Feature Space Correction (FSC) module. During the model training phase, the FSC module learns and adaptively aligns the feature distributions of different weather domains, and fits the feature mapping relationships and correction parameters for different scenarios such as sunny days, rainy days, foggy days, and low light.

[0060] During the inference detection phase, the target detection model can directly load the trained FSC module with fixed parameters to perform feature distribution correction and normalization mapping on the input first fusion feature. There is no need to relearn the inter-domain offset in real time; only forward inference correction operations are performed, thereby ensuring that the distribution of the input first fusion feature remains consistent under different weather conditions.

[0061] Step S1042: Through the feature pyramid network, multiple first fusion features are upsampled and feature concatenation operations are performed to fuse first fusion features of different scales in the spatial dimension to generate second fusion features.

[0062] In this embodiment, multiple first fusion features are subjected to multi-scale spatial fusion and scale alignment processing through the top-down structure and lateral connections of the feature pyramid network.

[0063] Specifically, the low-resolution, high-semantic-level first fusion feature is upsampled to ensure its spatial dimensions are consistent with the high-resolution, low-semantic-level first fusion feature of the adjacent layer. Furthermore, the feature distribution bias present during this process can be simultaneously corrected using trained FSC correction parameters. Subsequently, the upsampled feature is concatenated with the corresponding high-resolution first fusion feature along the channel dimension. Channel calibration and feature fusion are then performed using 1×1 pointwise convolution to eliminate semantic differences and spatial offsets between features of different scales, resulting in the generated second fusion feature.

[0064] By employing the above technical solution, multi-scale spatial fusion can integrate the first fusion features at different levels, preserving the accurate positioning information of shallow features while also taking into account the semantic discrimination ability of deep features. Furthermore, the FSC (Feature Space Correction) module can be used to correct feature offsets during inference by leveraging the feature mapping relationships learned during training for different weather domains. This ensures that the spatial location information of the fruit can be accurately captured regardless of the weather conditions (sunny / rainy, bright / dark environments) of the input image, avoiding positional judgment errors caused by imaging differences.

[0065] In some embodiments, step S105 can be implemented by the following steps.

[0066] Step S1051: Input the second fused feature into the detection head to obtain first prediction information including the coordinates of multiple candidate bounding boxes, category confidence, and target presence confidence.

[0067] In this embodiment, the detection head is an improved detection head adapted to the YOLO11 architecture, containing parallel bounding box regression branches and category classification branches for target prediction based on the second fused features. Specifically, during the model inference phase, the second fused features, which incorporate the global spatial location information of the fruit, are directly input into the detection head. Internally, the detection head simultaneously parses and predicts the features through parallel classification and regression branches. During the model training phase, before the features are input into the detection head, they undergo feature distribution correction via the first domain adaptation module (FSC), and adaptive modulation based on the frequency domain and texture is performed by the second domain adaptation module (CMM) to generate a more robust feature representation to weather changes before being fed into the detection head.

[0068] The category classification branch can use a fully connected layer and a softmax activation function. Based on the fruit semantic information and local features carried in the second fusion feature, it predicts the probability that each candidate target belongs to a preset fruit category, i.e., the category confidence score. For example, the confidence scores corresponding to specific categories such as crown pear and Dangshan pear range from 0 to 1. The higher the score, the higher the confidence score of the target belonging to the corresponding category.

[0069] The bounding box regression branch predicts the coordinate offset of candidate bounding boxes. This offset is a normalized value based on preset anchor points or grid centers, and after decoding, it corresponds to the pixel position of the target in the original image size, used to characterize the range of the candidate fruit target. Simultaneously, the detection head predicts the probability of any target existing at each candidate location (target presence confidence) through the target confidence branch, used for initial screening of valid candidate boxes and elimination of background candidate boxes without targets.

[0070] It should be noted that during the training phase, the optimization objective of the bounding box regression branch adopts WIoUv3 regression perceptual loss. This loss function reduces the negative impact of low-quality samples (such as severely occluded or blurred fruits) on model optimization through mechanisms such as dynamic gradient gain, thereby improving the model's localization stability and accuracy in complex weather scenarios. The specific calculation method of WIoUv3 loss is a well-known technique in the field, and its preset parameters (such as the scaling factor of gradient gain) can be set before training based on experience or validation set performance.

[0071] Step S1052: Decode the first prediction information and map the coordinates of the candidate bounding box to the original size space of the target image.

[0072] Decoding can refer to performing an inverse transformation on the original prediction vector output by the detection head (such as the YOLO11 detection head) to recover the actual position of the bounding box in the original image.

[0073] In this embodiment, a decoding operation can be performed on the first prediction information to map the coordinates of the candidate bounding box back to the original size space of the target image. That is, the normalized offset output by the detection head based on the feature map grid and the preset anchor box is converted into absolute pixel coordinates that can be directly used on the original input image.

[0074] Specifically, the parameters predicted by the detection head for each candidate bounding box typically include the offset (t_x, t_y) of the center point relative to its corresponding feature map grid and the scaling (t_w, t_h) of its width and height relative to the preset anchor box size (p_w, p_h). During decoding, the center point offset is first processed using the sigmoid function σ to obtain normalized coordinates, which are then added to the coordinates of the top-left corner of the grid (c_x, c_y) to calculate the center position (b_x, b_y) of the bounding box in the feature map space. Simultaneously, the width and height (b_w, b_h) of the bounding box in the feature map space are obtained by exponentiating the scaling and multiplying it by the anchor box size. Finally, by multiplying these coordinate values ​​(b_x, b_y, b_w, b_h) by the downsampling step size of the corresponding feature layer relative to the original image (e.g., 32, 16, or 8), the scale mapping from the feature map space to the pixel space of the original image is completed, and the bounding box coordinates (x_center, y_center, width, height) or its equivalent corner coordinates in the original image pixels are finally output.

[0075] Step S1053: Based on a preset confidence threshold, select a target bounding box from multiple candidate bounding boxes whose confidence level is not lower than the preset confidence threshold.

[0076] In some embodiments, a predefined confidence threshold, or one determined through validation set tuning, can be read first, and the target presence confidence of each candidate bounding box can be compared with this threshold one by one. Only candidate boxes with a confidence level greater than or equal to the threshold are retained and marked as target bounding boxes; candidate boxes with a confidence level lower than the threshold are considered background or noise predictions and are discarded at this stage. This reduces the number of candidate boxes requiring further processing and improves overall processing efficiency.

[0077] Step S1054: Remove redundant bounding boxes that overlap with each other in the target bounding box to obtain the final category and location information of one or more fruit objects in the target image.

[0078] In this embodiment, all target bounding boxes are first sorted in descending order according to the target existence confidence. The bounding box with the highest confidence is selected as the current best prediction and added to the final output list. Then, the intersection-union ratio (IoU) between the best box and all remaining boxes is calculated. If the IoU value between a remaining box and the best box exceeds a preset overlap threshold, it is determined that the two boxes detect the same target, and the redundant box is suppressed (i.e. removed from the candidate list).

[0079] The process of selecting the optimal bounding box and suppressing redundancy can be repeated in the remaining bounding boxes until all boxes have been processed. Finally, a list of detection results can be output, where each entry corresponds to the final category and location information of a fruit object, thus ensuring that each fruit is labeled only once and that its location and category identifiers have the highest confidence.

[0080] In some embodiments, the method may further include the following steps.

[0081] Step S106: Obtain image samples.

[0082] The image samples include a source domain dataset and a target domain dataset. All source domain images in the source domain dataset are labeled, while all target domain images in the target domain dataset are unlabeled. The target domain images are generated by synthetically degrading the source domain images and simulating at least one severe weather condition. These image samples are used in the training process of the target detection model to be trained.

[0083] In this embodiment, all source domain images were acquired in a sunny, well-lit normal orchard environment. The subjects were pears, such as Crown pears and Dangshan pears, corresponding to the target detection scene. The images contained typical orchard elements such as fruit, branches, leaves, and natural background, and were free from obvious occlusion or blurring. Each source domain image was fully labeled, including the bounding box coordinates of the fruit target (pixel-level precise localization) and the fruit category (e.g., Crown pear, Dangshan pear). The label format was adapted to the training requirements of the YOLO11 model, providing supervised label information for supervised learning of the model. Figure 7 As shown, this can represent image samples of pear fruits under different environmental conditions.

[0084] The target domain image is not directly acquired, but rather generated by synthesizing and degrading the source domain image. Specifically, various severe weather conditions that may occur in an orchard scene can be simulated to construct an unsupervised dataset that differs from the source domain (normal weather), which is used to train the model's ability to adapt across weather domains. Specific degradation processing methods can be set according to the actual severe weather type, including but not limited to: simulated rainy weather with rain line overlay and raindrop blurring; simulated foggy weather with fog blurring and contrast reduction; simulated low light (night, cloudy days) with brightness reduction and noise addition; and simulated strong light and backlight with overexposure processing. Each degradation processing corresponds to a severe weather scene, ensuring that the target domain image can cover common severe imaging conditions in orchards.

[0085] It should be noted that the image content of the source domain dataset and the target domain dataset are in one-to-one correspondence, that is, each degraded image of the target domain corresponds to one original image of the source domain, ensuring that the fruit target location, category and quantity are completely consistent between the two, and only the image quality and weather conditions are different; the target domain images are not labeled and belong to unsupervised samples, which are used by the model to learn the feature mapping relationship across weather domains during the training process.

[0086] After obtaining image samples from the source and target domains, all images can undergo the same preprocessing operation as in step S102, converting them into standard image tensors before inputting them into the model for training. The specific implementation of the preprocessing operation can be found in step S102 and will not be elaborated here.

[0087] Step S107: Using the first domain adaptation module in the target detection model to be trained, the first fusion feature samples extracted from the target domain image are used to correct the first fusion feature samples extracted from the source domain image to obtain the corrected fusion feature samples; and based on the corrected fusion feature samples, the category and location information of the sample fruit objects in the source domain image are generated.

[0088] Among them, the corrected fusion feature samples are features whose feature distribution is aligned with the target domain image.

[0089] In this embodiment, the first domain adaptation module can be a Feature Space Correction (FSC) module. The FSC module can be embedded in the feature pyramid network structure of the target detection model and is dedicated to performing cross-weather domain feature distribution alignment and feature correction tasks during the model training phase. The FSC module can be used to extract the first fused feature samples corresponding to the source domain sunny weather image and the first fused feature samples corresponding to the target domain severe weather unlabeled image, respectively. It learns the inter-domain offset rules in the feature channel and feature space dimensions and establishes the transformation relationship of source domain features to target domain features.

[0090] Specifically, the first domain adaptation module can first statistically analyze the mean, variance, and other distribution statistics of the first fused feature samples of the source domain and the first fused feature samples of the target domain to obtain the feature distribution differences between the sunny weather domain and the severe weather domains such as rainy weather, foggy weather, and low light. Subsequently, through adaptive normalization and feature transformation mapping, the first fused feature samples of the source domain are subjected to distribution translation, scaling, and feature reconstruction correction to weaken the original feature distribution of the source domain, so that its feature statistical distribution approaches and aligns with the feature distribution of the target domain image, thereby obtaining the corrected fused feature samples.

[0091] The corrected and fused feature samples not only retain the local feature information of the fruit and the relative position information of the fruit and branches in the source domain image, but also achieve the alignment and unification of the feature distribution of the source domain to the feature distribution of the target domain, reducing the inter-domain feature shift caused by different weather imaging conditions.

[0092] In one possible implementation, the first domain adaptation module (FSC) mitigates cross-domain feature offsets through channel-level statistical distribution alignment.

[0093] Specifically, channel statistics can first be extracted from the first fused feature samples of the source and target domains. For the features of the first layer, the average value of the first fused feature sample Fs of the source domain and the first fused feature sample Ft of the target domain in the spatial dimension is calculated, thereby obtaining the channel response vectors μs and μt. This allows us to obtain the average activation level of each channel and characterize the semantic structure of the features.

[0094] Secondly, to improve the stability of the target domain statistics, the first domain adaptation module can also introduce a cross-iteration accumulation mechanism. Since small-batch sampling involves random fluctuations, the FSC can maintain a cache variable μ't. In each iteration, μ't is updated using the following formula (4) combined with the channel response vector μt of the target domain for the current batch: μ't←γμ't+(1-γ)μt formula (4); Here, γ, as the momentum coefficient (default setting is 0.9), can be used to balance historical statistics with current information.

[0095] Finally, the first domain adaptation module can perform channel-level feature correction. The difference between the source domain channel response and the accumulated target domain statistics is calculated using the following formula (5), such as... Figure 3 As shown, the first fused feature sample from the source domain is linearly adjusted to obtain the corrected fused feature sample F's: F's=Fs-α(μs-μ't) formula (5); Here, α is a coefficient that controls the alignment strength. This operation explicitly suppresses channel-level offsets caused by domain differences, forcing the statistical distribution of source domain features to converge toward the target domain, thereby achieving non-adversarial optimized feature distribution alignment.

[0096] Step S108: Determine the target loss value based on the category and location information of the sample fruit objects in each source domain image and the label information of each source domain image.

[0097] The target loss value may include classification loss, which measures the difference between the fruit category probability distribution predicted by the model and the true category label, and regression loss, which measures the deviation between the bounding box position (coordinates) predicted by the model and the true label position.

[0098] In this embodiment, the classification loss is calculated using the cross-entropy loss function. For example, for a source domain image, the model outputs a confidence probability that each candidate target belongs to the category "pear" (which may be a single-class detection in this scheme). The classification loss is to make the predicted probability move closer to the true label (1 represents fruit, 0 represents background).

[0099] The regression loss can use the WIoU v3 loss function. WIoU v3 introduces a weighted term based on the distance between the center points of the predicted and ground truth boxes, and dynamically modulates the gradients generated by low-quality samples (such as severely occluded or blurred fruits). Specifically, the WIoU v3 loss function RWIoU can be determined using the following formula (6): RWIoU=exp(((x-xgt) 2 +(y-ygt) 2 ) / (W 2 +H 2 )) Formula (6); Among them, such as Figure 8 As shown, (x,y) and (xgt,ygt) represent the center coordinates of the candidate bounding box and the real bounding box, respectively; W and H represent the width and height of the minimum bounding rectangle of the two bounding boxes, respectively.

[0100] In one possible implementation, a dynamic gradient gain factor r can be introduced into the WIoU v3 loss function to suppress harmful gradients generated by low-quality samples during backpropagation, thereby improving the regression stability and generalization performance of the model in complex scenarios.

[0101] Specifically, the dynamic gradient gain factor r can be obtained by the following formula (7): r=β / (δ+α) Formula (7); Here, α and β are intermediate variables used to characterize the degree of anomaly in the predicted bounding box, and δ can be a preset very small normal number (e.g., 1e-7), whose main function is to prevent the denominator from being zero and to ensure the numerical stability of the formula.

[0102] The final regression loss LWIoUv3 can be obtained by the following formula (8): LWIoUv3=r·RWIoU·LIoU Formula (8) For low-quality samples, the large localization error results in a high degree of anomaly, leading to a smaller r-value. In other words, when calculating gradients and updating network parameters, the contribution of these poorly localized samples to the model parameter updates is weakened (i.e., harmful gradients are suppressed). For high-quality samples, the accurate localization and low anomaly degree result in a relatively large r-value, allowing the model to learn the regression features of these samples normally.

[0103] Step S109: Based on the target loss value, update the parameters of the target detection model at least once to obtain the trained target detection model.

[0104] In this embodiment, the gradient of the target loss with respect to all model parameters can first be calculated based on the target loss value. The parameters include the weights of all C3k2-BSD modules in the feature extraction backbone network, the internally learnable parameters of the first and second domain adaptation modules, and the parameters of the classification and regression branches in the detection head.

[0105] Next, the model parameters can be updated based on the gradient, the preset learning rate, and other hyperparameters. The general rule is: new parameter value = old parameter value - learning rate × gradient. This update operation drives the model parameters to move in the direction of reducing loss. In particular, in the optimization of the regression branch, the dynamic gradient gain factor r introduced by the WIoU v3 loss function automatically modulates the gradient magnitude of the regression loss, thereby suppressing harmful gradients generated by low-quality samples during the update process. This allows parameter optimization to focus more on improving the localization accuracy of typical, high-quality samples, enhancing the stability of training.

[0106] The process of calculating gradients and updating parameters described above is performed iteratively on the training dataset, with at least one update completed in each iteration (or each training batch). After multiple iterations, the model's parameters can be continuously adjusted and optimized.

[0107] The iteration terminates and the training process is complete when the performance on the validation set stabilizes or reaches the preset number of training epochs. At this point, the final parameter state of the model is saved, resulting in the trained object detection model.

[0108] By employing the aforementioned technical solution, a first domain adaptation module, which does not involve gradient inversion layers or domain discriminators, directly calculates and aligns the statistics of source and target domain features along the channel dimension. This allows for deterministic and interpretable mathematical operations to correct source domain features, avoiding common challenges in adversarial training such as mode collapse and fine-tuning, thus improving model stability during training. Furthermore, the first domain adaptation module is positioned as a dedicated component for the training phase. During training, it guides and corrects feature distributions; once model training is complete, its functionality is internalized into the backbone network parameters, and the module itself can be completely removed from the inference model. This results in a final deployed model without any additional computational units added for domain adaptation, maintaining the same lightweight and efficient performance as the basic detector, and avoiding the inference efficiency degradation caused by adding domain adaptation components.

[0109] In some embodiments, step S109 can be implemented by the following steps.

[0110] Step S1091: Extract the amplitude spectrum and phase spectrum of the target domain image in the frequency domain through the second domain adaptation module in the target detection model to be trained.

[0111] In this step, the second domain adaptation module in the target detection model to be trained can be used, such as... Figure 4 As shown, a two-dimensional discrete Fourier transform is performed on the input target domain image It to obtain F(u,v). The amplitude spectrum is obtained by taking the modulus (absolute value) of F(u,v). The amplitude spectrum reflects the intensity or energy distribution of different frequency components in the image. Among them, low-frequency components usually correspond to smooth areas and overall contours of the image (which are easily affected by global style changes caused by weather), while high-frequency components correspond to the edges, textures, and other details of the image.

[0112] The phase spectrum is obtained by calculating the argument (or taking the arctangent function) of F(u,v). The phase spectrum contains the spatial location information of structural elements in the image and can be used to preserve the geometry and layout of objects.

[0113] Step S1092: Determine the frequency domain structure baseline of the target domain image.

[0114] The frequency domain structure baseline includes amplitude information of the frequency components used to characterize the spatial structure of the target domain image, obtained by logarithmic compression and frequency domain smoothing of the amplitude spectrum of the target domain image.

[0115] In this step, to reduce the significant dynamic range difference between the low-frequency regions representing overall image brightness and contrast and the high-frequency regions representing detail and noise, a logarithmic transformation can be performed on the amplitude spectrum obtained in the above embodiments. This flattens the energy distribution of the spectrum, allowing the originally faint mid-to-high-frequency structural details to emerge, while compressing extreme values ​​in the low frequencies to prevent the loss of crucial edge information in subsequent smoothing operations.

[0116] Then, a smoothing filter can be performed on the amplitude spectrum after logarithmic compression.

[0117] Specifically, a two-dimensional Gaussian low-pass filter G(u,v) is applied to convolve the compressed spectrum. The filter is centered at the origin of the spectrum (0,0), and its standard deviation σ determines the strength of the smoothing.

[0118] In this way, on the one hand, weather interference can be suppressed, because severe weather usually manifests as random fluctuations in the mid-to-high frequency domain or stripes in a specific direction, and low-pass filtering can effectively cut off these unstable high-frequency components; on the other hand, structural consistency can also be enhanced, because the physical structure of an image (such as solid contours and the direction of branches) usually manifests as energy concentration at low or specific frequencies in the frequency domain. Through smoothing, these structural features that remain consistent across weather conditions are preserved and highlighted, while details and textures that are drastically affected by weather are filtered out.

[0119] The frequency domain structure baseline B(u,v) can be calculated using the following formula (9): B(u,v)=S(log(∣F(u,v)∣)) Formula (9).

[0120] Here, S represents the spatial structure response information; the frequency domain structure baseline B(u,v) after the above processing can include the most stable and representative spatial frequency distribution information in the target domain image. It is no longer affected by local brightness variations or subtle texture noise, but instead provides a pure structural template.

[0121] Step S1093: Construct the spatial structure response information of the target domain image using the frequency domain structure baseline and phase spectrum.

[0122] Among them, the spatial structure response information is the spatial response map that characterizes the spatial structure.

[0123] In this step, the smoothed amplitude spectrum (frequency domain structure baseline) and phase spectrum can be recombined and then returned to the spatial domain, i.e., the spatial structure response information, through inverse Fourier transform.

[0124] Specifically, the spatial structure response information S can be calculated using the following formula (10): S=F -1(exp(B(u,v)+Φ(u,v))) Formula (10); Where B(u,v) is the frequency domain structure baseline, and Φ(u,v) is the phase spectrum.

[0125] Step S1094: Generate spatial modulation weights based on the local texture response information and spatial structure response information extracted from the target domain image.

[0126] Among them, spatial modulation weights are used to spatially adaptively weight the corrected fusion feature samples to enhance the feature regions in the corrected fusion feature samples that are related to spatial structure.

[0127] Since the frequency domain baseline can only capture global trends and cannot handle fine textures and local contrast changes within a single image, a convolution branch can be introduced in this step to extract the local texture response map C (i.e., local texture response information) using the following formula (11) to supplement local detail information: C=Norm(∣Conv(It)∣) Formula (11); Where It is the target domain image.

[0128] Then, the spatial structure response information S and the local texture response C can be fused using the following formula (12) to construct the spatial weight map D: D = 1 + S⊙(0.5 + 0.5C) Formula (12); Here, ⊙ represents element-wise multiplication.

[0129] Step S1095: The corrected fusion feature samples are weighted using spatial modulation weights to obtain the modulated fusion feature samples.

[0130] In this step, the modulation fusion feature sample F′ can be calculated using the following formula (13): F′=F⊙(1+S⊙(0.5+0.5C)) Formula (13); Where F is the correction fusion feature sample and F′ is the modulation fusion feature sample.

[0131] Step S1096: Based on the modulation fusion feature samples, generate the category and location information of the sample fruit objects in the source domain image.

[0132] In this step, please refer to the implementation method of step S109; the specific steps will not be repeated here.

[0133] By adopting the above technical solution, on the one hand, the second domain adaptation module can adaptively modulate features based on frequency domain analysis and local texture extraction, jointly driving the backbone network to learn domain-invariant feature representations that are insensitive to various weather changes such as rain, fog, and darkness. This solves the problems of instability in adversarial training and insufficient generalization ability under complex multi-weather conditions. On the other hand, the second domain adaptation module is explicitly defined as a training-dedicated component. After the model training is completed, its function is internalized into the network weights, and the module itself can be completely removed from the inference model. Therefore, the final deployed model is a lightweight detector without any redundant computational branches, which can avoid the problem of decreased inference efficiency caused by adding a domain adaptation component.

[0134] Based on the above embodiments, this application also provides a target detection system. Figure 5 This is a schematic diagram of the composition structure of a target detection system provided in an embodiment of this application, as shown below. Figure 5 As shown, the target detection system 200 includes an input processing module 201, a feature fusion module 202, a feature pyramid network 203, and a detection module 204, wherein... The input processing module 201 is used to acquire the target image to be detected; and to preprocess the target image to obtain the image tensor corresponding to the target image. The feature fusion module 202 is used to perform iterative fusion processing on the image tensor in the channel dimension to obtain multiple first fusion features corresponding to the target image; wherein, the first fusion feature is a feature that fuses the local feature information of the fruit in the target image and the relative position information of the fruit and branches in the target image; different first fusion features have different spatial dimensions; The feature pyramid network 203 is used to perform multi-scale fusion processing on multiple first fusion features in the spatial dimension to obtain the second fusion feature corresponding to the target image; wherein, the second fusion feature is a feature that fuses the spatial location information of the fruit in the target image; The detection module 204 is used to obtain the category and location information of the fruit objects detected in the target image based on the second fusion feature.

[0135] In some embodiments, when using a target detection system for fruit detection, the user interface is as follows: Figure 9 As shown, during operation, different environmental scenarios can be selected according to actual needs, and the confidence threshold and intersection-over-union (IoU) threshold can be flexibly adjusted to control the screening criteria for detection results. Throughout the detection process, the interface can display the predicted bounding boxes, categories, and corresponding confidence scores. Figure 10 As shown, the detected results differ depending on the selected environmental scenario.

[0136] The description of the system embodiments above is similar to that of the method embodiments above, and has similar beneficial effects. For technical details not disclosed in the system embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0137] It should be noted that, in the embodiments of this application, if the above methods are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to related technologies, can be embodied in the form of software products. These software products are stored in a storage medium and include several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.

[0138] This application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the computer program to implement any of the methods described above.

[0139] This application also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, implement the above-described method. The computer-readable storage medium can be transient or non-transient.

[0140] This application also provides a computer program product, which includes a computer program or instructions that, when executed by a processor, implement some or all of the steps in any of the above-described methods. The computer program product can be implemented specifically through hardware, software, or a combination thereof. In one optional embodiment, the computer program product is specifically embodied in a computer storage medium; in another optional embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.

[0141] It should be noted that, Figure 6 This is a schematic diagram of the hardware entity of an electronic device provided in the embodiments of this application, such as... Figure 6 As shown, the hardware entity of the electronic device 300 includes: a processor 301, a communication interface 302, and a memory 303, wherein: The processor 301 typically controls the overall operation of the electronic device 300.

[0142] Communication interface 302 enables electronic devices to communicate with other terminals or servers via a network.

[0143] The memory 303 is configured to store instructions and applications executable by the processor 301, and can also cache data to be processed or already processed (e.g., image data, audio data, voice communication data, and video communication data) in the processor 301 and various modules in the electronic device 300. It can be implemented using flash memory or random access memory (RAM). Data transfer between the processor 301, the communication interface 302, and the memory 303 can be performed via bus 304.

[0144] It should be noted that the descriptions of the storage medium and device embodiments above are similar to the descriptions of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.

[0145] The above embodiments are merely preferred embodiments provided to fully illustrate the present invention, and the scope of protection of the present invention is not limited thereto. Equivalent substitutions or modifications made by those skilled in the art based on the present invention are all within the scope of protection of the present invention.

Claims

1. A target detection method, characterized in that, The method includes: Acquire the target image to be detected; The target image is preprocessed to obtain the image tensor corresponding to the target image; Using the feature fusion module in the trained target detection model, the image tensor is iteratively fused multiple times in the channel dimension to obtain multiple first fusion features corresponding to the target image; wherein, the first fusion feature is a feature that fuses the local feature information of the fruit in the target image and the relative position information of the fruit and branches in the target image; different first fusion features have different spatial dimensions; Using the feature pyramid network in the target detection model, multiple first fusion features are fused at multiple scales in the spatial dimension to obtain a second fusion feature corresponding to the target image; wherein, the second fusion feature is a feature that fuses the spatial location information of the fruit in the target image; Based on the second fusion feature, the category and location information of the fruit objects detected in the target image are obtained.

2. The method according to claim 1, characterized in that, The trained target detection model iteratively fuses the image tensor multiple times along the channel dimension to obtain multiple first fusion features corresponding to the target image, including: The image tensor is input into the feature extraction backbone network of the target detection model; The image tensor is iteratively fused multiple times along the channel dimension by multiple cascaded feature fusion modules in the feature extraction backbone network to obtain multiple first fused features corresponding to the target image.

3. The method according to claim 2, characterized in that, Each of the feature fusion modules includes at least a first convolutional branch and a second convolutional branch in parallel; wherein, the first convolutional branch is used to extract local feature information of the fruit in the target image based on the image tensor; and the second convolutional branch is used to extract the relative position information of the fruit and branches in the target image based on the image tensor. The image tensor is iteratively fused multiple times along the channel dimension by multiple cascaded feature fusion modules in the feature extraction backbone network to obtain multiple first fused features corresponding to the target image, including: Based on multiple cascaded feature fusion modules, multiple rounds of fusion processing operations are performed to obtain intermediate fused features output in each round; The intermediate fusion features output from multiple rounds are used as multiple first fusion features corresponding to the target image; The fusion processing operation is used in the feature fusion module of this round to fuse the local feature information extracted by the first convolution branch with the relative position information extracted by the second convolution branch in the channel dimension to generate the intermediate fused feature output of this round. The local feature information and the relative position information are extracted from the intermediate fused feature determined in the previous round. The local feature information and the relative position information extracted in the feature fusion module of the first round are extracted from the image tensor.

4. The method according to claim 1, characterized in that, The step of using the feature pyramid network in the target detection model to perform multi-scale fusion processing on multiple first fusion features in the spatial dimension to obtain the second fusion feature corresponding to the target image includes: Multiple first fusion features with different spatial dimensions are input into the feature pyramid network; The feature pyramid network is used to upsample and concatenate multiple first fusion features to fuse first fusion features of different scales in spatial dimension, thereby generating second fusion features.

5. The method according to any one of claims 1-4, characterized in that, The step of obtaining the category and location information of the fruit object detected in the target image based on the second fusion feature includes: The second fused feature is input into the detection head to obtain first prediction information including the coordinates of multiple candidate bounding boxes, category confidence, and target presence confidence. The first prediction information is decoded, and the coordinates of the candidate bounding box are mapped to the original size space of the target image; Based on a preset confidence threshold, a target bounding box with a confidence level not lower than the preset confidence threshold is selected from a plurality of candidate bounding boxes; By removing redundant bounding boxes that overlap with each other in the target bounding box, the final category and location information of one or more fruit objects in the target image are obtained.

6. The method according to any one of claims 1-4, characterized in that, The method further includes: Image samples are obtained; wherein the image samples include a source domain dataset and a target domain dataset, the source domain images in the source domain dataset are all labeled, and the target domain images in the target domain dataset are all unlabeled; the target domain images are images that simulate at least one severe weather condition, generated by synthetic degradation processing of the source domain images. The first domain adaptation module in the target detection model to be trained uses the first fusion feature samples extracted from the target domain image to correct the first fusion feature samples extracted from the source domain image, thereby obtaining corrected fusion feature samples; and based on the corrected fusion feature samples, the category and location information of the sample fruit object in the source domain image are generated; wherein, the corrected fusion feature samples are features whose feature distribution is aligned with the target domain image; The target loss value is determined based on the category and location information of the sample fruit objects in each source domain image and the label information of each source domain image; Based on the target loss value, the parameters of the target detection model are updated at least once to obtain the trained target detection model.

7. The method according to claim 6, characterized in that, The step of generating category and location information of sample fruit objects in the source domain image based on the corrected fusion feature samples includes: The amplitude spectrum and phase spectrum of the target domain image are extracted using the second domain adaptation module in the target detection model to be trained. Determine the frequency domain structure baseline of the target domain image; the frequency domain structure baseline includes amplitude information of the frequency components used to characterize the spatial structure of the target domain image, obtained by logarithmic compression and frequency domain smoothing of the amplitude spectrum of the target domain image; Using the frequency domain structural baseline and the phase spectrum, spatial structural response information of the target domain image is constructed, wherein the spatial structural response information is a spatial response map characterizing the spatial structure; Based on the local texture response information and the spatial structure response information extracted from the target domain image, spatial modulation weights are generated; the spatial modulation weights are used to spatially adaptively weight the corrected fusion feature samples to enhance the feature regions in the corrected fusion feature samples that are related to the spatial structure. The spatial modulation weights are used to weight the corrected fusion feature samples to obtain the modulated modulation fusion feature samples; Based on the modulation fusion feature samples, the category and location information of the sample fruit objects in the source domain image are generated.

8. A target detection system, characterized in that, The system includes: an input processing module, a feature fusion module, a feature pyramid network, and a detection module, wherein... The input processing module is used to acquire the target image to be detected; and to preprocess the target image to obtain the image tensor corresponding to the target image. The feature fusion module is used to perform iterative fusion processing on the image tensor multiple times in the channel dimension to obtain multiple first fusion features corresponding to the target image; wherein, the first fusion feature is a feature that fuses the local feature information of the fruit in the target image and the relative position information of the fruit and branches in the target image; different first fusion features have different spatial dimensions; The feature pyramid network is used to perform multi-scale fusion processing on multiple first fusion features in the spatial dimension to obtain a second fusion feature corresponding to the target image; wherein, the second fusion feature is a feature that fuses the spatial location information of the fruit in the target image; The detection module is used to obtain the category and location information of the fruit objects detected in the target image based on the second fusion feature.

9. An electronic device, comprising: A memory and a processor, the memory storing a computer program executable on the processor, characterized in that the processor, when executing the program, implements the method according to any one of claims 1 to 7.

10. A computer storage medium, characterized in that, The processor stores executable instructions that, when executed by a processor, perform the method as described in any one of claims 1 to 7.