def get_inferencer(weight_path: Path) -> Inferencer:
    """Parse args and open inferencer.

    Args:
        weight_path (Path): Path to model weights.
        metadata (Path | None, optional): Metadata is required for OpenVINO models. Defaults to None.

    Raises:
        ValueError: If unsupported model weight is passed.

    Returns:
        Inferencer: Torch or OpenVINO inferencer.
    """
    # Get the inferencer. We use .ckpt extension for Torch models and (onnx, bin)
    # for the openvino models.
    extension = weight_path.suffix
    inferencer: Inferencer
    module = import_module("anomalib.deploy")
    if extension in {".pt", ".pth", ".ckpt"}:
        torch_inferencer = module.TorchInferencer
        inferencer = torch_inferencer(path=weight_path)

    elif extension in {".onnx", ".bin", ".xml"}:
        openvino_inferencer = module.OpenVINOInferencer
        inferencer = openvino_inferencer(path=weight_path)

    else:
        msg = (
            "Model extension is not supported. "
            "Torch Inferencer exptects a .ckpt file,OpenVINO Inferencer expects either .onnx, .bin or .xml file. "
            f"Got {extension}"
        )
        raise ValueError(
            msg,
        )

    return inferencer
Parse args and open inferencer.

    Args:
        weight_path (Path): Path to model weights.
        metadata (Path | None, optional): Metadata is required for OpenVINO models. Defaults to None.

    Raises:
        ValueError: If unsupported model weight is passed.

    Returns:
        Inferencer: Torch or OpenVINO inferencer.
    
tools/inference/gradio_inference.py