{"record":{"id":"ce04083be356d055","repo":"WZMIAOMIAO/deep-learning-for-image-processing","slug":"unsupported-fields-in-cfg","errorCode":null,"errorMessage":"Unsupported fields:{} in cfg","messagePattern":"Unsupported fields:(.+?) in cfg","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pytorch_object_detection/yolov3_spp/build_utils/parse_config.py","lineNumber":56,"sourceCode":"            else:\n                # TODO: .isnumeric() actually fails to get the float case\n                if val.isnumeric():  # return int or float 如果是数值的情况\n                    mdefs[-1][key] = int(val) if (int(val) - float(val)) == 0 else float(val)\n                else:\n                    mdefs[-1][key] = val  # return string  是字符的情况\n\n    # check all fields are supported\n    supported = ['type', 'batch_normalize', 'filters', 'size', 'stride', 'pad', 'activation', 'layers', 'groups',\n                 'from', 'mask', 'anchors', 'classes', 'num', 'jitter', 'ignore_thresh', 'truth_thresh', 'random',\n                 'stride_x', 'stride_y', 'weights_type', 'weights_normalization', 'scale_x_y', 'beta_nms', 'nms_kind',\n                 'iou_loss', 'iou_normalizer', 'cls_normalizer', 'iou_thresh', 'probability']\n\n    # 遍历检查每个模型的配置\n    for x in mdefs[1:]:  # 0对应net配置\n        # 遍历每个配置字典中的key值\n        for k in x:\n            if k not in supported:\n                raise ValueError(\"Unsupported fields:{} in cfg\".format(k))\n\n    return mdefs\n\n\ndef parse_data_cfg(path):\n    # Parses the data configuration file\n    if not os.path.exists(path) and os.path.exists('data' + os.sep + path):  # add data/ prefix if omitted\n        path = 'data' + os.sep + path\n\n    with open(path, 'r') as f:\n        lines = f.readlines()\n\n    options = dict()\n    for line in lines:\n        line = line.strip()\n        if line == '' or line.startswith('#'):\n            continue\n        key, val = line.split('=')","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/WZMIAOMIAO/deep-learning-for-image-processing/blob/1ec3fe6f374fc9969973a61f819de25658595afa/pytorch_object_detection/yolov3_spp/build_utils/parse_config.py#L38-L74","documentation":"After parsing the .cfg into a list of dicts, parse_model_cfg checks every key in every module definition against a whitelist of supported fields. An unknown key (often a typo or a field from a newer/older YOLO cfg dialect) raises ValueError('Unsupported fields:{} in cfg').","triggerScenarios":"A [convolutional], [net], [yolo], [route], etc. block in the .cfg contains a key not in the supported set, e.g. misspelled 'batch_normalize' instead of 'batch_normalizing' variant, 'channels_out', or fields like 'groups'/'width_multiple' from other YOLO versions.","commonSituations":"Using a cfg copied from another YOLO repo (e.g. AlexeyAB/darknet cfgs with extra fields); hand-editing the cfg and typo-ing a key; upgrading the repo but keeping old cfgs.","solutions":["Open the cfg at the reported key's block and remove or rename the unsupported field to one the parser supports","Compare against the repo's bundled cfg files (cfg/yolov3-spp.cfg) and align your cfg with that dialect","Update parse_config.py's supported set if you intentionally need the new field"],"exampleFix":"// before (in .cfg)\n[convolutional]\nbatch_normalize=1\nsize=3\nchannels_out=128\n// after (in .cfg)\n[convolutional]\nbatch_normalize=1\nsize=3\nfilters=128","handlingStrategy":"validation","validationCode":"supported = {'net','convolutional','maxpool','route','upsample','shortcut','yolo'}\nimport re\nfor block in re.findall(r'\\[([^\\]]+)\\]', open(cfg).read()):\n    assert block.strip() in supported, f'unsupported block [{block}] in {cfg}'","typeGuard":null,"tryCatchPattern":"try:\n    mdefs = parse_model_cfg(cfg)\nexcept ValueError as e:\n    if 'Unsupported fields' in str(e):\n        bad_key = e.args[0].split(':')[1].strip()\n        raise SystemExit(f'{cfg}: remove/rename unsupported key {bad_key}')\n    raise","preventionTips":["Start from the repo's bundled cfg and edit incrementally","Diff custom cfgs against the stock yolov3-spp.cfg before training","Check parse_config.py's supported set when adopting cfgs from other darknet forks"],"tags":["python","yolo","config","validation"],"backgroundTag":"unsupported-config-field","analyzedSha":"1ec3fe6f374fc9969973a61f819de25658595afa","analyzedAt":"2026-08-30T09:19:11.901Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}