mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-16 12:53:44 +08:00
Google Colab support with viewer (#747)
* allows bridge server to run on a different machine * added script * update version * starting docs * update docs and scripts * ngrok support * use tcp * moving webrtc outside bridge server. wop * lazy commit * lazy commit * running code. webrtc not working * lazy commit * better logic for webrtc connection * cleanup * todo comment * working webrtc * removed logging * fixing black * fix eslint * fix python version * fix readme * misc cleanup * small docs fix Co-authored-by: Ethan Weber <ethanweber@Ethans-MacBook-Pro.local>
This commit is contained in:
1 parent
a4755a1349
commit
d71c05f256
37 files changed
+324
-329
No files matched your search
@@ -137,6 +137,9 @@ def _update_rc(
|
||||
[
|
||||
"",
|
||||
"# Source nerfstudio autocompletions.",
|
||||
"# From https://unix.stackexchange.com/questions/339954/zsh-command-not-found-compinstall-compinit-compdef",
|
||||
"autoload -Uz compinit",
|
||||
"compinit",
|
||||
f"source {completions_dir / 'setup'}.{shell}",
|
||||
]
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ import nbformat as nbf
|
||||
import tyro
|
||||
from rich.console import Console
|
||||
|
||||
console = Console(width=120)
|
||||
CONSOLE = Console(width=120)
|
||||
|
||||
|
||||
def main(check: bool = False):
|
||||
@@ -47,7 +47,7 @@ def main(check: bool = False):
|
||||
found_tags.append(val)
|
||||
|
||||
if len(found_keys) > 1:
|
||||
console.print(f"[bold yellow]Found multiple tags {found_keys} for {ipath}")
|
||||
CONSOLE.print(f"[bold yellow]Found multiple tags {found_keys} for {ipath}")
|
||||
sys.exit(1)
|
||||
|
||||
if len(cell_tags) != len(found_tags):
|
||||
@@ -59,7 +59,7 @@ def main(check: bool = False):
|
||||
cell["metadata"]["tags"] = found_tags
|
||||
if incorrect_metadata:
|
||||
if check:
|
||||
console.print(
|
||||
CONSOLE.print(
|
||||
f"[bold yellow]{ipath} has incorrect metadata. Call `python scripts.docs.add_nb_tags.py` to add it."
|
||||
)
|
||||
any_missing = True
|
||||
@@ -68,7 +68,7 @@ def main(check: bool = False):
|
||||
nbf.write(ntbk, ipath)
|
||||
|
||||
if not any_missing:
|
||||
console.print("[green]All notebooks have correct metadata.")
|
||||
CONSOLE.print("[green]All notebooks have correct metadata.")
|
||||
|
||||
if check and any_missing:
|
||||
sys.exit(1)
|
||||
|
||||
@@ -7,7 +7,7 @@ import tyro
|
||||
from rich.console import Console
|
||||
from rich.style import Style
|
||||
|
||||
console = Console(width=120)
|
||||
CONSOLE = Console(width=120)
|
||||
|
||||
LOCAL_TESTS = ["Run license checks", "Run Black", "Python Pylint", "Test with pytest"]
|
||||
|
||||
@@ -20,7 +20,7 @@ def run_command(command: str) -> None:
|
||||
"""
|
||||
ret_code = subprocess.call(command, shell=True)
|
||||
if ret_code != 0:
|
||||
console.print(f"[bold red]Error: `{command}` failed. Exiting...")
|
||||
CONSOLE.print(f"[bold red]Error: `{command}` failed. Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@@ -31,20 +31,20 @@ def main(clean_cache: bool = False):
|
||||
clean_cache: whether to clean the cache before building docs.
|
||||
"""
|
||||
|
||||
console.print("[green]Adding notebook documentation metadata")
|
||||
CONSOLE.print("[green]Adding notebook documentation metadata")
|
||||
run_command("python scripts/docs/add_nb_tags.py")
|
||||
|
||||
# Add checks for building documentation
|
||||
console.print("[green]Building Documentation")
|
||||
CONSOLE.print("[green]Building Documentation")
|
||||
if clean_cache:
|
||||
run_command("cd docs/; make clean; make html SPHINXOPTS='-W;'")
|
||||
else:
|
||||
run_command("cd docs/; make html SPHINXOPTS='-W;'")
|
||||
|
||||
console.line()
|
||||
console.rule(characters="=", style=Style(color="green"))
|
||||
console.print("[bold green]Done")
|
||||
console.rule(characters="=", style=Style(color="green"))
|
||||
CONSOLE.line()
|
||||
CONSOLE.rule(characters="=", style=Style(color="green"))
|
||||
CONSOLE.print("[bold green]Done")
|
||||
CONSOLE.rule(characters="=", style=Style(color="green"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -10,7 +10,7 @@ import gdown
|
||||
import tyro
|
||||
from rich.console import Console
|
||||
|
||||
console = Console(width=120)
|
||||
CONSOLE = Console(width=120)
|
||||
|
||||
|
||||
def download_blender(save_dir: Path):
|
||||
@@ -131,19 +131,19 @@ def main(
|
||||
|
||||
if dataset == "blender":
|
||||
if capture_name is not None:
|
||||
console.print("Capture name is ignored when downloading from the blender dataset.")
|
||||
CONSOLE.print("Capture name is ignored when downloading from the blender dataset.")
|
||||
download_blender(save_dir)
|
||||
if dataset == "friends":
|
||||
if capture_name is not None:
|
||||
console.print("Capture name is ignored when downloading from the blender dataset.")
|
||||
CONSOLE.print("Capture name is ignored when downloading from the blender dataset.")
|
||||
download_friends(save_dir)
|
||||
if dataset == "nerfstudio":
|
||||
if capture_name is None:
|
||||
capture_names = sorted(nerfstudio_file_ids.keys())
|
||||
console.rule("[bold red]Error", style="bold red")
|
||||
console.print("[bold yellow]You must pass in --capture-name when downloading from the nerfstudio dataset.")
|
||||
console.print("Use one of the following:")
|
||||
console.print(f"\t {capture_names}")
|
||||
CONSOLE.rule("[bold red]Error", style="bold red")
|
||||
CONSOLE.print("[bold yellow]You must pass in --capture-name when downloading from the nerfstudio dataset.")
|
||||
CONSOLE.print("Use one of the following:")
|
||||
CONSOLE.print(f"\t {capture_names}")
|
||||
sys.exit()
|
||||
download_nerfstudio(save_dir, capture_name)
|
||||
if dataset == "record3d":
|
||||
|
||||
+2
-5
@@ -5,7 +5,6 @@ eval.py
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
@@ -14,9 +13,7 @@ from rich.console import Console
|
||||
|
||||
from nerfstudio.utils.eval_utils import eval_setup
|
||||
|
||||
console = Console(width=120)
|
||||
|
||||
logging.basicConfig(format="[%(filename)s:%(lineno)d] %(message)s", level=logging.INFO)
|
||||
CONSOLE = Console(width=120)
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -43,7 +40,7 @@ class ComputePSNR:
|
||||
"results": metrics_dict,
|
||||
}
|
||||
self.output_path.write_text(json.dumps(benchmark_info, indent=2), "utf8")
|
||||
console.print(f"Saved results to: {self.output_path}")
|
||||
CONSOLE.print(f"Saved results to: {self.output_path}")
|
||||
|
||||
|
||||
def entrypoint():
|
||||
|
||||
@@ -8,7 +8,7 @@ import yaml
|
||||
from rich.console import Console
|
||||
from rich.style import Style
|
||||
|
||||
console = Console(width=120)
|
||||
CONSOLE = Console(width=120)
|
||||
|
||||
LOCAL_TESTS = ["Run license checks", "Run isort", "Run Black", "Python Pylint", "Test with pytest"]
|
||||
|
||||
@@ -22,7 +22,7 @@ def run_command(command: str, continue_on_fail: bool = False) -> bool:
|
||||
"""
|
||||
ret_code = subprocess.call(command, shell=True)
|
||||
if ret_code != 0:
|
||||
console.print(f"[bold red]Error: `{command}` failed.")
|
||||
CONSOLE.print(f"[bold red]Error: `{command}` failed.")
|
||||
if not continue_on_fail:
|
||||
sys.exit(1)
|
||||
return ret_code == 0
|
||||
@@ -47,31 +47,31 @@ def run_github_actions_file(filename: str, continue_on_fail: bool = False):
|
||||
compressed = compressed.replace("--check", "")
|
||||
curr_command = f"{compressed}"
|
||||
|
||||
console.line()
|
||||
console.rule(f"[bold green]Running: {curr_command}")
|
||||
CONSOLE.line()
|
||||
CONSOLE.rule(f"[bold green]Running: {curr_command}")
|
||||
success = success and run_command(curr_command, continue_on_fail=continue_on_fail)
|
||||
else:
|
||||
skip_name = step["name"] if "name" in step else step["uses"]
|
||||
console.print(f"Skipping {skip_name}")
|
||||
CONSOLE.print(f"Skipping {skip_name}")
|
||||
|
||||
# Add checks for building documentation
|
||||
console.line()
|
||||
console.rule("[bold green]Adding notebook documentation metadata")
|
||||
CONSOLE.line()
|
||||
CONSOLE.rule("[bold green]Adding notebook documentation metadata")
|
||||
success = success and run_command("python scripts/docs/add_nb_tags.py", continue_on_fail=continue_on_fail)
|
||||
console.line()
|
||||
console.rule("[bold green]Building Documentation")
|
||||
CONSOLE.line()
|
||||
CONSOLE.rule("[bold green]Building Documentation")
|
||||
success = success and run_command("cd docs/; make html SPHINXOPTS='-W;'", continue_on_fail=continue_on_fail)
|
||||
|
||||
if success:
|
||||
console.line()
|
||||
console.rule(characters="=")
|
||||
console.print("[bold green]:TADA: :TADA: :TADA: ALL CHECKS PASSED :TADA: :TADA: :TADA:", justify="center")
|
||||
console.rule(characters="=")
|
||||
CONSOLE.line()
|
||||
CONSOLE.rule(characters="=")
|
||||
CONSOLE.print("[bold green]:TADA: :TADA: :TADA: ALL CHECKS PASSED :TADA: :TADA: :TADA:", justify="center")
|
||||
CONSOLE.rule(characters="=")
|
||||
else:
|
||||
console.line()
|
||||
console.rule(characters="=", style=Style(color="red"))
|
||||
console.print("[bold red]:skull: :skull: :skull: ERRORS FOUND :skull: :skull: :skull:", justify="center")
|
||||
console.rule(characters="=", style=Style(color="red"))
|
||||
CONSOLE.line()
|
||||
CONSOLE.rule(characters="=", style=Style(color="red"))
|
||||
CONSOLE.print("[bold red]:skull: :skull: :skull: ERRORS FOUND :skull: :skull: :skull:", justify="center")
|
||||
CONSOLE.rule(characters="=", style=Style(color="red"))
|
||||
|
||||
|
||||
def run_code_checks(continue_on_fail: bool = False):
|
||||
|
||||
+8
-11
@@ -6,7 +6,6 @@ from __future__ import annotations
|
||||
|
||||
import dataclasses
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Literal, Optional
|
||||
@@ -32,9 +31,7 @@ from nerfstudio.utils import install_checks
|
||||
from nerfstudio.utils.eval_utils import eval_setup
|
||||
from nerfstudio.utils.rich_utils import ItersPerSecColumn
|
||||
|
||||
console = Console(width=120)
|
||||
|
||||
logging.basicConfig(format="[%(filename)s:%(lineno)d] %(message)s", level=logging.INFO)
|
||||
CONSOLE = Console(width=120)
|
||||
|
||||
|
||||
def _render_trajectory_video(
|
||||
@@ -55,7 +52,7 @@ def _render_trajectory_video(
|
||||
rendered_resolution_scaling_factor: Scaling factor to apply to the camera image resolution.
|
||||
seconds: Number for the output video.
|
||||
"""
|
||||
console.print("[bold green]Creating trajectory video")
|
||||
CONSOLE.print("[bold green]Creating trajectory video")
|
||||
images = []
|
||||
cameras.rescale_output_resolution(rendered_resolution_scaling_factor)
|
||||
|
||||
@@ -72,9 +69,9 @@ def _render_trajectory_video(
|
||||
with torch.no_grad():
|
||||
outputs = pipeline.model.get_outputs_for_camera_ray_bundle(camera_ray_bundle)
|
||||
if rendered_output_name not in outputs:
|
||||
console.rule("Error", style="red")
|
||||
console.print(f"Could not find {rendered_output_name} in the model outputs", justify="center")
|
||||
console.print(f"Please set --rendered_output_name to one of: {outputs.keys()}", justify="center")
|
||||
CONSOLE.rule("Error", style="red")
|
||||
CONSOLE.print(f"Could not find {rendered_output_name} in the model outputs", justify="center")
|
||||
CONSOLE.print(f"Please set --rendered_output_name to one of: {outputs.keys()}", justify="center")
|
||||
sys.exit(1)
|
||||
image = outputs[rendered_output_name].cpu().numpy()
|
||||
images.append(image)
|
||||
@@ -82,10 +79,10 @@ def _render_trajectory_video(
|
||||
fps = len(images) / seconds
|
||||
# make the folder if it doesn't exist
|
||||
output_filename.parent.mkdir(parents=True, exist_ok=True)
|
||||
with console.status("[yellow]Saving video", spinner="bouncingBall"):
|
||||
with CONSOLE.status("[yellow]Saving video", spinner="bouncingBall"):
|
||||
media.write_video(output_filename, images, fps=fps)
|
||||
console.rule("[green] :tada: :tada: :tada: Success :tada: :tada: :tada:")
|
||||
console.print(f"[green]Saved video to {output_filename}", justify="center")
|
||||
CONSOLE.rule("[green] :tada: :tada: :tada: Success :tada: :tada: :tada:")
|
||||
CONSOLE.print(f"[green]Saved video to {output_filename}", justify="center")
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
|
||||
+8
-9
@@ -31,7 +31,6 @@ subcommand:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import random
|
||||
import socket
|
||||
import traceback
|
||||
@@ -44,6 +43,7 @@ import torch.distributed as dist
|
||||
import torch.multiprocessing as mp
|
||||
import tyro
|
||||
import yaml
|
||||
from rich.console import Console
|
||||
|
||||
from nerfstudio.configs import base_config as cfg
|
||||
from nerfstudio.configs.config_utils import convert_markup_to_ansi
|
||||
@@ -51,8 +51,7 @@ from nerfstudio.configs.method_configs import AnnotatedBaseConfigUnion
|
||||
from nerfstudio.engine.trainer import train_loop
|
||||
from nerfstudio.utils import comms, profiler
|
||||
|
||||
logging.basicConfig(format="[%(filename)s:%(lineno)d] %(message)s", level=logging.DEBUG)
|
||||
|
||||
CONSOLE = Console(width=120)
|
||||
DEFAULT_TIMEOUT = timedelta(minutes=30)
|
||||
|
||||
# speedup for when input size to model doesn't change (much)
|
||||
@@ -117,7 +116,7 @@ def _distributed_worker(
|
||||
timeout=timeout,
|
||||
)
|
||||
except Exception as e:
|
||||
logging.error("Process group URL: %s", dist_url)
|
||||
CONSOLE.log(f"Process group URL: {dist_url}")
|
||||
raise e
|
||||
|
||||
assert comms._LOCAL_PROCESS_GROUP is None # pylint: disable=protected-access
|
||||
@@ -181,7 +180,7 @@ def launch(
|
||||
port = _find_free_port()
|
||||
dist_url = f"tcp://127.0.0.1:{port}"
|
||||
if num_machines > 1 and dist_url.startswith("file://"):
|
||||
logging.warning("file:// is not a reliable init_method in multi-machine jobs. Prefer tcp://")
|
||||
CONSOLE.log("file:// is not a reliable init_method in multi-machine jobs. Prefer tcp://")
|
||||
|
||||
process_context = mp.spawn(
|
||||
_distributed_worker,
|
||||
@@ -202,10 +201,10 @@ def launch(
|
||||
except KeyboardInterrupt:
|
||||
for i, process in enumerate(process_context.processes):
|
||||
if process.is_alive():
|
||||
logging.info("Terminating process %s", str(i))
|
||||
CONSOLE.log("Terminating process %s", str(i))
|
||||
process.terminate()
|
||||
process.join()
|
||||
logging.info("Process %s finished", str(i))
|
||||
CONSOLE.log("Process %s finished", str(i))
|
||||
finally:
|
||||
profiler.flush_profiler(config.logging)
|
||||
|
||||
@@ -215,11 +214,11 @@ def main(config: cfg.Config) -> None:
|
||||
|
||||
config.set_timestamp()
|
||||
if config.data:
|
||||
logging.info("Using --data alias for --data.pipeline.datamanager.dataparser.data")
|
||||
CONSOLE.log("Using --data alias for --data.pipeline.datamanager.dataparser.data")
|
||||
config.pipeline.datamanager.dataparser.data = config.data
|
||||
|
||||
if config.trainer.load_config:
|
||||
logging.info(f"Loading pre-set config from: {config.trainer.load_config}")
|
||||
CONSOLE.log(f"Loading pre-set config from: {config.trainer.load_config}")
|
||||
config = yaml.load(config.trainer.load_config.read_text(), Loader=yaml.Loader)
|
||||
|
||||
# print and save config
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
"""
|
||||
Runs the viewer bridge server.
|
||||
"""
|
||||
from nerfstudio.viewer.server.server import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -3,7 +3,9 @@
|
||||
view_dataset.py
|
||||
"""
|
||||
|
||||
import logging
|
||||
from rich.console import Console
|
||||
|
||||
CONSOLE = Console(width=120)
|
||||
import time
|
||||
from datetime import timedelta
|
||||
from pathlib import Path
|
||||
@@ -11,13 +13,11 @@ from pathlib import Path
|
||||
import torch
|
||||
import tyro
|
||||
|
||||
from nerfstudio.configs import model_configs as cfg
|
||||
from nerfstudio.configs import method_configs as cfg
|
||||
from nerfstudio.data.datamanagers import AnnotatedDataParserUnion
|
||||
from nerfstudio.data.utils.datasets import InputDataset
|
||||
from nerfstudio.viewer.server import viewer_utils
|
||||
|
||||
logging.basicConfig(format="[%(filename)s:%(lineno)d] %(message)s", level=logging.INFO)
|
||||
|
||||
DEFAULT_TIMEOUT = timedelta(minutes=30)
|
||||
|
||||
# speedup for when input size to model doesn't change (much)
|
||||
@@ -36,7 +36,7 @@ def main(
|
||||
)
|
||||
dataset = InputDataset(dataparser.setup().get_dataset_inputs(split="train"))
|
||||
viewer_state.init_scene(dataset=dataset, start_train=False)
|
||||
logging.info("Please refresh and load page at: %s", viewer_state.viewer_url)
|
||||
CONSOLE.log("Please refresh and load page at: %s", viewer_state.viewer_url)
|
||||
time.sleep(30) # allowing time to refresh page
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user