|
import shutil |
|
from tqdm.auto import tqdm |
|
import os.path as osp |
|
from glob import glob |
|
from PIL import Image |
|
|
|
|
|
ROOTS = ['/home/ubuntu/Datasets/coco-2017-train/train2017/train', "/home/ubuntu/Datasets/ms-5kimages", "/home/ubuntu/Datasets/ffhq/in-the-wild-images/train"] |
|
names = ['coco', 'ms-5k', 'ffhq'] |
|
DEST = "/home/ubuntu/y1/y1-global-truemedia/train/images" |
|
skipped = 0 |
|
for name, root in zip(names, ROOTS): |
|
|
|
|
|
reals = glob(osp.join(root, '*')) |
|
|
|
|
|
|
|
|
|
if name == 'coco': |
|
reals = reals[:35000] |
|
for real in tqdm(reals): |
|
fname = f'{name}_{osp.basename(real)}' |
|
size = Image.open(real).size |
|
if max(size) > 2000: |
|
skipped += 1 |
|
continue |
|
if not osp.exists(osp.join(DEST, 'reals', fname)): |
|
shutil.copy(real, osp.join(DEST, 'reals', fname)) |
|
|
|
print(f"Skipped {skipped} images for being too large.") |
|
|