{
  "workflow_info": {
    "name": "Remove Background (BiRefNet)",
    "description": "Cut the subject out of an image with a BiRefNet matting variant (ComfyUI-RMBG). Outputs the RGBA cut-out and the mask as a second image.",
    "version": "1.0.0",
    "author": "Oshun Platform",
    "category": "chroma",
    "tags": ["chroma", "runpod-serverless", "volume-backed", "background-removal", "matting"],
    "estimated_time_seconds": 8,
    "gpu_requirement": "A5000"
  },
  "estimated_cost_usd": 0.003,
  "cost_note": "Estimate from the 2026-09-11 cost model (RTX 4090 $1.10/h flex); replaced by measured C.11 numbers.",
  "content_policy": "adult_ok",
  "policy_note": "A matting tool that generates no content: BiRefNet is MIT, and the 2026-09-13 licence facts record no acceptable-use clause restricting what it separates.",
  "inputs": {
    "source_image": {
      "type": "image",
      "required": true,
      "description": "Image to matte"
    },
    "model": {
      "type": "enum",
      "options": ["birefnet-portrait", "birefnet-matting", "birefnet-hr-matting"],
      "default": "birefnet-hr-matting",
      "description": "Matting model (BiRefNet variants, MIT)"
    },
    "sensitivity": {
      "type": "float",
      "default": 1.0,
      "min": 0.0,
      "max": 1.0,
      "description": "Mask detection strength"
    },
    "mask_blur": {
      "type": "integer",
      "default": 0,
      "min": 0,
      "max": 64,
      "description": "Blur radius on the mask edge"
    },
    "mask_offset": {
      "type": "integer",
      "default": 0,
      "min": -20,
      "max": 20,
      "description": "Grow (+) or shrink (-) the mask"
    },
    "refine_foreground": {
      "type": "boolean",
      "default": true,
      "description": "Fast foreground colour estimation on the cut-out edge"
    }
  },
  "matte_option_map": {
    "birefnet-portrait": "BiRefNet-portrait",
    "birefnet-matting": "BiRefNet-matting",
    "birefnet-hr-matting": "BiRefNet-HR-matting"
  },
  "nodes": {
    "1": {
      "class_type": "LoadImage",
      "inputs": {
        "image": "{{source_image}}"
      },
      "outputs": ["IMAGE", "MASK"]
    },
    "2": {
      "class_type": "BiRefNetRMBG",
      "inputs": {
        "image": ["1", 0],
        "model": "{{matte_option_map[model]}}",
        "sensitivity": "{{sensitivity}}",
        "mask_blur": "{{mask_blur}}",
        "mask_offset": "{{mask_offset}}",
        "invert_output": false,
        "refine_foreground": "{{refine_foreground}}",
        "background": "Alpha",
        "background_color": "#222222"
      },
      "outputs": ["IMAGE", "MASK", "MASK_IMAGE"],
      "_comment": "ComfyUI-RMBG's BiRefNetRMBG for every option. RMBG-2.0 (non-commercial without a BRIA agreement, and the one model of four that failed C.12.20) was dropped by A.02.08, and with it the templated class_type and the process_res input only its RMBG node read."
    },
    "3": {
      "class_type": "SaveImage",
      "inputs": {
        "images": ["2", 0],
        "filename_prefix": "isis/removebg-rgba"
      },
      "outputs": []
    },
    "4": {
      "class_type": "SaveImage",
      "inputs": {
        "images": ["2", 2],
        "filename_prefix": "isis/removebg-mask"
      },
      "outputs": []
    }
  },
  "output_spec": {
    "type": "image",
    "format": "png",
    "primary": {
      "type": "image",
      "format": "png",
      "description": "RGBA cut-out with the background removed"
    },
    "render_passes": [
      {
        "pass": "beauty",
        "artifact_id": "cutout",
        "format": "png",
        "required": true,
        "description": "RGBA cut-out (SaveImage on the matte node image output)"
      },
      {
        "pass": "mask",
        "artifact_id": "mask",
        "format": "png",
        "required": true,
        "description": "Single-channel alpha matte (SaveImage on the matte node mask output)"
      }
    ]
  },
  "custom_nodes_required": ["BiRefNetRMBG"],
  "models_required": [
    "BiRefNet-portrait.safetensors",
    "BiRefNet-matting.safetensors",
    "BiRefNet-HR-matting.safetensors"
  ],
  "requires_families": ["birefnet"]
}
