Skip to main content

hugging_face_image_classification

Hugging Face Image Classification Algorithm.

Classes

HuggingFaceImageClassificationInference

class HuggingFaceImageClassificationInference(    model_id: str,    image_column_name: str,    seed: int = 42,    apply_softmax_to_predictions: bool = True,    batch_size: int = 1,    top_k: int = 5,):

Inference for pre-trained Hugging Face image classification models.

Arguments

  • batch_size: The batch size for inference. Defaults to 1.
  • image_column_name: The image column on which the inference should be done.
  • model_id: The model id to use for image classification inference. The model id is of a pretrained model hosted inside a model repo on huggingface.co. Accepts resnet models.
  • seed: Sets the seed of the algorithm. For reproducible behavior it defaults to 42.
  • top_k: The number of top labels that will be returned by the pipeline. If the provided number is higher than the number of labels available in the model configuration, it will default to the number of labels. Defaults to 5.

Attributes

  • batch_size: The batch size for inference. Defaults to 1.
  • class_name: The name of the algorithm class.
  • fields_dict: A dictionary mapping all attributes that will be serialized in the class to their marshamllow field type. (e.g. fields_dict = {"class_name": fields.Str()}).
  • image_column_name: The image column on which the inference should be done.
  • model_id: The model id to use for image classification inference. The model id is of a pretrained model hosted inside a model repo on huggingface.co. Accepts resnet models.
  • nested_fields: A dictionary mapping all nested attributes to a registry that contains class names mapped to the respective classes. (e.g. nested_fields = {"datastructure": datastructure.registry})
  • seed: Sets the seed of the algorithm. For reproducible behavior it defaults to 42.
  • top_k: The number of top labels that will be returned by the pipeline. If the provided number is higher than the number of labels available in the model configuration, it will default to the number of labels. Defaults to 5.

Ancestors

Variables

  • static fields_dict : ClassVar[T_FIELDS_DICT]

Methods


create

def create(self, role: Union[str, Role], **kwargs: Any)> Any:

Create an instance representing the role specified.

modeller

def modeller(    self,    **kwargs: Any,)> bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_image_classification._ModellerSide:

Returns the modeller side of the HuggingFaceImageClassificationInference algorithm.

worker

def worker(    self,    **kwargs: Any,)> bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_image_classification._WorkerSide:

Returns the worker side of the HuggingFaceImageClassification algorithm.