opendatalab/MinerU · error · Exception

Language {lang} not supported

Error message

Language {lang} not supported

What it means

get_model_params looks up the requested language in the OCR config's 'lang' table to fetch det/rec model names and dictionary path. If lang is not a key, it raises a plain Exception with the language name — there is no fallback language.

Source

Thrown at mineru/model/ocr/pytorch_paddle.py:39

    sorted_boxes,
    merge_det_boxes,
    update_det_boxes,
    get_rotate_crop_image_for_text_rec,
)
from mineru.model.utils.tools.infer.predict_system import TextSystem
from mineru.model.utils.tools.infer import pytorchocr_utility as utility
import argparse


def get_model_params(lang, config):
    if lang in config['lang']:
        params = config['lang'][lang]
        det = params.get('det')
        rec = params.get('rec')
        dict_file = params.get('dict')
        return det, rec, dict_file
    else:
        raise Exception (f'Language {lang} not supported')


root_dir = os.path.join(Path(__file__).resolve().parent.parent, 'utils')
DEFAULT_SEAL_DEBUG_DIR = os.path.join(
    Path(__file__).resolve().parents[3],
    'output_images',
    'seal_ocr_debug',
)


class PytorchPaddleOCR(TextSystem):
    def __init__(self, *args, **kwargs):
        parser = utility.init_args()
        args = parser.parse_args(args)

        requested_lang = kwargs.get('lang', 'ch')
        self.lang = requested_lang
        self.is_seal = requested_lang in ['seal', 'seal_lite']

View on GitHub (pinned to 4fe4bde114)

Solutions

  1. Use the exact key from the config (inspect config['lang'].keys(), commonly 'ch', 'en', 'japan', 'korean', ...).
  2. Fall back to 'ch' or 'en' if the language is unsupported but Latin/CJK-adjacent.
  3. Add the language to the config with det/rec/dict entries copied from upstream PaddleOCR's config.

Example fix

# before
ocr = PytorchPaddleOCR(lang='french')

# after
ocr = PytorchPaddleOCR(lang='fr')  # exact key from config['lang']
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED = set(config['lang'].keys())
if lang not in SUPPORTED:
    lang = 'ch' if 'ch' in SUPPORTED else next(iter(SUPPORTED))
    logger.warning('lang %s unsupported, falling back to %s', lang, lang)

Type guard

def is_supported_lang(lang: str, config) -> bool:
    return lang in config.get('lang', {})

Try / catch

try:
    det, rec, dic = get_model_params(lang, config)
except Exception as e:
    if 'not supported' in str(e):
        det, rec, dic = get_model_params('ch', config)  # explicit fallback
    else:
        raise

Prevention

When it happens

Trigger: Calling PytorchPaddleOCR/model-param resolution with lang='fr', 'german', 'zh-Hans', or any string not matching a config key exactly; keys are case-sensitive and typically like 'ch', 'en', 'japan'.

Common situations: Passing full locale names or ISO codes instead of the paddle-style short codes, typos, or using a language supported by upstream PaddleOCR but missing from this repo's trimmed config.

Related errors


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