Inference Providers documentation
Image Segmentation
Image Segmentation
Image Segmentation divides an image into segments where each pixel in the image is mapped to an object.
For more details about the image-segmentation
task, check out its dedicated page! You will find examples and related materials.
Recommended models
- openmmlab/upernet-convnext-small: Solid semantic segmentation model trained on ADE20k.
- facebook/mask2former-swin-large-coco-panoptic: Panoptic segmentation model trained on the COCO (common objects) dataset.
Explore all available models and find the one that suits you best here.
Using the API
Copied
from huggingface_hub import InferenceClient
client = InferenceClient(
provider="hf-inference",
api_key="hf_xxxxxxxxxxxxxxxxxxxxxxxx",
)
output = client.image_segmentation("cats.jpg", model="jonathandinu/face-parsing")
API specification
Request
Headers | ||
---|---|---|
authorization | string | Authentication header in the form 'Bearer: hf_****' when hf_**** is a personal user access token with “Inference Providers” permission. You can generate one from your settings page. |
Payload | ||
---|---|---|
inputs* | string | The input image data as a base64-encoded string. If no parameters are provided, you can also provide the image data as a raw bytes payload. |
parameters | object | |
mask_threshold | number | Threshold to use when turning the predicted masks into binary values. |
overlap_mask_area_threshold | number | Mask overlap threshold to eliminate small, disconnected segments. |
subtask | enum | Possible values: instance, panoptic, semantic. |
threshold | number | Probability threshold to filter out predicted masks. |
Response
Body | ||
---|---|---|
(array) | object[] | A predicted mask / segment |
label | string | The label of the predicted segment. |
mask | string | The corresponding mask as a black-and-white image (base64-encoded). |
score | number | The score or confidence degree the model has. |