-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmsceleb1m_genImage.py
36 lines (34 loc) · 1.04 KB
/
msceleb1m_genImage.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
30
31
32
33
34
35
import os,sys
import base64
import cv2
prefix = 'images/'
if __name__ == '__main__':
file_name = sys.argv[1]
count =0
with open(file_name) as infile:
for line in infile:
# print line
arr = line.strip().split('\t')
dirname = arr[0]
# imgid = arr[1]
imgid = str(count)
count += 1
faceid = arr[-3]
rect = arr[-2]
imgbase64 = arr[-1]
print dirname
# print 'freebasemid', arr[0]
# print 'face', imgbase64
imgdata = base64.b64decode(imgbase64)
# mkdir
mid_dir = prefix + dirname
if not os.path.exists(mid_dir):
os.makedirs(mid_dir)
# save file
filename = mid_dir + '/' + imgid + '_' + faceid + '.jpg'
print filename
with open(filename, 'wb') as f:
f.write(imgdata)
# img = cv2.imread(filename)
# cv2.imshow('abc', img)
# cv2.waitKey()