Compatibility for numpy 2.0 (#3265)

* compat for numpy 2.0

* lint changes
This commit is contained in:
Justin Kerr authored and GitHub committed 2024-06-28 08:07:10 +09:00
1 parent 9b3cbc79bf
commit d6df39b70d
93 files changed
+104 -74

No files matched your search

+1
View File
@@ -15,6 +15,7 @@
"""
Camera Models
"""
import base64
import math
from dataclasses import dataclass
+1
View File
@@ -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
+3 -4
View File
@@ -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(
-1
View File
@@ -14,7 +14,6 @@
"""Base Configs"""
from __future__ import annotations
from dataclasses import dataclass, field
@@ -15,6 +15,7 @@
"""
Parallel data manager that generates training data in multiple python processes.
"""
from __future__ import annotations
import concurrent.futures
@@ -13,6 +13,7 @@
# limitations under the License.
"""Data parser for ARKitScenes dataset"""
import math
from dataclasses import dataclass, field
from pathlib import Path
@@ -13,6 +13,7 @@
# limitations under the License.
"""Data parser for blender dataset"""
from __future__ import annotations
from dataclasses import dataclass, field
@@ -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
@@ -13,6 +13,7 @@
# limitations under the License.
"""Data parser for blender dataset"""
from __future__ import annotations
from dataclasses import dataclass, field
@@ -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
@@ -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/
"""
@@ -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
@@ -13,6 +13,7 @@
# limitations under the License.
"""Data parser for NuScenes dataset"""
import math
import os
from dataclasses import dataclass, field
@@ -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
@@ -13,6 +13,7 @@
# limitations under the License.
"""Data parser for ScanNet dataset"""
import math
from dataclasses import dataclass, field
from pathlib import Path
@@ -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
+1
View File
@@ -15,6 +15,7 @@
"""
Dataset.
"""
from __future__ import annotations
from copy import deepcopy
+1
View File
@@ -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
+1 -1
View File
@@ -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
+1
View File
@@ -15,6 +15,7 @@
"""
Callback code used for training iterations
"""
from __future__ import annotations
from dataclasses import dataclass
+1
View File
@@ -15,6 +15,7 @@
"""
Optimizers class.
"""
from __future__ import annotations
from dataclasses import dataclass
+1
View File
@@ -15,6 +15,7 @@
"""
Code to train model.
"""
from __future__ import annotations
import dataclasses
-1
View File
@@ -16,7 +16,6 @@
Export utils such as structs, point cloud generation, and rendering code.
"""
from __future__ import annotations
import sys
-1
View File
@@ -16,7 +16,6 @@
Texture utils.
"""
from __future__ import annotations
import math
-1
View File
@@ -16,7 +16,6 @@
TSDF utils.
"""
from __future__ import annotations
from dataclasses import dataclass, field
+1
View File
@@ -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
@@ -15,6 +15,7 @@
"""
The field module baseclass.
"""
from abc import abstractmethod
from typing import Optional
-1
View File
@@ -16,7 +16,6 @@
Code for embeddings.
"""
import torch
from jaxtyping import Shaped
from torch import Tensor
@@ -15,6 +15,7 @@
"""
Collection of render heads
"""
from enum import Enum
from typing import Callable, Optional, Union
+1
View File
@@ -15,6 +15,7 @@
"""
Multi Layer Perceptron
"""
from typing import Literal, Optional, Set, Tuple, Union
import numpy as np
-1
View File
@@ -16,7 +16,6 @@
Proposal network field.
"""
from typing import Literal, Optional, Tuple
import torch
-1
View File
@@ -16,7 +16,6 @@
Field for Generfacto model
"""
from typing import Dict, Literal, Optional, Tuple
import numpy as np
-1
View File
@@ -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
+1
View File
@@ -15,6 +15,7 @@
"""
Semantic NeRF field implementation.
"""
from typing import Dict, Optional, Tuple
import torch
-1
View File
@@ -14,7 +14,6 @@
"""TensoRF Field"""
from typing import Dict, Optional
import torch
-1
View File
@@ -14,7 +14,6 @@
"""Classic NeRF field"""
from typing import Dict, Optional, Tuple, Type
import torch
+1
View File
@@ -15,6 +15,7 @@
"""
Collection of Losses.
"""
from enum import Enum
from typing import Dict, Literal, Optional, Tuple, cast
@@ -15,6 +15,7 @@
"""
Ray generator.
"""
from jaxtyping import Int
from torch import Tensor, nn
+1 -2
View File
@@ -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):
+1
View File
@@ -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
+1
View File
@@ -13,6 +13,7 @@
# limitations under the License.
"""Shaders for rendering."""
from typing import Optional
from jaxtyping import Float
+1
View File
@@ -15,6 +15,7 @@
"""
Implementation of mip-NeRF.
"""
from __future__ import annotations
from typing import Dict, List, Tuple
+1
View File
@@ -15,6 +15,7 @@
"""
Abstracts for the Pipeline class.
"""
from __future__ import annotations
import typing
+1
View File
@@ -15,6 +15,7 @@
"""
This package contains specifications used to register plugins.
"""
from dataclasses import dataclass
from nerfstudio.engine.trainer import TrainerConfig
+1
View File
@@ -14,6 +14,7 @@
#!/usr/bin/env python
"""Simple yaml debugger"""
import subprocess
import sys
@@ -13,6 +13,7 @@
# limitations under the License.
"""Download datasets and specific captures from the datasets."""
from __future__ import annotations
import json
+1
View File
@@ -16,6 +16,7 @@
"""
eval.py
"""
from __future__ import annotations
import json
-1
View File
@@ -16,7 +16,6 @@
Script for exporting NeRF into other formats.
"""
from __future__ import annotations
import json
+1
View File
@@ -14,6 +14,7 @@
#!/usr/bin/env python
"""Simple yaml debugger"""
import subprocess
import sys
+1 -2
View File
@@ -506,8 +506,7 @@ class ProcessODM(BaseConverterToNerfstudioDataset):
@dataclass
class NotInstalled:
def main(self) -> None:
...
def main(self) -> None: ...
Commands = Union[
+1
View File
@@ -16,6 +16,7 @@
"""
render.py
"""
from __future__ import annotations
import gzip
@@ -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
+1 -1
View File
@@ -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
+1
View File
@@ -13,6 +13,7 @@
# limitations under the License.
"""Common Colors"""
from typing import Union
import torch
+1
View File
@@ -13,6 +13,7 @@
# limitations under the License.
"""functionality to handle multiprocessing syncing and communicating"""
import torch.distributed as dist
LOCAL_PROCESS_GROUP = None
+1
View File
@@ -15,6 +15,7 @@
"""
Decorator definitions
"""
from typing import Callable, List
from nerfstudio.utils import comms
+1
View File
@@ -15,6 +15,7 @@
"""
Evaluation utils
"""
from __future__ import annotations
import os
+1 -1
View File
@@ -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
-1
View File
@@ -16,7 +16,6 @@
Miscellaneous helper code.
"""
import platform
import typing
import warnings
+3 -4
View File
@@ -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]]:
+1
View File
@@ -15,6 +15,7 @@
"""
Generic Writer class
"""
from __future__ import annotations
import enum
+2 -1
View File
@@ -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
+2 -1
View File
@@ -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
@@ -16,4 +16,5 @@
Resolves issues like: https://github.com/ayaanzhaque/instruct-nerf2nerf/pull/88
"""
from ..viewer_elements import * # noqa
+4 -8
View File
@@ -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:
@@ -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
@@ -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
+1 -1
View File
@@ -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
+1 -3
View File
@@ -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
@@ -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
+1 -2
View File
@@ -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
@@ -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:
@@ -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
@@ -14,6 +14,7 @@
"""Code to interface with the `vis/` (the JS viewer)."""
from __future__ import annotations
import os
+1 -2
View File
@@ -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
+2 -1
View File
@@ -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
+5 -10
View File
@@ -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,
+1 -2
View File
@@ -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