From fdbeb2ae3197c465860a8ff8638b9cf0facb4ef0 Mon Sep 17 00:00:00 2001 From: Alexander Kristoffersen Date: Fri, 11 Nov 2022 15:27:57 -0800 Subject: [PATCH] Streamline Viewer in Colab, added more checks before training (#947) Created using Colaboratory --- colab/demo.ipynb | 130 ++++++++++++++++++++++------------------------- 1 file changed, 61 insertions(+), 69 deletions(-) diff --git a/colab/demo.ipynb b/colab/demo.ipynb index 6149ba4fe..cd001aa85 100644 --- a/colab/demo.ipynb +++ b/colab/demo.ipynb @@ -7,7 +7,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -46,37 +46,42 @@ "## Frequently Asked Questions\n", "\n", "* **Downloading custom data is stalling (no output):**\n", - " * This is a bug in Colab. The data is processing, but may take a while to complete. You will know processing completed if `data/nerfstudio/custom_data/transforms.json` exists.\n", + " * This is a bug in Colab. The data is processing, but may take a while to complete. You will know processing completed if `data/nerfstudio/custom_data/transforms.json` exists. Terminating the cell early will result in not being able to train.\n", + "* **Processing custom data is taking a long time:**\n", + " * The time it takes to process data depends on the number of images and its resolution. If processing is taking too long, try lowering the resolution of your custom data.\n", + "* **Error: Data processing did not complete:**\n", + " * This means that the data processing script did not fully complete. This could be because there were not enough images, or that the images were of low quality. We recommend images with little to no motion blur and lots of visual overlap of the scene to increase the chances of successful processing.\n", "* **Training is not showing progress**:\n", " * The lack of output is a bug in Colab. You can see the training progress from the viewer.\n", - "\n", "* **Viewer Quality is bad / Low resolution**:\n", " * This may be because more GPU is being used on training that rendering the viewer. Try pausing training or decreasing training utilization.\n", - "\n", + "* **WARNING: Running pip as the 'root' user...:**:\n", + " * This and other pip warnings or errors can be safely ignored.\n", "* **Other problems?**\n", " * Feel free to create an issue on our [GitHub repo](https://github.com/nerfstudio-project/nerfstudio).\n" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 2, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "RGr33zHaHak0", - "outputId": "851bcce2-dce9-4cb4-8429-9ff0e27f73fe" + "outputId": "14f33da4-1e52-4784-e4e5-79e5d884fb8f" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ - "⏬ Downloading https://github.com/jaimergp/miniforge/releases/latest/download/Mambaforge-colab-Linux-x86_64.sh...\n", + "\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n", + "\u001b[0m⏬ Downloading https://github.com/jaimergp/miniforge/releases/latest/download/Mambaforge-colab-Linux-x86_64.sh...\n", "📦 Installing...\n", "📌 Adjusting configuration...\n", "🩹 Patching environment...\n", - "⏲ Done in 0:00:19\n", + "⏲ Done in 0:00:18\n", "🔁 Restarting kernel...\n" ] } @@ -119,13 +124,14 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "msVLprI4gRA4", - "outputId": "0be99061-71e1-4e33-98ab-5096db323841" + "outputId": "e8074daa-afd5-4021-ae41-27ce0e2bf0d8", + "cellView": "form" }, "outputs": [ { @@ -136,13 +142,13 @@ "Downloading...\n", "From: https://drive.google.com/uc?id=1dmjWGXlJnUxwosN6MVooCDQe970PkD-1\n", "To: /content/data/nerfstudio/poster.zip\n", - "100% 750M/750M [00:03<00:00, 199MB/s]\n", + "100% 750M/750M [00:02<00:00, 295MB/s]\n", "\u001b[0mData Processing Succeeded!\n" ] } ], "source": [ - "#@markdown

Downloading Data

\n", + "#@markdown

Downloading and Processing Data

\n", "#@markdown

Pick the preset scene or upload your own images/video

\n", "import os\n", "from google.colab import files\n", @@ -199,27 +205,51 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", "colab": { - "base_uri": "https://localhost:8080/" + "base_uri": "https://localhost:8080/", + "height": 928 }, - "id": "Eju-3p2hjcB2", - "outputId": "c9ff081c-2436-44c6-d292-f22dc3ef78b5" + "id": "VoKDxqEcjmfC", + "outputId": "d6c97ce9-f77a-4026-d6f3-328918435bb0", + "cellView": "form" }, "outputs": [ { - "name": "stdout", "output_type": "stream", + "name": "stdout", "text": [ "/content\n", "\u001b[K\u001b[?25h/tools/node/bin/lt -> /tools/node/lib/node_modules/localtunnel/bin/lt.js\n", "+ localtunnel@2.0.2\n", - "added 22 packages from 22 contributors in 1.536s\n" + "updated 1 package in 1.523s\n", + "https://viewer.nerf.studio/?websocket_url=wss://fifty-jars-return-34-124-199-158.loca.lt\n", + "You may need to click Refresh Page after you start training!\n" ] + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "\n", + " \n", + " " + ] + }, + "metadata": {}, + "execution_count": 1 } ], "source": [ - "#@title # Set Up Viewer\n", + "#@title # Set up and Start Viewer\n", "\n", "%cd /content\n", "\n", @@ -229,54 +259,11 @@ "\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 &')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "cellView": "form", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 857 - }, - "id": "VoKDxqEcjmfC", - "outputId": "b966821b-7d18-43ee-ceb3-724ac2d0c022" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "https://viewer.nerf.studio/?websocket_url=wss://good-ways-ask-34-83-255-230.loca.lt\n", - "You may need to click Refresh Page after you start training!\n" - ] - }, - { - "data": { - "text/html": [ - "\n", - " \n", - " " - ], - "text/plain": [ - "" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "#@title # Start Viewer\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", @@ -296,14 +283,19 @@ "cell_type": "code", "execution_count": null, "metadata": { - "id": "m_N8_cLfjoXD" + "id": "m_N8_cLfjoXD", + "cellView": "form" }, "outputs": [], "source": [ "#@title # Start Training { vertical-output: true }\n", "\n", "%cd /content\n", - "!ns-train nerfacto --viewer.websocket-port 7007 nerfstudio-data --data data/nerfstudio/$scene --downscale-factor 4" + "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", + "else:\n", + " display(HTML('

Error: Data processing did not complete

'))\n", + " display(HTML('

Please re-run `Downloading and Processing Data`, or view the FAQ for more info.

'))" ] }, {