jacklangerman commited on
Commit
7eb69da
1 Parent(s): 0b5273d

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +19 -0
  2. example_notebook.ipynb +1010 -0
  3. script.py +58 -0
README.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Empty solution example for the S23DR competition
2
+
3
+ This repo provides a minimalistic example of a valid, but empty submission to S23DR competition.
4
+ We recommend to take a look at the [another example](https://huggingface.co/usm3d/handcrafted_baseline_submission),
5
+ which implement some primitive algorithm and provides useful I/O and visualization functions.
6
+
7
+ This one, though, containt the minimal code, which succeeds at reading the dataset and producing a solution, which consists of two vertices at the origin and edge of zero length connecting them.
8
+
9
+
10
+ The repo consistst of the following parts:
11
+
12
+ - `script.py` - the main file, which is run by the competition space. It should produce `submission.parquet` as the result of the run.
13
+ - `hoho.py` - the file for parsing the dataset at the inference time. Do NOT change it.
14
+
15
+
16
+ ---
17
+ license: apache-2.0
18
+ ---
19
+
example_notebook.ipynb ADDED
@@ -0,0 +1,1010 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "Mq5iNIZ9xWxt",
6
+ "metadata": {
7
+ "id": "Mq5iNIZ9xWxt"
8
+ },
9
+ "source": [
10
+ "# Empty Submission Example for S23DR Challenge\n",
11
+ "\n",
12
+ "### Helpful Links\n",
13
+ "[Challenge Page](https://huggingface.co/spaces/usm3d/S23DR) \n",
14
+ "[Workshop Page](usm3d.github.io) \n",
15
+ "\n",
16
+ "[HoHo Train Set](https://huggingface.co/datasets/usm3d/hoho-train-set) \n",
17
+ "[Handcrafted Baseline Solution](https://huggingface.co/usm3d/handcrafted_baseline_submission) \n",
18
+ " "
19
+ ]
20
+ },
21
+ {
22
+ "cell_type": "markdown",
23
+ "id": "dua8UJOoxiDi",
24
+ "metadata": {
25
+ "id": "dua8UJOoxiDi"
26
+ },
27
+ "source": [
28
+ "## Setup\n",
29
+ "\n",
30
+ "We'll start by checking if we are running to Google Colab (and if we are setting `IN_COLAB = True` and installing the [hoho tools](https://huggingface.co/usm3d/tools))."
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": 1,
36
+ "id": "ItDDqoXop8bb",
37
+ "metadata": {
38
+ "colab": {
39
+ "base_uri": "https://localhost:8080/"
40
+ },
41
+ "id": "ItDDqoXop8bb",
42
+ "outputId": "0c9d26a7-bf79-4452-c772-d5579a9cb2a9"
43
+ },
44
+ "outputs": [],
45
+ "source": [
46
+ "try:\n",
47
+ " import google.colab\n",
48
+ " IN_COLAB = True\n",
49
+ "except:\n",
50
+ " IN_COLAB = False\n",
51
+ "\n",
52
+ "if IN_COLAB:\n",
53
+ " !pip install git+http://hf.co/usm3d/tools.git"
54
+ ]
55
+ },
56
+ {
57
+ "cell_type": "markdown",
58
+ "id": "2tHX74Z-x1cU",
59
+ "metadata": {
60
+ "id": "2tHX74Z-x1cU"
61
+ },
62
+ "source": [
63
+ "We need to be logged into HF for this to work because the training dataset is gated. If you haven't already please go to the [dastaset page](https://huggingface.co/datasets/usm3d/hoho-train-set) to agree to our terms and request access to the dataset."
64
+ ]
65
+ },
66
+ {
67
+ "cell_type": "code",
68
+ "execution_count": 2,
69
+ "id": "zq_ljluLqzzv",
70
+ "metadata": {
71
+ "colab": {
72
+ "base_uri": "https://localhost:8080/"
73
+ },
74
+ "id": "zq_ljluLqzzv",
75
+ "outputId": "b66806f1-b88a-47e0-8194-79515b73fa23"
76
+ },
77
+ "outputs": [],
78
+ "source": [
79
+ "if IN_COLAB:\n",
80
+ " !huggingface-cli login"
81
+ ]
82
+ },
83
+ {
84
+ "cell_type": "markdown",
85
+ "id": "Xf2PY79fywa5",
86
+ "metadata": {
87
+ "id": "Xf2PY79fywa5"
88
+ },
89
+ "source": [
90
+ "## Data Download, Analysis, and Visualization"
91
+ ]
92
+ },
93
+ {
94
+ "cell_type": "code",
95
+ "execution_count": 3,
96
+ "id": "e171b1ec-e861-4349-98fd-2eac4d080ff5",
97
+ "metadata": {
98
+ "id": "e171b1ec-e861-4349-98fd-2eac4d080ff5"
99
+ },
100
+ "outputs": [],
101
+ "source": [
102
+ "import hoho\n",
103
+ "from hoho import *\n",
104
+ "\n",
105
+ "import numpy as np\n",
106
+ "import matplotlib.pyplot as plt\n",
107
+ "from pathlib import Path\n",
108
+ "from collections import Counter\n",
109
+ "import itertools\n",
110
+ "import datasets\n",
111
+ "import trimesh\n",
112
+ "from tqdm.notebook import tqdm\n",
113
+ "import webdataset as wds\n",
114
+ "import sys"
115
+ ]
116
+ },
117
+ {
118
+ "cell_type": "markdown",
119
+ "id": "83649a4c-fde7-4051-ba71-e596d382e76a",
120
+ "metadata": {
121
+ "id": "83649a4c-fde7-4051-ba71-e596d382e76a"
122
+ },
123
+ "source": [
124
+ "### Load the hoho package and point to the data folder\n",
125
+ "\n",
126
+ "We download only one shard of the data"
127
+ ]
128
+ },
129
+ {
130
+ "cell_type": "code",
131
+ "execution_count": 4,
132
+ "id": "ffffc234",
133
+ "metadata": {
134
+ "colab": {
135
+ "base_uri": "https://localhost:8080/"
136
+ },
137
+ "id": "ffffc234",
138
+ "outputId": "e969db58-e88e-457a-eee2-14e65c8117fb"
139
+ },
140
+ "outputs": [
141
+ {
142
+ "name": "stderr",
143
+ "output_type": "stream",
144
+ "text": [
145
+ "/Users/jack/dev/USM3D/comp/tools/hoho/hoho.py:309: UserWarning: streaming isn't using with 'all': changing `split` to 'train'\n",
146
+ " warnings.warn('streaming isn\\'t using with \\'all\\': changing `split` to \\'train\\'')\n",
147
+ "/Users/jack/dev/USM3D/comp/tools/hoho/hoho.py:310: UserWarning: no tarfiles found in data/usm-training-data/data/val.\n",
148
+ " warnings.warn(msg)\n"
149
+ ]
150
+ },
151
+ {
152
+ "name": "stdout",
153
+ "output_type": "stream",
154
+ "text": [
155
+ "/Users/jack/dev/USM3D/comp/empty_submission\n",
156
+ "total 104\n",
157
+ "-rw-r--r-- 1 jack staff 1.5K Apr 26 12:51 .gitattributes\n",
158
+ "-rw-r--r-- 1 jack staff 855B Apr 26 12:51 README.md\n",
159
+ "drwxr-xr-x 10 jack staff 320B Apr 26 12:55 \u001b[34m..\u001b[m\u001b[m\n",
160
+ "drwxr-xr-x 3 jack staff 96B Apr 26 15:06 \u001b[34mdata\u001b[m\u001b[m\n",
161
+ "-rw-r--r-- 1 jack staff 5.8K Apr 26 15:42 submission.parquet\n",
162
+ "-rw-r--r-- 1 jack staff 2.3K Apr 26 15:50 script.py\n",
163
+ "drwxr-xr-x 15 jack staff 480B Apr 26 15:50 \u001b[34m.git\u001b[m\u001b[m\n",
164
+ "-rw-r--r-- 1 jack staff 32K Apr 26 18:26 example_notebook.ipynb\n",
165
+ "drwxr-xr-x 9 jack staff 288B Apr 28 10:32 \u001b[34m.\u001b[m\u001b[m\n",
166
+ "Using data/usm-training-data/data as the data directory (we are running locally)\n",
167
+ "------------ Loading dataset------------ \n",
168
+ "params.json not found (this means we probably aren't in the test env). Using example params.\n",
169
+ "{'competition_id': 'usm3d/S23DR', 'competition_type': 'script', 'metric': 'custom', 'token': 'hf_**********************************', 'team_id': 'local-test-team_id', 'submission_id': 'local-test-submission_id', 'submission_id_col': '__key__', 'submission_cols': ['__key__', 'wf_edges', 'wf_vertices', 'edge_semantics'], 'submission_rows': 180, 'output_path': '.', 'submission_repo': '<THE HF MODEL ID of THIS REPO', 'time_limit': 7200, 'dataset': 'usm3d/usm-test-data-x', 'submission_filenames': ['submission.parquet']}\n",
170
+ "------------ Now you can do your solution ---------------\n"
171
+ ]
172
+ },
173
+ {
174
+ "name": "stderr",
175
+ "output_type": "stream",
176
+ "text": [
177
+ "0it [00:00, ?it/s]"
178
+ ]
179
+ },
180
+ {
181
+ "name": "stderr",
182
+ "output_type": "stream",
183
+ "text": [
184
+ "2it [00:34, 17.31s/it]\n"
185
+ ]
186
+ },
187
+ {
188
+ "ename": "KeyboardInterrupt",
189
+ "evalue": "",
190
+ "output_type": "error",
191
+ "traceback": [
192
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
193
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
194
+ "Cell \u001b[0;32mIn[4], line 47\u001b[0m\n\u001b[1;32m 45\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m------------ Now you can do your solution ---------------\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 46\u001b[0m solution \u001b[38;5;241m=\u001b[39m []\n\u001b[0;32m---> 47\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i, sample \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(tqdm(dataset)):\n\u001b[1;32m 48\u001b[0m \u001b[38;5;66;03m# replace this with your solution\u001b[39;00m\n\u001b[1;32m 49\u001b[0m pred_vertices, pred_edges \u001b[38;5;241m=\u001b[39m empty_solution(sample)\n\u001b[1;32m 51\u001b[0m solution\u001b[38;5;241m.\u001b[39mappend({\n\u001b[1;32m 52\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m__key__\u001b[39m\u001b[38;5;124m'\u001b[39m: sample[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m__key__\u001b[39m\u001b[38;5;124m'\u001b[39m], \n\u001b[1;32m 53\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mwf_vertices\u001b[39m\u001b[38;5;124m'\u001b[39m: pred_vertices\u001b[38;5;241m.\u001b[39mtolist(),\n\u001b[1;32m 54\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mwf_edges\u001b[39m\u001b[38;5;124m'\u001b[39m: pred_edges\n\u001b[1;32m 55\u001b[0m })\n",
195
+ "File \u001b[0;32m~/miniconda3/envs/d2/lib/python3.10/site-packages/tqdm/std.py:1181\u001b[0m, in \u001b[0;36mtqdm.__iter__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 1178\u001b[0m time \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_time\n\u001b[1;32m 1180\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 1181\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m obj \u001b[38;5;129;01min\u001b[39;00m iterable:\n\u001b[1;32m 1182\u001b[0m \u001b[38;5;28;01myield\u001b[39;00m obj\n\u001b[1;32m 1183\u001b[0m \u001b[38;5;66;03m# Update and possibly print the progressbar.\u001b[39;00m\n\u001b[1;32m 1184\u001b[0m \u001b[38;5;66;03m# Note: does not call self.update(1) for speed optimisation.\u001b[39;00m\n",
196
+ "File \u001b[0;32m~/miniconda3/envs/d2/lib/python3.10/site-packages/webdataset/pipeline.py:70\u001b[0m, in \u001b[0;36mDataPipeline.iterator\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 68\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Create an iterator through the entire dataset, using the given number of repetitions.\"\"\"\u001b[39;00m\n\u001b[1;32m 69\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m _ \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrepetitions):\n\u001b[0;32m---> 70\u001b[0m \u001b[38;5;28;01myield from\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39miterator1()\n",
197
+ "File \u001b[0;32m~/miniconda3/envs/d2/lib/python3.10/site-packages/webdataset/filters.py:302\u001b[0m, in \u001b[0;36m_map\u001b[0;34m(data, f, handler)\u001b[0m\n\u001b[1;32m 300\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_map\u001b[39m(data, f, handler\u001b[38;5;241m=\u001b[39mreraise_exception):\n\u001b[1;32m 301\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Map samples.\"\"\"\u001b[39;00m\n\u001b[0;32m--> 302\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m sample \u001b[38;5;129;01min\u001b[39;00m data:\n\u001b[1;32m 303\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 304\u001b[0m result \u001b[38;5;241m=\u001b[39m f(sample)\n",
198
+ "File \u001b[0;32m~/miniconda3/envs/d2/lib/python3.10/site-packages/webdataset/filters.py:302\u001b[0m, in \u001b[0;36m_map\u001b[0;34m(data, f, handler)\u001b[0m\n\u001b[1;32m 300\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_map\u001b[39m(data, f, handler\u001b[38;5;241m=\u001b[39mreraise_exception):\n\u001b[1;32m 301\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Map samples.\"\"\"\u001b[39;00m\n\u001b[0;32m--> 302\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m sample \u001b[38;5;129;01min\u001b[39;00m data:\n\u001b[1;32m 303\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 304\u001b[0m result \u001b[38;5;241m=\u001b[39m f(sample)\n",
199
+ "File \u001b[0;32m~/miniconda3/envs/d2/lib/python3.10/site-packages/webdataset/tariterators.py:219\u001b[0m, in \u001b[0;36mgroup_by_keys\u001b[0;34m(data, keys, lcase, suffixes, handler)\u001b[0m\n\u001b[1;32m 203\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Group tarfile contents by keys and yield samples.\u001b[39;00m\n\u001b[1;32m 204\u001b[0m \n\u001b[1;32m 205\u001b[0m \u001b[38;5;124;03mArgs:\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 216\u001b[0m \u001b[38;5;124;03m iterator over samples.\u001b[39;00m\n\u001b[1;32m 217\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 218\u001b[0m current_sample \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m--> 219\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m filesample \u001b[38;5;129;01min\u001b[39;00m data:\n\u001b[1;32m 220\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 221\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(filesample, \u001b[38;5;28mdict\u001b[39m)\n",
200
+ "File \u001b[0;32m~/miniconda3/envs/d2/lib/python3.10/site-packages/webdataset/tariterators.py:177\u001b[0m, in \u001b[0;36mtar_file_expander\u001b[0;34m(data, handler, select_files, rename_files)\u001b[0m\n\u001b[1;32m 175\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(source, \u001b[38;5;28mdict\u001b[39m)\n\u001b[1;32m 176\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mstream\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m source\n\u001b[0;32m--> 177\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m sample \u001b[38;5;129;01min\u001b[39;00m tar_file_iterator(\n\u001b[1;32m 178\u001b[0m source[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mstream\u001b[39m\u001b[38;5;124m\"\u001b[39m],\n\u001b[1;32m 179\u001b[0m handler\u001b[38;5;241m=\u001b[39mhandler,\n\u001b[1;32m 180\u001b[0m select_files\u001b[38;5;241m=\u001b[39mselect_files,\n\u001b[1;32m 181\u001b[0m rename_files\u001b[38;5;241m=\u001b[39mrename_files,\n\u001b[1;32m 182\u001b[0m ):\n\u001b[1;32m 183\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m (\n\u001b[1;32m 184\u001b[0m \u001b[38;5;28misinstance\u001b[39m(sample, \u001b[38;5;28mdict\u001b[39m) \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdata\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m sample \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfname\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m sample\n\u001b[1;32m 185\u001b[0m )\n\u001b[1;32m 186\u001b[0m sample[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m__url__\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m url\n",
201
+ "File \u001b[0;32m~/miniconda3/envs/d2/lib/python3.10/site-packages/webdataset/tariterators.py:142\u001b[0m, in \u001b[0;36mtar_file_iterator\u001b[0;34m(fileobj, skip_meta, handler, select_files, rename_files)\u001b[0m\n\u001b[1;32m 140\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m select_files \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m select_files(fname):\n\u001b[1;32m 141\u001b[0m \u001b[38;5;28;01mcontinue\u001b[39;00m\n\u001b[0;32m--> 142\u001b[0m data \u001b[38;5;241m=\u001b[39m \u001b[43mstream\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mextractfile\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtarinfo\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 143\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mdict\u001b[39m(fname\u001b[38;5;241m=\u001b[39mfname, data\u001b[38;5;241m=\u001b[39mdata)\n\u001b[1;32m 144\u001b[0m \u001b[38;5;28;01myield\u001b[39;00m result\n",
202
+ "File \u001b[0;32m~/miniconda3/envs/d2/lib/python3.10/tarfile.py:689\u001b[0m, in \u001b[0;36m_FileInFile.read\u001b[0;34m(self, size)\u001b[0m\n\u001b[1;32m 687\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m data:\n\u001b[1;32m 688\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfileobj\u001b[38;5;241m.\u001b[39mseek(offset \u001b[38;5;241m+\u001b[39m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mposition \u001b[38;5;241m-\u001b[39m start))\n\u001b[0;32m--> 689\u001b[0m b \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfileobj\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[43mlength\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 690\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(b) \u001b[38;5;241m!=\u001b[39m length:\n\u001b[1;32m 691\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ReadError(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124munexpected end of data\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
203
+ "File \u001b[0;32m~/miniconda3/envs/d2/lib/python3.10/tarfile.py:526\u001b[0m, in \u001b[0;36m_Stream.read\u001b[0;34m(self, size)\u001b[0m\n\u001b[1;32m 524\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Return the next size number of bytes from the stream.\"\"\"\u001b[39;00m\n\u001b[1;32m 525\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m size \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m--> 526\u001b[0m buf \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_read\u001b[49m\u001b[43m(\u001b[49m\u001b[43msize\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 527\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpos \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlen\u001b[39m(buf)\n\u001b[1;32m 528\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m buf\n",
204
+ "File \u001b[0;32m~/miniconda3/envs/d2/lib/python3.10/tarfile.py:544\u001b[0m, in \u001b[0;36m_Stream._read\u001b[0;34m(self, size)\u001b[0m\n\u001b[1;32m 542\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mbuf \u001b[38;5;241m=\u001b[39m \u001b[38;5;124mb\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 543\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 544\u001b[0m buf \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfileobj\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mbufsize\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 545\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m buf:\n\u001b[1;32m 546\u001b[0m \u001b[38;5;28;01mbreak\u001b[39;00m\n",
205
+ "File \u001b[0;32m~/miniconda3/envs/d2/lib/python3.10/site-packages/webdataset/gopen.py:87\u001b[0m, in \u001b[0;36mPipe.read\u001b[0;34m(self, *args, **kw)\u001b[0m\n\u001b[1;32m 85\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mread\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkw):\n\u001b[1;32m 86\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Wrap stream.read and checks status.\"\"\"\u001b[39;00m\n\u001b[0;32m---> 87\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstream\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkw\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 88\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcheck_status()\n\u001b[1;32m 89\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m result\n",
206
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
207
+ ]
208
+ }
209
+ ],
210
+ "source": [
211
+ "# %load script.py\n",
212
+ "### This is example of the script that will be run in the test environment.\n",
213
+ "### Some parts of the code are compulsory and you should NOT CHANGE THEM.\n",
214
+ "### They are between '''---compulsory---''' comments.\n",
215
+ "### You can change the rest of the code to define and test your solution.\n",
216
+ "### However, you should not change the signature of the provided function.\n",
217
+ "### The script would save \"submission.parquet\" file in the current directory.\n",
218
+ "### You can use any additional files and subdirectories to organize your code.\n",
219
+ "\n",
220
+ "'''---compulsory---'''\n",
221
+ "import hoho; hoho.setup() # YOU MUST CALL hoho.setup() BEFORE ANYTHING ELSE\n",
222
+ "'''---compulsory---'''\n",
223
+ "\n",
224
+ "from pathlib import Path\n",
225
+ "from tqdm import tqdm\n",
226
+ "import pandas as pd\n",
227
+ "import numpy as np\n",
228
+ "\n",
229
+ "\n",
230
+ "def empty_solution(sample):\n",
231
+ " '''Return a minimal valid solution, i.e. 2 vertices and 1 edge.'''\n",
232
+ " return np.zeros((2,3)), [(0, 1)]\n",
233
+ "\n",
234
+ "\n",
235
+ "if __name__ == \"__main__\":\n",
236
+ " print (\"------------ Loading dataset------------ \")\n",
237
+ " params = hoho.get_params()\n",
238
+ " \n",
239
+ " # by default it is usually better to use `get_dataset()` like this\n",
240
+ " # \n",
241
+ " # dataset = hoho.get_dataset(split='all')\n",
242
+ " # \n",
243
+ " # but in this case (because we don't do anything with the sample \n",
244
+ " # anyway) we set `decode=None`. We can set the `split` argument \n",
245
+ " # to 'train' or 'val' ('all' defaults back to 'train') if we are \n",
246
+ " # testing ourselves locally. \n",
247
+ " # \n",
248
+ " # dataset = hoho.get_dataset(split='val', decode=None)\n",
249
+ " #\n",
250
+ " # On the test server *`split` must be set to 'all'* \n",
251
+ " # to compute both the public and private leaderboards.\n",
252
+ " # \n",
253
+ " dataset = hoho.get_dataset(split='all', decode=None)\n",
254
+ " \n",
255
+ " print('------------ Now you can do your solution ---------------')\n",
256
+ " solution = []\n",
257
+ " for i, sample in enumerate(tqdm(dataset)):\n",
258
+ " # replace this with your solution\n",
259
+ " pred_vertices, pred_edges = empty_solution(sample)\n",
260
+ " \n",
261
+ " solution.append({\n",
262
+ " '__key__': sample['__key__'], \n",
263
+ " 'wf_vertices': pred_vertices.tolist(),\n",
264
+ " 'wf_edges': pred_edges\n",
265
+ " })\n",
266
+ " print('------------ Saving results ---------------')\n",
267
+ " sub = pd.DataFrame(solution, columns=[\"__key__\", \"wf_vertices\", \"wf_edges\"])\n",
268
+ " sub.to_parquet(Path(params['output_path']) / \"submission.parquet\")\n",
269
+ " print(\"------------ Done ------------ \")"
270
+ ]
271
+ },
272
+ {
273
+ "cell_type": "code",
274
+ "execution_count": null,
275
+ "id": "f077cbd7",
276
+ "metadata": {},
277
+ "outputs": [],
278
+ "source": []
279
+ },
280
+ {
281
+ "cell_type": "code",
282
+ "execution_count": null,
283
+ "id": "b65ed78e",
284
+ "metadata": {},
285
+ "outputs": [],
286
+ "source": []
287
+ },
288
+ {
289
+ "cell_type": "code",
290
+ "execution_count": null,
291
+ "id": "a4584502",
292
+ "metadata": {},
293
+ "outputs": [],
294
+ "source": []
295
+ }
296
+ ],
297
+ "metadata": {
298
+ "colab": {
299
+ "provenance": [],
300
+ "toc_visible": true
301
+ },
302
+ "kernelspec": {
303
+ "display_name": "Python 3 (ipykernel)",
304
+ "language": "python",
305
+ "name": "python3"
306
+ },
307
+ "language_info": {
308
+ "codemirror_mode": {
309
+ "name": "ipython",
310
+ "version": 3
311
+ },
312
+ "file_extension": ".py",
313
+ "mimetype": "text/x-python",
314
+ "name": "python",
315
+ "nbconvert_exporter": "python",
316
+ "pygments_lexer": "ipython3",
317
+ "version": "3.10.13"
318
+ },
319
+ "widgets": {
320
+ "application/vnd.jupyter.widget-state+json": {
321
+ "00dd3ba2c97a4a5f9e20e4c90ad4bcf8": {
322
+ "model_module": "@jupyter-widgets/controls",
323
+ "model_module_version": "1.5.0",
324
+ "model_name": "HTMLModel",
325
+ "state": {
326
+ "_dom_classes": [],
327
+ "_model_module": "@jupyter-widgets/controls",
328
+ "_model_module_version": "1.5.0",
329
+ "_model_name": "HTMLModel",
330
+ "_view_count": null,
331
+ "_view_module": "@jupyter-widgets/controls",
332
+ "_view_module_version": "1.5.0",
333
+ "_view_name": "HTMLView",
334
+ "description": "",
335
+ "description_tooltip": null,
336
+ "layout": "IPY_MODEL_e11a7d4a03954577aa59223fbe24780d",
337
+ "placeholder": "​",
338
+ "style": "IPY_MODEL_4d456e625cc248c18a6ee6171919a462",
339
+ "value": ""
340
+ }
341
+ },
342
+ "025d370c61d84fcba1a866731a16ee27": {
343
+ "model_module": "@jupyter-widgets/base",
344
+ "model_module_version": "1.2.0",
345
+ "model_name": "LayoutModel",
346
+ "state": {
347
+ "_model_module": "@jupyter-widgets/base",
348
+ "_model_module_version": "1.2.0",
349
+ "_model_name": "LayoutModel",
350
+ "_view_count": null,
351
+ "_view_module": "@jupyter-widgets/base",
352
+ "_view_module_version": "1.2.0",
353
+ "_view_name": "LayoutView",
354
+ "align_content": null,
355
+ "align_items": null,
356
+ "align_self": null,
357
+ "border": null,
358
+ "bottom": null,
359
+ "display": null,
360
+ "flex": null,
361
+ "flex_flow": null,
362
+ "grid_area": null,
363
+ "grid_auto_columns": null,
364
+ "grid_auto_flow": null,
365
+ "grid_auto_rows": null,
366
+ "grid_column": null,
367
+ "grid_gap": null,
368
+ "grid_row": null,
369
+ "grid_template_areas": null,
370
+ "grid_template_columns": null,
371
+ "grid_template_rows": null,
372
+ "height": null,
373
+ "justify_content": null,
374
+ "justify_items": null,
375
+ "left": null,
376
+ "margin": null,
377
+ "max_height": null,
378
+ "max_width": null,
379
+ "min_height": null,
380
+ "min_width": null,
381
+ "object_fit": null,
382
+ "object_position": null,
383
+ "order": null,
384
+ "overflow": null,
385
+ "overflow_x": null,
386
+ "overflow_y": null,
387
+ "padding": null,
388
+ "right": null,
389
+ "top": null,
390
+ "visibility": null,
391
+ "width": null
392
+ }
393
+ },
394
+ "1bee0e2f81104a22bad736cea9725dcb": {
395
+ "model_module": "@jupyter-widgets/controls",
396
+ "model_module_version": "1.5.0",
397
+ "model_name": "DescriptionStyleModel",
398
+ "state": {
399
+ "_model_module": "@jupyter-widgets/controls",
400
+ "_model_module_version": "1.5.0",
401
+ "_model_name": "DescriptionStyleModel",
402
+ "_view_count": null,
403
+ "_view_module": "@jupyter-widgets/base",
404
+ "_view_module_version": "1.2.0",
405
+ "_view_name": "StyleView",
406
+ "description_width": ""
407
+ }
408
+ },
409
+ "2509efdc0c6a4dd6b1ade16d30e8209d": {
410
+ "model_module": "@jupyter-widgets/base",
411
+ "model_module_version": "1.2.0",
412
+ "model_name": "LayoutModel",
413
+ "state": {
414
+ "_model_module": "@jupyter-widgets/base",
415
+ "_model_module_version": "1.2.0",
416
+ "_model_name": "LayoutModel",
417
+ "_view_count": null,
418
+ "_view_module": "@jupyter-widgets/base",
419
+ "_view_module_version": "1.2.0",
420
+ "_view_name": "LayoutView",
421
+ "align_content": null,
422
+ "align_items": null,
423
+ "align_self": null,
424
+ "border": null,
425
+ "bottom": null,
426
+ "display": null,
427
+ "flex": null,
428
+ "flex_flow": null,
429
+ "grid_area": null,
430
+ "grid_auto_columns": null,
431
+ "grid_auto_flow": null,
432
+ "grid_auto_rows": null,
433
+ "grid_column": null,
434
+ "grid_gap": null,
435
+ "grid_row": null,
436
+ "grid_template_areas": null,
437
+ "grid_template_columns": null,
438
+ "grid_template_rows": null,
439
+ "height": null,
440
+ "justify_content": null,
441
+ "justify_items": null,
442
+ "left": null,
443
+ "margin": null,
444
+ "max_height": null,
445
+ "max_width": null,
446
+ "min_height": null,
447
+ "min_width": null,
448
+ "object_fit": null,
449
+ "object_position": null,
450
+ "order": null,
451
+ "overflow": null,
452
+ "overflow_x": null,
453
+ "overflow_y": null,
454
+ "padding": null,
455
+ "right": null,
456
+ "top": null,
457
+ "visibility": null,
458
+ "width": null
459
+ }
460
+ },
461
+ "2ac27da2aa014ec782d2e7073d153f99": {
462
+ "model_module": "@jupyter-widgets/controls",
463
+ "model_module_version": "1.5.0",
464
+ "model_name": "DescriptionStyleModel",
465
+ "state": {
466
+ "_model_module": "@jupyter-widgets/controls",
467
+ "_model_module_version": "1.5.0",
468
+ "_model_name": "DescriptionStyleModel",
469
+ "_view_count": null,
470
+ "_view_module": "@jupyter-widgets/base",
471
+ "_view_module_version": "1.2.0",
472
+ "_view_name": "StyleView",
473
+ "description_width": ""
474
+ }
475
+ },
476
+ "452e42ee4a734b7a98b5945cffff9dac": {
477
+ "model_module": "@jupyter-widgets/controls",
478
+ "model_module_version": "1.5.0",
479
+ "model_name": "HTMLModel",
480
+ "state": {
481
+ "_dom_classes": [],
482
+ "_model_module": "@jupyter-widgets/controls",
483
+ "_model_module_version": "1.5.0",
484
+ "_model_name": "HTMLModel",
485
+ "_view_count": null,
486
+ "_view_module": "@jupyter-widgets/controls",
487
+ "_view_module_version": "1.5.0",
488
+ "_view_name": "HTMLView",
489
+ "description": "",
490
+ "description_tooltip": null,
491
+ "layout": "IPY_MODEL_2509efdc0c6a4dd6b1ade16d30e8209d",
492
+ "placeholder": "​",
493
+ "style": "IPY_MODEL_2ac27da2aa014ec782d2e7073d153f99",
494
+ "value": "Map: 100%"
495
+ }
496
+ },
497
+ "453f4cacb5bf490cb90f10c9cdccca30": {
498
+ "model_module": "@jupyter-widgets/controls",
499
+ "model_module_version": "1.5.0",
500
+ "model_name": "HBoxModel",
501
+ "state": {
502
+ "_dom_classes": [],
503
+ "_model_module": "@jupyter-widgets/controls",
504
+ "_model_module_version": "1.5.0",
505
+ "_model_name": "HBoxModel",
506
+ "_view_count": null,
507
+ "_view_module": "@jupyter-widgets/controls",
508
+ "_view_module_version": "1.5.0",
509
+ "_view_name": "HBoxView",
510
+ "box_style": "",
511
+ "children": [
512
+ "IPY_MODEL_452e42ee4a734b7a98b5945cffff9dac",
513
+ "IPY_MODEL_f4f69c0ea946405a8c1b88e68cfe6e38",
514
+ "IPY_MODEL_8e41e4539ee54d708b593c5d44699855"
515
+ ],
516
+ "layout": "IPY_MODEL_9a3ccc55920d4f9588e89e4d5579b0b0"
517
+ }
518
+ },
519
+ "4d456e625cc248c18a6ee6171919a462": {
520
+ "model_module": "@jupyter-widgets/controls",
521
+ "model_module_version": "1.5.0",
522
+ "model_name": "DescriptionStyleModel",
523
+ "state": {
524
+ "_model_module": "@jupyter-widgets/controls",
525
+ "_model_module_version": "1.5.0",
526
+ "_model_name": "DescriptionStyleModel",
527
+ "_view_count": null,
528
+ "_view_module": "@jupyter-widgets/base",
529
+ "_view_module_version": "1.2.0",
530
+ "_view_name": "StyleView",
531
+ "description_width": ""
532
+ }
533
+ },
534
+ "8d39835b987249799b1d000f9960e6f9": {
535
+ "model_module": "@jupyter-widgets/base",
536
+ "model_module_version": "1.2.0",
537
+ "model_name": "LayoutModel",
538
+ "state": {
539
+ "_model_module": "@jupyter-widgets/base",
540
+ "_model_module_version": "1.2.0",
541
+ "_model_name": "LayoutModel",
542
+ "_view_count": null,
543
+ "_view_module": "@jupyter-widgets/base",
544
+ "_view_module_version": "1.2.0",
545
+ "_view_name": "LayoutView",
546
+ "align_content": null,
547
+ "align_items": null,
548
+ "align_self": null,
549
+ "border": null,
550
+ "bottom": null,
551
+ "display": null,
552
+ "flex": null,
553
+ "flex_flow": null,
554
+ "grid_area": null,
555
+ "grid_auto_columns": null,
556
+ "grid_auto_flow": null,
557
+ "grid_auto_rows": null,
558
+ "grid_column": null,
559
+ "grid_gap": null,
560
+ "grid_row": null,
561
+ "grid_template_areas": null,
562
+ "grid_template_columns": null,
563
+ "grid_template_rows": null,
564
+ "height": null,
565
+ "justify_content": null,
566
+ "justify_items": null,
567
+ "left": null,
568
+ "margin": null,
569
+ "max_height": null,
570
+ "max_width": null,
571
+ "min_height": null,
572
+ "min_width": null,
573
+ "object_fit": null,
574
+ "object_position": null,
575
+ "order": null,
576
+ "overflow": null,
577
+ "overflow_x": null,
578
+ "overflow_y": null,
579
+ "padding": null,
580
+ "right": null,
581
+ "top": null,
582
+ "visibility": null,
583
+ "width": null
584
+ }
585
+ },
586
+ "8e41e4539ee54d708b593c5d44699855": {
587
+ "model_module": "@jupyter-widgets/controls",
588
+ "model_module_version": "1.5.0",
589
+ "model_name": "HTMLModel",
590
+ "state": {
591
+ "_dom_classes": [],
592
+ "_model_module": "@jupyter-widgets/controls",
593
+ "_model_module_version": "1.5.0",
594
+ "_model_name": "HTMLModel",
595
+ "_view_count": null,
596
+ "_view_module": "@jupyter-widgets/controls",
597
+ "_view_module_version": "1.5.0",
598
+ "_view_name": "HTMLView",
599
+ "description": "",
600
+ "description_tooltip": null,
601
+ "layout": "IPY_MODEL_ccfd6307c2cd4ba6b49e10ddb4a70d66",
602
+ "placeholder": "​",
603
+ "style": "IPY_MODEL_1bee0e2f81104a22bad736cea9725dcb",
604
+ "value": " 150/150 [00:02&lt;00:00, 55.18 examples/s]"
605
+ }
606
+ },
607
+ "9a3ccc55920d4f9588e89e4d5579b0b0": {
608
+ "model_module": "@jupyter-widgets/base",
609
+ "model_module_version": "1.2.0",
610
+ "model_name": "LayoutModel",
611
+ "state": {
612
+ "_model_module": "@jupyter-widgets/base",
613
+ "_model_module_version": "1.2.0",
614
+ "_model_name": "LayoutModel",
615
+ "_view_count": null,
616
+ "_view_module": "@jupyter-widgets/base",
617
+ "_view_module_version": "1.2.0",
618
+ "_view_name": "LayoutView",
619
+ "align_content": null,
620
+ "align_items": null,
621
+ "align_self": null,
622
+ "border": null,
623
+ "bottom": null,
624
+ "display": null,
625
+ "flex": null,
626
+ "flex_flow": null,
627
+ "grid_area": null,
628
+ "grid_auto_columns": null,
629
+ "grid_auto_flow": null,
630
+ "grid_auto_rows": null,
631
+ "grid_column": null,
632
+ "grid_gap": null,
633
+ "grid_row": null,
634
+ "grid_template_areas": null,
635
+ "grid_template_columns": null,
636
+ "grid_template_rows": null,
637
+ "height": null,
638
+ "justify_content": null,
639
+ "justify_items": null,
640
+ "left": null,
641
+ "margin": null,
642
+ "max_height": null,
643
+ "max_width": null,
644
+ "min_height": null,
645
+ "min_width": null,
646
+ "object_fit": null,
647
+ "object_position": null,
648
+ "order": null,
649
+ "overflow": null,
650
+ "overflow_x": null,
651
+ "overflow_y": null,
652
+ "padding": null,
653
+ "right": null,
654
+ "top": null,
655
+ "visibility": null,
656
+ "width": null
657
+ }
658
+ },
659
+ "9bac4c96e2b741b782da7fc36b79ead1": {
660
+ "model_module": "@jupyter-widgets/controls",
661
+ "model_module_version": "1.5.0",
662
+ "model_name": "FloatProgressModel",
663
+ "state": {
664
+ "_dom_classes": [],
665
+ "_model_module": "@jupyter-widgets/controls",
666
+ "_model_module_version": "1.5.0",
667
+ "_model_name": "FloatProgressModel",
668
+ "_view_count": null,
669
+ "_view_module": "@jupyter-widgets/controls",
670
+ "_view_module_version": "1.5.0",
671
+ "_view_name": "ProgressView",
672
+ "bar_style": "success",
673
+ "description": "",
674
+ "description_tooltip": null,
675
+ "layout": "IPY_MODEL_f0190337a99243e4b022dcf565dc7f5c",
676
+ "max": 1,
677
+ "min": 0,
678
+ "orientation": "horizontal",
679
+ "style": "IPY_MODEL_a9355a1d675c4ac4a2f68f4663a1d390",
680
+ "value": 1
681
+ }
682
+ },
683
+ "a9355a1d675c4ac4a2f68f4663a1d390": {
684
+ "model_module": "@jupyter-widgets/controls",
685
+ "model_module_version": "1.5.0",
686
+ "model_name": "ProgressStyleModel",
687
+ "state": {
688
+ "_model_module": "@jupyter-widgets/controls",
689
+ "_model_module_version": "1.5.0",
690
+ "_model_name": "ProgressStyleModel",
691
+ "_view_count": null,
692
+ "_view_module": "@jupyter-widgets/base",
693
+ "_view_module_version": "1.2.0",
694
+ "_view_name": "StyleView",
695
+ "bar_color": null,
696
+ "description_width": ""
697
+ }
698
+ },
699
+ "a9ef94f8656c483ebb8ee36c33c21a15": {
700
+ "model_module": "@jupyter-widgets/controls",
701
+ "model_module_version": "1.5.0",
702
+ "model_name": "HBoxModel",
703
+ "state": {
704
+ "_dom_classes": [],
705
+ "_model_module": "@jupyter-widgets/controls",
706
+ "_model_module_version": "1.5.0",
707
+ "_model_name": "HBoxModel",
708
+ "_view_count": null,
709
+ "_view_module": "@jupyter-widgets/controls",
710
+ "_view_module_version": "1.5.0",
711
+ "_view_name": "HBoxView",
712
+ "box_style": "",
713
+ "children": [
714
+ "IPY_MODEL_00dd3ba2c97a4a5f9e20e4c90ad4bcf8",
715
+ "IPY_MODEL_9bac4c96e2b741b782da7fc36b79ead1",
716
+ "IPY_MODEL_d4f9d577a48e46d39a86be7ad18f96d9"
717
+ ],
718
+ "layout": "IPY_MODEL_e47db715aee544a38f1286b2861e378f"
719
+ }
720
+ },
721
+ "b6d2b0649d794440aa5e5c77fdba4c34": {
722
+ "model_module": "@jupyter-widgets/controls",
723
+ "model_module_version": "1.5.0",
724
+ "model_name": "DescriptionStyleModel",
725
+ "state": {
726
+ "_model_module": "@jupyter-widgets/controls",
727
+ "_model_module_version": "1.5.0",
728
+ "_model_name": "DescriptionStyleModel",
729
+ "_view_count": null,
730
+ "_view_module": "@jupyter-widgets/base",
731
+ "_view_module_version": "1.2.0",
732
+ "_view_name": "StyleView",
733
+ "description_width": ""
734
+ }
735
+ },
736
+ "ccfd6307c2cd4ba6b49e10ddb4a70d66": {
737
+ "model_module": "@jupyter-widgets/base",
738
+ "model_module_version": "1.2.0",
739
+ "model_name": "LayoutModel",
740
+ "state": {
741
+ "_model_module": "@jupyter-widgets/base",
742
+ "_model_module_version": "1.2.0",
743
+ "_model_name": "LayoutModel",
744
+ "_view_count": null,
745
+ "_view_module": "@jupyter-widgets/base",
746
+ "_view_module_version": "1.2.0",
747
+ "_view_name": "LayoutView",
748
+ "align_content": null,
749
+ "align_items": null,
750
+ "align_self": null,
751
+ "border": null,
752
+ "bottom": null,
753
+ "display": null,
754
+ "flex": null,
755
+ "flex_flow": null,
756
+ "grid_area": null,
757
+ "grid_auto_columns": null,
758
+ "grid_auto_flow": null,
759
+ "grid_auto_rows": null,
760
+ "grid_column": null,
761
+ "grid_gap": null,
762
+ "grid_row": null,
763
+ "grid_template_areas": null,
764
+ "grid_template_columns": null,
765
+ "grid_template_rows": null,
766
+ "height": null,
767
+ "justify_content": null,
768
+ "justify_items": null,
769
+ "left": null,
770
+ "margin": null,
771
+ "max_height": null,
772
+ "max_width": null,
773
+ "min_height": null,
774
+ "min_width": null,
775
+ "object_fit": null,
776
+ "object_position": null,
777
+ "order": null,
778
+ "overflow": null,
779
+ "overflow_x": null,
780
+ "overflow_y": null,
781
+ "padding": null,
782
+ "right": null,
783
+ "top": null,
784
+ "visibility": null,
785
+ "width": null
786
+ }
787
+ },
788
+ "d354d88c25b04ca18c0d23d61f4e9cba": {
789
+ "model_module": "@jupyter-widgets/controls",
790
+ "model_module_version": "1.5.0",
791
+ "model_name": "ProgressStyleModel",
792
+ "state": {
793
+ "_model_module": "@jupyter-widgets/controls",
794
+ "_model_module_version": "1.5.0",
795
+ "_model_name": "ProgressStyleModel",
796
+ "_view_count": null,
797
+ "_view_module": "@jupyter-widgets/base",
798
+ "_view_module_version": "1.2.0",
799
+ "_view_name": "StyleView",
800
+ "bar_color": null,
801
+ "description_width": ""
802
+ }
803
+ },
804
+ "d4f9d577a48e46d39a86be7ad18f96d9": {
805
+ "model_module": "@jupyter-widgets/controls",
806
+ "model_module_version": "1.5.0",
807
+ "model_name": "HTMLModel",
808
+ "state": {
809
+ "_dom_classes": [],
810
+ "_model_module": "@jupyter-widgets/controls",
811
+ "_model_module_version": "1.5.0",
812
+ "_model_name": "HTMLModel",
813
+ "_view_count": null,
814
+ "_view_module": "@jupyter-widgets/controls",
815
+ "_view_module_version": "1.5.0",
816
+ "_view_name": "HTMLView",
817
+ "description": "",
818
+ "description_tooltip": null,
819
+ "layout": "IPY_MODEL_025d370c61d84fcba1a866731a16ee27",
820
+ "placeholder": "​",
821
+ "style": "IPY_MODEL_b6d2b0649d794440aa5e5c77fdba4c34",
822
+ "value": " 191/? [00:17&lt;00:00, 22.28it/s]"
823
+ }
824
+ },
825
+ "e11a7d4a03954577aa59223fbe24780d": {
826
+ "model_module": "@jupyter-widgets/base",
827
+ "model_module_version": "1.2.0",
828
+ "model_name": "LayoutModel",
829
+ "state": {
830
+ "_model_module": "@jupyter-widgets/base",
831
+ "_model_module_version": "1.2.0",
832
+ "_model_name": "LayoutModel",
833
+ "_view_count": null,
834
+ "_view_module": "@jupyter-widgets/base",
835
+ "_view_module_version": "1.2.0",
836
+ "_view_name": "LayoutView",
837
+ "align_content": null,
838
+ "align_items": null,
839
+ "align_self": null,
840
+ "border": null,
841
+ "bottom": null,
842
+ "display": null,
843
+ "flex": null,
844
+ "flex_flow": null,
845
+ "grid_area": null,
846
+ "grid_auto_columns": null,
847
+ "grid_auto_flow": null,
848
+ "grid_auto_rows": null,
849
+ "grid_column": null,
850
+ "grid_gap": null,
851
+ "grid_row": null,
852
+ "grid_template_areas": null,
853
+ "grid_template_columns": null,
854
+ "grid_template_rows": null,
855
+ "height": null,
856
+ "justify_content": null,
857
+ "justify_items": null,
858
+ "left": null,
859
+ "margin": null,
860
+ "max_height": null,
861
+ "max_width": null,
862
+ "min_height": null,
863
+ "min_width": null,
864
+ "object_fit": null,
865
+ "object_position": null,
866
+ "order": null,
867
+ "overflow": null,
868
+ "overflow_x": null,
869
+ "overflow_y": null,
870
+ "padding": null,
871
+ "right": null,
872
+ "top": null,
873
+ "visibility": null,
874
+ "width": null
875
+ }
876
+ },
877
+ "e47db715aee544a38f1286b2861e378f": {
878
+ "model_module": "@jupyter-widgets/base",
879
+ "model_module_version": "1.2.0",
880
+ "model_name": "LayoutModel",
881
+ "state": {
882
+ "_model_module": "@jupyter-widgets/base",
883
+ "_model_module_version": "1.2.0",
884
+ "_model_name": "LayoutModel",
885
+ "_view_count": null,
886
+ "_view_module": "@jupyter-widgets/base",
887
+ "_view_module_version": "1.2.0",
888
+ "_view_name": "LayoutView",
889
+ "align_content": null,
890
+ "align_items": null,
891
+ "align_self": null,
892
+ "border": null,
893
+ "bottom": null,
894
+ "display": null,
895
+ "flex": null,
896
+ "flex_flow": null,
897
+ "grid_area": null,
898
+ "grid_auto_columns": null,
899
+ "grid_auto_flow": null,
900
+ "grid_auto_rows": null,
901
+ "grid_column": null,
902
+ "grid_gap": null,
903
+ "grid_row": null,
904
+ "grid_template_areas": null,
905
+ "grid_template_columns": null,
906
+ "grid_template_rows": null,
907
+ "height": null,
908
+ "justify_content": null,
909
+ "justify_items": null,
910
+ "left": null,
911
+ "margin": null,
912
+ "max_height": null,
913
+ "max_width": null,
914
+ "min_height": null,
915
+ "min_width": null,
916
+ "object_fit": null,
917
+ "object_position": null,
918
+ "order": null,
919
+ "overflow": null,
920
+ "overflow_x": null,
921
+ "overflow_y": null,
922
+ "padding": null,
923
+ "right": null,
924
+ "top": null,
925
+ "visibility": null,
926
+ "width": null
927
+ }
928
+ },
929
+ "f0190337a99243e4b022dcf565dc7f5c": {
930
+ "model_module": "@jupyter-widgets/base",
931
+ "model_module_version": "1.2.0",
932
+ "model_name": "LayoutModel",
933
+ "state": {
934
+ "_model_module": "@jupyter-widgets/base",
935
+ "_model_module_version": "1.2.0",
936
+ "_model_name": "LayoutModel",
937
+ "_view_count": null,
938
+ "_view_module": "@jupyter-widgets/base",
939
+ "_view_module_version": "1.2.0",
940
+ "_view_name": "LayoutView",
941
+ "align_content": null,
942
+ "align_items": null,
943
+ "align_self": null,
944
+ "border": null,
945
+ "bottom": null,
946
+ "display": null,
947
+ "flex": null,
948
+ "flex_flow": null,
949
+ "grid_area": null,
950
+ "grid_auto_columns": null,
951
+ "grid_auto_flow": null,
952
+ "grid_auto_rows": null,
953
+ "grid_column": null,
954
+ "grid_gap": null,
955
+ "grid_row": null,
956
+ "grid_template_areas": null,
957
+ "grid_template_columns": null,
958
+ "grid_template_rows": null,
959
+ "height": null,
960
+ "justify_content": null,
961
+ "justify_items": null,
962
+ "left": null,
963
+ "margin": null,
964
+ "max_height": null,
965
+ "max_width": null,
966
+ "min_height": null,
967
+ "min_width": null,
968
+ "object_fit": null,
969
+ "object_position": null,
970
+ "order": null,
971
+ "overflow": null,
972
+ "overflow_x": null,
973
+ "overflow_y": null,
974
+ "padding": null,
975
+ "right": null,
976
+ "top": null,
977
+ "visibility": null,
978
+ "width": "20px"
979
+ }
980
+ },
981
+ "f4f69c0ea946405a8c1b88e68cfe6e38": {
982
+ "model_module": "@jupyter-widgets/controls",
983
+ "model_module_version": "1.5.0",
984
+ "model_name": "FloatProgressModel",
985
+ "state": {
986
+ "_dom_classes": [],
987
+ "_model_module": "@jupyter-widgets/controls",
988
+ "_model_module_version": "1.5.0",
989
+ "_model_name": "FloatProgressModel",
990
+ "_view_count": null,
991
+ "_view_module": "@jupyter-widgets/controls",
992
+ "_view_module_version": "1.5.0",
993
+ "_view_name": "ProgressView",
994
+ "bar_style": "success",
995
+ "description": "",
996
+ "description_tooltip": null,
997
+ "layout": "IPY_MODEL_8d39835b987249799b1d000f9960e6f9",
998
+ "max": 150,
999
+ "min": 0,
1000
+ "orientation": "horizontal",
1001
+ "style": "IPY_MODEL_d354d88c25b04ca18c0d23d61f4e9cba",
1002
+ "value": 150
1003
+ }
1004
+ }
1005
+ }
1006
+ }
1007
+ },
1008
+ "nbformat": 4,
1009
+ "nbformat_minor": 5
1010
+ }
script.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### This is example of the script that will be run in the test environment.
2
+ ### Some parts of the code are compulsory and you should NOT CHANGE THEM.
3
+ ### They are between '''---compulsory---''' comments.
4
+ ### You can change the rest of the code to define and test your solution.
5
+ ### However, you should not change the signature of the provided function.
6
+ ### The script would save "submission.parquet" file in the current directory.
7
+ ### You can use any additional files and subdirectories to organize your code.
8
+
9
+ '''---compulsory---'''
10
+ import hoho; hoho.setup() # YOU MUST CALL hoho.setup() BEFORE ANYTHING ELSE
11
+ '''---compulsory---'''
12
+
13
+ from pathlib import Path
14
+ from tqdm import tqdm
15
+ import pandas as pd
16
+ import numpy as np
17
+
18
+
19
+ def empty_solution(sample):
20
+ '''Return a minimal valid solution, i.e. 2 vertices and 1 edge.'''
21
+ return np.zeros((2,3)), [(0, 1)]
22
+
23
+
24
+ if __name__ == "__main__":
25
+ print ("------------ Loading dataset------------ ")
26
+ params = hoho.get_params()
27
+
28
+ # by default it is usually better to use `get_dataset()` like this
29
+ #
30
+ # dataset = hoho.get_dataset(split='all')
31
+ #
32
+ # but in this case (because we don't do anything with the sample
33
+ # anyway) we set `decode=None`. We can set the `split` argument
34
+ # to 'train' or 'val' ('all' defaults back to 'train') if we are
35
+ # testing ourselves locally.
36
+ #
37
+ # dataset = hoho.get_dataset(split='val', decode=None)
38
+ #
39
+ # On the test server *`split` must be set to 'all'*
40
+ # to compute both the public and private leaderboards.
41
+ #
42
+ dataset = hoho.get_dataset(split='all', decode=None)
43
+
44
+ print('------------ Now you can do your solution ---------------')
45
+ solution = []
46
+ for i, sample in enumerate(tqdm(dataset)):
47
+ # replace this with your solution
48
+ pred_vertices, pred_edges = empty_solution(sample)
49
+
50
+ solution.append({
51
+ '__key__': sample['__key__'],
52
+ 'wf_vertices': pred_vertices.tolist(),
53
+ 'wf_edges': pred_edges
54
+ })
55
+ print('------------ Saving results ---------------')
56
+ sub = pd.DataFrame(solution, columns=["__key__", "wf_vertices", "wf_edges"])
57
+ sub.to_parquet(Path(params['output_path']) / "submission.parquet")
58
+ print("------------ Done ------------ ")