Skip to content
Prev Previous commit
Next Next commit
fixed conflicts and forced updated examples from main
  • Loading branch information
rabah-khalek committed Dec 20, 2023
commit 39360af9e55f02a92f7f2313f25a1c046ddf32b5
223 changes: 20 additions & 203 deletions examples/criteria1_partial_faces.ipynb

Large diffs are not rendered by default.

115 changes: 12 additions & 103 deletions examples/ex1_draw_landmarks.ipynb

Large diffs are not rendered by default.

56 changes: 3 additions & 53 deletions examples/ex2_draw_partial_landmarks.ipynb

Large diffs are not rendered by default.

85 changes: 6 additions & 79 deletions examples/ex4_tests_and_metrics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'cpu'"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"import torch\n",
"\n",
Expand Down Expand Up @@ -100,90 +89,28 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <h4><span style=\"color:green;\">✓</span> Test \"NME_mean\" succeeded</h4>\n",
" <p>Description: Mean of normalised mean Euclidean distances across images</p>\n",
" <p>Metric: <b>0.0623</b> (threshold = 1)</p>\n",
" \n",
" <p>Prediction time: 7.9 s.</p>\n",
" "
],
"text/plain": [
"\n",
" Test \"NME_mean\" succeeded\n",
" Description: Mean of normalised mean Euclidean distances across images\n",
" Metric: 0.0623 (threshold = 1)\n",
" \n",
" Prediction time: 7.9 s.\n",
" "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"Test(metric=NMEMean, threshold=1).run(model, ds)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/bazire/Work/loreal-poc/.venv/lib/python3.11/site-packages/face_alignment/api.py:147: UserWarning: No faces were detected.\n",
" warnings.warn(\"No faces were detected.\")\n",
"/Users/bazire/Work/loreal-poc/loreal_poc/tests/performance.py:47: RuntimeWarning: Mean of empty slice\n",
" mes = np.nanmean(es, axis=1)\n"
]
},
{
"data": {
"text/html": [
"\n",
" <h4><span style=\"color:green;\">✓</span> Test \"NME_mean\" succeeded</h4>\n",
" <p>Description: Mean of normalised mean Euclidean distances across images</p>\n",
" <p>Metric: <b>0.3962</b> (threshold = 1)</p>\n",
" Prediction fail rate: 0.4\n",
" <p>Prediction time: 9.8 s.</p>\n",
" "
],
"text/plain": [
"\n",
" Test \"NME_mean\" succeeded\n",
" Description: Mean of normalised mean Euclidean distances across images\n",
" Metric: 0.3962 (threshold = 1)\n",
" Prediction fail rate: 0.4\n",
" Prediction time: 9.8 s.\n",
" "
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"from loreal_poc.marks.facial_parts import FacialParts\n",
"from loreal_poc.dataloaders.wrappers import CroppedDataLoader, CachedDataLoader\n",
"\n",
"facial_part = FacialParts.LEFT_HALF.value\n",
"facial_part = FacialParts.left_half\n",
"\n",
"TestDiff(metric=NMEMean, threshold=1).run(model, ds, CroppedDataLoader(ds, part=facial_part), facial_part=facial_part)"
]
Expand Down
114 changes: 12 additions & 102 deletions examples/ex5_models_comparison.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,118 +46,23 @@
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'cpu'"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import torch\n",
"\n",
"device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
"device"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"facealignment_model = FaceAlignmentWrapper(model=FaceAlignment(LandmarksType.TWO_D, device=\"cpu\", flip_input=False))\n",
"opencv_model = OpenCVWrapper()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'test_name': 'Test',\n",
" 'metric_name': 'NME_mean',\n",
" 'metric_value': 0.04136279942306024,\n",
" 'threshold': 1,\n",
" 'passed': True,\n",
" 'facial_part': 'entire face',\n",
" 'model_name': 'OpenCV',\n",
" 'dataloader_name': '300W'}"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"test = Test(metric=NMEMean, threshold=1).run(model=opencv_model, dataloader=dl)\n",
"\n",
"test.to_dict()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"name": "stdout",
"output_type": "stream",
"text": [
"/Users/bazire/Work/loreal-poc/loreal_poc/tests/performance.py:47: RuntimeWarning: Mean of empty slice\n",
" mes = np.nanmean(es, axis=1)\n"
"loading data from : lbfmodel.yaml\n"
]
},
{
"data": {
"text/plain": [
"{'test_name': 'TestDiff',\n",
" 'metric_name': 'NME_mean',\n",
" 'metric_value': 0.39174846002334746,\n",
" 'threshold': 1,\n",
" 'passed': True,\n",
" 'facial_part': 'left half',\n",
" 'model_name': 'OpenCV',\n",
" 'dataloader_name': '300W'}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from loreal_poc.marks.facial_parts import FacialParts\n",
"\n",
"facial_part = FacialParts.LEFT_HALF.value\n",
"\n",
"test_diff = TestDiff(metric=NMEMean, threshold=1).run(\n",
" model=opencv_model, dataloader=dl, dataloader_ref=CroppedDataLoader(dl, part=facial_part), facial_part=facial_part\n",
")\n",
"test_diff.to_dict()"
"facealignment_model = FaceAlignmentWrapper(model=FaceAlignment(LandmarksType.TWO_D, device=\"cpu\", flip_input=False))\n",
"opencv_model = OpenCVWrapper()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/bazire/Work/loreal-poc/loreal_poc/tests/performance.py:85: RuntimeWarning: Mean of empty slice\n",
" return np.nanmean(NMEs.get(prediction_result, marks))\n"
]
}
],
"outputs": [],
"source": [
"# from dataclasses import fields\n",
"def create_report(models, dataloader, tests, facial_parts):\n",
Expand All @@ -177,7 +82,12 @@
" return results\n",
"\n",
"\n",
"report = report([opencv_model], dl, [TestDiff], [FacialParts.BOTTOM_HALF.value, FacialParts.UPPER_HALF.value])"
"report = create_report(\n",
" [opencv_model, facealignment_model],\n",
" dl,\n",
" [TestDiff],\n",
" [FacialParts.bottom_half, FacialParts.upper_half, FacialParts.left_half, FacialParts.right_half],\n",
")"
]
},
{
Expand Down
1,286 changes: 42 additions & 1,244 deletions examples/ex6_cropping.ipynb

Large diffs are not rendered by default.

You are viewing a condensed version of this merge commit. You can view the full changes here.