Switch to conda install for COLMAP; formatting

This commit is contained in:
Gina Wu committed 2023-10-20 14:57:51 -07:00
1 parent 1cb99e9f95
commit 1a2b521c10
1 file changed
+55 -148
+55 -148
View File
@@ -3,8 +3,8 @@
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
"colab_type": "text",
"id": "view-in-github"
},
"source": [
"<a href=\"https://colab.research.google.com/github/nerfstudio-project/nerfstudio/blob/alex%2Fcolab310/colab/demo.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
@@ -43,8 +43,13 @@
"id": "Yyx5h6kz5ga7"
},
"source": [
"## Frequently Asked Questions\n",
"\n",
"## Frequently Asked Questions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* **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. Terminating the cell early will result in not being able to train.\n",
"* **Processing custom data is taking a long time:**\n",
@@ -58,19 +63,26 @@
"* **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"
" * Feel free to create an issue on our [GitHub repo](https://github.com/nerfstudio-project/nerfstudio)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Nerfstudio Demo"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "9oyLHl8QfYwP",
"cellView": "form"
"cellView": "form",
"id": "9oyLHl8QfYwP"
},
"outputs": [],
"source": [
"#@markdown <h1>Install Nerfstudio and Dependencies (~8 min)</h1>\n",
"#@markdown <h3>Install Nerfstudio and Dependencies (~8 min)</h3>\n",
"\n",
"%cd /content/\n",
"!pip install --upgrade pip\n",
@@ -81,36 +93,26 @@
"!gdown \"https://drive.google.com/u/1/uc?id=1-7x7qQfB7bIw2zV4Lr6-yhvMpjXC84Q5&confirm=t\"\n",
"!pip install tinycudann-1.7-cp310-cp310-linux_x86_64.whl\n",
"\n",
"# Installing COLMAP\n",
"%cd /content/\n",
"!gdown \"https://drive.google.com/u/0/uc?id=15WngFRNar_b8CaPR5R-hvQ3eAnlyk_SL&confirm=t\"\n",
"!sudo apt-get install \\\n",
" build-essential \\\n",
" libboost-program-options-dev \\\n",
" libboost-filesystem-dev \\\n",
" libboost-graph-dev \\\n",
" libboost-system-dev \\\n",
" libboost-test-dev \\\n",
" libeigen3-dev \\\n",
" libflann-dev \\\n",
" libfreeimage-dev \\\n",
" libmetis-dev \\\n",
" libgoogle-glog-dev \\\n",
" libgflags-dev \\\n",
" libsqlite3-dev \\\n",
" libglew-dev \\\n",
" qtbase5-dev \\\n",
" libqt5opengl5-dev \\\n",
" libcgal-dev \\\n",
" libceres-dev\n",
"!unzip local.zip -d /usr/\n",
"!chmod +x /usr/local/bin/colmap\n",
"\n",
"# Install nerfstudio\n",
"%cd /content/\n",
"!pip install git+https://github.com/nerfstudio-project/nerfstudio.git"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#@markdown <h3>Install COLMAP: Necessary for custom dataset (~15 min)</h3>\n",
"#@markdown <medium>Skip to the next cell if running on demo data.<br/medium>\n",
"#@markdown <medium>Run this cell only if you are uploading your own data. Installation takes a while to complete.<br/medium>\n",
"\n",
"# Installing COLMAP via conda\n",
"%cd /content\n",
"!conda install -c conda-forge colmap"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -120,8 +122,9 @@
},
"outputs": [],
"source": [
"#@markdown <h1> Downloading and Processing Data</h1>\n",
"#@markdown <h3>Pick the preset scene or upload your own images/video</h3>\n",
"#@markdown <h3> Downloading and Processing Data</h3>\n",
"#@markdown <medium>Pick the preset scene or upload your own images/video</medium>\n",
"\n",
"import os\n",
"import glob\n",
"from google.colab import files\n",
@@ -187,84 +190,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,
@@ -274,11 +199,12 @@
},
"outputs": [],
"source": [
"#@markdown <h1>Start Training</h1>\n",
"#@markdown <h2>Start Training</h2>\n",
"#@markdown <big>Open the generated share url to access viewer.<br/big>\n",
"\n",
"%cd /content\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",
" !ns-train nerfacto --viewer.websocket-port 7007 --vis viewer_beta --viewer.make-share-url True nerfstudio-data --data data/nerfstudio/$scene --downscale-factor 4\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",
@@ -296,38 +222,11 @@
"id": "WGt8ukG6Htg3",
"outputId": "fa946890-c7d8-4e46-a54e-7231bc5a2059"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[2;36m[19:48:48]\u001b[0m\u001b[2;36m \u001b[0mSkipping \u001b[1;36m0\u001b[0m files in dataset split train. \u001b]8;id=527413;file:///content/nerfstudio/nerfstudio/data/dataparsers/nerfstudio_dataparser.py\u001b\\\u001b[2mnerfstudio_dataparser.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=243595;file:///content/nerfstudio/nerfstudio/data/dataparsers/nerfstudio_dataparser.py#91\u001b\\\u001b[2m91\u001b[0m\u001b]8;;\u001b\\\n",
"\u001b[2;36m \u001b[0m\u001b[2;36m \u001b[0mSkipping \u001b[1;36m0\u001b[0m files in dataset split test. \u001b]8;id=109270;file:///content/nerfstudio/nerfstudio/data/dataparsers/nerfstudio_dataparser.py\u001b\\\u001b[2mnerfstudio_dataparser.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=464675;file:///content/nerfstudio/nerfstudio/data/dataparsers/nerfstudio_dataparser.py#91\u001b\\\u001b[2m91\u001b[0m\u001b]8;;\u001b\\\n",
"\u001b[2KLoading data batch \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[35m100%\u001b[0m \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25h/usr/local/lib/python3.7/site-packages/torch/utils/data/dataloader.py:566: UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.\n",
" cpuset_checked))\n",
"\u001b[2KLoading data batch \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[35m100%\u001b[0m \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25h/usr/local/lib/python3.7/site-packages/torchvision/models/_utils.py:209: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and will be removed in 0.15, please use 'weights' instead.\n",
" f\"The parameter '{pretrained_param}' is deprecated since 0.13 and will be removed in 0.15, \"\n",
"/usr/local/lib/python3.7/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and will be removed in 0.15. The current behavior is equivalent to passing `weights=AlexNet_Weights.IMAGENET1K_V1`. You can also use `weights=AlexNet_Weights.DEFAULT` to get the most up-to-date weights.\n",
" warnings.warn(msg)\n",
"Loading latest checkpoint from load_dir\n",
"✅ Done loading checkpoint from \n",
"outputs/data-nerfstudio-poster/nerfacto/\u001b[1;36m2022\u001b[0m-\u001b[1;36m10\u001b[0m-29_192844/nerfstudio_models/step-\u001b[1;36m000014000.\u001b[0mckpt\n",
"\u001b[1;32mCreating trajectory video\u001b[0m\n",
"\u001b[2K🎥 Rendering 🎥 \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[35m100%\u001b[0m \u001b[31m0.14 fps\u001b[0m \u001b[33m11:47\u001b[0m\n",
"\u001b[2K\u001b[32m( ● )\u001b[0m \u001b[33mSaving video\u001b[0m\n",
"\u001b[1A\u001b[2K\u001b[92m────────────────────────────────────────────── \u001b[0m\u001b[32m 🎉 🎉 🎉 Success 🎉 🎉 🎉\u001b[0m\u001b[92m ──────────────────────────────────────────────\u001b[0m\n",
" \u001b[32mSaved video to renders/output.mp4\u001b[0m \n",
"\u001b[0m"
]
}
],
"outputs": [],
"source": [
"#@title # Render Video { vertical-output: true }\n",
"#@markdown <h3>Export the camera path from within the viewer, then run this cell.</h3>\n",
"#@markdown <h5>The rendered video should be at renders/output.mp4!</h5>\n",
"\n",
"#@markdown <medium>Export the camera path from within the viewer, then run this cell.<br/medium>\n",
"#@markdown <medium>The rendered video should be at renders/output.mp4!</mediun>\n",
"\n",
"base_dir = \"/content/outputs/unnamed/nerfacto/\"\n",
"training_run_dir = base_dir + os.listdir(base_dir)[0]\n",
@@ -350,8 +249,8 @@
"metadata": {
"accelerator": "GPU",
"colab": {
"provenance": [],
"include_colab_link": true
"include_colab_link": true,
"provenance": []
},
"gpuClass": "standard",
"kernelspec": {
@@ -360,8 +259,16 @@
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"version": "3.8.13"
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
},
"vscode": {
"interpreter": {