generated from GT-ZhangAcer/AI-Studio-Template
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlandmarkModule.py
21 lines (20 loc) · 995 Bytes
/
landmarkModule.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import paddlehub as hub
class landmarker():
def __init__(self,debug=False):
self.face_landmark = hub.Module(name="face_landmark_localization")
self.debug=debug
def run(self, img):
landmarks = []
# print('begin baidu landmark')
results = self.face_landmark.keypoint_detection(images=[img],
paths=None,
batch_size=1,
use_gpu=False,
output_dir='face_landmark_output',
visualization=self.debug)
# print('emoi baidu landmark',landmarks)
for result in results:
landmarks = result['data']
break # one pic one result
# print('emoi baidu landmark', landmarks[0], len(landmarks[0]))
return landmarks