A deep learning-based zebrafish flowing blood cell detection method and system

By using a Transformer-based target detection model and an adaptive post-processing mechanism, the accuracy and automation issues in zebrafish blood cell detection were solved, achieving efficient and reliable blood cell identification and counting.

CN122265176APending Publication Date: 2026-06-23JIANGSU GUOYAO CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JIANGSU GUOYAO CLOUD TECH CO LTD
Filing Date
2026-03-13
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

Existing technologies for detecting mobile blood cells in zebrafish suffer from drawbacks such as time-consuming and inaccurate manual counting, error-prone semi-automatic counting, and low detection accuracy and lack of adaptive adjustment under long exposure times in deep learning models, making it difficult to meet the high-precision requirements of biomedical research.

Method used

By employing a Transformer-based target detection model, combined with adaptive post-processing and quality verification mechanisms, and through data processing optimization and model training, high-precision identification and automated detection of complex deformable cells are achieved.

Benefits of technology

It improves detection efficiency and reliability, adapts to different experimental conditions, reduces the risk of overfitting in small sample scenarios, and achieves high-precision blood cell counting and identification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122265176A_ABST
    Figure CN122265176A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of biomedicine, specifically to a zebrafish flowing blood cell detection method and system based on deep learning. The present application aims at the problems of cell blurring, distortion and adhesion caused by long-time exposure in microscopic imaging, and constructs a complete process including sample preparation and image acquisition, data processing and optimization, training of target detection model based on Transformer, adaptive post-processing, and quality checking and abnormal correction. Data processing improves image quality through multi-step enhancement and optimization, the detection model uses improved DETR structure to strengthen feature modeling and end-to-end positioning, the post-processing dynamically adjusts parameters according to the scene, and the quality checking and correction link guarantees the reliability of the results. The present application can realize stable blood cell detection and counting under complex deformation conditions, has good generalization ability and automation level, and can be used for high-throughput zebrafish blood flow dynamics research and related biomedical experimental scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of biomedical technology, specifically to a method and system for detecting zebrafish flowing blood cells based on deep learning. Background Technology

[0002] In biomedical research, accurate cell counting and analysis are crucial for revealing physiological mechanisms, studying disease progression, and evaluating drug effects. Zebrafish, as an important model organism, have red blood cells with a diameter of approximately 7-8 μm that flow at high speeds in blood vessels such as the aorta, making them an ideal model for studying blood-related issues. To capture the dynamic trajectory of red blood cells, experiments often employ long-exposure imaging at 3 seconds per frame. However, this leads to severe banding, distortion, adhesion, and blurred boundaries of red blood cells in the images, posing significant challenges to subsequent identification and counting.

[0003] Traditional cell counting methods have significant drawbacks: manual counting is not only time-consuming but also highly susceptible to subjective factors, resulting in poor batch-to-batch consistency. Semi-automatic counters rely on manually setting parameters such as thresholds and area ranges, making them prone to missegmentation, undersegmentation, or oversegmentation under different imaging conditions. While existing deep learning detection models can automatically extract high-order features, they rely on anchor boxes or candidate regions, leading to high false negative rates for small, dynamically blurred targets under long-exposure conditions. Furthermore, they suffer from slow convergence and are prone to overfitting in small-sample scenarios. Additionally, after model inference, thresholds typically require manual adjustment based on experience, lacking an adaptive adjustment mechanism and a secondary verification step for the reliability of detection results. This makes them susceptible to erroneous outputs due to imaging failures, sample anomalies, or other unforeseen circumstances, failing to meet the core requirements of biomedical research for high-precision, high-reliability, and automated detection. Therefore, there is an urgent need for a zebrafish flowing blood cell detection solution that is adaptable to the characteristics of long-exposure imaging, robust, highly automated, and possesses result verification and correction capabilities. Summary of the Invention

[0004] The purpose of this invention is to provide a method and system for detecting flowing blood cells in zebrafish based on deep learning, so as to solve the problems mentioned in the background art.

[0005] To achieve the above objectives, the present invention provides the following technical solution: a method and system for detecting flowing blood cells in zebrafish based on deep learning, comprising the following steps: S1: Prepare zebrafish embryo samples and acquire microscopic images of their aortic region; S2: Cropping, labeling, and filtering outomas from the acquired images to form a standardized labeled dataset; S3: Perform data processing and optimization on the labeled dataset; S4: Build and train a Transformer-based object detection model, and input the processed image into the model to obtain blood cell detection boxes and confidence scores; S5: Perform adaptive post-processing on the model output; S6: Perform quality verification and anomaly correction on the post-processing results; S7: Output test results and related performance indicators, quality verification and correction records.

[0006] Preferably, the sample preparation includes selecting healthy zebrafish embryos approximately 3 days after fertilization, anesthetizing them, and fixing them dorsally upward in a customized groove on the microscope stage; the image acquisition uses a biological microscope with an sCMOS camera, with an exposure time of 3 seconds / frame and a shooting frame rate of 20 frames / min; the cropping uses a 256×256 pixel sliding window with a step size of 128 pixels; the annotation uses the LabelStudio tool to annotate bounding boxes in COCO format, and after a consistency check with a Kappa coefficient ≥0.85, abnormal samples with no annotation boxes, annotation boxes that are out of bounds, and samples that are too small are removed.

[0007] Preferably, the data processing and optimization includes preprocessing, data augmentation, and dataset partitioning; The preprocessing includes: converting the image to LAB space, performing CLAHE enhancement, and then converting it back to RGB space; generating a binary image using the Otsu thresholding algorithm, and completing initial segmentation by combining Euclidean distance transformation to select seed points and an edge constraint watershed algorithm; automatically identifying image noise types and adapting corresponding filtering methods, and fusing the filtering results; extracting multi-scale edge features and overlaying them with the segmentation boundaries; enhancing boundary clarity using convolutional sharpening operators; and fusing the filtered, edge-enhanced, sharpened, and original images.

[0008] Preferably, the data augmentation includes: scaling all samples proportionally and filling them into a fixed 512×512 pixel canvas; randomly applying small affine perturbations with an amplitude not exceeding 5% to maintain the aspect ratio of blood cells; randomly adjusting brightness and contrast and adding Gaussian noise; performing pixel-level random perturbations on the coordinates and size of the bounding boxes to ensure that the bounding boxes are located within the canvas and their width and height are not less than 1 pixel; verifying the visible area of ​​the bounding boxes after each augmentation, removing samples if the visible area is less than 50%, and reverting to the basic normalization process when all targets fail; the dataset is divided into training and testing sets in a 7:3 ratio, and 3-fold cross-validation is used to improve the robustness of the model.

[0009] Preferably, the target detection model adopts the DETR architecture, with ResNet-50 as the backbone network, freezing the parameters of the first 5 layers, and fine-tuning the parameters of the 6th to 10th layers through a low-rank adaptation strategy; the model includes a 6-layer encoder and a 6-layer decoder, each layer of the encoder is equipped with a multi-head self-attention module and a feedforward network, and each layer of the decoder is equipped with a multi-head self-attention module, a multi-head cross-attention module and a feedforward network; the model also includes a cross-layer feature fusion module, which weights and fuses the output features of the 2nd, 4th and 6th layers of the encoder according to preset weights.

[0010] Preferably, the training of the model adopts a joint loss function, with the classification loss being soft maximum cross-entropy and the null class item being weighted by a coefficient of 0.3, and the bounding box regression loss adopting Generalized IoU; the training process adopts AdamW optimizer, cosine learning rate scheduling strategy and gradient pruning; different rank parameters, scaling factors, learning rates and weight decay are set for different functional sub-layers of the model, with a weight decay coefficient of 0.05 used in the early stage of training and adjusted to 0.01 in the later stage.

[0011] Preferably, the adaptive post-processing includes: setting four sets of candidate confidence thresholds of 0.55, 0.60, 0.65, and 0.70, and removing invalid predicted boxes below the threshold; dividing the blood cell density into low-density, medium-density, and high-density scenes, adjusting the IoU threshold accordingly, performing class-independent non-maximum suppression, and setting the maximum number of predicted boxes per image to 50; constructing a weighted evaluation function based on average precision, recall, and count consistency indicators, and automatically selecting the optimal threshold.

[0012] Preferably, the quality verification and anomaly correction includes: calculating four indicators: basic image quality score, detection box confidence distribution, count stability, and cell morphology consistency; determining the result as qualified, slightly abnormal, or severely abnormal based on the number of qualified indicators; directly outputting qualified results, re-executing post-processing for slightly abnormal results by fine-tuning post-processing parameters, and triggering secondary preprocessing or calling a special sub-model for abnormal morphology for secondary detection based on the cause of the severe abnormality. If the secondary correction is still unqualified, it is marked as a high-risk abnormal sample and the user is notified.

[0013] A deep learning-based zebrafish blood cell detection system, the system comprising hardware and software components; The hardware components include an imaging module, a computing module, an interaction module, a communication module, and experimental auxiliary components. The software components include a basic development environment, a core tool library, deployment and scheduling tools, a database system, core functional modules, and a security module; The system also includes a quality verification and correction module, which is used to calculate quality assessment indicators, determine the reliability level of results, execute graded correction strategies, and record relevant processes and results. Preferably, the system includes a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the deep learning-based zebrafish blood cell detection method according to any one of claims 1-8.

[0014] Compared with the prior art, the beneficial effects of the present invention are: This invention effectively solves the challenges of identifying blurred, distorted, and adhered hematocytic cells in zebrafish during long-exposure microscopy. Through systematic data processing optimization, it improves the contrast and boundary clarity of cell images, providing high-quality input for the model. The Transformer-based target detection model, through targeted structural optimization and hierarchical training strategies, enhances its ability to capture features of complex and deformed cells, reducing the risk of overfitting in small sample scenarios. Adaptive post-processing and quality verification mechanisms enable dynamic optimization and reliability control of detection results, avoiding misjudgments of abnormal samples. The entire solution is highly automated, requiring no manual intervention in threshold setting or result verification. It exhibits strong generalization ability, adaptable to different experimental conditions and imaging environments, significantly improving detection efficiency and data reliability. This provides precise and efficient technical support for hemodynamic analysis and drug efficacy evaluation in biomedical research. Attached Figure Description

[0015] Figure 1 This is a flowchart illustrating the operation of the system of the present invention.

[0016] Figure 2 This is a schematic diagram of the data preprocessing process of the present invention.

[0017] Figure 3 This is a schematic diagram of the DETR model structure of the present invention.

[0018] Figure 4 This is a schematic diagram illustrating the LoRA principle of the present invention.

[0019] Figure 5 This is a schematic diagram of the quality verification and anomaly correction process of the present invention. Detailed Implementation

[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] Please see Figures 1 to 5This invention provides a technical solution: a method and system for detecting flowing blood cells in zebrafish based on deep learning. This method enables high-precision identification, localization, and counting analysis of blood cells exhibiting tortuosity, adhesion, banding, and blurred boundaries due to high-speed flow within the aorta of zebrafish. It can be widely applied in core biomedical scenarios such as high-throughput zebrafish hemodynamics research, drug efficacy evaluation, and exploration of blood physiological mechanisms. The specific detection method is as follows: 1. Data processing and optimization: 1.1 Data Acquisition and Labeling: 1.1.1 Sample preparation: Healthy zebrafish embryos, about 3 days after fertilization, with a body length of 2.5–3 mm, were selected. After being anesthetized with MS-222, they were placed dorsally upward in the custom groove of the microscope stage to ensure clear exposure of the aortic vessel area. 1.1.2 Image Acquisition: An Olympus BX53 biological microscope was used in conjunction with an Andor Zyla 4.2 Plus CMOS camera. The resolution was 2048×2048 pixels, pixel size was 6.5μm×6.5μm, exposure time was 3s / frame, and the frame rate was 20 frames / min. Each image covered approximately 500μm of the zebrafish aorta, and a total of 600 raw images were acquired. 1.1.3 Sample screening: Invalid samples with motion blur or vascular occlusion were removed, and 500 valid images were retained in the end; 1.1.4 Image cropping and annotation: The original 4096×4096 pixel image was cropped using a 256×256 pixel sliding window, generating 31 sub-images from each original image, resulting in a total of 15,500 sub-image samples; Three annotators with cell biology backgrounds used LabelStudio to annotate the bounding boxes of blood cell targets in COCO format. 1.1.5 Label verification and anomaly removal: The labeling results were screened using a consistency verification standard with a Kappa coefficient ≥ 0.85, retaining 11,800 valid label samples; further, anomaly samples with no label boxes, label boxes exceeding the image boundaries, and width / height < 3 pixels were removed, resulting in 11,500 samples for subsequent processing.

[0022] 1.2 Preprocessing 1.2.1 Cell object enhancement: The image is converted from RGB space to LAB space, and CLAHE enhancement is performed on the L channel. The block size is 8×8 pixels and cliplimit=2.0. This suppresses noise amplification while improving the contrast of weak fluorescence areas by 30%-50%. After processing, the image is converted back to RGB space to avoid the color distortion commonly seen in HSV / V channel enhancement. 1.2.2 Seed-based initial segmentation: A binary image is generated using the Otsu adaptive thresholding algorithm to distinguish blood cells from the background region; Euclidean distance transformation is performed on the binary image, and the point with the maximum distance transformation value is selected as the seed point to ensure that the seed is located at the center of the blood cell; an edge constraint watershed algorithm is executed, in which region growth is prohibited in regions with gradient values ​​> 20 to avoid cross-blood cell segmentation; small region noise with an area < 10 pixels is filtered out, and the internal holes of the blood cell region are filled by the closing operation of 3×3 pixel circular structuring elements; 1.2.3 Intelligent Filtering and Fusion: Gaussian noise, salt-and-pepper noise, and Poisson noise in the image are automatically identified through a noise classification module. For salt-and-pepper noise, a 3×3 pixel kernel median filter is used, achieving a noise removal rate >80%. For Gaussian noise, LAB spatial adaptive guided filtering is used, with the L channel as the guide map. The kernel radius is dynamically calculated according to the image resolution; for a 512×512 pixel image, the kernel radius is 15, and the regularization coefficient is 0.01, smoothing textures while preserving edges. For Poisson noise, anisotropic diffusion filtering is used, with 5 iterations, kappa = 30, and a time step of 0.25, selectively smoothing low-gradient background areas while preserving high-gradient blood cell edges. The three filtering results are superimposed with a weighted ratio of 5:7:7 and normalized to the 0-255 range using min-max. 1.2.4 Edge Enhancement: The original image and the enhanced image of the cell object are blurred using Gaussian kernels with σ=1, 2, and 3 respectively. The gradients in the x and y directions are calculated using the Scharr operator, and the maximum absolute value of the gradient is taken as the multi-scale edge feature. The multi-scale edge features of the original image and the enhanced image are fused with a 1:1 weight, and then superimposed with the initial segmentation boundary information with a 4:1 weight, and normalized to the range of 0-255 to highlight the cell edge contour. 1.2.5 Sharpening Processing: A 3×3 convolutional sharpening operator [[0,-1,0],[-1,5,-1],[0,-1,0]] is used to perform spatial sharpening on the fused edge image, which increases the pixel grayscale difference of blood cell boundaries by 15%-20% and enhances the clarity of structural boundaries; 1.2.6 Result Fusion: The filtered fused image, edge-enhanced image, sharpened image and original image are linearly superimposed with a weight of 2:3:2:3 to maximize the enhancement of detail while maintaining the authenticity of cell morphology.

[0023] 1.3 Data Augmentation: 1.3.1 Geometric Normalization: All samples are scaled proportionally and filled to a fixed 512×512 pixel canvas. The pixel values ​​of the filled area are set to the zero values ​​of the image. The mean values ​​of the RGB channels are 0, 0, and 0, respectively, to ensure that different input sizes are trained in the same coordinate system. 1.3.2 Minimal Affine Perturbation: Randomly apply rotation (range -3° to 3°), translation (range -2 to 2 pixels), and scaling (range 0.95 to 1.05 times), with an amplitude not exceeding 5%. After each perturbation, the aspect ratio of blood cells remains unchanged to avoid systematic bias caused by stretching deformation to the detection regression. 1.3.3 Illumination and noise disturbance: Randomly adjust the brightness (ranging from 0.9 to 1.1 times the original brightness) and contrast (ranging from 0.85 to 1.15 times the original contrast) and add Gaussian noise to simulate light source fluctuations and sensor noise during microscope imaging. 1.3.4 Annotation box jitter mechanism: The x and y coordinates of each annotation box are randomly perturbed by ±1 pixel, and the w and h coordinates are randomly perturbed by ±1 pixel to simulate manual annotation error, forcing the model to learn to tolerate slight box deviations during training; after perturbation, the annotation boxes are cropped to the canvas area to ensure that the width and height are not less than 1 pixel; 1.3.5 Effectiveness assurance mechanism: After each enhancement, the visible area of ​​blood cells within the bounding box is calculated. If the visible area is <50%, the sample is removed. If the visible area of ​​the bounding box of all samples is <50%, the process reverts to the basic process of only performing geometric normalization to avoid generating invalid samples without bounding boxes. 1.3.6 Standardization Processing: The enhanced data is reassembled into a standardized annotation format and passed to detr_image_preprocessor for normalization. The mean of the RGB channels is [0.485, 0.456, 0.406], and the standard deviation is [0.229, 0.224, 0.225]. Tensor transformation is performed, and the output format is [batch_size, 3, 512, 512]. No further scaling or geometric changes are performed.

[0024] 1.4 Dataset Partitioning: The 11,500 preprocessed samples were divided into training and test sets in a 7:3 ratio. To improve model robustness, 3-fold cross-validation was performed on the training set, which was further divided into 3 subsets, each containing 2,683-2,684 samples. One subset was used as the validation set and the other two subsets were used as the training set. The final model performance was reported as the mean and standard deviation of the 3-fold results.

[0025] 2. Model Building and Training 2.1 Model Structure: DETR is adopted as the core detection model, transforming the detection problem into ensemble prediction. No anchor boxes or candidate regions are needed; the bounding boxes and categories are directly predicted through a Transformer encoder-decoder structure. The specific structure is as follows: 2.1.1 Backbone network: A pre-trained ResNet-50 was selected, with the parameters of the first 5 layers frozen and the parameters of the 6th to 10th layers fine-tuned using LoRA, which is responsible for extracting basic image features; 2.1.2 TransformerEncoder: A 6-layer encoder structure, each layer contains a multi-head self-attention module with 8 heads and a hidden layer dimension of 256, along with a feedforward network (hidden layer dimension of 1024) to globally model features and capture long-distance dependencies of blood cells; 2.1.3 Cross-layer feature fusion module: The output features of layers 2, 4, and 6 of TransformerEncoder are weighted and fused with a weight of 1:2:3 to enhance the feature expression of weak boundaries and small-sized blood cells, and improve the problem of missed detection of such targets by traditional models; 2.1.4 TransformerDecoder: A 6-layer decoder structure, each layer contains one multi-head self-attention module with 8 heads, one multi-head cross-attention module and one feedforward network. It takes 50 learnable queries as input and outputs a candidate object prediction for each query. 2.1.4 Prediction Header: The classification head is a 2-layer fully connected network; the bounding box head is a 2-layer fully connected network. 2.1.5 Hungarian Matching: The bipartite matching algorithm is adopted, which calculates the matching cost based on the weighted sum of classification loss and bounding box loss, so as to achieve a one-to-one correspondence between the predicted box and the ground truth box and avoid non-maximum suppression operation.

[0026] 2.2 Model Training Strategy: 2.2.1 Efficient Parameter Fine-Tuning Method: A LoRA low-rank adaptation strategy is adopted, appending a low-rank decomposition matrix to the original fully connected weight matrix. Only the newly added low-rank parameters are trained, while the original large model parameters are frozen. Differentiated hyperparameter configurations are designed for different functional sub-layers of the model: the decoder cross-attention layer is set to a rank of 32, a scaling factor of 64, and a learning rate of 3×10⁻⁶. -4 The weight decay is 0.05; the decoder self-attention layer is set to rank 16, scaling factor 32, and learning rate 3×10⁻⁶. -4 The weight decay is 0.05; the encoder self-attention layer is set to rank 8, scaling factor 16, and learning rate 1×10⁻⁶. -4 The weight decay is 0.05; the encoder-decoder FFN layer is set to rank 4, scaling factor 8, and learning rate 1×10⁻⁶. -4 The weight decay is 0.05; the convolutional backbone layer is set to rank 4, scaling factor 8, and learning rate 5×10⁻⁶. -5 The weight decay is 0.00; the learning rate of the LayerNorm layer is set to 1×10.-4 The weight decay is 0.00; the prediction head learning rate is set to 5×10. -5 The weight decay is set to 0.00; the query_position_embedding learning rate is set to 5×10. -5 The weight decay is 0.00; 2.2.2 Loss Function Design: A joint loss function is used for optimization, including classification loss and bounding box regression loss. The classification loss is soft maximum cross-entropy loss, with empty class terms weighted by a coefficient of 0.3 to suppress background noise interference; the bounding box regression loss uses Generalized IoU loss, which can still provide differentiable gradients when the boxes do not intersect, compensating for the plateau problem of traditional IoU; the decoder auxiliary loss shares the prediction head in each layer of the decoder and is superimposed with isomorphic ensemble loss, which helps to stably learn the correct number and localization of targets; the loss weight configuration is as follows: classification coefficient = 1.0, box localization coefficient = 7, gIoU region overlap coefficient = 3; 2.2.3 Optimizer and Scheduling Strategy: The optimizer selected is AdamW, with β1 of 0.9, β2 of 0.999, and ε of 1×10⁻⁶. -8 The weight decay coefficient is 0.05; the learning rate scheduling adopts a cosine scheduling strategy, the total number of training epochs is 120, the first 10 epochs are the warm-up phase, and the learning rate decays smoothly according to the cosine function curve from epochs 10 to 120; the gradient clipping sets the global gradient norm threshold to 1.0 to prevent training instability caused by abnormally large gradients during backpropagation. 2.2.4 Dynamic weight decay: For the first 50 epochs of training, the weight decay coefficient is set to 0.05 to enhance regularization and suppress overfitting; for the next 70 epochs, the weight decay coefficient is adjusted to 0.01 to balance the model's fitting ability and generalization ability, and to adapt to small sample scenarios. 2.2.5 Training Configuration and Monitoring: The global random seed is set to 42, the batch size is 16, and the weights are initialized using a normalized normal distribution. The model weights are saved every 10 epochs, and the model with the highest mAP on the validation set is selected as the final model. Training monitoring involves calculating the classification loss, bounding box loss, and total loss on the training set every epoch, and calculating the mAP, recall, precision, and counting error on the validation set every 5 epochs. If the mAP improvement on the validation set is less than 0.1% for 10 consecutive epochs, training is stopped early, and the model weights with the highest mAP in the first 10 epochs are loaded to avoid ineffective training. 2.2.6 Training of the sub-model for abnormal morphology: A new "sub-model for abnormal morphology" is added to the model resource pool. The DETR model is fine-tuned based on the labeled data containing deformed red blood cells. The training strategy is the same as that of the main model. It is used for secondary detection of severely abnormal samples.

[0027] 3. Adaptive post-processing A three-step post-processing strategy, employing threshold adaptation, dynamic NMS, and quantity control, is used to ensure a balance between the number of detection boxes and accuracy, as detailed below: 3.1 Candidate Threshold Screening: Four sets of candidate confidence thresholds were set: 0.55, 0.60, 0.65, and 0.70. The prediction results at different thresholds were calculated one by one, and obviously invalid prediction boxes below the threshold were removed to provide diversified candidates for subsequent screening. 3.2 Dynamic Non-Maximum Suppression: First, blood cell density scenarios are defined: <50 blood cells per image is considered low-density, 50-100 is medium-density, and >100 is high-density. The IoU threshold is dynamically adjusted for different scenarios: 0.25 for low-density, 0.3 for medium-density, and 0.35 for high-density. Class-independent Non-Maximum Suppression (NMS) is performed to eliminate redundant detection boxes based on spatial overlap and score. Simultaneously, a fallback constraint of 50 prediction boxes per image is set to prevent over-prediction in high-density scenarios. 3.3 Optimal Threshold Selection: Calculate multidimensional evaluation metrics for each candidate threshold, including mean precision (mAP), precision at IoU=0.5, recall, and consistency between predicted and actual labeled counts (counting bias rate). Construct a weighted evaluation function, where mAP has a weight of 0.4, recall has a weight of 0.3, and counting consistency has a weight of 0.3. Automatically select the threshold with the highest weighted score as the final decision criterion. If the task focuses more on the accuracy of statistical counts, the optimization objective can be switched to prioritize counting precision, and the threshold with the lowest counting bias rate can be selected first.

[0028] 4. Detection result quality verification and anomaly correction, serving as a link between adaptive post-processing and result output, ensures the reliability of the detection results through multi-dimensional quality assessment and graded correction, as detailed below: 4.1 Calculation of Quality Assessment Indicators: Indicator 1: Image basic quality score, which is calculated based on the sharpness, noise suppression effect and cell region integrity in the preprocessing stage. The full score is 100 points, and ≥80 points is qualified. Indicator 2: Distribution of detection frame confidence. The percentage of detection frames with a confidence level ≥ 0.7 is statistically analyzed. A percentage ≥ 70% is considered acceptable, while a percentage lower indicates high uncertainty in the detection results. Indicator 3: Count stability verification. Call the count mean library of normal samples in the same batch and calculate the deviation rate between the current sample count and the mean. ≤±10% is acceptable, and exceeding it is judged as an abnormal count. Indicator 4: Cell morphology consistency. Using a pre-trained cell morphology classifier, the detected blood cells are judged to be consistent with the morphological characteristics of zebrafish mobile red blood cells, that is, an aspect ratio of 1.2-1.8, an edge smoothness of ≥0.8, and a morphological consistency rate of ≥85% to be considered qualified.

[0029] 4.2 Determination of Result Reliability: Acceptance criteria: If at least 3 out of the 4 indicators are qualified, the test results are reliable; Mild abnormality: Two indicators are qualified, such as confidence level of 60%-70% and count deviation of 10%-15%, indicating that there is slight uncertainty in the test results; Severe anomalies: ≤1 indicator is qualified, such as image quality score <60 points or morphological conformity rate <70%. The reliability of the detection result is extremely low, and there may be imaging failure or sample abnormality.

[0030] 4.3 Graded Correction Strategy: Qualified results: Proceed directly to the subsequent result output stage; Mild anomalies: Invoke the fine-tuning post-processing parameter strategy, readjust the IoU threshold and candidate confidence threshold range of dynamic NMS, repeat the adaptive post-processing process, and output the corrected result; The severe abnormalities are: If image quality issues are the cause: a secondary preprocessing step is automatically triggered to enhance denoising, specifically by increasing the number of anisotropic diffusion filtering iterations to 8; edges are enhanced by increasing the gradient weights of the Scharr operator to 1.2 times the original weights, and re-executing model inference and adaptive post-processing. If the abnormal cell morphology is the cause, such as deformed red blood cells: call the special sub-model for abnormal morphology in the model resource pool to perform a secondary detection, use the same post-processing process, and output the corrected result; If the sample still fails to meet the standards after secondary correction, it is marked as a high-risk abnormal sample. The reason for the abnormality is recorded, such as "image quality is substandard" or "abnormal cell morphology". The result clearly prompts the user and suggests manual review.

[0031] 5. Results Output The final output includes: the detection frame location of blood cells, confidence score, blood cell count statistics, performance indicators such as mAP, recall, and count bias, as well as quality verification results and correction records, meeting the needs of downstream analysis and experimental traceability.

[0032] This invention also provides a system for implementing the above-described detection method, comprising hardware components, software components, and an operating procedure. The hardware components include: The imaging module includes an Olympus BX53 biological microscope and an Andor Zyla 4.2 Plus CMOS camera, used to acquire high-quality microscopic images of the zebrafish aortic region; The computing module includes a training server, which is responsible for model training, inference computation, and data storage; The interactive module includes the Lenovo ThinkStation P520 workstation, which serves as the user interaction terminal, supporting image uploading, parameter setting, training command initiation, and result visualization. The communication module supports HTTPS protocol network communication components, ensuring the security and stability of data transmission; The auxiliary components include a custom microscope stage recess, an MS-222 anesthetic storage device, and other experimental auxiliary equipment.

[0033] The system software consists of: Basic development environment: Server-side operating system Ubuntu 20.04LTS, client-side operating system Windows 10 Professional Edition; development language Python 3.8, deep learning frameworks PyTorch 1.12.1 and TorchVision 0.13.1; Core tool libraries: OpenCV 4.6.0 for image processing, LabelStudio 1.7.0 for data annotation, NumPy 1.23.5 for numerical computation, and Matplotlib 3.6.2 for result visualization; Deployment and scheduling tools: Docker 20.10.17 for containerized deployment, Kubernetes 1.24.3 for model image cluster management, supporting dynamic resource scheduling and efficient parallel computing; Database system: A unified storage system built with PostgreSQL+MinIO is used to achieve persistent management of multimodal data such as images, labeled data, model weights, detection results, quality verification records, and batch average counts. The system's core functional modules include: a data preprocessing module with functions such as intelligent noise classification and edge enhancement; a model training module with strategies such as LoRA fine-tuning and dynamic weight decay, supporting training of sub-models specifically for abnormal morphologies; an inference and prediction module with functions such as cross-layer feature fusion and dynamic NMS; a result post-processing module with adaptive threshold selection; a model lightweighting module supporting structured pruning and INT8 quantization, improving inference speed by 40% and reducing memory usage by 50%; a quality verification and correction module responsible for calculating four indicators: basic image quality score, detection box confidence distribution, count stability, and morphological consistency; determining the reliability of execution results; triggering corresponding correction strategies based on the anomaly level; recording the correction process and results; marking high-risk abnormal samples and alerting the user; and a security module based on the RBAC permission model for user permission management and the AES-256 data encryption algorithm to ensure the security of operational information and experimental data.

[0034] The system operation comprises two core processes: inference and training. The inference process includes: Command Initiation: The user uploads the image to be detected on the interactive visual interface, selects the "blood cell detection" function, and initiates the detection command; Permission verification and encryption: The system automatically verifies user permissions based on the RBAC permission model, encrypts uploaded images and operation instructions using AES-256, and generates a unique task ID to ensure data security; Data transmission and storage: The encrypted image and task ID are transmitted to the middle platform interaction layer on the server side through the API interface of HTTPS protocol; the server forwards the data to the task scheduling module, and the task scheduling module persists the data to the PostgreSQL+MinIO database; Data preprocessing: The task scheduling module calls the data preprocessing module to process the image according to the aforementioned preprocessing process, generating 512×512 pixel model input data; Model Inference: The task scheduling module sends the input data to the containerized inference cluster. Kubernetes dynamically schedules GPU resources, starts the DETR model image instance to perform inference, and outputs the blood cell prediction box and its confidence score. Post-processing and result analysis: The prediction tool reads the model output results, performs screening according to the post-processing workflow of candidate threshold screening, dynamic NMS, and optimal threshold selection, counts the number of blood cells, and generates a visual labeled image; Quality verification and correction: The task scheduling module calls the quality verification and correction module, loads the batch count mean library and morphology classifier, calculates four quality assessment indicators, and determines the reliability level of the results; executes corresponding correction strategies for mild and severe abnormal samples, and records the correction process; samples that still fail the second correction are marked as high-risk abnormal samples. Results feedback: Counting results, visualization images, quality verification results, and correction records are sent to the server and task scheduling module; the task scheduling module updates the database storage, and the server decrypts the results and sends them back to the interactive terminal. High-risk abnormal samples are marked in red to alert the user for viewing, downloading, analysis, and manual review.

[0035] The training process includes: Training command initiation: The user selects the "Model Training" function on the interactive terminal, uploads newly added labeled training data, including normal samples and abnormal samples of deformed red blood cells, sets training parameters, selects training type, and initiates training command; Data Acquisition and Initialization: After receiving the training instruction, the server starts the data acquisition program on the interactive end, downloads the new data to local storage, initializes the trainer, and loads the pre-trained ResNet-50 weights and LoRA initial parameters; Data preprocessing: The trainer calls the data processing module to preprocess the new data according to the aforementioned data processing and optimization process, and merges it with the existing training set, and then re-divides the training set and validation set in a 7:3 ratio; Model training and monitoring: The trainer performs model fine-tuning or retraining according to the aforementioned training strategy, saves model weights every 10 epochs, and calculates validation set performance every 5 epochs; if there is no improvement in validation set mAP for 10 consecutive epochs, training is stopped early. Model registration and update: When the validation set mAP reaches the preset threshold, the model is registered to the algorithm platform, which manages the model version and updates it to the model resource pool for subsequent inference processes to call as needed; at the same time, the trainer stores the average count of normal samples in the same batch in the database of the average count of the same batch for subsequent quality verification.

[0036] This invention addresses the issues of cell blurring, distortion, and adhesion caused by long-term exposure in microscopic imaging. It constructs a complete workflow encompassing sample preparation and image acquisition, data processing and optimization, Transformer-based target detection model training, adaptive post-processing, and quality verification and anomaly correction. The data processing enhances image quality through multi-step enhancement and optimization. The detection model utilizes an improved DETR structure to strengthen feature modeling and end-to-end localization. Post-processing dynamically adjusts parameters based on the scene, and the quality verification and correction stage ensures the reliability of the results. This invention can achieve stable blood cell detection and counting under complex deformation conditions, possesses good generalization ability and automation, and can be used for high-throughput zebrafish hemodynamics research and related biomedical experimental scenarios. Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for detecting flowing blood cells in zebrafish based on deep learning, characterized in that, Includes the following steps: S1: Prepare zebrafish embryo samples and acquire microscopic images of their aortic region; S2: Cropping, labeling, and filtering outomas from the acquired images to form a standardized labeled dataset; S3: Perform data processing and optimization on the labeled dataset; S4: Build and train a Transformer-based object detection model, and input the processed image into the model to obtain blood cell detection boxes and confidence scores; S5: Perform adaptive post-processing on the model output; S6: Perform quality verification and anomaly correction on the post-processing results; S7: Output test results and related performance indicators, quality verification and correction records.

2. The method for detecting zebrafish flowing blood cells based on deep learning according to claim 1, characterized in that: The sample preparation included selecting healthy zebrafish embryos approximately 3 days after fertilization, anesthetizing them, and fixing them dorsally upward in a custom groove on the microscope stage; the image acquisition used a biological microscope with an sCMOS camera, with an exposure time of 3 seconds per frame and a shooting frame rate of 20 frames per minute; the cropping used a 256×256 pixel sliding window with a step size of 128 pixels; the annotation used the LabelStudio tool to annotate bounding boxes in COCO format, and after consistency verification with a Kappa coefficient ≥0.85, abnormal samples with no labeled boxes, labeled boxes that exceeded the boundaries, and samples that were too small were removed.

3. The method for detecting zebrafish flowing blood cells based on deep learning according to claim 1, characterized in that: The data processing and optimization include preprocessing, data augmentation, and dataset partitioning; The preprocessing includes: converting the image to LAB space, performing CLAHE enhancement, and then converting it back to RGB space; generating a binary image using the Otsu thresholding algorithm, and completing initial segmentation by combining Euclidean distance transformation to select seed points and an edge constraint watershed algorithm; automatically identifying image noise types and adapting corresponding filtering methods, and fusing the filtering results; extracting multi-scale edge features and overlaying them with the segmentation boundaries; enhancing boundary clarity using convolutional sharpening operators; and fusing the filtered, edge-enhanced, sharpened, and original images.

4. The method for detecting zebrafish flowing blood cells based on deep learning according to claim 3, characterized in that: The data augmentation includes: scaling all samples proportionally and filling them into a fixed 512×512 pixel canvas; randomly applying small affine perturbations with an amplitude not exceeding 5% to maintain the aspect ratio of blood cells; randomly adjusting brightness and contrast and adding Gaussian noise; performing pixel-level random perturbations on the coordinates and size of the bounding boxes to ensure that the bounding boxes are within the canvas and their width and height are not less than 1 pixel; verifying the visible area of ​​the bounding boxes after each augmentation, removing samples if the visible area is less than 50%, and reverting to the basic normalization process when all targets fail; the dataset is divided into training and testing sets in a 7:3 ratio, and 3-fold cross-validation is used to improve the robustness of the model.

5. The method for detecting zebrafish flowing blood cells based on deep learning according to claim 1, characterized in that: The target detection model adopts the DETR architecture, with ResNet-50 as the backbone network. The parameters of the first 5 layers are frozen, and the parameters of the 6th to 10th layers are fine-tuned through a low-rank adaptation strategy. The model includes a 6-layer encoder and a 6-layer decoder. Each layer of the encoder has a multi-head self-attention module and a feedforward network, and each layer of the decoder has a multi-head self-attention module, a multi-head cross-attention module, and a feedforward network. The model also has a cross-layer feature fusion module, which weights and fuses the output features of the 2nd, 4th, and 6th layers of the encoder according to preset weights.

6. The method for detecting zebrafish flowing blood cells based on deep learning according to claim 1, characterized in that: The model is trained using a joint loss function. The classification loss is soft maximum cross-entropy with a weight reduction of 0.3 for empty class terms, and the bounding box regression loss is Generalized IoU. The training process uses the AdamW optimizer, cosine learning rate scheduling strategy, and gradient pruning. Different rank parameters, scaling factors, learning rates, and weight decays are set for different functional sub-layers of the model. A weight decay factor of 0.05 is used in the early stage of training and is adjusted to 0.01 in the later stage.

7. The method for detecting zebrafish flowing blood cells based on deep learning according to claim 1, characterized in that: The adaptive post-processing includes: setting four sets of candidate confidence thresholds of 0.55, 0.60, 0.65, and 0.70, and removing invalid predicted boxes below the threshold; dividing the scene into low-density, medium-density, and high-density based on blood cell density, adjusting the IoU threshold accordingly, performing class-independent non-maximum suppression, and setting the maximum number of predicted boxes per image to 50; constructing a weighted evaluation function based on average precision, recall, and count consistency indicators, and automatically selecting the optimal threshold.

8. The method for detecting zebrafish flowing blood cells based on deep learning according to claim 1, characterized in that: The quality verification and anomaly correction include: calculating four indicators: basic image quality score, detection box confidence distribution, count stability, and cell morphology consistency; the result is judged as qualified, slightly abnormal, or severely abnormal based on the number of qualified indicators; qualified results are directly output, slightly abnormal results are re-executed after fine-tuning post-processing parameters, and severely abnormal results are triggered for secondary preprocessing or called for secondary detection by a special sub-model for abnormal morphology based on the cause of the anomaly. If the secondary correction is still unqualified, it is marked as a high-risk abnormal sample and the user is notified.

9. A zebrafish flowing blood cell detection system based on deep learning according to any one of claims 1-8, characterized in that: The system includes hardware components and software components; The hardware components include an imaging module, a computing module, an interaction module, a communication module, and experimental auxiliary components. The software components include a basic development environment, a core tool library, deployment and scheduling tools, a database system, core functional modules, and a security module; The system also includes a quality verification and correction module, which is used to calculate quality assessment indicators, determine the reliability level of the results, execute graded correction strategies, and record relevant processes and results.

10. A zebrafish flowing blood cell detection system based on deep learning according to claim 9, characterized in that: The system includes a computer-readable storage medium on which a computer program is stored, the computer program being executed by a processor to perform the steps of the deep learning-based zebrafish blood cell detection method according to any one of claims 1-8.