forked from yxgeee/FD-GAN
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprepare.py
executable file
·30 lines (25 loc) · 855 Bytes
/
prepare.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
27
28
29
import os
from shutil import copyfile
# You only need to change this line to your dataset download path
download_path = './test'
if not os.path.isdir(download_path):
print('please change the download_path')
save_path = './test-class'
if not os.path.isdir(save_path):
os.mkdir(save_path)
#-----------------------------------------
#query
query_path = download_path
query_save_path = save_path
if not os.path.isdir(query_save_path):
os.mkdir(query_save_path)
for root, dirs, files in os.walk(query_path, topdown=True):
for name in files:
if not name[-3:]=='jpg':
continue
ID = name.split('_')
src_path = query_path + '/' + name
dst_path = query_save_path + '/' + ID[0]
if not os.path.isdir(dst_path):
os.mkdir(dst_path)
copyfile(src_path, dst_path + '/' + name)