-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselection_dataset_image.py
26 lines (17 loc) · 987 Bytes
/
selection_dataset_image.py
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 shutil
import os
SELECTION_DIR_NAME = 'face_dataset-2022-1-28'
for dir_dataset in os.listdir(os.path.join(os.getcwd(), 'face_dataset')):
if not os.path.isdir(os.path.join(os.getcwd(), 'face_dataset', dir_dataset)):
continue
if not os.path.isdir(os.path.join(os.getcwd(), SELECTION_DIR_NAME, dir_dataset)):
os.mkdir(os.path.join(os.getcwd(), SELECTION_DIR_NAME, dir_dataset))
print("Create dir: " + dir_dataset)
print(len(os.listdir(os.path.join(os.getcwd(), 'face_dataset', dir_dataset))))
for file in os.listdir(os.path.join(os.getcwd(), 'face_dataset', dir_dataset)) \
[::int((len(os.listdir(os.path.join(os.getcwd(), 'face_dataset', dir_dataset)))) / 30) + 1]:
if '.jpg' not in file:
continue
print(dir_dataset, file)
shutil.copy2(os.path.join(os.getcwd(), 'face_dataset', dir_dataset, file),
os.path.join(os.getcwd(), SELECTION_DIR_NAME, dir_dataset, file))