opendatalab/MinerU · error · ValueError

Unsupported formula label: {label}

Error message

Unsupported formula label: {label}

What it means

ValueError raised by _set_formula_label when label is not exactly 'inline_formula' or 'display_formula'. This narrow helper exists to re-classify detected boxes between the two formula classes (cls_id 15 and 5) and delegates to _set_box_label, so it intentionally accepts only that pair.

Source

Thrown at mineru/model/layout/pp_doclayoutv2.py:1197

            or PPDocLayoutV2LayoutModel._is_inline_formula_box(box)
        )

    @staticmethod
    def _is_formula_number_box(box: Dict) -> bool:
        return box.get("label") == "formula_number" or int(box.get("cls_id", -1)) == 11

    @staticmethod
    def _set_box_label(box: Dict, label: str) -> None:
        """统一同步设置 layout 检测框的标签名和类别编号。"""
        if label not in PP_DOCLAYOUT_V2_LABEL_TO_ID:
            raise ValueError(f"Unsupported PP-DocLayoutV2 label: {label}")
        box["label"] = label
        box["cls_id"] = PP_DOCLAYOUT_V2_LABEL_TO_ID[label]

    @staticmethod
    def _set_formula_label(box: Dict, label: str) -> None:
        if label not in {"inline_formula", "display_formula"}:
            raise ValueError(f"Unsupported formula label: {label}")
        PPDocLayoutV2LayoutModel._set_box_label(box, label)

    @staticmethod
    def _set_header_footer_label(box: Dict, label: str) -> None:
        """同步设置页眉/页脚相关标签及其类别编号。"""
        if label not in {"footer", "footer_image", "header", "header_image"}:
            raise ValueError(f"Unsupported header/footer label: {label}")
        PPDocLayoutV2LayoutModel._set_box_label(box, label)

    @staticmethod
    def _set_footnote_label(box: Dict) -> None:
        """同步设置 page footnote 标签及其类别编号。"""
        PPDocLayoutV2LayoutModel._set_box_label(box, "footnote")

    @classmethod
    def _reclassify_header_footer_by_page_half(
        cls,
        boxes: List[Dict],

View on GitHub (pinned to 4fe4bde114)

Solutions

  1. Pass 'inline_formula' or 'display_formula'.
  2. Use _set_box_label(box, 'formula_number') for formula-number boxes instead.
  3. Route other labels through _set_box_label, which accepts all 25 class names.

Example fix

# before
_set_formula_label(box, 'formula')  # ValueError

# after
_set_formula_label(box, 'display_formula')
# or for numbering boxes:
_set_box_label(box, 'formula_number')
Defensive patterns

Strategy: validation

Validate before calling

FORMULA_LABELS = {'inline_formula', 'display_formula'}

def set_formula_label(box: dict, label: str) -> None:
    if label not in FORMULA_LABELS:
        raise ValueError(f'formula label must be one of {sorted(FORMULA_LABELS)}, got {label!r}')
    PPDocLayoutV2LayoutModel._set_formula_label(box, label)

Type guard

def is_formula_label(label: str) -> bool:
    return label in {'inline_formula', 'display_formula'}

Prevention

When it happens

Trigger: _set_formula_label(box, 'formula') or _set_formula_label(box, 'formula_number') — the latter is a different class handled by _is_formula_number_box/cls_id 11, not this helper.

Common situations: Post-processing that collapses all math-like labels into 'formula'; passing the formula-number label through the wrong helper when re-classifying adjacent boxes near display formulas.

Related errors


AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14). Data as JSON: /api/errors/b634de8e71c0181a. Report an issue: GitHub.