mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-03 22:38:48 +08:00
merge
This commit is contained in:
1 parent
17d837babf
commit
b6f878f227
3 files changed
+27
-16
No files matched your search
+5
-2
@@ -3,7 +3,11 @@ resume_train:
|
|||||||
load_dir: # pretrained model directory
|
load_dir: # pretrained model directory
|
||||||
load_step: # pretrained model's step number
|
load_step: # pretrained model's step number
|
||||||
|
|
||||||
save_step: 10
|
max_num_iterations: 1000000
|
||||||
|
steps_per_save: 1000
|
||||||
|
steps_per_log: 100
|
||||||
|
steps_per_test: 5000
|
||||||
|
|
||||||
model_dir: /tmp/mattport_models/
|
model_dir: /tmp/mattport_models/
|
||||||
|
|
||||||
# dataset options
|
# dataset options
|
||||||
@@ -37,7 +41,6 @@ param_groups:
|
|||||||
type: ExponentialLR
|
type: ExponentialLR
|
||||||
gamma: 0.1
|
gamma: 0.1
|
||||||
|
|
||||||
|
|
||||||
# machine options
|
# machine options
|
||||||
machine_config:
|
machine_config:
|
||||||
num_gpus: 4
|
num_gpus: 4
|
||||||
|
|||||||
+19
-14
@@ -120,21 +120,26 @@ class Trainer:
|
|||||||
|
|
||||||
def train(self) -> None:
|
def train(self) -> None:
|
||||||
"""_summary_"""
|
"""_summary_"""
|
||||||
num_epochs = 10
|
num_iterations = 1000
|
||||||
for _ in range(num_epochs):
|
for step in range(self.start_step, self.start_step + num_iterations):
|
||||||
self.train_iteration()
|
|
||||||
|
|
||||||
def train_iteration(self):
|
|
||||||
"""_summary_"""
|
|
||||||
num_iters = 100
|
|
||||||
for step in range(self.start_step, self.start_step + num_iters):
|
|
||||||
batch = next(iter(self.train_dataloader))
|
batch = next(iter(self.train_dataloader))
|
||||||
# move batch to correct device
|
losses = self.train_iteration(step, batch)
|
||||||
ray_indices = batch.indices.to(f"cuda:{self.local_rank}")
|
self.local_writer.write_text(f"{step}/{num_iterations}: losses", losses)
|
||||||
graph_outputs = self.graph(ray_indices)
|
|
||||||
batch.pixels = batch.pixels.to(f"cuda:{self.local_rank}")
|
|
||||||
losses = self.graph.module.get_losses(batch, graph_outputs)
|
|
||||||
self.local_writer.write_text(f"{step}/{num_iters}: losses", losses)
|
|
||||||
if step % self.config.save_step == 0:
|
if step % self.config.save_step == 0:
|
||||||
self.save_checkpoint(self.config.model_dir, step)
|
self.save_checkpoint(self.config.model_dir, step)
|
||||||
self.local_writer.write_text(f"ckpt at {step}", f"{losses}\n")
|
self.local_writer.write_text(f"ckpt at {step}", f"{losses}\n")
|
||||||
|
|
||||||
|
def train_iteration(self, step: int, batch: dict):
|
||||||
|
"""Run one iteration with a batch of inputs."""
|
||||||
|
# move batch to correct device
|
||||||
|
ray_indices = batch.indices.to(f"cuda:{self.local_rank}")
|
||||||
|
graph_outputs = self.graph(ray_indices)
|
||||||
|
batch.pixels = batch.pixels.to(f"cuda:{self.local_rank}")
|
||||||
|
losses = self.graph.module.get_losses(batch, graph_outputs)
|
||||||
|
return losses
|
||||||
|
|
||||||
|
def test(self, image_idx):
|
||||||
|
"""Test a specific image."""
|
||||||
|
with torch.no_grad():
|
||||||
|
ray_indices = None
|
||||||
|
|
||||||
@@ -21,6 +21,9 @@ logging.basicConfig(format="[%(filename)s:%(lineno)d] %(message)s", level=loggin
|
|||||||
|
|
||||||
DEFAULT_TIMEOUT = timedelta(minutes=30)
|
DEFAULT_TIMEOUT = timedelta(minutes=30)
|
||||||
|
|
||||||
|
# speedup for when input size to model doesn't change (much)
|
||||||
|
torch.backends.cudnn.benchmark = True
|
||||||
|
|
||||||
|
|
||||||
def _find_free_port() -> str:
|
def _find_free_port() -> str:
|
||||||
"""Find free port on open socket"""
|
"""Find free port on open socket"""
|
||||||
|
|||||||
Reference in new issue
Block a user