File size: 533 Bytes
02c5426
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import os
from PIL import Image
from tqdm import tqdm

inp = r'H:\DataSet\SceneCls\UCMerced_LandUse\UCMerced_LandUse\Images'

for size in [256, 128, 64, 32]:
    if size == 256:
        inp = './data1024x1024'
    else:
        inp = './256'
    print(size)
    os.mkdir(str(size))
    filenames = os.listdir(inp)
    for filename in tqdm(filenames):
        Image.open(os.path.join(inp, filename)) \
            .resize((size, size), Image.BICUBIC) \
            .save(os.path.join('.', str(size), filename.split('.')[0] + '.png'))