High-density microalgae detection method for perception enhancement and feature distillation

By developing a high-density microalgae detection method based on perception enhancement and feature distillation, we have solved the problems of cell overlap, boundary blurring, and cross-scale issues in high-density microalgae detection, achieving high-precision and low-cost microalgae detection that is suitable for industrial applications.

CN121033044BActive Publication Date: 2026-02-24SOUTH CHINA NORMAL UNIV +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511562834.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-30
Publication Date
2026-02-24
Estimated Expiration
2045-10-30

AI Technical Summary

Technical Problem

Existing technologies are difficult to effectively detect the location, type, and quantity of high-density microalgae, especially in cases of cell overlap, blurred boundaries, and cross-scale distribution. It is difficult to balance detection accuracy and real-time performance. Traditional methods are time-consuming, labor-intensive, and costly. Deep learning algorithms have high false detection and false negative rates in high-density microalgae detection, which makes it difficult to meet industrial needs.

Method used

A high-density microalgae detection method based on perception enhancement and feature distillation is adopted. Multi-scale feature maps are extracted through the backbone network, and latent consistency mapping and density perception-assisted processing are combined. Feature distillation is performed using a dual feature distillation framework to optimize bounding boxes and density maps, and adaptive denoising is used to output detection results.

Benefits of technology

It significantly reduces the false detection and false negative rates of high-density microalgae detection, improves boundary positioning accuracy, can simultaneously process microalgae of different shapes and sizes, meets the real-time and accuracy requirements of industrial scenarios, reduces detection costs, and provides real-time and reliable data support.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121033044B_ABST
    Figure CN121033044B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of artificial intelligence image processing and biological detection, and discloses a high-density microalgae detection method for perception enhancement and feature distillation, which comprises the following steps: acquiring a high-density microalgae image containing cell overlap, fuzzy boundaries and cross-scale distribution, inputting a backbone network to extract a multi-scale feature map; optimizing a boundary box through latent consistency mapping processing; generating a microalgae density map through density perception auxiliary processing and calculating a density loss; adaptively denoising based on image complexity; optimizing a student model through a double feature distillation framework to enhance the detection capability of small-scale microalgae; and finally fusing the results of all modules to output the position, category and quantity of microalgae. The application can improve the overall average accuracy of high-density microalgae detection, reduce boundary box jitter and small-scale microalgae missing detection rate, shorten the average reasoning time, meet real-time detection requirements, and provide reliable data support for microalgae cultivation process control and optimization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the interdisciplinary field of artificial intelligence image processing and biological detection, specifically a high-density microalgae detection method oriented towards perception enhancement and feature distillation. Background Technology

[0002] Microalgae, as a versatile biological resource, possess irreplaceable application value in several key areas: in biofuel production, some microalgal species can accumulate high levels of lipids under specific stress conditions, which can be converted into biodiesel through transesterification; in the synthesis of high-value compounds, certain microalgae can produce nutritional supplements, pigments, and bioactive compounds through unique metabolic pathways; in carbon sequestration applications, microalgae convert carbon dioxide into biomass with high photosynthetic efficiency, surpassing that of most terrestrial plants under optimal conditions; and in wastewater treatment, microalgae can absorb nutrients such as nitrogen and phosphorus while generating oxygen to support bacterial degradation of organic pollutants. In all these applications, accurate detection of microalgal populations is the core factor limiting their industrial-scale implementation and optimization, thus necessitating reliable and efficient microalgae detection technologies.

[0003] Currently, microalgae detection technology still faces many unresolved issues. Traditional methods mainly rely on manual microscopic observation and flow cytometry. Microscopic observation requires extensive manual operation, which is not only time-consuming and labor-intensive, but also significantly affects accuracy due to the operator's experience, making it difficult to guarantee stability. While flow cytometry improves detection efficiency, the instruments are expensive, and highly skilled operators are required for equipment setup and data interpretation. Furthermore, neither method can achieve automated data acquisition, thus failing to provide real-time feedback for industrial production processes.

[0004] To address automation challenges, computer vision methods have been introduced into the field of microalgae detection. However, these methods still face significant challenges: due to the large morphological differences among different microalgae species, it is necessary to design dedicated feature recognition algorithms for the unique characteristics of each microalgae, resulting in poor generalization ability and difficulty in adapting to the detection needs of various microalgae. At the same time, microalgae often overlap and are squeezed during cultivation, and the cell boundaries are blurred, making feature modeling of microalgae images extremely difficult, further limiting the detection accuracy.

[0005] With the development of artificial intelligence technology, machine learning-based detection methods have been attempted for microalgae detection. However, these methods are difficult to effectively model the spatial relationships between microalgae targets, cannot fully utilize the local structural information of microalgae, and the accuracy of detection results is easily affected by the uneven distribution of microalgae density. In most scenarios, they have been gradually replaced by deep learning models based on convolutional neural networks. However, existing deep learning-based object detection algorithms still exhibit significant limitations when processing microalgae images: First, when faced with high-density, highly overlapping microalgae targets, algorithms such as Faster R-CNN have high false positive and false negative rates, making it difficult to meet practical needs; Second, microalgae are diverse in species and morphology, including spherical, spiral, and elongated shapes, and different species may have significant size differences. Existing algorithms are mostly good at capturing large-scale targets but tend to overlook small-scale microalgae, making it impossible to handle cross-scale detection requirements simultaneously; Third, mainstream deep learning algorithms often only approach practical needs in one aspect of real-time performance or accuracy, making it difficult to achieve a balance between the two and failing to meet the dual requirements of detection efficiency and accuracy in industrial scenarios; Fourth, although density-aware networks have specialized enhancements for detecting densely clustered objects, and diffusion models are highly robust for detection in complex backgrounds, both have shown great potential in microalgae detection tasks, their advantages have not yet been effectively combined and further enhanced, and they have not yet been applied to microalgae detection in biological processes.

[0006] Furthermore, microalgae face unique detection challenges during industrial cultivation: microalgae typically grow in high-density populations, resulting in crowded distributions, severe cell overlap, and blurred boundaries; simultaneously, many industrially important microalgae species exhibit highly similar morphological characteristics, further increasing the complexity of species identification. These issues severely impact the accuracy of biomass estimation and the precision of species differentiation in mixed cultures, preventing the biocontrol process from achieving ideal results. Therefore, a microalgae detection technology capable of addressing these problems is urgently needed. Summary of the Invention

[0007] The purpose of this application is to provide a high-density microalgae detection method based on sensing enhancement and feature distillation, so as to solve the technical problems mentioned in the background art.

[0008] To achieve the above objectives, this application discloses the following technical solution: a high-density microalgae detection method based on sensing enhancement and feature distillation, comprising:

[0009] Step 1: Obtain a high-density microalgae image to be detected. This high-density microalgae image contains overlapping microalgae cells, blurred boundaries, and cross-scale distribution.

[0010] The high-density microalgae images are input into the backbone network to extract multi-scale feature maps. The multi-scale feature maps include feature levels corresponding to different downsampling rates and the corresponding captured microalgae feature information from small to large scales.

[0011] Step 3: Perform latent consistency mapping on the region of interest features and diffusion time step in the multi-scale feature map to output the optimized bounding box;

[0012] Step 4: Perform density-aware assisted processing on the multi-scale feature map to construct a microalgae density map, calculate density loss, and generate prediction uncertainty results;

[0013] Step 5: Based on the multi-scale feature map, calculate the complexity of the microalgae image to be detected, and based on the complexity, determine the number of sampling steps according to the preset sampling step determination method, and then perform adaptive denoising.

[0014] Step 6: Perform feature distillation using a dual feature distillation framework, which includes a teacher model, a student model, and a dual distillation module. The dual distillation module includes a global feature distillation branch and a small target perception distillation branch. The global feature distillation branch transfers general representation knowledge across multiple feature levels, matches the feature channel dimensions of the teacher and student models through a feature adaptation layer, and calculates the global distillation loss. The small target perception distillation branch targets small-scale microalgae regions, filters small target region features through an adaptive area threshold, and calculates the small target perception distillation loss. The global distillation loss and the small target perception distillation loss are then fused to obtain the total distillation loss, which is used to optimize the student model.

[0015] Step 7: Integrate the optimized bounding box, microalgae density map, prediction uncertainty results, adaptive denoising results, and optimized student model to output the detection results of high-density microalgae, which include the location, type, and quantity of microalgae.

[0016] Preferably, the optimized bounding box is calculated using the following formula:

[0017]

[0018] in, For the optimized bounding box, For the original bounding box, As the first learnable scaling parameter, For the second learnable scaling parameter, For diffusion time step, The feature mapping function corresponding to the potential consistency mapping. These are the region of interest features extracted from the multi-scale feature map.

[0019] Preferably, the microalgae density map is constructed based on a Gaussian function, and it is used to characterize the probability that each pixel in the image is the center of microalgae; the formula for constructing the microalgae density map is:

[0020]

[0021] in, coordinates Density value at that location, This represents the total number of microalgae in the image. It is a Gaussian function. Let be the center coordinates of the i-th microalgae object. Let be the covariance matrix related to the size of the i-th microalgae object.

[0022] Preferably, the density loss is calculated using an uncertainty perception function, the formula of which is:

[0023]

[0024] in, For density loss, , These represent the height and width of the feature map at the target level in the multi-scale feature map, respectively. , coordinates The true density value at that location, coordinates The uncertainty of the forecast.

[0025] Preferably, the formula for calculating the complexity is:

[0026]

[0027] in, Let I be the complexity of image I. The number of feature maps involved in the complexity calculation. Let be the learnable feature-level weights of the i-th feature map. It is the sigmoid activation function. The relative importance weights of edge information, For the i-th feature map Space complexity metric For the i-th feature map The edge complexity metric.

[0028] Preferably, the number of sampling steps is determined as follows:

[0029]

[0030] in, For the corresponding complexity Number of sampling steps, For the minimum sampling step size, For the maximum sampling step size, This is the complexity threshold for switching between linear scaling and exponential scaling. It represents the exponential growth rate.

[0031] Preferably, the formula for calculating the global distillation loss is:

[0032]

[0033] in, For global distillation losses, The number of feature levels, Let be the weight of the i-th feature level. Let i be the temperature parameter of the i-th characteristic level. Let KL divergence be the KL divergence. The i-th level feature output by the student model. The i-th level feature output by the teacher model.

[0034] Preferably, the method for calculating the small target perception distillation loss is as follows: based on the small target region features selected by the SOAD branch, the difference loss between the student model and the teacher model in the small target region features is calculated, and the formula is:

[0035]

[0036] in, To detect distillation loss for small targets, To determine the number of features for the selected small target regions, The feature of the k-th small target region output by the student model. This represents the k-th small target region feature output by the teacher model. It is the square of the L2 norm.

[0037] Preferably, in step 4, the density sensing-assisted processing further includes:

[0038] Features at different levels in the multi-scale feature map are processed separately and connected in parallel with the density prediction branch and the uncertainty prediction branch; and after the feature processing at each level, a microalgae density map is generated in the dimension of the feature map at that level, and the density loss of the corresponding level is calculated based on the density map.

[0039] Preferably, in step 7, the detection result also includes a microalgae density distribution heatmap, which is drawn based on the microalgae density map generated in step 4, and is used to show the microalgae density in different regions of the high-density microalgae image.

[0040] Compared with existing technologies, the high-density microalgae detection method based on sensing enhancement and feature distillation proposed in this application has the following technical advantages:

[0041] 1. To address the core issues of crowded cell distribution, blurred boundaries, and similar species morphology in the industrial cultivation of microalgae, this application utilizes prior information on the spatial distribution of microalgae provided by density-sensing assisted processing, combined with potential consistency mapping processing to ensure predictive consistency during diffusion, thereby significantly reducing the false detection rate and false negative rate of microalgae in dense areas and improving boundary positioning accuracy.

[0042] 2. This application utilizes multi-scale feature maps extracted through the backbone network, combined with a dual feature distillation framework that integrates global feature distillation with small target perception distillation. This design enables the transfer of general representational knowledge across multiple feature levels through global feature distillation, ensuring the stability of large-scale microalgae detection. Simultaneously, small target perception distillation optimizes feature learning for small-scale microalgae regions, effectively identifying small, easily overlooked microalgae species. This covers two orders of magnitude scales that microalgae may span, avoiding the omission of small-scale targets by traditional detection algorithms. It meets the full-scale detection needs of microalgae of different shapes and sizes, such as spherical, spiral, and elongated shapes, in industrial scenarios.

[0043] 3. This application flexibly adjusts the number of sampling steps based on the complexity of microalgae images, which shortens the average inference time while ensuring that the detection accuracy does not decrease in complex scenarios. It solves the industry pain point that mainstream deep learning detection methods cannot balance real-time performance and accuracy, and is adapted to the dual requirements of detection efficiency and accuracy in industrial production processes.

[0044] 4. This application eliminates the need for repeated design of detection algorithms for specific microalgae species. Through the synergistic effect of multi-scale feature extraction and dual feature distillation, it can accurately distinguish key industrial microalgae species with highly similar morphologies, achieving high prediction accuracy and recovery rate, and significantly reducing the cost of technology application. At the same time, the detection results can output the location, type, quantity of microalgae, and density distribution heatmaps drawn based on multi-level density information fusion. This can provide real-time and reliable data support for process control and optimization in the industrial application of microalgae, effectively improving the industrial efficiency and quality of microalgae cultivation, and promoting the large-scale and efficient application of microalgae resources in various key fields. Attached Figure Description

[0045] 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, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0046] Figure 1 This is a flowchart illustrating a high-density microalgae detection method based on sensing enhancement and feature distillation, as provided in an embodiment of this application. Detailed Implementation

[0047] The technical solutions in the embodiments of this application will be clearly and completely described below. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in 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.

[0048] In this document, the term "comprising" is intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0049] This embodiment aims to address the technical challenges in industrial detection of high-density microalgae, including dense cell overlap, blurred boundaries, difficulty in distinguishing morphologically similar species, easy missed detection of targets across scales (especially small scales), and the difficulty in simultaneously achieving real-time detection and accuracy. It employs the AlgaeDiff-Net density-sensing diffusion network to achieve precise detection of high-density microalgae, providing a method such as… Figure 1 The high-density microalgae detection method shown here, which is based on perception enhancement and feature distillation, includes the following steps in sequence:

[0050] Step 1: Acquire high-density images of the microalgae to be detected. These images exhibit overlapping microalgae cells, blurred boundaries, and cross-scale distribution. The high-density microalgae images are sourced from industrial microalgae cultivation systems (such as bioreactors or culture tanks) and acquired using a high-resolution microscope (e.g., a 400-1000x optical microscope) paired with an industrial camera (e.g., a CMOS image sensor). The image resolution can be set to 1280×960 pixels or 2560×1920 pixels, and the acquisition frequency is matched to the monitoring requirements of the cultivation process (e.g., every 5-10 minutes).

[0051] Step 2: Input the high-density microalgae image into the backbone network to extract multi-scale feature maps. These multi-scale feature maps include feature layers corresponding to different downsampling rates and the captured microalgae feature information at scales ranging from small to large. When the backbone network is combined with a feature pyramid structure, it employs a bottom-up feature extraction + top-down feature upsampling + lateral connection feature fusion approach. From bottom to top, the backbone network's convolutional layers and pooling layers generate the original features P2-P5. From top to bottom, the P5 features are upsampled and fused with the P4 features, then upsampled again and fused with the P3 features, and so on, ensuring that small-scale microalgae information in the lower-level features (P2 layer) is not lost. Further, the extracted multi-scale feature maps are denoted as P2-P5 layers, where P2 is a feature layer downsampled by 4 times, P3 by 8 times, P4 by 16 times, and P5 by 32 times.

[0052] Step 3: Perform Latent Consistency Mapping (LCM) on the region of interest features and diffusion time step in the multi-scale feature map to output optimized bounding boxes, thus addressing the boundary localization bias problem of morphologically similar microalgae. The LCM processing flow is as follows: the time-aware feature embedding branch uses sinusoidal position encoding to encode the diffusion time step t (encoding formula is...). , ,in (For the feature dimension), the feature mapping branch generates bounding box offsets through three fully connected layers (with ReLU activation function), and an adaptive scaling factor. As t increases, it gradually approaches 1, ensuring more accurate adjustment of the boundary box in the later stage of diffusion.

[0053] Step 4: Perform density-aware assisted EM (ADEM) processing on the multi-scale feature maps. Generate microalgae density maps based on a preset density map construction method, calculate density loss based on a preset density loss calculation method, and generate prediction uncertainty results to improve the detection performance of microalgae in high-density areas. Specifically, the density-aware assisted EM processing uses corresponding scale convolution kernels for each level of features from P2 to P5 (3×3 convolution for P2, 5×5 convolution for P3, 7×7 convolution for P4, and 9×9 convolution for P5). The density prediction branch outputs density values ​​consistent with the feature map dimensions, and the uncertainty prediction branch uses the Softplus activation function (…). This ensures that the prediction uncertainty of the output is non-negative.

[0054] Step 5: Based on the multi-scale feature map, the complexity of the microalgae image to be detected is calculated by a preset image complexity calculation method. Based on the complexity, the number of sampling steps is determined by the dynamic denoising diffusion implicit model (dynamic DDIM) according to the preset sampling step determination method to complete adaptive denoising, so as to balance detection accuracy and real-time performance.

[0055] Step 6: Perform feature distillation using the Dual Feature Distillation Framework (DDF). The Dual Feature Distillation Framework includes a higher-capacity teacher model, a student model with simplified parameters, and a dual distillation module. The dual distillation module includes a Global Feature Distillation (GFD) branch and a Small Target Aware Distillation (SOAD) branch. The Global Feature Distillation branch transfers general representation knowledge across multiple feature levels, matches the feature channel dimensions of the teacher model and the student model through a feature adaptation layer, and calculates the global distillation loss based on a preset global distillation loss calculation method. The Small Target Aware Distillation branch targets small-scale microalgae regions, filters small target region features through an adaptive area threshold, and calculates the small target awareness distillation loss based on a preset small target awareness distillation loss calculation method (such as loss calculation logic based on small target region feature differences). The global distillation loss and the small target awareness distillation loss are fused to obtain the total distillation loss, which is used to optimize the student model to enhance the small-scale microalgae detection performance while maintaining full-scale detection capability. The adaptive area threshold adjustment of the small target perception distillation branch is based on the detection accuracy of small-scale microalgae during training. If the false negative rate of small-scale microalgae in a certain batch of training is higher than 5%, the threshold is reduced (e.g., from 1.5% to 1.2%). If the false positive rate is higher than 8%, the threshold is increased (e.g., from 1.5% to 1.8%). The threshold adjustment cycle is once every 10 training rounds.

[0056] Step 7: Fuse the optimized bounding box, microalgae density map, prediction uncertainty results, adaptive denoising results, and optimized student model to output high-density microalgae detection results. The detection results include the location, type, and quantity of microalgae. These results can be applied to industrial microalgae applications (such as monitoring microalgae concentration in biodiesel production, assessing microalgae activity in wastewater treatment, and tracking microalgae growth status in high-value compound synthesis). A weighted voting mechanism is used when fusing the results (optimized bounding box weight 0.3, density map weight 0.25, denoising results weight 0.2, and distillation model output weight 0.25).

[0057] Based on the above, the high-density microalgae detection method based on perception enhancement and feature distillation in this embodiment effectively solves the core problems of cell overlap, blurred boundaries, missed detection of cross-scale targets, and the difficulty in balancing real-time performance and accuracy in high-density microalgae detection through multi-step collaborative design: LCM processing improves the overall average accuracy and reduces bounding box jitter; ADEM processing provides spatial distribution priors for high-density region detection and reduces density prediction errors; dynamic DDIM adaptively adjusts the number of sampling steps according to complexity, shortening the inference time for simple images (such as sparse flat algae images) while maintaining the detection accuracy of complex images (such as small-scale dense microalgae images); DDF enhances the detection of small-scale microalgae and improves the accuracy of small-scale microalgae; ultimately, it improves the recovery rate of high-density microalgae prediction, meets the needs of industrial real-time detection, and provides reliable data support for the control and optimization of microalgae cultivation processes.

[0058] In this embodiment, the backbone network is a convolutional neural network capable of extracting multi-scale features, including but not limited to the ResNet series network and the EfficientNet series network. The backbone network can be combined with a feature pyramid structure to enhance the scale correlation of feature maps at different P2-P5 levels.

[0059] Among them, the ResNet series can select ResNet50 and ResNet101 (suitable for scenarios with sufficient computing power), and the EfficientNet series can select EfficientNet-B3 and EfficientNet-B4 (suitable for edge device scenarios with limited computing power). ResNet50 generates P2-P5 features through 4 residual block groups (the first residual block group outputs P2, the second group outputs P3, the third group outputs P4, and the fourth group outputs P5). EfficientNet-B3 improves feature extraction efficiency through an improved MBConv module (including depthwise separable convolution and squeeze-and-excitation attention mechanism).

[0060] Details of the feature pyramid structure: Bilinear interpolation is used for top-down upsampling (the interpolation step size is matched with the downsampling rate, P5 is upsampled by 2 times to P4 resolution, P4 is upsampled by 2 times to P3 resolution, etc.). When connecting laterally, 1×1 convolution is used to unify the number of channels of the bottom-up features with the number of channels of the top-down features (e.g., mapping the number of channels of the original features of P2-P5 to 256). After fusion, 3×3 convolution is used to eliminate upsampling blur.

[0061] Backbone network training initialization: The backbone network is initialized with weights pre-trained on the ImageNet dataset, and then fine-tuned on a microalgae image dataset (including more than 10 kinds of industrial microalgae such as Chlorella, Gynostemma pentaphyllum, and Lycopodium clavatum). During fine-tuning, the learning rate of the low-level convolutional layers (the layers that generate P2) is set to 1 / 10 of that of the high-level convolutional layers (the layers that generate P5) to avoid destroying the low-level features (edges and textures) of the pre-trained network.

[0062] Based on the above, the high-density microalgae detection method for perception enhancement and feature distillation in this embodiment ensures the scale correlation and feature quality of multi-scale feature maps by selecting ResNet and EfficientNet series networks and combining them with a feature pyramid structure. On the one hand, the pre-trained backbone network reduces the training difficulty of the microalgae dataset and accelerates the model convergence speed. On the other hand, the feature pyramid integrates features from different levels, avoiding the loss of small-scale microalgae features at the P2 level and the blurring of large-scale microalgae features at the P5 level. This improves the feature response value of small-scale microalgae at the P2 level (such as Chlorella vulgaris with a diameter of 2-10 μm) and enhances the feature integrity of large-scale microalgae at the P5 level (such as Spirulina with a diameter of 50-100 μm). This provides a high-quality feature foundation for subsequent density prediction of ADEM and feature distillation of DDF, thereby improving the consistency of microalgae detection at different scales and the average accuracy (mAP) of microalgae detection at all scales.

[0063] In this embodiment, the optimized bounding box is calculated using the following formula:

[0064]

[0065] in, For the optimized bounding box, For the original bounding box, As the first learnable scaling parameter, For the second learnable scaling parameter, For diffusion time step, The feature mapping function corresponding to the potential consistency mapping. These are the region of interest features extracted from the multi-scale feature map.

[0066] in, The initial value is set to 0.1-0.3 (preferably 0.2). The initial value is set to 0.05-0.15 (preferably 0.1). During training, the bounding box is dynamically optimized using gradient descent (such as the Adam optimizer with a learning rate of 1e-4) to ensure that the adjustment range matches the microalgae morphology. Implementation: The input is a flattened vector of ROI features (256×1 dimension, ROI features are extracted from the fusion features of P2-P4 layers to ensure that small-scale details and medium-scale structures are included), and the output is the x and y offsets of the bounding box (2×1 dimension). The network structure is "fully connected layer (256→128) + ReLU + fully connected layer (128→64) + ReLU + fully connected layer (64→2)". The diffusion time step t is set as follows: t ranges from [1,T], where T is the total number of diffusion steps (preferably 100-200, set to 150 in this embodiment). During the early diffusion stage (t≤50), ... When the value is small (approximately 0.05-0.3), the bounding box adjustment is small to avoid disrupting the initial prediction trend; in the later stages of diffusion (t>100) The value approaches 1, with a large adjustment range, ensuring accurate positioning of the bounding box. Source: Generated from the initial prediction branch of the diffusion detection framework. This branch performs classification (microalgae category) and regression (initial bounding box) based on ROI features. The regression head uses smooth L1 loss optimization. The coordinate format of the initial bounding box is as follows: ,and The format is consistent.

[0067] Based on the above, the high-density microalgae detection method for sensing enhancement and feature distillation in this embodiment effectively solves the boundary positioning deviation problem of morphologically similar microalgae (such as Chlorella vulgaris and Chlorella syringae, and Laminaria japonica and Schizophyllum sp.) through this bounding box optimization calculation method: on the one hand, The adjustment range is dynamically adjusted with time (t) to avoid excessive fluctuations in the bounding box during diffusion and to reduce bounding box jitter. On the other hand... Accurate offsets are generated based on multi-scale ROI features, combined with The scaling effect reduces the overlap rate of bounding boxes of morphologically similar microalgae and improves the accuracy of boundary positioning; ultimately improving the accuracy of distinguishing microalgae categories that rely on bounding boxes, especially improving the false detection problem caused by mutual occlusion of bounding boxes in high-density overlapping scenarios (such as more than 50 microalgae cells per square millimeter).

[0068] In this embodiment, the microalgae density map is constructed based on a Gaussian function, and it is used to characterize the probability that each pixel in the image is the center of a microalgae; the formula for constructing the microalgae density map is:

[0069]

[0070] in, coordinates Density value at that location, This represents the total number of microalgae in the image. It is a Gaussian function. Let be the center coordinates of the i-th microalgae object. Let be the covariance matrix related to the size of the i-th microalgae object.

[0071] Among them, Gaussian function Specific form: Using a two-dimensional Gaussian function, the formula is as follows: ,in It is a pixel coordinate vector. for The determinant of . Method of determination: Let it be a diagonal matrix, that is ,in , , , The bounding box width and height of the i-th microalgae object are respectively (predicted by the initial detection branch), ensuring that the coverage of the Gaussian function matches the actual size of the microalgae and avoiding excessive overlap of the Gaussian distributions of adjacent microalgae. The statistical method for N: During the training phase, N is the number of manually labeled microalgae objects (labeling tool uses LabelMe to label the center coordinates and bounding boxes of microalgae); during the testing phase, N is the number of microalgae objects with a confidence level higher than a threshold (e.g., 0.5) in the initial detection results of the model, ensuring that the density map construction is based on effective detection targets. Density map resolution: The density map resolution is related to the corresponding layer features. Figure 1 (e.g., the density map resolution of level P2 is 1 / 4 of the input image, and level P5 is 1 / 32). In subsequent use, the density maps of levels P3-P5 are upsampled to the resolution of level P2 to achieve multi-scale density information fusion.

[0072] Based on the above, the high-density microalgae detection method of this embodiment, which is based on the density map construction method of Gaussian function, can accurately characterize the spatial distribution density of microalgae, providing a reliable prior for the detection of high-density areas: on the one hand, By correlating density with the size of the microalgae bounding box, the density gradient is made more reasonable in high-density areas (such as overlapping microalgae regions), avoiding excessive smoothing or sharpness caused by a fixed Gaussian kernel, thus reducing the mean square error (MSE) of density prediction. On the other hand, multi-scale density maps (P2-P5) capture the density information of microalgae at different scales, improving the accuracy of the P2-level density map in characterizing the density of small-scale microalgae (such as Chlorella) and reducing the density statistical error of the P5 level for large-scale microalgae (such as Spirulina). Ultimately, this provides density constraints for subsequent detection, reduces missed detections caused by cell overlap, and improves the accuracy of microalgae count in high-density scenarios.

[0073] Furthermore, the density loss is calculated using an uncertainty perception function, the formula of which is:

[0074]

[0075] in, For density loss, , These represent the height and width of the feature map for the target layer (any or more layers from P2 to P5) in the multi-scale feature map. , coordinates The true density value at that location, coordinates The uncertainty of the forecast.

[0076] in, , The specific values ​​vary depending on the input image resolution and feature level. If the input image resolution is 1280×960 pixels, then for the P2 level feature map, H=240 and W=320; for the P3 level, H=120 and W=160; for the P4 level, H=60 and W=80; and for the P5 level, H=30 and W=40, ensuring that H and W are consistent with the actual spatial dimensions of the feature map. The method of obtaining the density map is as follows: Based on the manually labeled coordinates of the microalgae centers and bounding boxes, the same Gaussian function as in step 4 is used to construct the true density map. ,in The number of microalgae is manually labeled. The coordinates of the microalgae center are marked. This is the covariance matrix calculated based on the labeled bounding box. The calculation is as follows: It is generated by the sigma branch of ADEM, which runs in parallel with the density prediction branch. The input is a multi-scale feature map, which is processed by the "3×3 convolution + BatchNorm + ReLU" module, and then output by a 1×1 convolution with the same dimension as the density map. Then activate the function via Softplus ( Ensure its value is positive (typically in the range of 0.1-1.0). Loss calculation layer selection: During training, calculate the losses at all four layers (P2-P5) simultaneously. Then, a weighted summation is used to obtain the total density loss (with weights assigned as P2:0.4, P3:0.3, P4:0.2, and P5:0.1), highlighting the density loss weight of low-level features (P2) and strengthening the optimization of density prediction for small-scale microalgae.

[0077] Based on the above, this uncertainty-aware density loss calculation method improves the robustness and accuracy of density prediction in the ADEM module: on the one hand, through... Weighting the loss term reduces the weight of high-uncertainty regions (such as areas with severe microalgae overlap or blurred image edges) to avoid outliers interfering with model training and accelerate loss convergence. On the other hand... This encourages the model to learn reasonable uncertainty estimates, improving its performance in high uncertainty regions. The model's confidence assessment of the detection results is more accurate, ultimately improving the density prediction accuracy of the ADEM module, providing a reliable density prior for high-density microalgae detection, reducing false detections caused by density estimation bias, and especially improving the density differentiation effect in mixed culture scenarios (such as co-culture of Chlorella and Gynostemma pentaphyllum).

[0078] In this embodiment, the formula for calculating complexity is:

[0079]

[0080] in, Let I be the complexity of image I. The number of feature maps involved in the complexity calculation. Let be the learnable feature-level weights of the i-th feature map. It is the sigmoid activation function. The relative importance weights of edge information, For the i-th feature map Space complexity metric For the i-th feature map The edge complexity metric.

[0081] Among them, the parameter value details are as follows: M is set to 4 (corresponding to the four feature levels P2-P5). The initial values ​​are assigned as P2:0.4, P3:0.3, P4:0.2, and P5:0.1 (to highlight the contribution of low-level features to complexity), and are optimized during training using gradient descent (updated synchronously with other model parameters). The value range is 0.5-1.0 (preferably 0.8), which balances the impact of space and edge complexity and avoids misjudgment of complexity caused by a single dimension. Calculation based on feature maps Spatial distribution statistics, the formula is: ,in The variance of the pixel values ​​in the feature map (a measure of the dispersion of the feature distribution). The information entropy of the feature map (measures the uniformity of feature distribution) is normalized to the [0,1] interval by the maximum value. The larger the value, the more complex the spatial distribution (such as dense distribution of microalgae). The calculation is as follows: First, the Canny edge detection algorithm is used to extract the feature map. The edges (edge ​​detection threshold set to 0.1-0.3) are then calculated. ,in This is the ratio of the number of edge pixels to the total number of pixels in the feature map. This represents the average length of the edge segments, also normalized to the [0,1] interval. A larger value indicates denser and longer edges (e.g., blurred boundaries and complex morphology of microalgae). Complexity calculation process: First, calculate the complexity of each feature map from P2 to P5 separately. and After summing, normalize to [0,1] using the sigmoid function, and then sum to the corresponding [0,1]. Multiply and sum them to get the final result. (range [0,1]), where 0 represents a simple image (such as a sparse, clear image of microalgae) and 1 represents a complex image (such as a dense, blurry image of microalgae).

[0082] Based on the above, this method of calculating complexity by combining feature statistics and edge information can comprehensively and accurately measure the complexity of microalgae images: on the one hand, by combining multi-level features from P2 to P5, it avoids misjudgment of complexity caused by single-level features (e.g., the P5 level may ignore the density of small-scale microalgae, while the P2 level can supplement this information), thus improving the accuracy of complexity assessment; on the other hand... and Depict spatial distribution and edge features separately. The balancing effect ensures the smooth processing of complex images (such as those with dense microalgae and blurred boundaries). The value is higher than that of simple images, providing a precise basis for adjusting the sampling steps of dynamic DDIM; ultimately, it makes the subsequent dynamic sampling strategy more in line with the actual situation of the image, avoiding oversampling of simple images (saving computing resources) or undersampling of complex images (ensuring detection accuracy), laying the foundation for a balance between real-time performance and accuracy.

[0083] Furthermore, the number of sampling steps is determined as follows:

[0084]

[0085] in, For the corresponding complexity Number of sampling steps, For the minimum sampling step size, For the maximum sampling step size, This is the complexity threshold for switching between linear scaling and exponential scaling. It represents the exponential growth rate.

[0086] Among them, the parameter values ​​and constraints are as follows: Set it to 9 (minimum number of sampling steps for a simple image). Set to 33 (maximum number of sampling steps for complex images) to ensure Within the range of 9-33; Set to 0.5 (medium complexity threshold) to make images with C≤0.5 linearly scaled (sampling steps increase gradually) and images with C>0.5 exponentially scaled (sampling steps increase rapidly to match complexity). Set it to 4.0~4.5 (preferably 4.33) to ensure C=0.8. (Meets the requirements for complex image sampling), and when C>0.5, the number of sampling steps increases gradually, avoiding excessive growth that leads to excessively long inference times. It should be noted that although the exponential growth rate δ=4.33 is relatively large, under this parameter, the change in the number of sampling steps with complexity can effectively balance detection accuracy and real-time performance, especially suitable for the detection needs of complex scenes (such as small-scale dense distribution) in high-density microalgae images. At the same time, the number of sampling steps is affected by S max =33 is a limit to avoid excessive growth. A specific example of the number of sampling steps: when C=0.2 (for simple images, such as images of sparsely distributed flat algae), (Actual rounded to 14); When C=0.5 (medium complexity image, such as an image of a typical density of *Lycopodium clavatum*), When C=0.8 (for complex images, such as images of small-scale, densely packed Chlorella), the formula is determined based on the preset number of sampling steps. (Applicable at times) Substitute the parameters ( (Minimum sampling step size) (Complexity threshold) (Exponential growth rate) , and preset (Maximum sampling step size) consistent. Rounding and constraints on the number of sampling steps: calculated... If the number is a decimal, round it up (e.g., 14.2 becomes 15), and ensure that... (If the exponent calculation result exceeds 33, then take 33) to avoid the number of sampling steps exceeding the hardware computing power capacity; at the same time, the number of sampling steps should be an odd number (such as 9, 11, 13...33) to facilitate the symmetrical distribution of denoising steps during the diffusion process.

[0087] Based on the above, this dynamic sampling step determination method achieves precise allocation of sampling resources and effectively balances detection accuracy and real-time performance: On the one hand, simple images (C≤0.5) use fewer sampling steps with linear scaling, such as only 14 steps when C=0.2, reducing inference time by 45%-50% compared to a fixed 33 steps; on the other hand, complex images (C>0.5) use more sampling steps with exponential scaling, such as 33 steps when C=0.8 to ensure sufficient noise reduction, improving detection accuracy by 8%-10% compared to a fixed 9 steps; overall, while maintaining the full-scale microalgae detection accuracy at a rate not exceeding 1%, the average inference time is reduced by 35%-45%, and the detection frame rate is increased from 3-4 fps with fixed sampling to 5-8 fps, meeting the real-time detection requirements of industrial microalgae scenarios (such as real-time monitoring of culture tanks requiring a frame rate ≥5 fps).

[0088] In this embodiment, the formula for calculating global distillation loss is:

[0089]

[0090] in, For global distillation losses, The number of feature levels, The weights for the i-th feature level (lower-level features are assigned higher weights to preserve fine-grained information). Let i be the temperature parameter of the i-th characteristic level. Let KL divergence be the KL divergence. The i-th level feature output by the student model. The i-th level feature output by the teacher model.

[0091] Among them, the parameter value details are as follows: L is set to 4 (corresponding to the four feature levels P2-P5). The weights are assigned as P2:0.4, P3:0.3, P4:0.2, and P5:0.1 (lower-level features have higher weights, highlighting the fine-grained information of P2-P3). The values ​​are set to 1.0 for low-level features (P2-P3) and 1.2 for high-level features (P4-P5). The smoothness of the feature distribution is adjusted by the temperature parameter; low-level features have lower smoothness to preserve details, while high-level features have higher smoothness to convey the global structure. Feature processing and KL divergence calculation: and All are feature maps (e.g., P2 level is 240×320×256). Before calculation, the feature map is flattened (e.g., 240×320×256 → (240×320)×256), and then the feature vector at each spatial location is processed. The operation is then normalized to a probability distribution using the softmax function, and finally the KL divergence between the probability distributions of the student model and the teacher model is calculated. Teacher and student model structures: The teacher model uses a network with higher capacity (such as ResNet101+ feature pyramid), while the student model uses a network with fewer parameters (such as ResNet50+ lightweight feature pyramid, with 40% fewer parameters than the teacher model). and By using a feature adaptive layer (1×1 convolution) to unify the number of channels (e.g., mapping all channels to 256), dimensionality matching is ensured during KL divergence calculation.

[0092] Based on the above, this global distillation loss calculation method achieves efficient transfer of general representational knowledge from the teacher model while balancing the lightweight nature and performance of the student model: on the one hand, lower-level features (P2-P3) are more efficient in transferring general representational knowledge. To ensure the effective transmission of fine-grained information (such as edges and textures) of small-scale microalgae, the student model's response values ​​for small-scale microalgae features at the P2 level are narrowed compared to the teacher model; on the other hand, Differentiated settings balance the transmission of feature details and global structure, combined with KL divergence. To avoid insufficient distillation effect due to excessively small loss values; ultimately, with a reduced parameter scale, the student model achieves a smaller mAP for full-scale microalgae detection than the teacher model, significantly reducing the hardware resource requirements for model deployment (e.g., reducing GPU memory usage from 12GB to 6GB), while maintaining high detection performance and adapting to edge computing devices (e.g., industrial control terminals).

[0093] Furthermore, the small target perception distillation loss is calculated as follows: based on the small target region features selected by the SOAD branch, the difference loss between the student model and the teacher model in the small target region features is calculated, and the formula is:

[0094]

[0095] in, To detect distillation loss for small targets, To determine the number of features for the selected small target regions, The feature of the k-th small target region output by the student model. This represents the k-th small target region feature output by the teacher model. The square of the L2 norm, mathematically defined as "the sum of the squares of the differences between each element in the eigenvector" (i.e., the sum of the squares of the Euclidean distances, without needing to take the square root), is related to the outer layer. (Sum of all small target regions) with no repetition, and finally divide by K to calculate the average loss, avoiding interference from the number of small target regions on the loss scale.

[0096] The small target region selection method is as follows: A small target region is defined as a region whose bounding box area is less than 3% of the image area. During selection, small target bounding boxes that meet the area condition are first extracted from the initial detection results. Then, based on the bounding box coordinates, the corresponding region features are cropped from the P2 level feature map (the cropped region size is 1.2 times the bounding box size to avoid loss of edge information). K represents the number of small target regions selected in each batch of training (averaging 50-100, varying with the proportion of small targets in the dataset). Feature processing details: and For the cropped region features (e.g., size 32×32×256), before calculating the L2 norm, spatial alignment (bilinear interpolation to unify the region features of the student model and the teacher model to the same resolution) and channel alignment (1×1 convolution to unify the number of channels) are performed to ensure that the feature dimensions are completely matched. The L2 norm is calculated as the sum of squared Euclidean distances per pixel and per channel, and then the loss of K regions is averaged. Small target type and the advantages of P2 level: Small target microalgae specifically include Chlorella (diameter 2-10μm) and Reticulate algae (single filament width 5-8μm), etc. The resolution of the P2 level feature map is 1 / 4 of the input image, which can preserve the edge and texture details of small target microalgae (such as the circular outline of Chlorella and the filamentous structure of Reticulate algae), avoiding the loss of small target information caused by downsampling of high-level feature maps (such as P5). Therefore, the small target region features are mainly extracted from the P2 level.

[0097] Based on the above, this small-target-aware distillation loss calculation method specifically enhances the feature learning of small-scale microalgae, addressing the problem of insufficient attention to small targets in traditional distillation methods. On the one hand, it focuses on the features of small target regions at the P2 level, ensuring that key details of small-scale microalgae (such as edges and textures) are not lost during distillation, thus improving the detection accuracy of student models for small targets such as Chlorella and Reticulate Algae. On the other hand, the L2 norm loss directly measures the feature differences between student and teacher models, increasing the similarity of small target region features and reducing the performance loss of student models in small target detection. Ultimately, this narrows the performance gap between student and teacher models in small-scale microalgae detection, while avoiding biomass estimation errors caused by missed detection of small targets, making it particularly suitable for accurate detection of small-scale microalgae in mixed culture scenarios.

[0098] In this embodiment, the adaptive area threshold used by the SOAD branch in step 6 is dynamically adjusted between 0.8% and 3% of the area of ​​the microalgae image to be detected, and the adjustment process is optimized iteratively with model training to match the morphological characteristics of different small-scale microalgae (such as Chlorella and Reticulate Algae). The features of small-scale microalgae are mainly captured by the P2 layer feature map of the backbone network.

[0099] Among them, the morphological parameters of different small-scale microalgae are matched with the threshold: Chlorella is spherical, and the bounding box area is usually 0.8%-1.5% of the image area (corresponding to a diameter of 2-10μm and an image resolution of 1280×960). When adjusting the threshold, if the false negative rate of Chlorella is high, the lower limit of the threshold is reduced to 0.8%; Reticulate algae are filamentous, and the bounding box area of ​​a single filament is usually 1.2%-2.5%. The upper limit of the threshold can be adjusted to 2.5% to cover them; Split-faced algae (small colony-like) has a bounding box area of ​​about 2.0%-3.0%. The upper limit of the threshold is set to 3% to ensure that it is included in the small target screening. The specific mechanism for threshold adjustment is as follows: the adjustment cycle is once every 10 training epochs, and the adjustment is based on the detection indicators of small-scale microalgae (false negative rate, false positive rate, mAP) in the previous 10 epochs. If the false negative rate is >5%, the threshold is lowered (by 0.1% each time, down to a minimum of 0.8%). If the false positive rate is >8%, the threshold is raised (by 0.1% each time, up to a maximum of 3%). If the mAP is >90%, the threshold remains unchanged. For example, if the false negative rate of Chlorella reaches 7% in a certain batch of training, the threshold will be lowered from 1.5% to 1.4%. The specific advantages of P2 layer in capturing small-scale microalgae features are as follows: P2 layer feature maps are generated by early convolutional layers of the backbone network, with a smaller receptive field (e.g., the receptive field of P2 layer in ResNet50 is about 32×32 pixels), which matches the size of small-scale microalgae (e.g., Chlorella corresponds to 5-15 pixels in the image), and can accurately capture local details of small targets (e.g., the cell wall texture of Chlorella, the cell arrangement of reticulate algae); at the same time, the resolution difference between P2 layer and the original image is small, the feature mapping error is low, and the localization of small target regions is accurate.

[0100] Based on the above, by dynamically adjusting the adaptive area threshold, the SOAD branch is ensured to accurately match the morphological features of different small-scale microalgae, avoiding screening bias caused by a fixed threshold. On the one hand, the threshold is adjusted for different morphologies of small-scale microalgae such as Chlorella and Reticulate Algae to improve the recall rate of small target screening. On the other hand, the threshold is optimized with training iterations, which continuously improves the detection mAP of small-scale microalgae, eventually stabilizing at over 90%, reducing the false detection rate (such as avoiding misclassifying local areas of large-scale microalgae as small targets). At the same time, the efficient capture of P2-level features provides a high-quality feature foundation for small target detection, improves the boundary localization accuracy of small-scale microalgae, and provides an accurate spatial range for subsequent density prediction and class distinction, thus improving the overall detection performance and reliability of small-scale microalgae.

[0101] In this embodiment, the ADEM processing also includes a multi-scale feature processor, which is used to process the features of each level from P2 to P5 in the multi-scale feature map, and is connected in parallel with the density prediction branch and the uncertainty prediction branch. Among them, the P2 level features are used to capture the density information of small-scale microalgae, and the P5 level features are used to capture the density information of large-scale microalgae. After the feature processing of each level, a microalgae density map under the dimension of the feature map of that level is generated, and the density loss of the corresponding level is calculated based on the density map. Finally, the density losses of each level are fused to optimize the overall density prediction accuracy.

[0102] The specific structure of the multi-scale feature processor is as follows: Differentiated structures are adopted for features at each level (P2-P5). The P2 level processor contains two 3×3 convolutional layers (with ReLU activation and BatchNorm), the P3 level contains two 5×5 convolutional layers, the P4 level contains two 7×7 convolutional layers, and the P5 level contains two 9×9 convolutional layers. The kernel size increases with the feature level to match the receptive field of each level (P2 has a small receptive field, suitable for small-scale microalgae; P5 has a large receptive field, suitable for large-scale microalgae). Details of the density prediction and uncertainty prediction branches: Both branches have the same structure: "1×1 convolution (reducing channels to 1) + Softplus activation (uncertainty branch) / linear activation (density prediction branch)". The density prediction branch outputs density values ​​(range 0-10, corresponding to the number of microalgae per pixel), and the uncertainty branch outputs prediction uncertainty (range 0.1-1.0). Each level branch is calculated independently to ensure that the density and uncertainty prediction of microalgae at different scales do not interfere with each other. The fusion method for density loss at each level: weighted summation fusion of P2-P5 is used. The weight allocation is based on the importance and feature quality of the detection of microalgae at each level, specifically P2: 0.4, P3: 0.3, P4: 0.2, and P5: 0.1. Among them, P2 has the highest weight (small-scale microalgae density prediction is difficult and important), and P5 has the lowest weight (large-scale microalgae density prediction is relatively simple). The total density loss after fusion is weighted and summed with other model losses (such as classification loss and regression loss) (total density loss weight 0.3) to jointly optimize the model parameters.

[0103] Based on the above, the multi-scale design of ADEM processing enables the accurate capture and fusion of microalgal density information at different scales, significantly improving the overall density prediction accuracy. On the one hand, differentiated multi-scale feature processors match the receptive fields of features at each level, improving the density prediction accuracy of small-scale microalgae (such as Chlorella) at the P2 level and reducing the density statistical error of large-scale microalgae (such as Spirulina) at the P5 level, avoiding density prediction bias caused by a single-level processor. On the other hand, the density loss at each level is calculated independently and then fused to ensure that the model simultaneously optimizes the density prediction of microalgae at different scales, reduces the MSE of the total density prediction, and reduces the density estimation error in high-density areas (such as more than 50 microalgae per square millimeter). Ultimately, it provides a reliable density prior for microalgae detection, reduces false detections and missed detections caused by inaccurate density estimation, improves the accuracy of microalgae count statistics in high-density scenarios, and provides accurate data for biomass estimation and cultivation process regulation.

[0104] In this embodiment, Dynamic DDIM further includes a performance statistics cache unit. This unit stores the number of sampling steps and detection performance data (such as accuracy and inference time) corresponding to images of different complexities, and dynamically updates the calculation parameters for the number of sampling steps based on historical data (such as...). , To continuously optimize the efficiency and accuracy balance of the sampling strategy, ensuring that efficient inference and high detection accuracy are maintained when processing complex images containing dense microalgae at the P2 level.

[0105] The performance statistics cache unit uses a key-value pair storage structure. The key represents the image complexity range (divided into four ranges: [0, 0.2), [0.2, 0.5), [0.5, 0.8), and [0.8, 1.0]), and the value represents the statistical data for that range (including average sampling steps, average detection accuracy, average inference time, and number of samples). A parameter update is triggered when the cumulative number of samples in each range reaches 100. The parameter update mechanism is as follows: The update is based on the median of the complexity distribution. If the average accuracy in the interval [0.5, 0.8) is less than 90% and the inference time is less than 0.2 seconds, then the update will be performed. Reduce to 0.4 (expand the exponential scaling range and increase the number of sampling steps for complex images); if the inference time in the [0.2, 0.5) interval is >0.15s and the accuracy is >92%, then... Increased to 0.6 (reducing the exponential scaling range and decreasing the number of sampling steps for medium-complexity images); The update is based on the inference time in the range [0.8, 1.0]. If the inference time > 0.3s, the value is reduced. (For example, reduce the sampling step count by decreasing it from 0.04 to 0.03), and improve it if the accuracy is less than 88%. (For example, increasing the sampling steps from 0.04 to 0.05). Optimization processing of small-scale dense microalgae images at the P2 level: When the microalgae density (based on preliminary density prediction) in the P2 level feature map exceeds the threshold (e.g., 0.8 microalgae per pixel), the complexity C of the image is automatically increased by 10%-15% (e.g., from C=0.7 to 0.77), ensuring more sampling steps are allocated (e.g., from 28 steps to 31 steps). At the same time, the statistical data of this type of image is separately marked in the cache unit, and updates are prioritized based on this type of data. , This ensures the detection accuracy of complex, small-scale images.

[0106] Based on the above, the dynamic parameter update mechanism of the performance statistics cache unit continuously optimizes the dynamic DDIM sampling strategy, balancing detection accuracy and inference efficiency: on the one hand, it adjusts based on historical statistical data. , To avoid the mismatch between sampling steps and image complexity caused by fixed parameters, the average accuracy across different complexity ranges is improved, and inference time is reduced by 5%-8%. On the other hand, optimization processing for small-scale dense microalgae images at the P2 level ensures sufficient sampling steps for such complex images, improving detection accuracy while avoiding excessive inference time due to oversampling (inference time is controlled within 0.25-0.3s). Ultimately, the sampling strategy is adaptively evolved, enabling the model to maintain efficient inference and high detection accuracy in different microalgae scenarios (sparse, dense, small-scale, and large-scale), adapting to the dynamic environment of industrial microalgae cultivation.

[0107] In this embodiment, DDF also includes a feature alignment module. The feature alignment module solves the mismatch between the teacher model and the student model in terms of channel dimension and spatial resolution of features at each level from P2 to P5 by means of spatial interpolation (such as bilinear interpolation) and channel dimension mapping (such as 1×1 convolution), so as to ensure the consistency of feature transfer during the distillation process, especially to ensure the effective distillation of small-scale microalgal features at the P2 level.

[0108] The specific process of feature alignment is as follows: First, channel dimension mapping is performed. A 1×1 convolution is used to map the number of channels of each level of the teacher model's features (e.g., 512 channels for level P2 of the teacher model) to the number of channels of the corresponding level of the student model (e.g., 256 channels for level P2 of the student model). The weights of the convolution kernel are optimized synchronously with model training. Second, spatial resolution alignment is performed. If the resolution of the teacher model's feature map is lower than that of the student model (e.g., 200×260 for level P2 of the teacher model and 240×320 for the student model), bilinear interpolation (interpolation stride of 1 pixel) is used to upsample the teacher model's feature map to the student model's resolution. Otherwise, average pooling is used to downsample to ensure consistent spatial dimensions. Finally, feature normalization (BatchNorm) is performed to reduce the distribution differences of the aligned features. The key optimization for P2-level feature alignment: The P2 level corresponds to small-scale microalgae, with high spatial resolution and rich feature details. During alignment, a smaller interpolation stride (1 pixel) and finer channel mapping (1×1 convolution with ReLU activation to preserve detailed features) are used. Simultaneously, the similarity (cosine similarity) of P2-level features before and after alignment is calculated. If the similarity is <0.8, the interpolation parameters and convolution kernel weights are adjusted to ensure a similarity ≥0.85 after alignment, avoiding the loss of small-scale microalgae features during the alignment process. The alignment effect is evaluated using feature similarity (cosine similarity) and the reduction in distillation loss. After alignment, the cosine similarity of features at each level must be ≥0.8 (≥0.85 for P2 level), and the global distillation loss is considered. A 15%-20% decrease compared to the misaligned state, with small target perception distillation loss. A 20%-25% reduction ensures the effective transfer of distillation knowledge.

[0109] Based on the above, the feature alignment module effectively solves the problem of feature dimension mismatch between teacher and student models, ensuring the consistency and effectiveness of feature transfer during distillation: On the one hand, channel and spatial alignment ensures that the dimensions of features at each level (especially the P2 level) are fully matched, making the calculation of distillation loss such as KL divergence and L2 norm more accurate, avoiding loss bias caused by dimension mismatch, and reducing the global distillation loss and small target distillation loss respectively; on the other hand, the key optimization of the P2 level ensures that the detailed features of small-scale microalgae (such as edges and textures) are not lost after alignment, improving feature similarity and improving the detection accuracy of the student model for small-scale microalgae; ultimately, the student model's full-scale microalgae detection performance is closer to that of the teacher model under the premise of parameter simplification, while avoiding the low distillation efficiency caused by feature alignment deviation and accelerating the model training convergence speed.

[0110] In this embodiment, the output of the detection results also includes a microalgae density distribution heatmap. The microalgae density distribution heatmap is drawn by fusing the microalgae density maps of each level from P2 to P5 generated in step 4. It can intuitively show the density of microalgae in different regions of the image from small to large scale, and assist in subsequent biomass estimation and regulation of high-density microalgae cultivation process.

[0111] The density map fusion and heatmap drawing process involves: first, upsampling the density maps of layers P3-P5 to the resolution of layer P2 (using bilinear interpolation to ensure spatial correspondence), and then using weighted summation fusion (P2 weight 0.5, P3 weight 0.3, P4 weight 0.15, P5 weight 0.05) to obtain a global fused density map; when drawing the heatmap, the Jet color mapping scheme is used, with density values ​​0-2 corresponding to blue (low density), 2-4 to green (medium-low density), 4-6 to yellow (medium-high density), and 6-10 to red (high density). A color threshold is set (density value 4 is the yellow boundary), and color bars are added to mark the density range for easy and intuitive reading. Heatmap Output Format and Interactive Functions: Heatmaps can be output as image files (e.g., PNG format, resolution consistent with the input image) or overlaid in real-time on the original microalgae image (transparency set to 50% for easy comparison of actual microalgae distribution with density heatmaps); interactive operations are also supported (e.g., hovering the mouse over the image displays the specific density value of the corresponding pixel and the microalgae category; selecting an area allows for the calculation of average density and microalgae quantity), providing detailed data support for operators. Application Scenarios and Auxiliary Value: In biodiesel production, observing microalgae density distribution through heatmaps allows for reducing nutrient supply if the red area (high density) accounts for >60% (to prevent overgrowth leading to oxygen deficiency); in wastewater treatment, increasing light intensity if the blue area (low density) accounts for >50% (to promote microalgae growth); in biomass estimation, total biomass is calculated based on the density values ​​and corresponding area of ​​the heatmap. This reduces estimation errors.

[0112] Based on the above, the microalgae density distribution heatmap transforms abstract density data into intuitive visual information, providing strong support for the process control and optimization of industrial microalgae cultivation. On the one hand, color mapping and interactive functions enable operators (even non-technical personnel) to quickly judge the microalgae density distribution, improving density recognition efficiency and avoiding the cumbersome interpretation of traditional numerical tables. On the other hand, the heatmap assists in biomass estimation and cultivation condition adjustment, reducing biomass estimation errors and accelerating the response speed of cultivation condition adjustments (such as quickly judging nutrient and light requirements based on the heatmap). At the same time, the method of overlaying the heatmap with the original image facilitates the verification of the accuracy of density prediction. If the heatmap deviates significantly from the actual microalgae distribution, the density prediction parameters of the ADEM module can be optimized in reverse, forming a closed loop of "detection-feedback-optimization" to continuously improve the model's detection performance.

[0113] In summary, the high-density microalgae detection method based on perception enhancement and feature distillation in this embodiment is characterized by: extracting multi-scale microalgae feature maps covering P2 level (downsampled by 4 times) to P5 level (downsampled by 32 times) through a backbone network; optimizing boundary localization accuracy by using latent consistency mapping to ensure prediction consistency during diffusion; improving the reliability of dense area detection by providing prior information on microalgae spatial distribution through density-aware assisted processing; balancing real-time performance and accuracy by using dynamic DDIM to adaptively adjust the sampling steps based on image complexity; and covering cross-scale detection needs through dual feature distillation. Ultimately, this method improves the overall average accuracy of high-density microalgae detection, reduces the false negative rate of small-scale microalgae, shortens the average inference time in complex scenarios, and achieves a high recovery rate for predicting morphologically similar key industrial microalgae species. It can provide real-time and accurate detection data for industrial scenarios such as microalgae biodiesel production, high-value compound synthesis, and wastewater treatment, effectively supporting the control and optimization of microalgae cultivation processes and promoting the large-scale and efficient application of microalgae resources.

[0114] In the embodiments provided in this application, it should be understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, code, or any suitable combination thereof. For hardware implementation, the processor may be implemented in one or more of the following: application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), processors, controllers, microcontrollers, microprocessors, other electronic units designed to implement the functions described herein, or combinations thereof. For software implementation, some or all of the processes of the embodiments may be performed by a computer program instructing the associated hardware. During implementation, the program may be stored in a computer-readable storage medium or transmitted as one or more instructions or code on a computer-readable storage medium. Computer-readable storage media include computer storage media and communication media, wherein communication media include any medium that facilitates the transmission of a computer program from one place to another. Storage media may be any available medium accessible to a computer. Computer-readable storage media may include, but are not limited to, RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code having the form of instructions or data structures and accessible to a computer.

[0115] Finally, it should be noted that the above description is only a preferred embodiment of this application and is not intended to limit this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A high-density microalgae detection method oriented towards sensing enhancement and feature distillation, characterized in that, include: Step 1: Obtain a high-density microalgae image to be detected. This high-density microalgae image contains overlapping microalgae cells, blurred boundaries, and cross-scale distribution. Step 2: Input the high-density microalgae image into the backbone network and extract multi-scale feature maps. The multi-scale feature maps include feature levels corresponding to different downsampling rates and the corresponding captured microalgae feature information from small to large scales. Step 3: Perform latent consistency mapping on the region of interest features and diffusion time step in the multi-scale feature map to output the optimized bounding box; Step 4: Perform density-aware assisted processing on the multi-scale feature map to construct a microalgae density map, calculate density loss, and generate prediction uncertainty results; Step 5: Based on the multi-scale feature map, calculate the complexity of the microalgae image to be detected, and based on the complexity, determine the number of sampling steps according to the preset sampling step determination method, and then perform adaptive denoising. Step 6: Perform feature distillation using a dual feature distillation framework, which includes a teacher model, a student model, and a dual distillation module. The dual distillation module includes a global feature distillation branch and a small target perception distillation branch. The global feature distillation branch transfers general representation knowledge across multiple feature levels, matches the feature channel dimensions of the teacher and student models through a feature adaptation layer, and calculates the global distillation loss. The small target perception distillation branch targets small-scale microalgae regions, filters small target region features through an adaptive area threshold, and calculates the small target perception distillation loss. The global distillation loss and the small target perception distillation loss are then fused to obtain the total distillation loss, which is used to optimize the student model. Step 7: Combine the optimized bounding box, microalgae density map, prediction uncertainty results, adaptive denoising results, and optimized student model to output the detection results of high-density microalgae, including the location, type, and quantity of microalgae; The microalgae density map is constructed based on a Gaussian function and is used to characterize the probability that each pixel in the image is a microalgae center; the formula for constructing the microalgae density map is: in, coordinates Density value at that location, This represents the total number of microalgae in the image. It is a Gaussian function. Let be the center coordinates of the i-th microalgae object. The covariance matrix is ​​related to the size of the i-th microalgae object; The density loss is calculated using an uncertainty perception function, the formula of which is: in, For density loss, , These represent the height and width of the feature map at the target level in the multi-scale feature map, respectively. , coordinates The true density value at that location, coordinates The uncertainty of the forecast.

2. The high-density microalgae detection method based on sensing enhancement and feature distillation according to claim 1, characterized in that, The optimized bounding box is calculated using the following formula: in, For the optimized bounding box, For the original bounding box, As the first learnable scaling parameter, For the second learnable scaling parameter, For diffusion time step, The feature mapping function corresponding to the potential consistency mapping. These are the region of interest features extracted from the multi-scale feature map.

3. The high-density microalgae detection method based on sensing enhancement and feature distillation according to claim 1, characterized in that, The formula for calculating the complexity is: in, Let I be the complexity of image I. The number of feature maps involved in the complexity calculation. Let be the learnable feature-level weights of the i-th feature map. It is the sigmoid activation function. The relative importance weights of edge information, For the i-th feature map Space complexity metric For the i-th feature map The edge complexity metric.

4. The high-density microalgae detection method based on sensing enhancement and feature distillation according to claim 3, characterized in that, The number of sampling steps is determined as follows: in, For the corresponding complexity Number of sampling steps, For the minimum sampling step size, For the maximum sampling step size, This is the complexity threshold for switching between linear scaling and exponential scaling. It represents the exponential growth rate.

5. The high-density microalgae detection method based on sensing enhancement and feature distillation according to claim 1, characterized in that, The formula for calculating the global distillation loss is as follows: in, For global distillation losses, The number of feature levels, Let be the weight of the i-th feature level. Let i be the temperature parameter of the i-th characteristic level. Let KL divergence be the KL divergence. The i-th level feature output by the student model. The i-th level feature output by the teacher model.

6. The high-density microalgae detection method based on sensing enhancement and feature distillation according to claim 5, characterized in that, The small target perception distillation loss is calculated as follows: based on the small target region features selected by the SOAD branch, the difference loss between the student model and the teacher model in the small target region features is calculated, and the formula is: in, To detect distillation loss for small targets, To determine the number of features for the selected small target regions, The feature of the k-th small target region output by the student model. This represents the k-th small target region feature output by the teacher model. It is the square of the L2 norm.

7. The high-density microalgae detection method based on sensing enhancement and feature distillation according to claim 1, characterized in that, In step 4, the density sensing-assisted processing further includes: Features at different levels in the multi-scale feature map are processed separately and connected in parallel with the density prediction branch and the uncertainty prediction branch; and after the feature processing at each level, a microalgae density map is generated in the dimension of the feature map at that level, and the density loss of the corresponding level is calculated based on the density map.

8. The high-density microalgae detection method based on sensing enhancement and feature distillation according to claim 1, characterized in that, In step 7, the detection results also include a microalgae density distribution heatmap, which is drawn based on the microalgae density map generated in step 4 and is used to show the microalgae density in different regions of the high-density microalgae image.

Citation Information

Patent Citations

  • Target detection method, system and equipment based on knowledge distillation and medium

    CN120526269A

  • KR20220063347A