Ahsen Khaliq commited on
Commit
2a375c8
·
1 Parent(s): 241373a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -34
app.py CHANGED
@@ -77,39 +77,6 @@ def get_dlib_face_detector(predictor_path: str = "shape_predictor_68_face_landma
77
  return detect_face_landmarks
78
 
79
 
80
- def display_facial_landmarks(
81
- img: Image,
82
- landmarks: List[np.ndarray],
83
- fig_size=[15, 15]
84
- ):
85
- plot_style = dict(
86
- marker='o',
87
- markersize=4,
88
- linestyle='-',
89
- lw=2
90
- )
91
- pred_type = collections.namedtuple('prediction_type', ['slice', 'color'])
92
- pred_types = {
93
- 'face': pred_type(slice(0, 17), (0.682, 0.780, 0.909, 0.5)),
94
- 'eyebrow1': pred_type(slice(17, 22), (1.0, 0.498, 0.055, 0.4)),
95
- 'eyebrow2': pred_type(slice(22, 27), (1.0, 0.498, 0.055, 0.4)),
96
- 'nose': pred_type(slice(27, 31), (0.345, 0.239, 0.443, 0.4)),
97
- 'nostril': pred_type(slice(31, 36), (0.345, 0.239, 0.443, 0.4)),
98
- 'eye1': pred_type(slice(36, 42), (0.596, 0.875, 0.541, 0.3)),
99
- 'eye2': pred_type(slice(42, 48), (0.596, 0.875, 0.541, 0.3)),
100
- 'lips': pred_type(slice(48, 60), (0.596, 0.875, 0.541, 0.3)),
101
- 'teeth': pred_type(slice(60, 68), (0.596, 0.875, 0.541, 0.4))
102
- }
103
-
104
-
105
- for face in landmarks:
106
- for pred_type in pred_types.values():
107
- ax.plot(
108
- face[pred_type.slice, 0],
109
- face[pred_type.slice, 1],
110
- color=pred_type.color, **plot_style
111
- )
112
-
113
  import PIL.Image
114
  import PIL.ImageFile
115
  import numpy as np
@@ -203,7 +170,6 @@ def inference(image):
203
  face_detector = get_dlib_face_detector()
204
  landmarks = face_detector(img)
205
 
206
- display_facial_landmarks(img, landmarks, fig_size=[5, 5])
207
 
208
  for landmark in landmarks:
209
  face = align_and_crop_face(img, landmark, expand=1.3)
 
77
  return detect_face_landmarks
78
 
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  import PIL.Image
81
  import PIL.ImageFile
82
  import numpy as np
 
170
  face_detector = get_dlib_face_detector()
171
  landmarks = face_detector(img)
172
 
 
173
 
174
  for landmark in landmarks:
175
  face = align_and_crop_face(img, landmark, expand=1.3)