Overview
This node performs image segmentation using semantic prompts via an external image segmentation API service. It allows users to segment parts of an image based on descriptive keywords (prompts) that specify what to include or exclude in the segmentation. The node supports input images either by URL or from binary data within the workflow.
Common scenarios for this node include:
- Automatically isolating objects like clothes, shoes, or other items in product images for e-commerce.
- Preparing segmented images for further processing such as background removal or object recognition.
- Enhancing image editing workflows by programmatically extracting specific elements.
For example, a user can input an image URL and provide a prompt like "clothes, shoes" to segment those items, optionally excluding others with a negative prompt like "pants". The node can wait for the segmentation task to complete and return either JSON metadata or the segmented image as binary data.
Properties
| Name | Meaning |
|---|---|
| Image Input Method | How to input the image to segment: URL or Binary Field |
| Image URL | URL of the image to segment (required if Image Input Method is URL) |
| Binary Field | Name of the binary field containing the image to segment (required if Image Input Method is Binary Field) |
| Prompt | Semantic prompt listing things to segment, separated by commas (e.g., "clothes,shoes") (required) |
| Negative Prompt | Semantic prompt listing things NOT to segment, separated by commas (e.g., "pants") |
| Segment Factor | Number of pixels to expand (positive) or shrink (negative) the edges of the segmented area |
| Wait For Completion | Whether to wait for the segmentation task to finish before continuing |
| Return Binary Data | If waiting for completion, whether to return the segmented image as binary data |
| Binary Property | Name of the binary property to write the segmented image data to (used only if returning binary data) |
Output
The node outputs an array of items corresponding to each input item processed.
- If Wait For Completion is false, the output JSON contains at least the
taskIdand related task data returned immediately after starting the segmentation task. - If Wait For Completion is true and Return Binary Data is false, the output JSON contains the full task result including segmentation details and URLs.
- If Wait For Completion is true and Return Binary Data is true, the output includes:
- A JSON part with the task result metadata.
- A binary part containing the actual segmented image data under the specified binary property name.
If any error occurs during processing, the output JSON will contain an error field describing the issue (if continuing on failure).
Dependencies
- Requires an API key credential for the external image segmentation service (referred generically as an API authentication token).
- Uses helper functions to make HTTP requests to the segmentation API and to wait for asynchronous task completion.
- If returning binary data, it downloads the segmented image from a URL provided by the API.
Troubleshooting
- No binary data exists on item!: Occurs if the selected binary field does not exist in the input item when using binary input method. Ensure the binary field name matches exactly and the input item contains binary data.
- No binary data found for field "X"!: The specified binary field is missing in the current item. Verify the binary field name and input data.
- No segmented image URL found in the response: Happens if the API response does not include a URL for the segmented image when binary data output is requested. Check the API response and ensure the segmentation completed successfully.
- Network or API errors may occur; enabling "Continue On Fail" allows the workflow to proceed while capturing error messages in output.
Links and References
- No direct links are included in the source code. Users should refer to the documentation of the external image segmentation API service used by this node for detailed information on prompts, segmentation parameters, and API usage.