File size: 696 Bytes
7931fc7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import glob
import os
from os import path as osp
from PIL import Image
# print(len(sorted(glob.glob('GT_sub/*'))))
# raise NotImplementedError
with open('meta_info_DFO.txt', 'w') as f:
for idx, img_path in enumerate(sorted(glob.glob('GT_sub/*'))):
filename = osp.basename(img_path)
# img = Image.open(img_path) # lazy load
# width, height = img.size
# mode = img.mode
# if mode == 'RGB':
# n_channel = 3
# elif mode == 'L':
# n_channel = 1
# else:
# raise ValueError(f'Unsupported mode {mode}.')
info = f'{filename} (480,480,3)'
print(idx + 1, info)
f.write(f'{info}\n')
|