ImageEmbeddingConverter
HuggingFace image embedding converter.
Encodes every image column into dense float columns using a pretrained
vision model. Unlike the text Embedding converter this template is
based on, the source image column is kept by default, controlled by
keep_source_column, so a later stage can still reach the original
pixels of the same saved dataset.
Parameters
- model_name : string, default=
DINOv2 small - Pretrained vision model used to encode images. All options are Apache 2.0 licensed, which is compatible with this project.
- device : string, default=
CPU - Device to use for computation.
- batch_size : integer, default=
32 - Number of images to process at once.
- keep_source_column : boolean, default=
True - When enabled, the original image column is kept alongside the new embedding columns instead of being removed.
Methods
fit(self, x: 'DashAIDataset', y: 'DashAIDataset' = None) -> 'ImageEmbeddingConverter'
ImageEmbeddingConverterValidate the input dataset and load the vision model if needed.
Parameters
- x : DashAIDataset
- Input dataset whose columns must all be image typed.
- y : DashAIDataset or None, optional
- Ignored. Present for API compatibility. Default
None.
Returns
- ImageEmbeddingConverter
- The fitted converter instance (
self).
get_output_type(self, column_name: str = None) -> DashAI.back.types.dashai_data_type.DashAIDataType
ImageEmbeddingConverterReturn the DashAI type produced for a given output column.
Parameters
- column_name : str or None, optional
- Name of the output column. Default
None.
Returns
- DashAIDataType
- The type recorded in :attr:
column_typeswhencolumn_nameis one of the original columns carried through, for example the source image column whenkeep_source_columnis true. Otherwise, a DashAIFloattype backed bypyarrow.float32(), since every column this converter adds is an embedding column.
get_credential(self, name: str)
ConfigObjectResolve a registered credential component by name.
Parameters
- name : str
- Credential component class name (e.g. "HuggingFaceCredential").
Returns
- BaseCredential
- An instance of the requested credential component.
get_metadata(cls) -> 'Dict[str, Any]'
BaseConverterGet metadata for the converter, used by the DashAI frontend.
Parameters
- cls : type
- The converter class (injected automatically by Python for classmethods).
Returns
- Dict[str, Any]
- Dictionary containing display name, short description, image preview path, category, icon, color, and whether the converter is supervised.
get_schema(cls) -> dict
ConfigObjectGenerates the component related Json Schema.
Returns
- dict
- Dictionary representing the Json Schema of the component.
transform(self, x: 'DashAIDataset', y: 'DashAIDataset' = None) -> 'DashAIDataset'
HuggingFaceWrapperTransform the input dataset by running inference in batches.
Parameters
- x : DashAIDataset
- The dataset to transform. Must have been fitted first.
- y : DashAIDataset or None, optional
- Ignored. Present for API compatibility. Default
None.
Returns
- DashAIDataset
- Transformed dataset with output types set per column.
validate_and_transform(self, raw_data: dict) -> dict
ConfigObjectIt takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.
Parameters
- raw_data : dict
- A dictionary with the data provided by the user to initialize the model.
Returns
- dict
- A validated dictionary with the necessary objects.