{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Exploration of 3D Indoor Scenes Datasets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Install useful dependencies for data exploration" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "hideCode": false, "hideOutput": true, "hidePrompt": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Collecting xmltodict\n", " Downloading xmltodict-0.12.0-py2.py3-none-any.whl (9.2 kB)\n", "Installing collected packages: xmltodict\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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Successfully installed xmltodict-0.12.0\n" ] } ], "source": [ "import pip\n", "\n", "def install(package):\n", " if hasattr(pip, 'main'):\n", " pip.main(['install', package])\n", " else:\n", " pip._internal.main(['install', package])\n", "\n", "# install('panda3d')\n", "# install('ursina')\n", "# install('ipyvolume')\n", "# install('plotly')\n", "# install('pyquaternion')\n", "# install('xmltodict')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Explore SceneNN scene" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Copy minimalist scene data as string \"sample_scene_data\"" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "hideCode": true, "hideOutput": true, "hidePrompt": false }, "outputs": [], "source": [ "sample_scene_data = \"\"\"\n", "\n", "\n", "\"\"\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load scene data as xml tree element" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "OrderedDict([('@id', '716508'),\n", " ('@color', '21 156 162'),\n", " ('@text', ''),\n", " ('@nyu_class', 'wall'),\n", " ('@note', ''),\n", " ('@area', '492477'),\n", " ('@obbox',\n", " '-1.2153 -2.52873 -1.90061 4.76056 2.89713 3.58827 0.999386 0.0115122 0.0173149 0.02819'),\n", " ('@aabbox',\n", " '-1.19997 -0.368718 -1.66073 3.51822 2.43698 1.86119'),\n", " ('@local_pose', '1 0 0 0')])" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import xmltodict\n", "labels = xmltodict.parse(sample_scene_data)['annotation']['label']\n", "sample_label = labels[0]\n", "# sample_label" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [], "source": [ "import pyquaternion\n", "\n", "def obbox_properties_to_vertices(obbox_properties):\n", " \"\"\"\n", " Convert 3D box properties (center, dimensions, and quaternion)\n", " \"\"\"\n", " if isinstance(obbox_properties, str):\n", " obbox_properties = list(map(float, obbox_properties.split()))\n", " \n", "# TODO ADD EXTRA CHECKS\n", "# if isinstance(obbox_properties, iterable) and len(obbox_properties == 10) and \n", " \n", " # Extract properties\n", " cx, cy, cz = obbox_properties[0:3]\n", " dx, dy, dz = obbox_properties[3:6]\n", " qx, qy, qz, qw = obbox_properties[6:10]\n", "\n", " # Constants for converting properties to vertices\n", " X = [0, 0, 1, 1, 0, 0, 1, 1]\n", " Y = [0, 1, 1, 0, 0, 1, 1, 0]\n", " 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", " 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", " \n", " x, y, z = zip(*vertices)\n", " \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", "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", "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": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "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": {}, "outputs": [ { "data": { "text/plain": [ "{'bag',\n", " 'bed',\n", " 'bookshelf',\n", " 'box',\n", " 'cabinet',\n", " '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": [ "classes = set()\n", "for labebag',\n", " 'bed',\n", " 'bookshelf',\n", " 'box',\n", " 'cabinet',\n", " 'ceiling',\n", " 'chair',\n", " 'desk',\n", " 'door',\n", " 'floor',\n", " 'lamp',\n", " 'prop',\n", " 'shelvel in labels:\n", " classes.add(label['@nyu_class'])\n", "classes" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Check if a nyu_class can be represented by different colors in original dataset" ] }, { "cell_type": "code", "execution_count": 57, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'wall': ['21 156 162'],\n", " 'bed': ['195 224 75'],\n", " 'ceiling': ['249 129 6',\n", " '216 148 91',\n", " '210 171 73',\n", " '85 110 41',\n", " '148 2 50',\n", " '90 67 102'],\n", " 'floor': ['244 244 249', '84 102 188'],\n", " 'desk': ['73 37 200', '95 228 26'],\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": [ "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", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for label in labels:\n", " " ] } ], "metadata": { "celltoolbar": "Hide code", "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.4" } }, "nbformat": 4, "nbformat_minor": 2 }