OCR Business Rule Classifier
Rule-based triage before you ever spend an LLM call
- classified_json
- review_items_json
The expensive way to clean product images is to send every OCR detection to a vision model for judgment. The cheap way is to do the obvious cases with rules first and only escalate the ambiguous ones. That's the whole job of this node: it takes the JSON from RapidOCR Detect Text and adds deterministic fields to every detection - action, category, reason, region_policy, and decision_source=rules - without calling any model.
It's the second stage of the pack's business pipeline:
RapidOCR Detect Text -> OCR Business Rule Classifier -> [LLM?] -> OCR Apply Business Decisions -> OCR Business Regions To Mask
Known brand, restricted, and promotion terms get flagged for removal. Product specifications and configured functional terms get preserved. Everything ambiguous gets marked review, so a downstream LLM can take a look without you paying for the obvious cases.
How it works
Rules, not AI. Keyword matching drives removal vs. preserve, with remove_keywords and preserve_keywords as your overrides (each a multiline list). bottom_start_ratio (default 0.83) defines where the "bottom" of the frame begins for bottom-banner logic. preserve_left_features (default on) protects functional copy on the left side of the layout - a heuristic tuned for the product-listing look where the left column holds specs. minimum_confidence (default 0.72) drops detections below the recognition confidence bar.
Every item keeps its stable ID from the detector, so the LLM later - and the apply node - can reference each detection unambiguously. The node outputs two strings:
classified_json- the full, annotated detection list.review_items_json- just the items flaggedreview, i.e. the shortlist your LLM actually needs to see.
That split is the cost-saving core: review_items_json can be small even when the image is dense.
Inputs
ocr_detections_json- fromRapidOCR Detect Text.minimum_confidence,bottom_start_ratio,preserve_left_features- the rule dials above.remove_keywords/preserve_keywords- your own terms, newline-separated.
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, then:
pip install -r custom_nodes/comfyui-dsocr-bbox/requirements.txt
Gotchas
The built-in keyword lists are tuned for e-commerce product copy (Chinese storefront terms especially - the whole pack leans that direction), so expect to tune remove_keywords/preserve_keywords for your own catalog. If a term you care about isn't in the lists, it'll land in review rather than being silently removed - which is safe, just noisy. And remember this node only classifies; the actual decisions get applied later by OCR Apply Business Decisions, so wiring classified JSON straight to a mask node skips the apply step entirely (fine for rules-only, just know you're doing it).
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| ocr_detections_json | STRING | — | |
| minimum_confidence | FLOAT | 0.720–1 | — |
| bottom_start_ratio | FLOAT | 0.830.5–0.98 | — |
| preserve_left_features | BOOLEAN | true | — |
| remove_keywords | STRING | — | |
| preserve_keywords | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| classified_json | STRING | — |
| review_items_json | STRING | — |