使用Caffe的create_imagenet.sh转JPG为LMDB无输出问题求助
Let's walk through the possible issues step by step—since your script runs without any output, it's likely failing silently or hitting an early exit without showing errors:
1. Ditch sudo Unless You Really Need It
Running the script with sudo switches to the root user, which creates two common problems:
- Root might not have permission to access your user-specific directories (like
/home/sun/...), so commands that work for your user could fail for root. - Error messages might be suppressed or redirected to a root-only log instead of your terminal.
First, try running the script without sudo:
sh create_oxford.sh
If you get permission errors (e.g., writing to the $EXAMPLE directory), fix directory permissions instead of relying on sudo:
chmod -R 755 /home/sun/Documents/python/fine-tuning/Oxford102/data/test
2. Fix the Error Message Typo (and Validate Path Checks)
Looking at your script, there's a small but confusing typo in the DATA_TEST error handling:
if [ ! -d "$DATA_TEST" ]; then echo "Error: TRAIN_DATA_ROOT is not a path to a directory: $DATA_TEST" # ... rest of message fi
The message references TRAIN_DATA_ROOT but is checking DATA_TEST—this is just wording, but more importantly: your script uses set -e (exit immediately if any command fails). If either DATA_TRAIN or DATA_TEST is invalid, the script exits right away, but sudo might hide this error.
To capture all output (including errors), run the script with redirection:
sh create_oxford.sh > script_output.log 2>&1
Then check script_output.log for any messages about missing directories.
3. Verify the convert_imageset Tool Exists
Double-check that the convert_imageset binary is present in your specified BUILD path, and that your user can access it:
ls -l /home/sun/Documents/caffe/build/tools/convert_imageset
If this returns "No such file or directory", you need to re-build Caffe to generate the tool. If it exists but lacks execute permissions, fix that:
chmod +x /home/sun/Documents/caffe/build/tools/convert_imageset
4. Debug with Verbose Execution
Modify your script to print every command it runs, so you can see exactly where it stops working. Change the line set -e to:
set -ex
The x flag enables verbose mode, so each command is printed to the terminal before execution. Run the script again, and you'll spot which step is failing.
5. Validate Label Files and Image Paths
Even though you said your label files follow the image_0001.jpg 0 format, double-check:
- Every filename in
info_train.txtexists in/home/sun/Documents/python/fine-tuning/Oxford102/data/test/train/(Linux is case-sensitive—watch for typos likeImage_0001.jpginstead ofimage_0001.jpg). - Label files have no blank lines or extra spaces.
- Files are saved as plain text (not rich formats like .docx or .rtf).
6. Ensure LMDB Output Directories Are Writable
The script tries to create img_train_lmdb and img_test_lmdb in $EXAMPLE. Make sure the directory is writable:
mkdir -p /home/sun/Documents/python/fine-tuning/Oxford102/data/test/img_train_lmdb chmod 755 /home/sun/Documents/python/fine-tuning/Oxford102/data/test/img_train_lmdb
Repeat this for the test LMDB directory.
内容的提问来源于stack exchange,提问作者goldentime

