{"record":{"id":"373bb0c9cab2afd1","repo":"WZMIAOMIAO/deep-learning-for-image-processing","slug":"s-does-not-exist","errorCode":null,"errorMessage":"%s does not exist","messagePattern":"(.+?) does not exist","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"pytorch_object_detection/yolov3_spp/build_utils/datasets.py","lineNumber":71,"sourceCode":"                 # 当为训练集时，设置的是训练过程中(开启多尺度)的最大尺寸\n                 # 当为验证集时，设置的是最终使用的网络大小\n                 img_size=416,\n                 batch_size=16,\n                 augment=False,  # 训练集设置为True(augment_hsv)，验证集设置为False\n                 hyp=None,  # 超参数字典，其中包含图像增强会使用到的超参数\n                 rect=False,  # 是否使用rectangular training\n                 cache_images=False,  # 是否缓存图片到内存中\n                 single_cls=False, pad=0.0, rank=-1):\n\n        try:\n            path = str(Path(path))\n            # parent = str(Path(path).parent) + os.sep\n            if os.path.isfile(path):  # file\n                # 读取对应my_train/val_data.txt文件，读取每一行的图片路劲信息\n                with open(path, \"r\") as f:\n                    f = f.read().splitlines()\n            else:\n                raise Exception(\"%s does not exist\" % path)\n\n            # 检查每张图片后缀格式是否在支持的列表中，保存支持的图像路径\n            # img_formats = ['.bmp', '.jpg', '.jpeg', '.png', '.tif', '.dng']\n            self.img_files = [x for x in f if os.path.splitext(x)[-1].lower() in img_formats]\n            self.img_files.sort()  # 防止不同系统排序不同，导致shape文件出现差异\n        except Exception as e:\n            raise FileNotFoundError(\"Error loading data from {}. {}\".format(path, e))\n\n        # 如果图片列表中没有图片，则报错\n        n = len(self.img_files)\n        assert n > 0, \"No images found in %s. See %s\" % (path, help_url)\n\n        # batch index\n        # 将数据划分到一个个batch中\n        bi = np.floor(np.arange(n) / batch_size).astype(np.int)\n        # 记录数据集划分后的总batch数\n        nb = bi[-1] + 1  # number of batches\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/WZMIAOMIAO/deep-learning-for-image-processing/blob/1ec3fe6f374fc9969973a61f819de25658595afa/pytorch_object_detection/yolov3_spp/build_utils/datasets.py#L53-L89","documentation":"YOLOv3 LoadImagesAndLabels __init__ reads a text file of image paths; if os.path.isfile(path) is False it raises Exception('%s does not exist' % path). The path given for train/val data listing does not point to an existing file.","triggerScenarios":"Instantiating LoadImagesAndLabels with a path to my_train.txt / my_val.txt that does not exist on disk (typo, wrong working directory, file never generated).","commonSituations":"Forgetting to run the split-data script that writes the .txt listing; relative path resolved from a different CWD when training from another directory; path points to a directory instead of a file.","solutions":["Generate the data listing .txt file (split_data.py) before training","Use an absolute path or verify path exists with os.path.isfile(path)","Run the training command from the project root so relative paths resolve correctly"],"exampleFix":"// before\nparser.add_argument('--data-txt', default='data/my_train.txt')\n// after\nimport os\ntxt = 'data/my_train.txt'\nassert os.path.isfile(txt), f'{txt} not found - run split_data.py first'\nparser.add_argument('--data-txt', default=txt)","handlingStrategy":"validation","validationCode":"import os\ntxt = args.data_txt\nif not os.path.isfile(txt):\n    raise FileNotFoundError(f'{txt} missing; generate it with split_data.py')","typeGuard":null,"tryCatchPattern":"try:\n    dataset = LoadImagesAndLabels(txt, img_size=img_size)\nexcept Exception as e:\n    if 'does not exist' in str(e):\n        raise FileNotFoundError(f'Generate the data listing first: {txt}') from e\n    raise","preventionTips":["Generate my_train.txt / my_val.txt via split_data.py before training","Use absolute paths for data listings","Run training from the project root so relative paths resolve"],"tags":["python","file-not-found","yolo","dataset"],"backgroundTag":"file-not-found","analyzedSha":"1ec3fe6f374fc9969973a61f819de25658595afa","analyzedAt":"2026-08-30T09:19:11.901Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}