#1903·YOLOX

VOCDetection crashes with IndexError: list index out of range on Windows

Author: HikeAndMapCreated Aug 29, 2026Updated Aug 29, 2026

Description

VOCDetection.__init__ in yolox/data/datasets/voc.py raises IndexError: list index out of range on Windows, for any dataset and any exp config.

Root cause

python
self._imgpath = os.path.join("%s", "JPEGImages", "%s.jpg")
...
path_filename = [
    (self._imgpath % self.ids[i]).split(self.root + "/")[1]
    for i in range(self.num_imgs)
]

os.path.join produces backslash-separated paths on Windows (e.g. C:\data\VOC2007\JPEGImages\000001.jpg), but the split delimiter is hardcoded as self.root + "/" (forward slash). Since a forward slash never appears in a Windows path, .split(...) returns a single-element list, and indexing [1] raises IndexError. This executes unconditionally in __init__, independent of cache, image_sets, or dataset contents.

Environment

  • OS: Windows 11
  • YOLOX: installed via pip install -e . from a fresh clone of main
  • Reproduced via a custom exp whose get_dataset/get_eval_dataset return a VOCDetection

Steps to reproduce

  1. On Windows, run tools/train.py (or otherwise instantiate VOCDetection) with any VOC-format dataset.
  2. Traceback:
File ".../yolox/data/datasets/voc.py", line 138, in __init__
    (self._imgpath % self.ids[i]).split(self.root + "/")[1]
IndexError: list index out of range

Suggested fix

Use os.sep instead of a hardcoded "/", so the delimiter matches whatever separator os.path.join actually produced:

python
path_filename = [
    (self._imgpath % self.ids[i]).split(self.root + os.sep)[1]
    for i in range(self.num_imgs)
]

Verified this one-line change resolves the crash and loads the dataset correctly (tested with 742 images).

Source: Megvii-BaseDetection/YOLOX