WZMIAOMIAO/deep-learning-for-image-processing · error · FileNotFoundError
VOCdevkit dose not in path:'{}'.
Error message
VOCdevkit dose not in path:'{}'. What it means
validation.py checks that `<parser_data.data_path>/VOCdevkit` exists before building the validation DataLoader; otherwise it raises FileNotFoundError. It prevents evaluation against a missing dataset.
Source
Thrown at pytorch_object_detection/faster_rcnn/validation.py:111
device = torch.device(parser_data.device if torch.cuda.is_available() else "cpu")
print("Using {} device training.".format(device.type))
data_transform = {
"val": transforms.Compose([transforms.ToTensor()])
}
# read class_indict
label_json_path = './pascal_voc_classes.json'
assert os.path.exists(label_json_path), "json file {} dose not exist.".format(label_json_path)
with open(label_json_path, 'r') as f:
class_dict = json.load(f)
category_index = {v: k for k, v in class_dict.items()}
VOC_root = parser_data.data_path
# check voc root
if os.path.exists(os.path.join(VOC_root, "VOCdevkit")) is False:
raise FileNotFoundError("VOCdevkit dose not in path:'{}'.".format(VOC_root))
# 注意这里的collate_fn是自定义的,因为读取的数据包括image和targets,不能直接使用默认的方法合成batch
batch_size = parser_data.batch_size
nw = min([os.cpu_count(), batch_size if batch_size > 1 else 0, 8]) # number of workers
print('Using %g dataloader workers' % nw)
# load validation data set
val_dataset = VOCDataSet(VOC_root, "2012", data_transform["val"], "val.txt")
val_dataset_loader = torch.utils.data.DataLoader(val_dataset,
batch_size=1,
shuffle=False,
num_workers=nw,
pin_memory=True,
collate_fn=val_dataset.collate_fn)
# create model num_classes equal background + 20 classes
# 注意,这里的norm_layer要和训练脚本中保持一致
backbone = resnet50_fpn_backbone(norm_layer=torch.nn.BatchNorm2d)View on GitHub (pinned to 1ec3fe6f37)
Solutions
- Extract the VOC2012 dataset so `<data_path>/VOCdevkit` exists
- Pass the parent directory containing VOCdevkit as --data-path
- Verify VOCdevkit/VOC2012/ImageSets/Main (and Annotations) exist under the given path
Example fix
# before python validation.py --data-path ./data/VOCdevkit # after python validation.py --data-path ./data # ./data/VOCdevkit exists
Defensive patterns
Strategy: validation
Validate before calling
import os
data_path = parser_data.data_path
if not os.path.exists(os.path.join(data_path, "VOCdevkit")):
raise SystemExit(f"VOCdevkit not found under {data_path}") Try / catch
try:
run_validation(parser_data)
except FileNotFoundError as e:
if "VOCdevkit" in str(e):
print(f"Dataset missing at {parser_data.data_path}; extract VOC2012 first.")
sys.exit(1) Prevention
- Extract VOC2012 under the given data_path before validating
- Pass the parent directory of VOCdevkit as --data-path
- Verify the dataset layout (VOCdevkit/VOC2012/ImageSets/Main) in a pre-flight check
When it happens
Trigger: Running validation.py with --data-path pointing to a directory without the VOCdevkit subfolder, or pointing at VOCdevkit itself instead of its parent.
Common situations: Dataset not extracted on the eval machine; wrong --data-path value copied from another script; relative path resolved from unexpected working directory.
Related errors
- VOCdevkit dose not in path:'{}'.
- VOCdevkit dose not in path:'{}'.
- VOCdevkit dose not in path:'{}'.
- image: {} isn't RGB mode.
- dataset have {} classes, but input {}
AI-assisted analysis of WZMIAOMIAO/deep-learning-for-image-processing@1ec3fe6f37 (2026-08-30).
Data as JSON: /api/errors/e638a4134bc37975.
Report an issue: GitHub.