opendatalab/MinerU · error · NotImplementedError

{name} is not supported in MultiHead yet

Error message

{name} is not supported in MultiHead yet

What it means

Raised by MultiHead (rec_multi_head.py) when iterating head_list and encountering a head name other than the recognized ones (CTC/SAR/NRTR branches; the v6 LightSVTR path bypasses this loop). The multi-head rec model only knows how to build those specific heads from the out_channels_list.

Source

Thrown at mineru/model/utils/pytorchocr/modeling/heads/rec_multi_head.py:64

                    self.head = nn.Linear(self.encoder.out_channels, out_channels_list["CTCLabelDecode"], bias=True)
                    self.out_channels = out_channels_list["CTCLabelDecode"]
                    self.use_light_svtr_head = True
                else:
                    self.ctc_encoder = SequenceEncoder(
                        in_channels=in_channels, encoder_type=encoder_type, **neck_args
                    )
                    # ctc head
                    head_args = self.head_list[idx][name].get("Head", {})
                    if head_args is None:
                        head_args = {}

                    self.ctc_head = CTCHead(
                        in_channels=self.ctc_encoder.out_channels,
                        out_channels=out_channels_list["CTCLabelDecode"],
                        **head_args,
                    )
            else:
                raise NotImplementedError(f"{name} is not supported in MultiHead yet")

    def forward(self, x, data=None):
        """根据配置执行 v6 LightSVTR 或历史 CTC 分支。"""
        if self.use_light_svtr_head:
            ctc_encoder = self.encoder(x)
            ctc_encoder = ctc_encoder.squeeze(dim=2).permute(0, 2, 1)
            predicts = self.head(ctc_encoder)
            if not self.training:
                # 推理阶段保留 raw logits,交给 CTC 解码端按需计算 max 概率,避免整块 softmax 矩阵搬运。
                return {"ctc_logits": predicts, "ctc_use_raw_logits": True}
            return predicts
        ctc_encoder = self.ctc_encoder(x)
        return self.ctc_head(ctc_encoder)

View on GitHub (pinned to 4fe4bde114)

Solutions

  1. Restrict head_list entries to the supported head names (CTCLabelDecode/SARLabelDecode/NRTRLabelDecode families) — compare with the bundled MultiHead config.
  2. If you only need CTC, drop the extra head entries and keep just the CTC head.
  3. For PP-OCRv6 models, prefer the built-in LightSVTR head path (use_light_svtr_head) instead of hand-built head_list.

Example fix

# before
head_list:
  - CTCHead: {}
  - MyCustomHead: {}   # unsupported

# after
head_list:
  - CTCHead: {}
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED_HEADS = {"CTCLabelDecode", "SARLabelDecode", "NRTRLabelDecode"}
for entry in head_list:
    for name in entry:
        assert name in SUPPORTED_HEADS, f"MultiHead does not support {name!r}"

Prevention

When it happens

Trigger: A rec config with Head.name=MultiHead and head_list containing an entry like {'NRTRHead': ...} variants or a custom head name not handled by the constructor.

Common situations: Porting newer PaddleOCR rec configs whose head_list includes heads this port hasn't implemented; typos in head names inside YAML.

Related errors


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