Shortcuts

ImageEmbedder

class flash.image.embedding.model.ImageEmbedder(embedding_dim=None, backbone='resnet101', pretrained=True, loss_fn=torch.nn.functional.cross_entropy, optimizer=torch.optim.SGD, optimizer_kwargs=None, scheduler=None, scheduler_kwargs=None, metrics=torchmetrics.Accuracy, learning_rate=0.001, pooling_fn=torch.max)[source]

The ImageEmbedder is a Task for obtaining feature vectors (embeddings) from images. For more details, see Image Embedder.

Parameters
  • embedding_dim (Optional[int]) – Dimension of the embedded vector. None uses the default from the backbone.

  • backbone (str) – A model to use to extract image features, defaults to "swav-imagenet".

  • pretrained (bool) – Use a pretrained backbone, defaults to True.

  • loss_fn (Callable) – Loss function for training and finetuning, defaults to torch.nn.functional.cross_entropy()

  • optimizer (Type[Optimizer]) – Optimizer to use for training and finetuning, defaults to torch.optim.SGD.

  • optimizer_kwargs (Optional[Dict[str, Any]]) – Additional kwargs to use when creating the optimizer (if not passed as an instance).

  • scheduler (Union[Type[LRScheduler], str, LRScheduler, None]) – The scheduler or scheduler class to use.

  • scheduler_kwargs (Optional[Dict[str, Any]]) – Additional kwargs to use when creating the scheduler (if not passed as an instance).

  • metrics (Union[Metric, Callable, Mapping, Sequence, None]) – Metrics to compute for training and evaluation. Can either be an metric from the torchmetrics package, a custom metric inherenting from torchmetrics.Metric, a callable function or a list/dict containing a combination of the aforementioned. In all cases, each metric needs to have the signature metric(preds,target) and return a single scalar tensor. Defaults to torchmetrics.Accuracy.

  • learning_rate (float) – Learning rate to use for training, defaults to 1e-3.

  • pooling_fn (Callable) – Function used to pool image to generate embeddings, defaults to torch.max().

Read the Docs v: latest
Versions
latest
stable
0.5.0
0.4.0
0.3.2
0.3.1
0.3.0
0.2.3
0.2.2
0.2.1
0.2.0
0.1.0post1
Downloads
pdf
html
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.