Skip to content

apply_deep_counting_modelApplyDeepCountingModelApplyDeepCountingModelapply_deep_counting_modelT_apply_deep_counting_model๐Ÿ”—

Short description๐Ÿ”—

apply_deep_counting_modelApplyDeepCountingModelApplyDeepCountingModelapply_deep_counting_modelT_apply_deep_counting_model โ€” Apply a Deep Counting model on a set of images for inference.

Signature๐Ÿ”—

apply_deep_counting_model( image Image, deep_counting DeepCountingHandle, out integer Count, out dict DeepCountingResult )void ApplyDeepCountingModel( const HObject& Image, const HTuple& DeepCountingHandle, HTuple* Count, HTuple* DeepCountingResult )static void HOperatorSet.ApplyDeepCountingModel( HObject image, HTuple deepCountingHandle, out HTuple count, out HTuple deepCountingResult )def apply_deep_counting_model( image: HObject, deep_counting_handle: HHandle ) -> Tuple[Sequence[int], Sequence[HHandle]]

def apply_deep_counting_model_s( image: HObject, deep_counting_handle: HHandle ) -> Tuple[int, HHandle]Herror T_apply_deep_counting_model( const Hobject Image, const Htuple DeepCountingHandle, Htuple* Count, Htuple* DeepCountingResult )

HTuple HDlModelCounting::ApplyDeepCountingModel( const HImage& Image, HDictArray* DeepCountingResult ) const

Hlong HDlModelCounting::ApplyDeepCountingModel( const HImage& Image, HDict* DeepCountingResult ) const

HTuple HDlModelCounting.ApplyDeepCountingModel( HImage image, out HDict[] deepCountingResult )

int HDlModelCounting.ApplyDeepCountingModel( HImage image, out HDict deepCountingResult )

Description๐Ÿ”—

apply_deep_counting_modelApplyDeepCountingModel applies the Deep Counting model given by DeepCountingHandledeepCountingHandledeep_counting_handle on the tuple of input images Imageimageimage. A tuple with the number of found instances per input image is returned in Countcountcount. Additional information about the counted instances is returned in DeepCountingResultdeepCountingResultdeep_counting_result, which contains a tuple of dictionaries, again one per input image. Note that templates of the objects to be counted must be set beforehand using prepare_deep_counting_modelPrepareDeepCountingModel. Note that the inference time of apply_deep_counting_modelApplyDeepCountingModel depends on the number of defined templates in prepare_deep_counting_modelPrepareDeepCountingModel.

Please see the chapter Matching / Deep Counting for further information.

The procedure dev_display_deep_count_results can be used to visualize the detected instances.

The settings 'min_score'"min_score" and 'max_overlap'"max_overlap" can be used to set the minimum similarity of the instances to the templates as well as the allowed overlap of instances. Details can be found in get_deep_counting_model_paramGetDeepCountingModelParam.

The dictionary returned in DeepCountingResultdeepCountingResultdeep_counting_result contains additional information about the detected and counted object instances. It contains the following keys, where each key contains a tuple of values, one for each detection. If no instances were detected, i.e. the count is 00, those tuples are empty.

  • 'area'"area": Approximate area of the detected templates in pixels.

  • 'row'"row", 'column'"column": Approximate location in row and column coordinates of the instances in the input image.

  • 'score'"score": Similarity score of the detected instances, i.e., their approximate similarity with the most similar template provided to prepare_deep_counting_modelPrepareDeepCountingModel.

  • 'template_index'"template_index": Index of the template with the highest similarity to the detected instance. This can be used to find out which templates were counted.

  • 'angle'"angle", 'scale'"scale": The angle and scale of the template with the highest similarity to the detected instance. If rotational or scale augmentations were enabled during the call of prepare_deep_counting_modelPrepareDeepCountingModel, these values can be used to find out which rotation angle and scale creates a template that is most similar to the detected instance.

Attention๐Ÿ”—

Deep Counting does not take into account whether an image has a reduced domain.

System requirements: To run this operator on GPU (see get_deep_counting_model_paramGetDeepCountingModelParam), cuDNN and cuBLAS are required. For further details, please refer to the โ€œInstallation Guideโ€, paragraph โ€œRequirements for Deep Learning and Deep-Learning-Based Methodsโ€. Alternatively, this operator can also be run on CPU.

Execution information๐Ÿ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on internal data level.

This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.

Parameters๐Ÿ”—

Imageimageimage (input_object) (multichannel-)image(-array) โ†’ object (byte / real)HObject (byte / real)HImage (byte / real)HObject (byte / real)Hobject (byte / real)

Input image.

DeepCountingHandledeepCountingHandledeep_counting_handle (input_control) deep_counting โ†’ (handle)HTuple (HHandle)HDlModelCounting, HTuple (IntPtr)HHandleHtuple (handle)

Handle of the Deep Counting model.

Countcountcount (output_control) integer(-array) โ†’ (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Number of counted objects.

DeepCountingResultdeepCountingResultdeep_counting_result (output_control) dict(-array) โ†’ (handle)HTuple (HHandle)HDict, HTuple (IntPtr)Sequence[HHandle]Htuple (handle)

Tuple of result dictionaries.

Result๐Ÿ”—

If the parameters are valid, the operator apply_deep_counting_modelApplyDeepCountingModel returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.

Combinations with other operators๐Ÿ”—

Combinations

Possible predecessors

create_deep_counting_modelCreateDeepCountingModel, set_deep_counting_model_paramSetDeepCountingModelParam, get_deep_counting_model_paramGetDeepCountingModelParam, prepare_deep_counting_modelPrepareDeepCountingModel

See also

prepare_deep_counting_modelPrepareDeepCountingModel

Module๐Ÿ”—

Matching