Nodes/ComfyUI Layer Style/LayerMask: Load Segformer Model
ComfyUI Node Runs on cloud

LayerMask: Load Segformer Model

Load Segformer Model

By chflame163·Created 3 years ago·Updated 4 days ago· 3,113
LayerMask: Load Segformer Model
    • segfromer_model
    ◄model_name▾►
    ◄device▾►

    Load Segformer Model is a loader node - on its own it does nothing visible. Its job is to load a SegFormer human-parsing model into memory and hand it downstream to the node that actually segments your image. If you want to automatically mask "just the shirt" or "just the hair" on a person, this is the first node in that chain: it loads the brain, and a separate Segformer segmentation node does the parsing.

    SegFormer is a transformer-based semantic-segmentation model. The variants this node offers are fine-tuned for people and clothing, which is what makes them useful for fashion, try-on, and portrait editing:

    • model_name - pick one of segformer_b3_clothes, segformer_b2_clothes, or segformer_b3_fashion. The b2/b3 is model size: b3 is bigger and more accurate, b2 is lighter and faster. The clothes models parse a person into body parts and garments (hair, face, arms, legs, upper-clothes, pants, dress, and so on); fashion is tuned toward fashion-catalog garment categories. For general "mask this garment on a person" work, a clothes model is the one to grab.
    • device - cuda or cpu. Use cuda if you've got the GPU; these run fine on CPU too, just slower.

    The single output is segfromer_model (yes, the label has a typo in the node - it's the model handle regardless). You wire it into the Segformer segmentation node that does the actual work.

    Here's the key thing to understand: this node is half of a pair. By itself it produces no mask. The usual pattern is Load Segformer Model (this node) → a Segformer clothes/ultra segmentation node, often alongside a Segformer Clothes Setting node that tells it which parts to include. Loading the model separately means you can load it once and feed several segment operations without reloading, which is the efficiency reason it's a standalone node rather than baked into the segmenter.

    Where it fits in the bigger picture: this is precise, label-aware human parsing, a step up from generic background removal. The KB's take on garment segmentation is that rembg's u2net_cloth_seg splits a person into just upper/lower/full body - coarse. SegFormer clothes models give you many more classes (individual limbs, hair, hat, bag, each garment type), which is what you need for targeted edits: recolor only the dress, inpaint only the jacket, mask out the hair for a separate treatment. It's the loader behind that capability.

    On the model files: SegFormer weights download from Hugging Face on first use (or you place them in ComfyUI's models directory - the pack's docs cover the exact folder). First run may pause to fetch them, and if the machine is offline that's where it'll fail, so make sure the download completes once.

    Install is the pack standard. Easiest is ComfyUI Manager - search ComfyUI Layer Style (or "LayerStyle"), install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/chflame163/ComfyUI_LayerStyle, then pip install -r requirements.txt from inside the folder using ComfyUI's Python, and restart. On a hosted ComfyUI it's usually preinstalled with the SegFormer models in place.

    The pack-wide caveat, and it's pointed here: Layer Style is notorious for import failures - install it, restart, and the whole node set shows up red or missing. It's a dependency clash. The pack pulls a heavy stack (transformers, onnxruntime, opencv), and one mismatched version - a stray transformers or tensorflow being the classic - takes the entire pack down on import. SegFormer runs on transformers, so this node is one of the most sensitive to a bad transformers version. Fix it by reading the ComfyUI startup log for the traceback (it names the package that failed), reinstalling requirements against ComfyUI's own Python, and using Manager's Try Fix. If this loader is missing, every LayerStyle node is, and that shared import failure is the real thing to solve first.

    Category😺dzNodes/LayerMask

    Inputs (2)

    NameTypeDefaultDescription
    model_nameCOMBO3 options: segformer_b3_clothes, segformer_b2_clothes, segformer_b3_fashion
    deviceCOMBO2 options: cuda, cpu

    Outputs (1)

    NameTypeDescription
    segfromer_modelLS_SEGFORMER_MODEL—