From 56d1d19f01a8ff6a3164ead5f096f053481fea49 Mon Sep 17 00:00:00 2001
From: Anthony Zhang <47730496+AntonioMacaronio@users.noreply.github.com>
Date: Thu, 29 Feb 2024 22:47:40 -0800
Subject: [PATCH] Adding Terminal Window to Jupyter Cells so all Colab users
(free and pro) can train with Nerfstudio (#2870)
* adding terminal window to jupyter cells for free colab users to train and render
* updating torchaudio package dependency
* deleting viewer connection cell, replaced with ns-train's sharable URL viewer link
* fixing flying apostrophe
* fixing pip torch download installation typo
---------
Co-authored-by: Gina Wu <42229107+ginazhouhuiwu@users.noreply.github.com>
---
colab/demo.ipynb | 90 ++++++------------------------------------------
1 file changed, 10 insertions(+), 80 deletions(-)
diff --git a/colab/demo.ipynb b/colab/demo.ipynb
index aeb3def01..96eaa25ff 100644
--- a/colab/demo.ipynb
+++ b/colab/demo.ipynb
@@ -74,7 +74,7 @@
"\n",
"%cd /content/\n",
"!pip install --upgrade pip\n",
- "!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118\n",
+ "!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118\n",
"\n",
"# Installing TinyCuda\n",
"%cd /content/\n",
@@ -166,84 +166,6 @@
"print(\"Data Processing Succeeded!\")"
]
},
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "cellView": "form",
- "colab": {
- "base_uri": "https://localhost:8080/",
- "height": 928
- },
- "id": "VoKDxqEcjmfC",
- "outputId": "d2919aa4-96dd-4e50-829f-289e4208882b"
- },
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "/content\n",
- "\u001b[K\u001b[?25h/tools/node/bin/lt -> /tools/node/lib/node_modules/localtunnel/bin/lt.js\n",
- "\u001b[K\u001b[?25h+ localtunnel@2.0.2\n",
- "added 22 packages from 22 contributors in 2.07s\n",
- "https://viewer.nerf.studio/?websocket_url=wss://cyan-facts-matter-34-91-1-218.loca.lt\n",
- "You may need to click Refresh Page after you start training!\n"
- ]
- },
- {
- "data": {
- "text/html": [
- "\n",
- " \n",
- " "
- ],
- "text/plain": [
- ""
- ]
- },
- "execution_count": 2,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "#@markdown Set up and Start Viewer
\n",
- "\n",
- "%cd /content\n",
- "\n",
- "# Install localtunnel\n",
- "# We are using localtunnel https://github.com/localtunnel/localtunnel but ngrok could also be used\n",
- "!npm install -g localtunnel\n",
- "\n",
- "# Tunnel port 7007, the default for\n",
- "!rm url.txt 2> /dev/null\n",
- "get_ipython().system_raw('lt --port 7007 >> url.txt 2>&1 &')\n",
- "\n",
- "import time\n",
- "time.sleep(3) # the previous command needs time to write to url.txt\n",
- "\n",
- "\n",
- "with open('url.txt') as f:\n",
- " lines = f.readlines()\n",
- "websocket_url = lines[0].split(\": \")[1].strip().replace(\"https\", \"wss\")\n",
- "# from nerfstudio.utils.io import load_from_json\n",
- "# from pathlib import Path\n",
- "# json_filename = \"nerfstudio/nerfstudio/viewer/app/package.json\"\n",
- "# version = load_from_json(Path(json_filename))[\"version\"]\n",
- "url = f\"https://viewer.nerf.studio/?websocket_url={websocket_url}\"\n",
- "print(url)\n",
- "print(\"You may need to click Refresh Page after you start training!\")\n",
- "from IPython import display\n",
- "display.IFrame(src=url, height=800, width=\"100%\")"
- ]
- },
{
"cell_type": "code",
"execution_count": null,
@@ -256,8 +178,16 @@
"#@markdown Start Training
\n",
"\n",
"%cd /content\n",
+ "!pip install colab-xterm\n",
+ "%load_ext colabxterm\n",
+ "%env TERM=xterm\n",
+ "from IPython.display import clear_output\n",
+ "clear_output(wait=True)\n",
"if os.path.exists(f\"data/nerfstudio/{scene}/transforms.json\"):\n",
- " !ns-train nerfacto --viewer.websocket-port 7007 nerfstudio-data --data data/nerfstudio/$scene --downscale-factor 4\n",
+ " print(\"\\033[1m\" + \"Copy and paste the following command into the terminal window that pops up under this cell.\" + \"\\033[0m\")\n",
+ " print(f\"ns-train nerfacto --viewer.websocket-port 7007 --viewer.make-share-url True nerfstudio-data --data data/nerfstudio/{scene} --downscale-factor 4\")\n",
+ " print()\n",
+ " %xterm\n",
"else:\n",
" from IPython.core.display import display, HTML\n",
" display(HTML('Error: Data processing did not complete
'))\n",