Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use packaging for colmap version #2814

Merged
merged 3 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions nerfstudio/process_data/colmap_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import numpy as np
import requests
import torch
from packaging.version import Version
from rich.progress import track

# TODO(1480) use pycolmap instead of colmap_parsing_utils
Expand All @@ -42,7 +43,7 @@
from nerfstudio.utils.scripts import run_command


def get_colmap_version(colmap_cmd: str, default_version=3.8) -> float:
def get_colmap_version(colmap_cmd: str, default_version: str = "3.8") -> Version:
"""Returns the version of COLMAP.
This code assumes that colmap returns a version string of the form
"COLMAP 3.8 ..." which may not be true for all versions of COLMAP.
Expand All @@ -57,10 +58,10 @@ def get_colmap_version(colmap_cmd: str, default_version=3.8) -> float:
for line in output.split("\n"):
if line.startswith("COLMAP"):
version = line.split(" ")[1]
version = "".join([c for c in version if c.isdigit() or c == "."])
return float(version)
version = Version(version)
return version
CONSOLE.print(f"[bold red]Could not find COLMAP version. Using default {default_version}")
return default_version
return Version(default_version)


def get_vocab_tree() -> Path:
Expand Down Expand Up @@ -158,7 +159,7 @@ def run_colmap(
f"--image_path {image_dir}",
f"--output_path {sparse_dir}",
]
if colmap_version >= 3.7:
if colmap_version >= Version("3.7"):
mapper_cmd.append("--Mapper.ba_global_function_tolerance=1e-6")

mapper_cmd = " ".join(mapper_cmd)
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ dependencies = [
"timm==0.6.7",
"gsplat==0.1.2.1",
"pytorch-msssim",
"pathos"
"pathos",
"packaging"
]

[project.urls]
Expand Down
Loading