nicetoolbox.detectors.base_detector.BaseDetector

class nicetoolbox.detectors.base_detector.BaseDetector(io: SequenceIO, data: SequenceData, subsequence_context: SubsequenceContext, algorithm_instance: str)[source]

Bases: ABC

Abstract base class for ALL detectors.

Defines the common interface that both method and feature detectors implement. This enables a unified detector loop in main.py.

Initialize base detector with references.

Subclasses should call super().__init__() and set inference_config.

Methods

compute_output_folders

Compute extra output folders for all components.

compute_result_folders

Compute result folders for all components.

compute_viz_folders

Compute visualization folders for all components.

resolve_inputs

Return the inputs to resolve for this detector.

resolve_outputs

Return the outputs this detector declares it will produce.

run

Execute the detector's main computation.

visualization

Visualize detector output.

Attributes

inputs

outputs

predictions_mapping

Access predictions mapping from runtime config.

algorithm_type

algorithm_instance

data

io

subsequence_context

detector_config

inference_config

components

loaded_inputs

declared_outputs

visualize

compute_output_folders(requires_out_folder: bool) → Dict[str, str][source]

Compute extra output folders for all components.

compute_result_folders() → Dict[str, str][source]

Compute result folders for all components.

compute_viz_folders(visualize: bool) → Dict[str, str][source]

Compute visualization folders for all components.

property predictions_mapping

Access predictions mapping from runtime config.

resolve_inputs() → List[BaseDetectorInput][source]

Return the inputs to resolve for this detector.

Defaults to the class-level inputs. Override to vary inputs by config (e.g. add an optional input only when a flag is set).

resolve_outputs() → List[BaseDetectorOutput][source]

Return the outputs this detector declares it will produce.

Defaults to the class-level outputs. Override to vary outputs by config (e.g. pick the npz_key/schema based on a per-instance dimension).

abstract run() → Any | None[source]

Execute the detector’s main computation.

For method detectors: runs subprocess inference + post_inference() For feature detectors: runs compute()

Returns:

Optional data for visualization (feature detectors currently return computed data)

abstract visualization(data: Any) → None[source]

Visualize detector output.

Parameters:

data – Output from run() or external data source