CClassificationTask

class ikomia.dataprocess.pydataprocess.CClassificationTask

Base class for classification task in Computer Vision. It defines a task with the following properties:

Inputs:

Outputs:

  • image IO (CImageIO): by default source image is forwarded.

  • object detection IO (CObjectDetectionIO): filled if input graphics items are passed. In this case, classification is computed for each individual object.

  • graphics output (CGraphicsOutput): text item with top-1 class if classification is computed on whole image.

  • data output (CDataStringIO): sorted list of class scores if classification is computed on whole image.

Derived from C2dImageTask.

Import

from ikomia.dataprocess import CClassificationTask

Methods

__init__(arg1)

__init__( (object)self) -> None :

add_object(self, graphics_item, class_index, ...)

Add classification result for individual object.

get_input_objects(self)

Get input graphics items on which classification can be computed individually.

get_names(self)

Get class names.

get_objects_results(self)

Get classification results when applied on individual objects (input graphics items).

get_object_sub_image(self, item)

Get ROI image for the given graphics item.

get_image_with_graphics(self)

Get visualization image where all extracted information are embedded (graphics items).

get_whole_image_results(self)

Get classification results when applied on whole image (no input graphics items given).

is_whole_image_classification(self)

Check whether input graphics items are given for individual classification.

read_class_names(self, path)

Populate class names from the given text file (one line per class).

set_colors(self, colors)

Set colors associated with class names.

set_names(self, names)

Set class names.

set_whole_image_results(self, names, confidences)

Set whole image classification results.

emit_add_sub_progress_steps(self, count)

See emit_add_sub_progress_steps().

emit_graphics_context_changed(self)

See emit_graphics_context_changed().

emit_output_changed(self)

See emit_output_changed().

emit_step_progress(self)

See emit_step_progress().

Overridden methods

Inherited methods

add_input(self, input)

Add new input to the task.

add_output(self, output)

Add new output to the task.

apply_graphics_mask(self, origin, processed, ...)

Apply the mask generated from graphics to the result image so that only masked areas seems to be processed.

apply_graphics_mask_to_binary(self, origin, ...)

Apply the mask generated from graphics to the binary source image.

begin_task_run(self)

See begin_task_run().

create_input_graphics_mask(self, index, ...)

Generate a binary mask image from the task graphics input at the specified index.

create_graphics_mask(self, width, height, ...)

Generate a binary mask image from the given graphics input object.

execute_actions(self, action)

Method called when a specific action is requested from the associated widget (see emit_send_process_action()).

forward_input_image(self, input_index, ...)

Forward input image at position input_index to output at position output_index.

get_elapsed_time(self)

Get the time of the last execution in milliseconds.

get_graphics_mask(self, index)

Get the binary mask generated from graphics input at position index.

get_input(self, index)

Get input at position index.

get_input_count(self)

Get the number of inputs.

get_input_data_type(self, index)

Get input data type at position index.

get_inputs(self)

Get the whole list of inputs.

get_output(self, index)

Get output at position index.

get_output_count(self)

Get the number of outputs.

get_output_data_type(self, index)

Get output data type at position index.

get_outputs(self)

Get the whole list of outputs.

get_parameters(self)

Get values of task parameters.

get_progress_steps(self)

See get_progress_steps().

global_input_changed(self, is_new_sequence)

See global_input_changed().

graphics_changed(self)

See graphics_changed().

is_graphics_changed_listening(self)

Check whether the task is listening to graphics changed event.

is_mask_available(self, index)

Check whether a binary mask from graphics input is available at position index.

parameters_modified(self)

Notify that the task parameters have changed.

remove_input(self, index)

Remove input at the given position.

run(self)

See run().

set_action_flag(self, action, is_enable)

Enable or disable the given action.

set_active(self, is_active)

See set_active().

set_input(self, input, index)

Set input at position index with the given one.

set_input_data_type(self, data_type, index)

Set the data type for the input at position index.

set_inputs(self, inputs)

Set the whole list of inputs with the given one.

set_output(self, output, index)

Set output at position index with the given one.

set_output_color_map(self, index, ...)

Bind a display color map to an image output.

set_output_data_type(self, data_type, index)

Set the data type for the output at position index.

set_outputs(self, outputs)

Set the whole list of outputs with the given one.

set_parameters(self, values)

Set values of task parameters.

stop(self)

See stop().

update_static_outputs(self)

Determine output data type automatically from input data types.

Attributes

name

Task name (must be unique)

type

Main purpose or data type on which the task is dedicated to.

Details

__init__((object)arg1) None
__init__( (object)self) -> None :

Default constructor

__init__( (object)self, (str)name) -> None :

Construct CClassificationTask object with the given name.

Args:

name (str): task name, must be unique

add_object((CClassificationTask)self, (CGraphicsItem)graphics_item, (int)class_index, (float)confidence) None :

Add classification result for individual object. See get_input_objects() and get_object_sub_image() for more information.

Parameters:
  • graphics_item (CGraphicsItem based object)

  • class_index (int) – index is used to retrieve class name

  • confidence (float) – confidence score of top-1 class

get_input_objects((CClassificationTask)self) object :

Get input graphics items on which classification can be computed individually. One can iterate over this list to compute classification for each object. Use get_object_sub_image() to retieve object ROI image and add_object() to store classification result.

Returns:

graphics items

Return type:

CGraphicsItem based objects

get_names((CClassificationTask)self) object :

Get class names. Call read_class_names() to populate names from text file.

Returns:

class names

Return type:

str list

get_objects_results((CClassificationTask)self) CObjectDetectionIO :

Get classification results when applied on individual objects (input graphics items). Results are given as a CObjectDetectionIO instance.

Returns:

classification results

Return type:

CObjectDetectionIO

get_object_sub_image((CClassificationTask)self, (CGraphicsItem)item) object :

Get ROI image for the given graphics item. We use the bounding rect property of CGraphicsItem to compute ROI. Input graphics items can be retrieved with get_input_objects(). Classification can then be computed on the ROI to get individual object class.Args:

graphics item (CGraphicsItem based object)

Returns:

ROI image

Return type:

2D Numpy array

get_image_with_graphics((CClassificationTask)self) object :

Get visualization image where all extracted information are embedded (graphics items).

Returns:

visualization image

Return type:

2D Numpy array

get_whole_image_results((CClassificationTask)self) object :

Get classification results when applied on whole image (no input graphics items given). It gives a sorted list of tuple storing class name and confidence.

Returns:

classification results

Return type:

list of tuples (name, confidence)

is_whole_image_classification((CClassificationTask)self) bool :

Check whether input graphics items are given for individual classification.

Returns:

True if no input graphics items are given (whole image classification), False otherwise

Return type:

bool

read_class_names((CClassificationTask)self, (str)path) None :

Populate class names from the given text file (one line per class).

Parameters:

path (str) – path to class names definition file

set_colors((CClassificationTask)self, (object)colors) None :

Set colors associated with class names. The given list must have the same size as names list. If not provided, random colors are generated while populating the name list (read_class_names()).

Parameters:

list (colors (list of) – r, g, b integer values in range [0, 255])

set_names((CClassificationTask)self, (object)names) None :

Set class names. The function generate associated random colors if none is defined.

Parameters:

names (list of str)

set_whole_image_results((CClassificationTask)self, (object)names, (object)confidences) None :

Set whole image classification results.

Parameters:
  • names (str list) – sorted list with respect to confidence score

  • confidences (str list) – sorted list (descending)

emit_add_sub_progress_steps((CClassificationTask)self, (int)count) None :

See emit_add_sub_progress_steps().

emit_graphics_context_changed((CClassificationTask)self) None :

See emit_graphics_context_changed().

emit_output_changed((CClassificationTask)self) None :

See emit_output_changed().

emit_step_progress((CClassificationTask)self) None :

See emit_step_progress().

end_task_run((CClassificationTask)self) None :

See end_task_run().

end_task_run( (CClassificationTask)self) -> None