TrainProcess

class ikomia.dnn.dnntrain.TrainProcess(name: str, param: CWorkflowTaskParam)

Base class for task dedicated to Deep Learning training. It includes mlflow framework and Tensorboard and handle connections with them:

  • experiment creation

  • runs management

  • parameters logging

  • metrics logging

  • training dashboard

It must be used with TaskParam or derived for parameters. Derived from CDnnTrainTask.

Methods

__init__(name, param)

Constructor.

begin_task_run()

Proceed to training job initialization:

end_task_run()

Finalize mlflow run.

log_param(key, value)

Log parameter to mlflow server

log_params(params)

Log parameters to mlflow server

log_metric(key, value[, step])

Log metric to mlflow server

log_metrics(metrics[, step])

Log metrics to mlflow server

log_artifact(file_path)

Log artifact to mlflow server.

log_artifacts(folder_path)

Log artifacts to mlflow server.

stop()

Request training job to stop.

Inherited methods

add_input(self, input)

Add new input to the task.

add_output(self, output)

Add new output to the task.

emit_add_sub_progress_steps(self, count)

See emit_add_sub_progress_steps().

emit_graphics_context_changed(self)

Send event to notify that graphics context has changed inside the task and display has to be updated.

emit_output_changed(self)

See emit_output_changed().

emit_step_progress(self)

See emit_step_progress().

enable_mlflow(self, enable)

Enable or disable automatic display of MLflow dashboard when training starts.

enable_tensorboard(self, enable)

Enable or disable automatic launch of Tensorboard dashboard when training starts.

execute_actions(self, action)

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

get_elapsed_time(self)

Get the time of the last execution in milliseconds.

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)

Notify that the inputs of the workflow have changed.

graphics_changed(self)

Notify that graphics layers of input images have changed.

is_graphics_changed_listening(self)

Check whether the task is listening to graphics changed event.

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_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.

update_static_outputs(self)

Updates the static information deduced from inputs.

Details

__init__(name: str, param: CWorkflowTaskParam)

Constructor. Initialize mlflow local server.

Parameters:
  • name (str) – task name

  • param (TaskParam) – task parameters

stop()

Request training job to stop.

add_input((CWorkflowTask)self, (CWorkflowTaskIO)input) None :

Add new input to the task.

Args:

input (CWorkflowTaskIO based object): input object

add_input( (CWorkflowTask)self, (CWorkflowTaskIO)input) -> None

add_output((CWorkflowTask)self, (CWorkflowTaskIO)output) None :

Add new output to the task.

Args:

output (CWorkflowTaskIO based object): output object

add_output( (CWorkflowTask)self, (CWorkflowTaskIO)output) -> None

begin_task_run()

Proceed to training job initialization:

  • start new mlflow run

  • log hyperparameters contained in CDnnTrainProcessParam

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

See emit_add_sub_progress_steps().

emit_graphics_context_changed((CWorkflowTask)self) None :

Send event to notify that graphics context has changed inside the task and display has to be updated.

emit_output_changed((CDnnTrainTask)self) None :

See emit_output_changed().

emit_step_progress((CDnnTrainTask)self) None :

See emit_step_progress().

enable_mlflow((CDnnTrainTask)self, (bool)enable) None :

Enable or disable automatic display of MLflow dashboard when training starts. Dashboard is opened just once except if a new call to this function is made before a new training job starts. Default: enable.

Parameters:

enable (boolean) – True or False

enable_tensorboard((CDnnTrainTask)self, (bool)enable) None :

Enable or disable automatic launch of Tensorboard dashboard when training starts. Dashboard is opened just once except if a new call to this function is made before a new training job starts. Default: enable.

Parameters:

enable (boolean) – True or False

end_task_run()

Finalize mlflow run.

execute_actions((CDnnTrainTask)self, (int)action) None :

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

Args:

action (int): action code

execute_actions( (CDnnTrainTask)self, (int)action) -> None

get_elapsed_time((CWorkflowTask)self) float :

Get the time of the last execution in milliseconds.

Returns:

elapsed time in ms

Return type:

float

get_input((CWorkflowTask)self, (int)index) CWorkflowTaskIO :

Get input at position index.

Parameters:

index (int) – zero-based input index

Returns:

input object

Return type:

CWorkflowTaskIO based object

get_input_count((CWorkflowTask)self) int :

Get the number of inputs.

Returns:

inputs count

Return type:

int

get_input_data_type((CWorkflowTask)self, (int)index) IODataType :

Get input data type at position index. This data type can differ from the original type because it can change at runtime according to the data source.

Parameters:

index (int) – zero-based input index

Returns:

input data type

Return type:

IODataType

get_inputs((CWorkflowTask)self) object :

Get the whole list of inputs.

Returns:

input objects

Return type:

list of CWorkflowTaskIO based objects

get_output((CWorkflowTask)self, (int)index) CWorkflowTaskIO :

Get output at position index.

Parameters:

index (int) – zero-based output index

Returns:

output object

Return type:

CWorkflowTaskIO based object

get_output_count((CWorkflowTask)self) int :

Get the number of outputs.

Returns:

outputs count

Return type:

int

get_output_data_type((CWorkflowTask)self, (int)index) IODataType :

Get output data type at position index. This data type can differ from the original type because it can change at runtime according to the data source.

Parameters:

index (int) – zero-based output index

Returns:

output data type

Return type:

IODataType

get_outputs((CWorkflowTask)self) object :

Get the whole list of outputs.

Returns:

output objects

Return type:

list of CWorkflowTaskIO based objects

get_parameters((CWorkflowTask)self) object :

Get values of task parameters.

Returns:

string pairs (parameter name, value)

Return type:

dict

get_progress_steps((CDnnTrainTask)self) int :

See get_progress_steps().

get_progress_steps( (CDnnTrainTask)self) -> int

global_input_changed((CWorkflowTask)self, (bool)is_new_sequence) None :

Notify that the inputs of the workflow have changed. This method can be overriden to implement custom actions when this event happens. The method does nothing in this base class.

Args:

is_new_sequence (bool): True if new input is a new sequence (ex: new frame of the same video is not a new sequence)

global_input_changed( (CWorkflowTask)self, (bool)is_new_sequence) -> None

graphics_changed((CWorkflowTask)self) None :

Notify that graphics layers of input images have changed. This method can be overriden to implement custom actions when this event happens. The method does nothing in this base class.

graphics_changed( (CWorkflowTask)self) -> None

is_graphics_changed_listening((CWorkflowTask)self) bool :

Check whether the task is listening to graphics changed event.

Returns:

bool: True or False

is_graphics_changed_listening( (CWorkflowTask)self) -> bool

log_param(key: str, value: any)

Log parameter to mlflow server

Parameters:
  • key (str) – parameter name

  • value – parameter value (numerical)

log_params(params: dict)

Log parameters to mlflow server

Parameters:

params (dict) – parameters

log_metric(key: str, value: any, step: int | None = None)

Log metric to mlflow server

Parameters:
  • key (str) – metric name

  • value – metric value (numerical)

  • step (int) – epoch/iteration index

log_metrics(metrics: dict, step: int | None = None)

Log metrics to mlflow server

Parameters:
  • metrics (dict) – parameters

  • step (int) – epoch/iteration index

log_artifact(file_path: str)

Log artifact to mlflow server. Artifact could be any file (model weights, configuration file…)

Parameters:

file_path (str) – source file

log_artifacts(folder_path: str)

Log artifacts to mlflow server. Artifacts could be any files stored in the same folder (model weights, configuration file…)

Parameters:

folder_path (str) – artifacts folder

parameters_modified((CWorkflowTask)self) None :

Notify that the task parameters have changed. This method can be overriden to implement custom actions when this event happens. The method does nothing in this base class.

parameters_modified( (CWorkflowTask)self) -> None

remove_input((CWorkflowTask)self, (int)index) None :

Remove input at the given position.

Parameters:

index (int) – zero-based input index

run((CDnnTrainTask)self) None :

See run().

run( (CDnnTrainTask)self) -> None

set_action_flag((CWorkflowTask)self, (ActionFlag)action, (bool)is_enable) None :

Enable or disable the given action. If the action does not exist, it is added to the list.

Parameters:
  • action (ActionFlag) – action to enable or disable

  • is_enable (bool) – True or False

set_active((CDnnTrainTask)self, (bool)is_active) None :

See set_active().

set_active( (CDnnTrainTask)self, (bool)is_active) -> None

set_input((CWorkflowTask)self, (CWorkflowTaskIO)input, (int)index) None :

Set input at position index with the given one. If the input at position index does not exist, the function creates as many generic inputs to reach the number of index+1 and sets the input at position index.

Args:

input_tot (CWorkflowTaskIO based object)

index (int): zero-based input index

set_input( (CWorkflowTask)self, (CWorkflowTaskIO)input, (int)index) -> None

set_input_data_type((CWorkflowTask)self, (IODataType)data_type, (int)index) None :

Set the data type for the input at position index. If the input at position index does not exist, the function creates as many generic inputs to reach the number of index+1 and sets the data type for the input at position index.

Args:

data_type (IODataType): input data type

index (int): zero-based input index

set_input_data_type( (CWorkflowTask)self, (IODataType)data_type, (int)index) -> None

set_inputs((CWorkflowTask)self, (object)inputs) None :

Set the whole list of inputs with the given one.

Args:

inputs (list of CWorkflowTaskIO based objects)

set_inputs( (CWorkflowTask)self, (object)inputs) -> None

set_output((CWorkflowTask)self, (CWorkflowTaskIO)output, (int)index) None :

Set output at position index with the given one. If the output at position index does not exist, the function creates as many generic outputs to reach the number of index+1 and sets the output at position index.

Args:

output (CWorkflowTaskIO based object)

index (int): zero-based output index

set_output( (CWorkflowTask)self, (CWorkflowTaskIO)output, (int)index) -> None

set_output_data_type((CWorkflowTask)self, (IODataType)data_type, (int)index) None :

Set the data type for the output at position index. If the output at position index does not exist, the function creates as many generic outputs to reach the number of index+1 and sets the data type for the output at position index.

Args:

data_type (IODataType): output data type

index (int): zero-based output index

set_output_data_type( (CWorkflowTask)self, (IODataType)data_type, (int)index) -> None

set_outputs((CWorkflowTask)self, (object)outputs) None :

Set the whole list of outputs with the given one.

Args:

outputs (list of CWorkflowTaskIO based objects)

set_outputs( (CWorkflowTask)self, (object)outputs) -> None

set_parameters((CWorkflowTask)self, (object)values) None :

Set values of task parameters.

Parameters:

values (dict) – string pairs (parameter name, value)

update_static_outputs((CWorkflowTask)self) None :

Updates the static information deduced from inputs. The static data corresponds to all data that can be deduced without the runtime context. This method is called each time inputs change.

update_static_outputs( (CWorkflowTask)self) -> None

Attributes

name

Task name (must be unique)

type

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