{"record":{"id":"c0ab80745c86839a","repo":"WZMIAOMIAO/deep-learning-for-image-processing","slug":"vocdevkit-dose-not-in-path-c0ab80","errorCode":null,"errorMessage":"VOCdevkit dose not in path:'{}'.","messagePattern":"VOCdevkit dose not in path:'(.+?)'\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"pytorch_object_detection/retinaNet/validation.py","lineNumber":111,"sourceCode":"    device = torch.device(parser_data.device if torch.cuda.is_available() else \"cpu\")\n    print(\"Using {} device training.\".format(device.type))\n\n    data_transform = {\n        \"val\": transforms.Compose([transforms.ToTensor()])\n    }\n\n    # read class_indict\n    label_json_path = './pascal_voc_classes.json'\n    assert os.path.exists(label_json_path), \"json file {} dose not exist.\".format(label_json_path)\n    with open(label_json_path, 'r') as f:\n        class_dict = json.load(f)\n\n    category_index = {v: k for k, v in class_dict.items()}\n\n    VOC_root = parser_data.data_path\n    # check voc root\n    if os.path.exists(os.path.join(VOC_root, \"VOCdevkit\")) is False:\n        raise FileNotFoundError(\"VOCdevkit dose not in path:'{}'.\".format(VOC_root))\n\n    # 注意这里的collate_fn是自定义的，因为读取的数据包括image和targets，不能直接使用默认的方法合成batch\n    batch_size = parser_data.batch_size\n    nw = min([os.cpu_count(), batch_size if batch_size > 1 else 0, 8])  # number of workers\n    print('Using %g dataloader workers' % nw)\n\n    # load validation data set\n    val_dataset = VOCDataSet(VOC_root, \"2012\", data_transform[\"val\"], \"val.txt\")\n    val_dataset_loader = torch.utils.data.DataLoader(val_dataset,\n                                                     batch_size=batch_size,\n                                                     shuffle=False,\n                                                     num_workers=nw,\n                                                     pin_memory=True,\n                                                     collate_fn=val_dataset.collate_fn)\n\n    # create model\n    # 注意，这里的norm_layer要和训练脚本中保持一致\n    backbone = resnet50_fpn_backbone(norm_layer=torch.nn.BatchNorm2d,","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/WZMIAOMIAO/deep-learning-for-image-processing/blob/1ec3fe6f374fc9969973a61f819de25658595afa/pytorch_object_detection/retinaNet/validation.py#L93-L129","documentation":"Same FileNotFoundError check as training (index 100), raised in validation.py main(): the --data-path given to validation must contain VOCdevkit. Validation loads VOCDataSet with images and annotations from VOC_root/VOCdevkit/VOC2012, so an absent VOCdevkit aborts before any inference.","triggerScenarios":"Running validation.py with --data-path pointing to a nonexistent folder, to VOCdevkit itself (one level too deep), or to a machine that lacks the extracted VOC2012 dataset.","commonSituations":"Validating on a different server than training without copying the dataset; changing --data-path to a test placeholder; renaming VOCdevkit directory.","solutions":["Point --data-path at the parent directory of VOCdevkit (data_path/VOCdevkit/VOC2012 must exist)","Extract/restore the VOC2012 dataset at the specified path","Use an absolute path to avoid cwd-dependent relative path mistakes"],"exampleFix":"// before\npython validation.py --data-path ./my_dataset\n// after\npython validation.py --data-path /data/VOC  # /data/VOC/VOCdevkit/VOC2012 present","handlingStrategy":"validation","validationCode":"import os\nroot = parser_data.data_path\nif not os.path.isdir(os.path.join(root, 'VOCdevkit')):\n    raise SystemExit(f'--data-path must contain VOCdevkit/, got {root}')","typeGuard":"def has_vocdevkit(root: str) -> bool:\n    return os.path.isdir(os.path.join(root, 'VOCdevkit'))","tryCatchPattern":"try:\n    main(parser_data)\nexcept FileNotFoundError as e:\n    print(f'Dataset root missing: {e}')","preventionTips":["Mount/copy the same dataset layout used in training to the validation machine","Check dataset existence in shell before running python","Use the same --data-path value as training"],"tags":["filesystem","dataset","validation","config"],"backgroundTag":"dataset-root-path-missing","analyzedSha":"1ec3fe6f374fc9969973a61f819de25658595afa","analyzedAt":"2026-08-30T09:19:11.901Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}