mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-10 18:17:31 +08:00
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>
This commit is contained in:
parent
6df06f264e
commit
56d1d19f01
@ -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",
|
||||
" <iframe\n",
|
||||
" width=\"100%\"\n",
|
||||
" height=\"800\"\n",
|
||||
" src=\"https://viewer.nerf.studio/?websocket_url=wss://cyan-facts-matter-34-91-1-218.loca.lt\"\n",
|
||||
" frameborder=\"0\"\n",
|
||||
" allowfullscreen\n",
|
||||
" ></iframe>\n",
|
||||
" "
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.lib.display.IFrame at 0x7f1d0da6f950>"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#@markdown <h1>Set up and Start Viewer</h1>\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 <h1>Start Training</h1>\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('<h3 style=\"color:red\">Error: Data processing did not complete</h3>'))\n",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user