segments = crop_to_segments(test_images, test_masks, 455, 512)
当我启动我的功能时,我遇到了以下问题:权限被拒绝[Errno13]
我的路径是这样的:
path_to_dataset = 'C:/Users/nkuly/jupyter/vechile-dataset/'
test_images = os.path.join(path_to_dataset, 'test/', 'images/')
test_masks = os.path.join(path_to_dataset, 'test/', 'masks/')
起初我尝试使用相对路径,但有些人推荐绝对路径,但不起作用。 后来,我尝试了文件夹安全性的所有时刻,根据读写更改了所有权限。但还是不行。
为了测试,我使用了这段代码,就像打开图像一样:
image_files = [f for f in os.listdir(test_images) if os.path.isfile(os.path.join(test_images, f))]
if image_files:
# Open the first image file
image_path = os.path.join(test_images, image_files[0])
try:
with Image.open(image_path) as img:
img.show() # This will display the image
except IOError as e:
print(f"Error opening the image: {e}")
else:
print("No image files found in the directory.")
你知道吗? 图片已打开。
我不知道为什么它不起作用。
P.S:为了打开图像,我使用 PIL.Image.open() [我有 Windows,没有 Linux,MacOS] 顺便说一句,我已经尝试过(r''),是的,我正在以管理员身份启动。
尝试使用管理员cmd窗口并运行它