OCR Apply Business Decisions
Where your LLM's verdict gets merged back into the mask pipeline
- decisions_json
- remove_items_json
- preserve_items_json
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_decisionsis optional. The rule decisions from the classifier pass straight through, andunresolved_actiondecides what happens to anything still flaggedreview(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 pixelregionfor theexplicit_boxpolicy. 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- fromOCR Business Rule Classifier.llm_decisions(optional) - from your LLM, the JSON yourOCR Business LLM Review Promptprompted for.unresolved_action- fallback forreviewitems:keep_rule(default),preserve,ignore, orremove.
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.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| classified_json | STRING | — | |
| unresolved_action | COMBO | keep_rule | 4 options: keep_rule, preserve, ignore, remove |
| llm_decisionsopt | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| decisions_json | STRING | — |
| remove_items_json | STRING | — |
| preserve_items_json | STRING | — |