Skip to main content

hugging_face_image_segmentation

Hugging Face Image Segmentation Algorithm.

Classes

HuggingFaceImageSegmentationInference

class HuggingFaceImageSegmentationInference(    model_id: str,    image_column_name: str,    alpha: float = 0.3,    batch_size: int = 1,    dataframe_output: bool = False,    mask_threshold: float = 0.5,    overlap_mask_area_threshold: float = 0.5,    save_path: Union[str, os.PathLike] = PosixPath('.'),    seed: int = 42,    subtask: Optional[_Subtask] = None,    threshold: float = 0.9,):

Inference for pre-trained Hugging Face image segmentation models.

Perform segmentation (detect masks & classes) in the image(s) passed as inputs.

Arguments

  • alpha: the alpha for the mask overlay.
  • batch_size: The batch size for inference. Defaults to 1.
  • dataframe_output: Whether to output the prediction results in a dataframe format. Defaults to False.
  • image_column_name: The image column on which the inference should be done.
  • mask_threshold: Threshold to use when turning the predicted masks into binary values. Defaults to 0.5.
  • model_id: The model id to use for image segmentation inference. The model id is of a pretrained model hosted inside a model repo on huggingface.co. Accepts resnet models.
  • overlap_mask_area_threshold: Mask overlap threshold to eliminate small, disconnected segments. Defaults to 0.5.
  • save_path: The folder path where the images with masks drawn on them should be saved. Defaults to the current working directory.
  • seed: Sets the seed of the algorithm. For reproducible behavior it defaults to 42.
  • subtask: Segmentation task to be performed, choose [semantic, instance and panoptic] depending on model capabilities. If not set, the pipeline will attempt to resolve in the following order: panoptic, instance, semantic.
  • threshold: Probability threshold to filter out predicted masks. Defaults to 0.9.

Attributes

  • alpha: the alpha for the mask overlay.
  • batch_size: The batch size for inference. Defaults to 1.
  • class_name: The name of the algorithm class.
  • dataframe_output: Whether to output the prediction results in a dataframe format. Defaults to False.
  • 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.
  • mask_threshold: Threshold to use when turning the predicted masks into binary values. Defaults to 0.5.
  • model_id: The model id to use for image segmentation 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})
  • overlap_mask_area_threshold: Mask overlap threshold to eliminate small, disconnected segments. Defaults to 0.5.
  • save_path: The folder path where the images with masks drawn on them should be saved. Defaults to the current working directory.
  • seed: Sets the seed of the algorithm. For reproducible behavior it defaults to 42.
  • subtask: Segmentation task to be performed, choose [semantic, instance and panoptic] depending on model capabilities. If not set, the pipeline will attempt to resolve in the following order: panoptic, instance, semantic.
  • threshold: Probability threshold to filter out predicted masks. Defaults to 0.9.

Ancestors

Variables

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.base._HFModellerSide:

Returns the modeller side of the HuggingFaceImageSegmentationInference algorithm.

worker

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

Returns the worker side of the HuggingFaceImageSegmentationInference algorithm.