zensvi.cv.Embeddings ==================== .. py:class:: zensvi.cv.Embeddings(model_name: str = 'resnet-18', cuda: bool = False, tensor: bool = True, verbosity: int = 1) A class for extracting image embeddings using pre-trained models. .. py:method:: load_image(image_path) Load and preprocess an image from a file path. :param image_path: Path to the image file. :returns: Loaded and resized image. :rtype: PIL.Image .. py:method:: get_model_and_layer() Get the pre-trained model and extraction layer. :returns: Contains: - torch.nn.Module: The pre-trained model - torch.nn.Module: The extraction layer :rtype: tuple .. py:method:: get_image_embedding(image_path: Union[List[str], str], tensor: bool = None, cuda: bool = None) Extract embedding for a single image. :param image_path: Path to the image file. :param tensor: Whether to return the embedding as a PyTorch tensor. If None, uses the instance default. :param cuda: Whether to use CUDA for computation. If None, uses the instance default. :returns: The image embedding. :rtype: Union[torch.Tensor, numpy.ndarray] .. py:method:: generate_embedding(images_path: Union[List[str], str], dir_embeddings_output: str, batch_size: int = 100, maxWorkers: int = 8, verbosity: int = None) Generate and save embeddings for multiple images. :param images_path: Either a directory path containing images or a list of image paths. :param dir_embeddings_output: Directory where embeddings will be saved as parquet files. :param batch_size: Number of images to process in each batch. Default is 100. :param maxWorkers: Maximum number of worker threads for image processing. Default is 8. :param verbosity: Level of verbosity for progress bars. 0 = no progress bars, 1 = outer loops only, 2 = all loops. If None, uses the instance's verbosity level. :returns: True if embeddings were successfully generated and saved. :rtype: bool .. py:method:: search_similar_images(image_key: str, embeddings_dir: str, number_of_items: int = 10) Search for similar images using embeddings. :param image_key: Key of the query image. :param embeddings_dir: Directory containing the embeddings parquet file. :param number_of_items: Number of similar images to return. Default is 10. :returns: List of tuples containing (similarity_score, image_key, image_filename). :rtype: list .. py:method:: get_all_models() Get all the available models. :returns: Dictionary of available models with their configurations. :rtype: dict