Skip to content

Commit ff970d6

Browse files
committed
make sure that landmarks are in the face bounding box
1 parent d1125ea commit ff970d6

File tree

1 file changed

+65
-21
lines changed

1 file changed

+65
-21
lines changed

Face Quality Assessment.ipynb

+65-21
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,22 @@
1919
},
2020
{
2121
"cell_type": "code",
22-
"execution_count": null,
22+
"execution_count": 1,
2323
"metadata": {},
24-
"outputs": [],
24+
"outputs": [
25+
{
26+
"name": "stdout",
27+
"output_type": "stream",
28+
"text": [
29+
"WARNING:tensorflow:From D:\\Almaatech\\face\\face-quality-metrics\\detection\\mtcnn\\detect_face.py:210: calling reduce_max (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version.\n",
30+
"Instructions for updating:\n",
31+
"keep_dims is deprecated, use keepdims instead\n",
32+
"WARNING:tensorflow:From D:\\Almaatech\\face\\face-quality-metrics\\detection\\mtcnn\\detect_face.py:212: calling reduce_sum (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version.\n",
33+
"Instructions for updating:\n",
34+
"keep_dims is deprecated, use keepdims instead\n"
35+
]
36+
}
37+
],
2538
"source": [
2639
"import tensorflow as tf\n",
2740
"from detection.mtcnn import detect_face\n",
@@ -32,7 +45,7 @@
3245
},
3346
{
3447
"cell_type": "code",
35-
"execution_count": null,
48+
"execution_count": 2,
3649
"metadata": {},
3750
"outputs": [],
3851
"source": [
@@ -47,7 +60,7 @@
4760
},
4861
{
4962
"cell_type": "code",
50-
"execution_count": null,
63+
"execution_count": 3,
5164
"metadata": {},
5265
"outputs": [],
5366
"source": [
@@ -69,15 +82,6 @@
6982
"# Illumination "
7083
]
7184
},
72-
{
73-
"cell_type": "code",
74-
"execution_count": null,
75-
"metadata": {},
76-
"outputs": [],
77-
"source": [
78-
"points"
79-
]
80-
},
8185
{
8286
"cell_type": "code",
8387
"execution_count": null,
@@ -146,19 +150,22 @@
146150
"cell_type": "markdown",
147151
"metadata": {},
148152
"source": [
149-
"# Facial symmetry"
153+
"# Facial Symmetry"
150154
]
151155
},
152156
{
153157
"cell_type": "code",
154-
"execution_count": null,
158+
"execution_count": 4,
155159
"metadata": {},
156160
"outputs": [],
157161
"source": [
158162
"from skimage.feature import hog\n",
159163
"\n",
160164
"def symmetry(img, landmark, bounding_box):\n",
161-
" x1, y1, x2, y2 = int(bounding_box[0]), int(bounding_box[1]), int(bounding_box[2]), int(bounding_box[3])\n",
165+
" x1, y1, x2, y2 = int(min(bounding_box[0], min(landmark[:5]))), \\\n",
166+
" int(min(bounding_box[1], min(landmark[5:]))), \\\n",
167+
" int(max(bounding_box[2], max(landmark[:5]))), \\\n",
168+
" int(max(bounding_box[3], max(landmark[5:])))\n",
162169
" \n",
163170
" landmark = np.array([[landmark[i], landmark[5 + i]] for i in range(5)], np.int32).reshape((-1,1,2))\n",
164171
" contour = landmark[:, 0] - [[x1, y1]]\n",
@@ -181,9 +188,28 @@
181188
},
182189
{
183190
"cell_type": "code",
184-
"execution_count": null,
191+
"execution_count": 5,
185192
"metadata": {},
186-
"outputs": [],
193+
"outputs": [
194+
{
195+
"name": "stderr",
196+
"output_type": "stream",
197+
"text": [
198+
"c:\\users\\bahar\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\skimage\\feature\\_hog.py:150: skimage_deprecation: Default value of `block_norm`==`L1` is deprecated and will be changed to `L2-Hys` in v0.15. To supress this message specify explicitly the normalization method.\n",
199+
" skimage_deprecation)\n"
200+
]
201+
},
202+
{
203+
"data": {
204+
"text/plain": [
205+
"0.02465394288301468"
206+
]
207+
},
208+
"execution_count": 5,
209+
"metadata": {},
210+
"output_type": "execute_result"
211+
}
212+
],
187213
"source": [
188214
"symmetry(img, points, bounding_boxes[0])"
189215
]
@@ -197,7 +223,7 @@
197223
},
198224
{
199225
"cell_type": "code",
200-
"execution_count": null,
226+
"execution_count": 6,
201227
"metadata": {},
202228
"outputs": [],
203229
"source": [
@@ -216,12 +242,30 @@
216242
},
217243
{
218244
"cell_type": "code",
219-
"execution_count": null,
245+
"execution_count": 7,
220246
"metadata": {},
221-
"outputs": [],
247+
"outputs": [
248+
{
249+
"data": {
250+
"text/plain": [
251+
"1"
252+
]
253+
},
254+
"execution_count": 7,
255+
"metadata": {},
256+
"output_type": "execute_result"
257+
}
258+
],
222259
"source": [
223260
"size(img)"
224261
]
262+
},
263+
{
264+
"cell_type": "code",
265+
"execution_count": null,
266+
"metadata": {},
267+
"outputs": [],
268+
"source": []
225269
}
226270
],
227271
"metadata": {

0 commit comments

Comments
 (0)