-
Notifications
You must be signed in to change notification settings - Fork 3
/
inputimage.py
56 lines (50 loc) · 1.14 KB
/
inputimage.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from PIL import Image
from os import listdir
import os
# {
# '30601258@N03':[
# {
# imageid:
# image:
# }
# {
# imageid:
# image:
# }
# {
# imageid:
# image:
# }
# ]
# }
# 'imageid': '10424815813_e94629b1ec_o.jpg'
# 9505396598_2d1fb84849_o.jpg
# 'imageid': coarse_tilt_aligned_face.9.9505396598_2d1fb84849_o.jpg
def loadImages(userid, users):
if userid not in users:
users[userid] = []
path = os.path.join('./', userid)
imagesList = listdir(path)
loadedImages = []
setids = set()
for image in imagesList:
if image.endswith('.jpg'):
currimg = {}
# img = Image.open(os.path.join(path, image))
imgpath = os.path.join(path, image)
st = str(image)
imgidparsed = '.'.join(st.split('.')[-2:])
if imgidparsed in setids:
continue
else:
setids.add(imgidparsed)
currimg['imageid'] = imgidparsed
currimg['image'] = imgpath
loadedImages.append(currimg)
print 'for user {}, we have loaded {} number of pictures'.format(userid, len(loadedImages))
users[userid].extend(loadedImages)
users = {}
def load(userid):
loadImages(userid, users)
return users
# user = load('30601258@N03')