Nodes/comfyui-dsocr-bbox/OCR Apply Business Decisions
ComfyUI Node

OCR Apply Business Decisions

Where your LLM's verdict gets merged back into the mask pipeline

By maomaozi·Created 2 months ago·Updated 2 months ago· 0
OCR Apply Business Decisions
    • decisions_json
    • remove_items_json
    • preserve_items_json
    classified_json
    unresolved_actionkeep_rule
    llm_decisions

    The business pipeline's final brain: this node takes the classified OCR detections plus (optionally) whatever your LLM decided, merges them together by stable detection ID, and produces the decisions JSON the mask stage consumes. It's the "apply" half of "review and apply" - the moment the pipeline stops thinking and commits to what gets removed.

    Two paths, one node:

    • No LLM connected - llm_decisions is optional. The rule decisions from the classifier pass straight through, and unresolved_action decides what happens to anything still flagged review (keep the rule's verdict, or force it to preserve/ignore/remove).
    • LLM connected - the LLM's JSON is merged back by stable detection ID. The LLM can override actions and region policies, group multiple detections under a group, or supply an exact pixel region for the explicit_box policy. Markdown fences and stray prose around the JSON are accepted and stripped.

    It also produces a remove_items_json and a preserve_items_json - just the items slated for removal and preservation - which are handy for a text preview or an audit step before you commit pixels.

    The decision format

    A decision has two independent dimensions, and understanding the split is the key to using the whole pipeline:

    • action - remove, preserve, ignore, review. Whether the text is promotional is a semantic call.
    • region_policy - text, box, top_banner, bottom_banner, group_box, gift_object, explicit_box, none. How big the masked area should be is a geometric call.

    That separation is deliberate: deciding "this line is a promo" and deciding "the entire banner behind it gets reconstructed" are different kinds of reasoning, and the pipeline keeps them separate so either stage can run without the other.

    Inputs

    • classified_json - from OCR Business Rule Classifier.
    • llm_decisions (optional) - from your LLM, the JSON your OCR Business LLM Review Prompt prompted for.
    • unresolved_action - fallback for review items: keep_rule (default), preserve, ignore, or remove.

    Outputs: decisions_json, remove_items_json, preserve_items_json - all STRING, all feedable into OCR Business Regions To Mask (decisions_json does the driving).

    Installing

    Part of comfyui-dsocr-bbox. ComfyUI Manager (search "dsocr") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/maomaozi/comfyui-dsocr-bbox
    

    restart. Zero extra dependencies for this node - it's pure JSON plumbing.

    Gotchas

    The merge is by detection ID, so a re-run of the detector anywhere upstream invalidates the LLM's references - run the pipeline in one pass or you'll get silent mismatches. And don't skip this node for rules-only workflows: the README's shortcut connects classified_json straight to OCR Business Regions To Mask, which works, but then your review items just fall through with their rule verdicts. If you want the unresolved_action fallback applied, that's this node's job.

    CategoryDeepSeek OCR

    Inputs (3)

    NameTypeDefaultDescription
    classified_jsonSTRING
    unresolved_actionCOMBOkeep_rule4 options: keep_rule, preserve, ignore, remove
    llm_decisionsoptSTRING

    Outputs (3)

    NameTypeDescription
    decisions_jsonSTRING
    remove_items_jsonSTRING
    preserve_items_jsonSTRING