{"record":{"id":"d2b3c99167a1eef6","repo":"PaddlePaddle/PaddleOCR","slug":"the-file-label-dir-does-not-exist","errorCode":null,"errorMessage":"The file {label_dir} does not exist!","messagePattern":"The file (.+?) does not exist!","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/end2end/convert_ppocr_label.py","lineNumber":29,"sourceCode":"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport numpy as np\nimport json\nimport os\n\n\ndef poly_to_string(poly):\n    if len(poly.shape) > 1:\n        poly = np.array(poly).flatten()\n\n    string = \"\\t\".join(str(i) for i in poly)\n    return string\n\n\ndef convert_label(label_dir, mode=\"gt\", save_dir=\"./save_results/\"):\n    if not os.path.exists(label_dir):\n        raise ValueError(f\"The file {label_dir} does not exist!\")\n\n    assert label_dir != save_dir, \"hahahhaha\"\n\n    label_file = open(label_dir, \"r\")\n    data = label_file.readlines()\n\n    gt_dict = {}\n\n    for line in data:\n        try:\n            tmp = line.split(\"\\t\")\n            assert len(tmp) == 2, \"\"\n        except:\n            tmp = line.strip().split(\"    \")\n\n        gt_lists = []\n\n        if tmp[0].split(\"/\")[0] is not None:","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/tools/end2end/convert_ppocr_label.py#L11-L47","documentation":"convert_label in tools/end2end/convert_ppocr_label.py validates that the given label file path exists before opening it, and raises ValueError otherwise. It is a plain pre-flight filesystem check (the function would otherwise fail with a less clear FileNotFoundError). Note it is called with a file path despite the parameter name label_dir. The subsequent assert label_dir != save_dir is a separate guard against overwriting outputs.","triggerScenarios":"Running tools/end2end/convert_ppocr_label.py with a --label_path pointing at a nonexistent file (typo, wrong directory, or labels not yet generated by the end2end evaluation).","commonSituations":"After running end2end eval, the predicted-label file lands in a different directory than passed on the command line; CI running from a different working directory with relative paths; typo in the filename.","solutions":["Check the path exists before running: ls <label_path>, fix typos or use an absolute path","If labels come from predict_system/evaluation output, run that step first so the file is produced","Run from the repo root or pass absolute paths so relative resolution is deterministic"],"exampleFix":"# before\npython tools/end2end/convert_ppocr_label.py --label_path=./out/label.txt\n# ValueError: The file ./out/label.txt does not exist!\n\n# after\npython tools/end2end/convert_ppocr_label.py --label_path=$(pwd)/out/word_1.txt/label.txt","handlingStrategy":"validation","validationCode":"import os\nif not os.path.isfile(label_path):\n    raise SystemExit(f'label file missing: {label_path} — run the prediction step first')","typeGuard":null,"tryCatchPattern":"try:\n    convert_label(label_dir=label_path, mode='gt', save_dir=out_dir)\nexcept ValueError as e:\n    if 'does not exist' in str(e):\n        # regenerate labels or fix the path, then retry once\n        ...\n    raise","preventionTips":["Pass absolute paths to conversion scripts","Assert expected outputs exist between pipeline stages instead of assuming earlier steps succeeded"],"tags":["cli","file-not-found","labels","end2end"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}