{"record":{"id":"f3288dbc881d8e95","repo":"PaddlePaddle/PaddleOCR","slug":"does-not-exist","errorCode":null,"errorMessage":"{} does not exist!","messagePattern":"(.+?) does not exist!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"ppocr/data/pgnet_dataset.py","lineNumber":90,"sourceCode":"\n    def __getitem__(self, idx):\n        file_idx = self.data_idx_order_list[idx]\n        data_line = self.data_lines[file_idx]\n        img_id = 0\n        try:\n            data_line = data_line.decode(\"utf-8\")\n            substr = data_line.strip(\"\\n\").split(self.delimiter)\n            file_name = substr[0]\n            label = substr[1]\n            img_path = os.path.join(self.data_dir, file_name)\n            if self.mode.lower() == \"eval\":\n                try:\n                    img_id = int(data_line.split(\".\")[0][7:])\n                except:\n                    img_id = 0\n            data = {\"img_path\": img_path, \"label\": label, \"img_id\": img_id}\n            if not os.path.exists(img_path):\n                raise Exception(\"{} does not exist!\".format(img_path))\n            with open(data[\"img_path\"], \"rb\") as f:\n                img = f.read()\n                data[\"image\"] = img\n            outs = transform(data, self.ops)\n        except Exception as e:\n            self.logger.error(\n                \"When parsing line {}, error happened with msg: {}\".format(\n                    self.data_idx_order_list[idx], e\n                )\n            )\n            outs = None\n        if outs is None:\n            return self.__getitem__(np.random.randint(self.__len__()))\n        return outs\n\n    def __len__(self):\n        return len(self.data_idx_order_list)\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/ppocr/data/pgnet_dataset.py#L72-L108","documentation":"PGNet (spotted text detection/recognition) dataset loading iterates label lines, joins data_dir with the filename from the label, and requires the resulting path to exist. A missing file raises Exception('{path} does not exist!'); the outer handler logs it and skips the sample (outs = None).","triggerScenarios":"A label line whose first field (before the delimiter) names an image that is not under data_dir: moved images, wrong data_dir, absolute-vs-relative mismatch, or a Windows/Windows-path label on Linux.","commonSituations":"Downloading only the label file without the images; unzipping that flattens the directory structure; data_dir typo in the yml; label file using backslashes.","solutions":["Spot-check paths: python -c 'import os; l=open(label).readline().split(\"\\t\")[0]; print(os.path.exists(os.path.join(data_dir, l)))'","Correct data_dir in the PGNet yml so joined paths resolve","Re-extract the image archive preserving directory structure, or rewrite the label file to match the actual layout","Normalize separators in label files: line.replace('\\\\', '/') before use"],"exampleFix":"# before (config)\ndata_dir: ./train_data/pgnet\nlabel_file_list: ./train_data/labels.txt\n# after (match actual layout)\ndata_dir: ./train_data/pgnet/train_images\nlabel_file_list: ./train_data/pgnet/train_labels.txt","handlingStrategy":"validation","validationCode":"import os\nwith open(label_file, encoding='utf-8') as f:\n    for k, line in enumerate(f):\n        name = line.strip('\\r\\n').split(delimiter)[0]\n        p = name if name.startswith('http') else os.path.join(data_dir, name)\n        if not p.startswith('http') and not os.path.exists(p):\n            raise SystemExit(f'line {k}: {p} does not exist')","typeGuard":null,"tryCatchPattern":"try:\n    out = dataset[idx]\nexcept Exception:\n    out = None  # dataset already logs and skips; count skips and abort if too many","preventionTips":["Lint label files against data_dir before training","Normalize path separators and strip CRLF from label files","Count skipped samples after epoch 0; a high skip rate means a path/layout bug"],"tags":["dataset","file-not-found","config","pgnet"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}