:py:mod:`anomalib.utils.sweep.helpers.inference` ================================================ .. py:module:: anomalib.utils.sweep.helpers.inference .. autoapi-nested-parse:: Utils to help compute inference statistics. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: anomalib.utils.sweep.helpers.inference.MockImageLoader Functions ~~~~~~~~~ .. autoapisummary:: anomalib.utils.sweep.helpers.inference.get_torch_throughput anomalib.utils.sweep.helpers.inference.get_openvino_throughput .. py:class:: MockImageLoader(image_size: List[int], total_count: int) Create mock images for inference on CPU based on the specifics of the original torch test dataset. Uses yield so as to avoid storing everything in the memory. :param image_size: Size of input image :type image_size: List[int] :param total_count: Total images in the test dataset :type total_count: int .. py:method:: __len__() Get total count of images. .. py:method:: __call__() -> Iterable[numpy.ndarray] Yield batch of generated images. :param idx: Unused :type idx: int .. py:function:: get_torch_throughput(config: Union[omegaconf.DictConfig, omegaconf.ListConfig], model: anomalib.models.components.AnomalyModule, test_dataset: torch.utils.data.DataLoader) -> float Tests the model on dummy data. Images are passed sequentially to make the comparision with OpenVINO model fair. :param config: Model config. :type config: Union[DictConfig, ListConfig] :param model: Model on which inference is called. :type model: Path :param test_dataset: The test dataset used as a reference for the mock dataset. :type test_dataset: DataLoader :returns: Inference throughput :rtype: float .. py:function:: get_openvino_throughput(config: Union[omegaconf.DictConfig, omegaconf.ListConfig], model_path: pathlib.Path, test_dataset: torch.utils.data.DataLoader) -> float Runs the generated OpenVINO model on a dummy dataset to get throughput. :param config: Model config. :type config: Union[DictConfig, ListConfig] :param model_path: Path to folder containing the OpenVINO models. It then searches `model.xml` in the folder. :type model_path: Path :param test_dataset: The test dataset used as a reference for the mock dataset. :type test_dataset: DataLoader :returns: Inference throughput :rtype: float