Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Interfejs API segmentacji tematów w ML Kit pozwala programistom łatwo oddzielić wiele osób od tła na zdjęciu, co pozwala np. tworzyć naklejki, zmieniać tło czy dodawać ciekawe efekty do obiektów.
Obiekty to najbardziej widoczne osoby, zwierzęta lub obiekty na pierwszym planie obrazu. Jeśli 2 obiekty są bardzo blisko siebie lub się stykają, uznaje się je za 1 obiekt.
Interfejs API segmentacji podmiotów pobiera obraz wejściowy i generuje na pierwszym planie maskę wyjściową lub bitmapę. Zapewnia też maskę i mapę bitową dla każdego wykrytego obiektu (pierwszy plan jest równy wszystkim obiektom łącznie).
Domyślnie maska i bitmapa na pierwszym planie mają ten sam rozmiar co obraz wejściowy (rozmiar maski i bitmapy poszczególnych podmiotów prawdopodobnie będzie się różnić od rozmiaru obrazu wejściowego). Każdy piksel maski ma przypisaną liczbę zmiennoprzecinkową z zakresu od 0.0 do 1.0. Im bliższa jest liczba 1.0, tym większa pewność, że piksel reprezentuje obiekt – i odwrotnie.
Średni czas oczekiwania mierzony na Pixelu 7 Pro wynosi około 200 ms. Ten interfejs API obsługuje obecnie tylko obrazy statyczne.
Podział na segmenty według wielu tematów: umożliwia korzystanie z masek i map bitowych dla każdego obiektu zamiast pojedynczej maski i bitmapy dla wszystkich obiektów łącznie.
Rozpoznawanie obiektów: rozpoznawane obiekty to obiekty, zwierzęta i ludzie.
Przetwarzanie na urządzeniu: całość przetwarzania odbywa się na urządzeniu z zachowaniem ochrony prywatności użytkownika i nie wymaga połączenia sieciowego.
[null,null,["Ostatnia aktualizacja: 2025-07-25 UTC."],[[["\u003cp\u003eThe ML Kit subject segmentation API enables developers to isolate subjects (people, pets, objects) from the background in images for various applications like sticker creation and background replacement.\u003c/p\u003e\n"],["\u003cp\u003eThis API provides individual masks and bitmaps for each detected subject, allowing for granular manipulation and effects.\u003c/p\u003e\n"],["\u003cp\u003eAll processing happens on-device, ensuring user privacy and eliminating the need for internet connectivity.\u003c/p\u003e\n"],["\u003cp\u003eThis API is currently in beta and might undergo changes that could affect backward compatibility.\u003c/p\u003e\n"]]],[],null,["# Subject Segmentation\n\n| This API is offered in beta, and is not subject to any SLA or deprecation policy. Changes may be made to this API that break backward compatibility.\n\nML Kit's subject segmentation API allows developers to easily separate multiple\nsubjects from the background in a picture, enabling use cases such as sticker\ncreation, background swap, or adding cool effects to subjects.\n\nSubjects are defined as the most prominent people, pets, or objects in the\nforeground of the image. If 2 subjects are very close or touching each other,\nthey are considered a single subject.\n\nThe subject segmentation API takes an input image and generates an output mask\nor bitmap for the foreground. It also provides a mask and bitmap for each one of\nthe subjects detected (the foreground is equal to all subjects combined).\n\nBy default, the foreground mask and foreground bitmap are the same size as the\ninput image (the size of each individual subject's mask and bitmap will likely\ndiffer from input image size). Each pixel of the mask is assigned a float number\nthat has a range between `0.0` and `1.0`. The closer the number is to `1.0`, the\nhigher the confidence that the pixel represents a subject, and vice versa.\n\nOn average the latency measured on Pixel 7 Pro is around 200 ms. This API\ncurrently only supports static images.\n\n[Android](/ml-kit/vision/subject-segmentation/android)\n\n### Key capabilities\n\n- **Multi-subject segmentation:** provides masks and bitmaps for each individual subject, rather than a single mask and bitmap for all subjects combined.\n- **Subject recognition:** subjects recognized are objects, pets, and humans.\n- **On-device processing:** all processing is performed on the device, preserving user privacy and requiring no network connectivity.\n\n### Example results\n\n| Input Image | Output Image + Mask |\n|-------------|---------------------|\n| | |\n| | |\n| | |"]]