From 8cfe141fd7ffaba3419e418393adfddb8f678121 Mon Sep 17 00:00:00 2001 From: origamiman72 Date: Wed, 20 Jul 2022 17:36:24 -0700 Subject: [PATCH 1/3] Changed Rays / Sec formatting --- docs/index.rst | 4 ++-- scripts/run_eval.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index babd43971..63f2a02bd 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -67,7 +67,7 @@ Supported Models +------------------------+------------------------------+----------------------------+ -| | PSNR | Rays per sec. | +| | PSNR | Rays / sec. | +========================+==============================+============================+ | NeRF | |:hourglass_flowing_sand:| | |:hourglass_flowing_sand:| | +------------------------+------------------------------+----------------------------+ @@ -83,4 +83,4 @@ Indices and Tables * :ref:`genindex` * :ref:`modindex` -* :ref:`search` \ No newline at end of file +* :ref:`search` diff --git a/scripts/run_eval.py b/scripts/run_eval.py index ecf85e91a..b6a71ccfa 100644 --- a/scripts/run_eval.py +++ b/scripts/run_eval.py @@ -200,7 +200,7 @@ def main( avg_rays_per_sec = stats_dict["avg rays per sec"] avg_fps = stats_dict["avg fps"] print(f"Avg. PSNR: {avg_psnr:0.4f}") - print(f"Avg. Rays per sec: {avg_rays_per_sec:0.4f}") + print(f"Avg. Rays / Sec: {avg_rays_per_sec:.2e}") print(f"Avg. FPS: {avg_fps:0.4f}") elif method == MethodType.TRAJ: # TODO(ethan): pass in camera information into argparse parser From 66d23199ff8bbc180913f6a9e8aed6d5ab2251fa Mon Sep 17 00:00:00 2001 From: origamiman72 Date: Thu, 21 Jul 2022 21:47:05 -0700 Subject: [PATCH 2/3] Added human readable formatting --- pyrad/utils/misc.py | 9 +++++++++ scripts/run_eval.py | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pyrad/utils/misc.py b/pyrad/utils/misc.py index bf68cba22..68c3d0b94 100644 --- a/pyrad/utils/misc.py +++ b/pyrad/utils/misc.py @@ -23,6 +23,7 @@ from typing import Any, Dict import torch from omegaconf import DictConfig +from math import floor, log class DotDict(dict): @@ -90,3 +91,11 @@ def get_hash_str_from_dict(dictionary: Dict[str, Any]) -> str: encoded = json.dumps(dictionary, sort_keys=True).encode() dhash.update(encoded) return dhash.hexdigest() + + +def human_format(num): + """Format a number in a more human readable way""" + units = ["", "K", "M", "B", "T", "P"] + k = 1000.0 + magnitude = int(floor(log(num, k))) + return "%.2f %s" % (num / k**magnitude, units[magnitude]) diff --git a/scripts/run_eval.py b/scripts/run_eval.py index b6a71ccfa..81996c0bf 100644 --- a/scripts/run_eval.py +++ b/scripts/run_eval.py @@ -15,6 +15,7 @@ from tqdm import tqdm from pyrad.cameras.camera_paths import CameraPath, get_interpolated_camera_path, get_spiral_path from pyrad.data.dataloader import EvalDataloader, setup_dataset_eval, setup_dataset_train from pyrad.graphs.base import Graph, setup_graph +from pyrad.utils.misc import human_format from pyrad.utils.writer import TimeWriter @@ -200,7 +201,7 @@ def main( avg_rays_per_sec = stats_dict["avg rays per sec"] avg_fps = stats_dict["avg fps"] print(f"Avg. PSNR: {avg_psnr:0.4f}") - print(f"Avg. Rays / Sec: {avg_rays_per_sec:.2e}") + print(f"Avg. Rays / Sec: {human_format(avg_rays_per_sec)}") print(f"Avg. FPS: {avg_fps:0.4f}") elif method == MethodType.TRAJ: # TODO(ethan): pass in camera information into argparse parser From 27b8d94f8442ef839635a47d35b154add526df86 Mon Sep 17 00:00:00 2001 From: origamiman72 Date: Sun, 24 Jul 2022 02:13:47 -0700 Subject: [PATCH 3/3] Updated formatting --- pyrad/utils/misc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyrad/utils/misc.py b/pyrad/utils/misc.py index 68c3d0b94..b27afd055 100644 --- a/pyrad/utils/misc.py +++ b/pyrad/utils/misc.py @@ -21,9 +21,9 @@ import json from pydoc import locate from typing import Any, Dict +from math import floor, log import torch from omegaconf import DictConfig -from math import floor, log class DotDict(dict): @@ -98,4 +98,4 @@ def human_format(num): units = ["", "K", "M", "B", "T", "P"] k = 1000.0 magnitude = int(floor(log(num, k))) - return "%.2f %s" % (num / k**magnitude, units[magnitude]) + return f"{(num / k**magnitude):.2f} {units[magnitude]}"