mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-17 05:14:15 +08:00
Merge branch 'main' into justin/opensfm
This commit is contained in:
commit
d8265b4b21
9 files changed
+83
-56
No files matched your search
@@ -133,46 +133,52 @@ def _update_rc(
|
||||
"""
|
||||
|
||||
# Install or uninstall `source_line`.
|
||||
source_lines = "\n".join(
|
||||
[
|
||||
"",
|
||||
"# 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}",
|
||||
]
|
||||
)
|
||||
header_line = "# Source nerfstudio autocompletions."
|
||||
if shell == "zsh":
|
||||
source_lines = "\n".join(
|
||||
[
|
||||
"",
|
||||
header_line,
|
||||
"if ! command -v compdef &> /dev/null; then",
|
||||
" autoload -Uz compinit",
|
||||
" compinit",
|
||||
"fi",
|
||||
f"source {completions_dir / 'setup.zsh'}",
|
||||
]
|
||||
)
|
||||
elif shell == "bash":
|
||||
source_lines = "\n".join(
|
||||
[
|
||||
"",
|
||||
header_line,
|
||||
f"source {completions_dir / 'setup.bash'}",
|
||||
]
|
||||
)
|
||||
else:
|
||||
assert_never(shell)
|
||||
|
||||
rc_path = pathlib.Path(os.environ["HOME"]) / f".{shell}rc"
|
||||
|
||||
# Always try to uninstall previous completions.
|
||||
rc_source = rc_path.read_text()
|
||||
while header_line in rc_source:
|
||||
before_install, _, after_install = rc_source.partition(header_line)
|
||||
source_file, _, after_install = after_install.partition("\nsource ")[2].partition("\n")
|
||||
assert source_file.endswith(f"/completions/setup.{shell}")
|
||||
rc_source = before_install + after_install
|
||||
rc_path.write_text(rc_source)
|
||||
CONSOLE.log(f":broom: Existing completions uninstalled from {rc_path}.")
|
||||
|
||||
# Install completions.
|
||||
if mode == "install":
|
||||
if source_lines in rc_path.read_text():
|
||||
CONSOLE.log(f":call_me_hand: Completions are already installed in {rc_path}. {_exclamation()}")
|
||||
return
|
||||
|
||||
if not Confirm.ask(f"[bold yellow]Install to {rc_path}?", default=True):
|
||||
CONSOLE.log(f"[bold red]Skipping install for {rc_path.name}.")
|
||||
return
|
||||
|
||||
rc_path.write_text(rc_path.read_text() + source_lines)
|
||||
assert source_lines not in rc_source
|
||||
rc_path.write_text(rc_source.rstrip() + "\n" + source_lines)
|
||||
CONSOLE.log(
|
||||
f":person_gesturing_ok: Completions installed to {rc_path}. {_exclamation()} Open a new shell to try them"
|
||||
" out."
|
||||
)
|
||||
|
||||
elif mode == "uninstall":
|
||||
if source_lines not in rc_path.read_text():
|
||||
CONSOLE.log(f":heavy_check_mark: No completions to uninstall from {rc_path.name}.")
|
||||
return
|
||||
|
||||
if not Confirm.ask(f"[bold yellow]Uninstall from {rc_path}?", default=True):
|
||||
CONSOLE.log(f"[dim red]Skipping uninstall for {rc_path.name}.")
|
||||
return
|
||||
|
||||
rc_path.write_text(rc_path.read_text().replace(source_lines, ""))
|
||||
CONSOLE.log(f":broom: Completions uninstalled from {rc_path}.")
|
||||
|
||||
else:
|
||||
assert_never(mode)
|
||||
assert mode == "uninstall"
|
||||
|
||||
|
||||
def main(mode: ConfigureMode = "install") -> None:
|
||||
|
||||
@@ -32,7 +32,8 @@ def download_blender(save_dir: Path):
|
||||
unzip_path = save_dir / Path("nerf_synthetic")
|
||||
final_path = save_dir / Path("blender")
|
||||
unzip_path.rename(final_path)
|
||||
download_path.unlink(missing_ok=True)
|
||||
if download_path.exists():
|
||||
download_path.unlink()
|
||||
|
||||
|
||||
def download_friends(save_dir: Path):
|
||||
@@ -123,7 +124,8 @@ def download_dnerf(save_dir: Path):
|
||||
unzip_path = save_dir / Path("data")
|
||||
final_path = save_dir / Path("dnerf")
|
||||
unzip_path.rename(final_path)
|
||||
download_path.unlink(missing_ok=True)
|
||||
if download_path.exists():
|
||||
download_path.unlink()
|
||||
|
||||
|
||||
def main(
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ CONSOLE = Console(width=120)
|
||||
|
||||
@dataclass
|
||||
class ComputePSNR:
|
||||
"""Load a checkpoint, compute some PSNR metrics, and save to a JSON."""
|
||||
"""Load a checkpoint, compute some PSNR metrics, and save it to a JSON file."""
|
||||
|
||||
# Path to config YAML file.
|
||||
load_config: Path
|
||||
@@ -28,17 +28,17 @@ class ComputePSNR:
|
||||
def main(self) -> None:
|
||||
"""Main function."""
|
||||
config, pipeline, checkpoint_path = eval_setup(self.load_config)
|
||||
|
||||
assert self.output_path.suffix == ".json"
|
||||
metrics_dict = pipeline.get_average_eval_image_metrics()
|
||||
# save output to some file
|
||||
self.output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
# Get the output and define the names to save to
|
||||
benchmark_info = {
|
||||
"experiment_name": config.experiment_name,
|
||||
"method_name": config.method_name,
|
||||
"checkpoint": str(checkpoint_path),
|
||||
"results": metrics_dict,
|
||||
}
|
||||
# Save output to output file
|
||||
self.output_path.write_text(json.dumps(benchmark_info, indent=2), "utf8")
|
||||
CONSOLE.print(f"Saved results to: {self.output_path}")
|
||||
|
||||
|
||||
@@ -230,11 +230,9 @@ def convert_insta360_to_images(
|
||||
front_vf_cmds = vf_cmds + ["transpose=2"]
|
||||
back_vf_cmds = vf_cmds + ["transpose=1"]
|
||||
|
||||
front_ffmpeg_cmd = (
|
||||
f"ffmpeg -i {video_front} -vf '{','.join(front_vf_cmds)}' -r 1 {image_dir / 'frame_%05d.png'}"
|
||||
)
|
||||
front_ffmpeg_cmd = f"ffmpeg -i {video_front} -vf {','.join(front_vf_cmds)} -r 1 {image_dir / 'frame_%05d.png'}"
|
||||
back_ffmpeg_cmd = (
|
||||
f"ffmpeg -i {video_back} -vf '{','.join(back_vf_cmds)}' -r 1 {image_dir / 'back_frame_%05d.png'}"
|
||||
f"ffmpeg -i {video_back} -vf {','.join(back_vf_cmds)} -r 1 {image_dir / 'back_frame_%05d.png'}"
|
||||
)
|
||||
|
||||
run_command(front_ffmpeg_cmd, verbose=verbose)
|
||||
@@ -347,7 +345,10 @@ def run_colmap(
|
||||
|
||||
colmap_version = get_colmap_version()
|
||||
|
||||
(colmap_dir / "database.db").unlink(missing_ok=True)
|
||||
colmap_database_path = colmap_dir / "database.db"
|
||||
if colmap_database_path.exists():
|
||||
# Can't use missing_ok argument because of Python 3.7 compatibility.
|
||||
colmap_database_path.unlink()
|
||||
|
||||
# Feature extraction
|
||||
feature_extractor_cmd = [
|
||||
|
||||
Reference in new issue
Block a user