dunedn.inference package

Submodules

dunedn.inference.analysis module

This module contains the wrapper function for the dunedn analysis command.

Example

Analysis help output:

$ dunedn analysis --help
usage: dunedn analysis [-h] [--input INPUT] [--target TARGET] runcard

Load reconstructed and target events and compute accuracy metrics.

positional arguments:
  runcard               yaml configcard path

optional arguments:
  -h, --help            show this help message and exit
  --input INPUT, -i INPUT
                        path to the denoised event file
  --target TARGET, -t TARGET
                        path to the target event file
dunedn.inference.analysis.add_arguments_analysis(parser)[source]

Adds inference subparser arguments.

Parameters

parser (-) –

dunedn.inference.analysis.analysis(args)[source]

Wrapper analysis function.

Parameters

args (NameSpace) – Parsed from command line or from code.

dunedn.inference.analysis.analysis_main(input_path: Path, target_path: Path, task: str = 'dn')[source]

Inference main function.

Loads an input event from file, makes inference and saves the ouptut. Eventually returns the output array.

Parameters
  • input_path (Path) – Path to the denoised event file.

  • target_path (Path) – Path to the target event file.

  • task (str) – Performed task. Available options: dn|roi

Returns

Ouptut event of shape=(nb wires, nb tdc ticks).

Return type

np.array

dunedn.inference.hitreco module

This module contains utility functions for the inference step.

class dunedn.inference.hitreco.BaseModel(setup, modeltype, task, ckpt=None, should_use_onnx=False)[source]

Bases: object

Mother class for inference model.

onnx_export(output_dir=None)[source]

Exports the model to onnx format.

Parameters

output_dir (Path) – The directory to save the onnx files.

predict(event: ndarray, dev='cpu', profiler: Optional[BatchProfiler] = None) ndarray[source]

Interface for model prediction on pDUNE event.

Parameters
  • event (np.ndarray) – Event input array of shape=(nb wires, nb tdc ticks).

  • dev (str) – Device hosting computation.

  • profiler (BatchProfiler) – The profiler object to record batch inference time.

Returns

Denoised event of shape=(nb wires, nb tdc ticks).

Return type

np.ndarray

class dunedn.inference.hitreco.DnModel(setup, modeltype, ckpt=None, should_use_onnx=False)[source]

Bases: BaseModel

Wrapper class for denoising model.

class dunedn.inference.hitreco.DnRoiModel(setup, modeltype, roi_ckpt=None, dn_ckpt=None, should_use_onnx=False)[source]

Bases: object

Wrapper class for denoising and ROI selection model.

class dunedn.inference.hitreco.RoiModel(setup, modeltype, ckpt=None, should_use_onnx=False)[source]

Bases: BaseModel

Wrapper class for ROI selection model.

dunedn.inference.hitreco.get_models(task, modeltype, ckpt, msetup)[source]
dunedn.inference.hitreco.get_onnx_models(task, modeltype, ckpt)[source]

dunedn.inference.inference module

This module contains the wrapper function for the dunedn inference command.

Example

Inference help output:

$ dunedn inference --help
usage: dunedn inference [-h] [-i INPUT] [-o OUTPUT] -m MODEL [--model_path CKPT] [--onnx] [--onnx_export] runcard

Load event and make inference with saved model.

positional arguments:
  runcard            yaml configcard path

optional arguments:
  -h, --help         show this help message and exit
  -i INPUT           path to the input event file
  -o OUTPUT          path to the output event file
  -m MODEL           model name. Valid options: (uscg|gcnn|cnn|id)
  --model_path CKPT  (optional) path to directory with saved model
  --onnx             wether to use ONNX exported model
  --onnx_export      wether to export models to ONNX
dunedn.inference.inference.add_arguments_inference(parser)[source]

Adds inference subparser arguments.

Parameters

parser (-) –

dunedn.inference.inference.inference(args)[source]

Wrapper inference function.

Parameters

args (NameSpace) – Parsed from command line or from code.

Returns

Output event of shape=(nb wires, nb tdc ticks)

Return type

np.array

dunedn.inference.inference.inference_main(setup, input_path, output_folder, modeltype, ckpt, should_use_onnx=False, should_export_to_onnx=False)[source]

Inference main function.

Loads an input event from file, makes inference and saves the ouptut. Eventually returns the output array.

Parameters
  • setup (dict) – Settings dictionary.

  • input_path (Path) – Path to the input event file.

  • output_folder (Path) – Path to the output folder.

  • modeltype (str) – Model name. Available options: uscg|gcnn|cnn|id.

  • ckpt (path) – Directory with saved model.

  • should_use_onnx (bool) – Wether to use onnx format.

dunedn.inference.inference.thresholding_dn(evt, t=3.5)[source]

Apply a threhosld to the denoised waveforms to smooth results.

Parameters
  • evt (np.array) – Event of shape=(nb wires, nb tdc ticks).

  • t (float) – Threshold.

Returns

Thresholded event of shape=(nb wires, nb tdc ticks).

Return type

np.array

Module contents