:py:mod:`mipcandy.inference`
============================

.. py:module:: mipcandy.inference

.. autodoc2-docstring:: mipcandy.inference
   :allowtitles:

Module Contents
---------------

Classes
~~~~~~~

.. list-table::
   :class: autosummary longtable
   :align: left

   * - :py:obj:`Predictor <mipcandy.inference.Predictor>`
     - .. autodoc2-docstring:: mipcandy.inference.Predictor
          :summary:

Functions
~~~~~~~~~

.. list-table::
   :class: autosummary longtable
   :align: left

   * - :py:obj:`parse_predictant <mipcandy.inference.parse_predictant>`
     - .. autodoc2-docstring:: mipcandy.inference.parse_predictant
          :summary:

API
~~~

.. py:function:: parse_predictant(x: mipcandy.types.SupportedPredictant, loader: type[mipcandy.data.Loader], *, as_label: bool = False) -> tuple[list[torch.Tensor], list[str] | None]
   :canonical: mipcandy.inference.parse_predictant

   .. autodoc2-docstring:: mipcandy.inference.parse_predictant

.. py:class:: Predictor(experiment_folder: str | os.PathLike[str], example_shape: mipcandy.types.AmbiguousShape, *, checkpoint: str = 'checkpoint_best.pth', device: mipcandy.types.Device = 'cpu')
   :canonical: mipcandy.inference.Predictor

   Bases: :py:obj:`mipcandy.layer.WithPaddingModule`, :py:obj:`mipcandy.layer.WithNetwork`

   .. autodoc2-docstring:: mipcandy.inference.Predictor

   .. rubric:: Initialization

   .. autodoc2-docstring:: mipcandy.inference.Predictor.__init__

   .. py:method:: lazy_load_model() -> None
      :canonical: mipcandy.inference.Predictor.lazy_load_model

      .. autodoc2-docstring:: mipcandy.inference.Predictor.lazy_load_model

   .. py:method:: predict_image(image: torch.Tensor, *, batch: bool = False) -> torch.Tensor
      :canonical: mipcandy.inference.Predictor.predict_image

      .. autodoc2-docstring:: mipcandy.inference.Predictor.predict_image

   .. py:method:: _predict(x: mipcandy.types.SupportedPredictant | mipcandy.data.UnsupervisedDataset) -> tuple[list[torch.Tensor], list[str] | None]
      :canonical: mipcandy.inference.Predictor._predict

      .. autodoc2-docstring:: mipcandy.inference.Predictor._predict

   .. py:method:: predict(x: mipcandy.types.SupportedPredictant | mipcandy.data.UnsupervisedDataset) -> list[torch.Tensor]
      :canonical: mipcandy.inference.Predictor.predict

      .. autodoc2-docstring:: mipcandy.inference.Predictor.predict

   .. py:method:: save_prediction(output: torch.Tensor, path: str | os.PathLike[str]) -> None
      :canonical: mipcandy.inference.Predictor.save_prediction
      :staticmethod:

      .. autodoc2-docstring:: mipcandy.inference.Predictor.save_prediction

   .. py:method:: save_predictions(outputs: typing.Sequence[torch.Tensor], folder: str | os.PathLike[str], *, filenames: typing.Sequence[str | os.PathLike[str]] | None = None) -> None
      :canonical: mipcandy.inference.Predictor.save_predictions

      .. autodoc2-docstring:: mipcandy.inference.Predictor.save_predictions

   .. py:method:: predict_to_files(x: mipcandy.types.SupportedPredictant | mipcandy.data.UnsupervisedDataset, folder: str | os.PathLike[str]) -> list[str] | None
      :canonical: mipcandy.inference.Predictor.predict_to_files

      .. autodoc2-docstring:: mipcandy.inference.Predictor.predict_to_files

   .. py:method:: __call__(x: mipcandy.types.SupportedPredictant | mipcandy.data.UnsupervisedDataset) -> list[torch.Tensor]
      :canonical: mipcandy.inference.Predictor.__call__

      .. autodoc2-docstring:: mipcandy.inference.Predictor.__call__
