Please i need help. I am using windows. I am getting an empty list when I run this glob code. my ipynb file is inside the code folder, and I have 4 different folders inside the train and test folders that serve as labels for my image task.
# Setup train and testing paths
train_dir = "code/Datasets/train/**/*.jpg"
test_dir = "code/Datasets/test/**/*.jpg"
train_dir, test_dir
check = glob.glob(train_dir)
print(check)
I also tried pasting some images to enable me try this and it did not work
train_dir = "code/Datasets/train/*.jpg"
Two possible issues:
**
in your glob
path, you fail to pass recursive=True
, so it won't actually treat **
as specialimport os
, print(os.getcwd())
. Is your working directory the one that contains code/Datasets/...
? Relative paths like this require a specific working directory (separate from the script directory). If you were expecting it to use the script directory, you need to specify your path relative to __file__
, eg train_dir = os.path.join(__file__, "code/Datasets/train/**/*.jpg")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.