Python 如何在参数解析器中传递文件夹映像目录的路径,以测试我的文件夹上的所有映像,而不是只测试一个?

Python 如何在参数解析器中传递文件夹映像目录的路径,以测试我的文件夹上的所有映像,而不是只测试一个?,python,tensorflow,classification,detection,Python,Tensorflow,Classification,Detection,我的程序只测试一个图片示例_01.png,我想测试我放在示例文件夹中的所有图像 那我该怎么做呢? 谢谢 电话: 您是否尝试过os.list\U dir(路径名)? 通过此功能,您可以列出“路径”目录中的所有照片 您可以将此结果转换为列表并循环浏览所有图像 #!/usr/bin/python import os, sys # Open a file path = "/var/www/html/" dirs = os.listdir( path ) # This would

我的程序只测试一个图片示例_01.png,我想测试我放在示例文件夹中的所有图像 那我该怎么做呢? 谢谢

电话:

您是否尝试过os.list\U dir(路径名)? 通过此功能,您可以列出“路径”目录中的所有照片

您可以将此结果转换为列表并循环浏览所有图像

#!/usr/bin/python

import os, sys

# Open a file
path = "/var/www/html/"
dirs = os.listdir( path )

# This would print all the files and directories
for file in dirs:
   print file

使用cv2.imread()方法img=cv2.imread(path)从-

path='Image path'编写代码,但我发现ap=argparse.ArgumentParser()有问题
python detect_mask_image.py --image examples/example_01.png
#!/usr/bin/python

import os, sys

# Open a file
path = "/var/www/html/"
dirs = os.listdir( path )

# This would print all the files and directories
for file in dirs:
   print file