Image Embedding module

class orangecontrib.imageanalytics.image_embedder.ImageEmbedder(model: str = 'inception-v3', server_url: str = 'https://api.garaza.io/')[source]

Client side functionality for accessing a remote image embedding backend.

model

Name of the model, must be one from MODELS dictionary

server_url

The url of the server with embedding backend.

Examples

>>> import Orange
>>> from orangecontrib.imageanalytics.image_embedder import ImageEmbedder
>>> # embedding from list of paths
>>> image_file_paths = ['image001.jpg', 'image001.jpg']
>>> with ImageEmbedder(model='model_name') as emb:
...    embeddings = emb(image_file_paths)
>>> # embedding from orange tabl
>>> table = Orange.data.Table('Table_with_image_path.csv')
>>> with ImageEmbedder(model='model_name') as emb:
...    embeddings = emb(table, col="image_path_column")
clear_cache() None[source]

Function clear cache for the selected embedder. If embedder is loaded cache is cleaned from its dict otherwise we load cache and clean it from file.

static construct_output_data_table(embedded_images: Orange.data.table.Table, embeddings_: numpy.ndarray) Orange.data.table.Table[source]

Join the orange table with embeddings.

Parameters
  • embedded_images – Table with images that were successfully embedded

  • embeddings – Embeddings for images from table

Returns

Return type

Table with added embeddings to data.

from_table(data: Orange.data.table.Table, col: Union[str, Orange.data.variable.Variable] = 'image', callback: Optional[Callable] = None) Tuple[Orange.data.table.Table, Orange.data.table.Table, int][source]

Calls embedding when data are provided as a Orange Table.

Parameters
  • data – Data table with image paths

  • col – The column with image paths

  • callback – Optional callback - function that is called for every embedded image and is used to report the progress.

is_local_embedder() bool[source]

Tells whether selected embedder is local or not.

static prepare_output_data(input_data: Orange.data.table.Table, embeddings_: List[List[float]]) Tuple[Orange.data.table.Table, Orange.data.table.Table, int][source]

Prepare output data when data table on input.

Parameters
  • input_data – The table with original data that are joined with embeddings

  • embeddings – List with embeddings

Returns

  • Tuple where first parameter is table with embedded images, the second

  • table with skipped images and third the number of skipped images.

set_canceled() None[source]

Cancel the embedding