{"record":{"id":"bd996d555e90c90b","repo":"WZMIAOMIAO/deep-learning-for-image-processing","slug":"not-in-download-links","errorCode":null,"errorMessage":"{} not in download_links","messagePattern":"(.+?) not in download_links","errorType":"validation","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"pytorch_classification/Test10_regnet/pretrain_weights.py","lineNumber":37,"sourceCode":"    \"regnety_600mf\": 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-regnet/regnety_006-c67e57ec.pth',\n    \"regnety_800mf\": 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-regnet/regnety_008-dc900dbe.pth',\n    \"regnety_1.6gf\": 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-regnet/regnety_016-54367f74.pth',\n    \"regnety_3.2gf\": 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/regnety_032_ra-7f2439f9.pth',\n    \"regnety_4.0gf\": 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-regnet/regnety_040-f0d569f9.pth',\n    \"regnety_6.4gf\": 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-regnet/regnety_064-0a48325c.pth',\n    \"regnety_8.0gf\": 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-regnet/regnety_080-e7f3eb93.pth',\n    \"regnety_12gf\": 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-regnet/regnety_120-721ba79a.pth',\n    \"regnety_16gf\": 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-regnet/regnety_160-d64013cd.pth',\n    \"regnety_32gf\": 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-regnet/regnety_320-ba464b29.pth',\n}\n\n\ndef main():\n    model_name = \"regnetx_400mf\"\n    print(\"download weights name: \" + model_name)\n\n    if model_name not in download_links.keys():\n        raise KeyError(\"{} not in download_links\".format(model_name))\n\n    headers = {\"Content-Type\": \"application/json\",\n               \"Connection\": \"close\",\n               \"User-Agent\": \"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0\"}\n\n    save_weights = \"./\" + model_name + \".pth\"\n\n    req = requests.get(url=download_links[model_name],\n                       stream=True, headers=headers, timeout=10)\n    req.raise_for_status()\n    info = int(req.headers[\"Content-Length\"])\n\n    accumulate_data = 0\n    with open(save_weights, \"wb\") as f:\n        for data in req.iter_content(2048):\n            f.write(data)\n            accumulate_data += 2048\n            print(\"\\rdownload: [{}Mb/{}Mb] {}%\".format(int(accumulate_data / 1024 / 1024),","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/WZMIAOMIAO/deep-learning-for-image-processing/blob/1ec3fe6f374fc9969973a61f819de25658595afa/pytorch_classification/Test10_regnet/pretrain_weights.py#L19-L55","documentation":"The download script hardcodes model_name='regnetx_400mf' and checks it against the download_links dict, raising KeyError if the name has no entry. This prevents attempting an HTTP request with an unknown URL.","triggerScenarios":"Running pretrain_weights.py after editing model_name to a value missing from download_links (e.g. 'regnetx_4_0gf'), or after download_links was trimmed.","commonSituations":"Users changing the hardcoded name to the variant they actually train, but no link was added for it.","solutions":["Set model_name to a key that exists in download_links (print download_links.keys() to inspect).","Add a URL entry to download_links for the desired model.","Use the name shown in the KeyError message guidance / supported training script defaults."],"exampleFix":"// before\nmodel_name = \"regnetx_4_0gf\"\n// after\nmodel_name = \"regnetx_400mf\"  # exists in download_links","handlingStrategy":"validation","validationCode":"from pretrain_weights import download_links\nname = \"regnetx_400mf\"\nif name not in download_links:\n    raise SystemExit(f\"{name} not available; choose from {sorted(download_links)}\")","typeGuard":"def is_downloadable(name: str) -> bool:\n    from pretrain_weights import download_links\n    return name in download_links","tryCatchPattern":"try:\n    main()\nexcept KeyError as e:\n    print(f\"Unknown weights name {e}. Available: {sorted(download_links.keys())}\")","preventionTips":["Only use names present in download_links","Print download_links.keys() before editing model_name","Add new URLs to download_links when introducing new variants"],"tags":["pytorch","weights-download","keyerror","script-config"],"backgroundTag":"invalid-model-name","analyzedSha":"1ec3fe6f374fc9969973a61f819de25658595afa","analyzedAt":"2026-08-30T09:19:11.901Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}