diff --git a/nerfstudio/viewer/utils.py b/nerfstudio/viewer/utils.py index c512e9169..0f5ead912 100644 --- a/nerfstudio/viewer/utils.py +++ b/nerfstudio/viewer/utils.py @@ -15,7 +15,8 @@ from __future__ import annotations from dataclasses import dataclass -from typing import Any, List, Literal, Optional, Tuple, Union +from functools import cached_property +from typing import Any, List, Literal, Optional, Tuple, Type, Union import numpy as np import torch @@ -109,7 +110,7 @@ def update_render_aabb( def parse_object( obj: Any, - type_check, + type_check: Type[Any], tree_stub: str, ) -> List[Tuple[str, Any]]: """ @@ -138,7 +139,8 @@ def parse_object( return [] ret = [] # get a list of the properties of the object, sorted by whether things are instances of type_check - obj_props = [(k, v) for k, v in vars(obj).items()] + # we skip cached properties, which can be expensive to call `getattr()` on! + obj_props = [(k, getattr(obj, k)) for k in dir(obj) if not isinstance(getattr(type(obj), k, None), cached_property)] for k, v in obj_props: if k[0] == "_": continue