mednet.engine.segment.predictor

Functions

run(model, datamodule, device_manager, ...)

Run inference on input data, output predictions.

mednet.engine.segment.predictor.run(model, datamodule, device_manager, output_folder)[source]

Run inference on input data, output predictions.

Parameters:
  • model (LightningModule) – Neural network model (e.g. lwnet).

  • datamodule (LightningDataModule) – The lightning DataModule to run predictions on.

  • device_manager (DeviceManager) – An internal device representation, to be used for prediction. This representation can be converted into a pytorch device or a lightning accelerator setup.

  • output_folder (Path) – Folder where to store HDF5 representations of probability maps.

Return type:

dict[str, list[tuple[str, str]]] | list[list[tuple[str, str]]] | list[tuple[str, str]] | None

Returns:

A JSON-able representation of sample data stored at output_folder. For every split (dataloader), a list of samples in the form [sample-name, hdf5-path] is returned. In the cases where the predict_dataloader() returns a single loader, we then return a list. A dictionary is returned in case predict_dataloader() also returns a dictionary.

Raises:

TypeError – If the DataModule’s predict_dataloader() method does not return any of the types described above.