opendatalab/MinerU · error · ValueError
architecture {file_name} is not in arch_config.yaml
Error message
architecture {file_name} is not in arch_config.yaml What it means
Raised by get_arch_config when the stem (filename without extension) of the model path is not a key in arch_config.yaml (loaded from DEFAULT_CFG_PATH). This mapping is how the inference utility knows which network architecture corresponds to a given weights file.
Source
Thrown at mineru/model/utils/tools/infer/pytorchocr_utility.py:230
return s_len - math.ceil(en_dg_count / 2)
def base64_to_cv2(b64str):
import base64
data = base64.b64decode(b64str.encode('utf8'))
data = np.fromstring(data, np.uint8)
data = cv2.imdecode(data, cv2.IMREAD_COLOR)
return data
def get_arch_config(model_path):
import yaml
with open(DEFAULT_CFG_PATH, encoding='utf-8') as f:
all_arch_config = yaml.safe_load(f)
path = Path(model_path)
file_name = path.stem
if file_name not in all_arch_config:
raise ValueError(f"architecture {file_name} is not in arch_config.yaml")
arch_config = all_arch_config[file_name]
return arch_config
View on GitHub (pinned to 4fe4bde114)
Solutions
- Restore the original weights filename so its stem matches a known architecture name.
- Pass yaml_path explicitly to AnalysisConfig so arch inference from the filename is skipped.
- Update mineru so the bundled arch_config.yaml matches your models version.
Example fix
# before
get_arch_config("/models/my_renamed_rec.pth")
# after
# keep the official filename, or bypass filename inference:
AnalysisConfig(weights_path="/models/my_renamed_rec.pth", yaml_path="/models/rec_config.yml") Defensive patterns
Strategy: fallback
Validate before calling
import yaml
from pathlib import Path
with open(DEFAULT_CFG_PATH, encoding="utf-8") as f:
known = yaml.safe_load(f)
if Path(model_path).stem not in known:
# fall back to explicit config instead of filename inference
return AnalysisConfig(model_path, yaml_path=explicit_yaml) Try / catch
try:
arch = get_arch_config(model_path)
except ValueError:
arch = read_network_config_from_yaml(explicit_yaml_path) Prevention
- Never rename downloaded weights files
- Pass yaml_path explicitly when using custom or renamed weights
- Keep the mineru version in sync with the models bundle
When it happens
Trigger: Renaming a weights file (e.g. my_model.pth) so it no longer matches known names like ch_PP-OCRv4_rec_infer; using custom/foreign weights whose name is absent from the bundled arch_config.yaml; passing a path with an unexpected extension so path.stem differs.
Common situations: Users renaming downloaded models; side-loading third-party OCR weights; version mismatch between the weights bundle and the arch_config.yaml shipped with the installed mineru version.
Related errors
- {} is not existed.
- Unsupported activation: {name}
- PPLCNetV4 only supports 3 input channels, got {in_channels}.
- PPLCNetV4 {mode} model_size must be one of {list(config_dict
- {} has no Architecture
AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14).
Data as JSON: /api/errors/42cbb342c248376c.
Report an issue: GitHub.