mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-07 00:09:14 +08:00
Add 'inference' mode to pipeline (#956)
* cleanup test mode * cleanup eval loading * change default * cleanup * cleanup * comment
This commit is contained in:
1 parent
b67f96fc56
commit
b5c34f0154
7 files changed
+64
-38
No files matched your search
@@ -20,7 +20,7 @@ from __future__ import annotations
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Optional, Tuple
|
||||
from typing import Literal, Optional, Tuple
|
||||
|
||||
import torch
|
||||
import yaml
|
||||
@@ -63,11 +63,21 @@ def eval_load_checkpoint(config: cfg.TrainerConfig, pipeline: Pipeline) -> Path:
|
||||
return load_path
|
||||
|
||||
|
||||
def eval_setup(config_path: Path, eval_num_rays_per_chunk: Optional[int] = None) -> Tuple[cfg.Config, Pipeline, Path]:
|
||||
def eval_setup(
|
||||
config_path: Path,
|
||||
eval_num_rays_per_chunk: Optional[int] = None,
|
||||
test_mode: Literal["test", "val", "inference"] = "test",
|
||||
) -> Tuple[cfg.Config, Pipeline, Path]:
|
||||
"""Shared setup for loading a saved pipeline for evaluation.
|
||||
|
||||
Args:
|
||||
config_path: Path to config YAML file.
|
||||
eval_num_rays_per_chunk: Number of rays per forward pass
|
||||
test_mode:
|
||||
'val': loads train/val datasets into memory
|
||||
'test': loads train/test datset into memory
|
||||
'inference': does not load any dataset into memory
|
||||
|
||||
|
||||
Returns:
|
||||
Loaded config, pipeline module, and corresponding checkpoint.
|
||||
@@ -86,7 +96,7 @@ def eval_setup(config_path: Path, eval_num_rays_per_chunk: Optional[int] = None)
|
||||
|
||||
# setup pipeline (which includes the DataManager)
|
||||
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
||||
pipeline = config.pipeline.setup(device=device, test_mode=True)
|
||||
pipeline = config.pipeline.setup(device=device, test_mode=test_mode)
|
||||
assert isinstance(pipeline, Pipeline)
|
||||
pipeline.eval()
|
||||
|
||||
|
||||
Reference in new issue
Block a user