Computer_Vision/Chapter05/2D_and_3D_facial_keypoints.ipynb

844 lines
200 KiB
Plaintext
Raw Normal View History

2024-02-13 03:34:51 +01:00
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "2D_and_3D_facial_keypoints.ipynb",
"provenance": [],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"b4b2d80c111844cdbdb91fd51db71802": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_14d36861288a47c38570768bb533f177",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_356d2389955d4146adb1d864adfc0a78",
"IPY_MODEL_3f591e1bf0054e68aad1e045bab68951"
]
}
},
"14d36861288a47c38570768bb533f177": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"356d2389955d4146adb1d864adfc0a78": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_4f6e88842fc84f1eb084863b108d392b",
"_dom_classes": [],
"description": "100%",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 89843225,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 89843225,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_2c2d137aa6064e7589402691fc6a4b30"
}
},
"3f591e1bf0054e68aad1e045bab68951": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_355a5b355ccc4e64821d13bac0ca5cea",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 85.7M/85.7M [00:10<00:00, 8.48MB/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_deab2a6754cd4bc382ed3842e6ea7218"
}
},
"4f6e88842fc84f1eb084863b108d392b": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"2c2d137aa6064e7589402691fc6a4b30": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"355a5b355ccc4e64821d13bac0ca5cea": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"deab2a6754cd4bc382ed3842e6ea7218": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"4b1403989c2a422ebc5efd0e9b78a5d6": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_a8bb45a140bc4c2aa7c7cd88e72ce93d",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_cbcdee74f0c84962bc59c0c6597dd314",
"IPY_MODEL_b9721ca3e1b54772aa643710b1dc8a2f"
]
}
},
"a8bb45a140bc4c2aa7c7cd88e72ce93d": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"cbcdee74f0c84962bc59c0c6597dd314": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_771d11a506e54f4dbcdc933c972b9548",
"_dom_classes": [],
"description": "100%",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 95641761,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 95641761,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_148f9cc1be48436e99aadd1094eac66b"
}
},
"b9721ca3e1b54772aa643710b1dc8a2f": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_06c347e7481c48d99872ae64faac6909",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 91.2M/91.2M [00:11<00:00, 8.15MB/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_cd2e21545bd845dbb1b86c23632a06cf"
}
},
"771d11a506e54f4dbcdc933c972b9548": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"148f9cc1be48436e99aadd1094eac66b": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"06c347e7481c48d99872ae64faac6909": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"cd2e21545bd845dbb1b86c23632a06cf": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
}
}
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/PacktPublishing/Hands-On-Computer-Vision-with-PyTorch/blob/master/Chapter05/2D_and_3D_facial_keypoints.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "y6uKvT0pYKMz",
"outputId": "dcf0c23d-336e-40fe-89bf-d5dd5724155a",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 90
}
},
"source": [
"!pip install -qU face-alignment torch_snippets\n",
"import face_alignment\n",
"from torch_snippets import read, show"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"text": [
"\u001b[K |████████████████████████████████| 61kB 3.0MB/s \n",
"\u001b[K |████████████████████████████████| 36.7MB 102kB/s \n",
"\u001b[K |████████████████████████████████| 102kB 9.2MB/s \n",
"\u001b[?25h Building wheel for contextvars (setup.py) ... \u001b[?25l\u001b[?25hdone\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "-Clg3nhWYRqL",
"outputId": "8ff6d292-3842-45a4-ccb0-99974624f04b",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 401
}
},
"source": [
"!wget https://www.dropbox.com/s/2s7xjto7rb6q7dc/Hema.JPG"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"text": [
"--2020-10-09 08:02:03-- https://www.dropbox.com/s/2s7xjto7rb6q7dc/Hema.JPG\n",
"Resolving www.dropbox.com (www.dropbox.com)... 162.125.82.1, 2620:100:6032:1::a27d:5201\n",
"Connecting to www.dropbox.com (www.dropbox.com)|162.125.82.1|:443... connected.\n",
"HTTP request sent, awaiting response... 301 Moved Permanently\n",
"Location: /s/raw/2s7xjto7rb6q7dc/Hema.JPG [following]\n",
"--2020-10-09 08:02:03-- https://www.dropbox.com/s/raw/2s7xjto7rb6q7dc/Hema.JPG\n",
"Reusing existing connection to www.dropbox.com:443.\n",
"HTTP request sent, awaiting response... 302 Found\n",
"Location: https://uca0ee1ba76a0f56bcee98526bc1.dl.dropboxusercontent.com/cd/0/inline/BA7fn6ZPDWTae24PrMX4XwIJ4lbJZ18gdShIGu-rk1drszqsCZvrQRPHHwK8v9h_-JIpKYEE_ux3KvkpP122xv_FA03pu12Q-HF4TqQh8RV1GRpPpC1AAXn1K67aiWHyCtw/file# [following]\n",
"--2020-10-09 08:02:04-- https://uca0ee1ba76a0f56bcee98526bc1.dl.dropboxusercontent.com/cd/0/inline/BA7fn6ZPDWTae24PrMX4XwIJ4lbJZ18gdShIGu-rk1drszqsCZvrQRPHHwK8v9h_-JIpKYEE_ux3KvkpP122xv_FA03pu12Q-HF4TqQh8RV1GRpPpC1AAXn1K67aiWHyCtw/file\n",
"Resolving uca0ee1ba76a0f56bcee98526bc1.dl.dropboxusercontent.com (uca0ee1ba76a0f56bcee98526bc1.dl.dropboxusercontent.com)... 162.125.82.15, 2620:100:6032:15::a27d:520f\n",
"Connecting to uca0ee1ba76a0f56bcee98526bc1.dl.dropboxusercontent.com (uca0ee1ba76a0f56bcee98526bc1.dl.dropboxusercontent.com)|162.125.82.15|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 12860 (13K) [image/jpeg]\n",
"Saving to: Hema.JPG\n",
"\n",
"Hema.JPG 100%[===================>] 12.56K --.-KB/s in 0s \n",
"\n",
"2020-10-09 08:02:04 (279 MB/s) - Hema.JPG saved [12860/12860]\n",
"\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "pQEPhphbYTXy",
"outputId": "3303fac5-efbb-4c52-829e-d0ba807a4256",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 174,
"referenced_widgets": [
"b4b2d80c111844cdbdb91fd51db71802",
"14d36861288a47c38570768bb533f177",
"356d2389955d4146adb1d864adfc0a78",
"3f591e1bf0054e68aad1e045bab68951",
"4f6e88842fc84f1eb084863b108d392b",
"2c2d137aa6064e7589402691fc6a4b30",
"355a5b355ccc4e64821d13bac0ca5cea",
"deab2a6754cd4bc382ed3842e6ea7218",
"4b1403989c2a422ebc5efd0e9b78a5d6",
"a8bb45a140bc4c2aa7c7cd88e72ce93d",
"cbcdee74f0c84962bc59c0c6597dd314",
"b9721ca3e1b54772aa643710b1dc8a2f",
"771d11a506e54f4dbcdc933c972b9548",
"148f9cc1be48436e99aadd1094eac66b",
"06c347e7481c48d99872ae64faac6909",
"cd2e21545bd845dbb1b86c23632a06cf"
]
}
},
"source": [
"fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, flip_input=False, device='cpu')"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"text": [
"Downloading: \"https://www.adrianbulat.com/downloads/python-fan/s3fd-619a316812.pth\" to /root/.cache/torch/hub/checkpoints/s3fd-619a316812.pth\n"
],
"name": "stderr"
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b4b2d80c111844cdbdb91fd51db71802",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, max=89843225.0), HTML(value='')))"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n"
],
"name": "stdout"
},
{
"output_type": "stream",
"text": [
"Downloading: \"https://www.adrianbulat.com/downloads/python-fan/2DFAN4-11f355bf06.pth.tar\" to /root/.cache/torch/hub/checkpoints/2DFAN4-11f355bf06.pth.tar\n"
],
"name": "stderr"
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4b1403989c2a422ebc5efd0e9b78a5d6",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, max=95641761.0), HTML(value='')))"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "qA17vm9lYU1b",
"outputId": "44047c29-adce-4c09-e772-b31a8b4ec25c",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
}
},
"source": [
"input = read('Hema.JPG', 1)\n",
"preds = fa.get_landmarks(input)[0]\n",
"print(preds.shape)"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"text": [
"(68, 3)\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "NWdyl9XaYWfF",
"outputId": "a841a4bc-d724-46b2-ddab-add9ecefbaa8",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 303
}
},
"source": [
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"fig,ax = plt.subplots(figsize=(5,5))\n",
"show(read('Hema.JPG',1), ax=ax)\n",
"ax.scatter(preds[:,0], preds[:,1], marker='+', c='r')\n",
"plt.show()"
],
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAARwAAAEeCAYAAABYPKrrAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nOy92ZokSXKd+auqrb7FlkstXWiwCZDE4GZ4McMnmQeZh5sH4DUHADloApiP3V1A15KVmZGx+GaLbnMhqmYekUtldReaF5NaX5RneLibm+sieuTIEVEVY+RT+9Q+tU/tT9H0/+wb+NQ+tU/t/z/tk8H51D61T+1P1j4ZnE/tU/vU/mTtk8H51D61T+1P1j4ZnE/tU/vU/mTtk8H51D61T+1P1ooP/fE//1//OQIopVAqPxvT/+OD30//Pb8WvPfkawDEKD/GGIqikN/DfI0QIn3fo5Tm2bNnNE2b3hMJIRBCmD8tRmKMOOcYho4QQvq8+d6894Tgp3sex5FhGLB2pO87rLXs93u8d/R9T4yBsixRStF1HeM48vLVC25urun7I93xQFkWtG3DarXmq6/+nLquaZsVWmtGGwDFZ599wXq9Zru953DYc39/z+3tG6wb6IYjx+OBl69eEIKnKAxaa9q2oSwLnn32GcvVevq+n3/2BV999edUZcWiaTHaUJoahYbI1D+nTSmN1mbq+9z/+bHve/7lm98TQuAv/uIv2Gw21HWNMQZrLdbaqX9P+z2/3/lAjBHvIyFGttstfd9DCMTgidETg2e1WvDs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E8sVy2gc
"text/plain": [
"<Figure size 360x360 with 1 Axes>"
]
},
"metadata": {
"tags": [],
"needs_background": "light"
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "gYllyWUEYX8R",
"outputId": "323d322a-056f-4c10-bb98-1e47e7e712df",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 542
}
},
"source": [
"fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._3D, flip_input=False, device='cpu')\n",
"input = read('Hema.JPG', 1)\n",
"preds = fa.get_landmarks(input)[0]\n",
"import pandas as pd\n",
"df = pd.DataFrame(preds)\n",
"df.columns = ['x','y','z']\n",
"import plotly.express as px\n",
"fig = px.scatter_3d(df, x = 'x', y = 'y', z = 'z')\n",
"fig.show()"
],
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/html": [
"<html>\n",
"<head><meta charset=\"utf-8\" /></head>\n",
"<body>\n",
" <div>\n",
" <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>\n",
" <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
" <script src=\"https://cdn.plot.ly/plotly-latest.min.js\"></script> \n",
" <div id=\"322d56bd-296b-47cf-842b-dddbae622369\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>\n",
" <script type=\"text/javascript\">\n",
" \n",
" window.PLOTLYENV=window.PLOTLYENV || {};\n",
" \n",
" if (document.getElementById(\"322d56bd-296b-47cf-842b-dddbae622369\")) {\n",
" Plotly.newPlot(\n",
" '322d56bd-296b-47cf-842b-dddbae622369',\n",
" [{\"hoverlabel\": {\"namelength\": 0}, \"hovertemplate\": \"x=%{x}<br>y=%{y}<br>z=%{z}\", \"legendgroup\": \"\", \"marker\": {\"color\": \"#636efa\", \"symbol\": \"circle\"}, \"mode\": \"markers\", \"name\": \"\", \"scene\": \"scene\", \"showlegend\": false, \"type\": \"scatter3d\", \"x\": [27.0, 30.0, 31.0, 33.0, 35.0, 39.0, 42.0, 48.0, 57.0, 68.0, 76.0, 82.0, 87.0, 90.0, 92.0, 93.0, 93.0, 30.0, 32.0, 37.0, 41.0, 46.0, 62.0, 65.0, 71.0, 77.0, 82.0, 54.0, 54.0, 54.0, 54.0, 49.0, 52.0, 55.0, 59.0, 61.0, 35.0, 38.0, 42.0, 46.0, 42.0, 39.0, 64.0, 68.0, 71.0, 76.0, 72.0, 68.0, 46.0, 48.0, 53.0, 55.0, 57.0, 63.0, 68.0, 63.0, 60.0, 55.0, 52.0, 48.0, 46.0, 52.0, 55.0, 59.0, 67.0, 59.0, 55.0, 52.0], \"y\": [63.0, 71.0, 79.0, 86.0, 93.0, 98.0, 102.0, 104.0, 107.0, 103.0, 100.0, 96.0, 89.0, 82.0, 74.0, 66.0, 58.0, 54.0, 52.0, 51.0, 50.0, 51.0, 50.0, 48.0, 48.0, 48.0, 50.0, 59.0, 65.0, 71.0, 75.0, 78.0, 79.0, 79.0, 78.0, 78.0, 60.0, 59.0, 58.0, 59.0, 61.0, 61.0, 58.0, 56.0, 56.0, 57.0, 59.0, 59.0, 88.0, 86.0, 85.0, 85.0, 83.0, 86.0, 87.0, 90.0, 91.0, 93.0, 93.0, 90.0, 88.0, 88.0, 87.0, 87.0, 87.0, 88.0, 88.0, 88.0], \"z\": [-27.68233299255371, -28.37238311767578, -28.729385375976562, -27.933229446411133, -24.12045669555664, -16.820131301879883, -7.749030590057373, 0.9689182639122009, 5.48545503616333, 2.6860780715942383, -4.400628566741943, -12.421307563781738, -18.678613662719727, -21.614439010620117, -21.823501586914062, -21.041954040527344, -19.985063552856445, 3.8201372623443604, 9.531163215637207, 13.437037467956543, 15.872093200683594, 16.996686935424805, 19.374963760375977, 19.23256492614746, 17.92388916015625, 15.308772087097168, 10.421875, 17.0435848236084, 19.463165283203125, 22.750356674194336, 22.719547271728516, 13.829131126403809, 15.331435203552246, 16.305931091308594, 15.909503936767578, 14.878844261169434, 7.057541847229004, 10.965619087219238, 11.731825828552246, 10.690513610839844, 11.214056015014648, 9.811735153198242, 13.373595237731934, 15.314264297485352, 15.625443458557129, 12.25173568725586, 14.235583305358887, 14.656786918640137, 8.953569412231445, 13.679680824279785, 16.57196617126465, 17.15587615966797, 17.085573196411133, 14.777618408203125, 10.468396186828613, 13.696341514587402, 15.009588241577148, 14.991573333740234, 14.3329439163208, 12.554258346557617, 9.250266075134277, 14.560050010681152, 15.507245063781738, 15.07995891571045, 10.491459846496582, 15.02928352355957, 15.036974906921387, 14.468173027038574]}],\n",
" {\"legend\": {\"tracegroupgap\": 0}, \"margin\": {\"t\": 60}, \"scene\": {\"domain\": {\"x\": [0.0, 1.0], \"y\": [0.0, 1.0]}, \"xaxis\": {\"title\": {\"text\": \"x\"}}, \"yaxis\": {\"title\": {\"text\": \"y\"}}, \"zaxis\": {\"title\": {\"text\": \"z\"}}}, \"template\": {\"data\": {\"bar\": [{\"error_x\": {\"color\": \"#2a3f5f\"}, \"error_y\": {\"color\": \"#2a3f5f\"}, \"marker\": {\"line\": {\"color\": \"#E5ECF6\", \"width\": 0.5}}, \"type\": \"bar\"}], \"barpolar\": [{\"marker\": {\"line\": {\"color\": \"#E5ECF6\", \"width\": 0.5}}, \"type\": \"barpolar\"}], \"carpet\": [{\"aaxis\": {\"endlinecolor\": \"#2a3f5f\", \"gridcolor\": \"white\", \"linecolor\": \"white\", \"minorgridcolor\": \"white\", \"startlinecolor\": \"#2a3f5f\"}, \"baxis\": {\"endlinecolor\": \"#2a3f5f\", \"gridcolor\": \"white\", \"linecolor\": \"white\", \"minorgridcolor\": \"white\", \"startlinecolor\": \"#2a3f5f\"}, \"type\": \"carpet\"}], \"choropleth\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"type\": \"choropleth\"}], \"contour\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"colorscale\": [[0.0, \"#0d0887\"], [0.1111111111111111, \"#46039f\"], [0.2222222222222222, \"#7201a8\"], [0.3333333333333333, \"#9c179e\"], [0.4444444444444444, \"#bd3786\"], [0.5555555555555556, \"#d8576b\"], [0.6666666666666666, \"#ed7953\"], [0.7777777777777778, \"#fb9f3a\"], [0.8888888888888888, \"#fdca26\"], [1.0, \"#f0f921\"]], \"type\": \"contour\"}], \"contourcarpet\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"type\": \"contourcarpet\"}], \"heatmap\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"colorscale\": [[0.0, \"#0d0887\"], [0.1111111111111111, \"#46039f\"], [0.2222222222222222, \"#7201a8\"], [0.3333333333333333, \"#9c179e\"], [0.4444444444444444, \"#bd3786\"], [0.5555555555555556, \"#d8576b\"], [0.6666666666666666, \"#ed7953\"], [0.7777777777777778, \"#fb9f3a\"], [0.8888888888888888, \"#fdca26\"], [1.0, \"#f0f921\"]], \"type\": \"heatmap\"}], \"heatmapgl\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"colorscale\": [[0.0, \"#0d0887\"], [0.1111111111111111, \"#46039f\"], [0.2222222222222222, \"#7201a8\"], [0.3333333333333333, \"#9c179e\"], [0.4444444444444444, \"#bd3786\"], [0.5555555555555556, \"#d8576b\"], [0.6666666666666666, \"#ed7953\"], [0.7777777777777778, \"#fb9f3a\"], [0.8888888888888888, \"#fdca26\"], [1.0, \"#f0f921\"]], \"type\": \"heatmapgl\"}], \"histogram\": [{\"marker\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"type\": \"histogram\"}], \"histogram2d\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"colorscale\": [[0.0, \"#0d0887\"], [0.1111111111111111, \"#46039f\"], [0.2222222222222222, \"#7201a8\"], [0.3333333333333333, \"#9c179e\"], [0.4444444444444444, \"#bd3786\"], [0.5555555555555556, \"#d8576b\"], [0.6666666666666666, \"#ed7953\"], [0.7777777777777778, \"#fb9f3a\"], [0.8888888888888888, \"#fdca26\"], [1.0, \"#f0f921\"]], \"type\": \"histogram2d\"}], \"histogram2dcontour\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"colorscale\": [[0.0, \"#0d0887\"], [0.1111111111111111, \"#46039f\"], [0.2222222222222222, \"#7201a8\"], [0.3333333333333333, \"#9c179e\"], [0.4444444444444444, \"#bd3786\"], [0.5555555555555556, \"#d8576b\"], [0.6666666666666666, \"#ed7953\"], [0.7777777777777778, \"#fb9f3a\"], [0.8888888888888888, \"#fdca26\"], [1.0, \"#f0f921\"]], \"type\": \"histogram2dcontour\"}], \"mesh3d\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"type\": \"mesh3d\"}], \"parcoords\": [{\"line\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"type\": \"parcoords\"}], \"pie\": [{\"automargin\": true, \"type\": \"pie\"}], \"scatter\": [{\"marker\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"type\": \"scatter\"}], \"scatter3d\": [{\"line\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"marker\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"type\": \"scatter3d\"}], \"scattercarpet\": [{\"marker\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\
" {\"responsive\": true}\n",
" ).then(function(){\n",
" \n",
"var gd = document.getElementById('322d56bd-296b-47cf-842b-dddbae622369');\n",
"var x = new MutationObserver(function (mutations, observer) {{\n",
" var display = window.getComputedStyle(gd).display;\n",
" if (!display || display === 'none') {{\n",
" console.log([gd, 'removed!']);\n",
" Plotly.purge(gd);\n",
" observer.disconnect();\n",
" }}\n",
"}});\n",
"\n",
"// Listen for the removal of the full notebook cells\n",
"var notebookContainer = gd.closest('#notebook-container');\n",
"if (notebookContainer) {{\n",
" x.observe(notebookContainer, {childList: true});\n",
"}}\n",
"\n",
"// Listen for the clearing of the current output cell\n",
"var outputEl = gd.closest('.output');\n",
"if (outputEl) {{\n",
" x.observe(outputEl, {childList: true});\n",
"}}\n",
"\n",
" })\n",
" };\n",
" \n",
" </script>\n",
" </div>\n",
"</body>\n",
"</html>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Fycmc1rFYa8v"
},
"source": [
""
],
"execution_count": null,
"outputs": []
}
]
}