Huggingface Segmentation Model¶
sahi.models.huggingface_segmentation
¶
HuggingFace segmentation model wrapper for SAHI.
Supports MaskFormer, Mask2Former, and OneFormer for instance, semantic, and panoptic segmentation via Hugging Face Transformers.
Classes¶
HuggingfaceSegmentationModel
¶
HuggingfaceSegmentationModel(
*args: Any,
overlap_mask_area_threshold: float = 0.8,
label_ids_to_fuse: list[int] | None = None,
min_segment_area: int = 100,
segmentation_type: SegmentationType = INSTANCE_SEGMENTATION,
**kwargs: Any,
)
Bases: HuggingfaceDetectionModel
HuggingFace segmentation model.
Subclasses :class:HuggingfaceDetectionModel, reusing its processor,
num_categories, token handling, and dependency checks. Supports
MaskFormer, Mask2Former, and OneFormer for instance, semantic, and
panoptic segmentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
float
|
Overlap mask area threshold to merge or discard small disconnected parts within each binary instance mask. |
0.8
|
|
list[int] | None
|
Label ids whose instances will be fused together (panoptic only). E.g. sky can be a single segment per image. |
None
|
|
int
|
Segments below this contour area are dropped. |
100
|
|
SegmentationType
|
Which segmentation head to use. Params that do not apply to the chosen type are ignored. |
INSTANCE_SEGMENTATION
|
Source code in sahi/models/huggingface_segmentation.py
Methods:¶
load_model
¶
Load model and processor from HuggingFace.