{ "cells": [ { "cell_type": "markdown", "id": "Mq5iNIZ9xWxt", "metadata": { "id": "Mq5iNIZ9xWxt" }, "source": [ "# Empty Submission Example for S23DR Challenge\n", "\n", "### Helpful Links\n", "[Challenge Page](https://huggingface.co/spaces/usm3d/S23DR) \n", "[Workshop Page](usm3d.github.io) \n", "\n", "[HoHo Train Set](https://huggingface.co/datasets/usm3d/hoho-train-set) \n", "[Handcrafted Baseline Solution](https://huggingface.co/usm3d/handcrafted_baseline_submission) \n", " " ] }, { "cell_type": "markdown", "id": "dua8UJOoxiDi", "metadata": { "id": "dua8UJOoxiDi" }, "source": [ "## Setup\n", "\n", "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))." ] }, { "cell_type": "code", "execution_count": 1, "id": "ItDDqoXop8bb", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "ItDDqoXop8bb", "outputId": "0c9d26a7-bf79-4452-c772-d5579a9cb2a9" }, "outputs": [], "source": [ "try:\n", " import google.colab\n", " IN_COLAB = True\n", "except:\n", " IN_COLAB = False\n", "\n", "if IN_COLAB:\n", " !pip install git+http://hf.co/usm3d/tools.git" ] }, { "cell_type": "markdown", "id": "2tHX74Z-x1cU", "metadata": { "id": "2tHX74Z-x1cU" }, "source": [ "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." ] }, { "cell_type": "code", "execution_count": 2, "id": "zq_ljluLqzzv", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "zq_ljluLqzzv", "outputId": "b66806f1-b88a-47e0-8194-79515b73fa23" }, "outputs": [], "source": [ "if IN_COLAB:\n", " !huggingface-cli login" ] }, { "cell_type": "markdown", "id": "Xf2PY79fywa5", "metadata": { "id": "Xf2PY79fywa5" }, "source": [ "## Data Download, Analysis, and Visualization" ] }, { "cell_type": "code", "execution_count": 3, "id": "e171b1ec-e861-4349-98fd-2eac4d080ff5", "metadata": { "id": "e171b1ec-e861-4349-98fd-2eac4d080ff5" }, "outputs": [], "source": [ "import hoho\n", "from hoho import *\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from pathlib import Path\n", "from collections import Counter\n", "import itertools\n", "import datasets\n", "import trimesh\n", "from tqdm.notebook import tqdm\n", "import webdataset as wds\n", "import sys" ] }, { "cell_type": "markdown", "id": "83649a4c-fde7-4051-ba71-e596d382e76a", "metadata": { "id": "83649a4c-fde7-4051-ba71-e596d382e76a" }, "source": [ "### Load the hoho package and point to the data folder\n", "\n", "We download only one shard of the data" ] }, { "cell_type": "code", "execution_count": 4, "id": "ffffc234", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "ffffc234", "outputId": "e969db58-e88e-457a-eee2-14e65c8117fb" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/jack/dev/USM3D/comp/tools/hoho/hoho.py:309: UserWarning: streaming isn't using with 'all': changing `split` to 'train'\n", " warnings.warn('streaming isn\\'t using with \\'all\\': changing `split` to \\'train\\'')\n", "/Users/jack/dev/USM3D/comp/tools/hoho/hoho.py:310: UserWarning: no tarfiles found in data/usm-training-data/data/val.\n", " warnings.warn(msg)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "/Users/jack/dev/USM3D/comp/empty_submission\n", "total 104\n", "-rw-r--r-- 1 jack staff 1.5K Apr 26 12:51 .gitattributes\n", "-rw-r--r-- 1 jack staff 855B Apr 26 12:51 README.md\n", "drwxr-xr-x 10 jack staff 320B Apr 26 12:55 \u001b[34m..\u001b[m\u001b[m\n", "drwxr-xr-x 3 jack staff 96B Apr 26 15:06 \u001b[34mdata\u001b[m\u001b[m\n", "-rw-r--r-- 1 jack staff 5.8K Apr 26 15:42 submission.parquet\n", "-rw-r--r-- 1 jack staff 2.3K Apr 26 15:50 script.py\n", "drwxr-xr-x 15 jack staff 480B Apr 26 15:50 \u001b[34m.git\u001b[m\u001b[m\n", "-rw-r--r-- 1 jack staff 32K Apr 26 18:26 example_notebook.ipynb\n", "drwxr-xr-x 9 jack staff 288B Apr 28 10:32 \u001b[34m.\u001b[m\u001b[m\n", "Using data/usm-training-data/data as the data directory (we are running locally)\n", "------------ Loading dataset------------ \n", "params.json not found (this means we probably aren't in the test env). Using example params.\n", "{'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': ' 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", "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", "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", "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", "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", "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", "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", "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", "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", "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", "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", "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", "\u001b[0;31mKeyboardInterrupt\u001b[0m: " ] } ], "source": [ "# %load script.py\n", "### This is example of the script that will be run in the test environment.\n", "### Some parts of the code are compulsory and you should NOT CHANGE THEM.\n", "### They are between '''---compulsory---''' comments.\n", "### You can change the rest of the code to define and test your solution.\n", "### However, you should not change the signature of the provided function.\n", "### The script would save \"submission.parquet\" file in the current directory.\n", "### You can use any additional files and subdirectories to organize your code.\n", "\n", "'''---compulsory---'''\n", "import hoho; hoho.setup() # YOU MUST CALL hoho.setup() BEFORE ANYTHING ELSE\n", "'''---compulsory---'''\n", "\n", "from pathlib import Path\n", "from tqdm import tqdm\n", "import pandas as pd\n", "import numpy as np\n", "\n", "\n", "def empty_solution(sample):\n", " '''Return a minimal valid solution, i.e. 2 vertices and 1 edge.'''\n", " return np.zeros((2,3)), [(0, 1)]\n", "\n", "\n", "if __name__ == \"__main__\":\n", " print (\"------------ Loading dataset------------ \")\n", " params = hoho.get_params()\n", " \n", " # by default it is usually better to use `get_dataset()` like this\n", " # \n", " # dataset = hoho.get_dataset(split='all')\n", " # \n", " # but in this case (because we don't do anything with the sample \n", " # anyway) we set `decode=None`. We can set the `split` argument \n", " # to 'train' or 'val' ('all' defaults back to 'train') if we are \n", " # testing ourselves locally. \n", " # \n", " # dataset = hoho.get_dataset(split='val', decode=None)\n", " #\n", " # On the test server *`split` must be set to 'all'* \n", " # to compute both the public and private leaderboards.\n", " # \n", " dataset = hoho.get_dataset(split='all', decode=None)\n", " \n", " print('------------ Now you can do your solution ---------------')\n", " solution = []\n", " for i, sample in enumerate(tqdm(dataset)):\n", " # replace this with your solution\n", " pred_vertices, pred_edges = empty_solution(sample)\n", " \n", " solution.append({\n", " '__key__': sample['__key__'], \n", " 'wf_vertices': pred_vertices.tolist(),\n", " 'wf_edges': pred_edges\n", " })\n", " print('------------ Saving results ---------------')\n", " sub = pd.DataFrame(solution, columns=[\"__key__\", \"wf_vertices\", \"wf_edges\"])\n", " sub.to_parquet(Path(params['output_path']) / \"submission.parquet\")\n", " print(\"------------ Done ------------ \")" ] }, { "cell_type": "code", "execution_count": null, "id": "f077cbd7", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "b65ed78e", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "a4584502", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "colab": { "provenance": [], "toc_visible": true }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.10.13" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "00dd3ba2c97a4a5f9e20e4c90ad4bcf8": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_e11a7d4a03954577aa59223fbe24780d", "placeholder": "​", "style": "IPY_MODEL_4d456e625cc248c18a6ee6171919a462", "value": "" } }, "025d370c61d84fcba1a866731a16ee27": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "1bee0e2f81104a22bad736cea9725dcb": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "2509efdc0c6a4dd6b1ade16d30e8209d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "2ac27da2aa014ec782d2e7073d153f99": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "452e42ee4a734b7a98b5945cffff9dac": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_2509efdc0c6a4dd6b1ade16d30e8209d", "placeholder": "​", "style": "IPY_MODEL_2ac27da2aa014ec782d2e7073d153f99", "value": "Map: 100%" } }, "453f4cacb5bf490cb90f10c9cdccca30": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_452e42ee4a734b7a98b5945cffff9dac", "IPY_MODEL_f4f69c0ea946405a8c1b88e68cfe6e38", "IPY_MODEL_8e41e4539ee54d708b593c5d44699855" ], "layout": "IPY_MODEL_9a3ccc55920d4f9588e89e4d5579b0b0" } }, "4d456e625cc248c18a6ee6171919a462": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "8d39835b987249799b1d000f9960e6f9": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "8e41e4539ee54d708b593c5d44699855": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_ccfd6307c2cd4ba6b49e10ddb4a70d66", "placeholder": "​", "style": "IPY_MODEL_1bee0e2f81104a22bad736cea9725dcb", "value": " 150/150 [00:02<00:00, 55.18 examples/s]" } }, "9a3ccc55920d4f9588e89e4d5579b0b0": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "9bac4c96e2b741b782da7fc36b79ead1": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_f0190337a99243e4b022dcf565dc7f5c", "max": 1, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_a9355a1d675c4ac4a2f68f4663a1d390", "value": 1 } }, "a9355a1d675c4ac4a2f68f4663a1d390": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "a9ef94f8656c483ebb8ee36c33c21a15": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_00dd3ba2c97a4a5f9e20e4c90ad4bcf8", "IPY_MODEL_9bac4c96e2b741b782da7fc36b79ead1", "IPY_MODEL_d4f9d577a48e46d39a86be7ad18f96d9" ], "layout": "IPY_MODEL_e47db715aee544a38f1286b2861e378f" } }, "b6d2b0649d794440aa5e5c77fdba4c34": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "ccfd6307c2cd4ba6b49e10ddb4a70d66": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "d354d88c25b04ca18c0d23d61f4e9cba": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "d4f9d577a48e46d39a86be7ad18f96d9": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_025d370c61d84fcba1a866731a16ee27", "placeholder": "​", "style": "IPY_MODEL_b6d2b0649d794440aa5e5c77fdba4c34", "value": " 191/? [00:17<00:00, 22.28it/s]" } }, "e11a7d4a03954577aa59223fbe24780d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "e47db715aee544a38f1286b2861e378f": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "f0190337a99243e4b022dcf565dc7f5c": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": "20px" } }, "f4f69c0ea946405a8c1b88e68cfe6e38": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_8d39835b987249799b1d000f9960e6f9", "max": 150, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_d354d88c25b04ca18c0d23d61f4e9cba", "value": 150 } } } } }, "nbformat": 4, "nbformat_minor": 5 }