File size: 4,536 Bytes
72cdf8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{
 "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
}