VOCDetection crashes with IndexError: list index out of range on Windows
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
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 ofmain - Reproduced via a custom exp whose
get_dataset/get_eval_datasetreturn aVOCDetection
Steps to reproduce
- On Windows, run
tools/train.py(or otherwise instantiateVOCDetection) with any VOC-format dataset. - 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 rangeSuggested fix
Use os.sep instead of a hardcoded "/", so the delimiter matches whatever separator os.path.join actually produced:
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