I am trying to execute the code for creating labels and masks for buildings but I am getting the error that the system cannot find the path specified. I am unable to resolve it. Can anyone help?
from PIL import Image
label_dir = 'D:/RESEARCH/IITR/BUILDING_EXTRACTION_PhD_Final_WORK/DATASET/ISPRS_DATASET/Vaihingen/Vaihingen/temp/dest/label/'
mask_dir = 'D:/RESEARCH/IITR/BUILDING_EXTRACTION_PhD_Final_WORK/DATASET/ISPRS_DATASET/Vaihingen/Vaihingen/temp/dest/mask/'
for path in os.listdir(label_dir):
abs_path = os.path.join(label_dir,path)
im = Image.open(abs_path)
im_a = np.asarray(im)
im_size = im_a.shape[:2]
new_mask = np.zeros(im_size)
c1 = np.stack([im_a[...,0]==0,im_a[...,1]==0,im_a[...,2]==255],axis=-1)
new_mask[c1.all(-1)] = 255
new_im = Image.fromarray(new_mask)
new_im = new_im.convert('L')
new_im.save(os.path.join(mask_dir,path))
The error that I am getting is:
FileNotFoundError Traceback (most recent call last)
Input In [14], in <cell line: 4>()
2 label_dir = 'D:/RESEARCH/IITR/BUILDING_EXTRACTION_PhD_Final_WORK/DATASET/ISPRS_DATASET/Vaihingen/Vaihingen/temp/dest/label/'
3 mask_dir = 'D:/RESEARCH/IITR/BUILDING_EXTRACTION_PhD_Final_WORK/DATASET/ISPRS_DATASET/Vaihingen/Vaihingen/temp/dest/mask/'
----> 4 for path in os.listdir(label_dir):
5 abs_path = os.path.join(label_dir,path)
6 im = Image.open(abs_path)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'D:/RESEARCH/IITR/BUILDING_EXTRACTION_PhD_Final_WORK/DATASET/ISPRS_DATASET/Vaihingen/Vaihingen/temp/dest/label/'