Spaces:
Running
on
T4
Running
on
T4
File size: 1,153 Bytes
06f26d7 |
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 27 28 29 30 31 32 33 |
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Power by Zongsheng Yue 2022-07-19 12:32:34
import os
import argparse
from pathlib import Path
parser = argparse.ArgumentParser()
parser.add_argument("--save_dir", type=str, default="./testdata/LFW-Test",
help="Folder to save the LR images")
parser.add_argument("--data_dir", type=str, default="./testdata/lfw",
help="LFW Testing dataset")
parser.add_argument("--txt_file", type=str, default="./testdata/peopleDevTest.txt",
help="LFW Testing data file paths")
args = parser.parse_args()
with open(args.txt_file, 'r') as ff:
file_dirs = [x.split('\t')[0] for x in ff.readlines()][1:]
if not Path(args.save_dir).exists():
Path(args.save_dir).mkdir(parents=True)
for current_dir in file_dirs:
current_dir = Path(args.data_dir) / current_dir
file_path = sorted([str(x) for x in current_dir.glob('*.jpg')])[0]
commond = f'cp {file_path} {args.save_dir}'
os.system(commond)
num_images = len([x for x in Path(args.save_dir).glob('*.jpg')])
print(f'Number of images: {num_images}')
|