Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
API phân đoạn chủ thể của Bộ công cụ học máy cho phép các nhà phát triển dễ dàng tách nhiều chủ thể khỏi nền trong một ảnh, cho phép các trường hợp sử dụng như tạo hình dán, hoán đổi nền hoặc thêm hiệu ứng thú vị vào chủ thể.
Chủ thể được xác định là người, thú cưng hoặc đối tượng nổi bật nhất ở phía trước của hình ảnh. Nếu 2 đối tượng rất gần hoặc chạm nhau, thì chúng được coi là một đối tượng duy nhất.
API phân đoạn đối tượng sẽ lấy hình ảnh đầu vào và tạo mặt nạ đầu ra hoặc bitmap cho nền trước. Tính năng này cũng cung cấp một mặt nạ và bitmap cho từng đối tượng được phát hiện (nền trước bằng với tất cả các đối tượng kết hợp).
Theo mặc định, mặt nạ trên nền trước và bitmap trên nền trước có cùng kích thước với hình ảnh đầu vào (kích thước mặt nạ và bitmap của từng chủ thể riêng lẻ có thể sẽ khác với kích thước hình ảnh đầu vào). Mỗi pixel của mặt nạ được gán một số thực có phạm vi từ 0.0 đến 1.0. Số càng gần 1.0 thì độ tin cậy của pixel càng cao và ngược lại.
Trung bình, độ trễ đo được trên Pixel 7 Pro là khoảng 200 mili giây. API này hiện chỉ hỗ trợ hình ảnh tĩnh.
[null,null,["Cập nhật lần gần đây nhất: 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| | |"]]