opendatalab/MinerU · error · ValueError

{} has no Architecture

Error message

{} has no Architecture

What it means

Raised by read_network_config_from_yaml when the YAML parses successfully but contains no top-level 'Architecture' key. The pytorchocr config format requires Architecture (with Backbone/Head/Neck) to build the network, so the file is considered not a valid network config.

Source

Thrown at mineru/model/utils/tools/infer/pytorchocr_utility.py:162

    return parser

def parse_args():
    parser = init_args()
    return parser.parse_args()

def get_default_config(args):
    return vars(args)


def read_network_config_from_yaml(yaml_path, char_num=None):
    if not os.path.exists(yaml_path):
        raise FileNotFoundError('{} is not existed.'.format(yaml_path))
    import yaml
    with open(yaml_path, encoding='utf-8') as f:
        res = yaml.safe_load(f)
    if res.get('Architecture') is None:
        raise ValueError('{} has no Architecture'.format(yaml_path))
    if res['Architecture']['Head']['name'] == 'MultiHead' and char_num is not None:
        res['Architecture']['Head']['out_channels_list'] = {
            'CTCLabelDecode': char_num,
            'SARLabelDecode': char_num + 2,
            'NRTRLabelDecode': char_num + 3
        }
    return res['Architecture']

def AnalysisConfig(weights_path, yaml_path=None, char_num=None):
    if not os.path.exists(os.path.abspath(weights_path)):
        raise FileNotFoundError('{} is not found.'.format(weights_path))

    if yaml_path is not None:
        return read_network_config_from_yaml(yaml_path, char_num=char_num)


def resize_img(img, input_size=600):
    """

View on GitHub (pinned to 4fe4bde114)

Solutions

  1. Open the YAML and confirm a top-level 'Architecture:' key with Backbone/Head exists.
  2. Use the network config shipped with the model rather than a training/pipeline config.
  3. Fix indentation if Architecture got nested under Global or another section.

Example fix

# before (pipeline yaml)
Global:
  Architecture:
    ...

# after
Architecture:
  Backbone: ...
  Head: ...
Defensive patterns

Strategy: validation

Validate before calling

import yaml
with open(yaml_path, encoding="utf-8") as f:
    cfg = yaml.safe_load(f)
assert isinstance(cfg, dict) and "Architecture" in cfg, f"{yaml_path} lacks top-level Architecture"

Type guard

def is_network_config(cfg) -> bool:
    return isinstance(cfg, dict) and isinstance(cfg.get("Architecture"), dict)

Prevention

When it happens

Trigger: Pointing the config reader at a training pipeline YAML (Global/Train/Eval sections only), a dataset config, or an unrelated YAML; a truncated/corrupted download.

Common situations: Mixing up files in the configs directory; editing a config and accidentally removing the Architecture block; YAML indentation errors that nest Architecture under another key.

Related errors


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