diff --git a/nerfstudio/cameras/cameras.py b/nerfstudio/cameras/cameras.py index 614cd4a0d..cc04b1787 100644 --- a/nerfstudio/cameras/cameras.py +++ b/nerfstudio/cameras/cameras.py @@ -15,6 +15,7 @@ """ Camera Models """ + import base64 import math from dataclasses import dataclass diff --git a/nerfstudio/cameras/lie_groups.py b/nerfstudio/cameras/lie_groups.py index bba85d4de..c47ee1119 100644 --- a/nerfstudio/cameras/lie_groups.py +++ b/nerfstudio/cameras/lie_groups.py @@ -15,6 +15,7 @@ """ Helper for Lie group operations. Currently only used for pose optimization. """ + import torch from jaxtyping import Float from torch import Tensor diff --git a/nerfstudio/cameras/rays.py b/nerfstudio/cameras/rays.py index 33476f92e..a9c38d8e6 100644 --- a/nerfstudio/cameras/rays.py +++ b/nerfstudio/cameras/rays.py @@ -15,6 +15,7 @@ """ Some ray datastructures. """ + import random from dataclasses import dataclass, field from typing import Callable, Dict, Literal, Optional, Tuple, Union, overload @@ -153,15 +154,13 @@ class RaySamples(TensorDataclass): @staticmethod def get_weights_and_transmittance_from_alphas( alphas: Float[Tensor, "*batch num_samples 1"], weights_only: Literal[True] - ) -> Float[Tensor, "*batch num_samples 1"]: - ... + ) -> Float[Tensor, "*batch num_samples 1"]: ... @overload @staticmethod def get_weights_and_transmittance_from_alphas( alphas: Float[Tensor, "*batch num_samples 1"], weights_only: Literal[False] = False - ) -> Tuple[Float[Tensor, "*batch num_samples 1"], Float[Tensor, "*batch num_samples 1"]]: - ... + ) -> Tuple[Float[Tensor, "*batch num_samples 1"], Float[Tensor, "*batch num_samples 1"]]: ... @staticmethod def get_weights_and_transmittance_from_alphas( diff --git a/nerfstudio/configs/base_config.py b/nerfstudio/configs/base_config.py index f5ffddda9..e7f71d8ba 100644 --- a/nerfstudio/configs/base_config.py +++ b/nerfstudio/configs/base_config.py @@ -14,7 +14,6 @@ """Base Configs""" - from __future__ import annotations from dataclasses import dataclass, field diff --git a/nerfstudio/data/datamanagers/parallel_datamanager.py b/nerfstudio/data/datamanagers/parallel_datamanager.py index b28e530f9..0b56c988c 100644 --- a/nerfstudio/data/datamanagers/parallel_datamanager.py +++ b/nerfstudio/data/datamanagers/parallel_datamanager.py @@ -15,6 +15,7 @@ """ Parallel data manager that generates training data in multiple python processes. """ + from __future__ import annotations import concurrent.futures diff --git a/nerfstudio/data/dataparsers/arkitscenes_dataparser.py b/nerfstudio/data/dataparsers/arkitscenes_dataparser.py index 8dbd7d8bb..484424f3d 100644 --- a/nerfstudio/data/dataparsers/arkitscenes_dataparser.py +++ b/nerfstudio/data/dataparsers/arkitscenes_dataparser.py @@ -13,6 +13,7 @@ # limitations under the License. """Data parser for ARKitScenes dataset""" + import math from dataclasses import dataclass, field from pathlib import Path diff --git a/nerfstudio/data/dataparsers/blender_dataparser.py b/nerfstudio/data/dataparsers/blender_dataparser.py index 1027d7504..fa57f4d42 100644 --- a/nerfstudio/data/dataparsers/blender_dataparser.py +++ b/nerfstudio/data/dataparsers/blender_dataparser.py @@ -13,6 +13,7 @@ # limitations under the License. """Data parser for blender dataset""" + from __future__ import annotations from dataclasses import dataclass, field diff --git a/nerfstudio/data/dataparsers/colmap_dataparser.py b/nerfstudio/data/dataparsers/colmap_dataparser.py index b96d9b830..91169462b 100644 --- a/nerfstudio/data/dataparsers/colmap_dataparser.py +++ b/nerfstudio/data/dataparsers/colmap_dataparser.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" Data parser for nerfstudio datasets. """ +"""Data parser for nerfstudio datasets.""" from __future__ import annotations diff --git a/nerfstudio/data/dataparsers/dnerf_dataparser.py b/nerfstudio/data/dataparsers/dnerf_dataparser.py index 478b1fc38..7e890edff 100644 --- a/nerfstudio/data/dataparsers/dnerf_dataparser.py +++ b/nerfstudio/data/dataparsers/dnerf_dataparser.py @@ -13,6 +13,7 @@ # limitations under the License. """Data parser for blender dataset""" + from __future__ import annotations from dataclasses import dataclass, field diff --git a/nerfstudio/data/dataparsers/dycheck_dataparser.py b/nerfstudio/data/dataparsers/dycheck_dataparser.py index 90f5e9e97..c92cad339 100644 --- a/nerfstudio/data/dataparsers/dycheck_dataparser.py +++ b/nerfstudio/data/dataparsers/dycheck_dataparser.py @@ -13,6 +13,7 @@ # limitations under the License. """Data parser for DyCheck (https://arxiv.org/abs/2210.13445) dataset of `iphone` subset""" + from __future__ import annotations import math diff --git a/nerfstudio/data/dataparsers/nerfosr_dataparser.py b/nerfstudio/data/dataparsers/nerfosr_dataparser.py index db884cb73..a1ad87681 100644 --- a/nerfstudio/data/dataparsers/nerfosr_dataparser.py +++ b/nerfstudio/data/dataparsers/nerfosr_dataparser.py @@ -11,9 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" Data parser for NeRF-OSR datasets +"""Data parser for NeRF-OSR datasets - Presented in the paper: https://4dqv.mpi-inf.mpg.de/NeRF-OSR/ +Presented in the paper: https://4dqv.mpi-inf.mpg.de/NeRF-OSR/ """ diff --git a/nerfstudio/data/dataparsers/nerfstudio_dataparser.py b/nerfstudio/data/dataparsers/nerfstudio_dataparser.py index 910e0bc15..e11902c09 100644 --- a/nerfstudio/data/dataparsers/nerfstudio_dataparser.py +++ b/nerfstudio/data/dataparsers/nerfstudio_dataparser.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" Data parser for nerfstudio datasets. """ +"""Data parser for nerfstudio datasets.""" from __future__ import annotations diff --git a/nerfstudio/data/dataparsers/nuscenes_dataparser.py b/nerfstudio/data/dataparsers/nuscenes_dataparser.py index f1fecc888..69ec26315 100644 --- a/nerfstudio/data/dataparsers/nuscenes_dataparser.py +++ b/nerfstudio/data/dataparsers/nuscenes_dataparser.py @@ -13,6 +13,7 @@ # limitations under the License. """Data parser for NuScenes dataset""" + import math import os from dataclasses import dataclass, field diff --git a/nerfstudio/data/dataparsers/phototourism_dataparser.py b/nerfstudio/data/dataparsers/phototourism_dataparser.py index 538bad2f0..83c35bbb4 100644 --- a/nerfstudio/data/dataparsers/phototourism_dataparser.py +++ b/nerfstudio/data/dataparsers/phototourism_dataparser.py @@ -13,6 +13,7 @@ # limitations under the License. """Phototourism dataset parser. Datasets and documentation here: http://phototour.cs.washington.edu/datasets/""" + from __future__ import annotations import math diff --git a/nerfstudio/data/dataparsers/scannet_dataparser.py b/nerfstudio/data/dataparsers/scannet_dataparser.py index eb0c9ae19..73fcdcfe7 100644 --- a/nerfstudio/data/dataparsers/scannet_dataparser.py +++ b/nerfstudio/data/dataparsers/scannet_dataparser.py @@ -13,6 +13,7 @@ # limitations under the License. """Data parser for ScanNet dataset""" + import math from dataclasses import dataclass, field from pathlib import Path diff --git a/nerfstudio/data/dataparsers/scannetpp_dataparser.py b/nerfstudio/data/dataparsers/scannetpp_dataparser.py index 18afa4f42..3eed922e0 100644 --- a/nerfstudio/data/dataparsers/scannetpp_dataparser.py +++ b/nerfstudio/data/dataparsers/scannetpp_dataparser.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" Data parser for ScanNet++ datasets. """ +"""Data parser for ScanNet++ datasets.""" from __future__ import annotations diff --git a/nerfstudio/data/datasets/base_dataset.py b/nerfstudio/data/datasets/base_dataset.py index e16ea3348..449720bd3 100644 --- a/nerfstudio/data/datasets/base_dataset.py +++ b/nerfstudio/data/datasets/base_dataset.py @@ -15,6 +15,7 @@ """ Dataset. """ + from __future__ import annotations from copy import deepcopy diff --git a/nerfstudio/data/utils/data_utils.py b/nerfstudio/data/utils/data_utils.py index c81101c4f..11ce74d9d 100644 --- a/nerfstudio/data/utils/data_utils.py +++ b/nerfstudio/data/utils/data_utils.py @@ -13,6 +13,7 @@ # limitations under the License. """Utility functions to allow easy re-use of common operations across dataloaders""" + from pathlib import Path from typing import List, Tuple, Union diff --git a/nerfstudio/data/utils/dataparsers_utils.py b/nerfstudio/data/utils/dataparsers_utils.py index b48323f21..0c79cbde1 100644 --- a/nerfstudio/data/utils/dataparsers_utils.py +++ b/nerfstudio/data/utils/dataparsers_utils.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" Data parser utils for nerfstudio datasets. """ +"""Data parser utils for nerfstudio datasets.""" import math import os diff --git a/nerfstudio/engine/callbacks.py b/nerfstudio/engine/callbacks.py index f37cc7501..776fd829b 100644 --- a/nerfstudio/engine/callbacks.py +++ b/nerfstudio/engine/callbacks.py @@ -15,6 +15,7 @@ """ Callback code used for training iterations """ + from __future__ import annotations from dataclasses import dataclass diff --git a/nerfstudio/engine/optimizers.py b/nerfstudio/engine/optimizers.py index 0a8794786..830ac9a3a 100644 --- a/nerfstudio/engine/optimizers.py +++ b/nerfstudio/engine/optimizers.py @@ -15,6 +15,7 @@ """ Optimizers class. """ + from __future__ import annotations from dataclasses import dataclass diff --git a/nerfstudio/engine/trainer.py b/nerfstudio/engine/trainer.py index 0634f62e5..871e38375 100644 --- a/nerfstudio/engine/trainer.py +++ b/nerfstudio/engine/trainer.py @@ -15,6 +15,7 @@ """ Code to train model. """ + from __future__ import annotations import dataclasses diff --git a/nerfstudio/exporter/exporter_utils.py b/nerfstudio/exporter/exporter_utils.py index bad46f517..b87078bc9 100644 --- a/nerfstudio/exporter/exporter_utils.py +++ b/nerfstudio/exporter/exporter_utils.py @@ -16,7 +16,6 @@ Export utils such as structs, point cloud generation, and rendering code. """ - from __future__ import annotations import sys diff --git a/nerfstudio/exporter/texture_utils.py b/nerfstudio/exporter/texture_utils.py index 120696752..5859fcb47 100644 --- a/nerfstudio/exporter/texture_utils.py +++ b/nerfstudio/exporter/texture_utils.py @@ -16,7 +16,6 @@ Texture utils. """ - from __future__ import annotations import math diff --git a/nerfstudio/exporter/tsdf_utils.py b/nerfstudio/exporter/tsdf_utils.py index 301591316..9be7b3d9f 100644 --- a/nerfstudio/exporter/tsdf_utils.py +++ b/nerfstudio/exporter/tsdf_utils.py @@ -16,7 +16,6 @@ TSDF utils. """ - from __future__ import annotations from dataclasses import dataclass, field diff --git a/nerfstudio/field_components/__init__.py b/nerfstudio/field_components/__init__.py index 5f99dbcc8..365718aba 100644 --- a/nerfstudio/field_components/__init__.py +++ b/nerfstudio/field_components/__init__.py @@ -13,6 +13,7 @@ # limitations under the License. """init field modules""" + from .base_field_component import FieldComponent as FieldComponent from .encodings import Encoding as Encoding, ScalingAndOffset as ScalingAndOffset from .mlp import MLP as MLP diff --git a/nerfstudio/field_components/base_field_component.py b/nerfstudio/field_components/base_field_component.py index 8d84b782b..c961136c8 100644 --- a/nerfstudio/field_components/base_field_component.py +++ b/nerfstudio/field_components/base_field_component.py @@ -15,6 +15,7 @@ """ The field module baseclass. """ + from abc import abstractmethod from typing import Optional diff --git a/nerfstudio/field_components/embedding.py b/nerfstudio/field_components/embedding.py index cc934b099..4b568bbcb 100644 --- a/nerfstudio/field_components/embedding.py +++ b/nerfstudio/field_components/embedding.py @@ -16,7 +16,6 @@ Code for embeddings. """ - import torch from jaxtyping import Shaped from torch import Tensor diff --git a/nerfstudio/field_components/field_heads.py b/nerfstudio/field_components/field_heads.py index 44df9f602..7c86d7c5f 100644 --- a/nerfstudio/field_components/field_heads.py +++ b/nerfstudio/field_components/field_heads.py @@ -15,6 +15,7 @@ """ Collection of render heads """ + from enum import Enum from typing import Callable, Optional, Union diff --git a/nerfstudio/field_components/mlp.py b/nerfstudio/field_components/mlp.py index f1df2baa3..c27c7c996 100644 --- a/nerfstudio/field_components/mlp.py +++ b/nerfstudio/field_components/mlp.py @@ -15,6 +15,7 @@ """ Multi Layer Perceptron """ + from typing import Literal, Optional, Set, Tuple, Union import numpy as np diff --git a/nerfstudio/fields/density_fields.py b/nerfstudio/fields/density_fields.py index d4f6f28f6..e8eba7b9d 100644 --- a/nerfstudio/fields/density_fields.py +++ b/nerfstudio/fields/density_fields.py @@ -16,7 +16,6 @@ Proposal network field. """ - from typing import Literal, Optional, Tuple import torch diff --git a/nerfstudio/fields/generfacto_field.py b/nerfstudio/fields/generfacto_field.py index ee31bcb0b..d2597d9a5 100644 --- a/nerfstudio/fields/generfacto_field.py +++ b/nerfstudio/fields/generfacto_field.py @@ -16,7 +16,6 @@ Field for Generfacto model """ - from typing import Dict, Literal, Optional, Tuple import numpy as np diff --git a/nerfstudio/fields/nerfacto_field.py b/nerfstudio/fields/nerfacto_field.py index 52a4de4b3..5b3af8b55 100644 --- a/nerfstudio/fields/nerfacto_field.py +++ b/nerfstudio/fields/nerfacto_field.py @@ -16,7 +16,6 @@ Field for compound nerf model, adds scene contraction and image embeddings to instant ngp """ - from typing import Dict, Literal, Optional, Tuple import torch diff --git a/nerfstudio/fields/semantic_nerf_field.py b/nerfstudio/fields/semantic_nerf_field.py index 62b75094f..d36174472 100644 --- a/nerfstudio/fields/semantic_nerf_field.py +++ b/nerfstudio/fields/semantic_nerf_field.py @@ -15,6 +15,7 @@ """ Semantic NeRF field implementation. """ + from typing import Dict, Optional, Tuple import torch diff --git a/nerfstudio/fields/tensorf_field.py b/nerfstudio/fields/tensorf_field.py index b3aba4e54..a6c5b6c9e 100644 --- a/nerfstudio/fields/tensorf_field.py +++ b/nerfstudio/fields/tensorf_field.py @@ -14,7 +14,6 @@ """TensoRF Field""" - from typing import Dict, Optional import torch diff --git a/nerfstudio/fields/vanilla_nerf_field.py b/nerfstudio/fields/vanilla_nerf_field.py index efb3589eb..02565fbd9 100644 --- a/nerfstudio/fields/vanilla_nerf_field.py +++ b/nerfstudio/fields/vanilla_nerf_field.py @@ -14,7 +14,6 @@ """Classic NeRF field""" - from typing import Dict, Optional, Tuple, Type import torch diff --git a/nerfstudio/model_components/losses.py b/nerfstudio/model_components/losses.py index d46466989..7ec87a388 100644 --- a/nerfstudio/model_components/losses.py +++ b/nerfstudio/model_components/losses.py @@ -15,6 +15,7 @@ """ Collection of Losses. """ + from enum import Enum from typing import Dict, Literal, Optional, Tuple, cast diff --git a/nerfstudio/model_components/ray_generators.py b/nerfstudio/model_components/ray_generators.py index fab9e39bb..33ab2c8d1 100644 --- a/nerfstudio/model_components/ray_generators.py +++ b/nerfstudio/model_components/ray_generators.py @@ -15,6 +15,7 @@ """ Ray generator. """ + from jaxtyping import Int from torch import Tensor, nn diff --git a/nerfstudio/model_components/ray_samplers.py b/nerfstudio/model_components/ray_samplers.py index 7a2052b63..e0d15db92 100644 --- a/nerfstudio/model_components/ray_samplers.py +++ b/nerfstudio/model_components/ray_samplers.py @@ -379,8 +379,7 @@ class DensityFn(Protocol): def __call__( self, positions: Float[Tensor, "*batch 3"], times: Optional[Float[Tensor, "*batch 1"]] = None - ) -> Float[Tensor, "*batch 1"]: - ... + ) -> Float[Tensor, "*batch 1"]: ... class VolumetricSampler(Sampler): diff --git a/nerfstudio/model_components/renderers.py b/nerfstudio/model_components/renderers.py index 1fde0d693..1f3ee1749 100644 --- a/nerfstudio/model_components/renderers.py +++ b/nerfstudio/model_components/renderers.py @@ -26,6 +26,7 @@ Example: rgb = rgb_renderer(rgb=field_outputs[FieldHeadNames.RGB], weights=weights) """ + import contextlib import math from typing import Generator, Literal, Optional, Tuple, Union diff --git a/nerfstudio/model_components/shaders.py b/nerfstudio/model_components/shaders.py index f6cc22721..015dbfd41 100644 --- a/nerfstudio/model_components/shaders.py +++ b/nerfstudio/model_components/shaders.py @@ -13,6 +13,7 @@ # limitations under the License. """Shaders for rendering.""" + from typing import Optional from jaxtyping import Float diff --git a/nerfstudio/models/mipnerf.py b/nerfstudio/models/mipnerf.py index e033681f7..503fb4b03 100644 --- a/nerfstudio/models/mipnerf.py +++ b/nerfstudio/models/mipnerf.py @@ -15,6 +15,7 @@ """ Implementation of mip-NeRF. """ + from __future__ import annotations from typing import Dict, List, Tuple diff --git a/nerfstudio/pipelines/base_pipeline.py b/nerfstudio/pipelines/base_pipeline.py index 731f214e7..23797a154 100644 --- a/nerfstudio/pipelines/base_pipeline.py +++ b/nerfstudio/pipelines/base_pipeline.py @@ -15,6 +15,7 @@ """ Abstracts for the Pipeline class. """ + from __future__ import annotations import typing diff --git a/nerfstudio/plugins/types.py b/nerfstudio/plugins/types.py index cfdb54b55..7ad878f18 100644 --- a/nerfstudio/plugins/types.py +++ b/nerfstudio/plugins/types.py @@ -15,6 +15,7 @@ """ This package contains specifications used to register plugins. """ + from dataclasses import dataclass from nerfstudio.engine.trainer import TrainerConfig diff --git a/nerfstudio/scripts/docs/build_docs.py b/nerfstudio/scripts/docs/build_docs.py index 3d060670b..ff7c57677 100644 --- a/nerfstudio/scripts/docs/build_docs.py +++ b/nerfstudio/scripts/docs/build_docs.py @@ -14,6 +14,7 @@ #!/usr/bin/env python """Simple yaml debugger""" + import subprocess import sys diff --git a/nerfstudio/scripts/downloads/download_data.py b/nerfstudio/scripts/downloads/download_data.py index 4d89c1b48..cb0865119 100644 --- a/nerfstudio/scripts/downloads/download_data.py +++ b/nerfstudio/scripts/downloads/download_data.py @@ -13,6 +13,7 @@ # limitations under the License. """Download datasets and specific captures from the datasets.""" + from __future__ import annotations import json diff --git a/nerfstudio/scripts/eval.py b/nerfstudio/scripts/eval.py index 103467bbd..64b440350 100644 --- a/nerfstudio/scripts/eval.py +++ b/nerfstudio/scripts/eval.py @@ -16,6 +16,7 @@ """ eval.py """ + from __future__ import annotations import json diff --git a/nerfstudio/scripts/exporter.py b/nerfstudio/scripts/exporter.py index 7d90e0708..5ae603700 100644 --- a/nerfstudio/scripts/exporter.py +++ b/nerfstudio/scripts/exporter.py @@ -16,7 +16,6 @@ Script for exporting NeRF into other formats. """ - from __future__ import annotations import json diff --git a/nerfstudio/scripts/github/run_actions.py b/nerfstudio/scripts/github/run_actions.py index 2fa3aa54c..289876768 100644 --- a/nerfstudio/scripts/github/run_actions.py +++ b/nerfstudio/scripts/github/run_actions.py @@ -14,6 +14,7 @@ #!/usr/bin/env python """Simple yaml debugger""" + import subprocess import sys diff --git a/nerfstudio/scripts/process_data.py b/nerfstudio/scripts/process_data.py index 7a0968af5..5e1d869f3 100644 --- a/nerfstudio/scripts/process_data.py +++ b/nerfstudio/scripts/process_data.py @@ -506,8 +506,7 @@ class ProcessODM(BaseConverterToNerfstudioDataset): @dataclass class NotInstalled: - def main(self) -> None: - ... + def main(self) -> None: ... Commands = Union[ diff --git a/nerfstudio/scripts/render.py b/nerfstudio/scripts/render.py index c2d6d83ce..60bcaa9eb 100644 --- a/nerfstudio/scripts/render.py +++ b/nerfstudio/scripts/render.py @@ -16,6 +16,7 @@ """ render.py """ + from __future__ import annotations import gzip diff --git a/nerfstudio/scripts/viewer/sync_viser_message_defs.py b/nerfstudio/scripts/viewer/sync_viser_message_defs.py index a178aae4c..3b3e2ea5b 100644 --- a/nerfstudio/scripts/viewer/sync_viser_message_defs.py +++ b/nerfstudio/scripts/viewer/sync_viser_message_defs.py @@ -13,6 +13,7 @@ # limitations under the License. """Generate viser message definitions for TypeScript, by parsing Python dataclasses.""" + import json import pathlib from datetime import datetime diff --git a/nerfstudio/utils/colormaps.py b/nerfstudio/utils/colormaps.py index 4d5284e77..0a790e123 100644 --- a/nerfstudio/utils/colormaps.py +++ b/nerfstudio/utils/colormaps.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Helper functions for visualizing outputs """ +"""Helper functions for visualizing outputs""" from dataclasses import dataclass from typing import Literal, Optional diff --git a/nerfstudio/utils/colors.py b/nerfstudio/utils/colors.py index 66ac8d243..1208659bc 100644 --- a/nerfstudio/utils/colors.py +++ b/nerfstudio/utils/colors.py @@ -13,6 +13,7 @@ # limitations under the License. """Common Colors""" + from typing import Union import torch diff --git a/nerfstudio/utils/comms.py b/nerfstudio/utils/comms.py index 03aa44581..0a3880cff 100644 --- a/nerfstudio/utils/comms.py +++ b/nerfstudio/utils/comms.py @@ -13,6 +13,7 @@ # limitations under the License. """functionality to handle multiprocessing syncing and communicating""" + import torch.distributed as dist LOCAL_PROCESS_GROUP = None diff --git a/nerfstudio/utils/decorators.py b/nerfstudio/utils/decorators.py index cc78be8a5..9e439e703 100644 --- a/nerfstudio/utils/decorators.py +++ b/nerfstudio/utils/decorators.py @@ -15,6 +15,7 @@ """ Decorator definitions """ + from typing import Callable, List from nerfstudio.utils import comms diff --git a/nerfstudio/utils/eval_utils.py b/nerfstudio/utils/eval_utils.py index 2c4bfcd15..11a8b2341 100644 --- a/nerfstudio/utils/eval_utils.py +++ b/nerfstudio/utils/eval_utils.py @@ -15,6 +15,7 @@ """ Evaluation utils """ + from __future__ import annotations import os diff --git a/nerfstudio/utils/math.py b/nerfstudio/utils/math.py index 0ba9e6a51..d71907bee 100644 --- a/nerfstudio/utils/math.py +++ b/nerfstudio/utils/math.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Math Helper Functions """ +"""Math Helper Functions""" import itertools import math diff --git a/nerfstudio/utils/misc.py b/nerfstudio/utils/misc.py index ae3c4d557..f55e1259a 100644 --- a/nerfstudio/utils/misc.py +++ b/nerfstudio/utils/misc.py @@ -16,7 +16,6 @@ Miscellaneous helper code. """ - import platform import typing import warnings diff --git a/nerfstudio/utils/profiler.py b/nerfstudio/utils/profiler.py index ff0ae5bb9..b3046aa73 100644 --- a/nerfstudio/utils/profiler.py +++ b/nerfstudio/utils/profiler.py @@ -15,6 +15,7 @@ """ Profiler base class and functionality """ + from __future__ import annotations import functools @@ -41,13 +42,11 @@ CallableT = TypeVar("CallableT", bound=Callable) @overload -def time_function(name_or_func: CallableT) -> CallableT: - ... +def time_function(name_or_func: CallableT) -> CallableT: ... @overload -def time_function(name_or_func: str) -> ContextManager[Any]: - ... +def time_function(name_or_func: str) -> ContextManager[Any]: ... def time_function(name_or_func: Union[CallableT, str]) -> Union[CallableT, ContextManager[Any]]: diff --git a/nerfstudio/utils/writer.py b/nerfstudio/utils/writer.py index d460e9411..a986618ca 100644 --- a/nerfstudio/utils/writer.py +++ b/nerfstudio/utils/writer.py @@ -15,6 +15,7 @@ """ Generic Writer class """ + from __future__ import annotations import enum diff --git a/nerfstudio/viewer/control_panel.py b/nerfstudio/viewer/control_panel.py index 6524c5309..63209fcc7 100644 --- a/nerfstudio/viewer/control_panel.py +++ b/nerfstudio/viewer/control_panel.py @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Control panel for the viewer """ +"""Control panel for the viewer""" + from collections import defaultdict from typing import Callable, DefaultDict, List, Tuple, get_args diff --git a/nerfstudio/viewer/render_state_machine.py b/nerfstudio/viewer/render_state_machine.py index c95064464..07c74f220 100644 --- a/nerfstudio/viewer/render_state_machine.py +++ b/nerfstudio/viewer/render_state_machine.py @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" This file contains the render state machine, which is responsible for deciding when to render the image """ +"""This file contains the render state machine, which is responsible for deciding when to render the image""" + from __future__ import annotations import contextlib diff --git a/nerfstudio/viewer/server/viewer_elements.py b/nerfstudio/viewer/server/viewer_elements.py index 2689e432b..597c89c01 100644 --- a/nerfstudio/viewer/server/viewer_elements.py +++ b/nerfstudio/viewer/server/viewer_elements.py @@ -16,4 +16,5 @@ Resolves issues like: https://github.com/ayaanzhaque/instruct-nerf2nerf/pull/88 """ + from ..viewer_elements import * # noqa diff --git a/nerfstudio/viewer/viewer_elements.py b/nerfstudio/viewer/viewer_elements.py index 654503a3c..1d0ffd466 100644 --- a/nerfstudio/viewer/viewer_elements.py +++ b/nerfstudio/viewer/viewer_elements.py @@ -13,8 +13,7 @@ # limitations under the License. -""" Viewer GUI elements for the nerfstudio viewer """ - +"""Viewer GUI elements for the nerfstudio viewer""" from __future__ import annotations @@ -172,8 +171,7 @@ class ViewerControl: event_type: Literal["click"], cb: Callable[[ViewerClick], None], removed_cb: Optional[Callable[[], None]] = None, - ): - ... + ): ... @overload def register_pointer_cb( @@ -181,8 +179,7 @@ class ViewerControl: event_type: Literal["rect-select"], cb: Callable[[ViewerRectSelect], None], removed_cb: Optional[Callable[[], None]] = None, - ): - ... + ): ... def register_pointer_cb( self, @@ -388,8 +385,7 @@ class ViewerParameter(ViewerElement[TValue], Generic[TValue]): self.gui_handle.on_update(lambda _: self.cb_hook(self)) @abstractmethod - def _create_gui_handle(self, viser_server: ViserServer) -> None: - ... + def _create_gui_handle(self, viser_server: ViserServer) -> None: ... @property def value(self) -> TValue: diff --git a/nerfstudio/viewer_legacy/app/run_deploy.py b/nerfstudio/viewer_legacy/app/run_deploy.py index 8a5fce02d..6f1f9c38d 100644 --- a/nerfstudio/viewer_legacy/app/run_deploy.py +++ b/nerfstudio/viewer_legacy/app/run_deploy.py @@ -16,6 +16,7 @@ Code for deploying the built viewer folder to a server and handing versioning. We use the library sshconf (https://github.com/sorend/sshconf) for working with the ssh config file. """ + import json import subprocess from os.path import expanduser diff --git a/nerfstudio/viewer_legacy/server/control_panel.py b/nerfstudio/viewer_legacy/server/control_panel.py index 43fb51b46..f2caa793e 100644 --- a/nerfstudio/viewer_legacy/server/control_panel.py +++ b/nerfstudio/viewer_legacy/server/control_panel.py @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Control panel for the viewer """ +"""Control panel for the viewer""" + from collections import defaultdict from typing import Callable, DefaultDict, List, Tuple, get_args diff --git a/nerfstudio/viewer_legacy/server/gui_utils.py b/nerfstudio/viewer_legacy/server/gui_utils.py index cd17172cb..2bd34e1be 100644 --- a/nerfstudio/viewer_legacy/server/gui_utils.py +++ b/nerfstudio/viewer_legacy/server/gui_utils.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Utilities for generating custom gui elements in the viewer """ +"""Utilities for generating custom gui elements in the viewer""" from __future__ import annotations diff --git a/nerfstudio/viewer_legacy/server/path.py b/nerfstudio/viewer_legacy/server/path.py index 1dc8bdfea..12494e5d0 100644 --- a/nerfstudio/viewer_legacy/server/path.py +++ b/nerfstudio/viewer_legacy/server/path.py @@ -12,9 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Path class -""" - +"""Path class""" from typing import Tuple diff --git a/nerfstudio/viewer_legacy/server/render_state_machine.py b/nerfstudio/viewer_legacy/server/render_state_machine.py index a3c052490..9b27cf361 100644 --- a/nerfstudio/viewer_legacy/server/render_state_machine.py +++ b/nerfstudio/viewer_legacy/server/render_state_machine.py @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" This file contains the render state machine, which is responsible for deciding when to render the image """ +"""This file contains the render state machine, which is responsible for deciding when to render the image""" + from __future__ import annotations import contextlib diff --git a/nerfstudio/viewer_legacy/server/utils.py b/nerfstudio/viewer_legacy/server/utils.py index 0b26741db..7f49aeec7 100644 --- a/nerfstudio/viewer_legacy/server/utils.py +++ b/nerfstudio/viewer_legacy/server/utils.py @@ -12,8 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Generic utility functions -""" +"""Generic utility functions""" from typing import List, Optional, Tuple, Union diff --git a/nerfstudio/viewer_legacy/server/viewer_elements.py b/nerfstudio/viewer_legacy/server/viewer_elements.py index b8065f886..a8562d5b8 100644 --- a/nerfstudio/viewer_legacy/server/viewer_elements.py +++ b/nerfstudio/viewer_legacy/server/viewer_elements.py @@ -13,8 +13,7 @@ # limitations under the License. -""" Viewer GUI elements for the nerfstudio viewer """ - +"""Viewer GUI elements for the nerfstudio viewer""" from __future__ import annotations @@ -263,8 +262,7 @@ class ViewerParameter(ViewerElement[TValue], Generic[TValue]): self.gui_handle.on_update(lambda _: self.cb_hook(self)) @abstractmethod - def _create_gui_handle(self, viser_server: ViserServer) -> None: - ... + def _create_gui_handle(self, viser_server: ViserServer) -> None: ... @property def value(self) -> TValue: diff --git a/nerfstudio/viewer_legacy/server/viewer_state.py b/nerfstudio/viewer_legacy/server/viewer_state.py index ee02d2a4b..cfb3bff7b 100644 --- a/nerfstudio/viewer_legacy/server/viewer_state.py +++ b/nerfstudio/viewer_legacy/server/viewer_state.py @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Manage the state of the viewer """ +"""Manage the state of the viewer""" + from __future__ import annotations import threading diff --git a/nerfstudio/viewer_legacy/server/viewer_utils.py b/nerfstudio/viewer_legacy/server/viewer_utils.py index 3a2c01608..6e3b28e86 100644 --- a/nerfstudio/viewer_legacy/server/viewer_utils.py +++ b/nerfstudio/viewer_legacy/server/viewer_utils.py @@ -14,6 +14,7 @@ """Code to interface with the `vis/` (the JS viewer).""" + from __future__ import annotations import os diff --git a/nerfstudio/viewer_legacy/viser/__init__.py b/nerfstudio/viewer_legacy/viser/__init__.py index 7560a4cc8..228d65888 100644 --- a/nerfstudio/viewer_legacy/viser/__init__.py +++ b/nerfstudio/viewer_legacy/viser/__init__.py @@ -12,8 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Viser is used for the nerfstudio viewer backend """ - +"""Viser is used for the nerfstudio viewer backend""" from .message_api import GuiHandle as GuiHandle, GuiSelectHandle as GuiSelectHandle from .messages import NerfstudioMessage as NerfstudioMessage diff --git a/nerfstudio/viewer_legacy/viser/gui.py b/nerfstudio/viewer_legacy/viser/gui.py index 75c18deca..11536db3f 100644 --- a/nerfstudio/viewer_legacy/viser/gui.py +++ b/nerfstudio/viewer_legacy/viser/gui.py @@ -13,10 +13,11 @@ # limitations under the License. -""" Manages GUI communication. +"""Manages GUI communication. Should be almost identical to: https://github.com/brentyi/viser/blob/main/viser/_gui.py """ + from __future__ import annotations import dataclasses diff --git a/nerfstudio/viewer_legacy/viser/message_api.py b/nerfstudio/viewer_legacy/viser/message_api.py index bb6449cf8..982c41fcc 100644 --- a/nerfstudio/viewer_legacy/viser/message_api.py +++ b/nerfstudio/viewer_legacy/viser/message_api.py @@ -12,8 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" This module contains the MessageApi class, which is the interface for sending messages to the Viewer""" - +"""This module contains the MessageApi class, which is the interface for sending messages to the Viewer""" from __future__ import annotations @@ -274,8 +273,7 @@ class MessageApi(abc.ABC): options: List[TLiteralString], initial_value: Optional[TLiteralString] = None, hint: Optional[str] = None, - ) -> GuiSelectHandle[TLiteralString]: - ... + ) -> GuiSelectHandle[TLiteralString]: ... @overload def add_gui_select( @@ -284,8 +282,7 @@ class MessageApi(abc.ABC): options: List[str], initial_value: Optional[str] = None, hint: Optional[str] = None, - ) -> GuiSelectHandle[str]: - ... + ) -> GuiSelectHandle[str]: ... def add_gui_select( self, @@ -325,8 +322,7 @@ class MessageApi(abc.ABC): name: str, options: List[TLiteralString], initial_value: Optional[TLiteralString] = None, - ) -> GuiHandle[TLiteralString]: - ... + ) -> GuiHandle[TLiteralString]: ... @overload def add_gui_button_group( @@ -334,8 +330,7 @@ class MessageApi(abc.ABC): name: str, options: List[str], initial_value: Optional[str] = None, - ) -> GuiHandle[str]: - ... + ) -> GuiHandle[str]: ... def add_gui_button_group( self, diff --git a/nerfstudio/viewer_legacy/viser/server.py b/nerfstudio/viewer_legacy/viser/server.py index 31b1a78a5..5bbb1f9aa 100644 --- a/nerfstudio/viewer_legacy/viser/server.py +++ b/nerfstudio/viewer_legacy/viser/server.py @@ -12,8 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Core Viser Server """ - +"""Core Viser Server""" from __future__ import annotations diff --git a/pyproject.toml b/pyproject.toml index a5b3d39fc..b7998309b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ "msgpack_numpy>=0.4.8", "nerfacc==0.5.2", "open3d>=0.16.0", - "opencv-python==4.8.0.76", + "opencv-python==4.10.0.84", "Pillow>=10.3.0", "plotly>=5.7.0", "protobuf<=3.20.3,!=3.20.0", @@ -92,7 +92,7 @@ dev = [ "pytest==7.1.2", "pytest-xdist==2.5.0", "typeguard==2.13.3", - "ruff==0.1.13", + "ruff>=0.4.8", "sshconf==0.2.5", "pycolmap>=0.3.0", # NOTE: pycolmap==0.3.0 is not available on newer python versions "diffusers==0.16.1", @@ -165,7 +165,7 @@ pythonPlatform = "Linux" [tool.ruff] line-length = 120 respect-gitignore = false -select = [ +lint.select = [ "E", # pycodestyle errors. "F", # Pyflakes rules. "I", # isort formatting. @@ -173,8 +173,9 @@ select = [ "PLE", # Pylint errors. "PLR", # Pylint refactor recommendations. "PLW", # Pylint warnings. + "NPY201" # NumPY 2.0 migration https://numpy.org/devdocs/numpy_2_0_migration_guide.html#ruff-plugin ] -ignore = [ +lint.ignore = [ "E501", # Line too long. "F722", # Forward annotation false positive from jaxtyping. Should be caught by pyright. "F821", # Forward annotation false positive from jaxtyping. Should be caught by pyright. diff --git a/tests/cameras/test_cameras.py b/tests/cameras/test_cameras.py index 2c7d0b840..99f79da3f 100644 --- a/tests/cameras/test_cameras.py +++ b/tests/cameras/test_cameras.py @@ -1,6 +1,7 @@ """ Test the camera classes. """ + import dataclasses from itertools import product diff --git a/tests/field_components/test_embedding.py b/tests/field_components/test_embedding.py index 11ba7d5a9..569773745 100644 --- a/tests/field_components/test_embedding.py +++ b/tests/field_components/test_embedding.py @@ -1,6 +1,7 @@ """ Embedding tests """ + from nerfstudio.field_components.embedding import Embedding diff --git a/tests/field_components/test_encodings.py b/tests/field_components/test_encodings.py index a7dbb7f2c..a241fc52a 100644 --- a/tests/field_components/test_encodings.py +++ b/tests/field_components/test_encodings.py @@ -1,6 +1,7 @@ """ Encoding Tests """ + import pytest import torch diff --git a/tests/field_components/test_field_outputs.py b/tests/field_components/test_field_outputs.py index 08aa236a2..8a585d86c 100644 --- a/tests/field_components/test_field_outputs.py +++ b/tests/field_components/test_field_outputs.py @@ -1,6 +1,7 @@ """ Field output tests """ + import pytest import torch from torch import nn diff --git a/tests/field_components/test_fields.py b/tests/field_components/test_fields.py index fd5332776..95d6239f7 100644 --- a/tests/field_components/test_fields.py +++ b/tests/field_components/test_fields.py @@ -1,6 +1,7 @@ """ Test the fields """ + import torch from nerfstudio.cameras.rays import Frustums, RaySamples diff --git a/tests/field_components/test_mlp.py b/tests/field_components/test_mlp.py index b52734654..92a69d93e 100644 --- a/tests/field_components/test_mlp.py +++ b/tests/field_components/test_mlp.py @@ -1,6 +1,7 @@ """ MLP Test """ + import torch from torch import nn diff --git a/tests/field_components/test_temporal_distortions.py b/tests/field_components/test_temporal_distortions.py index 8d5abd191..24934da0d 100644 --- a/tests/field_components/test_temporal_distortions.py +++ b/tests/field_components/test_temporal_distortions.py @@ -1,6 +1,7 @@ """ Test if temporal distortions run properly """ + import torch from nerfstudio.field_components.temporal_distortions import DNeRFDistortion diff --git a/tests/model_components/test_renderers.py b/tests/model_components/test_renderers.py index a1e098388..79d5e54a2 100644 --- a/tests/model_components/test_renderers.py +++ b/tests/model_components/test_renderers.py @@ -1,6 +1,7 @@ """ Test renderers """ + import pytest import torch diff --git a/tests/pipelines/test_vanilla_pipeline.py b/tests/pipelines/test_vanilla_pipeline.py index 3bb73e06a..322c67b16 100644 --- a/tests/pipelines/test_vanilla_pipeline.py +++ b/tests/pipelines/test_vanilla_pipeline.py @@ -1,6 +1,7 @@ """ Test pipeline """ + from pathlib import Path import torch diff --git a/tests/plugins/test_registry.py b/tests/plugins/test_registry.py index c17d88e15..ae704be4c 100644 --- a/tests/plugins/test_registry.py +++ b/tests/plugins/test_registry.py @@ -1,6 +1,7 @@ """ Tests for the nerfstudio.plugins.registry module. """ + import os import sys from dataclasses import dataclass, field diff --git a/tests/process_data/test_process_images.py b/tests/process_data/test_process_images.py index fd506b1fb..b27346c68 100644 --- a/tests/process_data/test_process_images.py +++ b/tests/process_data/test_process_images.py @@ -1,6 +1,7 @@ """ Process images test """ + import os from pathlib import Path diff --git a/tests/utils/test_aabb_intersection.py b/tests/utils/test_aabb_intersection.py index 625ae6edb..c0c916938 100644 --- a/tests/utils/test_aabb_intersection.py +++ b/tests/utils/test_aabb_intersection.py @@ -1,6 +1,7 @@ """ Test AABB intersection """ + import importlib import math import os diff --git a/tests/utils/test_tensor_dataclass.py b/tests/utils/test_tensor_dataclass.py index 10e21adc0..a884d7c05 100644 --- a/tests/utils/test_tensor_dataclass.py +++ b/tests/utils/test_tensor_dataclass.py @@ -1,6 +1,7 @@ """ Test tensor dataclass """ + from dataclasses import dataclass, field from typing import Generic, Optional, TypeVar diff --git a/tests/utils/test_visualization.py b/tests/utils/test_visualization.py index b3d9f53d1..fa1b31be6 100644 --- a/tests/utils/test_visualization.py +++ b/tests/utils/test_visualization.py @@ -1,6 +1,7 @@ """ Test colormaps """ + import torch from nerfstudio.utils import colormaps, plotly_utils