Target counting method and apparatus, electronic device, and storage medium

CN122798697APending Publication Date: 2026-09-22CHINA MOBILE COMM LTD RES INST +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610658888.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-13
Publication Date
2026-09-22

AI Technical Summary

Technical Problem

这些方法虽然在特定场景下能达到一定精度,但严重依赖训练数据,泛化能力差

Benefits of technology

[0016]本申请提供的目标计数方法、装置、电子设备和存储介质,基于预设多模态大模型的零样本能力,无需针对特定目标进行耗时耗力的样本标注和模型训练,具备极强的泛化性和快速部署能力;通过逻辑网格划分和局部计数与累加的策略,将复杂的高密度计数任务分解为多个简单的低密度计数子任务,有效降低了多模态大模型的推理负担,显著提升了在密集场景下的计数准确性;通过融合机制,强制预设多模态大模型对其两种不同维度的计数结果进行自我审查和修正,能够有效克服单一计数路径带来的固有缺陷,使得最终输出的计数结果比任何单一的计数方式都更加稳健和精确;有效克服了相关技术中泛化能力与密集场景准确性难以兼顾的技术难题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122798697A_ABST
    Figure CN122798697A_ABST
Patent Text Reader

Abstract

The application provides a target counting method and device, electronic equipment and storage medium, relates to the technical field of artificial intelligence, and includes: performing logical grid division on an original image to obtain a grid image; inputting the original image and the grid image into a preset multi-modal large model synchronously, generating a first counting result by the preset multi-modal large model for global counting of the original image, and generating a second counting result by the preset multi-modal large model for grid region counting and accumulation of the grid image, fusing the first counting result and the second counting result, and outputting a final counting result; and determining a counting result of a target object in the original image based on the final counting result. The method and device provided by the application have strong generalization and rapid deployment capabilities based on the zero-shot capability of the multi-modal large model, without time-consuming and laborious sample labeling and model training. Through the strategy of logical grid division, local counting and accumulation, the counting accuracy in a dense scene is significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a target counting method, apparatus, electronic device, and storage medium. Background Technology

[0002] Object counting is a fundamental and important task in computer vision, aiming to automatically count the number of objects of a specific category in an image or video. This technology is widely used in vertical industry scenarios such as crowd counting, traffic monitoring, security surveillance, and animal and plant population estimation.

[0003] Related technologies employ object detection or density map-based methods for object counting. While these methods can achieve a certain level of accuracy in specific scenarios, they heavily rely on training data and exhibit poor generalization ability.

[0004] Therefore, how to improve the accuracy of target counting without relying on a large amount of labeled data and specialized training has become a technical problem that the industry urgently needs to solve. Summary of the Invention

[0005] This application provides a target counting method, apparatus, electronic device, and storage medium to address the technical problem of improving the accuracy of target counting without relying on large amounts of labeled data and specialized training.

[0006] This application provides a target counting method, including: Obtain the original image containing the target object; The original image is divided into logical grids to obtain a grid image containing multiple grid regions; The original image and the grid image are synchronously input into a preset multimodal large model. The preset multimodal large model performs global counting on the original image to generate a first counting result, and performs grid region counting and accumulation on the grid image to generate a second counting result. The first counting result and the second counting result are then fused to output the final counting result. Based on the final counting result, the counting result of the target object in the original image is determined.

[0007] In some embodiments, the step of synchronously inputting the original image and the grid image into a preset multimodal large model, having the preset multimodal large model perform global counting on the original image to generate a first counting result, and performing grid region counting and accumulation on the grid image to generate a second counting result, and fusing the first counting result and the second counting result to output a final counting result, includes: Construct preset prompts; The preset prompt words, the original image, and the grid image are simultaneously input into the preset multimodal large model to obtain the final counting result output by the preset multimodal large model; The preset prompt word is used to instruct the preset multimodal large model to perform the following operations: The target objects in the original image are identified and a global count is performed to obtain the first counting result; The target objects in each grid region of the grid image are identified and local counts are performed in each grid region. The results are accumulated with reference to the original image to obtain the second counting result. The first counting result and the second counting result are merged to obtain the final counting result; Output the first counting result, the second counting result, and the final counting result.

[0008] In some embodiments, fusing the first counting result and the second counting result to obtain the final counting result includes: Compare the first counting result with the second counting result; If there is a deviation between the first counting result and the second counting result, the second counting result is corrected based on the image features of the original image to generate the final counting result.

[0009] In some embodiments, identifying the target object within each grid region of the grid image and performing local counting of each grid region includes: Based on a preset sequence, each grid region in the grid image is scanned to identify the target object in each grid region and record the number of the target objects in each grid region.

[0010] In some embodiments, identifying the target object within each grid region of the grid image and performing local counting of each grid region includes: When any target object is located in at least two adjacent grid regions, a local count is performed based on the area ratio of the target object in each adjacent grid region.

[0011] In some embodiments, dividing the original image into logical grids to obtain a grid image containing multiple grid regions includes: Based on the scene information of the original image or the features of the target object, determine the number and / or size of the grid regions; The original image is logically divided into grids based on the number and / or size of the grid regions.

[0012] This application provides a target counting device, comprising: The acquisition module is used to acquire the original image containing the target object; The partitioning module is used to perform logical grid partitioning on the original image to obtain a grid image containing multiple grid regions; The counting module is used to synchronously input the original image and the grid image into a preset multimodal large model, and the preset multimodal large model performs global counting on the original image to generate a first counting result, and performs grid region counting and accumulation on the grid image to generate a second counting result, and fuses the first counting result and the second counting result to output the final counting result; A determining module is used to determine the count result of the target object in the original image based on the final counting result.

[0013] This application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the target counting method.

[0014] This application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the target counting method described above.

[0015] This application provides a computer program product, including a computer program that, when executed by a processor, implements the target counting method.

[0016] The target counting method, apparatus, electronic device, and storage medium provided in this application, based on the zero-shot capability of a pre-defined multimodal large model, eliminate the need for time-consuming and labor-intensive sample annotation and model training for specific targets, exhibiting strong generalization and rapid deployment capabilities. Through logical grid partitioning and local counting and accumulation strategies, the complex high-density counting task is decomposed into multiple simple low-density counting subtasks, effectively reducing the inference burden of the multimodal large model and significantly improving counting accuracy in dense scenes. Through a fusion mechanism, the pre-defined multimodal large model is forced to self-check and correct its counting results from two different dimensions, effectively overcoming the inherent defects of a single counting path, resulting in a more robust and accurate final output than any single counting method. This effectively overcomes the technical challenge of balancing generalization capability and accuracy in dense scenes in related technologies. Attached Figure Description

[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0018] To more clearly illustrate the technical solutions in 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 some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a flowchart illustrating the target counting method provided in this application.

[0020] Figure 2 This is a schematic diagram of the image grid division provided in this application.

[0021] Figure 3 This is a schematic diagram of the target counting device provided in this application.

[0022] Figure 4 This is a schematic diagram of the structure of the electronic device provided in this application. Detailed Implementation

[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0024] It should be noted that the terms "first," "second," etc., used in this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that comprises a series of steps, units, or modules is not necessarily limited to those explicitly listed, but may include other steps, units, or modules not explicitly listed or inherent to such processes, methods, products, or devices.

[0025] In related technologies, detection frameworks such as Faster R-CNN and YOLO are used to detect and count each target in an image. However, these methods are prone to missed detections and overlapping detections in dense target scenes. Generating density maps and calculating the number of targets through convolutional neural networks can handle dense targets better, but they heavily rely on labeled data and have poor generalization. None of the above methods can be implemented in zero-shot scenarios.

[0026] In order to address the shortcomings of related technologies, Figure 1 This is a flowchart illustrating the target counting method provided in this application, as shown below. Figure 1 As shown, the method includes steps 110, 120, 130 and 140.

[0027] Step 110: Obtain the original image containing the target object.

[0028] Specifically, the execution subject of the target counting method provided in this application embodiment is a target counting device. This device can be implemented by software, such as a target counting program; or it can be a device that executes the target counting method, such as a terminal, computer, or server.

[0029] The original image can be a digital image from any source. For example, it can be an image captured in real time by image acquisition devices such as cameras or surveillance cameras, or an existing image file read from a storage device (such as a hard drive or cloud storage). The content characteristic of the original image is that it contains at least one or more target objects to be counted.

[0030] The category of the target object is not specifically limited and can be any visually distinguishable entity. For example, in the fields of smart cities and public safety, the target object can be a person in a crowd or a vehicle on a road; in the field of ecological monitoring, the target object can be birds, mammals, etc.; in the field of agriculture, it can be crops in a field or fruit in an orchard. The method of this application aims to provide a general counting framework that can adapt to different categories of target objects with zero samples.

[0031] Step 120: Divide the original image into logical grids to obtain a grid image containing multiple grid regions.

[0032] Specifically, logical grid partitioning refers to conceptually or visually dividing the two-dimensional space of the original image into a grid composed of... lines and A regular grid composed of columns, thus forming Each independent grid region (of which) and It is an integer greater than or equal to 1, and , (Not both 1). This division can be a purely logical division, where each pixel is determined to belong to a specific grid region based on coordinate information in subsequent processing, without actually drawing lines on the image; or it can involve drawing visual dividing lines on a copy of the original image to aid in the understanding of the subsequent model.

[0033] Figure 2This is a schematic diagram of the image mesh division provided in this application, such as... Figure 2 As shown, the original image is divided into That is, 9 grid areas.

[0034] The image obtained after segmentation is referred to as a grid image in this embodiment of the application. The grid image is identical to the original image in pixel content, but with the addition of grid region segmentation information. The granularity of the segmentation, i.e. and The value of can be preset according to the complexity of the scene and the density of the target objects. For example, for a scene where the target objects are sparsely distributed, fewer grids can be used; while for a scene where the target objects are highly dense, more grids can be used to reduce the counting complexity in each sub-region.

[0035] Step 130: Simultaneously input the original image and the grid image into the preset multimodal large model. The preset multimodal large model performs global counting on the original image to generate a first counting result, and performs grid region counting and accumulation on the grid image to generate a second counting result. The first counting result and the second counting result are then fused to output the final counting result.

[0036] Specifically, a pre-trained multimodal large model refers to a visual language model (VLM) that has been pre-trained on a large scale and is capable of processing both image and text inputs simultaneously. The key feature of this type of model is its powerful zero-shot reasoning capability, meaning that it can understand instructions and complete tasks without needing fine-tuning for specific counting tasks.

[0037] Synchronous input refers to providing the original image and the grid image as two independent but related inputs in a single request to a pre-defined multimodal large model. This allows the model to access both global image information (from the original image) and local image information (from the grid image) simultaneously during a single inference process.

[0038] Upon receiving input, the pre-defined multimodal large model is configured or instructed to perform a complex operation containing three subtasks: (1) Global Count: The model first observes the complete original image and, relying on its overall visual understanding ability, quickly performs a macroscopic and holistic count of all visible target objects in the image. The output result is the first count result (Global Count).

[0039] (2) Counting and Accumulation by Grid Region: In parallel or serial with the global count, the model also observes the grid image. It systematically examines each grid region (Sub Region) and performs independent, local counting of the target objects within each region. After completing the local counting of all grid regions, the model accumulates these local count values ​​to obtain a sum. The output is the second counting result (Sub Region Sum). This method is more detailed, but it may cause problems of duplicate or missed counts when dealing with target objects that cross grid boundaries.

[0040] (3) Result Fusion: The pre-defined multimodal large model compares and analyzes the first and second count results obtained from the two different paths. When the two results are inconsistent, the model will initiate an internal fusion logic. This fusion process does not simply select one of the results, but rather comprehensively utilizes the global features of the original image and the local details of the grid image to intelligently reason and correct the two results. For example, using the more ordered local statistical results as the core reference, combined with the image details of the original image, logical correction is performed to obtain the final accurate value, which is the Calibrated Final Count.

[0041] Step 140: Based on the final counting result, determine the counting result of the target object in the original image.

[0042] Specifically, the final counting result output by the preset multimodal large model can be used as the counting result of the target object in the original image.

[0043] The target counting method provided in this application, based on the zero-shot capability of a pre-defined multimodal large model, eliminates the need for time-consuming and labor-intensive sample labeling and model training for specific targets, exhibiting strong generalization and rapid deployment capabilities. Through logical grid partitioning and local counting and accumulation strategies, the complex high-density counting task is decomposed into multiple simple low-density counting subtasks, effectively reducing the inference burden of the multimodal large model and significantly improving counting accuracy in dense scenarios. Through a fusion mechanism, the pre-defined multimodal large model is forced to self-examine and correct its counting results from two different dimensions, effectively overcoming the inherent defects of a single counting path, resulting in a more robust and accurate final output than any single counting method. This effectively overcomes the technical challenge of balancing generalization capability and accuracy in dense scenarios in related technologies.

[0044] It should be noted that each implementation method of this application can be freely combined, rearranged, or executed individually, and does not need to rely on or depend on a fixed execution order.

[0045] In some embodiments, the original image and the grid image are synchronously input into a preset multimodal large model. The preset multimodal large model performs global counting on the original image to generate a first counting result, and performs grid region counting and accumulation on the grid image to generate a second counting result. The first counting result and the second counting result are then fused to output a final counting result, including: Construct preset prompts; The preset prompt words, the original image, and the grid image are simultaneously input into the preset multimodal large model to obtain the final counting result output by the preset multimodal large model; The preset prompts are used to instruct the preset multimodal large model to perform the following operations: Identify the target objects in the original image and perform a global count to obtain the first count result; Identify target objects within each grid region of the grid image and perform local counting for each grid region. Then, accumulate the results with reference to the original image to obtain a second counting result. The first and second counting results are merged to obtain the final counting result; Output the first count result, the second count result, and the final count result.

[0046] Specifically, the preset prompts are essentially a piece of natural language text whose content and structure are specially designed to eliminate the ambiguity of the task and ensure that the model can accurately understand the specific operation it needs to perform.

[0047] Preset prompts can include task descriptions, input instructions, execution logic, and output formats.

[0048] For example, a typical preset prompt word can be constructed as follows (where {Obj} is the name of the target object to be counted): Task Description: You are a highly accurate visual counting expert. Please use a dual verification method combining "global preliminary exploration" and "local verification" to count the number of {Obj} in the image.

[0049] Input instructions: The first image is the original image, and the second image is a grid image, which is drawn horizontally based on the original image. Draw ) horizontal lines, and draw (in the vertical direction) ) vertical lines logically divide the original image into A square.

[0050] Execution logic: Global estimation: observe the first image, give an initial intuitive judgment on the total number of {Obj} based on the overall visual distribution, and record it as the first counting result (Global Count).

[0051] Block accumulation: observe the second image, scan each grid area one by one in the order from left to right and top to bottom. Record the number within each sub-region (Sub-region). If an object crosses a boundary, determine its attribution according to the proportion of the main body to ensure no repetition and no omission. Sum the counts of all sub-grids, and record it as the second counting result (Sub Region Sum).

[0052] Fusion: compare the first counting result with the second counting result. If there is a deviation, take the more ordered local statistical result as the core reference, perform logical correction combined with image details to obtain the final accurate value, which is recorded as the final counting result (Calibrated Final Count).

[0053] Output format: Please return the result only in JSON format: JSON{"First Counting Result":<value of Global Count>, "Second Counting Result": <sub region sum的值>," 最终计数结果":<Calibrated Final Count的值>}”。

[0054] 构造好预设提示词后,将其与原始图像、网格图像,共同作为一次请求的完整输入,提交给预设多模态大模型。

[0055] 预设多模态大模型在接收到这个包含两张图片和一段文本的复合输入后,会首先解析预设提示词中的指令。根据指令,模型会执行上述两个计数任务,并按照提示词中要求的格式(例如JSON格式)来组织其输出。

[0056] 本申请实施例提供的目标计数方法,通过构造结构化的预设提示词,实现了对多模态大模型行为的精确控制;将一个内隐的、复杂的模型推理过程,转化为一个外显的、由清晰指令控制的、可重复的工作流;极大地提升了整个目标计数方法的可控性和稳定性。

[0057] 在一些实施例中,对第一计数结果和第二计数结果进行融合,得到最终计数结果,包括:对比第一计数结果与第二计数结果;在第一计数结果与第二计数结果存在偏差的情况下,基于原始图像的图像特征对第二计数结果进行修正,生成最终计数结果。

[0058] 具体地,在预设多模态大模型分别通过全局视角和分网格区域累加两种路径,独立地生成了第一计数结果和第二计数结果之后,融合机制首先被触发。

[0059] 预设多模态大模型会判断两个结果是否相等。

[0060] 若两个结果相等,这表明从宏观和微观两个尺度上得到的结论是一致的,具有很高的置信度。在这种情况下,可以认为该计数值是准确的,模型可以直接将此数值作为最终计数结果输出,融合流程结束。

[0061] 若两个结果不相等,即两者之间存在偏差,则表明至少有一种计数路径可能存在误差。此时,需要启动下一步的修正流程。

[0062] 当偏差被检测到后,预设多模态大模型并非简单地取平均值或选择其中一个,而是以结构更精细的第二计数结果(分网格区域计数累加结果)为基础,利用原始图像的图像特征作为判据,对其进行审查和修正。

[0063] 原始图像的图像特征,是指能够揭示目标物体分布、状态和相互关系的视觉信息,这些信息对于判断计数误差的来源至关重要。

[0064] 预设多模态大模型在修正过程中会重点分析但不限于以下图像特征:(1)边界区域特征:模型会重点审视那些位于网格线附近的区域。在原始图像上,一个目标物体可能恰好被一条或多条逻辑网格线分割。分网格计数时,这种情况极易导致该物体在相邻的两个或多个网格区域中被重复计数。模型通过分析原始图像中这些边界区域的连通性,可以判断出跨网格的物体实为一个整体,从而对第二计数结果进行减法修正,消除重复计数。

[0065] (2)密集与遮挡特征:模型会分析原始图像中目标物体的分布密度和遮挡情况。全局计数(第一计数结果)在处理高度密集或严重遮挡的区域时,很容易发生遗漏。如果第二计数结果显著高于第一计数结果,并且差异主要来自于某些特定网格区域,模型就会检查原始图像中这些区域是否具有高密度或遮挡的图像特征。如果确认存在,模型会采信第二计数结果的合理性。

[0066] (3)尺寸与形态特征:模型会分析目标物体的尺寸和形态多样性。如果目标物体尺寸差异巨大,全局计数可能会忽略掉一些尺寸过小的目标。当偏差出现时,模型可以重新审视原始图像,验证那些由分网格计数发现、但可能被全局计数遗漏的小尺寸目标,并以此为依据来修正计数。

[0067] 本申请实施例提供的目标计数方法,以更细致的局部计数为基础,利用原始图像的图像细节来审查和修正潜在的错误;使得最终输出的计数结果在逻辑上更自洽、在数值上更逼近真实值,显著提升了整个目标计数方法的可靠性和准确度。

[0068] 在一些实施例中,识别网格图像中各个网格区域内的目标物体并对各个网格区域进行局部计数,包括:基于预设顺序扫描网格图像中各个网格区域,识别各个网格区域内的目标物体,记录各个网格区域内的目标物体的数量。

[0069] 具体地,预设顺序是指一个预先规定好的、用于遍历所有网格区域的确定性序列。采用预设顺序的目的是为了保证每一个网格区域都被检查到,且仅被检查一次,从而避免在局部计数阶段发生遗漏或重复处理。预设顺序具体可以是从左至右、从上至下的顺序等。

[0070] 预设多模态大模型会按照预设的扫描顺序,对每一个网格区域重复执行"识别-计数-记录”的微循环,直至所有网格区域都被处理完毕。这个过程完成后,模型就获得了一份详尽的、每个网格区域内目标物体数量的数据。这份数据是后续进行结果累加,生成第二计数结果的基础。

[0071] 本申请实施例提供的目标计数方法,确保了局部计数的完备性,即不重不漏地覆盖了整个图像区域。同时,它将复杂的全图计数任务,有序地分解为一系列简单、独立的子区域计数任务,极大地降低了模型的单次处理复杂度,使得整个局部计数过程更加稳定、可靠。

[0072] 在一些实施例中,识别网格图像中各个网格区域内的目标物体并对各个网格区域进行局部计数,包括:在任一目标物体处于至少两个相邻网格区域的情况下,基于任一目标物体在各个相邻网格区域中所占的面积比例进行局部计数。

[0073] 具体地,可以对预设提示词进行进一步的增强和细化。在构造预设提示词时,增加一条关于如何处理边界物体的明确指令。例如,可以在前述实施例的预设提示词中增加如下内容:"对于任何处于网格分割线上的‘{Obj}’,请根据其主体在各个相邻区域中所占的视觉面积比例,进行小数(或分数)计数。例如,如果一个‘{Obj}’约有一半在A区,一半在B区,则在A区计数为0.5,在B区计数为0.5。然后将所有区域的计数值累加求和,将最终总和记为第二计数结果。”当预设多模态大模型接收到这条指令后,其在执行局部计数任务时会采用如下方式:对于完全包含在单个网格区域内的目标物体,其在该区域的计数值为1。

[0074] 对于一个被分割线切割的目标物体,模型会利用其视觉理解能力,估算该物体分布在相邻的个网格区域中的面积比例。其中,。随后,在计算每个区域的局部计数值时,该物体对第个相邻区域的贡献计数值即为,。例如,假设一辆汽车的60%车身位于网格A,40%车身位于相邻的网格B。当模型按照本申请实施例的指令进行局部计数时:在统计网格A的物体数量时,这辆汽车会被记为0.6个。在统计网格B的物体数量时,这辆汽车会被记为0.4个。在后续的累加步骤中,这辆汽车对第二计数结果(Sub Region Sum)的总贡献为,不多也不少,从而实现了精确计数。

[0075] 本申请实施例提供的目标计数方法,将基于面积比例的边界目标计数方法以预设提示词的方式传达给多模态大模型,巧妙地解决了网格划分方法中固有的边界处理难题;充分利用了视觉-语言大模型不仅能识别物体,还能进行一定程度的空间关系和比例估算的先进能力;显著提升了局部计数汇总结果的准确性,使得最终融合后的计数结果更加逼近真实值。

[0076] 在一些实施例中,对原始图像进行逻辑网格划分,得到包含多个网格区域的网格图像,包括:基于原始图像的场景信息或目标物体的特征,确定网格区域的数量和 / 或尺寸;基于网格区域的数量和 / 或尺寸,对原始图像进行逻辑网格划分。

[0077] 具体地,场景信息可以包括:(1)目标密度:场景中目标物体的密集程度,可分为稀疏、中等、密集等级别;(2)目标分布:目标物体是均匀分布在整个图像,还是聚集在某些特定区域。

[0078] 目标物体的特征可以包括:物体尺寸:待计数的物体在图像中的平均像素尺寸。尺寸较大的物体(如公交车)可能适合较粗的网格,而尺寸较小的物体(如人群中的人脸)则可能需要更细的网格。

[0079] 确定网格区域的数量和 / 或尺寸的具体实现方式有多种。在本申请实施例中,可以利用预设多模态大模型自身的强大理解能力,通过一个额外的交互步骤来确定网格参数。例如,可以设计一个两阶段的提示过程:第一阶段(分析阶段):向模型输入原始图像,并使用提示词:"请分析此图像中‘{Obj}’的分布密度,并从‘稀疏’、‘中等’、‘密集’中选择一个最合适的描述。”第二阶段(决策与计数阶段):根据模型在第一阶段的输出,程序自动选择一个与之匹配的网格数量(例如,‘稀疏’对应,‘中等’对应,‘密集’对应),然后再执行前述实施例中的包含双重计数任务的主提示流程。

[0080] 在确定了最佳的网格参数后,再按照这些参数对原始图像进行逻辑网格划分,生成后续步骤所需的网格图像。

[0081] 本申请实施例提供的目标计数方法,通过自适应网格划分机制,能够根据输入图像的具体内容,智能地选择最优的网格划分方法;显著提升了方法在不同场景下的普适性和平均准确率,同时也使得整个计数流程更加自动化和智能化,减少了人工设置参数的需要。

[0082] 下面对本申请实施例提供的装置进行描述,下文描述的装置与上文描述的方法可相互对应参照。

[0083] 图3是本申请提供的目标计数装置的结构示意图,如图3所示,该装置包括:获取模块310,用于获取包含目标物体的原始图像;划分模块320,用于对原始图像进行逻辑网格划分,得到包含多个网格区域的网格图像;计数模块330,用于将原始图像和网格图像同步输入预设多模态大模型,由预设多模态大模型对原始图像进行全局计数生成第一计数结果,以及对网格图像进行分网格区域计数和累加生成第二计数结果,并对第一计数结果和第二计数结果进行融合,输出最终计数结果;确定模块340,用于基于最终计数结果,确定原始图像中目标物体的计数结果。

[0084] 本申请实施例提供的目标计数装置,基于预设多模态大模型的零样本能力,无需针对特定目标进行耗时耗力的样本标注和模型训练,具备极强的泛化性和快速部署能力;通过逻辑网格划分和局部计数与累加的策略,将复杂的高密度计数任务分解为多个简单的低密度计数子任务,有效降低了多模态大模型的推理负担,显著提升了在密集场景下的计数准确性;通过融合机制,强制预设多模态大模型对其两种不同维度的计数结果进行自我审查和修正,能够有效克服单一计数路径带来的固有缺陷,使得最终输出的计数结果比任何单一的计数方式都更加稳健和精确;有效克服了相关技术中泛化能力与密集场景准确性难以兼顾的技术难题。

[0085] 图4是本申请提供的电子设备的结构示意图,如图4所示,该电子设备可以包括:处理器(Processor)410、通信接口(Communications Interface)420、存储器(Memory)430和通信总线(Communications Bus)440,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信。处理器可以调用存储器中的逻辑命令,以执行上述实施例中所述的方法,例如:获取包含目标物体的原始图像;对原始图像进行逻辑网格划分,得到包含多个网格区域的网格图像;将原始图像和网格图像同步输入预设多模态大模型,由预设多模态大模型对原始图像进行全局计数生成第一计数结果,以及对网格图像进行分网格区域计数和累加生成第二计数结果,并对第一计数结果和第二计数结果进行融合,输出最终计数结果;基于最终计数结果,确定原始图像中目标物体的计数结果。

[0086] 此外,上述的存储器中的逻辑命令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干命令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。

[0087] 本申请实施例提供的电子设备中的处理器可以调用存储器中的逻辑指令,实现上述方法,其具体的实施方式与前述方法实施方式一致,且可以达到相同的有益效果,此处不再赘述。

[0088] 本申请实施例还提供一种计算机可读的存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现以执行上述各实施例提供的方法。

[0089] 其具体的实施方式与前述方法实施方式一致,且可以达到相同的有益效果,此处不再赘述。

[0090] 本申请实施例提供一种计算机程序产品,包括计算机程序,计算机程序被处理器执行时实现如上述方法。

[0091] 以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。

[0092] 通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM / RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。

[0093] 最后应说明的是:以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。

Claims

1. A target counting method, characterized in that, include: Obtain the original image containing the target object; The original image is divided into logical grids to obtain a grid image containing multiple grid regions; The original image and the grid image are synchronously input into a preset multimodal large model. The preset multimodal large model performs global counting on the original image to generate a first counting result, and performs grid region counting and accumulation on the grid image to generate a second counting result. The first counting result and the second counting result are then fused to output the final counting result. Based on the final counting result, the counting result of the target object in the original image is determined.

2. The target counting method according to claim 1, characterized in that, The process involves synchronously inputting the original image and the grid image into a preset multimodal large model, where the preset multimodal large model performs global counting on the original image to generate a first counting result, and performs grid region counting and accumulation on the grid image to generate a second counting result. The first and second counting results are then fused to output the final counting result, including: Construct preset prompts; The preset prompt words, the original image, and the grid image are simultaneously input into the preset multimodal large model to obtain the final counting result output by the preset multimodal large model; The preset prompt word is used to instruct the preset multimodal large model to perform the following operations: The target objects in the original image are identified and a global count is performed to obtain the first counting result; The target objects in each grid region of the grid image are identified and local counts are performed in each grid region. The results are accumulated with reference to the original image to obtain the second counting result. The first counting result and the second counting result are merged to obtain the final counting result; Output the first counting result, the second counting result, and the final counting result.

3. The target counting method according to claim 2, characterized in that, The process of fusing the first counting result and the second counting result to obtain the final counting result includes: Compare the first counting result with the second counting result; If there is a deviation between the first counting result and the second counting result, the second counting result is corrected based on the image features of the original image to generate the final counting result.

4. The target counting method according to claim 2, characterized in that, The step of identifying the target object within each grid region of the grid image and performing local counting of each grid region includes: Based on a preset sequence, each grid region in the grid image is scanned to identify the target object in each grid region and record the number of the target objects in each grid region.

5. The target counting method according to claim 2, characterized in that, The step of identifying the target object within each grid region of the grid image and performing local counting of each grid region includes: When any target object is located in at least two adjacent grid regions, a local count is performed based on the area ratio of the target object in each adjacent grid region.

6. The target counting method according to any one of claims 1 to 4, characterized in that, The step of dividing the original image into logical grids to obtain a grid image containing multiple grid regions includes: Based on the scene information of the original image or the features of the target object, determine the number and / or size of the grid regions; The original image is logically divided into grids based on the number and / or size of the grid regions.

7. A target counting device, characterized in that, include: The acquisition module is used to acquire the original image containing the target object; The partitioning module is used to perform logical grid partitioning on the original image to obtain a grid image containing multiple grid regions; The counting module is used to synchronously input the original image and the grid image into a preset multimodal large model, and the preset multimodal large model performs global counting on the original image to generate a first counting result, and performs grid region counting and accumulation on the grid image to generate a second counting result, and fuses the first counting result and the second counting result to output the final counting result; A determining module is used to determine the count result of the target object in the original image based on the final counting result.

8. 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 computer program, it implements the target counting method according to any one of claims 1 to 6.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the target counting method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the target counting method according to any one of claims 1 to 6.