opendatalab/MinerU · error · ValueError

Unsupported PP-DocLayoutV2 label: {label}

Error message

Unsupported PP-DocLayoutV2 label: {label}

What it means

ValueError raised by PPDocLayoutV2LayoutModel._set_box_label when label is not a key of PP_DOCLAYOUT_V2_LABEL_TO_ID (the 25 fixed class names 'abstract'..'vision_footnote' with ids 0..24). The helper keeps box['label'] and box['cls_id'] in sync, so unknown labels cannot be assigned an id and are rejected.

Source

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

    def _is_inline_formula_box(box: Dict) -> bool:
        return box.get("label") == "inline_formula" or int(box.get("cls_id", -1)) == 15

    @staticmethod
    def _is_formula_box(box: Dict) -> bool:
        return (
            PPDocLayoutV2LayoutModel._is_display_formula_box(box)
            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:

View on GitHub (pinned to 4fe4bde114)

Solutions

  1. Use one of the 25 supported labels exactly as spelled in PP_DOCLAYOUT_V2_LABELS (e.g. 'text', 'image', 'table', 'figure_title', 'footnote').
  2. Map your vocabulary to the supported one before calling the helper.
  3. If you truly need new classes, extend PP_DOCLAYOUT_V2_LABELS and retrain — runtime relabeling cannot invent ids.

Example fix

# before
PPDocLayoutV2LayoutModel._set_box_label(box, 'caption')  # ValueError

# after
PPDocLayoutV2LayoutModel._set_box_label(box, 'figure_title')
Defensive patterns

Strategy: validation

Validate before calling

from mineru.model.layout.pp_doclayoutv2 import PP_DOCLAYOUT_V2_LABEL_TO_ID

def safe_set_box_label(box: dict, label: str) -> None:
    if label not in PP_DOCLAYOUT_V2_LABEL_TO_ID:
        raise ValueError(
            f'label {label!r} unsupported; valid labels: {sorted(PP_DOCLAYOUT_V2_LABEL_TO_ID)}'
        )
    PPDocLayoutV2LayoutModel._set_box_label(box, label)

Type guard

def is_supported_label(label: str) -> bool:
    from mineru.model.layout.pp_doclayoutv2 import PP_DOCLAYOUT_V2_LABEL_TO_ID
    return label in PP_DOCLAYOUT_V2_LABEL_TO_ID

Prevention

When it happens

Trigger: Calling _set_box_label(box, 'caption') or any string outside PP_DOCLAYOUT_V2_LABELS; also custom post-processing code that renames labels before calling helpers like _set_header_footer_label / _set_footnote_label, which delegate to this method.

Common situations: Porting label vocabularies from other layout models (PubLayNet, DocBank) whose names differ; typos ('paragragh_title'); new custom classes added by users without extending the mapping; version differences in label sets.

Related errors


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