There is an images folder and test.py directly under the data directory.In the images folder, there are two folders: data1 and data2, and data1 and data2 contain images such as 1.png and 2.png.I would like to take out the image in data1 and data2.
on test.py
import argparse
parser=argparse.ArgumentParser()
parser.add_argument("--img_dir")
data_dir=parser.parse_args()
if data_dir.img_dir is None or notos.path.exists(data_dir.img_dir):
raise Exception("data_dir does not exist")
input_paths=glob.glob(os.path.join(data_dir.img_dir, "*.jpg")))
I wrote the code.This code is
python test.py images
The error "data_dir does not exist" always appears when you run .I don't know why it always comes out like this even though I'm specifying a file.I write this code while looking into it, and I don't think so, but doesn't os.path.exists(data_dir.img_dir) recognize that it's not a full pass?How can I fix it?
python
@metropolis is also mentioned in the comment section, but if data
is the current directory, the location relationship between the script and the image file should be as follows, so images/data1/
, images/data2/
,... should be the relative path.
test.py
images/data1/1.png
images/data1/2.png
images/data2/1.png
images/data2/2.png
In Python, the current folder is the folder that contains the scripts to run.Looking at the folder configuration, test.py, data1, data2 are in the same images folder, so I think the current code and configuration should be python test.py data1
.
© 2024 OneMinuteCode. All rights reserved.