mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-24 00:26:08 +08:00
Add std for eval (#2239)
* Add std for eval * change default value of get_std --------- Co-authored-by: khoa <tuankhoanguyen94@gmail.com>
This commit is contained in:
1 parent
e417ee07e7
commit
dbd4092dbb
2 files changed
+19
-6
No files matched your search
@@ -183,12 +183,15 @@ class Pipeline(nn.Module):
|
|||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
@profiler.time_function
|
@profiler.time_function
|
||||||
def get_average_eval_image_metrics(self, step: Optional[int] = None, output_path: Optional[Path] = None):
|
def get_average_eval_image_metrics(
|
||||||
|
self, step: Optional[int] = None, output_path: Optional[Path] = None, get_std: bool = False
|
||||||
|
):
|
||||||
"""Iterate over all the images in the eval dataset and get the average.
|
"""Iterate over all the images in the eval dataset and get the average.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
step: current training step
|
step: current training step
|
||||||
output_path: optional path to save rendered images to
|
output_path: optional path to save rendered images to
|
||||||
|
get_std: Set True if you want to return std with the mean metric.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def load_pipeline(self, loaded_state: Dict[str, Any], step: int) -> None:
|
def load_pipeline(self, loaded_state: Dict[str, Any], step: int) -> None:
|
||||||
@@ -354,12 +357,15 @@ class VanillaPipeline(Pipeline):
|
|||||||
return metrics_dict, images_dict
|
return metrics_dict, images_dict
|
||||||
|
|
||||||
@profiler.time_function
|
@profiler.time_function
|
||||||
def get_average_eval_image_metrics(self, step: Optional[int] = None, output_path: Optional[Path] = None):
|
def get_average_eval_image_metrics(
|
||||||
|
self, step: Optional[int] = None, output_path: Optional[Path] = None, get_std: bool = False
|
||||||
|
):
|
||||||
"""Iterate over all the images in the eval dataset and get the average.
|
"""Iterate over all the images in the eval dataset and get the average.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
step: current training step
|
step: current training step
|
||||||
output_path: optional path to save rendered images to
|
output_path: optional path to save rendered images to
|
||||||
|
get_std: Set True if you want to return std with the mean metric.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
metrics_dict: dictionary of metrics
|
metrics_dict: dictionary of metrics
|
||||||
@@ -401,9 +407,16 @@ class VanillaPipeline(Pipeline):
|
|||||||
# average the metrics list
|
# average the metrics list
|
||||||
metrics_dict = {}
|
metrics_dict = {}
|
||||||
for key in metrics_dict_list[0].keys():
|
for key in metrics_dict_list[0].keys():
|
||||||
metrics_dict[key] = float(
|
if get_std:
|
||||||
torch.mean(torch.tensor([metrics_dict[key] for metrics_dict in metrics_dict_list]))
|
key_std, key_mean = torch.std_mean(
|
||||||
)
|
torch.tensor([metrics_dict[key] for metrics_dict in metrics_dict_list])
|
||||||
|
)
|
||||||
|
metrics_dict[key] = float(key_mean)
|
||||||
|
metrics_dict[f"{key}_std"] = float(key_std)
|
||||||
|
else:
|
||||||
|
metrics_dict[key] = float(
|
||||||
|
torch.mean(torch.tensor([metrics_dict[key] for metrics_dict in metrics_dict_list]))
|
||||||
|
)
|
||||||
self.train()
|
self.train()
|
||||||
return metrics_dict
|
return metrics_dict
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class ComputePSNR:
|
|||||||
assert self.output_path.suffix == ".json"
|
assert self.output_path.suffix == ".json"
|
||||||
if self.render_output_path is not None:
|
if self.render_output_path is not None:
|
||||||
self.render_output_path.mkdir(parents=True)
|
self.render_output_path.mkdir(parents=True)
|
||||||
metrics_dict = pipeline.get_average_eval_image_metrics(output_path=self.render_output_path)
|
metrics_dict = pipeline.get_average_eval_image_metrics(output_path=self.render_output_path, get_std=True)
|
||||||
self.output_path.parent.mkdir(parents=True, exist_ok=True)
|
self.output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
# Get the output and define the names to save to
|
# Get the output and define the names to save to
|
||||||
benchmark_info = {
|
benchmark_info = {
|
||||||
|
|||||||
Reference in new issue
Block a user