nicetoolbox.detectors.in_out.IO

class nicetoolbox.detectors.in_out.IO(config)[source]

Bases: object

The IO class handles input/output operations and folder management for the NICE toolbox.

Parameters:

config (dict) – A dictionary containing the configuration parameters.

out_folder

The path to the output folder.

Type:

str

log_level

The log level.

Type:

str

out_sub_folder

The path to the output sub-folder.

Type:

str

data_folder

The path to the data folder.

Type:

str

data_input_folder

The path to the input data folder.

Type:

str

calibration_file

The path to the calibration file.

Type:

str

conda_path

The path to the Conda installation directory.

Type:

str

algorithm_names

A list of algorithm names.

Type:

list

detector_out_folder

The path to the detector output folder.

Type:

str

detector_visualization_folder

The path to the detector visualization folder.

Type:

str

detector_additional_output_folder

The path to the detector additional output folder.

Type:

str

detector_run_config_path

The path to the detector run configuration file.

Type:

str

detector_final_result_folder

The path to the detector final result folder.

Type:

str

Initializes IO by creating the output folder and setting the log level.

Parameters:

config (dict) – A dictionary containing configuration parameters.

Raises:

OSError – If there is an error creating the output folder or the base data folder.

Methods

check_config

Check the validity of the given configuration.

create_folders

Creates the necessary output and data folders.

get_calibration_file

Returns the calibration file path.

get_conda_path

Returns the path to the Conda installation directory.

get_config_file

Returns the path of the configuration file.

get_data_source_folder

Returns the folder path to the original dataset source data.

get_detector_output_folder

Get the output folder path for a specific component, algorithm, and token.

get_inference_path

Get the file path for the inference script of a given detector.

get_log_file_level

Returns the path of the log file and the log level.

get_nice_input_folder

Returns the data folder associated with the current instance.

get_output_folder

Returns the output folder based on the given name and token.

get_venv_path

Get the file path of the virtual environment for the given detector and environment name.

initialization

Initializes the necessary variables and folders for data processing.

check_config(config)[source]

Check the validity of the given configuration.

Parameters:

config (dict) – The configuration dictionary.

Raises:
  • TypeError – If the ‘process_data_to’ value is not a string.

  • ValueError – If the ‘process_data_to’ value is not ‘data_folder’.

  • ValueError – If any of the detector input folders are invalid.

  • OSError – If any of the detector input folders are not accessible.

create_folders()[source]

Creates the necessary output and data folders.

This method creates the output folder and data folder if they don’t already exist. If the folders cannot be created, an exception is raised.

Raises:

OSError – If the output folder or data folder cannot be created.

get_calibration_file()[source]

Returns the calibration file path.

Returns:

The path of the calibration file.

Return type:

str

get_conda_path()[source]

Returns the path to the Conda installation directory.

Returns:

The path to the Conda installation directory.

Return type:

str

get_config_file()[source]

Returns the path of the configuration file.

Returns:

The path of the configuration file.

Return type:

str

get_data_source_folder() Path[source]

Returns the folder path to the original dataset source data. (E.g. storing mp4/avi files)

Returns:

The path to the source data folder.

Return type:

str

get_detector_output_folder(component, algorithm, token)[source]

Get the output folder path for a specific component, algorithm, and token.

Parameters:
  • component (str) – The name of the component.

  • algorithm (str) – The name of the algorithm.

  • token (str) – The token indicating the type of output folder.

Returns:

The path of the output folder.

Return type:

str

Raises:

NotImplementedError – If the algorithm or token is not supported.

get_inference_path(component_name, detector_name)[source]

Get the file path for the inference script of a given detector.

Parameters:

detector_name (str) – The name of the detector.

Returns:

The file path for the inference script.

Return type:

str

Raises:

FileNotFoundError – If the inference script file does not exist.

get_log_file_level()[source]

Returns the path of the log file and the log level.

Returns:

A tuple containing the path of the log file and the log level.

Return type:

tuple

get_nice_input_folder() Path[source]

Returns the data folder associated with the current instance.

Returns:

The path to the data folder.

Return type:

str

get_output_folder(token)[source]

Returns the output folder based on the given name and token.

Parameters:
  • token (str) – The token specifying the type of output folder

  • ('tmp'

  • 'output'

  • 'main'

  • 'csv'). (or) –

Returns:

The path to the output folder.

Return type:

str

Raises:

NotImplementedError – If the token is not ‘tmp’, ‘output’, ‘main’, or ‘csv’.

get_venv_path(detector_name, env_name)[source]

Get the file path of the virtual environment for the given detector and environment name.

Parameters:
  • detector_name (str) – The name of the detector.

  • env_name (str) – The name of the environment.

Returns:

The file path of the virtual environment.

Return type:

str

Raises:

FileNotFoundError – If the virtual environment does not exist.

initialization(config, algorithm_names)[source]

Initializes the necessary variables and folders for data processing.

Parameters:
  • config (dict) – A dictionary containing the configuration parameters.

  • algorithm_names (list) – A list of algorithm names.

Returns:

None