Skip to content

Commit 882fff1

Browse files
authored
Merge pull request #15 from Giskard-AI/feature/gsk-2424-improve-the-hierarchy-structure-see-ffhq
[GSK-2424] Improve a bit FFHQ structure
2 parents 70993c0 + 8836c95 commit 882fff1

16 files changed

+510
-326
lines changed

‎examples/criteria1_partial_faces.ipynb‎

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,7 @@
3434
"cell_type": "code",
3535
"execution_count": 2,
3636
"metadata": {},
37-
"outputs": [
38-
{
39-
"name": "stdout",
40-
"output_type": "stream",
41-
"text": [
42-
"loading data from : lbfmodel.yaml\n"
43-
]
44-
}
45-
],
37+
"outputs": [],
4638
"source": [
4739
"# model = FaceAlignmentWrapper(model=FaceAlignment(LandmarksType.TWO_D, device=device, flip_input=False))\n",
4840
"model = OpenCVWrapper()\n",
@@ -69,7 +61,7 @@
6961
" <p>Description: Mean of normalised mean Euclidean distances across images</p>\n",
7062
" <p>Metric: <b>0.0383</b> (threshold = 1)</p>\n",
7163
" \n",
72-
" <p>Prediction time: 0.71 s.</p>\n",
64+
" <p>Prediction time: 0.34 s.</p>\n",
7365
" "
7466
],
7567
"text/plain": [
@@ -78,7 +70,7 @@
7870
" Description: Mean of normalised mean Euclidean distances across images\n",
7971
" Metric: 0.0383 (threshold = 1)\n",
8072
" \n",
81-
" Prediction time: 0.71 s.\n",
73+
" Prediction time: 0.34 s.\n",
8274
" "
8375
]
8476
},
@@ -117,7 +109,7 @@
117109
"name": "stderr",
118110
"output_type": "stream",
119111
"text": [
120-
"/Users/rak/Documents/loreal-poc/loreal_poc/tests/performance.py:47: RuntimeWarning: Mean of empty slice\n",
112+
"/Users/bazire/Work/loreal-poc/loreal_poc/tests/performance.py:47: RuntimeWarning: Mean of empty slice\n",
121113
" mes = np.nanmean(es, axis=1)\n"
122114
]
123115
}
@@ -159,8 +151,10 @@
159151
"squares = []\n",
160152
"chosen_idx = 1\n",
161153
"image, _, _ = ds[chosen_idx]\n",
154+
"image = image[0]\n",
162155
"for rel_margin in rel_margins:\n",
163156
" img, marks, meta = ds[chosen_idx]\n",
157+
" img, marks, meta = img[0], marks[0], meta[0]\n",
164158
" h, w, _ = img.shape\n",
165159
" margins = np.array([w, h]) * rel_margin\n",
166160
" cropped_mark = crop_mark(marks, facial_part)\n",
@@ -211,7 +205,7 @@
211205
"name": "stderr",
212206
"output_type": "stream",
213207
"text": [
214-
"/Users/rak/Documents/loreal-poc/loreal_poc/tests/performance.py:47: RuntimeWarning: Mean of empty slice\n",
208+
"/Users/bazire/Work/loreal-poc/loreal_poc/tests/performance.py:47: RuntimeWarning: Mean of empty slice\n",
215209
" mes = np.nanmean(es, axis=1)\n"
216210
]
217211
},
@@ -223,7 +217,7 @@
223217
" <p>Description: Mean of normalised mean Euclidean distances across images</p>\n",
224218
" <p>Metric: <b>0.5774</b> (threshold = 1)</p>\n",
225219
" Prediction fail rate: 0.6\n",
226-
" <p>Prediction time: 0.82 s.</p>\n",
220+
" <p>Prediction time: 0.41 s.</p>\n",
227221
" "
228222
],
229223
"text/plain": [
@@ -232,7 +226,7 @@
232226
" Description: Mean of normalised mean Euclidean distances across images\n",
233227
" Metric: 0.5774 (threshold = 1)\n",
234228
" Prediction fail rate: 0.6\n",
235-
" Prediction time: 0.82 s.\n",
229+
" Prediction time: 0.41 s.\n",
236230
" "
237231
]
238232
},
@@ -261,7 +255,7 @@
261255
" <p>Description: Standard deviation of normalised Mean Euclidean distances across images</p>\n",
262256
" <p>Metric: <b>0.0532</b> (threshold = 1)</p>\n",
263257
" Prediction fail rate: 0.6\n",
264-
" <p>Prediction time: 0.65 s.</p>\n",
258+
" <p>Prediction time: 0.43 s.</p>\n",
265259
" "
266260
],
267261
"text/plain": [
@@ -270,7 +264,7 @@
270264
" Description: Standard deviation of normalised Mean Euclidean distances across images\n",
271265
" Metric: 0.0532 (threshold = 1)\n",
272266
" Prediction fail rate: 0.6\n",
273-
" Prediction time: 0.65 s.\n",
267+
" Prediction time: 0.43 s.\n",
274268
" "
275269
]
276270
},
@@ -307,7 +301,7 @@
307301
"name": "python",
308302
"nbconvert_exporter": "python",
309303
"pygments_lexer": "ipython3",
310-
"version": "3.11.6"
304+
"version": "3.11.7"
311305
}
312306
},
313307
"nbformat": 4,

‎examples/ex1_draw_landmarks.ipynb‎

Lines changed: 94 additions & 6 deletions
Large diffs are not rendered by default.

‎examples/ex2_draw_partial_landmarks.ipynb‎

Lines changed: 13 additions & 13 deletions
Large diffs are not rendered by default.

‎examples/ex3_calculate_euc_dists.ipynb‎

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 1,
66
"metadata": {
77
"collapsed": false,
88
"jupyter": {
@@ -19,28 +19,61 @@
1919
},
2020
{
2121
"cell_type": "code",
22-
"execution_count": null,
22+
"execution_count": 2,
2323
"metadata": {},
24-
"outputs": [],
24+
"outputs": [
25+
{
26+
"data": {
27+
"text/plain": [
28+
"array([4. , 1. , 2.23606798, 2.23606798])"
29+
]
30+
},
31+
"execution_count": 2,
32+
"metadata": {},
33+
"output_type": "execute_result"
34+
}
35+
],
2536
"source": [
2637
"a_min_b = A - B\n",
2738
"np.sqrt(np.einsum(\"ij,ij->i\", a_min_b, a_min_b))"
2839
]
2940
},
3041
{
3142
"cell_type": "code",
32-
"execution_count": null,
43+
"execution_count": 3,
3344
"metadata": {},
34-
"outputs": [],
45+
"outputs": [
46+
{
47+
"data": {
48+
"text/plain": [
49+
"array([4. , 1. , 2.23606798, 2.23606798])"
50+
]
51+
},
52+
"execution_count": 3,
53+
"metadata": {},
54+
"output_type": "execute_result"
55+
}
56+
],
3557
"source": [
3658
"np.linalg.norm(A - B, axis=1)"
3759
]
3860
},
3961
{
4062
"cell_type": "code",
41-
"execution_count": null,
63+
"execution_count": 4,
4264
"metadata": {},
43-
"outputs": [],
65+
"outputs": [
66+
{
67+
"data": {
68+
"text/plain": [
69+
"array([4. , 1. , 2.23606798, 2.23606798])"
70+
]
71+
},
72+
"execution_count": 4,
73+
"metadata": {},
74+
"output_type": "execute_result"
75+
}
76+
],
4477
"source": [
4578
"d_all = np.sqrt(np.einsum(\"ij->i\", (A - B) ** 2))\n",
4679
"d_all"
@@ -63,7 +96,7 @@
6396
"name": "python",
6497
"nbconvert_exporter": "python",
6598
"pygments_lexer": "ipython3",
66-
"version": "3.11.6"
99+
"version": "3.11.7"
67100
}
68101
},
69102
"nbformat": 4,

‎examples/ex4_tests_and_metrics.ipynb‎

Lines changed: 83 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 1,
66
"metadata": {
77
"collapsed": false,
88
"jupyter": {
@@ -37,7 +37,7 @@
3737
},
3838
{
3939
"cell_type": "code",
40-
"execution_count": null,
40+
"execution_count": 2,
4141
"metadata": {
4242
"collapsed": false,
4343
"jupyter": {
@@ -51,9 +51,20 @@
5151
},
5252
{
5353
"cell_type": "code",
54-
"execution_count": null,
54+
"execution_count": 3,
5555
"metadata": {},
56-
"outputs": [],
56+
"outputs": [
57+
{
58+
"data": {
59+
"text/plain": [
60+
"'cpu'"
61+
]
62+
},
63+
"execution_count": 3,
64+
"metadata": {},
65+
"output_type": "execute_result"
66+
}
67+
],
5768
"source": [
5869
"import torch\n",
5970
"\n",
@@ -75,7 +86,7 @@
7586
},
7687
{
7788
"cell_type": "code",
78-
"execution_count": null,
89+
"execution_count": 4,
7990
"metadata": {
8091
"collapsed": false,
8192
"jupyter": {
@@ -89,23 +100,85 @@
89100
},
90101
{
91102
"cell_type": "code",
92-
"execution_count": null,
103+
"execution_count": 5,
93104
"metadata": {
94105
"collapsed": false,
95106
"jupyter": {
96107
"outputs_hidden": false
97108
}
98109
},
99-
"outputs": [],
110+
"outputs": [
111+
{
112+
"data": {
113+
"text/html": [
114+
"\n",
115+
" <h4><span style=\"color:green;\">✓</span> Test \"NME_mean\" succeeded</h4>\n",
116+
" <p>Description: Mean of normalised mean Euclidean distances across images</p>\n",
117+
" <p>Metric: <b>0.0623</b> (threshold = 1)</p>\n",
118+
" \n",
119+
" <p>Prediction time: 13.1 s.</p>\n",
120+
" "
121+
],
122+
"text/plain": [
123+
"\n",
124+
" Test \"NME_mean\" succeeded\n",
125+
" Description: Mean of normalised mean Euclidean distances across images\n",
126+
" Metric: 0.0623 (threshold = 1)\n",
127+
" \n",
128+
" Prediction time: 13.1 s.\n",
129+
" "
130+
]
131+
},
132+
"execution_count": 5,
133+
"metadata": {},
134+
"output_type": "execute_result"
135+
}
136+
],
100137
"source": [
101138
"Test(metric=NMEMean, threshold=1).run(model, ds)"
102139
]
103140
},
104141
{
105142
"cell_type": "code",
106-
"execution_count": null,
143+
"execution_count": 6,
107144
"metadata": {},
108-
"outputs": [],
145+
"outputs": [
146+
{
147+
"name": "stderr",
148+
"output_type": "stream",
149+
"text": [
150+
"/Users/bazire/Work/loreal-poc/.venv/lib/python3.11/site-packages/face_alignment/api.py:147: UserWarning: No faces were detected.\n",
151+
" warnings.warn(\"No faces were detected.\")\n",
152+
"/Users/bazire/Work/loreal-poc/loreal_poc/tests/performance.py:47: RuntimeWarning: Mean of empty slice\n",
153+
" mes = np.nanmean(es, axis=1)\n"
154+
]
155+
},
156+
{
157+
"data": {
158+
"text/html": [
159+
"\n",
160+
" <h4><span style=\"color:green;\">✓</span> Test \"NME_mean\" succeeded</h4>\n",
161+
" <p>Description: Mean of normalised mean Euclidean distances across images</p>\n",
162+
" <p>Metric: <b>0.3962</b> (threshold = 1)</p>\n",
163+
" Prediction fail rate: 0.4\n",
164+
" <p>Prediction time: 18.74 s.</p>\n",
165+
" "
166+
],
167+
"text/plain": [
168+
"\n",
169+
" Test \"NME_mean\" succeeded\n",
170+
" Description: Mean of normalised mean Euclidean distances across images\n",
171+
" Metric: 0.3962 (threshold = 1)\n",
172+
" Prediction fail rate: 0.4\n",
173+
" Prediction time: 18.74 s.\n",
174+
" "
175+
]
176+
},
177+
"execution_count": 6,
178+
"metadata": {},
179+
"output_type": "execute_result"
180+
}
181+
],
109182
"source": [
110183
"from loreal_poc.marks.facial_parts import FacialParts\n",
111184
"from loreal_poc.dataloaders.wrappers import CroppedDataLoader, CachedDataLoader\n",
@@ -132,7 +205,7 @@
132205
"name": "python",
133206
"nbconvert_exporter": "python",
134207
"pygments_lexer": "ipython3",
135-
"version": "3.11.6"
208+
"version": "3.11.7"
136209
}
137210
},
138211
"nbformat": 4,

0 commit comments

Comments
 (0)