From 6e654ee939c40e8459fb743a2fedf5e97f92c538 Mon Sep 17 00:00:00 2001 From: 1a8fa007520eaf08a0ff2aa23436817a <1a8fa007520eaf08a0ff2aa23436817a@app-learninglab.inria.fr> Date: Thu, 20 Aug 2020 14:28:59 +0000 Subject: [PATCH] update --- module2/exo4/exercice.ipynb | 3408 ++++++++++++++++++++++++++++++++++- 1 file changed, 3320 insertions(+), 88 deletions(-) diff --git a/module2/exo4/exercice.ipynb b/module2/exo4/exercice.ipynb index e7d9051..36b0ada 100644 --- a/module2/exo4/exercice.ipynb +++ b/module2/exo4/exercice.ipynb @@ -16,43 +16,20 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 140, "metadata": { "hideCode": false, "hideOutput": true, "hidePrompt": false }, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.\n", - "Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.\n", - "To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.\n" - ] - }, { "name": "stdout", "output_type": "stream", "text": [ - "Collecting plotly\n", - " Downloading plotly-4.9.0-py2.py3-none-any.whl (12.9 MB)\n", + "Requirement already satisfied: plotly in /opt/conda/lib/python3.6/site-packages (4.9.0)\n", "Requirement already satisfied: six in /opt/conda/lib/python3.6/site-packages (from plotly) (1.14.0)\n", - "Collecting retrying>=1.3.3\n", - " Downloading retrying-1.3.3.tar.gz (10 kB)\n", - "Building wheels for collected packages: retrying\n", - " Building wheel for retrying (setup.py): started\n", - " Building wheel for retrying (setup.py): finished with status 'done'\n", - " Created wheel for retrying: filename=retrying-1.3.3-py3-none-any.whl size=11430 sha256=aadcf7c4fb481ad4c17a17895314b11482e582e1588b81c4feca2294d100700d\n", - " Stored in directory: /home/jovyan/.cache/pip/wheels/ac/cb/8a/b27bf6323e2f4c462dcbf77d70b7c5e7868a7fbe12871770cf\n", - "Successfully built retrying\n", - "Installing collected packages: retrying, plotly\n", - "Successfully installed plotly-4.9.0 retrying-1.3.3\n", - "Collecting pyquaternion\n", - " Downloading pyquaternion-0.9.5-py3-none-any.whl (14 kB)\n", - "Requirement already satisfied: numpy in /opt/conda/lib/python3.6/site-packages (from pyquaternion) (1.15.2)\n", - "Installing collected packages: pyquaternion\n" + "Requirement already satisfied: retrying>=1.3.3 in /opt/conda/lib/python3.6/site-packages (from plotly) (1.3.3)\n" ] }, { @@ -68,16 +45,17 @@ "name": "stdout", "output_type": "stream", "text": [ - "Successfully installed pyquaternion-0.9.5\n", - "Collecting xmltodict\n", - " Downloading xmltodict-0.12.0-py2.py3-none-any.whl (9.2 kB)\n", - "Installing collected packages: xmltodict\n" + "Requirement already satisfied: pyquaternion in /opt/conda/lib/python3.6/site-packages (0.9.5)\n", + "Requirement already satisfied: numpy in /opt/conda/lib/python3.6/site-packages (from pyquaternion) (1.15.2)\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ + "WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.\n", + "Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.\n", + "To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.\n", "WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.\n", "Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.\n", "To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.\n" @@ -87,7 +65,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Successfully installed xmltodict-0.12.0\n" + "Requirement already satisfied: xmltodict in /opt/conda/lib/python3.6/site-packages (0.12.0)\n" ] } ], @@ -124,7 +102,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 141, "metadata": { "hideCode": true, "hideOutput": true, @@ -380,7 +358,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 142, "metadata": {}, "outputs": [], "source": [ @@ -392,7 +370,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 143, "metadata": {}, "outputs": [], "source": [ @@ -419,18 +397,18 @@ " Z = [0, 0, 0, 0, 1, 1, 1, 1]\n", "\n", " # Properties to unrotated vertices\n", - " x = [cx + (-0.5 * dx if v == 0 else 0.5 * dx) for v in X]\n", - " y = [cy + (-0.5 * dy if v == 0 else 0.5 * dy) for v in Y]\n", - " z = [cz + (-0.5 * dz if v == 0 else 0.5 * dz) for v in Z]\n", + " x = [(-0.5 * dx if v == 0 else 0.5 * dx) for v in X]\n", + " y = [(-0.5 * dy if v == 0 else 0.5 * dy) for v in Y]\n", + " z = [(-0.5 * dz if v == 0 else 0.5 * dz) for v in Z]\n", " unrotated_vertices = zip(x, y, z)\n", " \n", " # Apply quaternion\n", - " quaternion = pyquaternion.Quaternion(qw, qx, qy, qz)\n", - " unrotated_vectors = [(v[0] - cx, v[1] - cy, v[2] - cz) for v in unrotated_vertices]\n", - " vectors = [quaternion.rotate(v) for v in unrotated_vectors]\n", - " vertices = [(v[0] + cx, v[1] + cy, v[2] + cz) for v in vectors]\n", + "# quaternion = pyquaternion.Quaternion(qw, qx, qy, qz)\n", + "# unrotated_vectors = [(v[0] - cx, v[1] - cy, v[2] - cz) for v in unrotated_vertices]\n", + "# vectors = [quaternion.rotate(v) for v in unrotated_vectors]\n", + "# vertices = [(v[0] + cx, v[1] + cy, v[2] + cz) for v in vectors]\n", " \n", - " x, y, z = zip(*vertices)\n", + " x, y, z = zip(*unrotated_vertices)\n", " \n", " return x, y, z\n", "\n", @@ -463,16 +441,14 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 153, "metadata": {}, "outputs": [], "source": [ "import plotly.graph_objects as go\n", "import numpy as np\n", "\n", - "def label_to_mesh_3d(label, color='magenta'):\n", - "# x, y, z = obbox_properties_to_vertices(label['@obbox'])\n", - " x, y, z = aabbox_properties_to_vertices(label['@aabbox'])\n", + "def vertices_to_mesh_3d(x, y, z, name='unknown_label', color='magenta'):\n", " mesh_3d = go.Mesh3d(\n", " x=x, y=y, z=z,\n", " color=color,\n", @@ -481,7 +457,7 @@ " i = [7, 0, 0, 0, 4, 4, 6, 6, 4, 0, 3, 2],\n", " j = [3, 4, 1, 2, 5, 6, 5, 2, 0, 1, 6, 3],\n", " k = [0, 7, 2, 3, 6, 7, 1, 1, 5, 5, 7, 6],\n", - " name=label['@nyu_class'],\n", + " name=name,\n", " showscale=True\n", " )\n", " return mesh_3d\n", @@ -508,7 +484,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 154, "metadata": { "scrolled": true }, @@ -569,34 +545,34 @@ "showscale": true, "type": "mesh3d", "x": [ - -3.6886965305184787, - -3.6248609873006448, - 1.1315826823865907, - 1.0677471391687567, - -3.5621826823865907, - -3.498347139168757, - 1.2580965305184786, - 1.1942609873006447 + -2.38028, + -2.38028, + 2.38028, + 2.38028, + -2.38028, + -2.38028, + 2.38028, + 2.38028 ], "y": [ - -1.039569781668396, - -3.931327300833111, - -3.8171381678029768, - -0.9253806486382623, - -1.240321832197023, - -4.132079351361738, - -4.017890218331604, - -1.1261326991668894 + -1.448565, + 1.448565, + 1.448565, + -1.448565, + -1.448565, + 1.448565, + 1.448565, + -1.448565 ], "z": [ - -0.2734329098196713, - -0.10903792608714347, - 0.05262831216329, - -0.11176667156923759, - -3.8538483121632896, - -3.689453328430762, - -3.527787090180328, - -3.692182073912856 + -1.794135, + -1.794135, + -1.794135, + -1.794135, + 1.794135, + 1.794135, + 1.794135, + 1.794135 ] } ], @@ -1412,20 +1388,20 @@ "
\n", " \n", " \n", - "
\n", + "
\n", "