WZMIAOMIAO/deep-learning-for-image-processing · error · FileNotFoundError

VOCdevkit dose not in path:'{}'.

Error message

VOCdevkit dose not in path:'{}'.

What it means

Raised as FileNotFoundError in the multi-GPU RetinaNet training entry point when args.data_path does not contain a 'VOCdevkit' subdirectory. The script checks the VOC dataset root up-front before building datasets, since VOCDataSet expects VOC_root/VOCdevkit/VOC2012/... layout. It is a data-path configuration error, not a code bug.

Source

Thrown at pytorch_object_detection/retinaNet/train_multi_GPU.py:60

    device = torch.device(args.device)

    # 用来保存coco_info的文件
    results_file = "results{}.txt".format(datetime.datetime.now().strftime("%Y%m%d-%H%M%S"))

    # Data loading code
    print("Loading data")

    data_transform = {
        "train": transforms.Compose([transforms.ToTensor(),
                                     transforms.RandomHorizontalFlip(0.5)]),
        "val": transforms.Compose([transforms.ToTensor()])
    }

    VOC_root = args.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))

    # load train data set
    # VOCdevkit -> VOC2012 -> ImageSets -> Main -> train.txt
    train_dataset = VOCDataSet(VOC_root, "2012", data_transform["train"], "train.txt")

    # load validation data set
    # VOCdevkit -> VOC2012 -> ImageSets -> Main -> val.txt
    val_dataset = VOCDataSet(VOC_root, "2012", data_transform["val"], "val.txt")

    print("Creating data loaders")
    if args.distributed:
        train_sampler = torch.utils.data.distributed.DistributedSampler(train_dataset)
        test_sampler = torch.utils.data.distributed.DistributedSampler(val_dataset)
    else:
        train_sampler = torch.utils.data.RandomSampler(train_dataset)
        test_sampler = torch.utils.data.SequentialSampler(val_dataset)

    if args.aspect_ratio_group_factor >= 0:

View on GitHub (pinned to 1ec3fe6f37)

Solutions

  1. Verify the directory layout: args.data_path must be the parent folder containing VOCdevkit/ (i.e. data_path/VOCdevkit/VOC2012 exists)
  2. Extract the VOC2012 dataset (e.g. tar -xvf VOCtrainval_11-May-2012.tar) into the given data-path
  3. Pass an absolute path to --data-path to avoid working-directory issues
  4. ls the path given in the message to confirm it exists and contains VOCdevkit

Example fix

// before
python train_multi_GPU.py --data-path ./VOCdevkit
// after
python train_multi_GPU.py --data-path /data/VOC  # contains /data/VOC/VOCdevkit/VOC2012
Defensive patterns

Strategy: validation

Validate before calling

import os
data_path = args.data_path
assert os.path.isdir(os.path.join(data_path, 'VOCdevkit', 'VOC2012')), f'VOC2012 not under {data_path}'

Type guard

def has_vocdevkit(root: str) -> bool:
    return os.path.isdir(os.path.join(root, 'VOCdevkit'))

Try / catch

try:
    main(args)
except FileNotFoundError as e:
    print(f'Dataset root misconfigured: {e}. Fix --data-path to contain VOCdevkit/.')

Prevention

When it happens

Trigger: Running train_multi_GPU.py with --data-path pointing to a directory that does not exist, points to the VOCdevkit folder itself (one level too deep), or points to a parent that lacks the VOCdevkit extraction of the VOC2012 dataset.

Common situations: Downloaded the VOC2012 tar but extracted it elsewhere or renamed it; passing a relative path from a different working directory; passing the path to VOCdevkit instead of its parent; forgetting to download the dataset on a training server.

Related errors


AI-assisted analysis of WZMIAOMIAO/deep-learning-for-image-processing@1ec3fe6f37 (2026-08-30). Data as JSON: /api/errors/5ae19df590c5bde4. Report an issue: GitHub.