A balanced density regression method for object localization and counting in dense scenes

By using inverse distance transformation and dynamic multi-scale enhancement modules, combined with cross-attention mechanism and edge attention loss, the problems of boundary ambiguity and peak adhesion in cell localization and counting in dense scenes are solved, achieving higher localization accuracy and counting consistency.

CN122289157APending Publication Date: 2026-06-26BEIJING UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING UNIV OF TECH
Filing Date
2026-03-19
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Existing technologies suffer from boundary blurring and peak adhesion issues when locating and counting cells in dense scenarios due to excessive focus on the central pixel. Furthermore, differences in cross-laboratory acquisition processes and staining batches affect the model's generalization ability.

Method used

Density maps are generated using inverse focal distance transform (FIDT). Combined with a dynamic multi-scale enhancement module and a cross-attention mechanism, cell region priors are learned through pixel-level occupancy estimation branches, and edge attention loss is introduced to improve boundary consistency and localization accuracy.

Benefits of technology

It significantly improves cell localization accuracy and counting consistency in dense scenes, reduces peak adhesion and boundary blurring, and enhances the model's generalization ability under different conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122289157A_ABST
    Figure CN122289157A_ABST
Patent Text Reader

Abstract

This invention discloses a balanced density regression method for object localization and counting in dense scenes. It unifies point-level annotations into supervisory signals: a density map is generated by accumulating two-dimensional Gaussian kernels at the cell center coordinates, ensuring the sum of pixels in the density map equals the number of cells; and the density map is thresholded to obtain a pixel-level occupancy map for auxiliary supervision. The model employs a high-resolution multi-scale backbone, with density regression as the main thread, introducing pixel-level occupancy estimation and edge-sensitive loss as auxiliary constraints to balance the regression contributions of the center and edges, improving the separability of adhered targets and the ability to identify fuzzy boundaries. During the inference phase, the density map is output, and coordinate-level localization and counting are obtained by combining local extremum search and non-maximum suppression. Occupancy consistency verification and minimum spacing constraints eliminate false detections. This method has been validated on multiple cell datasets, effectively reducing missed detections and peak adhesion in high-density, overlapping, and weak-contrast scenes, demonstrating good engineering usability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision technology, specifically a balanced density regression method for object localization and counting in dense scenes. It can be applied to scenarios such as cell image processing and pathological grading assessment, and has achieved good prediction results. Background Technology

[0002] With the development of digital pathology and high-throughput microscopy, target localization and counting in dense scenes have become crucial links in pathological auxiliary diagnosis and scientific research statistics. Cell localization and counting, by objectively quantifying the central location and number of cells in tissue sections or cytological images, can intuitively reflect the spatial distribution characteristics and proliferation level of cells, providing key quantitative indicators for tumor grading and staging, lesion activity assessment, efficacy monitoring, and follow-up. Relying on standardized image acquisition, data governance, and intelligent analysis processes, cell localization and counting can transform large-scale image data into structured information, supporting batch quality control, key area screening, and workload allocation, achieving automated report generation and result visualization, and significantly improving the work efficiency and decision-making consistency of pathology departments. At the clinical application level, accurate cell counting and spatial localization not only provide doctors with reliable quantitative evidence, promoting individualized diagnosis and treatment and plan optimization, but also provide unified and reusable basic data support for scientific research statistics, drug evaluation, and multi-center collaborative research, thereby promoting the standardization and routine implementation of precision medicine. These tasks require coordinate-level localization and full-image counting of a large number of adjacent or even overlapping targets in large-format images, while maintaining the traceability and cross-sample consistency of the results. In clinical and research scenarios, cells exhibit characteristics such as high-density aggregation, significant scale differences, irregular morphology, blurred boundaries, and uneven staining intensity. This leads to peak adhesion, missegmentation, and missed detection in crowded areas using traditional methods, thus affecting the counting accuracy and the reliability of spatial distribution statistics.

[0003] Current mainstream solutions include density regression, detection-based centroid regression, and segmentation-based instance extraction. Among these, Gaussian kernel-based density map regression is widely used because it can be directly generated from point annotations and has stable training. However, Gaussian density supervision suffers from inherent regression imbalance: center pixels are much larger than edge pixels, and the network tends to fit the strong response at the center while ignoring the weak response at the edge. In dense regions and at weak contrast boundaries, this imbalance is amplified into problems such as peak confluence, blurred boundaries, and difficulty in decoupling from nearby targets. In addition, cross-laboratory collection processes and differences in staining batches introduce domain shifts, further weakening the model's generalization ability in real-world deployments.

[0004] Currently, with the rapid development of whole-slice scanning (WSI), high-resolution microscopy, and GPU computing power, cell counting and localization technologies are being rapidly integrated into digital pathology workflows: large-scale point-level / instance-level labeled data and standardized preprocessing pipelines enable high-throughput quantitative analysis under different tissues, staining, and magnification levels. In terms of research paradigms, early methods primarily relied on density map regression, achieving "counting + implicit localization" by mapping point labels to continuous density supervision, leading to improvements such as multi-column convolution, dilated convolution, and attention enhancement (e.g., MCNN, CSRNet). Subsequently, detection-based methods directly localized cell centers using pyramid features and anchor-free heatmap regression (e.g., CenterNet), demonstrating robustness in crowded scenarios; segmentation-based approaches, represented by U-Net systems and instance segmentation (e.g., Hover-Net, StarDist, Cellpose), support accurate counting while obtaining interpretable morphological boundaries. In recent years, Transformer / Visual Transformer (ViT, Swin) and lightweight attention have been widely used for multi-scale contextual modeling. Combined with edge / gradient perception, morphological priors, and post-processing of peak shaping (local extrema, LoG, watershed), they further improve localization clarity and counting consistency. Meanwhile, weak / semi-supervised and self-supervised pre-training have shown potential in reducing annotation costs and improving cross-domain generalization; graph-based spatial relationship modeling and uncertainty assessment are also increasingly used for quality control and quantification of result reliability. Overall, current cell counting and localization are evolving from a single paradigm to a comprehensive approach integrating density regression, detection, segmentation, Transformer, and prior / uncertainty fusion, providing efficient and reusable foundational capabilities for clinical quantitative assessment and scientific research statistics.

[0005] Existing methods mostly employ density map regression based on Gaussian kernels, generating continuous density supervision by convolutional processing of point-level annotations. However, traditional Gaussian density regression inherently suffers from regression imbalance: the values ​​of center pixels are much larger than those of edge pixels, leading to an overemphasis on the center and neglect of boundary information during network training. This easily results in peak consolidation and blurred boundaries in dense regions. Furthermore, irregular cell morphology, significant scale differences, and uneven staining intensity further exacerbate the localization difficulties. Figure 1 A large dataset was used to locate Ki-67 cells in breast tumor cells and to analyze their cellular localization. The tumor cells in this dataset exhibited diversity in size and shape, with significant variations in staining depth, and some cells were extremely blurry. Figure 1 (a) shows a schematic diagram of the dataset. It can be seen that the circled cells and the background have little color difference and are difficult to distinguish. Figure 1 (b) and Figure 1(c) shows the cell localization map of the image and the localization map predicted by the original density regression model. Figure 1 Image (d) shows the localization map predicted by the present invention for this image. It can be seen that the present invention can specifically identify cells with blurred edges and low color contrast, thereby improving the accuracy of the prediction. Summary of the Invention

[0006] This invention proposes a novel cell localization and counting method and apparatus based on pixel occupancy estimation and dynamic multi-scale enhancement. During training, a focal inverse distance transform (FIDT) density map is first generated based on point-level annotations, and a binary occupancy map is obtained through thresholding. This map is used to construct a pixel-level occupancy estimation branch to learn cell region priors. Subsequently, a dynamic multi-scale enhancement module is introduced into the backbone network that maintains high-resolution representation. This module adaptively fuses morphological features from different receptive fields and employs a cross-attention mechanism combining occupancy priors and backbone features to achieve information filtering and enhancement. Simultaneously, edge attention loss is combined to align predictions with ground truth values ​​in the gradient domain, thereby improving the independence and boundary consistency of density peaks. Finally, the density map is output through a prediction head, and local peak detection is performed to obtain the cell center coordinates and counting results. The invention consists of a data preprocessing and annotation conversion module, a feature extraction and multi-scale enhancement module, an occupancy estimation and feature fusion module, and a density regression and post-processing module. Evaluations on multiple publicly available cell image datasets demonstrate that this method has significant advantages in terms of localization accuracy and counting consistency.

[0007] The technical solution adopted in this invention is a balanced density regression method for object localization and counting in dense scenes, comprising the following steps:

[0008] Data preprocessing and annotation conversion steps: Obtain the original image containing dense targets and its corresponding point-level annotations, generate a density map based on the point-level annotations as a regression supervision signal, and generate a binary occupancy map by thresholding the density map as a supervision signal for pixel-level occupancy estimation;

[0009] Feature extraction and multi-scale enhancement steps: The preprocessed image is input into a pre-constructed backbone network to extract high-resolution feature maps; a dynamic multi-scale enhancement module is introduced at the encoding end of the backbone network to obtain robust morphological feature representations across scales through feature selection and adaptive fusion of different receptive fields.

[0010] Occupation estimation and feature fusion steps: Construct parallel pixel-level occupancy estimation branches, using the binary occupancy map as supervision, to learn and predict pixel-level cell occupancy probability maps; through a cross-attention mechanism, fuse the location prior information extracted by the occupancy estimation branches with the semantic features extracted by the backbone network and the multi-scale features output by the dynamic multi-scale enhancement module to generate fused features that simultaneously possess accurate spatial localization and discriminative semantics.

[0011] Density regression and post-processing steps: Based on the fused features, the final predicted density map is output through the prediction head; during the inference stage, local peak detection is performed on the predicted density map to obtain the center coordinates of each target and count the total number of targets.

[0012] Furthermore, the backbone network is a multi-branch convolutional network that maintains high-resolution features, and the standard convolutional layers are replaced with central difference convolutions to enhance the model's sensitivity to boundary and gradient information.

[0013] Furthermore, the density map employs a focal inverse distance transform map, which generates a density map with sharper, non-overlapping peaks to clearly characterize the center of each target.

[0014] Furthermore, in the density regression and post-processing steps, the loss function of the training process is a weighted combination of density map regression loss and pixel-level occupancy estimation loss; the density map regression loss further includes a base loss and an edge-sensitive loss, the edge-sensitive loss being used to constrain the consistency between the predicted density map and the true density map in the gradient domain, so as to enhance the structural fidelity and boundary clarity of the prediction results.

[0015] Furthermore, the base loss is the mean squared error loss, which is used to ensure global numerical consistency between the predicted density map and the true density map.

[0016] Furthermore, the edge-sensitive loss is calculated based on the discrete gradient differences between the predicted density map and the true density map in the horizontal and vertical directions.

[0017] Furthermore, the pixel-level occupancy estimation loss is a binary cross-entropy loss, used to supervise the prediction of the occupancy probability map at the pixel level.

[0018] A balanced density regression device for object localization and counting in dense scenes, comprising:

[0019] The preprocessing module is used to acquire the original image containing dense targets and its corresponding point-level annotations, generate a density map based on the point-level annotations as a regression supervision signal, and generate a binary occupancy map by thresholding the density map as a supervision signal for pixel-level occupancy estimation.

[0020] The feature extraction and enhancement module is used to input the preprocessed image into the pre-constructed backbone network to extract high-resolution feature maps, and to perform feature selection and adaptive fusion of different receptive fields on the feature maps through the dynamic multi-scale enhancement module to obtain robust morphological feature representations across scales.

[0021] The occupancy estimation and fusion module is used to construct a parallel pixel-level occupancy estimation branch. Using the binary occupancy map as supervision, it learns to predict the pixel-level cell occupancy probability map and fuses the occupancy prior information with semantic features and multi-scale features through a cross-attention mechanism to generate fused features.

[0022] The output and post-processing module is used to output the final prediction density map through the prediction head based on the fused features, and to perform local peak detection on the prediction density map during the inference stage to obtain the center coordinates of each target and the total number of targets.

[0023] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor, when executing the program, implements the balanced density regression method for object localization and counting in dense scenes.

[0024] A computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the balanced density regression method for object localization and counting in dense scenes.

[0025] Specifically, the main steps of this invention include the following:

[0026] Step 1: Introduce the backbone architecture:

[0027] EFNet employs the multi-stage high-resolution network HRNet as its regressor for accurate cell localization in medical images. HRNet is a powerful architecture designed to maintain high-resolution representations throughout the process, crucial for tasks requiring precise localization. Its key features include parallel connections of high- to low-resolution convolutional streams and repetitive information exchange between different resolutions. This design enables the network to learn semantically rich and spatially accurate representations. In predicting the head, we avoid direct regression to traditional Gaussian-based density maps, as overlapping Gaussian kernels in dense regions often lead to blurred responses and loss of individual localization information. To address this, we use an inverse focal length transform (FIDT) map as the prediction target. FIDT maps highlight cell centers with distinct peaks while rapidly suppressing background responses. This design ensures that each cell is represented by a clear, non-overlapping local maxima, making the localized map clearer and easier to interpret. As a result, the network outputs predictions where cell centers can be accurately extracted through simple peak detection. Compared to traditional density regression methods, this approach reduces ambiguity in crowded scenes and significantly improves the robustness and accuracy of localization. To further improve HRNet's feature extraction capabilities and address the challenge of fine-grained pattern recognition, standard convolutional layers were replaced with central difference convolutions (CDC), as shown in the attached diagram. Figure 2 As shown. CDC is particularly well-suited for tasks requiring robust modeling of invariant fine-grained features across different environments, giving the network an enhanced ability to recognize subtle changes, which is crucial for accurate cell localization, especially in complex or blurred areas of medical images.

[0028] Step 2: Introducing the multi-scale pixel-level occupancy estimation module:

[0029] To address the challenges of feature extraction and precise localization in cell counting, we designed a novel network integrating two main modules. The Dynamic Multi-Scale Encoding (DyME) module selects the most effective cell morphology features from a multi-scale receptive field, while the Pixel Occupancy Estimation (PwOE) module uses prior location information to guide the network to focus on the actual cell region. Both modules work collaboratively through a cross-attention mechanism, combining the accurate "what" features extracted by DyME with the accurate "where" localization provided by PwOE. This overcomes the regression imbalance problem, achieving efficient and accurate cell localization and counting.

[0030] The core idea of ​​the multi-scale pixel-wise occupancy estimation (PwOE) module is to explicitly introduce spatial occupancy information—"where are the cells?"—as supervision and features into the density regression backbone, thereby alleviating the regression imbalance of "center dominance and edge neglect" in traditional Gaussian density map training from the source. Specifically, a density / kernel map is first generated from point annotations, and then binarized to obtain the ground truth occupancy map. (Pixels with a density value greater than zero are marked as 1, otherwise as 0), thus bringing the supervision contribution of each pixel within the cell to the same order of magnitude, no longer dominated solely by the central peak; the model uses a parallel occupancy branch to predict ( Using binary cross-entropy as the loss for this branch, the network is forced to learn continuous "foreground regions" at the pixel level rather than just center points. To ensure that this location / occupancy cue effectively modifies the backbone representation, PwOE further uses the features extracted from the occupancy branch as a "query" and performs cross-attention fusion with the backbone (and multi-scale semantic features selected by DyME). The location information of "I think there should be cells here" is used to retrieve and enhance the semantic information of "what shape / which scale is most suitable", resulting in fused features that have both accurate spatial alignment and discriminative semantics. During training, the overall objective is to weight and sum the density map regression loss (such as MSE, often combined with edge-sensitive terms to emphasize contours) and the BCE loss of the occupancy branch. During inference, the occupancy-guided fused features will produce sharper, separable peak responses in crowded, overlapping, and blurred boundary scenes, and significantly improve the consistency between edges and the overall shape. In other words, DyME is responsible for "seeing clearly" at multiple scales, while PwOE is responsible for "positioning" at the pixel level. Together, they learn "what to see" and "where" at the same time, thereby improving the positioning F1 and counting stability.

[0031] Step 3: Introduce the components of the loss function:

[0032] This method designs a unified optimization objective for the dual tasks of "density map regression + pixel-level occupancy classification", which consists of three weighted components: density map regression loss, pixel-level occupancy loss, and so on. And the edge-sensitive items within it Density map regression uses mean squared error (MSE) to ensure global numerical consistency and introduces edge-sensitive constraints to enhance structural fidelity. A linear combination of these two methods yields:

[0033]

[0034] in ,in The balancing coefficient is used. The edge sensitivity term is calculated using the first norm difference of the density map's discrete gradient (Sobel) in the horizontal / vertical directions, in the form of:

[0035]

[0036] Explicit constraints are used to predict and label spatial gradients in transition regions, thereby highlighting fine-grained boundaries and morphological details and mitigating the bias of traditional regression towards the central peak. Pixel-level occupancy loss is used for the supervised-aided PwOE branch, which is based on the binary occupancy map obtained by thresholding point labels. Pixel-by-pixel binary classification learning is performed using binary cross-entropy:

[0037]

[0038] in For occupancy probability prediction, N is the number of pixels. The final total loss is defined as:

[0039]

[0040] Used to weigh the intensity of object-perception supervision. In the example, =0.3、 A value of 0.01 yields stable and effective joint optimization, improving localization and boundary clarity while maintaining counting accuracy. Ablation results further demonstrate that replacing or introducing the aforementioned edge-sensitive terms significantly reduces MAE / RMSE and produces clearer density peaks and boundary responses in high-density, complex-morphology scenarios, validating the effectiveness of this loss design in terms of structural fidelity and localization robustness.

[0041] A Balanced Density Regression Network (EFNet) is proposed. By introducing multi-scale pixel-level occupancy estimation (PwOE) and dynamic multi-scale enhancement (DyME) modules, and coordinating edge-sensitive constraints, it effectively alleviates the imbalance problem of traditional density regression in cell center and boundary learning, thereby improving both localization accuracy and counting stability. On several publicly available cell microscopy image datasets, EFNet achieves better localization and counting performance than existing methods, verifying the robustness and advancement of the proposed method in high-density and morphologically complex scenes. Attached Figure Description

[0042] Figure 1 This is a schematic diagram illustrating the characteristics of the cell dataset targeted by this invention.

[0043] Figure 2 This is a framework diagram of the overall model in this invention.

[0044] Figure 3 This is a framework diagram of the overall model in this invention. Detailed Implementation

[0045] A method for locating and counting dense scenes based on equilibrium density regression, comprising the following steps:

[0046] Step 1: Download the BCData, ccRCC Grading, CoNIC, and PSU datasets in the following format:

[0047] The original image resolutions and field-of-view scales of the aforementioned datasets vary (ranging from small field-of-view patches to full-slice sub-blocks), but the label processing method remains consistent: for each image, the cell point coordinates in the annotation file are directly read, a two-dimensional Gaussian kernel is placed at the corresponding pixel position, and the kernels are accumulated to generate a density map, ensuring that the sum of the pixels in the density map equals the number of labeled cells in the image. Thus, the supervision signals from BCData, ccRCC Grading, CoNIC, and PSU are unified into a form where point annotations are converted into Gaussian density maps, facilitating unified training and evaluation across datasets. Therefore, the dense scene localization and counting problem can be defined as a cell localization and counting problem on a cell map.

[0048] Step 2: Perform color normalization and batch effect correction on full-slice sub-blocks / images, removing out-of-focus, contaminated, and severely striped samples; standardize the long side to a fixed scale (e.g., 512 or 640) while maintaining the aspect ratio; divide the training / validation / test sets into an 8:1:1 ratio to ensure a balanced stratification of tissue sites and experimental sources. For the point-level coordinates provided in each dataset, a unified strategy is used to generate supervision signals: place a two-dimensional Gaussian kernel at the point coordinates and accumulate it to form a density map, the pixel sum of which is consistent with the target cell number; simultaneously, threshold the density map to obtain a binary occupancy map for PwOE branch supervision. To improve the peak separability in crowded regions, a sharper density shaping (e.g., FIDT-style center enhancement) can be used as the main regression target to reduce peak adhesion caused by Gaussian overlap.

[0049] Step 3: The backbone employs a multi-branch convolutional network (such as HRNet) that preserves high-resolution features and replaces standard convolutions with central difference convolutions (CDC) to enhance boundary / gradient sensitivity. A dynamic multi-scale enhancement module (DyME) is embedded at the encoding end to achieve robust cross-scale representation through feature selection with different hole rates / receptive fields. A pixel-level occupancy estimation (PwOE) branch is introduced into the auxiliary pathway to output a cell occupancy probability map, which is then fused with backbone features across attention, thereby enhancing the spatial separation capability of neighboring targets while maintaining counting consistency. The prediction head outputs a density map, and coordinate-level localization is obtained during the inference stage through local peak detection.

[0050] Step 3: The backbone employs a multi-branch convolutional network (such as HRNet) that preserves high-resolution features and replaces standard convolutions with central difference convolutions (CDC) to enhance boundary / gradient sensitivity. A dynamic multi-scale enhancement module (DyME) is embedded at the encoding end to achieve robust cross-scale representation through feature selection with different hole rates / receptive fields. A pixel-level occupancy estimation (PwOE) branch is introduced into the auxiliary pathway to output a cell occupancy probability map, which is then fused with backbone features across attention, thereby enhancing the spatial separation capability of neighboring targets while maintaining counting consistency. The prediction head outputs a density map, and coordinate-level localization is obtained during the inference stage through local peak detection.

[0051] Step 4: A weighted combination of density regression basis loss (such as MSE) and edge-sensitive loss is used. The latter constrains the gradient difference between the predicted and ground truth density maps to improve structural fidelity of blurred edges and contiguous regions. The PwOE branch uses binary cross-entropy for pixel-level supervision. The global loss is a weighted sum of the two, and uncertainty-based weighting or hard example mining is introduced to adaptively balance easy and hard samples. During training, the Adam optimizer, cosine annealing, or multi-step learning rate decay is used, along with data augmentation through random flipping / scaling / color perturbation to improve generalization ability.

[0052] Step 5: Output density and occupancy maps at the inference end: First, smoothing and local extremum search (or LoG / DoG peak detection) are performed on the density map. Then, non-maximum suppression and minimum distance thresholding are used for deduplication to obtain the final cell center coordinates. For abnormally high-density regions, consistency verification is performed by combining PwOE occupancy probability and edge saliency map to reduce false detections and peak merging. The final output includes a list of coordinates, count values, and uncertainty score.

[0053] Step 6: Finally, after the student network training is completed, the student network can be used directly to predict traffic data.

[0054] In the experimental data of this invention, localization was evaluated using Precision / Recall / F1@r (r=5 / 10 pixels), and counting was evaluated using MAE / RMSE. For cross-dataset / cross-center validation, the stratification index by staining / tissue subtype was reported. Classical density regression, detection-based, and segmentation-based methods were compared, and ablation experiments were conducted to verify the contributions of FIDT-based density supervision, CDC, DyME, and PwOE to crowded / weakly contrasted samples. The prediction error was evaluated and analyzed using the Mean Absolute Error (MAE), Root Mean Squared Error (RMSE), and Mean Absolute Percentage Error (MAPE) evaluation criteria.

[0055]

[0056]

[0057]

[0058]

[0059]

Claims

1. A balanced density regression method for object localization and counting in dense scenes, characterized in that, Includes the following steps: Data preprocessing and annotation conversion steps: Obtain the original image containing dense targets and its corresponding point-level annotations, generate a density map based on the point-level annotations as a regression supervision signal, and generate a binary occupancy map by thresholding the density map as a supervision signal for pixel-level occupancy estimation; Feature extraction and multi-scale enhancement steps: The preprocessed image is input into a pre-constructed backbone network to extract high-resolution feature maps; A dynamic multi-scale enhancement module is introduced at the encoding end of the backbone network to obtain robust morphological feature representations across scales through feature selection and adaptive fusion of different receptive fields. Occupation estimation and feature fusion steps: Construct parallel pixel-level occupancy estimation branches, using the binary occupancy map as supervision, to learn and predict pixel-level cell occupancy probability maps; through a cross-attention mechanism, fuse the location prior information extracted by the occupancy estimation branches with the semantic features extracted by the backbone network and the multi-scale features output by the dynamic multi-scale enhancement module to generate fused features that simultaneously possess accurate spatial localization and discriminative semantics. Density regression and post-processing steps: Based on the fused features, the final predicted density map is output through the prediction head; during the inference stage, local peak detection is performed on the predicted density map to obtain the center coordinates of each target and count the total number of targets.

2. The method of claim 1, wherein, The backbone network is a multi-branch convolutional network that maintains high-resolution features, and the standard convolutional layers are replaced with central difference convolutions to enhance the model's sensitivity to boundary and gradient information.

3. The method of claim 1, wherein, The density map employs a focal inverse distance transform, which generates a density map with sharper, non-overlapping peaks to clearly characterize the center of each target.

4. The method of claim 1, wherein, In the density regression and post-processing steps, the loss function of the training process is a weighted combination of density map regression loss and pixel-level occupancy estimation loss; the density map regression loss further includes a base loss and an edge-sensitive loss, the edge-sensitive loss being used to constrain the consistency between the predicted density map and the true density map in the gradient domain, so as to enhance the structural fidelity and boundary clarity of the prediction results.

5. The method of claim 4, wherein, The basic loss is the mean squared error loss, which is used to ensure global numerical consistency between the predicted density map and the true density map.

6. The method of claim 4, wherein, The edge-sensitive loss is calculated based on the difference between the discrete gradients of the predicted density map and the true density map in the horizontal and vertical directions.

7. The method of claim 4, wherein, The pixel-level occupancy estimation loss is a binary cross-entropy loss, used to supervise the prediction of the occupancy probability map at the pixel level.

8. A balanced density regression device for object localization and counting in dense scenes, characterized by, include: The preprocessing module is used to acquire the original image containing dense targets and its corresponding point-level annotations, generate a density map based on the point-level annotations as a regression supervision signal, and generate a binary occupancy map by thresholding the density map as a supervision signal for pixel-level occupancy estimation. The feature extraction and enhancement module is used to input the preprocessed image into the pre-constructed backbone network to extract high-resolution feature maps, and to perform feature selection and adaptive fusion of different receptive fields on the feature maps through the dynamic multi-scale enhancement module to obtain robust morphological feature representations across scales. The occupancy estimation and fusion module is used to construct a parallel pixel-level occupancy estimation branch. Using the binary occupancy map as supervision, it learns to predict the pixel-level cell occupancy probability map and fuses the occupancy prior information with semantic features and multi-scale features through a cross-attention mechanism to generate fused features. The output and post-processing module is used to output the final prediction density map through the prediction head based on the fused features, and to perform local peak detection on the prediction density map during the inference stage to obtain the center coordinates of each target and the total number of targets.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the balanced density regression method for object localization and counting in dense scenes as described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the balanced density regression method for object localization and counting in dense scenes as described in any one of claims 1 to 7.