Update cdb

parent 3e16bd20
...@@ -371,26 +371,26 @@ ...@@ -371,26 +371,26 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 20, "execution_count": 37,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"import pyquaternion\n", "import pyquaternion\n",
"\n", "\n",
"def obbox_properties_to_vertices(obbox_properties)\n", "def obbox_properties_to_vertices(obbox_properties):\n",
" \"\"\"\n", " \"\"\"\n",
" Convert 3D box properties (center, dimensions, and quaternion)\n", " Convert 3D box properties (center, dimensions, and quaternion)\n",
" \"\"\"\n", " \"\"\"\n",
" if isinstance(obbox_properties, str):\n", " if isinstance(obbox_properties, str):\n",
" obbox_properties = a = map(float, obbox_properties.split())\n", " obbox_properties = list(map(float, obbox_properties.split()))\n",
" \n", " \n",
"# TODO ADD EXTRA CHECKS\n", "# TODO ADD EXTRA CHECKS\n",
"# if isinstance(obbox_properties, iterable) and len(obbox_properties == 10) and \n", "# if isinstance(obbox_properties, iterable) and len(obbox_properties == 10) and \n",
" \n", " \n",
" # Extract properties\n", " # Extract properties\n",
" cx, cy, cz = [0:3]\n", " cx, cy, cz = obbox_properties[0:3]\n",
" dx, dy, dz = [3:6]\n", " dx, dy, dz = obbox_properties[3:6]\n",
" qx, qy, qz, qw = [6:10]\n", " qx, qy, qz, qw = obbox_properties[6:10]\n",
"\n", "\n",
" # Constants for converting properties to vertices\n", " # Constants for converting properties to vertices\n",
" X = [0, 0, 1, 1, 0, 0, 1, 1]\n", " X = [0, 0, 1, 1, 0, 0, 1, 1]\n",
...@@ -398,9 +398,9 @@ ...@@ -398,9 +398,9 @@
" Z = [0, 0, 0, 0, 1, 1, 1, 1]\n", " Z = [0, 0, 0, 0, 1, 1, 1, 1]\n",
"\n", "\n",
" # Properties to unrotated vertices\n", " # Properties to unrotated vertices\n",
" x = [c_x + (-0.5 * d_x if v == 0 else 0.5 * d_x) for v in X]\n", " x = [cx + (-0.5 * dx if v == 0 else 0.5 * dx) for v in X]\n",
" y = [c_y + (-0.5 * d_y if v == 0 else 0.5 * d_y) for v in Y]\n", " y = [cy + (-0.5 * dy if v == 0 else 0.5 * dy) for v in Y]\n",
" z = [c_z + (-0.5 * d_z if v == 0 else 0.5 * d_z) for v in Z]\n", " z = [cz + (-0.5 * dz if v == 0 else 0.5 * dz) for v in Z]\n",
" unrotated_vertices = zip(x, y, z)\n", " unrotated_vertices = zip(x, y, z)\n",
" \n", " \n",
" # Apply quaternion\n", " # Apply quaternion\n",
...@@ -411,85 +411,1331 @@ ...@@ -411,85 +411,1331 @@
" \n", " \n",
" x, y, z = zip(*vertices)\n", " x, y, z = zip(*vertices)\n",
" \n", " \n",
" return x, y, z\n", " return x, y, z"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [],
"source": [
"import plotly.graph_objects as go\n",
"import numpy as np\n",
"\n", "\n",
"def box_vertices" "def label_to_mesh_3d(label, color='magenta'):\n",
" x, y, z = obbox_properties_to_vertices(label['@obbox'])\n",
" mesh_3d = go.Mesh3d(\n",
" x=x, y=y, z=z,\n",
" color=color,\n",
" opacity=0.5,\n",
" # i, j and k give the vertices of triangles\n",
" 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",
" showscale=True\n",
" )\n",
" return mesh_3d\n",
"\n",
"def plot_obbox(obbox):\n",
" x, y, z = obbox_properties_to_vertices(obbox)\n",
" fig = go.Figure(data=[\n",
" go.Mesh3d(\n",
" x=x, y=y, z=z,\n",
" color='magenta',\n",
" opacity=0.5,\n",
" # i, j and k give the vertices of triangles\n",
" 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='y',\n",
" showscale=True\n",
" )\n",
" ])\n",
" return fig\n",
"\n",
"# fig.show()"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 21, "execution_count": 52,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"color": "magenta",
"i": [
7,
0,
0,
0,
4,
4,
6,
6,
4,
0,
3,
2
],
"j": [
3,
4,
1,
2,
5,
6,
5,
2,
0,
1,
6,
3
],
"k": [
0,
7,
2,
3,
6,
7,
1,
1,
5,
5,
7,
6
],
"name": "y",
"opacity": 0.5,
"showscale": true,
"type": "mesh3d",
"x": [
-3.6886965305184787,
-3.6248609873006448,
1.1315826823865907,
1.0677471391687567,
-3.5621826823865907,
-3.498347139168757,
1.2580965305184786,
1.1942609873006447
],
"y": [
-1.039569781668396,
-3.931327300833111,
-3.8171381678029768,
-0.9253806486382623,
-1.240321832197023,
-4.132079351361738,
-4.017890218331604,
-1.1261326991668894
],
"z": [
-0.2734329098196713,
-0.10903792608714347,
0.05262831216329,
-0.11176667156923759,
-3.8538483121632896,
-3.689453328430762,
-3.527787090180328,
-3.692182073912856
]
}
],
"layout": {
"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,
"#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,
"#f0f921"
]
],
"type": "contour"
}
],
"contourcarpet": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "contourcarpet"
}
],
"heatmap": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
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,
"#f0f921"
]
],
"type": "heatmap"
}
],
"heatmapgl": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
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,
"#f0f921"
]
],
"type": "heatmapgl"
}
],
"histogram": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "histogram"
}
],
"histogram2d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
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,
"#f0f921"
]
],
"type": "histogram2d"
}
],
"histogram2dcontour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
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,
"#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": ""
}
},
"type": "scattercarpet"
}
],
"scattergeo": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergeo"
}
],
"scattergl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergl"
}
],
"scattermapbox": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattermapbox"
}
],
"scatterpolar": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolar"
}
],
"scatterpolargl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolargl"
}
],
"scatterternary": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterternary"
}
],
"surface": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
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,
"#f0f921"
]
],
"type": "surface"
}
],
"table": [
{
"cells": {
"fill": {
"color": "#EBF0F8"
},
"line": {
"color": "white"
}
},
"header": {
"fill": {
"color": "#C8D4E3"
},
"line": {
"color": "white"
}
},
"type": "table"
}
]
},
"layout": {
"annotationdefaults": {
"arrowcolor": "#2a3f5f",
"arrowhead": 0,
"arrowwidth": 1
},
"coloraxis": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"colorscale": {
"diverging": [
[
0,
"#8e0152"
],
[
0.1,
"#c51b7d"
],
[
0.2,
"#de77ae"
],
[
0.3,
"#f1b6da"
],
[
0.4,
"#fde0ef"
],
[
0.5,
"#f7f7f7"
],
[
0.6,
"#e6f5d0"
],
[
0.7,
"#b8e186"
],
[
0.8,
"#7fbc41"
],
[
0.9,
"#4d9221"
],
[
1,
"#276419"
]
],
"sequential": [
[
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,
"#f0f921"
]
],
"sequentialminus": [
[
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,
"#f0f921"
]
]
},
"colorway": [
"#636efa",
"#EF553B",
"#00cc96",
"#ab63fa",
"#FFA15A",
"#19d3f3",
"#FF6692",
"#B6E880",
"#FF97FF",
"#FECB52"
],
"font": {
"color": "#2a3f5f"
},
"geo": {
"bgcolor": "white",
"lakecolor": "white",
"landcolor": "#E5ECF6",
"showlakes": true,
"showland": true,
"subunitcolor": "white"
},
"hoverlabel": {
"align": "left"
},
"hovermode": "closest",
"mapbox": {
"style": "light"
},
"paper_bgcolor": "white",
"plot_bgcolor": "#E5ECF6",
"polar": {
"angularaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"radialaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"scene": {
"xaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"yaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"zaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
}
},
"shapedefaults": {
"line": {
"color": "#2a3f5f"
}
},
"ternary": {
"aaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"baxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"caxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"title": {
"x": 0.05
},
"xaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
},
"yaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
}
}
}
}
},
"text/html": [
"<div>\n",
" \n",
" \n",
" <div id=\"a2572bb8-2f68-4914-9e5d-faf6a569a205\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>\n",
" <script type=\"text/javascript\">\n",
" require([\"plotly\"], function(Plotly) {\n",
" window.PLOTLYENV=window.PLOTLYENV || {};\n",
" \n",
" if (document.getElementById(\"a2572bb8-2f68-4914-9e5d-faf6a569a205\")) {\n",
" Plotly.newPlot(\n",
" 'a2572bb8-2f68-4914-9e5d-faf6a569a205',\n",
" [{\"color\": \"magenta\", \"i\": [7, 0, 0, 0, 4, 4, 6, 6, 4, 0, 3, 2], \"j\": [3, 4, 1, 2, 5, 6, 5, 2, 0, 1, 6, 3], \"k\": [0, 7, 2, 3, 6, 7, 1, 1, 5, 5, 7, 6], \"name\": \"y\", \"opacity\": 0.5, \"showscale\": true, \"type\": \"mesh3d\", \"x\": [-3.6886965305184787, -3.6248609873006448, 1.1315826823865907, 1.0677471391687567, -3.5621826823865907, -3.498347139168757, 1.2580965305184786, 1.1942609873006447], \"y\": [-1.039569781668396, -3.931327300833111, -3.8171381678029768, -0.9253806486382623, -1.240321832197023, -4.132079351361738, -4.017890218331604, -1.1261326991668894], \"z\": [-0.2734329098196713, -0.10903792608714347, 0.05262831216329, -0.11176667156923759, -3.8538483121632896, -3.689453328430762, -3.527787090180328, -3.692182073912856]}],\n",
" {\"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\": \"\"}}, \"type\": \"scattercarpet\"}], \"scattergeo\": [{\"marker\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"type\": \"scattergeo\"}], \"scattergl\": [{\"marker\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"type\": \"scattergl\"}], \"scattermapbox\": [{\"marker\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"type\": \"scattermapbox\"}], \"scatterpolar\": [{\"marker\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"type\": \"scatterpolar\"}], \"scatterpolargl\": [{\"marker\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"type\": \"scatterpolargl\"}], \"scatterternary\": [{\"marker\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"type\": \"scatterternary\"}], \"surface\": [{\"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\": \"surface\"}], \"table\": [{\"cells\": {\"fill\": {\"color\": \"#EBF0F8\"}, \"line\": {\"color\": \"white\"}}, \"header\": {\"fill\": {\"color\": \"#C8D4E3\"}, \"line\": {\"color\": \"white\"}}, \"type\": \"table\"}]}, \"layout\": {\"annotationdefaults\": {\"arrowcolor\": \"#2a3f5f\", \"arrowhead\": 0, \"arrowwidth\": 1}, \"coloraxis\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"colorscale\": {\"diverging\": [[0, \"#8e0152\"], [0.1, \"#c51b7d\"], [0.2, \"#de77ae\"], [0.3, \"#f1b6da\"], [0.4, \"#fde0ef\"], [0.5, \"#f7f7f7\"], [0.6, \"#e6f5d0\"], [0.7, \"#b8e186\"], [0.8, \"#7fbc41\"], [0.9, \"#4d9221\"], [1, \"#276419\"]], \"sequential\": [[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\"]], \"sequentialminus\": [[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\"]]}, \"colorway\": [\"#636efa\", \"#EF553B\", \"#00cc96\", \"#ab63fa\", \"#FFA15A\", \"#19d3f3\", \"#FF6692\", \"#B6E880\", \"#FF97FF\", \"#FECB52\"], \"font\": {\"color\": \"#2a3f5f\"}, \"geo\": {\"bgcolor\": \"white\", \"lakecolor\": \"white\", \"landcolor\": \"#E5ECF6\", \"showlakes\": true, \"showland\": true, \"subunitcolor\": \"white\"}, \"hoverlabel\": {\"align\": \"left\"}, \"hovermode\": \"closest\", \"mapbox\": {\"style\": \"light\"}, \"paper_bgcolor\": \"white\", \"plot_bgcolor\": \"#E5ECF6\", \"polar\": {\"angularaxis\": {\"gridcolor\": \"white\", \"linecolor\": \"white\", \"ticks\": \"\"}, \"bgcolor\": \"#E5ECF6\", \"radialaxis\": {\"gridcolor\": \"white\", \"linecolor\": \"white\", \"ticks\": \"\"}}, \"scene\": {\"xaxis\": {\"backgroundcolor\": \"#E5ECF6\", \"gridcolor\": \"white\", \"gridwidth\": 2, \"linecolor\": \"white\", \"showbackground\": true, \"ticks\": \"\", \"zerolinecolor\": \"white\"}, \"yaxis\": {\"backgroundcolor\": \"#E5ECF6\", \"gridcolor\": \"white\", \"gridwidth\": 2, \"linecolor\": \"white\", \"showbackground\": true, \"ticks\": \"\", \"zerolinecolor\": \"white\"}, \"zaxis\": {\"backgroundcolor\": \"#E5ECF6\", \"gridcolor\": \"white\", \"gridwidth\": 2, \"linecolor\": \"white\", \"showbackground\": true, \"ticks\": \"\", \"zerolinecolor\": \"white\"}}, \"shapedefaults\": {\"line\": {\"color\": \"#2a3f5f\"}}, \"ternary\": {\"aaxis\": {\"gridcolor\": \"white\", \"linecolor\": \"white\", \"ticks\": \"\"}, \"baxis\": {\"gridcolor\": \"white\", \"linecolor\": \"white\", \"ticks\": \"\"}, \"bgcolor\": \"#E5ECF6\", \"caxis\": {\"gridcolor\": \"white\", \"linecolor\": \"white\", \"ticks\": \"\"}}, \"title\": {\"x\": 0.05}, \"xaxis\": {\"automargin\": true, \"gridcolor\": \"white\", \"linecolor\": \"white\", \"ticks\": \"\", \"title\": {\"standoff\": 15}, \"zerolinecolor\": \"white\", \"zerolinewidth\": 2}, \"yaxis\": {\"automargin\": true, \"gridcolor\": \"white\", \"linecolor\": \"white\", \"ticks\": \"\", \"title\": {\"standoff\": 15}, \"zerolinecolor\": \"white\", \"zerolinewidth\": 2}}}},\n",
" {\"responsive\": true}\n",
" ).then(function(){\n",
" \n",
"var gd = document.getElementById('a2572bb8-2f68-4914-9e5d-faf6a569a205');\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>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_obbox(sample_label['@obbox'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Take a look at the classes in the sample scene:"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"ename": "NameError", "data": {
"evalue": "name 'np' is not defined", "text/plain": [
"output_type": "error", "{'bag',\n",
"traceback": [ " 'bed',\n",
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", " 'bookshelf',\n",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", " 'box',\n",
"\u001b[0;32m<ipython-input-21-29c839d25695>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 11\u001b[0m [1, 'magenta']],\n\u001b[1;32m 12\u001b[0m \u001b[0;31m# Intensity of each vertex, which will be interpolated and color-coded\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 13\u001b[0;31m \u001b[0mintensity\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlinspace\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m12\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mendpoint\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 14\u001b[0m \u001b[0mintensitymode\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'cell'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[0;31m# i, j and k give the vertices of triangles\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", " 'cabinet',\n",
"\u001b[0;31mNameError\u001b[0m: name 'np' is not defined" " 'ceiling',\n",
] " 'chair',\n",
" 'desk',\n",
" 'door',\n",
" 'floor',\n",
" 'lamp',\n",
" 'prop',\n",
" 'shelves',\n",
" 'television',\n",
" 'towel',\n",
" 'unknown',\n",
" 'wall',\n",
" 'window'}"
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
} }
], ],
"source": [ "source": [
"import plotly.graph_objects as go\n", "classes = set()\n",
"fig = go.Figure(data=[\n", "for labebag',\n",
" go.Mesh3d(\n", " 'bed',\n",
" # 8 vertices of a cube\n", " 'bookshelf',\n",
" x=[0, 0, 1, 1, 0, 0, 1, 1],\n", " 'box',\n",
" y=[0, 1, 1, 0, 0, 1, 1, 0],\n", " 'cabinet',\n",
" z=[0, 0, 0, 0, 1, 1, 1, 1],\n", " 'ceiling',\n",
" colorbar_title='z',\n", " 'chair',\n",
" colorscale=[[0, 'gold'],\n", " 'desk',\n",
" [0.5, 'mediumturquoise'],\n", " 'door',\n",
" [1, 'magenta']],\n", " 'floor',\n",
" # Intensity of each vertex, which will be interpolated and color-coded\n", " 'lamp',\n",
" intensity = np.linspace(0, 1, 12, endpoint=True),\n", " 'prop',\n",
" intensitymode='cell',\n", " 'shelvel in labels:\n",
" # i, j and k give the vertices of triangles\n", " classes.add(label['@nyu_class'])\n",
" i = [7, 0, 0, 0, 4, 4, 6, 6, 4, 0, 3, 2],\n", "classes"
" 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='y',\n", {
" showscale=True\n", "cell_type": "markdown",
" )\n", "metadata": {},
"])\n", "source": [
"\n", "Check if a nyu_class can be represented by different colors in original dataset"
"fig.show()"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 28, "execution_count": 57,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "data": {
"output_type": "stream", "text/plain": [
"text": [ "{'wall': ['21 156 162'],\n",
"<class 'float'>\n", " 'bed': ['195 224 75'],\n",
"<class 'float'>\n", " 'ceiling': ['249 129 6',\n",
"<class 'float'>\n", " '216 148 91',\n",
"<class 'float'>\n", " '210 171 73',\n",
"<class 'float'>\n", " '85 110 41',\n",
"<class 'float'>\n", " '148 2 50',\n",
"<class 'float'>\n", " '90 67 102'],\n",
"<class 'float'>\n", " 'floor': ['244 244 249', '84 102 188'],\n",
"<class 'float'>\n", " 'desk': ['73 37 200', '95 228 26'],\n",
"<class 'float'>\n" " 'bookshelf': ['205 250 112'],\n",
] " 'window': ['240 88 86'],\n",
" 'door': ['153 91 119', '241 196 116', '36 242 138'],\n",
" 'chair': ['56 190 211', '174 76 53', '58 1 47', '206 81 234'],\n",
" 'shelves': ['244 76 17'],\n",
" 'cabinet': ['139 41 45'],\n",
" 'prop': ['17 15 47',\n",
" '166 71 56',\n",
" '218 234 195',\n",
" '130 122 54',\n",
" '41 64 0',\n",
" '172 18 250',\n",
" '26 98 68'],\n",
" 'box': ['196 11 210', '191 240 43', '246 217 198', '123 185 187'],\n",
" 'unknown': ['18 72 169',\n",
" '250 241 183',\n",
" '208 23 69',\n",
" '162 77 150',\n",
" '209 7 128',\n",
" '182 133 137',\n",
" '25 103 137',\n",
" '108 71 13',\n",
" '112 144 15',\n",
" '52 237 197',\n",
" '106 59 108',\n",
" '210 95 11',\n",
" '90 67 102',\n",
" '73 40 150',\n",
" '122 86 209',\n",
" '30 172 1',\n",
" '203 120 184',\n",
" '154 107 160',\n",
" '148 185 161',\n",
" '167 223 45',\n",
" '207 177 201',\n",
" '4 189 197',\n",
" '59 43 90',\n",
" '163 100 250',\n",
" '159 239 33',\n",
" '112 144 78',\n",
" '188 152 217',\n",
" '139 146 65',\n",
" '93 225 236',\n",
" '76 95 67',\n",
" '223 118 188',\n",
" '4 83 132',\n",
" '201 250 235',\n",
" '62 159 62',\n",
" '28 120 85',\n",
" '104 146 227',\n",
" '184 83 32',\n",
" '233 201 250',\n",
" '107 220 11',\n",
" '51 152 136',\n",
" '118 140 164',\n",
" '217 239 62',\n",
" '167 41 210',\n",
" '27 215 220',\n",
" '172 250 142',\n",
" '48 5 152',\n",
" '233 44 11',\n",
" '110 101 52',\n",
" '175 220 62',\n",
" '1 150 55',\n",
" '74 13 143',\n",
" '205 52 250',\n",
" '133 22 195',\n",
" '110 149 205',\n",
" '119 93 63',\n",
" '119 184 22',\n",
" '105 244 233',\n",
" '215 141 14',\n",
" '149 85 4',\n",
" '71 161 161',\n",
" '70 75 9',\n",
" '95 212 147',\n",
" '4 8 173',\n",
" '101 141 78',\n",
" '207 7 169',\n",
" '164 107 190',\n",
" '205 37 21',\n",
" '85 183 82',\n",
" '58 10 102',\n",
" '218 56 84',\n",
" '186 239 250',\n",
" '202 148 65',\n",
" '53 77 233',\n",
" '40 145 247',\n",
" '187 145 169',\n",
" '112 218 250',\n",
" '30 223 64',\n",
" '32 207 20',\n",
" '169 79 4',\n",
" '113 80 146',\n",
" '171 190 18',\n",
" '147 26 117',\n",
" '250 220 60',\n",
" '164 163 217',\n",
" '217 230 40',\n",
" '43 3 39',\n",
" '239 153 26',\n",
" '102 154 66',\n",
" '101 55 196',\n",
" '210 246 33',\n",
" '173 100 189',\n",
" '41 92 11',\n",
" '6 249 146',\n",
" '172 231 18',\n",
" '138 62 70',\n",
" '132 140 147',\n",
" '106 141 197',\n",
" '183 175 113',\n",
" '210 198 143',\n",
" '96 105 119',\n",
" '240 81 17',\n",
" '173 58 234',\n",
" '229 193 249',\n",
" '173 196 236',\n",
" '102 178 37',\n",
" '135 200 219',\n",
" '41 183 99',\n",
" '59 70 204',\n",
" '184 211 242',\n",
" '136 69 244',\n",
" '46 90 116',\n",
" '159 147 75',\n",
" '18 128 86',\n",
" '161 250 179',\n",
" '140 77 118',\n",
" '188 109 114',\n",
" '132 58 181',\n",
" '250 45 179',\n",
" '210 32 14',\n",
" '24 250 147',\n",
" '124 199 230',\n",
" '48 202 90',\n",
" '56 214 222',\n",
" '235 134 96',\n",
" '5 226 192',\n",
" '146 193 125',\n",
" '35 23 132',\n",
" '151 191 199',\n",
" '0 140 96',\n",
" '250 107 130',\n",
" '240 192 243',\n",
" '201 117 245',\n",
" '20 36 204',\n",
" '113 215 14',\n",
" '68 30 77',\n",
" '119 96 221',\n",
" '51 168 0',\n",
" '140 167 165',\n",
" '100 149 43',\n",
" '25 146 177',\n",
" '203 175 125',\n",
" '218 225 152',\n",
" '128 35 113',\n",
" '235 149 165',\n",
" '240 119 130',\n",
" '63 157 23',\n",
" '250 226 153',\n",
" '64 72 124',\n",
" '220 77 11',\n",
" '82 70 205',\n",
" '193 63 183',\n",
" '246 150 162',\n",
" '191 33 82',\n",
" '49 9 124',\n",
" '236 97 247',\n",
" '29 73 42',\n",
" '174 176 151',\n",
" '216 104 115',\n",
" '27 52 207',\n",
" '250 241 209',\n",
" '107 100 148',\n",
" '132 40 88',\n",
" '111 106 74',\n",
" '122 57 155',\n",
" '38 90 35',\n",
" '152 39 154',\n",
" '212 100 97',\n",
" '136 81 169',\n",
" '250 166 155',\n",
" '9 197 112',\n",
" '125 175 130',\n",
" '120 165 250',\n",
" '18 10 103',\n",
" '246 199 122',\n",
" '172 40 30',\n",
" '223 121 124',\n",
" '63 144 165',\n",
" '99 1 245',\n",
" '130 237 103',\n",
" '67 146 89',\n",
" '134 201 211',\n",
" '150 163 193',\n",
" '209 54 93',\n",
" '227 28 148',\n",
" '59 198 224',\n",
" '135 155 63',\n",
" '245 37 151',\n",
" '110 170 171',\n",
" '161 250 79',\n",
" '30 162 66',\n",
" '88 228 147'],\n",
" 'towel': ['166 215 75', '190 249 53'],\n",
" 'television': ['182 11 150'],\n",
" 'bag': ['79 176 148'],\n",
" 'lamp': ['126 210 18', '196 36 92', '234 250 54']}"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
} }
], ],
"source": [] "source": [
"classes = {}\n",
"for label in labels:\n",
" if label['@nyu_class'] in classes:\n",
" if label['@color'] not in classes[label['@nyu_class']]:\n",
" classes[label['@nyu_class']].append(label['@color'])\n",
" else:\n",
" classes[label['@nyu_class']] = [label['@color']]\n",
"classes"
]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": [
"for label in labels:\n",
" "
]
} }
], ],
"metadata": { "metadata": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment