You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TensorFlow自定义目标检测报错:文件不存在及自制数据集失效求助

Hey there, let's dig into why your custom dataset is throwing that "No such file or directory" error. I’ve worked with this repo and TensorFlow 1.x before, so here are the most likely fixes to try:

1. Double-check file paths (Windows loves to mess with these!)

Windows uses backslashes (\) but TensorFlow/Python often expects forward slashes (/). Even if you mirrored the sample structure, verify:

  • All paths in train.txt, test.txt, and config files (like pipeline.config) use forward slashes. For example, replace C:\Users\You\Custom-Object-Detection\images\train\img1.jpg with C:/Users/You/Custom-Object-Detection/images/train/img1.jpg.
  • Avoid spaces or special characters in paths/filenames. Rename files like my image.jpg to my_image.jpg—Python/TensorFlow can choke on unescaped spaces.
  • Confirm every path listed in train.txt and test.txt actually exists. A tiny typo (e.g., img001.jpg vs img01.jpg) will trigger this error. You can quickly validate paths with a short Python script that loops through each line and checks os.path.exists().
2. Match the dataset directory structure exactly to the sample

The repo relies on a strict folder layout. Make yours looks like this:

Custom-Object-Detection/
├─ images/
│  ├─ train/
│  │  ├─ Your training images
│  │  └─ Corresponding .xml annotations (from LabelImg)
│  └─ test/
│     ├─ Your test images
│     └─ Corresponding .xml annotations
├─ annotations/
│  ├─ train_labels.csv
│  ├─ test_labels.csv
│  └─ label_map.pbtxt
└─ ... other repo files
  • Did you run xml_to_csv.py to generate the CSV files? This step converts your LabelImg annotations into the format the model expects—skip it, and the pipeline won’t find valid labels.
  • Ensure label_map.pbtxt matches the sample format exactly. For a class named dog, it should look like:
    item {
      id: 1
      name: 'dog'
    }
    
    Double-check that class IDs match what’s in your CSV files, and there are no typos in class names.
3. Fix path references in pipeline.config

The training/pipeline.config file has hardcoded placeholder paths. Update these to point to your actual files:

  • Look for lines like input_path: "PATH_TO_BE_CONFIGURED/train.record" and replace PATH_TO_BE_CONFIGURED with your full repo path (using forward slashes).
  • Repeat for test_input_path and label_map_path. For example:
    label_map_path: "C:/Users/You/Custom-Object-Detection/annotations/label_map.pbtxt"
    
  • Also confirm you ran generate_tfrecord.py to create train.record and test.record—these are the TFRecord files the model reads. If they’re missing or misdirected, you’ll get the file-not-found error.
4. Unhide file extensions (Windows hidden gotcha!)

Windows defaults to hiding known file extensions. So img1.jpg might actually be img1.jpg.jpg without you noticing. Fix this:

  • Open File Explorer > View tab > Check "File name extensions".
  • Verify all images have .jpg (or your chosen format) and annotations have .xml extensions.
5. Check folder permissions (less common but worth trying)

Sometimes Windows restricts access to certain folders. Try:

  • Running your command prompt or IDE as Administrator.
  • Moving the Custom-Object-Detection folder out of restricted locations like Program Files—use your Documents or Desktop instead.

If you’ve tried all these and still hit issues, paste the exact error message (including the full path it’s trying to access) and we can narrow it down further.

内容的提问来源于stack exchange,提问作者Markus Mikkonen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:32:49