{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "a71a7958", "metadata": {}, "outputs": [], "source": [ "from graphviz import Digraph\n", "from vre.utils import str_topk\n", "\n", "DATA = {\n", " 'rgb': [],\n", " 'semantic_m2f_coco_0': [],\n", " 'semantic_m2f_mapillary_0': [],\n", " 'semantic_m2f_mapillary_1': [],\n", " 'depth_marigold': [],\n", " 'semantic_m2f_swin_coco_converted': ['semantic_m2f_coco_0'],\n", " 'semantic_m2f_swin_mapillary_converted': ['semantic_m2f_mapillary_0'],\n", " 'semantic_m2f_r50_mapillary_converted': ['semantic_m2f_mapillary_1'],\n", " 'buildings': ['semantic_m2f_mapillary_0', 'semantic_m2f_coco_0', 'semantic_m2f_mapillary_1'],\n", " 'sky-and-water': ['semantic_m2f_mapillary_0', 'semantic_m2f_coco_0', 'semantic_m2f_mapillary_1'],\n", " 'transportation': ['semantic_m2f_mapillary_0', 'semantic_m2f_coco_0', 'semantic_m2f_mapillary_1'],\n", " 'containing': ['semantic_m2f_mapillary_0', 'semantic_m2f_coco_0', 'semantic_m2f_mapillary_1'],\n", " 'vegetation': ['semantic_m2f_mapillary_0', 'semantic_m2f_coco_0', 'semantic_m2f_mapillary_1'],\n", " 'normals_svd(depth_marigold)': ['depth_marigold'],\n", " 'buildings(nearby)': ['semantic_m2f_mapillary_0', 'semantic_m2f_coco_0', 'semantic_m2f_mapillary_1', 'depth_marigold'],\n", " 'semantic_output': ['semantic_m2f_swin_mapillary_converted', 'semantic_m2f_r50_mapillary_converted', 'semantic_m2f_swin_coco_converted'],\n", " 'safe-landing-no-sseg': ['depth_marigold', 'normals_svd(depth_marigold)'],\n", " 'safe-landing-semantics': ['depth_marigold', 'normals_svd(depth_marigold)', 'semantic_m2f_mapillary_0', 'semantic_m2f_coco_0', 'semantic_m2f_mapillary_1'],\n", "}" ] }, { "cell_type": "code", "execution_count": null, "id": "f6b33d6b", "metadata": {}, "outputs": [], "source": [ "def f(item: str) -> str:\n", " if item == 'buildings(nearby)':\n", " return 'buildings\\n(nearby)'\n", " if item == 'safe-landing-semantics':\n", " return 'safe-landing\\n-semantics'\n", " if item == 'semantic_output':\n", " return 'semantic\\n_output'\n", " if item == 'semantic_m2f_coco_0':\n", " return 'semantic_m2f\\n_coco_0'\n", " if item == 'safe-landing-no-sseg':\n", " return 'safe-landing\\n-no-sseg'\n", " if item == 'normals_svd(depth_marigold)':\n", " return 'normals_svd\\n(depth_marigold)'\n", " if item == 'semantic_m2f_swin_mapillary_converted':\n", " return 'semantic_m2f_swin\\n_mapillary_converted'\n", " if item == 'semantic_m2f_swin_coco_converted':\n", " return 'semantic_m2f_swin\\n_coco_converted'\n", " if item == 'semantic_m2f_r50_mapillary_converted':\n", " return 'semantic_m2f_r50\\n_mapillary_converted'\n", " if len(item) < 15:\n", " return item\n", "\n", " k = len(item) // 2\n", " parts = []\n", " for i in range(len(item) // k + (len(item) % k != 0)):\n", " parts.append(item[i*k: (i+1)*k])\n", " return \"\\n\".join(parts)\n", "\n", "# print(f(\"abc\"))\n", "# print(f(\"abcabcabcabc\"))" ] }, { "cell_type": "code", "execution_count": null, "id": "2e6ef629", "metadata": {}, "outputs": [], "source": [ "g = Digraph()\n", "g.attr(rankdir=\"LR\")\n", "shape = \"box\"\n", "edges: list[tuple[str, str]] = []\n", "for node, node_deps in DATA.items():\n", " for node_dep in node_deps:\n", " edges.append((f(node), f(node_dep)))\n", " else:\n", " g.node(f(node), shape=shape)\n", "for l, r in edges:\n", " g.edge(r, l, shape=shape) # reverse?\n", "display(g)\n", "g.render(\"graph-test\", cleanup=True, format=\"png\")" ] }, { "cell_type": "code", "execution_count": null, "id": "441ab171", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "vre", "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.11.9" } }, "nbformat": 4, "nbformat_minor": 5 }