anomalib.utils.sweep.helpers.inference¶
Utils to help compute inference statistics.
Module Contents¶
Classes¶
Create mock images for inference on CPU based on the specifics of the original torch test dataset. |
Functions¶
|
Tests the model on dummy data. Images are passed sequentially to make the comparision with OpenVINO model fair. |
|
Runs the generated OpenVINO model on a dummy dataset to get throughput. |
- class anomalib.utils.sweep.helpers.inference.MockImageLoader(image_size: List[int], total_count: int)[source]¶
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.
- Parameters
image_size (List[int]) – Size of input image
total_count (int) – Total images in the test dataset
- anomalib.utils.sweep.helpers.inference.get_torch_throughput(config: Union[omegaconf.DictConfig, omegaconf.ListConfig], model: anomalib.models.components.AnomalyModule, test_dataset: torch.utils.data.DataLoader) float[source]¶
Tests the model on dummy data. Images are passed sequentially to make the comparision with OpenVINO model fair.
- Parameters
config (Union[DictConfig, ListConfig]) – Model config.
model (Path) – Model on which inference is called.
test_dataset (DataLoader) – The test dataset used as a reference for the mock dataset.
- Returns
Inference throughput
- Return type
float
- anomalib.utils.sweep.helpers.inference.get_openvino_throughput(config: Union[omegaconf.DictConfig, omegaconf.ListConfig], model_path: pathlib.Path, test_dataset: torch.utils.data.DataLoader) float[source]¶
Runs the generated OpenVINO model on a dummy dataset to get throughput.
- Parameters
config (Union[DictConfig, ListConfig]) – Model config.
model_path (Path) – Path to folder containing the OpenVINO models. It then searches model.xml in the folder.
test_dataset (DataLoader) – The test dataset used as a reference for the mock dataset.
- Returns
Inference throughput
- Return type
float