Nodes/ComfyUI-BytePlus-ModelArk/BytePlus Seedream 5.0 Layer Separation
ComfyUI Node

BytePlus Seedream 5.0 Layer Separation

Turn a flat image into editable layers

By byteplus-sa·Created 8 days ago·Updated about 8 hours ago· 3
BytePlus Seedream 5.0 Layer Separation
    • base_image
    • base_mask
    • layers
    • masks
    • bboxes
    • layer_stack
    • layers_json
    ◄model▾►

    Every masking workflow has the same boring middle: you want the subject separated from the background and the logo separated from the subject and the lamp isolated, so you can move things. Segments, SAM, manual masks, one pass each. This node asks a generative model to do the whole decomposition at once - base plate, up to sixteen elements, each as its own layer with a stacking order, a bounding box, a name and a description.

    That's a different thing from segmentation. A segmentation node answers "where is the foreground?". This one answers "what are the parts of this picture, in what order do they stack, and roughly what is each one?" - and then hands you tensors you can actually composite with.

    How it works

    You give it one image. Seedream 5.0 Pro or Flash runs the same layer-decomposition call as the image node, returning a base image plus layer images with metadata: transparency, z-order, bounding box, and for each layer a text name/description. The pack decodes the RGBA layers and assembles several different views of the result, because different downstream nodes want different geometry.

    Under each model option you get image (exactly one image, at least 262,144 pixels - think 512×512 - aspect ratio within 1:16 to 16:1; anything over about 4 MP is downscaled before upload), prompt, size, seed, watermark, and crop_layers, plus prompt_optimization on Pro.

    • prompt is how you steer the split. Leave it empty and the model auto-detects the major elements. Describe elements in natural language to control it, or target exact regions with <bbox>left top right bottom</bbox> tags using 0–999 relative coordinates.
    • crop_layers is the geometry switch, and it's the one people get wrong. Off ("full canvas"), every layer sits at its true position on a base-sized canvas, so you can recomposite directly with ImageCompositeMasked. On ("minimal size"), each layer is cropped tight to its bounding box - far smaller tensors, but you have to rebuild placement with the bboxes output and a node that consumes it.

    Outputs, and they matter: base_image and base_mask; layers (transparent layers ordered bottom to top) and masks (index-aligned per-layer transparency, 1 = transparent like Load Image - add InvertMask first for ImageCompositeMasked-style work); bboxes, one placement box per layer with name, desc, z_index, native_size and flags in its metadata; layer_stack, a ready-to-edit layer document for Create Layered Image (each element its own tight, named layer at its true position - you can also extend it with Add Layer); and layers_json, the manifest of z-orders, names, descriptions and bounding boxes.

    There's one extra setting the whole pack otherwise avoids: save_layers. The README calls it out as the only option in the pack that writes files itself, with filename_prefix controlling where. Everything else here leaves saving to you.

    Install and key

    cd ComfyUI/custom_nodes
    git clone https://github.com/byteplus-sa/ComfyUI-BytePlus-ModelArk
    pip install -r ComfyUI-BytePlus-ModelArk/requirements.txt
    

    Restart (ComfyUI 0.31.0 or newer), or install via Manager by searching BytePlus ModelArk. Save the ModelArk key and region in Settings → BytePlus, or BYTEPLUS_API_KEY / BYTEPLUS_REGION in user/.env. Layer separation runs on 5.0 Pro or Flash, so activate one of those in the ModelArk console for your region.

    Where people get burned

    The single-image rule. Feed it a batch and it errors - this is a one-image-in node, so if your graph produces five variations, you need to pick one first (or accept five calls).

    Second, the mask convention: 1 means transparent, matching Load Image, not the "1 = keep" convention some masking nodes use. Get that backwards and your first composite is a hole where the subject should be.

    Third, crop_layers changes which outputs are directly usable, not just how big they are. If you want to composite immediately, leave it off; if you're feeding layer_stack into Create Layered Image, geometry barely matters because that output is always tight and always positioned.

    And the usual: this is a billed call, your image leaves the machine, and nothing here is going to run offline.

    CategoryBytePlus ModelArk

    Inputs (1)

    NameTypeDefaultDescription
    modelCOMBO2 options: [object Object], [object Object]

    Outputs (7)

    NameTypeDescription
    base_imageIMAGEThe base image (background plate) the layers stack onto.
    base_maskMASKTransparency of the base image (1 = transparent, LoadImage convention); currently always fully opaque.
    layersIMAGETransparent layers ordered bottom to top. Full canvas mode: placed on a black base-sized canvas at their bounding-box position. Minimal size mode: cropped to their bounding box, anchored top-left, padded to the largest layer.
    masksMASKPer-layer transparency, index-aligned with the layers batch (1 = transparent, LoadImage convention). For ImageCompositeMasked-style compositing, add InvertMask first.
    bboxesBOUNDING_BOXOne placement box per layer, index-aligned with the layers batch (feed both, plus masks, into Layers From Bounding Boxes to rebuild per-layer placement): {x, y, width, height, metadata: {name, desc, z_index, native_size, content_rect, flags}}. content_rect = [left, top, width, height] is the layer's content region within its own frame; it lands on the canvas at the box position plus that offset.
    layer_stackLAYERSReady-to-edit layer document for Create Layered Image: the base plate plus each element as its own named, tight-cropped layer at its true position and stacking order. Connect directly, or extend with Add Layer.
    layers_jsonSTRINGz_index, name, description, bounding box and saved file of the base image and each layer.